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