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
1 lines • 5.02 kB
Source Map (JSON)
{"version":3,"sources":["/home/mkabumattar/withrawi/rawi/dist/chunk-7D7CXXN7.cjs","../src/core/templates/utils.ts"],"names":["findActTemplate","id","actTemplates","template","listActTemplates","templates","a","b","totalPages","page","renderPage","pageIdx","table","Table","chalk"],"mappings":"AAAA;AACA,wDAAwC,4CCDnB,4EACH,6FACA,IAGLA,CAAAA,CAAmBC,CAAAA,EACvBC,mBAAAA,CAAa,IAAA,CAAMC,CAAAA,EAAaA,CAAAA,CAAS,EAAA,GAAOF,CAAE,CAAA,CAG9CG,CAAAA,aAAmB,KAAA,CAAA,CAAA,EAA2B,CAEzD,IAAMC,CAAAA,CAAYH,mBAAAA,CACf,KAAA,CAAM,CAAA,CACN,IAAA,CAAK,CAACI,CAAAA,CAAGC,CAAAA,CAAAA,EAAMD,CAAAA,CAAE,KAAA,CAAM,aAAA,CAAcC,CAAAA,CAAE,KAAK,CAAC,CAAA,CAC1CC,CAAAA,CAAa,IAAA,CAAK,IAAA,CAAKH,CAAAA,CAAU,MAAA,CAAS,EAAQ,CAAA,CACpDI,CAAAA,CAAO,CAAA,CAELC,CAAAA,CAAcC,CAAAA,EAAoB,CACtC,IAAMC,CAAAA,CAAQ,IAAIC,wBAAAA,CAAM,CACtB,IAAA,CAAM,CACJC,eAAAA,CAAM,IAAA,CAAK,IAAI,CAAA,CACfA,eAAAA,CAAM,IAAA,CAAK,OAAO,CAAA,CAClBA,eAAAA,CAAM,IAAA,CAAK,UAAU,CAAA,CACrBA,eAAAA,CAAM,IAAA,CAAK,aAAa,CAC1B,CAAA,CACA,KAAA,CAAO,CAAC,IAAA,CAAM,CAAC,MAAM,CAAC,CAAA,CACtB,SAAA,CAAW,CAAC,EAAA,CAAI,EAAA,CAAI,EAAA,CAAI,EAAE,CAAA,CAC1B,QAAA,CAAU,CAAA,CACZ,CAAC,CAAA,CACDT,CAAAA,CACG,KAAA,CAAMM,CAAAA,CAAU,EAAA,CAAA,CAAWA,CAAAA,CAAU,CAAA,CAAA,CAAK,EAAQ,CAAA,CAClD,OAAA,CAASR,CAAAA,EAAa,CACrBS,CAAAA,CAAM,IAAA,CAAK,CACTE,eAAAA,CAAM,KAAA,CAAMX,CAAAA,CAAS,EAAE,CAAA,CACvBA,CAAAA,CAAS,KAAA,CACTW,eAAAA,CAAM,IAAA,CAAKX,CAAAA,CAAS,QAAQ,CAAA,CAC5B,EACF,CAAC,CACH,CAAC,CAAA,CACH,OAAA,CAAQ,GAAA,CAAIW,eAAAA,CAAM,IAAA,CAAK,IAAA,CAAK,CAAA;AAAA,kCAAA,CAA+B,CAAC,CAAA,CAC5D,OAAA,CAAQ,GAAA,CAAIF,CAAAA,CAAM,QAAA,CAAS,CAAC,CAAA,CAC5B,OAAA,CAAQ,GAAA,CAAIE,eAAAA,CAAM,IAAA,CAAK,CAAA,KAAA,EAAQH,CAAAA,CAAU,CAAC,CAAA,IAAA,EAAOH,CAAU,CAAA,CAAA;AA0CtC,wBAAA;AD/E8E","file":"/home/mkabumattar/withrawi/rawi/dist/chunk-7D7CXXN7.cjs","sourcesContent":[null,"import {select} from '@inquirer/prompts';\nimport chalk from 'chalk';\nimport Table from 'cli-table3';\nimport {type ActTemplate, actTemplates} from './act.js';\n\nexport const findActTemplate = (id: string): ActTemplate | undefined => {\n return actTemplates.find((template) => template.id === id);\n};\n\nexport const listActTemplates = async (): Promise<void> => {\n const pageSize = 10;\n const templates = actTemplates\n .slice()\n .sort((a, b) => a.label.localeCompare(b.label));\n const totalPages = Math.ceil(templates.length / pageSize);\n let page = 0;\n\n const renderPage = (pageIdx: number) => {\n const table = new Table({\n head: [\n chalk.cyan('ID'),\n chalk.cyan('Label'),\n chalk.cyan('Category'),\n chalk.cyan('Description'),\n ],\n style: {head: ['cyan']},\n colWidths: [16, 22, 16, 36],\n wordWrap: true,\n });\n templates\n .slice(pageIdx * pageSize, (pageIdx + 1) * pageSize)\n .forEach((template) => {\n table.push([\n chalk.green(template.id),\n template.label,\n chalk.blue(template.category),\n '',\n ]);\n });\n console.log(chalk.bold.cyan('\\n🎭 Available Act Templates:'));\n console.log(table.toString());\n console.log(chalk.gray(`Page ${pageIdx + 1} of ${totalPages}`));\n };\n\n if (templates.length > pageSize) {\n let exit = false;\n while (!exit) {\n renderPage(page);\n const choices = [];\n if (page > 0) choices.push({name: 'Previous', value: 'prev'});\n if (page < totalPages - 1) choices.push({name: 'Next', value: 'next'});\n choices.push({name: 'Exit', value: 'exit'});\n const nav = await select({\n message: 'Navigate pages:',\n choices,\n default: page < totalPages - 1 ? 'next' : 'exit',\n });\n if (nav === 'prev') page--;\n else if (nav === 'next') page++;\n else exit = true;\n if (!exit) console.clear();\n }\n } else {\n renderPage(0);\n }\n console.log();\n console.log(chalk.dim('Usage: rawi ask --act <template-id> \"your question\"'));\n console.log(chalk.dim('Show template: rawi act --show <template-id>'));\n};\n\nexport const showActTemplate = (id: string): void => {\n const template = findActTemplate(id);\n\n if (!template) {\n console.error(chalk.red(`❌ Act template '${id}' not found.`));\n console.log(\n chalk.yellow('💡 Use \"rawi act --list\" to see available templates.'),\n );\n return;\n }\n\n console.log(chalk.bold.cyan(`\\n🎭 Act Template: ${template.label}`));\n console.log(chalk.blue(`ID: ${template.id}`));\n console.log(chalk.blue(`Category: ${template.category}`));\n console.log();\n console.log(chalk.bold('Template:'));\n console.log(chalk.white(template.template));\n console.log();\n console.log(chalk.dim(`Usage: rawi ask --act ${template.id} \"{userInput}\"`));\n};\n\nexport const applyActTemplate = (\n templateId: string,\n userInput: string,\n): string => {\n const template = findActTemplate(templateId);\n\n if (!template) {\n throw new Error(`Act template '${templateId}' not found`);\n }\n\n return template.template.replace('{userInput}', userInput);\n};\n"]}