aico-cli 2.0.32 → 2.0.33
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/bin/cli/cli.js +1400 -1366
- package/bin/cli/package.json +1 -1
- package/bin/cli/sdk-tools.d.ts +1 -4
- package/bin/cli/tree-sitter-bash.wasm +0 -0
- package/bin/cli/tree-sitter.wasm +0 -0
- package/dist/chunks/simple-config.mjs +163 -146
- package/dist/cli.mjs +134 -257
- package/package.json +2 -2
- package/templates/cursor.md +7 -3
- package/templates/hooks/install-hooks.ts +0 -3
- package/templates/hooks/scripts/PostToolUse/code-formatter.ts +1 -1
- package/templates/hooks/scripts/Stop/session-summary.ts +12 -10
- package/templates/hooks/scripts/UserPromptSubmit/input-notifier.ts +1 -1
- package/templates/hooks/scripts/UserPromptSubmit/user-prompt-submit.ts +2 -1
- package/templates/hooks/test-hook.ts +1 -1
- package/templates/personality.md +7 -2
- package/bin/cli/yoga.wasm +0 -0
package/bin/cli/package.json
CHANGED
package/bin/cli/sdk-tools.d.ts
CHANGED
|
@@ -94,10 +94,7 @@ export interface BashOutputInput {
|
|
|
94
94
|
filter?: string;
|
|
95
95
|
}
|
|
96
96
|
export interface ExitPlanModeInput {
|
|
97
|
-
|
|
98
|
-
* The plan you came up with, that you want to run by the user for approval. Supports markdown. The plan should be pretty concise.
|
|
99
|
-
*/
|
|
100
|
-
plan: string;
|
|
97
|
+
[k: string]: unknown;
|
|
101
98
|
}
|
|
102
99
|
export interface FileEditInput {
|
|
103
100
|
/**
|
|
Binary file
|
|
Binary file
|
|
@@ -14,11 +14,11 @@ import { join, dirname, basename } from 'pathe';
|
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
15
15
|
import { EventEmitter } from 'node:events';
|
|
16
16
|
|
|
17
|
-
const version = "2.0.
|
|
17
|
+
const version = "2.0.33";
|
|
18
18
|
|
|
19
19
|
function displayBanner(subtitle) {
|
|
20
20
|
const defaultSubtitle = "\u4E00\u952E\u914D\u7F6E\u4F60\u7684\u5F00\u53D1\u73AF\u5883";
|
|
21
|
-
const subtitleText =
|
|
21
|
+
const subtitleText = defaultSubtitle;
|
|
22
22
|
const paddedSubtitle = subtitleText.padEnd(60, " ");
|
|
23
23
|
console.log(
|
|
24
24
|
ansis.cyan.bold(`
|
|
@@ -39,7 +39,7 @@ function displayBanner(subtitle) {
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
function displayBannerWithInfo(subtitle) {
|
|
42
|
-
displayBanner(
|
|
42
|
+
displayBanner();
|
|
43
43
|
console.log(ansis.gray(` Version: ${ansis.cyan(version)}`));
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -171,8 +171,10 @@ class AbstractInstaller {
|
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* 通用日志方法
|
|
174
|
+
* @param silent 静默模式,不输出日志
|
|
174
175
|
*/
|
|
175
|
-
log(message, type = "info") {
|
|
176
|
+
log(message, type = "info", silent = false) {
|
|
177
|
+
if (silent) return;
|
|
176
178
|
const prefix = `[${this.name}]`;
|
|
177
179
|
switch (type) {
|
|
178
180
|
case "success":
|
|
@@ -285,12 +287,17 @@ class InstallerExecutor {
|
|
|
285
287
|
*/
|
|
286
288
|
async executeBatch(names, options) {
|
|
287
289
|
const results = {};
|
|
290
|
+
const silent = options?.silent ?? false;
|
|
288
291
|
for (const name of names) {
|
|
289
|
-
|
|
292
|
+
if (!silent) {
|
|
293
|
+
console.log(ansis.cyan(`
|
|
290
294
|
\u2501\u2501\u2501 \u6267\u884C\u5B89\u88C5\u5668: ${name} \u2501\u2501\u2501`));
|
|
295
|
+
}
|
|
291
296
|
results[name] = await this.execute(name, options);
|
|
292
297
|
if (!results[name].success && !options?.force) {
|
|
293
|
-
|
|
298
|
+
if (!silent) {
|
|
299
|
+
console.log(ansis.yellow(`\u5B89\u88C5\u5668 '${name}' \u5931\u8D25\uFF0C\u505C\u6B62\u6279\u91CF\u6267\u884C`));
|
|
300
|
+
}
|
|
294
301
|
break;
|
|
295
302
|
}
|
|
296
303
|
}
|
|
@@ -3589,15 +3596,7 @@ const messages = {
|
|
|
3589
3596
|
ccrSetupComplete: "CCR \u8BBE\u7F6E\u5B8C\u6210"
|
|
3590
3597
|
},
|
|
3591
3598
|
// 工具相关
|
|
3592
|
-
tools: {
|
|
3593
|
-
runningCcusage: "\u6B63\u5728\u8FD0\u884C Claude Code \u7528\u91CF\u5206\u6790\u5DE5\u5177...",
|
|
3594
|
-
ccusageDescription: "\u5206\u6790\u4EE4\u724C\u4F7F\u7528\u91CF\u548C\u6210\u672C - https://github.com/ryoppippi/ccusage",
|
|
3595
|
-
selectAnalysisMode: "\u9009\u62E9\u5206\u6790\u6A21\u5F0F:",
|
|
3596
|
-
enterCustomArgs: "\u8F93\u5165\u81EA\u5B9A\u4E49\u53C2\u6570 (\u4F8B\u5982: daily --json):",
|
|
3597
|
-
ccusageFailed: "\u8FD0\u884C ccusage \u5931\u8D25",
|
|
3598
|
-
checkNetworkConnection: "\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u5E76\u91CD\u8BD5",
|
|
3599
|
-
errorDetails: "\u9519\u8BEF\u8BE6\u60C5:"
|
|
3600
|
-
},
|
|
3599
|
+
tools: {},
|
|
3601
3600
|
// 错误处理
|
|
3602
3601
|
errors: {
|
|
3603
3602
|
unexpectedError: "\u53D1\u751F\u610F\u5916\u9519\u8BEF",
|
|
@@ -4334,45 +4333,41 @@ class CCRInstaller extends AbstractInstaller {
|
|
|
4334
4333
|
};
|
|
4335
4334
|
}
|
|
4336
4335
|
async install(options = {}) {
|
|
4336
|
+
const silent = options.silent ?? false;
|
|
4337
4337
|
try {
|
|
4338
4338
|
const status = await this.checkStatus();
|
|
4339
4339
|
if (status.hasCorrectPackage) {
|
|
4340
|
-
this.log("\u5DF2\u5B89\u88C5", "success");
|
|
4341
4340
|
if (!options.skipPrompt) {
|
|
4342
|
-
await this.update();
|
|
4341
|
+
await this.update(silent);
|
|
4343
4342
|
await setupCcrConfiguration();
|
|
4344
4343
|
const ccrConfig = await this.getCcrConfig();
|
|
4345
4344
|
if (ccrConfig) {
|
|
4346
|
-
await this.configureCcrProxy(ccrConfig);
|
|
4345
|
+
await this.configureCcrProxy(ccrConfig, silent);
|
|
4347
4346
|
}
|
|
4348
4347
|
}
|
|
4349
4348
|
return this.createSkipResult("CCR \u5DF2\u5B89\u88C5", "already_installed");
|
|
4350
4349
|
}
|
|
4351
4350
|
if (status.isInstalled && !status.hasCorrectPackage) {
|
|
4352
|
-
await this.uninstallIncorrectPackage();
|
|
4351
|
+
await this.uninstallIncorrectPackage(silent);
|
|
4353
4352
|
}
|
|
4354
|
-
this.log("\u6B63\u5728\u5B89\u88C5...", "info");
|
|
4355
4353
|
try {
|
|
4356
4354
|
await execAsync$1("npm install -g @musistudio/claude-code-router --force");
|
|
4357
|
-
this.log("\u5B89\u88C5\u6210\u529F", "success");
|
|
4358
4355
|
if (!options.skipConfig) {
|
|
4359
|
-
this.log("\u6B63\u5728\u914D\u7F6ECCR...", "info");
|
|
4360
4356
|
await setupCcrConfiguration();
|
|
4361
4357
|
const ccrConfig = await this.getCcrConfig();
|
|
4362
4358
|
if (ccrConfig) {
|
|
4363
|
-
await this.configureCcrProxy(ccrConfig);
|
|
4359
|
+
await this.configureCcrProxy(ccrConfig, silent);
|
|
4364
4360
|
}
|
|
4365
4361
|
}
|
|
4366
4362
|
return this.createSuccessResult("CCR \u5B89\u88C5\u6210\u529F");
|
|
4367
4363
|
} catch (error) {
|
|
4368
4364
|
if (error.message?.includes("EEXIST")) {
|
|
4369
|
-
this.log("\u5DF2\u5B89\u88C5\uFF08EEXIST\uFF09", "warning");
|
|
4370
4365
|
if (!options.skipPrompt) {
|
|
4371
|
-
await this.update();
|
|
4366
|
+
await this.update(silent);
|
|
4372
4367
|
await setupCcrConfiguration();
|
|
4373
4368
|
const ccrConfig = await this.getCcrConfig();
|
|
4374
4369
|
if (ccrConfig) {
|
|
4375
|
-
await this.configureCcrProxy(ccrConfig);
|
|
4370
|
+
await this.configureCcrProxy(ccrConfig, silent);
|
|
4376
4371
|
}
|
|
4377
4372
|
}
|
|
4378
4373
|
return this.createSkipResult("CCR \u5DF2\u5B89\u88C5", "eexist_error");
|
|
@@ -4383,24 +4378,20 @@ class CCRInstaller extends AbstractInstaller {
|
|
|
4383
4378
|
return this.handleError(error, "CCR \u5B89\u88C5");
|
|
4384
4379
|
}
|
|
4385
4380
|
}
|
|
4386
|
-
async update() {
|
|
4381
|
+
async update(silent = false) {
|
|
4387
4382
|
try {
|
|
4388
|
-
this.log("\u68C0\u67E5\u66F4\u65B0...", "info");
|
|
4389
4383
|
await updateCcr();
|
|
4390
4384
|
return this.createSuccessResult("CCR \u66F4\u65B0\u68C0\u67E5\u5B8C\u6210");
|
|
4391
4385
|
} catch (error) {
|
|
4392
4386
|
return this.handleError(error, "CCR \u66F4\u65B0");
|
|
4393
4387
|
}
|
|
4394
4388
|
}
|
|
4395
|
-
async uninstallIncorrectPackage() {
|
|
4389
|
+
async uninstallIncorrectPackage(silent = false) {
|
|
4396
4390
|
try {
|
|
4397
4391
|
await execAsync$1("npm list -g claude-code-router");
|
|
4398
|
-
this.log("\u68C0\u6D4B\u5230\u9519\u8BEF\u7684\u5305\uFF0C\u6B63\u5728\u5378\u8F7D...", "warning");
|
|
4399
4392
|
try {
|
|
4400
4393
|
await execAsync$1("npm uninstall -g claude-code-router");
|
|
4401
|
-
this.log("\u9519\u8BEF\u5305\u5378\u8F7D\u6210\u529F", "success");
|
|
4402
4394
|
} catch (uninstallError) {
|
|
4403
|
-
this.log("\u5378\u8F7D\u9519\u8BEF\u5305\u5931\u8D25", "warning");
|
|
4404
4395
|
}
|
|
4405
4396
|
} catch {
|
|
4406
4397
|
}
|
|
@@ -4434,7 +4425,7 @@ class CCRInstaller extends AbstractInstaller {
|
|
|
4434
4425
|
};
|
|
4435
4426
|
}
|
|
4436
4427
|
}
|
|
4437
|
-
async configureCcrProxy(ccrConfig) {
|
|
4428
|
+
async configureCcrProxy(ccrConfig, silent = false) {
|
|
4438
4429
|
try {
|
|
4439
4430
|
const settings = readJsonConfig(SETTINGS_FILE) || {};
|
|
4440
4431
|
const host = ccrConfig.HOST || "127.0.0.1";
|
|
@@ -4446,14 +4437,11 @@ class CCRInstaller extends AbstractInstaller {
|
|
|
4446
4437
|
settings.env.ANTHROPIC_BASE_URL = `http://${host}:${port}`;
|
|
4447
4438
|
settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
|
|
4448
4439
|
writeJsonConfig(SETTINGS_FILE, settings);
|
|
4449
|
-
this.log("\u4EE3\u7406\u914D\u7F6E\u5DF2\u66F4\u65B0", "success");
|
|
4450
4440
|
} catch (error) {
|
|
4451
|
-
this.log(`\u4EE3\u7406\u914D\u7F6E\u5931\u8D25: ${error.message}`, "warning");
|
|
4452
4441
|
}
|
|
4453
4442
|
}
|
|
4454
|
-
async startUI() {
|
|
4443
|
+
async startUI(silent = false) {
|
|
4455
4444
|
try {
|
|
4456
|
-
this.log("\u542F\u52A8 CCR UI \u754C\u9762...", "info");
|
|
4457
4445
|
const { spawn } = await import('node:child_process');
|
|
4458
4446
|
const command = isWindows() ? "npx" : "ccr";
|
|
4459
4447
|
const args = isWindows() ? ["ccr", "ui"] : ["ui"];
|
|
@@ -4461,12 +4449,8 @@ class CCRInstaller extends AbstractInstaller {
|
|
|
4461
4449
|
stdio: "ignore",
|
|
4462
4450
|
detached: true,
|
|
4463
4451
|
shell: false
|
|
4464
|
-
// 避免创建额外的shell进程
|
|
4465
4452
|
});
|
|
4466
4453
|
ccrProcess.unref();
|
|
4467
|
-
this.log("CCR UI \u5DF2\u542F\u52A8", "success");
|
|
4468
|
-
this.log("\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u8BBF\u95EE http://127.0.0.1:3456/ui/", "info");
|
|
4469
|
-
this.log("API\u5BC6\u94A5: sk-aico-x-ccr", "info");
|
|
4470
4454
|
return this.createSuccessResult("CCR UI \u542F\u52A8\u6210\u529F");
|
|
4471
4455
|
} catch (error) {
|
|
4472
4456
|
return this.handleError(error, "CCR UI \u542F\u52A8");
|
|
@@ -4530,32 +4514,19 @@ class CCometixLineInstaller extends AbstractInstaller {
|
|
|
4530
4514
|
}
|
|
4531
4515
|
}
|
|
4532
4516
|
async install(options = {}) {
|
|
4517
|
+
options.silent ?? false;
|
|
4533
4518
|
try {
|
|
4534
4519
|
const status = await this.checkStatus();
|
|
4535
4520
|
if (status.isInstalled) {
|
|
4536
|
-
this.log("\u5DF2\u5B89\u88C5", "success");
|
|
4537
|
-
if (!options.silent) {
|
|
4538
|
-
this.log("\u6B63\u5728\u68C0\u67E5\u66F4\u65B0...", "info");
|
|
4539
|
-
}
|
|
4540
4521
|
try {
|
|
4541
4522
|
await execAsync(COMETIX_COMMANDS.INSTALL);
|
|
4542
|
-
this.log("\u66F4\u65B0\u6210\u529F", "success");
|
|
4543
4523
|
} catch (error) {
|
|
4544
|
-
this.log(`\u66F4\u65B0\u5931\u8D25: ${error}`, "warning");
|
|
4545
|
-
}
|
|
4546
|
-
const configResult2 = await this.configure(options);
|
|
4547
|
-
if (!configResult2.success) {
|
|
4548
|
-
return configResult2;
|
|
4549
4524
|
}
|
|
4525
|
+
await this.configure(options);
|
|
4550
4526
|
return this.createSkipResult("CCometixLine \u5DF2\u5B89\u88C5\u5E76\u914D\u7F6E", "already_installed");
|
|
4551
4527
|
}
|
|
4552
|
-
this.log("\u6B63\u5728\u5B89\u88C5...", "info");
|
|
4553
4528
|
await execAsync(COMETIX_COMMANDS.INSTALL);
|
|
4554
|
-
this.
|
|
4555
|
-
const configResult = await this.configure(options);
|
|
4556
|
-
if (!configResult.success) {
|
|
4557
|
-
this.log("\u914D\u7F6E\u5931\u8D25\uFF0C\u4F46\u5B89\u88C5\u6210\u529F", "warning");
|
|
4558
|
-
}
|
|
4529
|
+
await this.configure(options);
|
|
4559
4530
|
return this.createSuccessResult("CCometixLine \u5B89\u88C5\u6210\u529F");
|
|
4560
4531
|
} catch (error) {
|
|
4561
4532
|
return this.handleError(error, "CCometixLine \u5B89\u88C5");
|
|
@@ -4564,14 +4535,11 @@ class CCometixLineInstaller extends AbstractInstaller {
|
|
|
4564
4535
|
async configure(options = {}) {
|
|
4565
4536
|
try {
|
|
4566
4537
|
if (hasCCometixLineConfig()) {
|
|
4567
|
-
this.log("\u72B6\u6001\u680F\u5DF2\u914D\u7F6E", "info");
|
|
4568
4538
|
return this.createSkipResult("\u72B6\u6001\u680F\u914D\u7F6E\u5DF2\u5B58\u5728", "already_configured");
|
|
4569
4539
|
}
|
|
4570
4540
|
addCCometixLineConfig();
|
|
4571
|
-
this.log("Claude Code \u72B6\u6001\u680F\u914D\u7F6E\u6210\u529F", "success");
|
|
4572
4541
|
return this.createSuccessResult("\u72B6\u6001\u680F\u914D\u7F6E\u5B8C\u6210");
|
|
4573
4542
|
} catch (error) {
|
|
4574
|
-
this.log("\u72B6\u6001\u680F\u914D\u7F6E\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6DFB\u52A0\u914D\u7F6E\u5230 Claude Code \u8BBE\u7F6E", "warning");
|
|
4575
4543
|
return this.handleError(error, "\u72B6\u6001\u680F\u914D\u7F6E");
|
|
4576
4544
|
}
|
|
4577
4545
|
}
|
|
@@ -4943,25 +4911,21 @@ class ConfigInstaller extends AbstractInstaller {
|
|
|
4943
4911
|
};
|
|
4944
4912
|
}
|
|
4945
4913
|
async install(options = {}) {
|
|
4914
|
+
options.silent ?? false;
|
|
4946
4915
|
try {
|
|
4947
4916
|
ensureClaudeDir();
|
|
4948
4917
|
const status = await this.checkStatus();
|
|
4949
4918
|
let backupPath;
|
|
4950
4919
|
if (status.isInstalled && !options.force) {
|
|
4951
|
-
this.log("\u68C0\u6D4B\u5230\u73B0\u6709\u914D\u7F6E\uFF0C\u5C06\u5907\u4EFD\u5E76\u8986\u76D6", "warning");
|
|
4952
4920
|
const backup = backupExistingConfig();
|
|
4953
4921
|
if (backup) {
|
|
4954
4922
|
backupPath = backup;
|
|
4955
|
-
this.log(`\u5907\u4EFD\u6210\u529F: ${backupPath}`, "info");
|
|
4956
4923
|
}
|
|
4957
4924
|
}
|
|
4958
4925
|
this.copyConfigFilesWithOptions(options);
|
|
4959
4926
|
const apiConfig = options.configData?.apiConfig;
|
|
4960
4927
|
if (apiConfig) {
|
|
4961
|
-
|
|
4962
|
-
if (configuredApi) {
|
|
4963
|
-
this.log("API \u914D\u7F6E\u6210\u529F", "success");
|
|
4964
|
-
}
|
|
4928
|
+
configureApi(apiConfig);
|
|
4965
4929
|
}
|
|
4966
4930
|
return this.createSuccessResult(
|
|
4967
4931
|
`\u914D\u7F6E\u5B8C\u6210`,
|
|
@@ -4999,7 +4963,7 @@ class ConfigInstaller extends AbstractInstaller {
|
|
|
4999
4963
|
/**
|
|
5000
4964
|
* 应用公司预设配置
|
|
5001
4965
|
*/
|
|
5002
|
-
async applyCompanyConfig() {
|
|
4966
|
+
async applyCompanyConfig(silent = false) {
|
|
5003
4967
|
try {
|
|
5004
4968
|
const apiConfig = {
|
|
5005
4969
|
url: "http://11.0.166.20:13456",
|
|
@@ -5007,7 +4971,6 @@ class ConfigInstaller extends AbstractInstaller {
|
|
|
5007
4971
|
};
|
|
5008
4972
|
const configuredApi = configureApi(apiConfig);
|
|
5009
4973
|
if (configuredApi) {
|
|
5010
|
-
this.log("\u516C\u53F8\u914D\u7F6E\u5E94\u7528\u6210\u529F", "success");
|
|
5011
4974
|
return this.createSuccessResult("\u516C\u53F8API\u914D\u7F6E\u6210\u529F");
|
|
5012
4975
|
}
|
|
5013
4976
|
return this.createFailureResult("\u516C\u53F8\u914D\u7F6E\u5E94\u7528\u5931\u8D25");
|
|
@@ -5018,14 +4981,13 @@ class ConfigInstaller extends AbstractInstaller {
|
|
|
5018
4981
|
/**
|
|
5019
4982
|
* 备份现有配置
|
|
5020
4983
|
*/
|
|
5021
|
-
async backupConfig() {
|
|
4984
|
+
async backupConfig(silent = false) {
|
|
5022
4985
|
try {
|
|
5023
4986
|
if (!existsSync(SETTINGS_FILE)) {
|
|
5024
4987
|
return this.createSkipResult("\u65E0\u73B0\u6709\u914D\u7F6E\u9700\u8981\u5907\u4EFD", "no_config");
|
|
5025
4988
|
}
|
|
5026
4989
|
const backupPath = backupExistingConfig();
|
|
5027
4990
|
if (backupPath) {
|
|
5028
|
-
this.log(`\u914D\u7F6E\u5907\u4EFD\u6210\u529F: ${backupPath}`, "success");
|
|
5029
4991
|
return this.createSuccessResult("\u914D\u7F6E\u5907\u4EFD\u5B8C\u6210", backupPath);
|
|
5030
4992
|
}
|
|
5031
4993
|
return this.createFailureResult("\u914D\u7F6E\u5907\u4EFD\u5931\u8D25");
|
|
@@ -5070,15 +5032,10 @@ class MCPInstaller extends AbstractInstaller {
|
|
|
5070
5032
|
return !options?.skipPrompt && !options?.configData?.mcpServices;
|
|
5071
5033
|
}
|
|
5072
5034
|
async install(options = {}) {
|
|
5035
|
+
options.silent ?? false;
|
|
5073
5036
|
try {
|
|
5074
|
-
if (isWindows()) {
|
|
5075
|
-
this.log("\u68C0\u6D4B\u5230 Windows \u7CFB\u7EDF\uFF0C\u5C06\u81EA\u52A8\u914D\u7F6E\u517C\u5BB9\u683C\u5F0F", "info");
|
|
5076
|
-
}
|
|
5077
5037
|
const selectedServices = MCP_SERVICES.map((service) => service.id);
|
|
5078
5038
|
const backupPath = backupMcpConfig();
|
|
5079
|
-
if (backupPath) {
|
|
5080
|
-
this.log(`MCP \u914D\u7F6E\u5DF2\u5907\u4EFD`, "info");
|
|
5081
|
-
}
|
|
5082
5039
|
const newServers = {};
|
|
5083
5040
|
for (const serviceId of selectedServices) {
|
|
5084
5041
|
const service = MCP_SERVICES.find((s) => s.id === serviceId);
|
|
@@ -5086,7 +5043,6 @@ class MCPInstaller extends AbstractInstaller {
|
|
|
5086
5043
|
let config = service.config;
|
|
5087
5044
|
if (service.requiresApiKey) {
|
|
5088
5045
|
if (options.skipPrompt) {
|
|
5089
|
-
this.log(`\u8DF3\u8FC7 ${service.name} (\u9700\u8981 API key)`, "warning");
|
|
5090
5046
|
continue;
|
|
5091
5047
|
} else {
|
|
5092
5048
|
const response = await inquirer.prompt({
|
|
@@ -5096,7 +5052,6 @@ class MCPInstaller extends AbstractInstaller {
|
|
|
5096
5052
|
validate: (value) => !!value || "Key \u5FC5\u586B"
|
|
5097
5053
|
});
|
|
5098
5054
|
if (!response.apiKey) {
|
|
5099
|
-
this.log(`\u8DF3\u8FC7 ${service.name}`, "warning");
|
|
5100
5055
|
continue;
|
|
5101
5056
|
}
|
|
5102
5057
|
config = buildMcpServerConfig(
|
|
@@ -5108,17 +5063,14 @@ class MCPInstaller extends AbstractInstaller {
|
|
|
5108
5063
|
}
|
|
5109
5064
|
}
|
|
5110
5065
|
newServers[service.id] = config;
|
|
5111
|
-
this.log(`\u914D\u7F6E\u670D\u52A1: ${service.name}`, "success");
|
|
5112
5066
|
}
|
|
5113
5067
|
const existingConfig = readMcpConfig();
|
|
5114
5068
|
let mergedConfig = mergeMcpServers(existingConfig, newServers);
|
|
5115
5069
|
mergedConfig = fixWindowsMcpConfig(mergedConfig);
|
|
5116
5070
|
writeMcpConfig(mergedConfig);
|
|
5117
|
-
this.log("MCP \u914D\u7F6E\u5199\u5165\u6210\u529F", "success");
|
|
5118
5071
|
try {
|
|
5119
5072
|
addCompletedOnboarding();
|
|
5120
5073
|
} catch (error) {
|
|
5121
|
-
this.log("\u8BBE\u7F6E\u5F15\u5BFC\u6807\u5FD7\u5931\u8D25", "warning");
|
|
5122
5074
|
}
|
|
5123
5075
|
return this.createSuccessResult(
|
|
5124
5076
|
`MCP \u914D\u7F6E\u5B8C\u6210\uFF0C\u5DF2\u914D\u7F6E ${Object.keys(newServers).length} \u4E2A\u670D\u52A1`,
|
|
@@ -5243,6 +5195,8 @@ const INSTALLER_NAMES = {
|
|
|
5243
5195
|
class ProcessManager extends EventEmitter {
|
|
5244
5196
|
processes = /* @__PURE__ */ new Map();
|
|
5245
5197
|
isShuttingDown = false;
|
|
5198
|
+
silent = true;
|
|
5199
|
+
// 默认静默模式,不输出日志
|
|
5246
5200
|
constructor() {
|
|
5247
5201
|
super();
|
|
5248
5202
|
this.setupSignalHandlers();
|
|
@@ -5674,10 +5628,17 @@ class ProcessManager extends EventEmitter {
|
|
|
5674
5628
|
}
|
|
5675
5629
|
return false;
|
|
5676
5630
|
}
|
|
5631
|
+
/**
|
|
5632
|
+
* 设置静默模式
|
|
5633
|
+
*/
|
|
5634
|
+
setSilent(silent) {
|
|
5635
|
+
this.silent = silent;
|
|
5636
|
+
}
|
|
5677
5637
|
/**
|
|
5678
5638
|
* 日志输出
|
|
5679
5639
|
*/
|
|
5680
5640
|
log(message, level = "info") {
|
|
5641
|
+
if (this.silent) return;
|
|
5681
5642
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
5682
5643
|
const prefix = `[${timestamp}] [ProcessManager]`;
|
|
5683
5644
|
switch (level) {
|
|
@@ -5736,6 +5697,74 @@ const runCommand = {
|
|
|
5736
5697
|
run: run
|
|
5737
5698
|
};
|
|
5738
5699
|
|
|
5700
|
+
class InstallSpinner {
|
|
5701
|
+
spinner = null;
|
|
5702
|
+
silent = false;
|
|
5703
|
+
constructor(silent = false) {
|
|
5704
|
+
this.silent = silent;
|
|
5705
|
+
}
|
|
5706
|
+
/**
|
|
5707
|
+
* 开始安装进度
|
|
5708
|
+
*/
|
|
5709
|
+
start(text) {
|
|
5710
|
+
if (this.silent) return;
|
|
5711
|
+
this.spinner = ora({
|
|
5712
|
+
text,
|
|
5713
|
+
color: "cyan",
|
|
5714
|
+
spinner: "dots"
|
|
5715
|
+
}).start();
|
|
5716
|
+
}
|
|
5717
|
+
/**
|
|
5718
|
+
* 更新进度文本
|
|
5719
|
+
*/
|
|
5720
|
+
update(text) {
|
|
5721
|
+
if (this.silent || !this.spinner) return;
|
|
5722
|
+
this.spinner.text = text;
|
|
5723
|
+
}
|
|
5724
|
+
/**
|
|
5725
|
+
* 成功完成
|
|
5726
|
+
*/
|
|
5727
|
+
succeed(text) {
|
|
5728
|
+
if (this.silent || !this.spinner) return;
|
|
5729
|
+
this.spinner.succeed(text);
|
|
5730
|
+
this.spinner = null;
|
|
5731
|
+
}
|
|
5732
|
+
/**
|
|
5733
|
+
* 失败
|
|
5734
|
+
*/
|
|
5735
|
+
fail(text) {
|
|
5736
|
+
if (this.silent || !this.spinner) return;
|
|
5737
|
+
this.spinner.fail(text);
|
|
5738
|
+
this.spinner = null;
|
|
5739
|
+
}
|
|
5740
|
+
/**
|
|
5741
|
+
* 警告
|
|
5742
|
+
*/
|
|
5743
|
+
warn(text) {
|
|
5744
|
+
if (this.silent || !this.spinner) return;
|
|
5745
|
+
this.spinner.warn(text);
|
|
5746
|
+
this.spinner = null;
|
|
5747
|
+
}
|
|
5748
|
+
/**
|
|
5749
|
+
* 停止(不显示状态)
|
|
5750
|
+
*/
|
|
5751
|
+
stop() {
|
|
5752
|
+
if (this.spinner) {
|
|
5753
|
+
this.spinner.stop();
|
|
5754
|
+
this.spinner = null;
|
|
5755
|
+
}
|
|
5756
|
+
}
|
|
5757
|
+
/**
|
|
5758
|
+
* 是否正在运行
|
|
5759
|
+
*/
|
|
5760
|
+
isSpinning() {
|
|
5761
|
+
return this.spinner?.isSpinning ?? false;
|
|
5762
|
+
}
|
|
5763
|
+
}
|
|
5764
|
+
function createInstallSpinner(silent = false) {
|
|
5765
|
+
return new InstallSpinner(silent);
|
|
5766
|
+
}
|
|
5767
|
+
|
|
5739
5768
|
class InstallationComposer {
|
|
5740
5769
|
executor;
|
|
5741
5770
|
context;
|
|
@@ -5781,50 +5810,36 @@ class InstallationComposer {
|
|
|
5781
5810
|
* 公司配置不需要安装 CCR
|
|
5782
5811
|
*/
|
|
5783
5812
|
async installCompanySetup(options = {}) {
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5813
|
+
const spinner = createInstallSpinner(options.silent);
|
|
5814
|
+
spinner.start("\u6B63\u5728\u5B89\u88C5\u516C\u53F8\u914D\u7F6E...");
|
|
5815
|
+
try {
|
|
5816
|
+
await run("npm install -g tsx");
|
|
5817
|
+
const configOptions = {
|
|
5818
|
+
...options,
|
|
5819
|
+
silent: true,
|
|
5820
|
+
// 静默模式,不输出子安装器日志
|
|
5821
|
+
force: true,
|
|
5822
|
+
configData: {
|
|
5823
|
+
...options.configData,
|
|
5824
|
+
apiConfig: {
|
|
5825
|
+
url: "http://11.0.166.20:13456",
|
|
5826
|
+
key: "sk-4730d06849b5fea00f551bd60a0902e1"
|
|
5827
|
+
}
|
|
5799
5828
|
}
|
|
5800
|
-
}
|
|
5801
|
-
};
|
|
5802
|
-
const results = await this.executor.executeBatch(installationSteps, configOptions);
|
|
5803
|
-
const configCheckResult = results[INSTALLER_NAMES.CONFIG_CHECKER];
|
|
5804
|
-
const configType = configCheckResult?.data?.configType;
|
|
5805
|
-
if (configType === "none" || options.force) {
|
|
5806
|
-
const companySteps = [
|
|
5807
|
-
INSTALLER_NAMES.CONFIG,
|
|
5808
|
-
INSTALLER_NAMES.CCOMETIX_LINE,
|
|
5809
|
-
INSTALLER_NAMES.MCP
|
|
5810
|
-
];
|
|
5811
|
-
const companyResults = await this.executor.executeBatch(companySteps, configOptions);
|
|
5812
|
-
const configInstaller = new ConfigInstaller(this.context);
|
|
5813
|
-
await configInstaller.applyCompanyConfig();
|
|
5814
|
-
this.updateGlobalConfig();
|
|
5815
|
-
this.printResults({ ...results, ...companyResults }, "\u516C\u53F8\u914D\u7F6E");
|
|
5816
|
-
} else {
|
|
5817
|
-
console.log(ansis.yellow(`\u26A0 \u68C0\u6D4B\u5230${configType === "company" ? "\u516C\u53F8" : "\u4E2A\u4EBA"}\u914D\u7F6E\uFF0C\u5C06\u5F3A\u5236\u6267\u884C\u5B8C\u6574\u516C\u53F8\u914D\u7F6E`));
|
|
5829
|
+
};
|
|
5818
5830
|
const companySteps = [
|
|
5819
5831
|
INSTALLER_NAMES.CONFIG,
|
|
5820
5832
|
INSTALLER_NAMES.CCOMETIX_LINE,
|
|
5821
5833
|
INSTALLER_NAMES.MCP
|
|
5822
5834
|
];
|
|
5823
|
-
|
|
5835
|
+
await this.executor.executeBatch(companySteps, configOptions);
|
|
5824
5836
|
const configInstaller = new ConfigInstaller(this.context);
|
|
5825
5837
|
await configInstaller.applyCompanyConfig();
|
|
5826
|
-
this.updateGlobalConfig();
|
|
5827
|
-
|
|
5838
|
+
this.updateGlobalConfig(true);
|
|
5839
|
+
spinner.succeed("\u516C\u53F8\u914D\u7F6E\u5B89\u88C5\u5B8C\u6210");
|
|
5840
|
+
} catch (error) {
|
|
5841
|
+
spinner.fail("\u516C\u53F8\u914D\u7F6E\u5B89\u88C5\u5931\u8D25");
|
|
5842
|
+
throw error;
|
|
5828
5843
|
}
|
|
5829
5844
|
}
|
|
5830
5845
|
/**
|
|
@@ -5833,25 +5848,32 @@ class InstallationComposer {
|
|
|
5833
5848
|
* Claude Code 由 startClaudeCodeEditor 函数自动安装
|
|
5834
5849
|
*/
|
|
5835
5850
|
async installPersonalSetup(options = {}) {
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5851
|
+
const spinner = createInstallSpinner(options.silent);
|
|
5852
|
+
spinner.start("\u6B63\u5728\u5B89\u88C5\u4E2A\u4EBA\u914D\u7F6E...");
|
|
5853
|
+
try {
|
|
5854
|
+
await run("npm install -g tsx");
|
|
5855
|
+
const installationSteps = [
|
|
5856
|
+
INSTALLER_NAMES.CCR,
|
|
5857
|
+
INSTALLER_NAMES.CONFIG,
|
|
5858
|
+
INSTALLER_NAMES.CCOMETIX_LINE,
|
|
5859
|
+
INSTALLER_NAMES.MCP
|
|
5860
|
+
];
|
|
5861
|
+
const configOptions = {
|
|
5862
|
+
...options,
|
|
5863
|
+
silent: true,
|
|
5864
|
+
// 静默模式
|
|
5865
|
+
force: true
|
|
5866
|
+
};
|
|
5867
|
+
const results = await this.executor.executeBatch(installationSteps, configOptions);
|
|
5868
|
+
if (results[INSTALLER_NAMES.CCR]?.success) {
|
|
5869
|
+
await this.configureCCRForPersonal(true);
|
|
5870
|
+
}
|
|
5871
|
+
this.updateGlobalConfig(true);
|
|
5872
|
+
spinner.succeed("\u4E2A\u4EBA\u914D\u7F6E\u5B89\u88C5\u5B8C\u6210");
|
|
5873
|
+
} catch (error) {
|
|
5874
|
+
spinner.fail("\u4E2A\u4EBA\u914D\u7F6E\u5B89\u88C5\u5931\u8D25");
|
|
5875
|
+
throw error;
|
|
5852
5876
|
}
|
|
5853
|
-
this.updateGlobalConfig();
|
|
5854
|
-
this.printResults(results, "\u4E2A\u4EBA\u914D\u7F6E");
|
|
5855
5877
|
}
|
|
5856
5878
|
/**
|
|
5857
5879
|
* 自定义安装
|
|
@@ -5866,27 +5888,22 @@ class InstallationComposer {
|
|
|
5866
5888
|
/**
|
|
5867
5889
|
* 配置 CCR 用于个人设置
|
|
5868
5890
|
*/
|
|
5869
|
-
async configureCCRForPersonal() {
|
|
5870
|
-
try {
|
|
5871
|
-
console.log(ansis.blue("\u6B63\u5728\u914D\u7F6E CCR \u4EE3\u7406..."));
|
|
5872
|
-
console.log(ansis.green("\u2714 CCR \u4EE3\u7406\u914D\u7F6E\u5B8C\u6210"));
|
|
5873
|
-
} catch (error) {
|
|
5874
|
-
console.log(ansis.yellow(`\u26A0 CCR \u914D\u7F6E\u5931\u8D25: ${error}`));
|
|
5875
|
-
}
|
|
5891
|
+
async configureCCRForPersonal(silent = false) {
|
|
5876
5892
|
}
|
|
5877
5893
|
/**
|
|
5878
5894
|
* 更新全局配置
|
|
5879
5895
|
*/
|
|
5880
|
-
updateGlobalConfig() {
|
|
5896
|
+
updateGlobalConfig(silent = false) {
|
|
5881
5897
|
try {
|
|
5882
5898
|
updateAicoConfig({
|
|
5883
5899
|
version,
|
|
5884
5900
|
preferredLang: "zh-CN",
|
|
5885
5901
|
aiOutputLang: this.context.lang
|
|
5886
5902
|
});
|
|
5887
|
-
console.log(ansis.green("\n\u2714 \u5168\u5C40\u914D\u7F6E\u5DF2\u66F4\u65B0"));
|
|
5888
5903
|
} catch (error) {
|
|
5889
|
-
|
|
5904
|
+
if (!silent) {
|
|
5905
|
+
console.log(ansis.yellow(`\u26A0 \u5168\u5C40\u914D\u7F6E\u66F4\u65B0\u5931\u8D25: ${error}`));
|
|
5906
|
+
}
|
|
5890
5907
|
}
|
|
5891
5908
|
}
|
|
5892
5909
|
/**
|
|
@@ -6109,4 +6126,4 @@ async function openSettingsJson() {
|
|
|
6109
6126
|
}
|
|
6110
6127
|
}
|
|
6111
6128
|
|
|
6112
|
-
export {
|
|
6129
|
+
export { init$1 as $, AICO_CONFIG_FILE as A, getMcpConfigPath as B, CLAUDE_DIR as C, DEFAULT_FILE_COPY_CONFIGS as D, readMcpConfig as E, writeMcpConfig as F, backupMcpConfig as G, mergeMcpServers as H, buildMcpServerConfig as I, fixWindowsMcpConfig as J, addCompletedOnboarding as K, LEGACY_AICO_CONFIG_FILE as L, MCP_SERVICES as M, createEscapablePrompt as N, processManager as O, displayBannerWithInfo as P, executeWithEscapeSupport as Q, handleExitPromptError as R, SETTINGS_FILE as S, handleGeneralError as T, EscapeKeyPressed as U, version as V, ConfigCheckerInstaller as W, readAicoConfig as X, updateAicoConfig as Y, processManager$1 as Z, runCommand as _, importRecommendedEnv as a, importRecommendedPermissions as b, commandExists as c, cleanupPermissions as d, CLAUDE_MD_FILE as e, ClAUDE_CONFIG_FILE as f, getPlatform as g, SUPPORTED_LANGS as h, init as i, LANG_LABELS as j, AI_OUTPUT_LANGUAGES as k, isClaudeCodeInstalled as l, mergeAndCleanPermissions as m, installClaudeCode as n, openSettingsJson as o, installClaudeCodeSilently as p, ensureClaudeDir as q, backupExistingConfig as r, copyConfigFiles as s, copyConfigFilesWithConfig as t, configureApi as u, mergeConfigs as v, updateDefaultModel as w, mergeSettingsFile as x, getExistingApiConfig as y, applyAiLanguageDirective as z };
|