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,10 +1,10 @@
import { program as app, Command } from '@/program.ts';
import { SyncBase } from './modules/base.ts';
import { baseURL, storage } from '@/module/query.ts';
import { baseURL, query, storage } from '@/module/query.ts';
import { fetchLink, fetchAiList } from '@/module/download/install.ts';
import fs from 'node:fs';
import { upload } from '@/module/download/upload.ts';
import { logger } from '@/module/logger.ts';
import { logger, printClickableLink } from '@/module/logger.ts';
import { chalk } from '@/module/chalk.ts';
import path from 'node:path';
import { fileIsExist } from '@/uitls/file.ts';
@@ -124,7 +124,9 @@ const syncList = new Command('list')
syncList.forEach((item) => {
if (opts.all) {
logger.info(item);
} else logger.info(chalk.blue(item.key), chalk.gray(item.type), chalk.green(item.url));
} else {
logger.info(chalk.green(printClickableLink({ url: item.url, text: item.key, print: false })), chalk.gray(item.type));
}
});
});
const syncCreateList = new Command('create')
@@ -154,16 +156,26 @@ const syncCreateList = new Command('create')
}
});
const checkDir = new Command('check')
const clone = new Command('clone')
.option('-d --dir <dir>', '配置目录')
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
.option('-i --link <link>', '克隆链接, 比 kevisual.json 优先级更高')
.description('检查目录')
.action(async (opts) => {
const link = opts.link || '';
const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config });
if (link) {
const res = await query.fetchText(link);
if (res.code === 200) {
fs.writeFileSync(sync.configPath, JSON.stringify(res.data, null, 2));
}
sync.init()
}
const syncList = await sync.getSyncList();
logger.debug(syncList);
logger.info('检查目录\n');
const checkList = await sync.getCheckList();
logger.info('检查列表', checkList);
for (const item of checkList) {
if (!item.auth) {
continue;
@@ -226,6 +238,6 @@ command.addCommand(syncUpload);
command.addCommand(syncDownload);
command.addCommand(syncList);
command.addCommand(syncCreateList);
command.addCommand(checkDir);
command.addCommand(clone);
app.addCommand(command);