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
10 lines (8 loc) • 5.01 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/* 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. */
var _chunkDFRFF36Ycjs = require('./chunk-DFRFF36Y.cjs');var _chunkMGIUGMP2cjs = require('./chunk-MGIUGMP2.cjs');var _chunk3YIPDBV3cjs = require('./chunk-3YIPDBV3.cjs');var _chunkG5AO4Y3Mcjs = require('./chunk-G5AO4Y3M.cjs');var _chunkFAD6MIW3cjs = require('./chunk-FAD6MIW3.cjs');var _os = require('os'); var _os2 = _interopRequireDefault(_os);var _prompts = require('@inquirer/prompts');var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);async function P(o){try{let n=new (0, _chunkG5AO4Y3Mcjs.a)().getCredentials(o);return n?!n.provider||!n.model?{isValid:!1,error:`Invalid credentials for profile '${o}' - missing provider or model`}:{isValid:!0}:{isValid:!1,error:`No credentials found for profile '${o}'`}}catch(e){return{isValid:!1,error:`Failed to validate credentials: ${e instanceof Error?e.message:String(e)}`}}}async function V(o){try{return new (0, _chunkG5AO4Y3Mcjs.a)().getCredentials(o)?{isValid:!0}:{isValid:!1,error:`Profile '${o}' not found. Run 'rawi configure --profile ${o}' to set it up.`}}catch(e){return{isValid:!1,error:`Failed to validate profile: ${e instanceof Error?e.message:String(e)}`}}}async function p(o){let n=new (0, _chunkG5AO4Y3Mcjs.a)().getCredentials(o);if(!n)throw new Error(`No credentials found for profile '${o}'. Run 'rawi configure --profile ${o}' to set it up.`);if(!n.provider||!n.model)throw new Error(`Invalid credentials for profile '${o}' - missing provider or model`);return n}async function b(o,e){console.log(_chalk2.default.dim("\u{1F916} Generating command..."));let n=await p(e.profile||_chunkFAD6MIW3cjs.d);e.verbose&&(console.log(_chalk2.default.dim(`\u{1F527} Using provider: ${n.provider}`)),console.log(_chalk2.default.dim(`\u{1F916} Using model: ${n.model}`)),console.log(_chalk2.default.dim(`\u{1F4BB} OS: ${_os2.default.platform()} ${_os2.default.release()} (${_os2.default.type()})`)));let i=await _chunkDFRFF36Ycjs.a.call(void 0, {credentials:n,description:o,timeout:e.timeout?Number(e.timeout):void 0});console.log(_chalk2.default.cyan(`\u{1F916} Generated command: ${i.command}`));let r=_chunkDFRFF36Ycjs.b.call(void 0, i.command);if(!r.isValid)throw new Error(`Invalid command generated: ${r.warnings.join(", ")}`);if(r.warnings.length>0){console.log(_chalk2.default.yellow("\u26A0\uFE0F Warnings:"));for(let a of r.warnings)console.log(_chalk2.default.yellow(` - ${a}`))}if((r.isDangerous||e.confirm)&&!e.dryRun){let a=await _prompts.input.call(void 0, {message:_chunk3YIPDBV3cjs.c.call(void 0, i.command),default:"N"});if(a.toLowerCase()!=="y"&&a.toLowerCase()!=="yes")return console.log(_chalk2.default.yellow("\u274C Command execution cancelled.")),{command:i.command,stdout:void 0,stderr:"Execution cancelled by user",exitCode:1,executionTime:0,success:!1}}return console.log(_chalk2.default.dim("\u26A1 Executing command...")),await _chunkMGIUGMP2cjs.a.call(void 0, {command:i.command,shell:e.shell,cwd:e.workingDirectory,timeout:e.timeout?Number(e.timeout):void 0,dryRun:e.dryRun,interactive:e.interactive,copyCommand:e.copyCommand})}async function M(o,e,n,i){try{let r=await o.createSession(i.profile||_chunkFAD6MIW3cjs.d,`Exec: ${e}`,"exec");await o.addMessage(r,"user",e,"exec","command-generator",void 0,void 0,{type:"exec_request",timestamp:new Date().toISOString()});let m=n.success?`Generated command: \`${n.command}\`
Execution result:
${n.stdout||"Command executed successfully"}`:`Generated command: \`${n.command}\`
Execution failed:
${n.stderr||"Unknown error"}`;return await o.addMessage(r,"assistant",m,"exec","command-generator",void 0,void 0,{type:"exec_result",command:n.command,success:n.success,exitCode:n.exitCode,executionTime:n.executionTime,timestamp:new Date().toISOString()}),r}catch(r){return console.error("Failed to save exec session to database:",r),`exec-${Date.now()}`}}async function S(o,e){e?console.log(_chunkMGIUGMP2cjs.b.call(void 0, o)):o.success?(console.log(_chalk2.default.green("\u2705 Command executed successfully")),o.stdout&&console.log(o.stdout)):(console.log(_chalk2.default.red("\u274C Command execution failed")),o.stderr&&console.error(o.stderr))}exports.a = P; exports.b = V; exports.c = p; exports.d = b; exports.e = M; exports.f = S;
/* 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-6UQYRNYT.cjs.map