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.8 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 f}from"./chunk-TK3ACB5Q.js";import{g as l,h as p}from"./chunk-HI45C3TT.js";import{d as c,g as d}from"./chunk-YGEDZIJR.js";import{confirm as v,input as m,password as y,search as w,select as g}from"@inquirer/prompts";import P from"chalk";var h=class{#r=new f;async getProfile(e){if(e){if(!this.#e(e))throw new Error(`Invalid profile name: ${e}`);return e}return m({message:"Profile Name:",default:c,validate:t=>t.trim()?this.#e(t.trim())?!0:"Profile name can only contain letters, numbers, hyphens, and underscores":"Profile name is required"})}async selectProvider(e){let s=p().map(r=>({name:`${r.displayName} (${r.name})`,value:r.name,description:`${r.name} - ${r.displayName}`}));return s.length>5?w({message:"Select AI Provider (type to search):",source:async r=>{if(!r){if(e){let a=s.find(o=>o.value===e),i=s.filter(o=>o.value!==e);return a?[a,...i]:s}return s}return s.filter(a=>a.name.toLowerCase().includes(r.toLowerCase())||a.value.toLowerCase().includes(r.toLowerCase())||a.description?.toLowerCase().includes(r.toLowerCase()))}}):g({message:"Select AI Provider:",choices:s,default:e})}async selectModel(e,t){let s=l(e);if(!s)throw new Error(`Unknown provider: ${e}`);let r=s.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 r.length>5?w({message:`Select ${s.displayName} Model (type to search):`,source:async n=>{if(!n){if(t){let i=r.find(u=>u.value===t),o=r.filter(u=>u.value!==t);return i?[i,...o]:r}return r}return r.filter(i=>i.name.toLowerCase().includes(n.toLowerCase())||i.value.toLowerCase().includes(n.toLowerCase())||i.description?.toLowerCase().includes(n.toLowerCase()))}}):g({message:`Select ${s.displayName} Model:`,choices:r,default:t})}async getApiKey(e,t){let s=t?`${l(t)?.displayName||t} API Key:`:"API Key:",r;if(e&&await v({message:`Use existing API key (${this.#t(e)})?`,default:!0}))return e;do r=await y({message:s,mask:"*",validate:n=>{if(!n.trim())return"API key is required";if(t){let a=this.#r.validateApiKey(n.trim(),t);if(!a.isValid)return a.errors[0]||"Invalid API key";a.warnings.length>0&&console.log(P.yellow(`Warning: ${a.warnings.join(", ")}`))}return!0}});while(!r.trim());return r.trim()}async getTemperature(e=.7){let t=await m({message:"Temperature (0.0 - 2.0):",default:e.toString(),validate:s=>{let r=Number.parseFloat(s);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 m({message:"Max Tokens (1 - 100000):",default:e.toString(),validate:s=>{let r=Number.parseInt(s,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=d){return g({message:"Response Language:",choices:[{name:"English",value:"english"},{name:"Arabic",value:"arabic"}],default:e})}#e(e){return/^[a-zA-Z0-9_-]+$/.test(e)&&e.length<=50}#t(e){return e.length<=8?"*".repeat(e.length):`${e.slice(0,4)}${"*".repeat(e.length-8)}${e.slice(-4)}`}};export{h 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-J3VDTHHY.js.map