UNPKG

rawi

Version:

Rawi (راوي) is the developer-friendly AI CLI that brings the power of 12 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into

4 lines 3.61 kB
/* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 12 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into an intelligent development workspace. */ import{c as d,d as o,e as i}from"./chunk-TXXQXILX.js";import{a as l}from"./chunk-C3TRDJRW.js";import{a as c}from"./chunk-SSJ4P3F5.js";import{a as n}from"./chunk-MRVNIX7F.js";var p=class{readers;options;batchProcessor;constructor(e={}){this.options={enableFallback:!0,...e},this.readers=new Map,this.initializeReaders(),this.batchProcessor=new n(this)}initializeReaders(){let e=new l(this.options),r=["pdf","docx","pptx","xlsx","odt","odp","ods"];for(let a of r)this.readers.set(a,e);let t=new c(this.options),s=["txt","md","xml","html","htm","js","jsx","ts","tsx","css","json","py","java","cpp","c","h","go","rs","rb","kt","swift","dart","scala","r","m","pl","lua","php","yml","yaml","toml","env","ini","conf","cfg","sql","sh","bash","vim","dockerfile","makefile","gitignore","log"];for(let a of s)this.readers.set(a,t)}async readFile(e){try{let r=await this.determineFileType(e);if(!o(r))return{success:!1,error:`Unsupported file type: ${i(r)}. Supported formats include office documents (PDF, DOCX, PPTX, XLSX, ODT, ODP, ODS), programming languages (JS, TS, Python, Java, C/C++, Go, Rust, etc.), configuration files (YAML, JSON, TOML, etc.), and many more.`};let t=this.getReader(r);if(!t)return{success:!1,error:`No reader available for file type: ${i(r)}`};this.logVerbose(`Using ${t.constructor.name} for ${i(r)}`);let s=await t.read(e);return s.success&&s.content&&(s.content.metadata.additionalInfo={...s.content.metadata.additionalInfo,detectedFileType:r,readerUsed:t.constructor.name}),s}catch(r){return{success:!1,error:`File reading failed: ${r instanceof Error?r.message:String(r)}`}}}async readFiles(e){let r=[];for(let t of e){let s=await this.readFile(t);r.push(s)}return r}async readFilesParallel(e){let r=e.map(t=>this.readFile(t));return Promise.all(r)}async canReadFile(e){try{let r=await this.determineFileType(e);return o(r)&&this.readers.has(r)}catch{return!1}}async getFileInfo(e){let r=await this.determineFileType(e);return{filePath:e,fileType:r,description:i(r),supported:o(r),readerAvailable:this.readers.has(r)}}getSupportedFileTypes(){return Array.from(this.readers.keys())}registerReader(e,r){this.readers.set(e,r),this.logVerbose(`Registered custom reader for ${i(e)}`)}updateOptions(e){this.options={...this.options,...e},this.initializeReaders(),this.batchProcessor=new n(this),this.logVerbose("Updated reader options and reinitialized readers")}async processMultipleFiles(e,r={}){return this.batchProcessor.processFiles(e,r)}async processGlobPatterns(e,r={}){return this.batchProcessor.processGlobPatterns(e,r)}async expandGlob(e,r={}){return this.batchProcessor.expandGlobPatterns(e,r)}async filterSupportedFiles(e){return this.batchProcessor.filterSupportedFiles(e)}async determineFileType(e){return this.options.forceFileType?this.options.forceFileType:(await d(e)).fileType}getReader(e){return this.readers.get(e)}logVerbose(e){this.options.verbose&&console.log(`[FileReaderManager] ${e}`)}},T=new p;export{p as a,T as b}; /* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 12 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into an intelligent development workspace. */ //# sourceMappingURL=chunk-MPDXSLZB.js.map