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