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.11 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{a as g}from"./chunk-PTY25BFJ.js";import{d as s,e as d}from"./chunk-LDSHVY7O.js";import{d as m,g as l}from"./chunk-3JCRW7ET.js";import{confirm as c,input as o,password as f,select as u}from"@inquirer/prompts";import P from"chalk";var p=class{validator=new g;async getProfile(e){if(e){if(!this.isValidProfileName(e))throw new Error(`Invalid profile name: ${e}`);return e}return o({message:"Profile Name:",default:m,validate:t=>t.trim()?this.isValidProfileName(t.trim())?!0:"Profile name can only contain letters, numbers, hyphens, and underscores":"Profile name is required"})}async selectProvider(e){let a=d().map(r=>({name:`${r.displayName} (${r.name})`,value:r.name}));return u({message:"Select AI Provider:",choices:a,default:e})}async selectModel(e,t){let a=s(e);if(!a)throw new Error(`Unknown provider: ${e}`);let r=a.models.map(n=>({name:n.displayName||n.name,value:n.name,description:n.description||""}));if(r.length===0)throw new Error(`No models available for provider: ${e}`);return u({message:`Select ${a.displayName} Model:`,choices:r,default:t})}async getApiKey(e,t){let a=t?`${s(t)?.displayName||t} API Key:`:"API Key:",r;if(e&&await c({message:`Use existing API key (${this.maskApiKey(e)})?`,default:!0}))return e;do r=await f({message:a,mask:"*",validate:n=>{if(!n.trim())return"API key is required";if(t){let i=this.validator.validateApiKey(n.trim(),t);if(!i.isValid)return i.errors[0]||"Invalid API key";i.warnings.length>0&&console.log(P.yellow(`Warning: ${i.warnings.join(", ")}`))}return!0}});while(!r.trim());return r.trim()}async getTemperature(e=.7){let t=await o({message:"Temperature (0.0 - 2.0):",default:e.toString(),validate:a=>{let r=Number.parseFloat(a);return Number.isNaN(r)?"Temperature must be a number":r<0||r>2?"Temperature must be between 0.0 and 2.0":!0}});return Number.parseFloat(t)}async getMaxTokens(e=2048){let t=await o({message:"Max Tokens (1 - 100000):",default:e.toString(),validate:a=>{let r=Number.parseInt(a,10);return Number.isNaN(r)?"Max tokens must be a number":r<1||r>1e5?"Max tokens must be between 1 and 100000":!0}});return Number.parseInt(t,10)}async getLanguage(e=l){return u({message:"Response Language:",choices:[{name:"English",value:"english"},{name:"Arabic",value:"arabic"}],default:e})}isValidProfileName(e){return/^[a-zA-Z0-9_-]+$/.test(e)&&e.length<=50}maskApiKey(e){return e.length<=8?"*".repeat(e.length):`${e.slice(0,4)}${"*".repeat(e.length-8)}${e.slice(-4)}`}};export{p 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-XGV3I4XU.js.map