feat: 重构代理功能,添加文件代理支持并优化相关逻辑

This commit is contained in:
2026-01-18 13:41:47 +08:00
parent 5e5f4f6543
commit 43992d896f
11 changed files with 166 additions and 63 deletions

View File

@@ -6,19 +6,19 @@ import inquirer from 'inquirer';
import chalk from 'chalk';
type InitCommandOptions = {
path?: string;
workspace?: string;
};
const Init = new Command('init')
.description('初始化一个助手客户端,生成配置文件。')
.option('-p --path <path>', '助手路径,默认为执行命令的目录,如果助手路径不存在则创建。')
.option('-w --workspace <workspace>', '助手路径,默认为执行命令的目录,如果助手路径不存在则创建。')
.action((opts: InitCommandOptions) => {
// 如果path参数存在检测path是否是相对路径,如果是相对路径,则转换为绝对路径
if (opts.path && !opts.path.startsWith('/')) {
opts.path = path.join(process.cwd(), opts.path);
} else if (opts.path) {
opts.path = path.resolve(opts.path);
// 如果workspace参数存在检测workspace是否是相对路径,如果是相对路径,则转换为绝对路径
if (opts.workspace && !opts.workspace.startsWith('/')) {
opts.workspace = path.join(process.cwd(), opts.workspace);
} else if (opts.workspace) {
opts.workspace = path.resolve(opts.workspace);
}
const configDir = AssistantInit.detectConfigDir(opts.path);
const configDir = AssistantInit.detectConfigDir(opts.workspace);
console.log('configDir', configDir);
const assistantInit = new AssistantInit({
path: configDir,