aico-cli 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/feature-checker.mjs +117 -0
- package/dist/{shared/aico-cli.mxgSz9yk.mjs → chunks/simple-config.mjs} +2158 -2639
- package/dist/cli.mjs +184 -998
- package/dist/index.d.mts +12 -42
- package/dist/index.d.ts +12 -42
- package/dist/index.mjs +7 -7
- package/dist/shared/aico-cli.C9hv-Gol.mjs +51 -0
- package/package.json +1 -1
- package/templates/CLAUDE.md +1 -3
- package/templates/{zh-CN/workflow/common/agents → agents/aico/plan}/get-current-datetime.md +2 -2
- package/templates/{zh-CN/workflow/common/agents → agents/aico/plan}/init-architect.md +11 -8
- package/templates/agents/aico/requirement/aico-requirement-aligner.md +231 -0
- package/templates/agents/aico/requirement/aico-requirement-identifier.md +221 -0
- package/templates/agents/aico/requirement/aico-task-executor-validator.md +289 -0
- package/templates/agents/aico/requirement/aico-task-executor.md +328 -0
- package/templates/agents/aico/requirement/aico-task-splitter-validator.md +585 -0
- package/templates/base.md +51 -0
- package/templates/{zh-CN/workflow/common/commands → commands/aico}/init-project.md +1 -1
- package/templates/commands/aico/requirement.md +351 -0
- package/templates/commands/aico/workflow.md +229 -0
- package/templates/language.md +1 -0
- package/templates/personality.md +143 -0
- package/templates/settings.json +6 -3
- package/templates/en/memory/mcp.md +0 -6
- package/templates/en/memory/personality.md +0 -1
- package/templates/en/memory/rules.md +0 -45
- package/templates/en/memory/technical-guides.md +0 -97
- package/templates/en/workflow/bmad/commands/bmad-init.md +0 -103
- package/templates/en/workflow/common/agents/get-current-datetime.md +0 -29
- package/templates/en/workflow/common/agents/init-architect.md +0 -114
- package/templates/en/workflow/common/commands/init-project.md +0 -53
- package/templates/en/workflow/git/commands/git-cleanBranches.md +0 -101
- package/templates/en/workflow/git/commands/git-commit.md +0 -152
- package/templates/en/workflow/git/commands/git-rollback.md +0 -89
- package/templates/en/workflow/git/commands/git-worktree.md +0 -301
- package/templates/en/workflow/plan/agents/planner.md +0 -116
- package/templates/en/workflow/plan/agents/ui-ux-designer.md +0 -91
- package/templates/en/workflow/plan/commands/feat.md +0 -105
- package/templates/en/workflow/sixStep/commands/workflow.md +0 -230
- package/templates/zh-CN/memory/mcp.md +0 -34
- package/templates/zh-CN/memory/personality.md +0 -1
- package/templates/zh-CN/memory/rules.md +0 -45
- package/templates/zh-CN/memory/technical-guides.md +0 -126
- package/templates/zh-CN/workflow/bmad/commands/bmad-init.md +0 -109
- package/templates/zh-CN/workflow/git/commands/git-cleanBranches.md +0 -101
- package/templates/zh-CN/workflow/git/commands/git-commit.md +0 -162
- package/templates/zh-CN/workflow/git/commands/git-rollback.md +0 -90
- package/templates/zh-CN/workflow/git/commands/git-worktree.md +0 -225
- package/templates/zh-CN/workflow/plan/commands/feat.md +0 -105
- package/templates/zh-CN/workflow/sixStep/commands/workflow.md +0 -199
- /package/templates/{zh-CN/workflow/plan/agents → agents/aico/plan}/planner.md +0 -0
- /package/templates/{zh-CN/workflow/plan/agents → agents/aico/plan}/ui-ux-designer.md +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,784 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import cac from 'cac';
|
|
3
3
|
import ansis from 'ansis';
|
|
4
|
-
import {
|
|
4
|
+
import { K as createEscapablePrompt, N as displayBannerWithInfo, i as init, O as executeWithEscapeSupport, P as handleExitPromptError, Q as handleGeneralError, R as EscapeKeyPressed, T as displayBanner, U as version, V as ConfigCheckerInstaller } from './chunks/simple-config.mjs';
|
|
5
5
|
import inquirer$1 from 'inquirer';
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import { spawn, exec as exec$1 } from 'node:child_process';
|
|
7
|
+
import 'tinyexec';
|
|
8
|
+
import 'node:os';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'pathe';
|
|
11
|
+
import 'node:url';
|
|
12
|
+
import 'node:path';
|
|
9
13
|
import { exec } from 'child_process';
|
|
10
14
|
import { promisify } from 'util';
|
|
11
|
-
import { x } from 'tinyexec';
|
|
12
|
-
import { exec as exec$1, spawn } from 'node:child_process';
|
|
13
15
|
import { promisify as promisify$1 } from 'node:util';
|
|
14
|
-
import 'dayjs';
|
|
15
|
-
import 'pathe';
|
|
16
16
|
import 'ora';
|
|
17
|
-
import '
|
|
18
|
-
import 'node:fs/promises';
|
|
19
|
-
|
|
20
|
-
async function selectAiOutputLanguage(scriptLang, defaultLang) {
|
|
21
|
-
const i18n = getTranslation(scriptLang);
|
|
22
|
-
console.log(ansis.dim(`
|
|
23
|
-
${i18n.language.aiOutputLangHint}
|
|
24
|
-
`));
|
|
25
|
-
const aiLangChoices = Object.entries(AI_OUTPUT_LANGUAGES).map(
|
|
26
|
-
([key, value]) => ({
|
|
27
|
-
title: value.label,
|
|
28
|
-
value: key
|
|
29
|
-
})
|
|
30
|
-
);
|
|
31
|
-
const defaultChoice = defaultLang || (scriptLang === "zh-CN" ? "zh-CN" : "en");
|
|
32
|
-
const { lang } = await inquirer.prompt({
|
|
33
|
-
type: "list",
|
|
34
|
-
name: "lang",
|
|
35
|
-
message: i18n.language.selectAiOutputLang,
|
|
36
|
-
choices: addNumbersToChoices(
|
|
37
|
-
aiLangChoices.map((choice) => ({
|
|
38
|
-
name: choice.title,
|
|
39
|
-
value: choice.value
|
|
40
|
-
}))
|
|
41
|
-
),
|
|
42
|
-
default: defaultChoice
|
|
43
|
-
});
|
|
44
|
-
if (!lang) {
|
|
45
|
-
console.log(ansis.yellow(i18n.common.cancelled));
|
|
46
|
-
process.exit(0);
|
|
47
|
-
}
|
|
48
|
-
let aiOutputLang = lang;
|
|
49
|
-
if (aiOutputLang === "custom") {
|
|
50
|
-
const { customLang } = await inquirer.prompt({
|
|
51
|
-
type: "input",
|
|
52
|
-
name: "customLang",
|
|
53
|
-
message: i18n.language.enterCustomLanguage,
|
|
54
|
-
validate: (value) => !!value || i18n.language?.languageRequired || "Language is required"
|
|
55
|
-
});
|
|
56
|
-
if (!customLang) {
|
|
57
|
-
console.log(ansis.yellow(i18n.common.cancelled));
|
|
58
|
-
process.exit(0);
|
|
59
|
-
}
|
|
60
|
-
return customLang;
|
|
61
|
-
}
|
|
62
|
-
return aiOutputLang;
|
|
63
|
-
}
|
|
64
|
-
async function selectScriptLanguage(currentLang) {
|
|
65
|
-
const aicoConfig = readAicoConfig();
|
|
66
|
-
if (aicoConfig?.preferredLang) {
|
|
67
|
-
return aicoConfig.preferredLang;
|
|
68
|
-
}
|
|
69
|
-
const scriptLang = "zh-CN";
|
|
70
|
-
updateAicoConfig({
|
|
71
|
-
version,
|
|
72
|
-
preferredLang: scriptLang
|
|
73
|
-
});
|
|
74
|
-
return scriptLang;
|
|
75
|
-
}
|
|
76
|
-
async function resolveAiOutputLanguage(scriptLang, commandLineOption, savedConfig) {
|
|
77
|
-
const i18n = getTranslation(scriptLang);
|
|
78
|
-
if (commandLineOption) {
|
|
79
|
-
return commandLineOption;
|
|
80
|
-
}
|
|
81
|
-
if (savedConfig?.aiOutputLang) {
|
|
82
|
-
console.log(
|
|
83
|
-
ansis.gray(
|
|
84
|
-
`\u2714 ${i18n.language.aiOutputLangHint}: ${savedConfig.aiOutputLang}`
|
|
85
|
-
)
|
|
86
|
-
);
|
|
87
|
-
return savedConfig.aiOutputLang;
|
|
88
|
-
}
|
|
89
|
-
return await selectAiOutputLanguage(scriptLang, scriptLang);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async function updatePromptOnly(configLang, scriptLang, aiOutputLang) {
|
|
93
|
-
const i18n = getTranslation(scriptLang);
|
|
94
|
-
const backupDir = backupExistingConfig();
|
|
95
|
-
if (backupDir) {
|
|
96
|
-
console.log(ansis.gray(`\u2714 ${i18n.configuration.backupSuccess}: ${backupDir}`));
|
|
97
|
-
}
|
|
98
|
-
copyConfigFiles(configLang, true);
|
|
99
|
-
if (aiOutputLang) {
|
|
100
|
-
applyAiLanguageDirective(aiOutputLang);
|
|
101
|
-
}
|
|
102
|
-
await configureAiPersonality(scriptLang);
|
|
103
|
-
console.log(ansis.green(`\u2714 ${i18n.configuration.configSuccess} ${CLAUDE_DIR}`));
|
|
104
|
-
console.log("\n" + ansis.cyan(i18n.common.complete));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const execAsync$1 = promisify(exec);
|
|
108
|
-
async function runCcrUi(scriptLang, apiKey) {
|
|
109
|
-
const i18n = I18N[scriptLang];
|
|
110
|
-
console.log(ansis.cyan(`
|
|
111
|
-
\u{1F5A5}\uFE0F ${i18n.ccr.startingCcrUi}`));
|
|
112
|
-
if (apiKey) {
|
|
113
|
-
console.log(ansis.bold.green(`
|
|
114
|
-
\u{1F511} ${i18n.ccr.ccrUiApiKey || "CCR UI API Key"}: ${apiKey}`));
|
|
115
|
-
console.log(ansis.gray(` ${i18n.ccr.ccrUiApiKeyHint || "Use this API key to login to CCR UI"}
|
|
116
|
-
`));
|
|
117
|
-
}
|
|
118
|
-
try {
|
|
119
|
-
const ccrCommand = isWindows() ? "npx ccr ui" : "ccr ui";
|
|
120
|
-
const { stdout, stderr } = await execAsync$1(ccrCommand);
|
|
121
|
-
if (stdout) console.log(stdout);
|
|
122
|
-
if (stderr) console.error(ansis.yellow(stderr));
|
|
123
|
-
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrUiStarted}`));
|
|
124
|
-
} catch (error) {
|
|
125
|
-
console.error(ansis.red(`\u2716 ${i18n.ccr.ccrCommandFailed}: ${error instanceof Error ? error.message : String(error)}`));
|
|
126
|
-
throw error;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async function runCcrStatus(scriptLang) {
|
|
130
|
-
const i18n = I18N[scriptLang];
|
|
131
|
-
console.log(ansis.cyan(`
|
|
132
|
-
\u{1F4CA} ${i18n.ccr.checkingCcrStatus}`));
|
|
133
|
-
try {
|
|
134
|
-
const ccrCommand = isWindows() ? "npx ccr status" : "ccr status";
|
|
135
|
-
const { stdout, stderr } = await execAsync$1(ccrCommand);
|
|
136
|
-
if (stdout) {
|
|
137
|
-
console.log("\n" + ansis.bold(i18n.ccr.ccrStatusTitle));
|
|
138
|
-
console.log(stdout);
|
|
139
|
-
}
|
|
140
|
-
if (stderr) console.error(ansis.yellow(stderr));
|
|
141
|
-
} catch (error) {
|
|
142
|
-
console.error(ansis.red(`\u2716 ${i18n.ccr.ccrCommandFailed}: ${error instanceof Error ? error.message : String(error)}`));
|
|
143
|
-
throw error;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
async function runCcrRestart(scriptLang) {
|
|
147
|
-
const i18n = I18N[scriptLang];
|
|
148
|
-
console.log(ansis.cyan(`
|
|
149
|
-
\u{1F504} ${i18n.ccr.restartingCcr}`));
|
|
150
|
-
try {
|
|
151
|
-
const ccrCommand = isWindows() ? "npx ccr restart" : "ccr restart";
|
|
152
|
-
const { stdout, stderr } = await execAsync$1(ccrCommand);
|
|
153
|
-
if (stdout) console.log(stdout);
|
|
154
|
-
if (stderr) console.error(ansis.yellow(stderr));
|
|
155
|
-
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrRestarted}`));
|
|
156
|
-
} catch (error) {
|
|
157
|
-
console.error(ansis.red(`\u2716 ${i18n.ccr.ccrCommandFailed}: ${error instanceof Error ? error.message : String(error)}`));
|
|
158
|
-
throw error;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
async function runCcrStart(scriptLang) {
|
|
162
|
-
const i18n = I18N[scriptLang];
|
|
163
|
-
console.log(ansis.cyan(`
|
|
164
|
-
\u25B6\uFE0F ${i18n.ccr.startingCcr}`));
|
|
165
|
-
try {
|
|
166
|
-
const ccrCommand = isWindows() ? "npx ccr start" : "ccr start";
|
|
167
|
-
const { stdout, stderr } = await execAsync$1(ccrCommand);
|
|
168
|
-
if (stdout) console.log(stdout);
|
|
169
|
-
if (stderr) console.error(ansis.yellow(stderr));
|
|
170
|
-
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrStarted}`));
|
|
171
|
-
} catch (error) {
|
|
172
|
-
if (error.stdout && error.stdout.includes("Loaded JSON config from:")) {
|
|
173
|
-
console.log(error.stdout);
|
|
174
|
-
if (error.stderr) console.error(ansis.yellow(error.stderr));
|
|
175
|
-
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrStarted}`));
|
|
176
|
-
} else {
|
|
177
|
-
console.error(ansis.red(`\u2716 ${i18n.ccr.ccrCommandFailed}: ${error instanceof Error ? error.message : String(error)}`));
|
|
178
|
-
throw error;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
async function runCcrStop(scriptLang) {
|
|
183
|
-
const i18n = I18N[scriptLang];
|
|
184
|
-
console.log(ansis.cyan(`
|
|
185
|
-
\u23F9\uFE0F ${i18n.ccr.stoppingCcr}`));
|
|
186
|
-
try {
|
|
187
|
-
const ccrCommand = isWindows() ? "npx ccr stop" : "ccr stop";
|
|
188
|
-
const { stdout, stderr } = await execAsync$1(ccrCommand);
|
|
189
|
-
if (stdout) console.log(stdout);
|
|
190
|
-
if (stderr) console.error(ansis.yellow(stderr));
|
|
191
|
-
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrStopped}`));
|
|
192
|
-
} catch (error) {
|
|
193
|
-
console.error(ansis.red(`\u2716 ${i18n.ccr.ccrCommandFailed}: ${error instanceof Error ? error.message : String(error)}`));
|
|
194
|
-
throw error;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function isCcrConfigured() {
|
|
199
|
-
const CCR_CONFIG_FILE = join(homedir(), ".claude-code-router", "config.json");
|
|
200
|
-
if (!existsSync(CCR_CONFIG_FILE)) {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
const config = readCcrConfig();
|
|
204
|
-
return config !== null && config.Providers && config.Providers.length > 0;
|
|
205
|
-
}
|
|
206
|
-
async function showCcrMenu(scriptLang) {
|
|
207
|
-
try {
|
|
208
|
-
const i18n = I18N[scriptLang];
|
|
209
|
-
console.log("\n" + ansis.cyan("\u2550".repeat(50)));
|
|
210
|
-
console.log(ansis.bold.cyan(` ${i18n.ccr.ccrMenuTitle}`));
|
|
211
|
-
console.log(ansis.cyan("\u2550".repeat(50)) + "\n");
|
|
212
|
-
console.log(` ${ansis.cyan("1.")} ${i18n.ccr.ccrMenuOptions.initCcr} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.initCcr)}`);
|
|
213
|
-
console.log(` ${ansis.cyan("2.")} ${i18n.ccr.ccrMenuOptions.startUi} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.startUi)}`);
|
|
214
|
-
console.log(` ${ansis.cyan("3.")} ${i18n.ccr.ccrMenuOptions.checkStatus} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.checkStatus)}`);
|
|
215
|
-
console.log(` ${ansis.cyan("4.")} ${i18n.ccr.ccrMenuOptions.restart} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.restart)}`);
|
|
216
|
-
console.log(` ${ansis.cyan("5.")} ${i18n.ccr.ccrMenuOptions.start} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.start)}`);
|
|
217
|
-
console.log(` ${ansis.cyan("6.")} ${i18n.ccr.ccrMenuOptions.stop} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.stop)}`);
|
|
218
|
-
console.log(` ${ansis.yellow("0.")} ${i18n.ccr.ccrMenuOptions.back}`);
|
|
219
|
-
console.log("");
|
|
220
|
-
const { choice } = await inquirer$1.prompt({
|
|
221
|
-
type: "list",
|
|
222
|
-
name: "choice",
|
|
223
|
-
message: i18n.common.enterChoice,
|
|
224
|
-
choices: [
|
|
225
|
-
{ name: `${i18n.ccr.ccrMenuOptions.initCcr} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.initCcr)}`, value: "1" },
|
|
226
|
-
{ name: `${i18n.ccr.ccrMenuOptions.startUi} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.startUi)}`, value: "2" },
|
|
227
|
-
{ name: `${i18n.ccr.ccrMenuOptions.checkStatus} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.checkStatus)}`, value: "3" },
|
|
228
|
-
{ name: `${i18n.ccr.ccrMenuOptions.restart} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.restart)}`, value: "4" },
|
|
229
|
-
{ name: `${i18n.ccr.ccrMenuOptions.start} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.start)}`, value: "5" },
|
|
230
|
-
{ name: `${i18n.ccr.ccrMenuOptions.stop} ${ansis.gray("- " + i18n.ccr.ccrMenuDescriptions.stop)}`, value: "6" },
|
|
231
|
-
{ name: i18n.ccr.ccrMenuOptions.back, value: "0" }
|
|
232
|
-
]
|
|
233
|
-
});
|
|
234
|
-
switch (choice) {
|
|
235
|
-
case "1":
|
|
236
|
-
const ccrStatus = await isCcrInstalled();
|
|
237
|
-
if (!ccrStatus.hasCorrectPackage) {
|
|
238
|
-
await installCcr(scriptLang);
|
|
239
|
-
} else {
|
|
240
|
-
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrAlreadyInstalled}`));
|
|
241
|
-
}
|
|
242
|
-
await configureCcrFeature(scriptLang);
|
|
243
|
-
console.log(ansis.green(`
|
|
244
|
-
\u2714 ${i18n.ccr.ccrSetupComplete}`));
|
|
245
|
-
break;
|
|
246
|
-
case "2":
|
|
247
|
-
if (!isCcrConfigured()) {
|
|
248
|
-
console.log(ansis.yellow(`
|
|
249
|
-
\u26A0\uFE0F ${i18n.ccr.ccrNotConfigured || "CCR is not configured yet. Please initialize CCR first."}`));
|
|
250
|
-
console.log(ansis.cyan(` ${i18n.ccr.pleaseInitFirst || "Please select option 1 to initialize CCR."}
|
|
251
|
-
`));
|
|
252
|
-
} else {
|
|
253
|
-
const config = readCcrConfig();
|
|
254
|
-
await runCcrUi(scriptLang, config?.APIKEY);
|
|
255
|
-
}
|
|
256
|
-
break;
|
|
257
|
-
case "3":
|
|
258
|
-
if (!isCcrConfigured()) {
|
|
259
|
-
console.log(ansis.yellow(`
|
|
260
|
-
\u26A0\uFE0F ${i18n.ccr.ccrNotConfigured || "CCR is not configured yet. Please initialize CCR first."}`));
|
|
261
|
-
console.log(ansis.cyan(` ${i18n.ccr.pleaseInitFirst || "Please select option 1 to initialize CCR."}
|
|
262
|
-
`));
|
|
263
|
-
} else {
|
|
264
|
-
await runCcrStatus(scriptLang);
|
|
265
|
-
}
|
|
266
|
-
break;
|
|
267
|
-
case "4":
|
|
268
|
-
if (!isCcrConfigured()) {
|
|
269
|
-
console.log(ansis.yellow(`
|
|
270
|
-
\u26A0\uFE0F ${i18n.ccr.ccrNotConfigured || "CCR is not configured yet. Please initialize CCR first."}`));
|
|
271
|
-
console.log(ansis.cyan(` ${i18n.ccr.pleaseInitFirst || "Please select option 1 to initialize CCR."}
|
|
272
|
-
`));
|
|
273
|
-
} else {
|
|
274
|
-
await runCcrRestart(scriptLang);
|
|
275
|
-
}
|
|
276
|
-
break;
|
|
277
|
-
case "5":
|
|
278
|
-
if (!isCcrConfigured()) {
|
|
279
|
-
console.log(ansis.yellow(`
|
|
280
|
-
\u26A0\uFE0F ${i18n.ccr.ccrNotConfigured || "CCR is not configured yet. Please initialize CCR first."}`));
|
|
281
|
-
console.log(ansis.cyan(` ${i18n.ccr.pleaseInitFirst || "Please select option 1 to initialize CCR."}
|
|
282
|
-
`));
|
|
283
|
-
} else {
|
|
284
|
-
await runCcrStart(scriptLang);
|
|
285
|
-
}
|
|
286
|
-
break;
|
|
287
|
-
case "6":
|
|
288
|
-
if (!isCcrConfigured()) {
|
|
289
|
-
console.log(ansis.yellow(`
|
|
290
|
-
\u26A0\uFE0F ${i18n.ccr.ccrNotConfigured || "CCR is not configured yet. Please initialize CCR first."}`));
|
|
291
|
-
console.log(ansis.cyan(` ${i18n.ccr.pleaseInitFirst || "Please select option 1 to initialize CCR."}
|
|
292
|
-
`));
|
|
293
|
-
} else {
|
|
294
|
-
await runCcrStop(scriptLang);
|
|
295
|
-
}
|
|
296
|
-
break;
|
|
297
|
-
case "0":
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
if (choice !== "0") {
|
|
301
|
-
console.log("\n" + ansis.dim("\u2500".repeat(50)) + "\n");
|
|
302
|
-
const { continueInCcr } = await inquirer$1.prompt({
|
|
303
|
-
type: "confirm",
|
|
304
|
-
name: "continueInCcr",
|
|
305
|
-
message: i18n.common.returnToMenu || "Return to CCR menu?",
|
|
306
|
-
default: true
|
|
307
|
-
});
|
|
308
|
-
if (continueInCcr) {
|
|
309
|
-
return await showCcrMenu(scriptLang);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return false;
|
|
313
|
-
} catch (error) {
|
|
314
|
-
if (!handleExitPromptError(error)) {
|
|
315
|
-
handleGeneralError(error, scriptLang);
|
|
316
|
-
}
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function getValidLanguage(lang) {
|
|
322
|
-
return lang && lang in I18N ? lang : "en";
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
async function executeCcusage(args = []) {
|
|
326
|
-
try {
|
|
327
|
-
let lang = "en";
|
|
328
|
-
try {
|
|
329
|
-
const aicoConfig = await readAicoConfigAsync();
|
|
330
|
-
const rawLang = aicoConfig?.preferredLang || "en";
|
|
331
|
-
lang = getValidLanguage(rawLang);
|
|
332
|
-
} catch {
|
|
333
|
-
lang = "en";
|
|
334
|
-
}
|
|
335
|
-
const i18n = I18N[lang];
|
|
336
|
-
const command = "npx";
|
|
337
|
-
const commandArgs = ["ccusage@latest", ...args || []];
|
|
338
|
-
console.log(ansis.cyan(i18n.tools.runningCcusage));
|
|
339
|
-
console.log(ansis.gray(`$ npx ccusage@latest ${(args || []).join(" ")}`));
|
|
340
|
-
console.log("");
|
|
341
|
-
await x(command, commandArgs, {
|
|
342
|
-
nodeOptions: {
|
|
343
|
-
stdio: "inherit"
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
} catch (error) {
|
|
347
|
-
let lang = "en";
|
|
348
|
-
try {
|
|
349
|
-
const aicoConfig = await readAicoConfigAsync();
|
|
350
|
-
const rawLang = aicoConfig?.preferredLang || "en";
|
|
351
|
-
lang = getValidLanguage(rawLang);
|
|
352
|
-
} catch {
|
|
353
|
-
lang = "en";
|
|
354
|
-
}
|
|
355
|
-
const i18n = I18N[lang];
|
|
356
|
-
console.error(ansis.red(i18n.tools.ccusageFailed));
|
|
357
|
-
console.error(ansis.yellow(i18n.tools.checkNetworkConnection));
|
|
358
|
-
if (process.env.DEBUG) {
|
|
359
|
-
console.error(ansis.gray(i18n.tools.errorDetails), error);
|
|
360
|
-
}
|
|
361
|
-
if (process.env.NODE_ENV !== "test") {
|
|
362
|
-
process.exit(1);
|
|
363
|
-
}
|
|
364
|
-
throw error;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const execAsync = promisify$1(exec$1);
|
|
369
|
-
async function runCometixPrintConfig(scriptLang) {
|
|
370
|
-
const i18n = getTranslation(scriptLang);
|
|
371
|
-
try {
|
|
372
|
-
console.log(ansis.blue(`${i18n.cometix.printingConfig}`));
|
|
373
|
-
const { stdout } = await execAsync(COMETIX_COMMANDS.PRINT_CONFIG);
|
|
374
|
-
console.log(stdout);
|
|
375
|
-
} catch (error) {
|
|
376
|
-
if (error.message.includes(`command not found: ${COMETIX_COMMAND_NAME}`)) {
|
|
377
|
-
console.error(ansis.red(`\u2717 ${i18n.cometix.commandNotFound}`));
|
|
378
|
-
} else {
|
|
379
|
-
console.error(ansis.red(`\u2717 ${i18n.cometix.printConfigFailed}: ${error}`));
|
|
380
|
-
}
|
|
381
|
-
throw error;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
async function showCometixMenu(scriptLang) {
|
|
386
|
-
try {
|
|
387
|
-
const i18n = getTranslation(scriptLang);
|
|
388
|
-
console.log("\n" + ansis.cyan("\u2550".repeat(50)));
|
|
389
|
-
console.log(ansis.bold.cyan(` ${i18n.cometix.cometixMenuTitle}`));
|
|
390
|
-
console.log(ansis.cyan("\u2550".repeat(50)) + "\n");
|
|
391
|
-
console.log(` ${ansis.cyan("1.")} ${i18n.cometix.cometixMenuOptions.installOrUpdate} ${ansis.gray("- " + i18n.cometix.cometixMenuDescriptions.installOrUpdate)}`);
|
|
392
|
-
console.log(` ${ansis.cyan("2.")} ${i18n.cometix.cometixMenuOptions.printConfig} ${ansis.gray("- " + i18n.cometix.cometixMenuDescriptions.printConfig)}`);
|
|
393
|
-
console.log(` ${ansis.yellow("0.")} ${i18n.cometix.cometixMenuOptions.back}`);
|
|
394
|
-
console.log("");
|
|
395
|
-
const { choice } = await inquirer$1.prompt({
|
|
396
|
-
type: "input",
|
|
397
|
-
name: "choice",
|
|
398
|
-
message: i18n.common.enterChoice,
|
|
399
|
-
validate: (value) => {
|
|
400
|
-
const valid = ["1", "2", "0"];
|
|
401
|
-
return valid.includes(value) || i18n.common.invalidChoice;
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
switch (choice) {
|
|
405
|
-
case "1":
|
|
406
|
-
await installCometixLine(scriptLang);
|
|
407
|
-
break;
|
|
408
|
-
case "2":
|
|
409
|
-
await runCometixPrintConfig(scriptLang);
|
|
410
|
-
break;
|
|
411
|
-
case "0":
|
|
412
|
-
return false;
|
|
413
|
-
}
|
|
414
|
-
if (choice !== "0") {
|
|
415
|
-
console.log("\n" + ansis.dim("\u2500".repeat(50)) + "\n");
|
|
416
|
-
const { continueInCometix } = await inquirer$1.prompt({
|
|
417
|
-
type: "confirm",
|
|
418
|
-
name: "continueInCometix",
|
|
419
|
-
message: i18n.common.returnToMenu,
|
|
420
|
-
default: true
|
|
421
|
-
});
|
|
422
|
-
if (continueInCometix) {
|
|
423
|
-
return await showCometixMenu(scriptLang);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
return false;
|
|
427
|
-
} catch (error) {
|
|
428
|
-
if (!handleExitPromptError(error)) {
|
|
429
|
-
handleGeneralError(error, scriptLang);
|
|
430
|
-
}
|
|
431
|
-
return false;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
function handleCancellation(scriptLang) {
|
|
436
|
-
const i18n = getTranslation(scriptLang);
|
|
437
|
-
console.log(ansis.yellow(i18n.common.cancelled));
|
|
438
|
-
}
|
|
439
|
-
async function configureMcpFeature(scriptLang) {
|
|
440
|
-
const i18n = getTranslation(scriptLang);
|
|
441
|
-
if (isWindows()) {
|
|
442
|
-
const { fixWindows } = await inquirer.prompt({
|
|
443
|
-
type: "confirm",
|
|
444
|
-
name: "fixWindows",
|
|
445
|
-
message: i18n.configuration.fixWindowsMcp || "Fix Windows MCP configuration?",
|
|
446
|
-
default: true
|
|
447
|
-
});
|
|
448
|
-
if (fixWindows) {
|
|
449
|
-
const existingConfig = readMcpConfig() || { mcpServers: {} };
|
|
450
|
-
const fixedConfig = fixWindowsMcpConfig(existingConfig);
|
|
451
|
-
writeMcpConfig(fixedConfig);
|
|
452
|
-
console.log(ansis.green(`\u2714 Windows MCP configuration fixed`));
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
const selectedServices = await selectMcpServices(scriptLang);
|
|
456
|
-
if (selectedServices === void 0) {
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
if (selectedServices.length === 0) {
|
|
460
|
-
console.log(
|
|
461
|
-
ansis.yellow(i18n.mcp.noServicesSelected || "\u6CA1\u6709\u9009\u62E9\u4EFB\u4F55\u670D\u52A1")
|
|
462
|
-
);
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
if (selectedServices.length > 0) {
|
|
466
|
-
const mcpBackupPath = backupMcpConfig();
|
|
467
|
-
if (mcpBackupPath) {
|
|
468
|
-
console.log(
|
|
469
|
-
ansis.gray(`\u2714 ${i18n.mcp.mcpBackupSuccess}: ${mcpBackupPath}`)
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
const newServers = {};
|
|
473
|
-
const installResults = [];
|
|
474
|
-
for (const serviceId of selectedServices) {
|
|
475
|
-
const service = MCP_SERVICES.find((s) => s.id === serviceId);
|
|
476
|
-
if (!service) {
|
|
477
|
-
installResults.push({
|
|
478
|
-
serviceId,
|
|
479
|
-
serviceName: serviceId,
|
|
480
|
-
success: false,
|
|
481
|
-
reason: i18n.mcp.serviceNotFound || "\u670D\u52A1\u672A\u627E\u5230"
|
|
482
|
-
});
|
|
483
|
-
continue;
|
|
484
|
-
}
|
|
485
|
-
try {
|
|
486
|
-
let config = service.config;
|
|
487
|
-
if (service.requiresApiKey) {
|
|
488
|
-
console.log(ansis.cyan(`
|
|
489
|
-
\u914D\u7F6E ${service.name[scriptLang]}...`));
|
|
490
|
-
const { apiKey } = await inquirer.prompt({
|
|
491
|
-
type: "input",
|
|
492
|
-
name: "apiKey",
|
|
493
|
-
message: service.apiKeyPrompt[scriptLang],
|
|
494
|
-
validate: (value) => !!value || i18n.api.keyRequired
|
|
495
|
-
});
|
|
496
|
-
if (apiKey) {
|
|
497
|
-
config = buildMcpServerConfig(
|
|
498
|
-
service.config,
|
|
499
|
-
apiKey,
|
|
500
|
-
service.apiKeyPlaceholder,
|
|
501
|
-
service.apiKeyEnvVar
|
|
502
|
-
);
|
|
503
|
-
newServers[service.id] = config;
|
|
504
|
-
installResults.push({
|
|
505
|
-
serviceId: service.id,
|
|
506
|
-
serviceName: service.name[scriptLang],
|
|
507
|
-
success: true
|
|
508
|
-
});
|
|
509
|
-
console.log(ansis.green(`\u2714 ${service.name[scriptLang]} \u914D\u7F6E\u6210\u529F`));
|
|
510
|
-
} else {
|
|
511
|
-
installResults.push({
|
|
512
|
-
serviceId: service.id,
|
|
513
|
-
serviceName: service.name[scriptLang],
|
|
514
|
-
success: false,
|
|
515
|
-
reason: i18n.mcp.apiKeyRequired || "API Key \u5FC5\u586B"
|
|
516
|
-
});
|
|
517
|
-
console.log(
|
|
518
|
-
ansis.yellow(
|
|
519
|
-
`\u26A0 ${service.name[scriptLang]} \u914D\u7F6E\u8DF3\u8FC7\uFF08\u672A\u63D0\u4F9B API Key\uFF09`
|
|
520
|
-
)
|
|
521
|
-
);
|
|
522
|
-
}
|
|
523
|
-
} else {
|
|
524
|
-
if (service.presetApiKey && service.apiKeyEnvVar) {
|
|
525
|
-
config = buildMcpServerConfig(
|
|
526
|
-
service.config,
|
|
527
|
-
service.presetApiKey,
|
|
528
|
-
service.apiKeyPlaceholder,
|
|
529
|
-
service.apiKeyEnvVar
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
newServers[service.id] = config;
|
|
533
|
-
installResults.push({
|
|
534
|
-
serviceId: service.id,
|
|
535
|
-
serviceName: service.name[scriptLang],
|
|
536
|
-
success: true
|
|
537
|
-
});
|
|
538
|
-
console.log(ansis.green(`\u2714 ${service.name[scriptLang]} \u914D\u7F6E\u6210\u529F`));
|
|
539
|
-
}
|
|
540
|
-
} catch (error) {
|
|
541
|
-
if (error instanceof EscapeKeyPressed) {
|
|
542
|
-
installResults.push({
|
|
543
|
-
serviceId: service.id,
|
|
544
|
-
serviceName: service.name[scriptLang],
|
|
545
|
-
success: false,
|
|
546
|
-
reason: i18n.common.cancelled || "\u7528\u6237\u53D6\u6D88"
|
|
547
|
-
});
|
|
548
|
-
console.log(ansis.yellow(`\u26A0 ${service.name[scriptLang]} \u914D\u7F6E\u5DF2\u53D6\u6D88`));
|
|
549
|
-
} else {
|
|
550
|
-
installResults.push({
|
|
551
|
-
serviceId: service.id,
|
|
552
|
-
serviceName: service.name[scriptLang],
|
|
553
|
-
success: false,
|
|
554
|
-
reason: error.message || i18n.common.error || "\u914D\u7F6E\u5931\u8D25"
|
|
555
|
-
});
|
|
556
|
-
console.log(
|
|
557
|
-
ansis.red(
|
|
558
|
-
`\u2717 ${service.name[scriptLang]} \u914D\u7F6E\u5931\u8D25: ${error.message}`
|
|
559
|
-
)
|
|
560
|
-
);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
if (Object.keys(newServers).length > 0) {
|
|
565
|
-
const existingConfig = readMcpConfig();
|
|
566
|
-
let mergedConfig = mergeMcpServers(existingConfig, newServers);
|
|
567
|
-
mergedConfig = fixWindowsMcpConfig(mergedConfig);
|
|
568
|
-
writeMcpConfig(mergedConfig);
|
|
569
|
-
}
|
|
570
|
-
console.log("\n" + ansis.dim("\u2500".repeat(50)));
|
|
571
|
-
console.log(ansis.bold(i18n.mcp.installationSummary || "MCP \u670D\u52A1\u5B89\u88C5\u7ED3\u679C"));
|
|
572
|
-
console.log(ansis.dim("\u2500".repeat(50)));
|
|
573
|
-
const successfulServices = installResults.filter((r) => r.success);
|
|
574
|
-
const failedServices = installResults.filter((r) => !r.success);
|
|
575
|
-
if (successfulServices.length > 0) {
|
|
576
|
-
console.log(
|
|
577
|
-
ansis.green(`\u2714 \u6210\u529F\u5B89\u88C5 ${successfulServices.length} \u4E2A\u670D\u52A1:`)
|
|
578
|
-
);
|
|
579
|
-
successfulServices.forEach((service) => {
|
|
580
|
-
console.log(ansis.green(` \u2022 ${service.serviceName}`));
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
if (failedServices.length > 0) {
|
|
584
|
-
console.log(ansis.yellow(`
|
|
585
|
-
\u26A0 ${failedServices.length} \u4E2A\u670D\u52A1\u5B89\u88C5\u5931\u8D25:`));
|
|
586
|
-
failedServices.forEach((service) => {
|
|
587
|
-
console.log(
|
|
588
|
-
ansis.yellow(` \u2022 ${service.serviceName}: ${service.reason}`)
|
|
589
|
-
);
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
if (successfulServices.length > 0) {
|
|
593
|
-
console.log(ansis.green(`
|
|
594
|
-
\u2714 ${i18n.mcp.mcpConfigSuccess}`));
|
|
595
|
-
} else if (failedServices.length === selectedServices.length) {
|
|
596
|
-
console.log(
|
|
597
|
-
ansis.yellow(
|
|
598
|
-
`
|
|
599
|
-
\u26A0 ${i18n.mcp.noServicesInstalled || "\u6CA1\u6709\u670D\u52A1\u88AB\u6210\u529F\u5B89\u88C5"}`
|
|
600
|
-
)
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
async function configureAiMemoryFeature(scriptLang) {
|
|
606
|
-
const i18n = getTranslation(scriptLang);
|
|
607
|
-
const { option } = await inquirer.prompt({
|
|
608
|
-
type: "list",
|
|
609
|
-
name: "option",
|
|
610
|
-
message: "Select configuration option",
|
|
611
|
-
choices: addNumbersToChoices([
|
|
612
|
-
{
|
|
613
|
-
name: i18n.configuration.configureAiLanguage || "Configure AI output language",
|
|
614
|
-
value: "language"
|
|
615
|
-
},
|
|
616
|
-
{
|
|
617
|
-
name: i18n.configuration.configureAiPersonality || "Configure AI personality",
|
|
618
|
-
value: "personality"
|
|
619
|
-
}
|
|
620
|
-
])
|
|
621
|
-
});
|
|
622
|
-
if (!option) {
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
if (option === "language") {
|
|
626
|
-
const aicoConfig = readAicoConfig();
|
|
627
|
-
const aiOutputLang = await resolveAiOutputLanguage(
|
|
628
|
-
scriptLang,
|
|
629
|
-
void 0,
|
|
630
|
-
aicoConfig
|
|
631
|
-
);
|
|
632
|
-
applyAiLanguageDirective(aiOutputLang);
|
|
633
|
-
updateAicoConfig({ aiOutputLang });
|
|
634
|
-
console.log(
|
|
635
|
-
ansis.green(
|
|
636
|
-
`\u2714 ${i18n.configuration.aiLanguageConfigured || "AI output language configured"}`
|
|
637
|
-
)
|
|
638
|
-
);
|
|
639
|
-
} else {
|
|
640
|
-
await configureAiPersonality(scriptLang);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
async function configureCCR(scriptLang) {
|
|
644
|
-
const i18n = getTranslation(scriptLang);
|
|
645
|
-
const existingConfig = readCcrConfig();
|
|
646
|
-
const ccrInstallStatus = await isCcrInstalled();
|
|
647
|
-
if (existingConfig && ccrInstallStatus.isInstalled && ccrInstallStatus.hasCorrectPackage) {
|
|
648
|
-
console.log(ansis.green(`\u2714 ${i18n.ccr.existingCcrConfig || "CCR configuration already exists"}`));
|
|
649
|
-
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrAlreadyInstalled || "CCR is already installed"}`));
|
|
650
|
-
console.log(ansis.cyan(`${i18n.ccr.showingCcrMenu || "Showing CCR menu..."}`));
|
|
651
|
-
await showCcrMenu(scriptLang);
|
|
652
|
-
} else {
|
|
653
|
-
await configureCcrFeature(scriptLang);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
async function configureCCometixLine(scriptLang) {
|
|
657
|
-
await showCometixMenu(scriptLang);
|
|
658
|
-
}
|
|
659
|
-
async function configureEnvPermissionFeature(scriptLang) {
|
|
660
|
-
const i18n = getTranslation(scriptLang);
|
|
661
|
-
const { choice } = await inquirer.prompt({
|
|
662
|
-
type: "list",
|
|
663
|
-
name: "choice",
|
|
664
|
-
message: i18n.configuration?.selectEnvPermissionOption || "Select option",
|
|
665
|
-
choices: addNumbersToChoices([
|
|
666
|
-
{
|
|
667
|
-
name: `${i18n.configuration?.importRecommendedEnv || "Import environment"} ${ansis.gray(
|
|
668
|
-
"- " + (i18n.configuration?.importRecommendedEnvDesc || "Import env settings")
|
|
669
|
-
)}`,
|
|
670
|
-
value: "env"
|
|
671
|
-
},
|
|
672
|
-
{
|
|
673
|
-
name: `${i18n.configuration?.importRecommendedPermissions || "Import permissions"} ${ansis.gray(
|
|
674
|
-
"- " + (i18n.configuration?.importRecommendedPermissionsDesc || "Import permission settings")
|
|
675
|
-
)}`,
|
|
676
|
-
value: "permissions"
|
|
677
|
-
},
|
|
678
|
-
{
|
|
679
|
-
name: `${i18n.configuration?.openSettingsJson || "Open settings"} ${ansis.gray(
|
|
680
|
-
"- " + (i18n.configuration?.openSettingsJsonDesc || "View settings file")
|
|
681
|
-
)}`,
|
|
682
|
-
value: "open"
|
|
683
|
-
}
|
|
684
|
-
])
|
|
685
|
-
});
|
|
686
|
-
if (!choice) {
|
|
687
|
-
handleCancellation(scriptLang);
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
try {
|
|
691
|
-
switch (choice) {
|
|
692
|
-
case "env":
|
|
693
|
-
await importRecommendedEnv();
|
|
694
|
-
console.log(ansis.green(`\u2705 ${i18n.configuration.envImportSuccess}`));
|
|
695
|
-
break;
|
|
696
|
-
case "permissions":
|
|
697
|
-
await importRecommendedPermissions();
|
|
698
|
-
console.log(
|
|
699
|
-
ansis.green(
|
|
700
|
-
`\u2705 ${i18n.configuration?.permissionsImportSuccess || "Permissions imported"}`
|
|
701
|
-
)
|
|
702
|
-
);
|
|
703
|
-
break;
|
|
704
|
-
case "open":
|
|
705
|
-
console.log(
|
|
706
|
-
ansis.cyan(
|
|
707
|
-
i18n.configuration?.openingSettingsJson || "Opening settings.json..."
|
|
708
|
-
)
|
|
709
|
-
);
|
|
710
|
-
await openSettingsJson();
|
|
711
|
-
break;
|
|
712
|
-
}
|
|
713
|
-
} catch (error) {
|
|
714
|
-
console.error(ansis.red(`${i18n.common.error}: ${error.message}`));
|
|
715
|
-
}
|
|
716
|
-
}
|
|
17
|
+
import 'dayjs';
|
|
717
18
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
console.log(ansis.green("\u2705 \u4EE3\u7801\u7F16\u8F91\u5668\u5DF2\u9000\u51FA"));
|
|
724
|
-
resolve();
|
|
725
|
-
} else {
|
|
726
|
-
reject(new Error(`Claude \u8FDB\u7A0B\u9000\u51FA\uFF0C\u9000\u51FA\u7801: ${code}`));
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
child.on("error", (error) => {
|
|
730
|
-
reject(error);
|
|
731
|
-
});
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
async function startClaudeCodeEditor(_lang) {
|
|
735
|
-
try {
|
|
736
|
-
console.log(ansis.cyan("\u{1F680} \u6B63\u5728\u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668..."));
|
|
737
|
-
const isWindows = process.platform === "win32";
|
|
738
|
-
const spawnOptions = {
|
|
739
|
-
stdio: "inherit",
|
|
740
|
-
// 继承父进程的 stdio,这样可以在当前终端中交互
|
|
741
|
-
cwd: process.cwd(),
|
|
742
|
-
// 使用当前工作目录
|
|
743
|
-
shell: isWindows
|
|
744
|
-
// Windows 上使用 shell 来解析命令
|
|
745
|
-
};
|
|
746
|
-
try {
|
|
747
|
-
const command = isWindows ? "claude.cmd" : "claude";
|
|
748
|
-
await tryStartClaude(command, ["--dangerously-skip-permissions"], spawnOptions);
|
|
749
|
-
return;
|
|
750
|
-
} catch (firstError) {
|
|
751
|
-
if (firstError.code === "ENOENT") {
|
|
752
|
-
console.log(ansis.yellow("\u26A0\uFE0F \u76F4\u63A5\u8C03\u7528 claude \u5931\u8D25\uFF0C\u5C1D\u8BD5\u4F7F\u7528 npx..."));
|
|
753
|
-
try {
|
|
754
|
-
await tryStartClaude("npx", ["@anthropic-ai/claude-code", "--dangerously-skip-permissions"], spawnOptions);
|
|
755
|
-
return;
|
|
756
|
-
} catch (secondError) {
|
|
757
|
-
throw firstError;
|
|
758
|
-
}
|
|
759
|
-
} else {
|
|
760
|
-
throw firstError;
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
} catch (error) {
|
|
764
|
-
console.error(ansis.red("\u274C \u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668\u5931\u8D25:"));
|
|
765
|
-
if (error.code === "ENOENT" || error.message?.includes("command not found")) {
|
|
766
|
-
console.error(ansis.yellow("\u{1F4A1} \u8BF7\u786E\u4FDD\u5DF2\u5B89\u88C5 Claude Code:"));
|
|
767
|
-
console.error(ansis.gray(" npm install -g @anthropic-ai/claude-code"));
|
|
768
|
-
if (process.platform === "win32") {
|
|
769
|
-
console.error(ansis.yellow("\u{1F4A1} Windows \u7528\u6237\u989D\u5916\u63D0\u793A:"));
|
|
770
|
-
console.error(ansis.gray(" 1. \u91CD\u542F\u547D\u4EE4\u884C\u7A97\u53E3\u4EE5\u5237\u65B0 PATH \u73AF\u5883\u53D8\u91CF"));
|
|
771
|
-
console.error(ansis.gray(" 2. \u786E\u8BA4 npm \u5168\u5C40\u5B89\u88C5\u8DEF\u5F84\u5728 PATH \u4E2D"));
|
|
772
|
-
console.error(ansis.gray(" 3. \u5C1D\u8BD5\u4F7F\u7528 npx @anthropic-ai/claude-code --dangerously-skip-permissions"));
|
|
773
|
-
}
|
|
774
|
-
} else {
|
|
775
|
-
console.error(ansis.gray(` \u9519\u8BEF\u4FE1\u606F: ${error.message || error}`));
|
|
776
|
-
}
|
|
777
|
-
console.error(ansis.cyan("\n\u{1F4A1} \u6216\u8005\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5728\u547D\u4EE4\u884C\u4E2D\u624B\u52A8\u6267\u884C:"));
|
|
778
|
-
console.error(ansis.white(" claude --dangerously-skip-permissions"));
|
|
779
|
-
throw error;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
19
|
+
const inquirer = {
|
|
20
|
+
...inquirer$1,
|
|
21
|
+
prompt: createEscapablePrompt,
|
|
22
|
+
createPromptModule: inquirer$1.createPromptModule
|
|
23
|
+
};
|
|
782
24
|
|
|
783
25
|
async function getCurrentVersion() {
|
|
784
26
|
try {
|
|
@@ -879,152 +121,162 @@ async function updateAicoCli() {
|
|
|
879
121
|
}
|
|
880
122
|
}
|
|
881
123
|
|
|
882
|
-
|
|
124
|
+
promisify(exec);
|
|
125
|
+
|
|
126
|
+
promisify$1(exec$1);
|
|
127
|
+
|
|
128
|
+
promisify$1(exec$1);
|
|
129
|
+
|
|
130
|
+
async function tryStartClaude(command, args, options) {
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
const child = spawn(command, args, options);
|
|
133
|
+
child.on("close", (code) => {
|
|
134
|
+
if (code === 0) {
|
|
135
|
+
console.log(ansis.green("\u2705 \u4EE3\u7801\u7F16\u8F91\u5668\u5DF2\u9000\u51FA"));
|
|
136
|
+
resolve();
|
|
137
|
+
} else {
|
|
138
|
+
reject(new Error(`Claude \u8FDB\u7A0B\u9000\u51FA\uFF0C\u9000\u51FA\u7801: ${code}`));
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
child.on("error", (error) => {
|
|
142
|
+
reject(error);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async function startClaudeCodeEditor(_lang) {
|
|
883
147
|
try {
|
|
884
|
-
|
|
885
|
-
|
|
148
|
+
console.log(ansis.cyan("\u{1F680} \u6B63\u5728\u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668..."));
|
|
149
|
+
const isWindows = process.platform === "win32";
|
|
150
|
+
const spawnOptions = {
|
|
151
|
+
stdio: "inherit",
|
|
152
|
+
// 继承父进程的 stdio,这样可以在当前终端中交互
|
|
153
|
+
cwd: process.cwd(),
|
|
154
|
+
// 使用当前工作目录
|
|
155
|
+
shell: isWindows
|
|
156
|
+
// Windows 上使用 shell 来解析命令
|
|
157
|
+
};
|
|
158
|
+
try {
|
|
159
|
+
const command = isWindows ? "claude.cmd" : "claude";
|
|
160
|
+
await tryStartClaude(command, ["--dangerously-skip-permissions"], spawnOptions);
|
|
161
|
+
return;
|
|
162
|
+
} catch (firstError) {
|
|
163
|
+
if (firstError.code === "ENOENT") {
|
|
164
|
+
console.log(ansis.yellow("\u26A0\uFE0F \u76F4\u63A5\u8C03\u7528 claude \u5931\u8D25\uFF0C\u5C1D\u8BD5\u4F7F\u7528 npx..."));
|
|
165
|
+
try {
|
|
166
|
+
await tryStartClaude("npx", ["@anthropic-ai/claude-code", "--dangerously-skip-permissions"], spawnOptions);
|
|
167
|
+
return;
|
|
168
|
+
} catch (secondError) {
|
|
169
|
+
throw firstError;
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
throw firstError;
|
|
173
|
+
}
|
|
886
174
|
}
|
|
887
|
-
const scriptLang = await selectScriptLanguage();
|
|
888
|
-
const aicoConfig = readAicoConfig();
|
|
889
|
-
const i18n = I18N[scriptLang];
|
|
890
|
-
const configLang = options.configLang || "zh-CN";
|
|
891
|
-
const aiOutputLang = await resolveAiOutputLanguage(scriptLang, options.aiOutputLang, aicoConfig);
|
|
892
|
-
console.log(ansis.cyan(`
|
|
893
|
-
${i18n.configuration.updatingPrompts}
|
|
894
|
-
`));
|
|
895
|
-
await updatePromptOnly(configLang, scriptLang, aiOutputLang);
|
|
896
|
-
await selectAndInstallWorkflows(configLang, scriptLang);
|
|
897
|
-
updateAicoConfig({
|
|
898
|
-
version,
|
|
899
|
-
preferredLang: scriptLang,
|
|
900
|
-
aiOutputLang
|
|
901
|
-
});
|
|
902
175
|
} catch (error) {
|
|
903
|
-
|
|
904
|
-
|
|
176
|
+
console.error(ansis.red("\u274C \u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668\u5931\u8D25:"));
|
|
177
|
+
if (error.code === "ENOENT" || error.message?.includes("command not found")) {
|
|
178
|
+
console.error(ansis.yellow("\u{1F4A1} \u8BF7\u786E\u4FDD\u5DF2\u5B89\u88C5 Claude Code:"));
|
|
179
|
+
console.error(ansis.gray(" npm install -g @anthropic-ai/claude-code"));
|
|
180
|
+
if (process.platform === "win32") {
|
|
181
|
+
console.error(ansis.yellow("\u{1F4A1} Windows \u7528\u6237\u989D\u5916\u63D0\u793A:"));
|
|
182
|
+
console.error(ansis.gray(" 1. \u91CD\u542F\u547D\u4EE4\u884C\u7A97\u53E3\u4EE5\u5237\u65B0 PATH \u73AF\u5883\u53D8\u91CF"));
|
|
183
|
+
console.error(ansis.gray(" 2. \u786E\u8BA4 npm \u5168\u5C40\u5B89\u88C5\u8DEF\u5F84\u5728 PATH \u4E2D"));
|
|
184
|
+
console.error(ansis.gray(" 3. \u5C1D\u8BD5\u4F7F\u7528 npx @anthropic-ai/claude-code --dangerously-skip-permissions"));
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
console.error(ansis.gray(` \u9519\u8BEF\u4FE1\u606F: ${error.message || error}`));
|
|
905
188
|
}
|
|
189
|
+
console.error(ansis.cyan("\n\u{1F4A1} \u6216\u8005\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5728\u547D\u4EE4\u884C\u4E2D\u624B\u52A8\u6267\u884C:"));
|
|
190
|
+
console.error(ansis.white(" claude --dangerously-skip-permissions"));
|
|
191
|
+
throw error;
|
|
906
192
|
}
|
|
907
193
|
}
|
|
908
194
|
|
|
195
|
+
function createDefaultContext() {
|
|
196
|
+
return {
|
|
197
|
+
lang: "zh-CN",
|
|
198
|
+
platform: process.platform === "win32" ? "windows" : process.platform === "darwin" ? "macos" : "linux",
|
|
199
|
+
isCI: !!process.env.CI
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
async function launchCodeEditor() {
|
|
203
|
+
return startClaudeCodeEditor();
|
|
204
|
+
}
|
|
205
|
+
|
|
909
206
|
async function showMainMenu() {
|
|
910
207
|
try {
|
|
911
208
|
displayBannerWithInfo();
|
|
912
|
-
const aicoConfig = await readAicoConfigAsync();
|
|
913
|
-
let scriptLang = aicoConfig?.preferredLang || await selectScriptLanguage();
|
|
914
209
|
const menuProcessors = {
|
|
915
210
|
// 基础配置 - 放在前面
|
|
916
211
|
"1": {
|
|
917
212
|
key: "1",
|
|
918
|
-
|
|
919
|
-
|
|
213
|
+
label: "\u542F\u52A8\u516C\u53F8\u914D\u7F6E",
|
|
214
|
+
description: "\u4E00\u952E\u4F7F\u7528\u5B8C\u6574\u7684\u516C\u53F8\u914D\u7F6E\u670D\u52A1",
|
|
215
|
+
processor: () => init({ skipBanner: true }),
|
|
920
216
|
section: "\u57FA\u7840\u914D\u7F6E"
|
|
921
217
|
},
|
|
922
218
|
"2": {
|
|
923
219
|
key: "2",
|
|
924
|
-
|
|
925
|
-
|
|
220
|
+
label: "\u542F\u52A8\u4E2A\u4EBA\u914D\u7F6E",
|
|
221
|
+
description: "\u4E00\u952E\u914D\u7F6E\u4E2A\u4EBA\u672C\u5730\u6A21\u578B\u914D\u7F6E\u670D\u52A1",
|
|
222
|
+
processor: () => init({ skipBanner: true, apiType: "ccr_proxy" }),
|
|
926
223
|
section: "\u57FA\u7840\u914D\u7F6E"
|
|
927
224
|
},
|
|
928
225
|
"3": {
|
|
929
226
|
key: "3",
|
|
930
|
-
|
|
931
|
-
|
|
227
|
+
label: "\u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668",
|
|
228
|
+
description: "\u4E00\u952E\u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668\u8FDB\u884C\u4EE3\u7801\u5F00\u53D1",
|
|
229
|
+
processor: () => launchCodeEditor(),
|
|
932
230
|
section: "\u57FA\u7840\u914D\u7F6E"
|
|
933
231
|
},
|
|
934
232
|
"4": {
|
|
935
233
|
key: "4",
|
|
936
|
-
|
|
234
|
+
label: "\u66F4\u65B0\u7248\u672C",
|
|
235
|
+
description: "\u66F4\u65B0 \u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382 \u5230\u6700\u65B0\u7248\u672C",
|
|
937
236
|
processor: () => updateAicoCli(),
|
|
938
237
|
section: "\u57FA\u7840\u914D\u7F6E"
|
|
939
|
-
},
|
|
940
|
-
"5": {
|
|
941
|
-
key: "5",
|
|
942
|
-
labelKey: "configureMcp",
|
|
943
|
-
processor: () => configureMcpFeature(scriptLang),
|
|
944
|
-
section: "\u4E2A\u6027\u5316\u914D\u7F6E"
|
|
945
|
-
},
|
|
946
|
-
"6": {
|
|
947
|
-
key: "6",
|
|
948
|
-
labelKey: "configureAiMemory",
|
|
949
|
-
processor: () => configureAiMemoryFeature(scriptLang),
|
|
950
|
-
section: "\u4E2A\u6027\u5316\u914D\u7F6E"
|
|
951
|
-
},
|
|
952
|
-
"7": {
|
|
953
|
-
key: "7",
|
|
954
|
-
labelKey: "configureEnvPermission",
|
|
955
|
-
processor: () => configureEnvPermissionFeature(scriptLang),
|
|
956
|
-
section: "\u4E2A\u6027\u5316\u914D\u7F6E"
|
|
957
|
-
},
|
|
958
|
-
"8": {
|
|
959
|
-
key: "8",
|
|
960
|
-
labelKey: "importWorkflow",
|
|
961
|
-
processor: () => update({ skipBanner: true }),
|
|
962
|
-
section: "\u4E2A\u6027\u5316\u914D\u7F6E"
|
|
963
|
-
},
|
|
964
|
-
"9": {
|
|
965
|
-
key: "9",
|
|
966
|
-
labelKey: "configureCCometixLine",
|
|
967
|
-
processor: () => configureCCometixLine(scriptLang),
|
|
968
|
-
section: "\u4E2A\u6027\u5316\u914D\u7F6E"
|
|
969
238
|
}
|
|
970
|
-
// "10": {
|
|
971
|
-
// key: "10",
|
|
972
|
-
// labelKey: "configureCCUsage",
|
|
973
|
-
// processor: () => configureCCUsage(scriptLang),
|
|
974
|
-
// section: "个性化配置",
|
|
975
|
-
// },
|
|
976
239
|
};
|
|
977
240
|
let exitMenu = false;
|
|
978
241
|
while (!exitMenu) {
|
|
979
|
-
const i18n = I18N[scriptLang];
|
|
980
242
|
const menuChoices = Object.values(menuProcessors).map((item) => ({
|
|
981
|
-
name: `${item.key}. ${
|
|
243
|
+
name: `${item.key}. ${item.label} - ${ansis.gray(item.description || "")}`,
|
|
982
244
|
value: item.key,
|
|
983
|
-
short:
|
|
245
|
+
short: item.label
|
|
984
246
|
}));
|
|
985
247
|
menuChoices.push({
|
|
986
|
-
name: `0.
|
|
248
|
+
name: `0. \u9000\u51FA`,
|
|
987
249
|
value: "0",
|
|
988
|
-
short:
|
|
250
|
+
short: "\u9000\u51FA"
|
|
989
251
|
});
|
|
990
252
|
const { choice } = await inquirer$1.prompt({
|
|
991
253
|
type: "list",
|
|
992
254
|
name: "choice",
|
|
993
|
-
message:
|
|
255
|
+
message: "\u8BF7\u9009\u62E9\u529F\u80FD",
|
|
994
256
|
choices: menuChoices
|
|
995
257
|
});
|
|
996
258
|
if (!choice) {
|
|
997
|
-
console.log(ansis.yellow(
|
|
259
|
+
console.log(ansis.yellow("\u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
998
260
|
exitMenu = true;
|
|
999
261
|
break;
|
|
1000
262
|
}
|
|
1001
263
|
const menuChoice = choice.toLowerCase();
|
|
1002
264
|
if (menuChoice === "0") {
|
|
1003
265
|
exitMenu = true;
|
|
1004
|
-
console.log(ansis.cyan(
|
|
266
|
+
console.log(ansis.cyan("\u{1F44B} \u611F\u8C22\u4F7F\u7528 \u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382\uFF01\u518D\u89C1\uFF01"));
|
|
1005
267
|
continue;
|
|
1006
268
|
}
|
|
1007
269
|
const selectedItem = menuProcessors[choice];
|
|
1008
270
|
if (selectedItem) {
|
|
1009
271
|
const success = await executeWithEscapeSupport(
|
|
1010
|
-
selectedItem.processor
|
|
1011
|
-
i18n
|
|
272
|
+
selectedItem.processor
|
|
1012
273
|
);
|
|
1013
274
|
if (success) {
|
|
1014
|
-
if (selectedItem.key === "0") {
|
|
1015
|
-
try {
|
|
1016
|
-
const result = await selectedItem.processor();
|
|
1017
|
-
if (result !== scriptLang) {
|
|
1018
|
-
scriptLang = result;
|
|
1019
|
-
}
|
|
1020
|
-
} catch (error) {
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
275
|
try {
|
|
1024
|
-
await handleMenuContinuation(choice
|
|
276
|
+
await handleMenuContinuation(choice);
|
|
1025
277
|
} catch (continuationError) {
|
|
1026
278
|
if (continuationError.message === "EXIT_MENU") {
|
|
1027
|
-
console.log(ansis.cyan(
|
|
279
|
+
console.log(ansis.cyan("\u{1F44B} \u611F\u8C22\u4F7F\u7528 \u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382\uFF01\u518D\u89C1\uFF01"));
|
|
1028
280
|
exitMenu = true;
|
|
1029
281
|
break;
|
|
1030
282
|
}
|
|
@@ -1039,7 +291,7 @@ async function showMainMenu() {
|
|
|
1039
291
|
}
|
|
1040
292
|
}
|
|
1041
293
|
}
|
|
1042
|
-
async function handleMenuContinuation(choice
|
|
294
|
+
async function handleMenuContinuation(choice) {
|
|
1043
295
|
console.log("\n" + ansis.dim("\u2500".repeat(50)) + "\n");
|
|
1044
296
|
if (choice === "0" || choice === "-" || choice.toLowerCase() === "u" || choice.toLowerCase() === "r") {
|
|
1045
297
|
return;
|
|
@@ -1048,7 +300,7 @@ async function handleMenuContinuation(choice, i18n) {
|
|
|
1048
300
|
const { continue: shouldContinue } = await inquirer.prompt({
|
|
1049
301
|
type: "confirm",
|
|
1050
302
|
name: "continue",
|
|
1051
|
-
message:
|
|
303
|
+
message: "\u8FD4\u56DE\u4E3B\u83DC\u5355\uFF1F",
|
|
1052
304
|
default: true
|
|
1053
305
|
});
|
|
1054
306
|
if (!shouldContinue) {
|
|
@@ -1057,8 +309,7 @@ async function handleMenuContinuation(choice, i18n) {
|
|
|
1057
309
|
} catch (error) {
|
|
1058
310
|
if (error instanceof EscapeKeyPressed) {
|
|
1059
311
|
console.log(
|
|
1060
|
-
ansis.yellow(
|
|
1061
|
-
${i18n.common.returnToPrevious || "\u8FD4\u56DE\u4E0A\u4E00\u6B65"}`)
|
|
312
|
+
ansis.yellow("\n\u8FD4\u56DE\u4E0A\u4E00\u6B65")
|
|
1062
313
|
);
|
|
1063
314
|
return;
|
|
1064
315
|
}
|
|
@@ -1066,166 +317,101 @@ ${i18n.common.returnToPrevious || "\u8FD4\u56DE\u4E0A\u4E00\u6B65"}`)
|
|
|
1066
317
|
}
|
|
1067
318
|
}
|
|
1068
319
|
|
|
1069
|
-
async function
|
|
320
|
+
async function update(options = {}) {
|
|
1070
321
|
try {
|
|
1071
322
|
if (!options.skipBanner) {
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1074
|
-
const aicoConfig = await readAicoConfigAsync();
|
|
1075
|
-
const scriptLang = options.lang || aicoConfig?.preferredLang || await selectScriptLanguage();
|
|
1076
|
-
const continueInCcr = await showCcrMenu(scriptLang);
|
|
1077
|
-
if (!continueInCcr && !options.skipBanner) {
|
|
1078
|
-
await showMainMenu();
|
|
323
|
+
displayBanner("Update AICO CLI to latest version");
|
|
1079
324
|
}
|
|
325
|
+
await updateAicoCli();
|
|
326
|
+
console.log(ansis.green("\n\u2705 AICO CLI \u66F4\u65B0\u5B8C\u6210\uFF01"));
|
|
327
|
+
console.log(ansis.gray(" \u60A8\u53EF\u4EE5\u7EE7\u7EED\u4F7F\u7528\u5176\u4ED6\u547D\u4EE4\u914D\u7F6E\u63D0\u793A\u8BCD\u548C\u5DE5\u4F5C\u6D41\u3002"));
|
|
1080
328
|
} catch (error) {
|
|
1081
329
|
if (!handleExitPromptError(error)) {
|
|
1082
|
-
handleGeneralError(error
|
|
330
|
+
handleGeneralError(error);
|
|
1083
331
|
}
|
|
1084
332
|
}
|
|
1085
333
|
}
|
|
1086
334
|
|
|
1087
|
-
async function checkUpdates(options = {}) {
|
|
1088
|
-
const scriptLang = options.lang || await selectScriptLanguage();
|
|
1089
|
-
try {
|
|
1090
|
-
await checkAndUpdateTools(scriptLang);
|
|
1091
|
-
} catch (error) {
|
|
1092
|
-
console.error(ansis.red("Error checking updates:"), error);
|
|
1093
|
-
process.exit(1);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
335
|
function setupCommands(cli) {
|
|
1098
|
-
cli.command("
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
336
|
+
cli.command("", "\u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668\uFF08\u9ED8\u8BA4\uFF09").option("--menu", "\u663E\u793A\u4EA4\u4E92\u5F0F\u83DC\u5355").option("--init", "\u521D\u59CB\u5316\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382AI\u914D\u7F6E").option("--update", "\u66F4\u65B0\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382\u5230\u6700\u65B0\u7248\u672C").option("--company", "\u914D\u7F6E\u516C\u53F8\u914D\u7F6E").option("--personal", "\u914D\u7F6E\u4E2A\u4EBA\u914D\u7F6E").option("--help", "\u663E\u793A\u5E2E\u52A9\u4FE1\u606F").alias("i").alias("u").alias("c").alias("p").alias("h").action(async (options) => {
|
|
337
|
+
if (options.menu) {
|
|
338
|
+
await showMainMenu();
|
|
339
|
+
} else if (options.init) {
|
|
340
|
+
await init({ force: options.force });
|
|
341
|
+
} else if (options.update) {
|
|
342
|
+
await update({});
|
|
343
|
+
} else if (options.company) {
|
|
344
|
+
const { init: init2 } = await import('./chunks/simple-config.mjs').then(function (n) { return n.W; });
|
|
345
|
+
await init2({
|
|
346
|
+
apiType: "auth_token",
|
|
347
|
+
force: options.force,
|
|
348
|
+
skipBanner: false,
|
|
349
|
+
skipPrompt: true
|
|
350
|
+
});
|
|
351
|
+
} else if (options.personal) {
|
|
352
|
+
const { init: init2 } = await import('./chunks/simple-config.mjs').then(function (n) { return n.W; });
|
|
353
|
+
await init2({
|
|
354
|
+
apiType: "ccr_proxy",
|
|
355
|
+
force: options.force,
|
|
356
|
+
skipBanner: false,
|
|
357
|
+
skipPrompt: true
|
|
358
|
+
});
|
|
359
|
+
} else if (options.help) {
|
|
360
|
+
cli.outputHelp();
|
|
361
|
+
} else {
|
|
362
|
+
await startCodeEditor();
|
|
363
|
+
}
|
|
1115
364
|
});
|
|
1116
365
|
cli.help((sections) => customizeHelp(sections));
|
|
1117
366
|
cli.version(version);
|
|
367
|
+
return cli;
|
|
1118
368
|
}
|
|
1119
|
-
async function
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
369
|
+
async function startCodeEditor() {
|
|
370
|
+
try {
|
|
371
|
+
const context = createDefaultContext();
|
|
372
|
+
const checker = new ConfigCheckerInstaller(context);
|
|
373
|
+
const status = await checker.checkStatus();
|
|
374
|
+
if (status.isInstalled) {
|
|
375
|
+
console.log(ansis.green("\u2705 \u68C0\u6D4B\u5230\u5DF2\u6709\u914D\u7F6E\uFF0C\u68C0\u67E5\u5404\u529F\u80FD\u6A21\u5757\u5B89\u88C5\u72B6\u6001..."));
|
|
376
|
+
const { checkAllFeatures } = await import('./chunks/feature-checker.mjs');
|
|
377
|
+
const featureStatus = await checkAllFeatures(context);
|
|
378
|
+
const missingFeatures = Object.entries(featureStatus).filter(([_, status2]) => !status2.isInstalled).map(([name, _]) => name);
|
|
379
|
+
if (missingFeatures.length > 0) {
|
|
380
|
+
console.log(ansis.yellow(`\u26A0\uFE0F \u53D1\u73B0\u672A\u5B89\u88C5\u7684\u529F\u80FD\u6A21\u5757: ${missingFeatures.join(", ")}`));
|
|
381
|
+
console.log(ansis.yellow(" \u8FD0\u884C `aico --init` \u6216 `aico --update` \u6765\u5B89\u88C5\u7F3A\u5931\u529F\u80FD"));
|
|
382
|
+
}
|
|
383
|
+
} else {
|
|
384
|
+
console.log(ansis.yellow("\u26A0\uFE0F \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\uFF0C\u5C06\u5148\u6267\u884C\u521D\u59CB\u5316\u914D\u7F6E..."));
|
|
385
|
+
const { init: init2 } = await import('./chunks/simple-config.mjs').then(function (n) { return n.W; });
|
|
386
|
+
await init2({ skipBanner: true, skipPrompt: true });
|
|
387
|
+
}
|
|
388
|
+
await startClaudeCodeEditor();
|
|
389
|
+
} catch (error) {
|
|
390
|
+
console.error(ansis.red(`\u2716 \u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668\u5931\u8D25: ${error}`));
|
|
391
|
+
process.exit(1);
|
|
1128
392
|
}
|
|
1129
393
|
}
|
|
1130
|
-
async function handleInitCommand(options) {
|
|
1131
|
-
await init({
|
|
1132
|
-
lang: options.lang,
|
|
1133
|
-
configLang: options.configLang,
|
|
1134
|
-
aiOutputLang: options.aiOutputLang,
|
|
1135
|
-
force: options.force,
|
|
1136
|
-
skipPrompt: options.skipPrompt,
|
|
1137
|
-
configAction: options.configAction,
|
|
1138
|
-
apiKey: options.apiKey,
|
|
1139
|
-
apiUrl: options.apiUrl,
|
|
1140
|
-
mcpServices: options.mcpServices,
|
|
1141
|
-
workflows: options.workflows,
|
|
1142
|
-
aiPersonality: options.aiPersonality,
|
|
1143
|
-
allLang: options.allLang,
|
|
1144
|
-
installCometixLine: options.installCometixLine
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
async function handleUpdateCommand(options) {
|
|
1148
|
-
await update({ configLang: options.configLang });
|
|
1149
|
-
}
|
|
1150
394
|
function customizeHelp(sections) {
|
|
1151
395
|
sections.unshift({
|
|
1152
396
|
title: "",
|
|
1153
|
-
body: ansis.cyan.bold(`AICO -
|
|
1154
|
-
});
|
|
1155
|
-
sections.push({
|
|
1156
|
-
title: ansis.yellow("Commands / \u547D\u4EE4:"),
|
|
1157
|
-
body: [
|
|
1158
|
-
` ${ansis.cyan("aico")} Show interactive menu (default) / \u663E\u793A\u4EA4\u4E92\u5F0F\u83DC\u5355\uFF08\u9ED8\u8BA4\uFF09`,
|
|
1159
|
-
` ${ansis.cyan("aico init")} | ${ansis.cyan(
|
|
1160
|
-
"i"
|
|
1161
|
-
)} Initialize Claude Code configuration / \u521D\u59CB\u5316 Claude Code \u914D\u7F6E`,
|
|
1162
|
-
` ${ansis.cyan("aico update")} | ${ansis.cyan("u")} Update workflow-related md files / \u4EC5\u66F4\u65B0\u5DE5\u4F5C\u6D41\u76F8\u5173md`,
|
|
1163
|
-
` ${ansis.cyan("aico ccr")} Configure Claude Code Router for model proxy / \u914D\u7F6E\u6A21\u578B\u8DEF\u7531\u4EE3\u7406`,
|
|
1164
|
-
` ${ansis.cyan("aico ccu")} [args] Claude Code usage statistics analysis / Claude Code \u7528\u91CF\u7EDF\u8BA1\u5206\u6790`,
|
|
1165
|
-
` ${ansis.cyan("aico check-updates")} Check and update to latest versions / \u68C0\u67E5\u5E76\u66F4\u65B0\u5230\u6700\u65B0\u7248\u672C`,
|
|
1166
|
-
"",
|
|
1167
|
-
ansis.gray(" Shortcuts / \u5FEB\u6377\u65B9\u5F0F:"),
|
|
1168
|
-
` ${ansis.cyan("aico i")} Quick init / \u5FEB\u901F\u521D\u59CB\u5316`,
|
|
1169
|
-
` ${ansis.cyan("aico u")} Quick update / \u5FEB\u901F\u66F4\u65B0`,
|
|
1170
|
-
` ${ansis.cyan("aico check")} Quick check updates / \u5FEB\u901F\u68C0\u67E5\u66F4\u65B0`
|
|
1171
|
-
].join("\n")
|
|
397
|
+
body: ansis.cyan.bold(`AICO - \u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382 v${version}`)
|
|
1172
398
|
});
|
|
1173
399
|
sections.push({
|
|
1174
400
|
title: ansis.yellow("Options / \u9009\u9879:"),
|
|
1175
401
|
body: [
|
|
1176
|
-
` ${ansis.
|
|
1177
|
-
` ${ansis.
|
|
1178
|
-
` ${ansis.
|
|
1179
|
-
` ${ansis.
|
|
1180
|
-
` ${ansis.
|
|
1181
|
-
""
|
|
1182
|
-
ansis.gray(" Non-interactive mode (for CI/CD) / \u975E\u4EA4\u4E92\u6A21\u5F0F\uFF08\u9002\u7528\u4E8ECI/CD\uFF09:"),
|
|
1183
|
-
` ${ansis.green("--skip-prompt, -s")} Skip all prompts / \u8DF3\u8FC7\u6240\u6709\u4EA4\u4E92\u63D0\u793A`,
|
|
1184
|
-
` ${ansis.green("--api-type, -t")} <type> API type / API\u7C7B\u578B (auth_token, api_key, ccr_proxy, skip)`,
|
|
1185
|
-
` ${ansis.green("--api-key, -k")} <key> API key (for both types) / API\u5BC6\u94A5\uFF08\u9002\u7528\u4E8E\u6240\u6709\u7C7B\u578B\uFF09`,
|
|
1186
|
-
` ${ansis.green("--api-url, -u")} <url> Custom API URL / \u81EA\u5B9A\u4E49API\u5730\u5740`,
|
|
1187
|
-
` ${ansis.green("--ai-output-lang, -a")} <lang> AI output language / AI\u8F93\u51FA\u8BED\u8A00`,
|
|
1188
|
-
` ${ansis.green("--all-lang, -g")} <lang> Set all language params / \u7EDF\u4E00\u8BBE\u7F6E\u6240\u6709\u8BED\u8A00\u53C2\u6570`,
|
|
1189
|
-
` ${ansis.green("--config-action, -o")} <action> Config handling / \u914D\u7F6E\u5904\u7406 (default: backup)`,
|
|
1190
|
-
` ${ansis.green("--mcp-services, -m")} <list> MCP services / MCP\u670D\u52A1 (default: all non-key services)`,
|
|
1191
|
-
` ${ansis.green("--workflows, -w")} <list> Workflows / \u5DE5\u4F5C\u6D41 (default: all workflows)`,
|
|
1192
|
-
` ${ansis.green("--ai-personality, -p")} <type> AI personality / AI\u4E2A\u6027 (default: professional)`,
|
|
1193
|
-
` ${ansis.green("--install-cometix-line, -x")} <value> Install statusline tool / \u5B89\u88C5\u72B6\u6001\u680F\u5DE5\u5177 (default: true)`
|
|
1194
|
-
].join("\n")
|
|
1195
|
-
});
|
|
1196
|
-
sections.push({
|
|
1197
|
-
title: ansis.yellow("Examples / \u793A\u4F8B:"),
|
|
1198
|
-
body: [
|
|
1199
|
-
ansis.gray(" # Show interactive menu / \u663E\u793A\u4EA4\u4E92\u5F0F\u83DC\u5355"),
|
|
1200
|
-
` ${ansis.cyan("npx aico")}`,
|
|
1201
|
-
"",
|
|
1202
|
-
ansis.gray(" # Run full initialization / \u8FD0\u884C\u5B8C\u6574\u521D\u59CB\u5316"),
|
|
1203
|
-
` ${ansis.cyan("npx aico init")}`,
|
|
1204
|
-
` ${ansis.cyan("npx aico i")}`,
|
|
1205
|
-
` ${ansis.cyan("npx aico --init")}`,
|
|
1206
|
-
"",
|
|
1207
|
-
ansis.gray(" # Update workflow-related md files only / \u4EC5\u66F4\u65B0\u5DE5\u4F5C\u6D41\u76F8\u5173md\u6587\u4EF6"),
|
|
1208
|
-
` ${ansis.cyan("npx aico u")}`,
|
|
1209
|
-
"",
|
|
1210
|
-
ansis.gray(" # Configure Claude Code Router / \u914D\u7F6E Claude Code Router"),
|
|
1211
|
-
` ${ansis.cyan("npx aico ccr")}`,
|
|
1212
|
-
"",
|
|
1213
|
-
ansis.gray(" # Run Claude Code usage analysis / \u8FD0\u884C Claude Code \u7528\u91CF\u5206\u6790"),
|
|
1214
|
-
` ${ansis.cyan("npx aico ccu")} ${ansis.gray("# Daily usage (default)")}`,
|
|
1215
|
-
` ${ansis.cyan("npx aico ccu monthly --json")}`,
|
|
1216
|
-
"",
|
|
1217
|
-
ansis.gray(" # Check and update tools / \u68C0\u67E5\u5E76\u66F4\u65B0\u5DE5\u5177"),
|
|
1218
|
-
` ${ansis.cyan("npx aico check-updates")} ${ansis.gray("# Update Claude Code, CCR and CCometixLine")}`,
|
|
1219
|
-
` ${ansis.cyan("npx aico check")}`,
|
|
1220
|
-
"",
|
|
1221
|
-
ansis.gray(" # Non-interactive mode (CI/CD) / \u975E\u4EA4\u4E92\u6A21\u5F0F\uFF08CI/CD\uFF09"),
|
|
1222
|
-
` ${ansis.cyan('npx aico i --skip-prompt --api-type api_key --api-key "sk-ant-..."')}`,
|
|
1223
|
-
` ${ansis.cyan('npx aico i --skip-prompt --all-lang zh-CN --api-type api_key --api-key "key"')}`,
|
|
1224
|
-
` ${ansis.cyan("npx aico i --skip-prompt --api-type ccr_proxy")}`,
|
|
402
|
+
` ${ansis.cyan("--menu")} \u663E\u793A\u4EA4\u4E92\u5F0F\u83DC\u5355`,
|
|
403
|
+
` ${ansis.cyan("--init")} \u521D\u59CB\u5316\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382AI\u914D\u7F6E`,
|
|
404
|
+
` ${ansis.cyan("--update")} \u66F4\u65B0\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382\u5230\u6700\u65B0\u7248\u672C`,
|
|
405
|
+
` ${ansis.cyan("--company")} \u914D\u7F6E\u516C\u53F8\u914D\u7F6E`,
|
|
406
|
+
` ${ansis.cyan("--personal")} \u914D\u7F6E\u4E2A\u4EBA\u914D\u7F6E`,
|
|
407
|
+
` ${ansis.cyan("--help")} \u663E\u793A\u5E2E\u52A9\u4FE1\u606F`,
|
|
1225
408
|
"",
|
|
1226
|
-
ansis.gray("
|
|
1227
|
-
` ${ansis.cyan("
|
|
1228
|
-
` ${ansis.cyan("
|
|
409
|
+
ansis.gray(" \u5FEB\u6377\u65B9\u5F0F:"),
|
|
410
|
+
` ${ansis.cyan("aico i")} (--init) \u5FEB\u901F\u521D\u59CB\u5316`,
|
|
411
|
+
` ${ansis.cyan("aico u")} (--update) \u5FEB\u901F\u66F4\u65B0`,
|
|
412
|
+
` ${ansis.cyan("aico c")} (--company) \u516C\u53F8\u914D\u7F6E`,
|
|
413
|
+
` ${ansis.cyan("aico p")} (--personal) \u4E2A\u4EBA\u914D\u7F6E`,
|
|
414
|
+
` ${ansis.cyan("aico h")} (--help) \u663E\u793A\u5E2E\u52A9`
|
|
1229
415
|
].join("\n")
|
|
1230
416
|
});
|
|
1231
417
|
return sections;
|