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

1 lines 6.36 kB
{"version":3,"sources":["/home/mkabumattar/work/withrawi/rawi/dist/chunk-TUGYUPJG.cjs","../src/cli/commands/exec.command.ts"],"names":["readStdin","resolve","data","chunk","createExecCommand","execCommand","Command","chalk","execCommandOptions","option","description","options","dbManager","finalDescription","stdinContent","input","startExecSession","error"],"mappings":"AAAA;AACA,wDAAwC,wDAAyC,4CCD7D,4EACF,sCACI,IAKhBA,CAAAA,CAAY,CAAA,CAAA,EACT,IAAI,OAAA,CAASC,CAAAA,EAAY,CAC9B,IAAIC,CAAAA,CAAO,EAAA,CAEX,EAAA,CAAI,OAAA,CAAQ,KAAA,CAAM,KAAA,CAAO,CACvBD,CAAAA,CAAQ,EAAE,CAAA,CACV,MACF,CAEA,OAAA,CAAQ,KAAA,CAAM,WAAA,CAAY,MAAM,CAAA,CAEhC,OAAA,CAAQ,KAAA,CAAM,EAAA,CAAG,MAAA,CAASE,CAAAA,EAAU,CAClCD,CAAAA,EAAQC,CACV,CAAC,CAAA,CAED,OAAA,CAAQ,KAAA,CAAM,EAAA,CAAG,KAAA,CAAO,CAAA,CAAA,EAAM,CAC5BF,CAAAA,CAAQC,CAAAA,CAAK,IAAA,CAAK,CAAC,CACrB,CAAC,CACH,CAAC,CAAA,CAGUE,CAAAA,aAAoB,CAAA,CAAA,EAAe,CAC9C,IAAMC,CAAAA,CAAc,IAAIC,uBAAAA,CAAQ,MAAM,CAAA,CAEtC,OAAAD,CAAAA,CACG,WAAA,CACC,CACEE,eAAAA,CAAM,IAAA,CAAK,sDAAsD,CAAA,CACjE,EAAA,CACAA,eAAAA,CAAM,IAAA,CAAK,yDAAyD,CAAA,CACpEA,eAAAA,CAAM,IAAA,CAAK,wDAAwD,CAAA,CACnEA,eAAAA,CAAM,IAAA,CAAK,oDAAoD,CAAA,CAC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AAoBA,CAAAA,CAAiB,IAAA,CAAK,CAAA,GAAM,EAAA,CAAI,CACvDR,CAAAA,CAAY,IAAA,CAAK,CAAA,CACjB,MACF,CAEIM,CAAAA,CAAQ,OAAA,EACV,OAAA,CAAQ,GAAA,CAAIJ,eAAAA,CAAM,GAAA,CAAI,oCAA6B,CAAC,CAAA,CAGtDK,CAAAA,CAAY,GAAA,CACV,MAAM,4DAAA,CAAO,6BAAgC,GAAA,CAAA,CAC7C,eAAA,CACF,MAAMI,iCAAAA,CAAiBJ,CAAWC,CAAAA,CAAkBF,CAAO,CAC7D,CAAA,KAAA,CAASM,CAAAA,CAAO,CACVN,CAAAA,CAAQ,OAAA,CACV,OAAA,CAAQ,KAAA,CAAM,wBAAA,CAA0BM,CAAK,CAAA,CAE7C,OAAA,CAAQ,KAAA,CACNV,eAAAA,CAAM,GAAA,CACJ,CAAA,OAAA,EAAKU,EAAAA,WAAiB,KAAA,CAAQA,CAAAA,CAAM,OAAA,CAAU,eAAe,CAAA,CAAA;ADhH0wB","file":"/home/mkabumattar/work/withrawi/rawi/dist/chunk-TUGYUPJG.cjs","sourcesContent":[null,"import {input} from '@inquirer/prompts';\nimport chalk from 'chalk';\nimport {Command} from 'commander';\nimport type {DatabaseManager} from '../../core/database/manager.js';\nimport {execCommandOptions, startExecSession} from './exec/index.js';\nimport type {ExecOptions} from './exec/types.js';\n\nconst readStdin = (): Promise<string> => {\n return new Promise((resolve) => {\n let data = '';\n\n if (process.stdin.isTTY) {\n resolve('');\n return;\n }\n\n process.stdin.setEncoding('utf8');\n\n process.stdin.on('data', (chunk) => {\n data += chunk;\n });\n\n process.stdin.on('end', () => {\n resolve(data.trim());\n });\n });\n};\n\nexport const createExecCommand = (): Command => {\n const execCommand = new Command('exec');\n\n execCommand\n .description(\n [\n chalk.bold('Convert natural language to executable CLI commands.'),\n '',\n chalk.gray('Describe what you want to do and get the right command.'),\n chalk.gray('Use --dry-run to see the command without executing it.'),\n chalk.gray('Use --profile to specify which AI provider to use.'),\n '─'.repeat(80),\n ].join('\\n'),\n )\n .argument(\n '[description]',\n chalk.white(\n 'Description of what you want to accomplish with the command',\n ),\n );\n\n execCommandOptions.forEach((option) => {\n if ('defaultValue' in option && option.defaultValue !== undefined) {\n if (typeof option.defaultValue === 'string') {\n execCommand.option(\n option.flags,\n option.description,\n option.defaultValue,\n );\n } else if (typeof option.defaultValue === 'boolean') {\n execCommand.option(\n option.flags,\n option.description,\n option.defaultValue,\n );\n } else {\n execCommand.option(\n option.flags,\n option.description,\n String(option.defaultValue),\n );\n }\n } else {\n execCommand.option(option.flags, option.description);\n }\n });\n\n execCommand.action(async (description: string, options: ExecOptions) => {\n let dbManager: DatabaseManager | null = null;\n\n try {\n let finalDescription = description;\n\n if (!finalDescription) {\n const stdinContent = await readStdin();\n if (stdinContent) {\n finalDescription = stdinContent;\n }\n }\n\n if (!finalDescription && process.stdin.isTTY) {\n const userInput = await input({\n message: 'What would you like to do?',\n required: true,\n });\n finalDescription = userInput;\n }\n\n if (!finalDescription || finalDescription.trim() === '') {\n execCommand.help();\n return;\n }\n\n if (options.verbose) {\n console.log(chalk.dim('🚀 Starting exec session...'));\n }\n\n dbManager = new (\n await import('../../core/database/manager.js')\n ).DatabaseManager();\n await startExecSession(dbManager, finalDescription, options);\n } catch (error) {\n if (options.verbose) {\n console.error('Error in exec session:', error);\n } else {\n console.error(\n chalk.red(\n `❌ ${error instanceof Error ? error.message : 'Unknown error'}`,\n ),\n );\n }\n process.exit(1);\n } finally {\n if (dbManager) {\n dbManager.close();\n }\n }\n });\n\n return execCommand;\n};\n"]}