UNPKG

rawi

Version:

Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 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.29 kB
/* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 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{a as p}from"./chunk-I53R2YNN.js";import{a as c}from"./chunk-VRKU5YYZ.js";import{a as n}from"./chunk-PT5U2YR3.js";import{c as d,d as o,e as i}from"./chunk-LYW4VAAJ.js";var l=class{#e;#t;#r;constructor(e={}){this.#t={enableFallback:!0,...e},this.#e=new Map,this.#o(),this.#r=new n(this)}#o(){let e=new p(this.#t),t=["pdf","docx","pptx","xlsx","odt","odp","ods"];for(let a of t)this.#e.set(a,e);let r=new c(this.#t),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","csv","toml","env","ini","conf","cfg","sql","sh","bash","vim","dockerfile","makefile","gitignore","log"];for(let a of s)this.#e.set(a,r)}async readFile(e){try{let t=await this.#s(e);if(!o(t))return{success:!1,error:`Unsupported file type: ${i(t)}. 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 r=this.#a(t);if(!r)return{success:!1,error:`No reader available for file type: ${i(t)}`};this.#i(`Using ${r.constructor.name} for ${i(t)}`);let s=await r.read(e);return s.success&&s.content&&(s.content.metadata.additionalInfo={...s.content.metadata.additionalInfo,detectedFileType:t,readerUsed:r.constructor.name}),s}catch(t){return{success:!1,error:`File reading failed: ${t instanceof Error?t.message:String(t)}`}}}async readFiles(e){let t=[];for(let r of e){let s=await this.readFile(r);t.push(s)}return t}async readFilesParallel(e){let t=e.map(r=>this.readFile(r));return Promise.all(t)}async canReadFile(e){try{let t=await this.#s(e);return o(t)&&this.#e.has(t)}catch{return!1}}async getFileInfo(e){let t=await this.#s(e);return{filePath:e,fileType:t,description:i(t),supported:o(t),readerAvailable:this.#e.has(t)}}getSupportedFileTypes(){return Array.from(this.#e.keys())}registerReader(e,t){this.#e.set(e,t),this.#i(`Registered custom reader for ${i(e)}`)}updateOptions(e){this.#t={...this.#t,...e},this.#o(),this.#r=new n(this),this.#i("Updated reader options and reinitialized readers")}async processMultipleFiles(e,t={}){return this.#r.processFiles(e,t)}async processGlobPatterns(e,t={}){return this.#r.processGlobPatterns(e,t)}async expandGlob(e,t={}){return this.#r.expandGlobPatterns(e,t)}async filterSupportedFiles(e){return this.#r.filterSupportedFiles(e)}async#s(e){return this.#t.forceFileType?this.#t.forceFileType:(await d(e)).fileType}#a(e){return this.#e.get(e)}#i(e){this.#t.verbose&&console.log(`[FileReaderManager] ${e}`)}},g=new l;export{l as a,g as b}; /* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 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-VRNK6ZGU.js.map