feat: enhance AI commands and logging system

- Update @kevisual/query to 0.0.32 and @kevisual/router to 0.0.37
- Restructure AI command interface with run and deploy subcommands
- Add comprehensive logging throughout cmd-execution flow
- Improve sync module with better configuration handling
- Add clickable link functionality in logger
- Enhance error handling and debugging capabilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-10 17:45:09 +08:00
parent 5b83f7a6d1
commit 4aeb3637bf
13 changed files with 167 additions and 73 deletions

View File

@@ -1,30 +1,41 @@
import { App } from '@kevisual/app/src/app.ts';
import { storage } from '../module/query.ts';
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) => {
});
export const runAIApp = async () => {
const token = storage.getItem('token') || '';
if (!token) {
console.log('Please login first.');
return;
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 aiApp = new App({ token })
await aiApp.loadAI();
const router= aiApp.router;
router.route({
description: '今天的天气怎么样?',
}).define(async (ctx) => {
ctx.body = '今天的天气晴朗,适合外出活动!';
}).addTo(router)
router.route({
description: '当前时间是几点?',
}).define(async (ctx) => {
ctx.body = `当前时间是:${new Date().toLocaleTimeString()}`;
}).addTo(router)
const chat = await aiApp.chat('今天的天气怎么样?');
console.log('AI Response:', aiApp.ai.responseText);
console.log('chat', chat);
}
runAIApp();
const aiRun = new Command('run')
.description('执行 AI 命令')
.option('-c, --cmd <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);