import { program, Command } from '@/program.ts'; import { app } from '../ai/index.ts'; import util from 'util'; import { chalk } from '@/module/chalk.ts'; import { logger } from '@/module/logger.ts'; const aiCmd = new Command('ai') .description('AI 相关命令') .action(async (opts) => { }); const runCmd = async (cmd: string) => { const res = await app.router.call({ path: 'cmd-run', payload: { cmd } }); const { body } = res; const steps = body?.steps || []; for (const step of steps) { logger.debug(chalk.blue(`\n==== 步骤: ${step.cmd || '结束'} ====`)); logger.debug(step.result || 'No result'); } } const aiRun = new Command('run') .description('执行 AI 命令') .option('-c, --cmd ', '要执行的 CMD 命令') .action(async (opts) => { if (opts.cmd) { await runCmd(opts.cmd); } else { console.log('请提供要执行的 CMD 命令'); } }); const aiRunDeploy = new Command('deploy') .description('部署 AI 后端应用') .action(async (opts) => { const cmd = 'ev pack -p -u'; const res = await runCmd(cmd); }); aiCmd.addCommand(aiRun); aiCmd.addCommand(aiRunDeploy); program.addCommand(aiCmd);