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

8 lines 6.1 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 u}from"./chunk-74BMVZGU.js";import{j as m,l as f}from"./chunk-A65FQHKW.js";import{d as g,h}from"./chunk-YGEDZIJR.js";import{select as b}from"@inquirer/prompts";import o from"chalk";import S from"cli-table3";import{Command as Y}from"commander";var P=()=>{let e=new Y("history");return e.description([o.bold("Manage chat history and sessions."),"",o.gray("Search, filter, export, and clean up your AI chat history."),o.gray('Use "rawi history ask", "rawi history chat",'),o.gray('or "rawi history exec" to view specific session types.'),"\u2500".repeat(80)].join(` `)),e.command("ask").description([o.bold("Show ask session history."),"",o.gray("View and search your ask sessions and messages.")].join(` `)).option("-p, --profile <profile>",o.white("Profile to show history for"),g).option("-l, --limit <number>",o.white("Number of sessions to show"),50 .toString()).option("--all",o.white("Show all sessions without pagination limit")).option("--all-profiles",o.white("Show sessions from all profiles")).option("-s, --search <query>",o.white("Search messages containing text")).option("--provider <provider>",o.white("Filter by AI provider")).option("--model <model>",o.white("Filter by AI model")).option("--from <date>",o.white("Show sessions from date (YYYY-MM-DD)")).option("--to <date>",o.white("Show sessions to date (YYYY-MM-DD)")).action(async t=>{await y(t,"ask")}),e.command("chat").description([o.bold("Show chat session history."),"",o.gray("View and search your chat sessions and messages.")].join(` `)).option("-p, --profile <profile>",o.white("Profile to show history for"),g).option("-l, --limit <number>",o.white("Number of sessions to show"),50 .toString()).option("--all",o.white("Show all sessions without pagination limit")).option("--all-profiles",o.white("Show sessions from all profiles")).option("-s, --search <query>",o.white("Search messages containing text")).option("--provider <provider>",o.white("Filter by AI provider")).option("--model <model>",o.white("Filter by AI model")).option("--from <date>",o.white("Show sessions from date (YYYY-MM-DD)")).option("--to <date>",o.white("Show sessions to date (YYYY-MM-DD)")).action(async t=>{await y(t,"chat")}),e.command("exec").description([o.bold("Show exec session history."),"",o.gray("View and search your exec sessions and messages.")].join(` `)).option("-p, --profile <profile>",o.white("Profile to show history for"),g).option("-l, --limit <number>",o.white("Number of sessions to show"),50 .toString()).option("--all",o.white("Show all sessions without pagination limit")).option("--all-profiles",o.white("Show sessions from all profiles")).option("-s, --search <query>",o.white("Search messages containing text")).option("--provider <provider>",o.white("Filter by AI provider")).option("--model <model>",o.white("Filter by AI model")).option("--from <date>",o.white("Show sessions from date (YYYY-MM-DD)")).option("--to <date>",o.white("Show sessions to date (YYYY-MM-DD)")).action(async t=>{await y(t,"exec")}),e};async function y(e,t){let l=null;try{l=new u;let a={profile:e.allProfiles?void 0:e.profile,limit:e.all?1e3:Number.parseInt(e.limit,10)||50,search:e.search,provider:e.provider,model:e.model,fromDate:e.from,toDate:e.to,type:t},d=10;if(e.search){let i=await l.searchMessages(a);if(i.length===0){console.log(o.yellow("\u{1F4ED} No messages found matching your search."));return}console.log(o.cyan(`\u{1F50D} Found ${i.length} ${t} messages:`)),console.log();let c=new S({head:[o.cyan("Session"),o.cyan("Role"),o.cyan("Content"),o.cyan("Time"),o.cyan("Provider/Model")],style:{head:["cyan"]},colWidths:[15,10,35,15,20],wordWrap:!0});for(let s of i)c.push([m(s.sessionId||"Unknown",13),s.role==="user"?o.blue("User"):o.green("AI"),m(s.content,33),f(s.timestamp),`${s.provider||"N/A"}/${m(s.model||"N/A",8)}`]);console.log(c.toString());return}let n=await l.getSessions(a);if(n.length===0){console.log(o.yellow(`\u{1F4ED} No ${t} sessions found for this profile.`)),console.log(),console.log(o.gray("\u{1F4A1} Tips:")),console.log(o.gray(` \u2022 Start a new ${t} session: rawi ${t} <your-question>`)),console.log(o.gray(" \u2022 Use --all-profiles to search all profiles"));return}console.log(o.cyan(`\u{1F4DA} ${t.charAt(0).toUpperCase()+t.slice(1)} Session History (${n.length} sessions):`)),console.log();let w=Math.ceil(n.length/d),r=0,p=i=>{let c=new S({head:[o.cyan("Title"),o.cyan("ID"),o.cyan("Profile"),o.cyan("Messages"),o.cyan("Updated")],style:{head:["cyan"]},colWidths:[22,38,12,10,18],wordWrap:!0});n.slice(i*d,(i+1)*d).forEach(s=>{c.push([m(s.title||"Untitled",20),s.id,s.profile,s.messageCount?.toString()||"0",f(s.updatedAt)])}),console.log(c.toString()),console.log(),console.log(o.gray(`Page ${i+1} of ${w} | Total: ${n.length} sessions`)),console.log(),console.log(o.gray("\u{1F4A1} Tips:")),console.log(o.gray(` \u2022 Use --session <id> with ${t} command to continue a session`)),console.log(o.gray(" \u2022 Use --search <query> to search message content"))};if(n.length<=d){p(0);return}for(p(r);r<w-1;){let i=await b({message:"What would you like to do?",choices:[{name:"Next page",value:"next"},{name:"Previous page",value:"prev",disabled:r===0},{name:"Exit",value:"exit"}]});if(i==="exit")break;i==="next"&&r<w-1?(r++,p(r)):i==="prev"&&r>0&&(r--,p(r))}}catch(a){console.error(o.red(`\u274C Error fetching ${t} history: ${a instanceof Error?a.message:String(a)}`)),process.exit(1)}finally{l&&l.close()}}export{P 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-WKRKQOPB.js.map