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

26 lines (24 loc) 5.99 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/* 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 A;(o=>{function f(e){if(e.length===0)return"No sessions found.";let n=["ID","Title","Profile","Messages","Created","Last Updated"],a=e.map(i=>[`${i.id.substring(0,8)}...`,i.title||"Untitled",i.profile,i.messageCount.toString(),l(i.createdAt),t(i.updatedAt)]);return r(n,a)}o.formatSessionTable=f;function m(e){return JSON.stringify(e,null,2)}o.formatSessionJSON=m;function p(e){if(e.length===0)return"No sessions found.";let n=e.reduce((d,s)=>d+s.messageCount,0),a=[...new Set(e.map(d=>d.profile))],i=`\u{1F4CA} Session Summary `;return i+=`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 `,i+=`Total Sessions: ${e.length} `,i+=`Total Messages: ${n} `,i+=`Profiles: ${a.join(", ")} `,i+=`Average Messages per Session: ${Math.round(n/e.length)} `,i+=`Recent Sessions: `,i+=`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 `,e.slice(0,5).forEach((d,s)=>{i+=`${s+1}. ${d.title||"Untitled"} `,i+=` Profile: ${d.profile} | Messages: ${d.messageCount} `,i+=` Updated: ${t(d.updatedAt)} `}),i}o.formatSessionSummary=p;function h(e){return{id:e.id,title:e.title||"Untitled Chat",profile:e.profile,createdAt:e.createdAt,updatedAt:e.updatedAt,messageCount:e.messageCount,lastActivity:e.updatedAt,age:t(e.updatedAt)}}o.toDisplayInfo=h;function S(e){let n=`\u{1F4C8} Session Statistics `;return n+=`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 `,n+=`Total Messages: ${e.messageCount} `,n+=`Created: ${l(e.createdAt)} `,n+=`Last Updated: ${l(e.updatedAt)} `,n+=`Duration: ${e.duration} `,e.providers.length>0&&(n+=`Providers: ${e.providers.join(", ")} `),e.models.length>0&&(n+=`Models: ${e.models.join(", ")} `),n}o.formatSessionStats=S;function l(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function t(e){let n=Date.now(),a=new Date(e).getTime(),i=n-a,c=Math.floor(i/1e3),d=Math.floor(c/60),s=Math.floor(d/60),u=Math.floor(s/24);return u>0?`${u}d ago`:s>0?`${s}h ago`:d>0?`${d}m ago`:`${c}s ago`}function r(e,n){let a=e.map((s,u)=>{let g=n.map(C=>_optionalChain([C, 'access', _ => _[u], 'optionalAccess', _2 => _2.length])||0);return Math.max(s.length,...g)}),i=e.map((s,u)=>s.padEnd(a[u])).join(" \u2502 "),c=a.map(s=>"\u2500".repeat(s)).join("\u2500\u253C\u2500"),d=n.map(s=>s.map((u,g)=>u.padEnd(a[g])).join(" \u2502 "));return[i,c,...d].join(` `)}})(A = exports.a||={});var w;(l=>{function f(t,r){if(!r.trim())return t;let o=r.toLowerCase();return t.filter(e=>{let n=(e.title||"").toLowerCase().includes(o),a=e.profile.toLowerCase().includes(o),i=e.id.toLowerCase().includes(o);return n||a||i})}l.filterSessions=f;function m(t,r,o){let e=t;if(r){let n=new Date(r).getTime();e=e.filter(a=>new Date(a.createdAt).getTime()>=n)}if(o){let n=new Date(o).getTime();e=e.filter(a=>new Date(a.createdAt).getTime()<=n)}return e}l.filterByDateRange=m;function p(t,r){return t.filter(o=>o.profile===r)}l.filterByProfile=p;function h(t,r="updatedAt",o="desc"){return[...t].sort((e,n)=>{let a=0;switch(r){case"createdAt":a=new Date(e.createdAt).getTime()-new Date(n.createdAt).getTime();break;case"updatedAt":a=new Date(e.updatedAt).getTime()-new Date(n.updatedAt).getTime();break;case"title":a=(e.title||"").localeCompare(n.title||"");break;case"messageCount":a=e.messageCount-n.messageCount;break}return o==="desc"?-a:a})}l.sortSessions=h;function S(t,r=1,o=10){let e=(r-1)*o,n=t.slice(e,e+o),a=Math.ceil(t.length/o);return{sessions:n,pagination:{page:r,limit:o,total:t.length,totalPages:a,hasNext:r<a,hasPrev:r>1}}}l.paginateSessions=S})(w = exports.b||={});var D;(l=>{function f(t){return/^[A-Za-z0-9_-]{21}$/.test(t)}l.isValidSessionId=f;function m(t){return t.length>0&&t.length<=100}l.isValidSessionTitle=m;function p(t){return t.length>0&&t.length<=50&&/^[a-zA-Z0-9_-]+$/.test(t)}l.isValidProfile=p;function h(t){return t.trim().replace(/[<>:"/\\|?*]/g,"_").substring(0,100)}l.sanitizeTitle=h;function S(t){let r=[];return t.id?f(t.id)||r.push("Invalid session ID format"):r.push("Session ID is required"),t.profile?p(t.profile)||r.push("Invalid profile format"):r.push("Profile is required"),t.createdAt?Number.isNaN(new Date(t.createdAt).getTime())&&r.push("Invalid created date format"):r.push("Created date is required"),t.updatedAt?Number.isNaN(new Date(t.updatedAt).getTime())&&r.push("Invalid updated date format"):r.push("Updated date is required"),t.messageCount!==void 0&&t.messageCount<0&&r.push("Message count cannot be negative"),{isValid:r.length===0,errors:r}}l.validateSession=S})(D = exports.c||={});exports.a = A; exports.b = w; exports.c = D; /* 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-Z56DRU3M.cjs.map