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.13 kB
JavaScript
/* 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{promises as p}from"fs";import{performance as g}from"perf_hooks";import{glob as f}from"glob";var m=class{#e;constructor(e){this.#e=e}async expandGlobPatterns(e,r={}){let s=[];for(let t of e)try{let n=await f(t,{cwd:r.cwd||process.cwd(),nocase:r.nocase||!1,ignore:r.ignore||[],absolute:!0,dot:!1});s.push(...n)}catch(n){console.warn(`Failed to expand glob pattern "${t}":`,n)}return[...new Set(s)].sort()}async filterSupportedFiles(e){let r=[];for(let s of e)try{await p.access(s),await this.#e.canReadFile(s)&&r.push(s)}catch{}return r}async#r(e,r){let s=g.now();try{let t=await this.#e.readFile(e),n=g.now()-s;return{filePath:e,result:t,processingTime:n}}catch(t){let n=g.now()-s;return{filePath:e,result:{success:!1,error:t instanceof Error?t.message:String(t)},processingTime:n}}}async#t(e,r){let s=[];for(let t=0;t<e.length;t++){let n=e[t];try{let o=await this.#r(n,r.fileType);if(s.push(o),r.onProgress&&r.onProgress(t+1,e.length,n,o.result),!o.result.success&&!r.continueOnError)break}catch(o){if(!r.continueOnError)throw o;s.push({filePath:n,result:{success:!1,error:o instanceof Error?o.message:String(o)},processingTime:0}),r.onProgress&&r.onProgress(t+1,e.length,n)}}return s}async#n(e,r){let s=r.maxConcurrency||Math.min(e.length,5),t=[],n=0;for(let o=0;o<e.length;o+=s){let l=e.slice(o,o+s).map(async a=>{try{let i=await this.#r(a,r.fileType);return n++,r.onProgress&&r.onProgress(n,e.length,a,i.result),i}catch(i){n++;let h={filePath:a,result:{success:!1,error:i instanceof Error?i.message:String(i)},processingTime:0};if(r.onProgress&&r.onProgress(n,e.length,a,h.result),!r.continueOnError)throw i;return h}}),u=await Promise.all(l);if(t.push(...u),!r.continueOnError&&u.some(i=>!i.result.success))break}return t}#s(e){let r=e.filter(c=>c.result.success).length,s=e.length-r,t=e.reduce((c,l)=>c+l.processingTime,0),n=e.length>0?t/e.length:0,o=e.filter(c=>!c.result.success).map(c=>({filePath:c.filePath,error:c.result.error||"Unknown error"}));return{totalFiles:e.length,successfulFiles:r,failedFiles:s,totalProcessingTime:t,averageProcessingTime:n,results:e,errors:o}}async processFiles(e,r={}){if(e.length===0)return this.#s([]);let s=r.parallel?await this.#n(e,r):await this.#t(e,r);return this.#s(s)}async processGlobPatterns(e,r={}){let{cwd:s,nocase:t,ignore:n,absolute:o,dot:c,...l}=r,u={cwd:s,nocase:t,ignore:n,absolute:o,dot:c},a=await this.expandGlobPatterns(e,u),i=await this.filterSupportedFiles(a);return this.processFiles(i,l)}};export{m as a};
/* 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-PT5U2YR3.js.map