ccjk 12.0.7 → 12.0.8
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/package.json +1 -1
- package/dist/chunks/agent-teams.mjs +0 -136
- package/dist/chunks/agent.mjs +0 -1439
- package/dist/chunks/agents.mjs +0 -3778
- package/dist/chunks/api-cli.mjs +0 -132
- package/dist/chunks/api-providers.mjs +0 -129
- package/dist/chunks/api.mjs +0 -112
- package/dist/chunks/auto-bootstrap.mjs +0 -358
- package/dist/chunks/auto-init.mjs +0 -7584
- package/dist/chunks/auto-updater.mjs +0 -410
- package/dist/chunks/banner.mjs +0 -188
- package/dist/chunks/bash.mjs +0 -187
- package/dist/chunks/boost.mjs +0 -397
- package/dist/chunks/ccjk-agents.mjs +0 -414
- package/dist/chunks/ccjk-all.mjs +0 -1028
- package/dist/chunks/ccjk-config.mjs +0 -261
- package/dist/chunks/ccjk-hooks.mjs +0 -1074
- package/dist/chunks/ccjk-mcp.mjs +0 -761
- package/dist/chunks/ccjk-setup.mjs +0 -763
- package/dist/chunks/ccjk-skills.mjs +0 -514
- package/dist/chunks/ccr.mjs +0 -98
- package/dist/chunks/ccu.mjs +0 -40
- package/dist/chunks/check-updates.mjs +0 -108
- package/dist/chunks/claude-code-config-manager.mjs +0 -750
- package/dist/chunks/claude-code-incremental-manager.mjs +0 -623
- package/dist/chunks/claude-config.mjs +0 -236
- package/dist/chunks/claude-wrapper.mjs +0 -85
- package/dist/chunks/cleanup-migration.mjs +0 -20
- package/dist/chunks/cli-hook.mjs +0 -2285
- package/dist/chunks/cloud-sync.mjs +0 -29
- package/dist/chunks/codex-config-switch.mjs +0 -451
- package/dist/chunks/codex-provider-manager.mjs +0 -236
- package/dist/chunks/codex-uninstaller.mjs +0 -404
- package/dist/chunks/codex.mjs +0 -2077
- package/dist/chunks/commands.mjs +0 -108
- package/dist/chunks/commands2.mjs +0 -413
- package/dist/chunks/commit.mjs +0 -138
- package/dist/chunks/completion.mjs +0 -515
- package/dist/chunks/config-consolidator.mjs +0 -172
- package/dist/chunks/config-switch.mjs +0 -317
- package/dist/chunks/config.mjs +0 -379
- package/dist/chunks/config2.mjs +0 -477
- package/dist/chunks/config3.mjs +0 -470
- package/dist/chunks/constants.mjs +0 -133
- package/dist/chunks/context-loader.mjs +0 -343
- package/dist/chunks/context.mjs +0 -372
- package/dist/chunks/convoy-manager.mjs +0 -880
- package/dist/chunks/dashboard.mjs +0 -476
- package/dist/chunks/doctor.mjs +0 -964
- package/dist/chunks/evolution.mjs +0 -382
- package/dist/chunks/features.mjs +0 -698
- package/dist/chunks/fish.mjs +0 -181
- package/dist/chunks/fs-operations.mjs +0 -192
- package/dist/chunks/health-alerts.mjs +0 -304
- package/dist/chunks/health-check.mjs +0 -532
- package/dist/chunks/help.mjs +0 -340
- package/dist/chunks/hook-installer.mjs +0 -45
- package/dist/chunks/index.mjs +0 -24
- package/dist/chunks/index10.mjs +0 -1171
- package/dist/chunks/index11.mjs +0 -1008
- package/dist/chunks/index12.mjs +0 -193
- package/dist/chunks/index13.mjs +0 -218
- package/dist/chunks/index14.mjs +0 -663
- package/dist/chunks/index2.mjs +0 -19
- package/dist/chunks/index3.mjs +0 -19092
- package/dist/chunks/index4.mjs +0 -8
- package/dist/chunks/index5.mjs +0 -7600
- package/dist/chunks/index6.mjs +0 -171
- package/dist/chunks/index7.mjs +0 -3583
- package/dist/chunks/index8.mjs +0 -19
- package/dist/chunks/index9.mjs +0 -616
- package/dist/chunks/init.mjs +0 -1606
- package/dist/chunks/installer.mjs +0 -690
- package/dist/chunks/installer2.mjs +0 -179
- package/dist/chunks/interview.mjs +0 -2927
- package/dist/chunks/json-config.mjs +0 -60
- package/dist/chunks/linux.mjs +0 -3863
- package/dist/chunks/macos.mjs +0 -69
- package/dist/chunks/main.mjs +0 -635
- package/dist/chunks/manager.mjs +0 -1048
- package/dist/chunks/marketplace.mjs +0 -949
- package/dist/chunks/mcp-cli.mjs +0 -204
- package/dist/chunks/mcp-performance.mjs +0 -187
- package/dist/chunks/mcp.mjs +0 -1231
- package/dist/chunks/menu.mjs +0 -652
- package/dist/chunks/metrics-display.mjs +0 -153
- package/dist/chunks/migrator.mjs +0 -178
- package/dist/chunks/monitor.mjs +0 -1856
- package/dist/chunks/notification.mjs +0 -1864
- package/dist/chunks/onboarding.mjs +0 -385
- package/dist/chunks/package.mjs +0 -3
- package/dist/chunks/paradigm.mjs +0 -74
- package/dist/chunks/permission-manager.mjs +0 -132
- package/dist/chunks/permissions.mjs +0 -265
- package/dist/chunks/persistence-manager.mjs +0 -794
- package/dist/chunks/persistence.mjs +0 -667
- package/dist/chunks/platform.mjs +0 -391
- package/dist/chunks/plugin.mjs +0 -1936
- package/dist/chunks/powershell.mjs +0 -213
- package/dist/chunks/prompts.mjs +0 -241
- package/dist/chunks/providers.mjs +0 -260
- package/dist/chunks/quick-actions.mjs +0 -320
- package/dist/chunks/quick-provider.mjs +0 -682
- package/dist/chunks/quick-setup.mjs +0 -412
- package/dist/chunks/remote.mjs +0 -497
- package/dist/chunks/session.mjs +0 -878
- package/dist/chunks/sessions.mjs +0 -106
- package/dist/chunks/silent-updater.mjs +0 -396
- package/dist/chunks/simple-config.mjs +0 -98
- package/dist/chunks/skill.mjs +0 -117
- package/dist/chunks/skill2.mjs +0 -9003
- package/dist/chunks/skills-sync.mjs +0 -6460
- package/dist/chunks/skills.mjs +0 -567
- package/dist/chunks/slash-commands.mjs +0 -207
- package/dist/chunks/smart-defaults.mjs +0 -412
- package/dist/chunks/smart-guide.mjs +0 -194
- package/dist/chunks/startup.mjs +0 -487
- package/dist/chunks/stats.mjs +0 -410
- package/dist/chunks/status.mjs +0 -289
- package/dist/chunks/team.mjs +0 -63
- package/dist/chunks/thinking.mjs +0 -626
- package/dist/chunks/trace.mjs +0 -57
- package/dist/chunks/uninstall.mjs +0 -849
- package/dist/chunks/update.mjs +0 -167
- package/dist/chunks/upgrade-manager.mjs +0 -204
- package/dist/chunks/version-checker.mjs +0 -881
- package/dist/chunks/vim.mjs +0 -903
- package/dist/chunks/windows.mjs +0 -14
- package/dist/chunks/workflows.mjs +0 -633
- package/dist/chunks/wsl.mjs +0 -129
- package/dist/chunks/zero-config.mjs +0 -374
- package/dist/chunks/zsh.mjs +0 -182
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -2199
- package/dist/i18n/locales/en/agent-teams.json +0 -18
- package/dist/i18n/locales/en/agentBrowser.json +0 -79
- package/dist/i18n/locales/en/agents.json +0 -135
- package/dist/i18n/locales/en/api.json +0 -63
- package/dist/i18n/locales/en/ccjk-agents.json +0 -33
- package/dist/i18n/locales/en/ccjk-all.json +0 -23
- package/dist/i18n/locales/en/ccjk-skills.json +0 -22
- package/dist/i18n/locales/en/ccjk.json +0 -276
- package/dist/i18n/locales/en/ccr.json +0 -65
- package/dist/i18n/locales/en/claude-md.json +0 -73
- package/dist/i18n/locales/en/cli.json +0 -152
- package/dist/i18n/locales/en/cloud-setup.json +0 -31
- package/dist/i18n/locales/en/cloud-sync.json +0 -147
- package/dist/i18n/locales/en/cloud.json +0 -40
- package/dist/i18n/locales/en/cloudPlugins.json +0 -118
- package/dist/i18n/locales/en/codex.json +0 -127
- package/dist/i18n/locales/en/cometix.json +0 -29
- package/dist/i18n/locales/en/common.json +0 -68
- package/dist/i18n/locales/en/config.json +0 -108
- package/dist/i18n/locales/en/configuration.json +0 -226
- package/dist/i18n/locales/en/context.json +0 -85
- package/dist/i18n/locales/en/dashboard.json +0 -78
- package/dist/i18n/locales/en/errors.json +0 -26
- package/dist/i18n/locales/en/evolution.json +0 -54
- package/dist/i18n/locales/en/hooks.json +0 -74
- package/dist/i18n/locales/en/hooksSync.json +0 -133
- package/dist/i18n/locales/en/installation.json +0 -83
- package/dist/i18n/locales/en/interview.json +0 -104
- package/dist/i18n/locales/en/language.json +0 -19
- package/dist/i18n/locales/en/lsp.json +0 -78
- package/dist/i18n/locales/en/marketplace.json +0 -116
- package/dist/i18n/locales/en/mcp.json +0 -178
- package/dist/i18n/locales/en/memory.json +0 -92
- package/dist/i18n/locales/en/menu.json +0 -143
- package/dist/i18n/locales/en/multi-config.json +0 -79
- package/dist/i18n/locales/en/notification.json +0 -307
- package/dist/i18n/locales/en/permissions.json +0 -95
- package/dist/i18n/locales/en/persistence.json +0 -127
- package/dist/i18n/locales/en/plugins.json +0 -146
- package/dist/i18n/locales/en/quick-actions.json +0 -78
- package/dist/i18n/locales/en/registry.json +0 -54
- package/dist/i18n/locales/en/remote.json +0 -93
- package/dist/i18n/locales/en/sandbox.json +0 -44
- package/dist/i18n/locales/en/setup.json +0 -44
- package/dist/i18n/locales/en/shencha.json +0 -14
- package/dist/i18n/locales/en/skills.json +0 -100
- package/dist/i18n/locales/en/skillsSync.json +0 -74
- package/dist/i18n/locales/en/smartGuide.json +0 -49
- package/dist/i18n/locales/en/stats.json +0 -20
- package/dist/i18n/locales/en/subagent.json +0 -69
- package/dist/i18n/locales/en/superpowers.json +0 -117
- package/dist/i18n/locales/en/team.json +0 -7
- package/dist/i18n/locales/en/thinking.json +0 -65
- package/dist/i18n/locales/en/tools.json +0 -42
- package/dist/i18n/locales/en/uninstall.json +0 -56
- package/dist/i18n/locales/en/updater.json +0 -29
- package/dist/i18n/locales/en/vim.json +0 -169
- package/dist/i18n/locales/en/workflow.json +0 -55
- package/dist/i18n/locales/en/workspace.json +0 -108
- package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
- package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -79
- package/dist/i18n/locales/zh-CN/agents.json +0 -135
- package/dist/i18n/locales/zh-CN/api.json +0 -63
- package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
- package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
- package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
- package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
- package/dist/i18n/locales/zh-CN/ccr.json +0 -65
- package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
- package/dist/i18n/locales/zh-CN/cli.json +0 -152
- package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
- package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
- package/dist/i18n/locales/zh-CN/cloud.json +0 -40
- package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
- package/dist/i18n/locales/zh-CN/codex.json +0 -127
- package/dist/i18n/locales/zh-CN/cometix.json +0 -29
- package/dist/i18n/locales/zh-CN/common.json +0 -68
- package/dist/i18n/locales/zh-CN/config.json +0 -108
- package/dist/i18n/locales/zh-CN/configuration.json +0 -224
- package/dist/i18n/locales/zh-CN/context.json +0 -85
- package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
- package/dist/i18n/locales/zh-CN/errors.json +0 -26
- package/dist/i18n/locales/zh-CN/evolution.json +0 -54
- package/dist/i18n/locales/zh-CN/hooks.json +0 -74
- package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
- package/dist/i18n/locales/zh-CN/installation.json +0 -83
- package/dist/i18n/locales/zh-CN/interview.json +0 -104
- package/dist/i18n/locales/zh-CN/language.json +0 -19
- package/dist/i18n/locales/zh-CN/lsp.json +0 -78
- package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
- package/dist/i18n/locales/zh-CN/mcp.json +0 -178
- package/dist/i18n/locales/zh-CN/memory.json +0 -92
- package/dist/i18n/locales/zh-CN/menu.json +0 -143
- package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
- package/dist/i18n/locales/zh-CN/notification.json +0 -307
- package/dist/i18n/locales/zh-CN/permissions.json +0 -95
- package/dist/i18n/locales/zh-CN/persistence.json +0 -127
- package/dist/i18n/locales/zh-CN/plugins.json +0 -146
- package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
- package/dist/i18n/locales/zh-CN/registry.json +0 -54
- package/dist/i18n/locales/zh-CN/remote.json +0 -93
- package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
- package/dist/i18n/locales/zh-CN/setup.json +0 -44
- package/dist/i18n/locales/zh-CN/shencha.json +0 -14
- package/dist/i18n/locales/zh-CN/skills.json +0 -100
- package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
- package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
- package/dist/i18n/locales/zh-CN/stats.json +0 -20
- package/dist/i18n/locales/zh-CN/subagent.json +0 -69
- package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
- package/dist/i18n/locales/zh-CN/team.json +0 -7
- package/dist/i18n/locales/zh-CN/thinking.json +0 -65
- package/dist/i18n/locales/zh-CN/tools.json +0 -42
- package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
- package/dist/i18n/locales/zh-CN/updater.json +0 -29
- package/dist/i18n/locales/zh-CN/vim.json +0 -169
- package/dist/i18n/locales/zh-CN/workflow.json +0 -55
- package/dist/i18n/locales/zh-CN/workspace.json +0 -108
- package/dist/index.d.mts +0 -5295
- package/dist/index.d.ts +0 -5295
- package/dist/index.mjs +0 -4941
- package/dist/shared/ccjk.B364Fu0N.mjs +0 -1819
- package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
- package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
- package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
- package/dist/shared/ccjk.BFxsJM0k.mjs +0 -599
- package/dist/shared/ccjk.BIxuVL3_.mjs +0 -25
- package/dist/shared/ccjk.BRZ9ww8S.mjs +0 -142
- package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
- package/dist/shared/ccjk.BrPUmTqm.mjs +0 -266
- package/dist/shared/ccjk.BtB1e5jm.mjs +0 -171
- package/dist/shared/ccjk.BwfbSKN2.mjs +0 -1051
- package/dist/shared/ccjk.BxSmJ8B7.mjs +0 -243
- package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
- package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
- package/dist/shared/ccjk.CL4Yat0G.mjs +0 -303
- package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
- package/dist/shared/ccjk.CePkJq2S.mjs +0 -223
- package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
- package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
- package/dist/shared/ccjk.Cjj8SVrn.mjs +0 -54
- package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
- package/dist/shared/ccjk.D5MFQT7w.mjs +0 -400
- package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
- package/dist/shared/ccjk.D8ZLYSZZ.mjs +0 -299
- package/dist/shared/ccjk.DG_o24cZ.mjs +0 -88
- package/dist/shared/ccjk.DLLw-h4Y.mjs +0 -460
- package/dist/shared/ccjk.DOwtZMk8.mjs +0 -4019
- package/dist/shared/ccjk.DS7UESmF.mjs +0 -2451
- package/dist/shared/ccjk.DTdjs-qK.mjs +0 -1447
- package/dist/shared/ccjk.DXRAZcix.mjs +0 -66
- package/dist/shared/ccjk.DsYaCCx4.mjs +0 -317
- package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
- package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
- package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
- package/dist/shared/ccjk.SPoXMvZD.mjs +0 -1242
- package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
- package/dist/shared/ccjk.UIvifqNE.mjs +0 -1486
- package/dist/shared/ccjk._dESH4Rk.mjs +0 -111
- package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
- package/dist/shared/ccjk.c-ETfBZ_.mjs +0 -617
- package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
- package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
- package/dist/shared/ccjk.waa2ikKJ.mjs +0 -351
package/dist/chunks/mcp.mjs
DELETED
|
@@ -1,1231 +0,0 @@
|
|
|
1
|
-
import a from './index2.mjs';
|
|
2
|
-
import { i18n } from './index5.mjs';
|
|
3
|
-
import 'node:child_process';
|
|
4
|
-
import 'node:process';
|
|
5
|
-
import { M as MCP_SERVICE_TIERS, i as isCoreService, g as getServicesByTier, c as checkMcpPerformance, f as formatPerformanceWarning, a as calculateResourceUsage, b as getOptimizationSuggestions, d as getMcpTierConfig } from './mcp-performance.mjs';
|
|
6
|
-
import { r as readMcpConfig, b as backupMcpConfig, w as writeMcpConfig } from './claude-config.mjs';
|
|
7
|
-
import { i as inquirer } from './index3.mjs';
|
|
8
|
-
import { M as MCP_SERVICE_CONFIGS } from './codex.mjs';
|
|
9
|
-
import { d as displayInstalledMcpServices, b as isMcpServiceInstalled, i as installMcpService, u as uninstallMcpService } from '../shared/ccjk.waa2ikKJ.mjs';
|
|
10
|
-
import { existsSync, unlinkSync, statSync, mkdirSync, readFileSync } from 'node:fs';
|
|
11
|
-
import { homedir } from 'node:os';
|
|
12
|
-
import { writeFileAtomic } from './fs-operations.mjs';
|
|
13
|
-
import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
14
|
-
import '../shared/ccjk.BAGoDD49.mjs';
|
|
15
|
-
import 'node:url';
|
|
16
|
-
import './constants.mjs';
|
|
17
|
-
import './json-config.mjs';
|
|
18
|
-
import '../shared/ccjk.RyizuzOI.mjs';
|
|
19
|
-
import 'node:crypto';
|
|
20
|
-
import 'node:fs/promises';
|
|
21
|
-
import './platform.mjs';
|
|
22
|
-
import './main.mjs';
|
|
23
|
-
import 'module';
|
|
24
|
-
import 'node:path';
|
|
25
|
-
import 'node:stream';
|
|
26
|
-
import 'node:readline';
|
|
27
|
-
import 'stream';
|
|
28
|
-
import 'node:tty';
|
|
29
|
-
import 'node:async_hooks';
|
|
30
|
-
import '../shared/ccjk.Cjgrln_h.mjs';
|
|
31
|
-
import 'node:util';
|
|
32
|
-
import 'tty';
|
|
33
|
-
import 'fs';
|
|
34
|
-
import 'child_process';
|
|
35
|
-
import 'buffer';
|
|
36
|
-
import 'string_decoder';
|
|
37
|
-
import './index7.mjs';
|
|
38
|
-
import '../shared/ccjk.CxpGa6MC.mjs';
|
|
39
|
-
import '../shared/ccjk.BBtCGd_g.mjs';
|
|
40
|
-
import './ccjk-config.mjs';
|
|
41
|
-
import './index6.mjs';
|
|
42
|
-
import './config.mjs';
|
|
43
|
-
import '../shared/ccjk.DXRAZcix.mjs';
|
|
44
|
-
import '../shared/ccjk.BFQ7yr5S.mjs';
|
|
45
|
-
import './prompts.mjs';
|
|
46
|
-
import '../shared/ccjk.gDEDGD_t.mjs';
|
|
47
|
-
import '../shared/ccjk.DOwtZMk8.mjs';
|
|
48
|
-
|
|
49
|
-
function getReleasableServices(configuredServices, tier) {
|
|
50
|
-
return configuredServices.filter((serviceId) => {
|
|
51
|
-
if (isCoreService(serviceId)) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
const serviceTier = MCP_SERVICE_TIERS[serviceId] || "ondemand";
|
|
55
|
-
if (tier === "all") {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
if (tier) {
|
|
59
|
-
return serviceTier === tier;
|
|
60
|
-
}
|
|
61
|
-
return serviceTier === "ondemand" || serviceTier === "scenario";
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async function releaseServices(servicesToRelease, options = {}) {
|
|
65
|
-
const result = {
|
|
66
|
-
success: true,
|
|
67
|
-
releasedServices: [],
|
|
68
|
-
skippedServices: [],
|
|
69
|
-
errors: []
|
|
70
|
-
};
|
|
71
|
-
if (servicesToRelease.length === 0) {
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
const config = readMcpConfig();
|
|
75
|
-
if (!config?.mcpServers) {
|
|
76
|
-
result.errors.push("No MCP configuration found");
|
|
77
|
-
result.success = false;
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
if (!options.dryRun) {
|
|
81
|
-
backupMcpConfig();
|
|
82
|
-
}
|
|
83
|
-
const newServers = { ...config.mcpServers };
|
|
84
|
-
for (const serviceId of servicesToRelease) {
|
|
85
|
-
if (isCoreService(serviceId) && !options.force) {
|
|
86
|
-
result.skippedServices.push(serviceId);
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
if (!newServers[serviceId]) {
|
|
90
|
-
result.skippedServices.push(serviceId);
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
if (!options.dryRun) {
|
|
94
|
-
delete newServers[serviceId];
|
|
95
|
-
}
|
|
96
|
-
result.releasedServices.push(serviceId);
|
|
97
|
-
}
|
|
98
|
-
if (!options.dryRun && result.releasedServices.length > 0) {
|
|
99
|
-
try {
|
|
100
|
-
writeMcpConfig({ ...config, mcpServers: newServers });
|
|
101
|
-
} catch (error) {
|
|
102
|
-
result.errors.push(`Failed to write config: ${error}`);
|
|
103
|
-
result.success = false;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
async function mcpRelease(options = {}) {
|
|
109
|
-
const lang = options.lang || i18n.language || "en";
|
|
110
|
-
const isZh = lang === "zh-CN";
|
|
111
|
-
console.log("");
|
|
112
|
-
console.log(a.bold.cyan(isZh ? "\u{1F9F9} MCP \u670D\u52A1\u91CA\u653E" : "\u{1F9F9} MCP Service Release"));
|
|
113
|
-
console.log(a.dim("\u2500".repeat(50)));
|
|
114
|
-
console.log("");
|
|
115
|
-
const config = readMcpConfig();
|
|
116
|
-
const configuredServices = config?.mcpServers ? Object.keys(config.mcpServers) : [];
|
|
117
|
-
if (configuredServices.length === 0) {
|
|
118
|
-
console.log(a.yellow(isZh ? "\u6CA1\u6709\u914D\u7F6E\u4EFB\u4F55 MCP \u670D\u52A1" : "No MCP services configured"));
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
let servicesToRelease;
|
|
122
|
-
if (options.service) {
|
|
123
|
-
servicesToRelease = [options.service];
|
|
124
|
-
} else if (options.tier) {
|
|
125
|
-
servicesToRelease = getReleasableServices(configuredServices, options.tier);
|
|
126
|
-
} else {
|
|
127
|
-
servicesToRelease = getReleasableServices(configuredServices, "all");
|
|
128
|
-
}
|
|
129
|
-
if (servicesToRelease.length === 0) {
|
|
130
|
-
console.log(a.green(isZh ? "\u2714 \u6CA1\u6709\u53EF\u91CA\u653E\u7684\u670D\u52A1" : "\u2714 No services to release"));
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
console.log(isZh ? "\u5C06\u91CA\u653E\u4EE5\u4E0B\u670D\u52A1:" : "Services to release:");
|
|
134
|
-
for (const serviceId of servicesToRelease) {
|
|
135
|
-
const tier = MCP_SERVICE_TIERS[serviceId] || "ondemand";
|
|
136
|
-
console.log(` ${a.yellow("\u2022")} ${serviceId} ${a.dim(`[${tier}]`)}`);
|
|
137
|
-
}
|
|
138
|
-
console.log("");
|
|
139
|
-
if (options.dryRun) {
|
|
140
|
-
console.log(a.green(isZh ? "(\u6A21\u62DF\u8FD0\u884C - \u4E0D\u4F1A\u5B9E\u9645\u4FEE\u6539\u914D\u7F6E)" : "(Dry run - no changes will be made)"));
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
const result = await releaseServices(servicesToRelease, options);
|
|
144
|
-
if (result.success) {
|
|
145
|
-
console.log(a.green(`\u2714 ${isZh ? "\u5DF2\u91CA\u653E" : "Released"} ${result.releasedServices.length} ${isZh ? "\u4E2A\u670D\u52A1" : "services"}`));
|
|
146
|
-
if (result.skippedServices.length > 0) {
|
|
147
|
-
console.log(a.yellow(`${isZh ? "\u8DF3\u8FC7" : "Skipped"}: ${result.skippedServices.join(", ")}`));
|
|
148
|
-
}
|
|
149
|
-
const remaining = configuredServices.filter((s) => !result.releasedServices.includes(s));
|
|
150
|
-
console.log("");
|
|
151
|
-
console.log(a.dim(`${isZh ? "\u5269\u4F59\u670D\u52A1" : "Remaining services"}: ${remaining.length}`));
|
|
152
|
-
if (remaining.length > 0) {
|
|
153
|
-
console.log(a.dim(` ${remaining.join(", ")}`));
|
|
154
|
-
}
|
|
155
|
-
console.log("");
|
|
156
|
-
console.log(a.yellow(isZh ? "\u26A0\uFE0F \u8BF7\u91CD\u542F Claude Code \u4EE5\u4F7F\u66F4\u6539\u751F\u6548" : "\u26A0\uFE0F Please restart Claude Code for changes to take effect"));
|
|
157
|
-
} else {
|
|
158
|
-
console.log(a.red(`\u2716 ${isZh ? "\u91CA\u653E\u5931\u8D25" : "Release failed"}`));
|
|
159
|
-
for (const error of result.errors) {
|
|
160
|
-
console.log(a.red(` ${error}`));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function checkServiceHealth(serviceId, configuredServices) {
|
|
166
|
-
const tierConfig = getMcpTierConfig(serviceId);
|
|
167
|
-
const tier = MCP_SERVICE_TIERS[serviceId] || "ondemand";
|
|
168
|
-
const isConfigured = configuredServices.includes(serviceId);
|
|
169
|
-
const issues = [];
|
|
170
|
-
const suggestions = [];
|
|
171
|
-
let status = "healthy";
|
|
172
|
-
if (isConfigured && !MCP_SERVICE_TIERS[serviceId]) {
|
|
173
|
-
issues.push("Service not in tier system (using default: ondemand)");
|
|
174
|
-
status = "warning";
|
|
175
|
-
}
|
|
176
|
-
if (serviceId === "Playwright" && configuredServices.includes("puppeteer")) {
|
|
177
|
-
issues.push("Both Playwright and Puppeteer are enabled");
|
|
178
|
-
suggestions.push("Consider using only one browser automation service");
|
|
179
|
-
status = "warning";
|
|
180
|
-
}
|
|
181
|
-
if (serviceId === "puppeteer" && configuredServices.includes("Playwright")) {
|
|
182
|
-
issues.push("Both Puppeteer and Playwright are enabled");
|
|
183
|
-
suggestions.push("Consider using only one browser automation service");
|
|
184
|
-
status = "warning";
|
|
185
|
-
}
|
|
186
|
-
if (tier === "scenario" && isConfigured) {
|
|
187
|
-
suggestions.push("Scenario service - consider disabling when not needed");
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
serviceId,
|
|
191
|
-
status,
|
|
192
|
-
tier,
|
|
193
|
-
autoStart: tierConfig.autoStart,
|
|
194
|
-
idleTimeout: tierConfig.idleTimeout,
|
|
195
|
-
issues,
|
|
196
|
-
suggestions
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
async function mcpDoctor(options = {}) {
|
|
200
|
-
const lang = options.lang || i18n.language || "en";
|
|
201
|
-
const isZh = lang === "zh-CN";
|
|
202
|
-
console.log("");
|
|
203
|
-
console.log(a.bold.cyan(isZh ? "\u{1F50D} MCP \u5065\u5EB7\u68C0\u67E5" : "\u{1F50D} MCP Health Check"));
|
|
204
|
-
console.log(a.dim("\u2550".repeat(60)));
|
|
205
|
-
console.log("");
|
|
206
|
-
const config = readMcpConfig();
|
|
207
|
-
const configuredServices = config?.mcpServers ? Object.keys(config.mcpServers) : [];
|
|
208
|
-
console.log(a.bold(isZh ? "\u{1F4CA} \u670D\u52A1\u7EDF\u8BA1" : "\u{1F4CA} Service Statistics"));
|
|
209
|
-
console.log(a.dim("\u2500".repeat(40)));
|
|
210
|
-
const coreServices = getServicesByTier("core");
|
|
211
|
-
const ondemandServices = getServicesByTier("ondemand");
|
|
212
|
-
const scenarioServices = getServicesByTier("scenario");
|
|
213
|
-
const configuredCore = configuredServices.filter((s) => coreServices.includes(s));
|
|
214
|
-
const configuredOndemand = configuredServices.filter((s) => ondemandServices.includes(s));
|
|
215
|
-
const configuredScenario = configuredServices.filter((s) => scenarioServices.includes(s));
|
|
216
|
-
console.log(` ${isZh ? "\u603B\u8BA1" : "Total"}: ${a.bold(configuredServices.length.toString())} ${isZh ? "\u4E2A\u670D\u52A1" : "services"}`);
|
|
217
|
-
console.log(` ${a.green("Core")}: ${configuredCore.length}/${coreServices.length}`);
|
|
218
|
-
console.log(` ${a.yellow("OnDemand")}: ${configuredOndemand.length}/${ondemandServices.length}`);
|
|
219
|
-
console.log(` ${a.green("Scenario")}: ${configuredScenario.length}/${scenarioServices.length}`);
|
|
220
|
-
console.log("");
|
|
221
|
-
const perfWarning = checkMcpPerformance(configuredServices.length);
|
|
222
|
-
if (perfWarning) {
|
|
223
|
-
console.log(a.bold(isZh ? "\u26A0\uFE0F \u6027\u80FD\u8B66\u544A" : "\u26A0\uFE0F Performance Warning"));
|
|
224
|
-
console.log(a.dim("\u2500".repeat(40)));
|
|
225
|
-
console.log(formatPerformanceWarning(perfWarning, lang));
|
|
226
|
-
console.log("");
|
|
227
|
-
}
|
|
228
|
-
const resourceUsage = calculateResourceUsage(configuredServices.length);
|
|
229
|
-
console.log(a.bold(isZh ? "\u{1F4BB} \u8D44\u6E90\u4F7F\u7528\u4F30\u7B97" : "\u{1F4BB} Resource Usage Estimate"));
|
|
230
|
-
console.log(a.dim("\u2500".repeat(40)));
|
|
231
|
-
const ratingColors = {
|
|
232
|
-
low: a.green,
|
|
233
|
-
medium: a.yellow,
|
|
234
|
-
high: a.red,
|
|
235
|
-
critical: a.bgRed.white
|
|
236
|
-
};
|
|
237
|
-
const ratingLabels = {
|
|
238
|
-
low: isZh ? "\u4F4E" : "Low",
|
|
239
|
-
medium: isZh ? "\u4E2D" : "Medium",
|
|
240
|
-
high: isZh ? "\u9AD8" : "High",
|
|
241
|
-
critical: isZh ? "\u4E25\u91CD" : "Critical"
|
|
242
|
-
};
|
|
243
|
-
console.log(` ${isZh ? "\u5185\u5B58" : "Memory"}: ~${resourceUsage.memory.value}${resourceUsage.memory.unit}`);
|
|
244
|
-
console.log(` ${isZh ? "CPU" : "CPU"}: ~${resourceUsage.cpu.value}${resourceUsage.cpu.unit}`);
|
|
245
|
-
console.log(` ${isZh ? "\u8BC4\u7EA7" : "Rating"}: ${ratingColors[resourceUsage.rating](ratingLabels[resourceUsage.rating])}`);
|
|
246
|
-
console.log("");
|
|
247
|
-
if (options.verbose || options.service) {
|
|
248
|
-
console.log(a.bold(isZh ? "\u{1F527} \u670D\u52A1\u8BE6\u60C5" : "\u{1F527} Service Details"));
|
|
249
|
-
console.log(a.dim("\u2500".repeat(40)));
|
|
250
|
-
const servicesToCheck = options.service ? [options.service] : configuredServices;
|
|
251
|
-
for (const serviceId of servicesToCheck) {
|
|
252
|
-
const health = checkServiceHealth(serviceId, configuredServices);
|
|
253
|
-
const statusIcon = {
|
|
254
|
-
healthy: a.green("\u2714"),
|
|
255
|
-
warning: a.yellow("\u26A0"),
|
|
256
|
-
error: a.red("\u2716"),
|
|
257
|
-
unknown: a.gray("?")
|
|
258
|
-
};
|
|
259
|
-
const tierColor = {
|
|
260
|
-
core: a.green,
|
|
261
|
-
ondemand: a.yellow,
|
|
262
|
-
scenario: a.green
|
|
263
|
-
};
|
|
264
|
-
console.log(` ${statusIcon[health.status]} ${a.bold(serviceId)}`);
|
|
265
|
-
console.log(` ${isZh ? "\u5C42\u7EA7" : "Tier"}: ${(tierColor[health.tier] || a.gray)(health.tier)}`);
|
|
266
|
-
if (health.idleTimeout) {
|
|
267
|
-
console.log(` ${isZh ? "\u7A7A\u95F2\u8D85\u65F6" : "Idle Timeout"}: ${health.idleTimeout}s`);
|
|
268
|
-
}
|
|
269
|
-
if (health.issues.length > 0) {
|
|
270
|
-
for (const issue of health.issues) {
|
|
271
|
-
console.log(` ${a.yellow("!")} ${issue}`);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
if (health.suggestions.length > 0) {
|
|
275
|
-
for (const suggestion of health.suggestions) {
|
|
276
|
-
console.log(` ${a.dim("\u2192")} ${suggestion}`);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
console.log("");
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
const suggestions = getOptimizationSuggestions(configuredServices);
|
|
283
|
-
if (suggestions.length > 0) {
|
|
284
|
-
console.log(a.bold(isZh ? "\u{1F4A1} \u4F18\u5316\u5EFA\u8BAE" : "\u{1F4A1} Optimization Suggestions"));
|
|
285
|
-
console.log(a.dim("\u2500".repeat(40)));
|
|
286
|
-
for (const suggestion of suggestions) {
|
|
287
|
-
console.log(` \u2022 ${suggestion}`);
|
|
288
|
-
}
|
|
289
|
-
console.log("");
|
|
290
|
-
}
|
|
291
|
-
console.log(a.bold(isZh ? "\u{1F680} \u5FEB\u901F\u64CD\u4F5C" : "\u{1F680} Quick Actions"));
|
|
292
|
-
console.log(a.dim("\u2500".repeat(40)));
|
|
293
|
-
console.log(` ${a.green("ccjk mcp profile use minimal")} - ${isZh ? "\u5207\u6362\u5230\u6781\u7B80\u6A21\u5F0F" : "Switch to minimal mode"}`);
|
|
294
|
-
console.log(` ${a.green("ccjk mcp profile list")} - ${isZh ? "\u67E5\u770B\u6240\u6709\u9884\u8BBE" : "View all profiles"}`);
|
|
295
|
-
console.log(` ${a.green("ccjk mcp release")} - ${isZh ? "\u91CA\u653E\u7A7A\u95F2\u670D\u52A1" : "Release idle services"}`);
|
|
296
|
-
console.log("");
|
|
297
|
-
console.log(a.dim("\u2550".repeat(60)));
|
|
298
|
-
const summaryStatus = perfWarning?.level === "critical" ? a.red(isZh ? "\u9700\u8981\u4F18\u5316" : "Needs Optimization") : perfWarning?.level === "warning" ? a.yellow(isZh ? "\u5EFA\u8BAE\u4F18\u5316" : "Optimization Recommended") : a.green(isZh ? "\u72B6\u6001\u826F\u597D" : "Healthy");
|
|
299
|
-
console.log(`${isZh ? "\u603B\u4F53\u72B6\u6001" : "Overall Status"}: ${summaryStatus}`);
|
|
300
|
-
console.log("");
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const DEFAULT_API_URL = "https://api.api.claudehome.cn/v1/mcp-marketplace";
|
|
304
|
-
const REQUEST_TIMEOUT = 3e4;
|
|
305
|
-
const MAX_RETRY_ATTEMPTS = 3;
|
|
306
|
-
const RETRY_DELAY = 1e3;
|
|
307
|
-
const DEFAULT_CACHE_TTL = 36e5;
|
|
308
|
-
const DEFAULT_THROTTLE_INTERVAL = 100;
|
|
309
|
-
const CACHE_VERSION = "1.0.0";
|
|
310
|
-
const CACHE_BASE_DIR = join(homedir(), ".ccjk", "mcp-marketplace", "cache");
|
|
311
|
-
class MarketplaceClient {
|
|
312
|
-
baseUrl;
|
|
313
|
-
apiKey;
|
|
314
|
-
timeout;
|
|
315
|
-
offlineMode;
|
|
316
|
-
enableLogging;
|
|
317
|
-
maxRetries;
|
|
318
|
-
retryDelay;
|
|
319
|
-
cacheTTL;
|
|
320
|
-
enableDeduplication;
|
|
321
|
-
throttleInterval;
|
|
322
|
-
// In-memory cache
|
|
323
|
-
memoryCache;
|
|
324
|
-
// Pending requests for deduplication
|
|
325
|
-
pendingRequests;
|
|
326
|
-
// Last request timestamp for throttling
|
|
327
|
-
lastRequestTime;
|
|
328
|
-
// File-based cache
|
|
329
|
-
cacheDir;
|
|
330
|
-
cacheFile;
|
|
331
|
-
constructor(options = {}) {
|
|
332
|
-
this.baseUrl = options.baseUrl || DEFAULT_API_URL;
|
|
333
|
-
this.apiKey = options.apiKey;
|
|
334
|
-
this.timeout = options.timeout || REQUEST_TIMEOUT;
|
|
335
|
-
this.offlineMode = options.offlineMode || false;
|
|
336
|
-
this.enableLogging = options.enableLogging || false;
|
|
337
|
-
this.maxRetries = options.maxRetries || MAX_RETRY_ATTEMPTS;
|
|
338
|
-
this.retryDelay = options.retryDelay || RETRY_DELAY;
|
|
339
|
-
this.cacheTTL = options.cacheTTL || DEFAULT_CACHE_TTL;
|
|
340
|
-
this.enableDeduplication = options.enableDeduplication !== false;
|
|
341
|
-
this.throttleInterval = options.throttleInterval || DEFAULT_THROTTLE_INTERVAL;
|
|
342
|
-
this.memoryCache = /* @__PURE__ */ new Map();
|
|
343
|
-
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
344
|
-
this.lastRequestTime = 0;
|
|
345
|
-
this.cacheDir = CACHE_BASE_DIR;
|
|
346
|
-
this.cacheFile = join(this.cacheDir, "marketplace.json");
|
|
347
|
-
}
|
|
348
|
-
// ==========================================================================
|
|
349
|
-
// Public API Methods
|
|
350
|
-
// ==========================================================================
|
|
351
|
-
/**
|
|
352
|
-
* Search packages with filters and sorting
|
|
353
|
-
*/
|
|
354
|
-
async search(options = {}) {
|
|
355
|
-
this.log("Searching packages with options:", options);
|
|
356
|
-
const params = this.buildSearchParams(options);
|
|
357
|
-
const response = await this.request("/search", {
|
|
358
|
-
method: "GET",
|
|
359
|
-
params
|
|
360
|
-
});
|
|
361
|
-
if (response.success && response.data) {
|
|
362
|
-
return response.data;
|
|
363
|
-
}
|
|
364
|
-
return {
|
|
365
|
-
packages: [],
|
|
366
|
-
total: 0,
|
|
367
|
-
page: options.page || 1,
|
|
368
|
-
limit: options.limit || 20,
|
|
369
|
-
totalPages: 0,
|
|
370
|
-
hasMore: false
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Get detailed information about a specific package
|
|
375
|
-
*/
|
|
376
|
-
async getPackage(id) {
|
|
377
|
-
this.log("Getting package:", id);
|
|
378
|
-
const encodedId = encodeURIComponent(id);
|
|
379
|
-
const response = await this.request(`/packages/${encodedId}`, {
|
|
380
|
-
method: "GET"
|
|
381
|
-
});
|
|
382
|
-
return response.success && response.data ? response.data : null;
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Get version history for a package
|
|
386
|
-
*/
|
|
387
|
-
async getVersions(id) {
|
|
388
|
-
this.log("Getting versions for package:", id);
|
|
389
|
-
const encodedId = encodeURIComponent(id);
|
|
390
|
-
const response = await this.request(`/packages/${encodedId}/versions`, {
|
|
391
|
-
method: "GET"
|
|
392
|
-
});
|
|
393
|
-
return response.success && response.data ? response.data : [];
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Get trending/popular packages
|
|
397
|
-
*/
|
|
398
|
-
async getTrending(limit = 10) {
|
|
399
|
-
this.log("Getting trending packages, limit:", limit);
|
|
400
|
-
const response = await this.request("/trending", {
|
|
401
|
-
method: "GET",
|
|
402
|
-
params: { limit }
|
|
403
|
-
});
|
|
404
|
-
return response.success && response.data ? response.data : [];
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Get personalized recommendations based on installed packages
|
|
408
|
-
*/
|
|
409
|
-
async getRecommendations(installed) {
|
|
410
|
-
this.log("Getting recommendations for installed packages:", installed);
|
|
411
|
-
const response = await this.request("/recommendations", {
|
|
412
|
-
method: "POST",
|
|
413
|
-
body: JSON.stringify({ installed })
|
|
414
|
-
});
|
|
415
|
-
return response.success && response.data ? response.data : [];
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Get all available categories
|
|
419
|
-
*/
|
|
420
|
-
async getCategories() {
|
|
421
|
-
this.log("Getting categories");
|
|
422
|
-
const response = await this.request("/categories", {
|
|
423
|
-
method: "GET"
|
|
424
|
-
});
|
|
425
|
-
return response.success && response.data ? response.data : [];
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Check for updates for installed packages
|
|
429
|
-
*/
|
|
430
|
-
async checkUpdates(installed) {
|
|
431
|
-
this.log("Checking updates for", installed.length, "packages");
|
|
432
|
-
const response = await this.request("/updates/check", {
|
|
433
|
-
method: "POST",
|
|
434
|
-
body: JSON.stringify({ packages: installed })
|
|
435
|
-
});
|
|
436
|
-
return response.success && response.data ? response.data : [];
|
|
437
|
-
}
|
|
438
|
-
// ==========================================================================
|
|
439
|
-
// Cache Management
|
|
440
|
-
// ==========================================================================
|
|
441
|
-
/**
|
|
442
|
-
* Clear all cached data (memory and file)
|
|
443
|
-
*/
|
|
444
|
-
clearCache() {
|
|
445
|
-
this.memoryCache.clear();
|
|
446
|
-
this.pendingRequests.clear();
|
|
447
|
-
try {
|
|
448
|
-
if (existsSync(this.cacheFile)) {
|
|
449
|
-
unlinkSync(this.cacheFile);
|
|
450
|
-
}
|
|
451
|
-
} catch (error) {
|
|
452
|
-
this.log("Failed to clear file cache:", error);
|
|
453
|
-
}
|
|
454
|
-
this.log("Cache cleared");
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* Clear expired cache entries
|
|
458
|
-
*/
|
|
459
|
-
clearExpiredCache() {
|
|
460
|
-
const now = Date.now();
|
|
461
|
-
const keysToDelete = [];
|
|
462
|
-
this.memoryCache.forEach((entry, key) => {
|
|
463
|
-
if (now - entry.timestamp > entry.ttl) {
|
|
464
|
-
keysToDelete.push(key);
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
keysToDelete.forEach((key) => this.memoryCache.delete(key));
|
|
468
|
-
this.log("Cleared", keysToDelete.length, "expired cache entries");
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Get cache statistics
|
|
472
|
-
*/
|
|
473
|
-
getCacheStats() {
|
|
474
|
-
const fileCache = this.loadFileCache();
|
|
475
|
-
let cacheSize = 0;
|
|
476
|
-
try {
|
|
477
|
-
if (existsSync(this.cacheFile)) {
|
|
478
|
-
cacheSize = statSync(this.cacheFile).size;
|
|
479
|
-
}
|
|
480
|
-
} catch {
|
|
481
|
-
}
|
|
482
|
-
return {
|
|
483
|
-
totalPackages: fileCache?.packages.length || 0,
|
|
484
|
-
cacheSize,
|
|
485
|
-
lastUpdated: fileCache?.lastUpdated || null,
|
|
486
|
-
expiresAt: fileCache?.expiresAt || null,
|
|
487
|
-
isExpired: this.isFileCacheExpired(),
|
|
488
|
-
cachedCategories: fileCache?.categories.length || 0
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Set offline mode
|
|
493
|
-
*/
|
|
494
|
-
setOfflineMode(enabled) {
|
|
495
|
-
this.offlineMode = enabled;
|
|
496
|
-
this.log("Offline mode:", enabled ? "enabled" : "disabled");
|
|
497
|
-
}
|
|
498
|
-
// ==========================================================================
|
|
499
|
-
// Private Request Methods
|
|
500
|
-
// ==========================================================================
|
|
501
|
-
/**
|
|
502
|
-
* Make an HTTP request with caching, deduplication, and throttling
|
|
503
|
-
*/
|
|
504
|
-
async request(endpoint, options = {}) {
|
|
505
|
-
const url = this.buildUrl(endpoint, options.params);
|
|
506
|
-
const cacheKey = `${options.method || "GET"}:${url}`;
|
|
507
|
-
if (!options.skipCache && (options.method === "GET" || !options.method)) {
|
|
508
|
-
const cached = this.getFromMemoryCache(cacheKey);
|
|
509
|
-
if (cached) {
|
|
510
|
-
this.log("Memory cache hit:", cacheKey);
|
|
511
|
-
return {
|
|
512
|
-
success: true,
|
|
513
|
-
data: cached,
|
|
514
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
515
|
-
};
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
if (this.enableDeduplication && (options.method === "GET" || !options.method)) {
|
|
519
|
-
const pending = this.pendingRequests.get(cacheKey);
|
|
520
|
-
if (pending) {
|
|
521
|
-
this.log("Deduplicating request:", cacheKey);
|
|
522
|
-
return pending.promise;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
if (this.offlineMode) {
|
|
526
|
-
const cached = this.getFromMemoryCache(cacheKey);
|
|
527
|
-
if (cached) {
|
|
528
|
-
this.log("Offline mode: returning cached data");
|
|
529
|
-
return {
|
|
530
|
-
success: true,
|
|
531
|
-
data: cached,
|
|
532
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
return {
|
|
536
|
-
success: false,
|
|
537
|
-
error: {
|
|
538
|
-
code: "OFFLINE_MODE",
|
|
539
|
-
message: "Offline mode enabled and no cached data available"
|
|
540
|
-
},
|
|
541
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
await this.throttle();
|
|
545
|
-
const requestPromise = this.executeRequest(url, options, cacheKey);
|
|
546
|
-
if (this.enableDeduplication && (options.method === "GET" || !options.method)) {
|
|
547
|
-
this.pendingRequests.set(cacheKey, {
|
|
548
|
-
promise: requestPromise,
|
|
549
|
-
timestamp: Date.now()
|
|
550
|
-
});
|
|
551
|
-
requestPromise.finally(() => {
|
|
552
|
-
this.pendingRequests.delete(cacheKey);
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
return requestPromise;
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Execute HTTP request with retry logic
|
|
559
|
-
*/
|
|
560
|
-
async executeRequest(url, options, cacheKey) {
|
|
561
|
-
let lastError = null;
|
|
562
|
-
for (let attempt = 1; attempt <= this.maxRetries; attempt++) {
|
|
563
|
-
try {
|
|
564
|
-
this.log(`Request attempt ${attempt}/${this.maxRetries}:`, url);
|
|
565
|
-
const response = await this.makeRequest(url, options);
|
|
566
|
-
if (response.success && response.data && (options.method === "GET" || !options.method)) {
|
|
567
|
-
this.setMemoryCache(cacheKey, response.data, this.cacheTTL);
|
|
568
|
-
}
|
|
569
|
-
return response;
|
|
570
|
-
} catch (error) {
|
|
571
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
572
|
-
this.log(`Request failed (attempt ${attempt}):`, lastError.message);
|
|
573
|
-
if (lastError.name === "AbortError") {
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
if (attempt < this.maxRetries) {
|
|
577
|
-
await this.sleep(this.retryDelay * attempt);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return {
|
|
582
|
-
success: false,
|
|
583
|
-
error: {
|
|
584
|
-
code: "REQUEST_FAILED",
|
|
585
|
-
message: lastError?.message || "Request failed after all retries"
|
|
586
|
-
},
|
|
587
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
588
|
-
};
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Make a single HTTP request
|
|
592
|
-
*/
|
|
593
|
-
async makeRequest(url, options) {
|
|
594
|
-
const controller = new AbortController();
|
|
595
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
596
|
-
try {
|
|
597
|
-
const response = await fetch(url, {
|
|
598
|
-
method: options.method || "GET",
|
|
599
|
-
headers: this.getHeaders(),
|
|
600
|
-
body: options.body,
|
|
601
|
-
signal: controller.signal
|
|
602
|
-
});
|
|
603
|
-
clearTimeout(timeoutId);
|
|
604
|
-
this.lastRequestTime = Date.now();
|
|
605
|
-
const data = await response.json();
|
|
606
|
-
if (!response.ok) {
|
|
607
|
-
return {
|
|
608
|
-
success: false,
|
|
609
|
-
error: data.error || {
|
|
610
|
-
code: `HTTP_${response.status}`,
|
|
611
|
-
message: `HTTP ${response.status}: ${response.statusText}`
|
|
612
|
-
},
|
|
613
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
return {
|
|
617
|
-
...data,
|
|
618
|
-
success: true,
|
|
619
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
620
|
-
};
|
|
621
|
-
} catch (error) {
|
|
622
|
-
clearTimeout(timeoutId);
|
|
623
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
624
|
-
throw error;
|
|
625
|
-
}
|
|
626
|
-
return {
|
|
627
|
-
success: false,
|
|
628
|
-
error: {
|
|
629
|
-
code: "NETWORK_ERROR",
|
|
630
|
-
message: error instanceof Error ? error.message : String(error)
|
|
631
|
-
},
|
|
632
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
// ==========================================================================
|
|
637
|
-
// Helper Methods
|
|
638
|
-
// ==========================================================================
|
|
639
|
-
/**
|
|
640
|
-
* Build full URL with query parameters
|
|
641
|
-
*/
|
|
642
|
-
buildUrl(endpoint, params) {
|
|
643
|
-
const url = new URL(endpoint, this.baseUrl);
|
|
644
|
-
if (params) {
|
|
645
|
-
for (const [key, value] of Object.entries(params)) {
|
|
646
|
-
if (value !== void 0 && value !== null) {
|
|
647
|
-
if (Array.isArray(value)) {
|
|
648
|
-
value.forEach((v) => url.searchParams.append(key, String(v)));
|
|
649
|
-
} else {
|
|
650
|
-
url.searchParams.append(key, String(value));
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
return url.toString();
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Build search parameters from options
|
|
659
|
-
*/
|
|
660
|
-
buildSearchParams(options) {
|
|
661
|
-
return {
|
|
662
|
-
q: options.query,
|
|
663
|
-
category: options.category,
|
|
664
|
-
tags: options.tags,
|
|
665
|
-
sortBy: options.sortBy,
|
|
666
|
-
sortOrder: options.sortOrder,
|
|
667
|
-
verified: options.verified,
|
|
668
|
-
verificationStatus: options.verificationStatus,
|
|
669
|
-
author: options.author,
|
|
670
|
-
platform: options.platform,
|
|
671
|
-
codeTool: options.codeTool,
|
|
672
|
-
minRating: options.minRating,
|
|
673
|
-
page: options.page || 1,
|
|
674
|
-
limit: options.limit || 20
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* Get request headers
|
|
679
|
-
*/
|
|
680
|
-
getHeaders() {
|
|
681
|
-
const headers = {
|
|
682
|
-
"Content-Type": "application/json",
|
|
683
|
-
"User-Agent": "CCJK-MCP-Marketplace-Client/1.0"
|
|
684
|
-
};
|
|
685
|
-
if (this.apiKey) {
|
|
686
|
-
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
687
|
-
}
|
|
688
|
-
return headers;
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* Throttle requests
|
|
692
|
-
*/
|
|
693
|
-
async throttle() {
|
|
694
|
-
const now = Date.now();
|
|
695
|
-
const elapsed = now - this.lastRequestTime;
|
|
696
|
-
const remaining = this.throttleInterval - elapsed;
|
|
697
|
-
if (remaining > 0) {
|
|
698
|
-
await this.sleep(remaining);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Sleep for specified milliseconds
|
|
703
|
-
*/
|
|
704
|
-
sleep(ms) {
|
|
705
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Log message (if logging is enabled)
|
|
709
|
-
*/
|
|
710
|
-
log(...args) {
|
|
711
|
-
if (this.enableLogging) {
|
|
712
|
-
console.log("[MarketplaceClient]", ...args);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
// ==========================================================================
|
|
716
|
-
// Memory Cache Methods
|
|
717
|
-
// ==========================================================================
|
|
718
|
-
/**
|
|
719
|
-
* Get data from memory cache
|
|
720
|
-
*/
|
|
721
|
-
getFromMemoryCache(key) {
|
|
722
|
-
const entry = this.memoryCache.get(key);
|
|
723
|
-
if (!entry) {
|
|
724
|
-
return null;
|
|
725
|
-
}
|
|
726
|
-
const now = Date.now();
|
|
727
|
-
if (now - entry.timestamp > entry.ttl) {
|
|
728
|
-
this.memoryCache.delete(key);
|
|
729
|
-
return null;
|
|
730
|
-
}
|
|
731
|
-
return entry.data;
|
|
732
|
-
}
|
|
733
|
-
/**
|
|
734
|
-
* Set data in memory cache
|
|
735
|
-
*/
|
|
736
|
-
setMemoryCache(key, data, ttl) {
|
|
737
|
-
this.memoryCache.set(key, {
|
|
738
|
-
data,
|
|
739
|
-
timestamp: Date.now(),
|
|
740
|
-
ttl
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
// ==========================================================================
|
|
744
|
-
// File Cache Methods
|
|
745
|
-
// ==========================================================================
|
|
746
|
-
/**
|
|
747
|
-
* Ensure cache directory exists
|
|
748
|
-
*/
|
|
749
|
-
ensureCacheDir() {
|
|
750
|
-
if (!existsSync(this.cacheDir)) {
|
|
751
|
-
mkdirSync(this.cacheDir, { recursive: true });
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
/**
|
|
755
|
-
* Load cache from file
|
|
756
|
-
*/
|
|
757
|
-
loadFileCache() {
|
|
758
|
-
try {
|
|
759
|
-
if (!existsSync(this.cacheFile)) {
|
|
760
|
-
return null;
|
|
761
|
-
}
|
|
762
|
-
const content = readFileSync(this.cacheFile, "utf-8");
|
|
763
|
-
const cache = JSON.parse(content);
|
|
764
|
-
if (cache.version !== CACHE_VERSION) {
|
|
765
|
-
return null;
|
|
766
|
-
}
|
|
767
|
-
return cache;
|
|
768
|
-
} catch {
|
|
769
|
-
return null;
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Save cache to file
|
|
774
|
-
*/
|
|
775
|
-
saveFileCache(packages, categories) {
|
|
776
|
-
try {
|
|
777
|
-
this.ensureCacheDir();
|
|
778
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
779
|
-
const expiresAt = new Date(Date.now() + this.cacheTTL).toISOString();
|
|
780
|
-
const cache = {
|
|
781
|
-
version: CACHE_VERSION,
|
|
782
|
-
packages,
|
|
783
|
-
categories,
|
|
784
|
-
createdAt: now,
|
|
785
|
-
expiresAt,
|
|
786
|
-
lastUpdated: now
|
|
787
|
-
};
|
|
788
|
-
writeFileAtomic(this.cacheFile, JSON.stringify(cache, null, 2), "utf-8");
|
|
789
|
-
} catch (error) {
|
|
790
|
-
this.log("Failed to save file cache:", error);
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Check if file cache is expired
|
|
795
|
-
*/
|
|
796
|
-
isFileCacheExpired() {
|
|
797
|
-
const cache = this.loadFileCache();
|
|
798
|
-
if (!cache) {
|
|
799
|
-
return true;
|
|
800
|
-
}
|
|
801
|
-
const expiresAt = new Date(cache.expiresAt).getTime();
|
|
802
|
-
return Date.now() >= expiresAt;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
let defaultClientInstance = null;
|
|
806
|
-
function getDefaultMarketplaceClient() {
|
|
807
|
-
if (!defaultClientInstance) {
|
|
808
|
-
defaultClientInstance = new MarketplaceClient();
|
|
809
|
-
}
|
|
810
|
-
return defaultClientInstance;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
function getLocalFallbackServices() {
|
|
814
|
-
return [
|
|
815
|
-
// CCJK managed services (from mcp-services config)
|
|
816
|
-
...MCP_SERVICE_CONFIGS.map((svc) => ({
|
|
817
|
-
name: svc.id,
|
|
818
|
-
description: svc.id,
|
|
819
|
-
// Will be replaced with i18n
|
|
820
|
-
package: svc.config.command || svc.id,
|
|
821
|
-
category: "ccjk",
|
|
822
|
-
serviceId: svc.id,
|
|
823
|
-
requiresApiKey: svc.requiresApiKey
|
|
824
|
-
})),
|
|
825
|
-
// External MCP servers from Awesome MCP Servers (fallback)
|
|
826
|
-
{ name: "Filesystem", description: "Secure file operations", package: "@modelcontextprotocol/server-filesystem", category: "core" },
|
|
827
|
-
{ name: "GitHub", description: "Repository management", package: "@modelcontextprotocol/server-github", category: "dev" },
|
|
828
|
-
{ name: "PostgreSQL", description: "Database operations", package: "@modelcontextprotocol/server-postgres", category: "database" },
|
|
829
|
-
{ name: "Puppeteer", description: "Browser automation", package: "@modelcontextprotocol/server-puppeteer", category: "automation" },
|
|
830
|
-
{ name: "Brave Search", description: "Web search", package: "@modelcontextprotocol/server-brave-search", category: "search" },
|
|
831
|
-
{ name: "Google Maps", description: "Location services", package: "@modelcontextprotocol/server-google-maps", category: "api" },
|
|
832
|
-
{ name: "Slack", description: "Team communication", package: "@modelcontextprotocol/server-slack", category: "communication" },
|
|
833
|
-
{ name: "Memory", description: "Knowledge graph", package: "@modelcontextprotocol/server-memory", category: "ai" }
|
|
834
|
-
];
|
|
835
|
-
}
|
|
836
|
-
function convertToMcpServer(pkg) {
|
|
837
|
-
const lang = i18n.language;
|
|
838
|
-
return {
|
|
839
|
-
name: pkg.name,
|
|
840
|
-
description: pkg.description[lang] || pkg.description.en,
|
|
841
|
-
package: pkg.id,
|
|
842
|
-
category: pkg.category,
|
|
843
|
-
stars: pkg.rating,
|
|
844
|
-
serviceId: pkg.id,
|
|
845
|
-
requiresApiKey: pkg.permissions.some((p) => p.type === "env")
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
async function mcpSearch(keyword, options = {}) {
|
|
849
|
-
const client = getDefaultMarketplaceClient();
|
|
850
|
-
try {
|
|
851
|
-
const searchOptions = {
|
|
852
|
-
query: keyword,
|
|
853
|
-
category: options.category,
|
|
854
|
-
verified: options.verified,
|
|
855
|
-
sortBy: options.sortBy || "relevance",
|
|
856
|
-
limit: options.limit || 50
|
|
857
|
-
};
|
|
858
|
-
const result = await client.search(searchOptions);
|
|
859
|
-
if (result.packages.length === 0) {
|
|
860
|
-
console.log(a.yellow(`
|
|
861
|
-
${i18n.t("mcp:market.noResults", { keyword })}`));
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
864
|
-
console.log(a.green.bold(`
|
|
865
|
-
${i18n.t("mcp:market.searchResults", { count: result.total, keyword })}
|
|
866
|
-
`));
|
|
867
|
-
result.packages.forEach((pkg, idx) => {
|
|
868
|
-
const lang = i18n.language;
|
|
869
|
-
const verifiedBadge = pkg.verified ? a.green("\u2713") : a.dim("\u25CB");
|
|
870
|
-
console.log(`${a.green(`${idx + 1}.`)} ${a.bold(pkg.name)} ${verifiedBadge} ${a.dim(`[${pkg.category}]`)}`);
|
|
871
|
-
console.log(` ${pkg.description[lang] || pkg.description.en}`);
|
|
872
|
-
console.log(` ${a.dim(`\u{1F4E5} ${pkg.downloads.toLocaleString()} | \u2B50 ${pkg.rating.toFixed(1)}/5.0`)}`);
|
|
873
|
-
console.log(` ${a.dim(pkg.id)}
|
|
874
|
-
`);
|
|
875
|
-
});
|
|
876
|
-
if (result.hasMore) {
|
|
877
|
-
console.log(a.dim(`
|
|
878
|
-
${i18n.t("mcp:market.moreResults", { total: result.total, shown: result.packages.length })}`));
|
|
879
|
-
}
|
|
880
|
-
} catch {
|
|
881
|
-
console.log(a.yellow(`
|
|
882
|
-
${i18n.t("mcp:market.apiUnavailable")}`));
|
|
883
|
-
console.log(a.dim(i18n.t("mcp:market.usingLocalData")));
|
|
884
|
-
const localServers = getLocalFallbackServices();
|
|
885
|
-
const results = localServers.filter(
|
|
886
|
-
(s) => s.name.toLowerCase().includes(keyword.toLowerCase()) || s.description.toLowerCase().includes(keyword.toLowerCase()) || s.category.toLowerCase().includes(keyword.toLowerCase())
|
|
887
|
-
);
|
|
888
|
-
if (results.length === 0) {
|
|
889
|
-
console.log(a.yellow(`
|
|
890
|
-
${i18n.t("mcp:market.noResults", { keyword })}`));
|
|
891
|
-
return;
|
|
892
|
-
}
|
|
893
|
-
console.log(a.green.bold(`
|
|
894
|
-
${i18n.t("mcp:market.searchResults", { count: results.length, keyword })}
|
|
895
|
-
`));
|
|
896
|
-
results.forEach((server, idx) => {
|
|
897
|
-
console.log(`${a.green(`${idx + 1}.`)} ${a.bold(server.name)} ${a.dim(`[${server.category}]`)}`);
|
|
898
|
-
console.log(` ${server.description}`);
|
|
899
|
-
console.log(` ${a.dim(server.package)}
|
|
900
|
-
`);
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
async function mcpInstall(serverName, options = {}) {
|
|
905
|
-
const client = getDefaultMarketplaceClient();
|
|
906
|
-
let server = null;
|
|
907
|
-
const localServers = getLocalFallbackServices();
|
|
908
|
-
server = localServers.find((s) => s.name.toLowerCase() === serverName.toLowerCase()) || null;
|
|
909
|
-
if (!server) {
|
|
910
|
-
try {
|
|
911
|
-
const pkg = await client.getPackage(serverName);
|
|
912
|
-
if (pkg) {
|
|
913
|
-
server = convertToMcpServer(pkg);
|
|
914
|
-
}
|
|
915
|
-
} catch {
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
if (!server) {
|
|
919
|
-
console.log(a.red(`
|
|
920
|
-
${i18n.t("mcp:market.serverNotFound", { name: serverName })}`));
|
|
921
|
-
return;
|
|
922
|
-
}
|
|
923
|
-
if (server.serviceId) {
|
|
924
|
-
const isInstalled = await isMcpServiceInstalled(server.serviceId, options.tool);
|
|
925
|
-
if (isInstalled) {
|
|
926
|
-
console.log(a.yellow(`
|
|
927
|
-
${i18n.t("mcp:installer.alreadyInstalled", { name: server.name })}`));
|
|
928
|
-
return;
|
|
929
|
-
}
|
|
930
|
-
console.log(a.green(`
|
|
931
|
-
${i18n.t("mcp:market.installing", { name: server.name })}`));
|
|
932
|
-
if (server.requiresApiKey) {
|
|
933
|
-
console.log(a.dim(i18n.t("mcp:installer.requiresApiKey")));
|
|
934
|
-
}
|
|
935
|
-
console.log("");
|
|
936
|
-
const { confirm } = await inquirer.prompt([{
|
|
937
|
-
type: "confirm",
|
|
938
|
-
name: "confirm",
|
|
939
|
-
message: i18n.t("mcp:market.confirmInstall"),
|
|
940
|
-
default: true
|
|
941
|
-
}]);
|
|
942
|
-
if (!confirm) {
|
|
943
|
-
console.log(a.yellow(i18n.t("mcp:market.cancelled")));
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
946
|
-
const result = await installMcpService(server.serviceId, options.tool);
|
|
947
|
-
if (result.success) {
|
|
948
|
-
console.log(a.green(`
|
|
949
|
-
${i18n.t("mcp:market.installSuccess", { name: server.name })}`));
|
|
950
|
-
console.log(a.dim(i18n.t("mcp:installer.restartRequired")));
|
|
951
|
-
} else {
|
|
952
|
-
console.log(a.red(`
|
|
953
|
-
${i18n.t("mcp:installer.installFailed", { name: server.name })}`));
|
|
954
|
-
if (result.error) {
|
|
955
|
-
console.log(a.dim(result.error));
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
} else {
|
|
959
|
-
console.log(a.green(`
|
|
960
|
-
${i18n.t("mcp:market.installing", { name: server.name })}`));
|
|
961
|
-
console.log(a.dim(`Package: ${server.package}
|
|
962
|
-
`));
|
|
963
|
-
const { confirm } = await inquirer.prompt([{
|
|
964
|
-
type: "confirm",
|
|
965
|
-
name: "confirm",
|
|
966
|
-
message: i18n.t("mcp:market.confirmInstall"),
|
|
967
|
-
default: true
|
|
968
|
-
}]);
|
|
969
|
-
if (!confirm) {
|
|
970
|
-
console.log(a.yellow(i18n.t("mcp:market.cancelled")));
|
|
971
|
-
return;
|
|
972
|
-
}
|
|
973
|
-
console.log(a.green(`
|
|
974
|
-
${i18n.t("mcp:market.installSuccess", { name: server.name })}`));
|
|
975
|
-
console.log(a.dim(i18n.t("mcp:market.manualConfig")));
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
async function mcpUninstall(serverName, options = {}) {
|
|
979
|
-
const localServers = getLocalFallbackServices();
|
|
980
|
-
const server = localServers.find((s) => s.name.toLowerCase() === serverName.toLowerCase());
|
|
981
|
-
const serviceId = server?.serviceId || serverName;
|
|
982
|
-
const isInstalled = await isMcpServiceInstalled(serviceId, options.tool);
|
|
983
|
-
if (!isInstalled) {
|
|
984
|
-
console.log(a.yellow(`
|
|
985
|
-
${i18n.t("mcp:installer.serviceNotInstalled", { id: serverName })}`));
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
const displayName = server?.name || serverName;
|
|
989
|
-
const { confirm } = await inquirer.prompt([{
|
|
990
|
-
type: "confirm",
|
|
991
|
-
name: "confirm",
|
|
992
|
-
message: i18n.t("mcp:market.confirmUninstall", { name: displayName }),
|
|
993
|
-
default: false
|
|
994
|
-
}]);
|
|
995
|
-
if (!confirm) {
|
|
996
|
-
console.log(a.yellow(i18n.t("mcp:market.cancelled")));
|
|
997
|
-
return;
|
|
998
|
-
}
|
|
999
|
-
const result = await uninstallMcpService(serviceId, options.tool);
|
|
1000
|
-
if (result.success) {
|
|
1001
|
-
console.log(a.green(`
|
|
1002
|
-
${i18n.t("mcp:installer.uninstallSuccess", { name: displayName })}`));
|
|
1003
|
-
console.log(a.dim(i18n.t("mcp:installer.restartRequired")));
|
|
1004
|
-
} else {
|
|
1005
|
-
console.log(a.red(`
|
|
1006
|
-
${i18n.t("mcp:installer.uninstallFailed", { name: displayName })}`));
|
|
1007
|
-
if (result.error) {
|
|
1008
|
-
console.log(a.dim(result.error));
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
async function mcpList(options = {}) {
|
|
1013
|
-
await displayInstalledMcpServices(options.tool);
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
const MCP_PROFILES = [
|
|
1017
|
-
{
|
|
1018
|
-
id: "minimal",
|
|
1019
|
-
name: "Minimal",
|
|
1020
|
-
nameZh: "\u6781\u7B80\u6A21\u5F0F",
|
|
1021
|
-
description: "Core services only, best performance",
|
|
1022
|
-
descriptionZh: "\u4EC5\u6838\u5FC3\u670D\u52A1\uFF0C\u6700\u4F73\u6027\u80FD",
|
|
1023
|
-
services: ["context7", "open-websearch"],
|
|
1024
|
-
maxServices: 3,
|
|
1025
|
-
tier: "core"
|
|
1026
|
-
},
|
|
1027
|
-
{
|
|
1028
|
-
id: "development",
|
|
1029
|
-
name: "Development",
|
|
1030
|
-
nameZh: "\u5F00\u53D1\u6A21\u5F0F",
|
|
1031
|
-
description: "Suitable for daily development",
|
|
1032
|
-
descriptionZh: "\u9002\u5408\u65E5\u5E38\u5F00\u53D1",
|
|
1033
|
-
services: ["context7", "open-websearch", "mcp-deepwiki", "sqlite"],
|
|
1034
|
-
maxServices: 5,
|
|
1035
|
-
tier: "ondemand",
|
|
1036
|
-
isDefault: true
|
|
1037
|
-
},
|
|
1038
|
-
{
|
|
1039
|
-
id: "testing",
|
|
1040
|
-
name: "Testing",
|
|
1041
|
-
nameZh: "\u6D4B\u8BD5\u6A21\u5F0F",
|
|
1042
|
-
description: "Includes browser automation",
|
|
1043
|
-
descriptionZh: "\u5305\u542B\u6D4F\u89C8\u5668\u81EA\u52A8\u5316",
|
|
1044
|
-
services: ["context7", "open-websearch", "Playwright"],
|
|
1045
|
-
maxServices: 4,
|
|
1046
|
-
tier: "ondemand"
|
|
1047
|
-
},
|
|
1048
|
-
{
|
|
1049
|
-
id: "research",
|
|
1050
|
-
name: "Research",
|
|
1051
|
-
nameZh: "\u7814\u7A76\u6A21\u5F0F",
|
|
1052
|
-
description: "Enhanced documentation and search",
|
|
1053
|
-
descriptionZh: "\u589E\u5F3A\u6587\u6863\u548C\u641C\u7D22\u529F\u80FD",
|
|
1054
|
-
services: ["context7", "open-websearch", "mcp-deepwiki", "memory", "sequential-thinking"],
|
|
1055
|
-
maxServices: 6,
|
|
1056
|
-
tier: "ondemand"
|
|
1057
|
-
},
|
|
1058
|
-
{
|
|
1059
|
-
id: "full",
|
|
1060
|
-
name: "Full",
|
|
1061
|
-
nameZh: "\u5168\u529F\u80FD\u6A21\u5F0F",
|
|
1062
|
-
description: "All services (high resource usage)",
|
|
1063
|
-
descriptionZh: "\u6240\u6709\u670D\u52A1\uFF08\u9AD8\u8D44\u6E90\u6D88\u8017\uFF09",
|
|
1064
|
-
services: [],
|
|
1065
|
-
// Empty means all services
|
|
1066
|
-
maxServices: void 0,
|
|
1067
|
-
tier: "scenario"
|
|
1068
|
-
}
|
|
1069
|
-
];
|
|
1070
|
-
function getProfileById(id) {
|
|
1071
|
-
return MCP_PROFILES.find((p) => p.id === id);
|
|
1072
|
-
}
|
|
1073
|
-
function getProfileIds() {
|
|
1074
|
-
return MCP_PROFILES.map((p) => p.id);
|
|
1075
|
-
}
|
|
1076
|
-
function getProfileName(profile, lang = "en") {
|
|
1077
|
-
return lang === "zh-CN" ? profile.nameZh : profile.name;
|
|
1078
|
-
}
|
|
1079
|
-
function getProfileDescription(profile, lang = "en") {
|
|
1080
|
-
return lang === "zh-CN" ? profile.descriptionZh : profile.description;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
async function listProfiles(options = {}) {
|
|
1084
|
-
const lang = options.lang || i18n.language || "en";
|
|
1085
|
-
const isZh = lang === "zh-CN";
|
|
1086
|
-
console.log("");
|
|
1087
|
-
console.log(a.bold.cyan(isZh ? "\u{1F4CB} \u53EF\u7528\u7684 MCP \u914D\u7F6E\u9884\u8BBE" : "\u{1F4CB} Available MCP Profiles"));
|
|
1088
|
-
console.log(a.dim("\u2500".repeat(50)));
|
|
1089
|
-
console.log("");
|
|
1090
|
-
for (const profile of MCP_PROFILES) {
|
|
1091
|
-
const name = getProfileName(profile, lang);
|
|
1092
|
-
const desc = getProfileDescription(profile, lang);
|
|
1093
|
-
const serviceCount = profile.services.length === 0 ? isZh ? "\u5168\u90E8" : "All" : profile.services.length.toString();
|
|
1094
|
-
const defaultBadge = profile.isDefault ? a.green(isZh ? " [\u9ED8\u8BA4]" : " [default]") : "";
|
|
1095
|
-
console.log(`${a.bold.green(profile.id)}${defaultBadge}`);
|
|
1096
|
-
console.log(` ${a.white(name)} - ${a.dim(desc)}`);
|
|
1097
|
-
console.log(` ${a.dim(isZh ? "\u670D\u52A1\u6570\u91CF" : "Services")}: ${serviceCount}`);
|
|
1098
|
-
if (profile.services.length > 0 && profile.services.length <= 6) {
|
|
1099
|
-
console.log(` ${a.dim(profile.services.join(", "))}`);
|
|
1100
|
-
}
|
|
1101
|
-
console.log("");
|
|
1102
|
-
}
|
|
1103
|
-
console.log(a.dim("\u2500".repeat(50)));
|
|
1104
|
-
console.log(a.dim(isZh ? "\u4F7F\u7528 `ccjk mcp profile use <id>` \u5207\u6362\u914D\u7F6E" : "Use `ccjk mcp profile use <id>` to switch profile"));
|
|
1105
|
-
console.log("");
|
|
1106
|
-
}
|
|
1107
|
-
async function useProfile(profileId, options = {}) {
|
|
1108
|
-
const lang = options.lang || i18n.language || "en";
|
|
1109
|
-
const isZh = lang === "zh-CN";
|
|
1110
|
-
const profile = getProfileById(profileId);
|
|
1111
|
-
if (!profile) {
|
|
1112
|
-
console.log(a.red(isZh ? `\u274C \u672A\u627E\u5230\u914D\u7F6E\u9884\u8BBE: ${profileId}` : `\u274C Profile not found: ${profileId}`));
|
|
1113
|
-
console.log(a.dim(isZh ? `\u53EF\u7528\u9884\u8BBE: ${getProfileIds().join(", ")}` : `Available profiles: ${getProfileIds().join(", ")}`));
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
|
-
const backupPath = backupMcpConfig();
|
|
1117
|
-
if (backupPath) {
|
|
1118
|
-
console.log(a.gray(`\u2714 ${isZh ? "\u5DF2\u5907\u4EFD\u5F53\u524D\u914D\u7F6E" : "Backed up current config"}: ${backupPath}`));
|
|
1119
|
-
}
|
|
1120
|
-
let servicesToEnable;
|
|
1121
|
-
if (profile.services.length === 0) {
|
|
1122
|
-
servicesToEnable = MCP_SERVICE_CONFIGS.filter((s) => !s.requiresApiKey).map((s) => s.id);
|
|
1123
|
-
} else {
|
|
1124
|
-
servicesToEnable = profile.services;
|
|
1125
|
-
}
|
|
1126
|
-
const newServers = {};
|
|
1127
|
-
for (const serviceId of servicesToEnable) {
|
|
1128
|
-
const serviceConfig = MCP_SERVICE_CONFIGS.find((s) => s.id === serviceId);
|
|
1129
|
-
if (serviceConfig) {
|
|
1130
|
-
newServers[serviceId] = serviceConfig.config;
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
const existingConfig = readMcpConfig() || {};
|
|
1134
|
-
const newConfig = {
|
|
1135
|
-
...existingConfig,
|
|
1136
|
-
mcpServers: newServers
|
|
1137
|
-
};
|
|
1138
|
-
writeMcpConfig(newConfig);
|
|
1139
|
-
const profileName = getProfileName(profile, lang);
|
|
1140
|
-
console.log(a.green(`\u2714 ${isZh ? "\u5DF2\u5207\u6362\u5230\u914D\u7F6E\u9884\u8BBE" : "Switched to profile"}: ${profileName}`));
|
|
1141
|
-
console.log(a.dim(` ${isZh ? "\u5DF2\u542F\u7528\u670D\u52A1" : "Enabled services"}: ${servicesToEnable.length}`));
|
|
1142
|
-
const warning = checkMcpPerformance(servicesToEnable.length);
|
|
1143
|
-
if (warning) {
|
|
1144
|
-
console.log("");
|
|
1145
|
-
console.log(formatPerformanceWarning(warning, lang));
|
|
1146
|
-
}
|
|
1147
|
-
console.log("");
|
|
1148
|
-
console.log(a.yellow(isZh ? "\u26A0\uFE0F \u8BF7\u91CD\u542F Claude Code \u4EE5\u4F7F\u66F4\u6539\u751F\u6548" : "\u26A0\uFE0F Please restart Claude Code for changes to take effect"));
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
async function mcpStatus(options = {}) {
|
|
1152
|
-
const { readMcpConfig } = await import('./claude-config.mjs').then(function (n) { return n.h; });
|
|
1153
|
-
const { checkMcpPerformance, formatPerformanceWarning } = await import('./mcp-performance.mjs').then(function (n) { return n.e; });
|
|
1154
|
-
const { MCP_SERVICE_TIERS } = await import('./mcp-performance.mjs').then(function (n) { return n.m; });
|
|
1155
|
-
const lang = options.lang || i18n.language || "en";
|
|
1156
|
-
const isZh = lang === "zh-CN";
|
|
1157
|
-
console.log("");
|
|
1158
|
-
console.log(a.bold.cyan(isZh ? "\u26A1 MCP \u5FEB\u901F\u72B6\u6001" : "\u26A1 MCP Quick Status"));
|
|
1159
|
-
console.log(a.dim("\u2500".repeat(40)));
|
|
1160
|
-
const config = await readMcpConfig();
|
|
1161
|
-
const services = Object.keys(config?.mcpServers || {});
|
|
1162
|
-
let coreCount = 0;
|
|
1163
|
-
let ondemandCount = 0;
|
|
1164
|
-
let scenarioCount = 0;
|
|
1165
|
-
for (const svc of services) {
|
|
1166
|
-
const tier = MCP_SERVICE_TIERS[svc] || "ondemand";
|
|
1167
|
-
if (tier === "core")
|
|
1168
|
-
coreCount++;
|
|
1169
|
-
else if (tier === "ondemand")
|
|
1170
|
-
ondemandCount++;
|
|
1171
|
-
else scenarioCount++;
|
|
1172
|
-
}
|
|
1173
|
-
console.log("");
|
|
1174
|
-
console.log(`${a.green("\u25CF")} ${isZh ? "\u6838\u5FC3\u670D\u52A1" : "Core"}: ${coreCount}`);
|
|
1175
|
-
console.log(`${a.yellow("\u25CF")} ${isZh ? "\u6309\u9700\u670D\u52A1" : "On-demand"}: ${ondemandCount}`);
|
|
1176
|
-
console.log(`${a.green("\u25CF")} ${isZh ? "\u573A\u666F\u670D\u52A1" : "Scenario"}: ${scenarioCount}`);
|
|
1177
|
-
console.log(`${a.dim("\u2500")} ${isZh ? "\u603B\u8BA1" : "Total"}: ${services.length}`);
|
|
1178
|
-
const perfResult = checkMcpPerformance(services.length);
|
|
1179
|
-
if (perfResult) {
|
|
1180
|
-
console.log("");
|
|
1181
|
-
console.log(formatPerformanceWarning(perfResult, lang));
|
|
1182
|
-
} else {
|
|
1183
|
-
console.log("");
|
|
1184
|
-
console.log(a.green(isZh ? "\u2713 \u6027\u80FD\u72B6\u6001\u826F\u597D" : "\u2713 Performance OK"));
|
|
1185
|
-
}
|
|
1186
|
-
console.log("");
|
|
1187
|
-
console.log(a.dim(isZh ? "\u63D0\u793A: \u4F7F\u7528 ccjk mcp doctor \u67E5\u770B\u8BE6\u7EC6\u8BCA\u65AD" : "Tip: Use ccjk mcp doctor for detailed diagnostics"));
|
|
1188
|
-
}
|
|
1189
|
-
function mcpHelp(options = {}) {
|
|
1190
|
-
const lang = options.lang || i18n.language || "en";
|
|
1191
|
-
const isZh = lang === "zh-CN";
|
|
1192
|
-
console.log("");
|
|
1193
|
-
console.log(a.bold.cyan(isZh ? "\u{1F527} MCP \u7BA1\u7406\u547D\u4EE4" : "\u{1F527} MCP Management Commands"));
|
|
1194
|
-
console.log(a.dim("\u2500".repeat(50)));
|
|
1195
|
-
console.log("");
|
|
1196
|
-
const commands = [
|
|
1197
|
-
{
|
|
1198
|
-
cmd: "ccjk mcp status",
|
|
1199
|
-
desc: isZh ? "\u5FEB\u901F\u67E5\u770B MCP \u72B6\u6001" : "Quick MCP status overview"
|
|
1200
|
-
},
|
|
1201
|
-
{
|
|
1202
|
-
cmd: "ccjk mcp doctor",
|
|
1203
|
-
desc: isZh ? "\u5065\u5EB7\u68C0\u67E5\u4E0E\u6027\u80FD\u8BCA\u65AD" : "Health check and diagnostics"
|
|
1204
|
-
},
|
|
1205
|
-
{
|
|
1206
|
-
cmd: "ccjk mcp profile [name]",
|
|
1207
|
-
desc: isZh ? "\u5207\u6362\u914D\u7F6E\u9884\u8BBE (minimal/dev/full)" : "Switch profile (minimal/dev/full)"
|
|
1208
|
-
},
|
|
1209
|
-
{
|
|
1210
|
-
cmd: "ccjk mcp release",
|
|
1211
|
-
desc: isZh ? "\u91CA\u653E\u95F2\u7F6E\u670D\u52A1" : "Release idle services"
|
|
1212
|
-
},
|
|
1213
|
-
{
|
|
1214
|
-
cmd: "ccjk mcp market",
|
|
1215
|
-
desc: isZh ? "MCP \u670D\u52A1\u5E02\u573A" : "MCP service marketplace"
|
|
1216
|
-
},
|
|
1217
|
-
{
|
|
1218
|
-
cmd: "ccjk mcp list",
|
|
1219
|
-
desc: isZh ? "\u5217\u51FA\u5DF2\u5B89\u88C5\u670D\u52A1" : "List installed services"
|
|
1220
|
-
}
|
|
1221
|
-
];
|
|
1222
|
-
for (const { cmd, desc } of commands) {
|
|
1223
|
-
console.log(` ${a.green(cmd)}`);
|
|
1224
|
-
console.log(` ${a.dim(desc)}`);
|
|
1225
|
-
console.log("");
|
|
1226
|
-
}
|
|
1227
|
-
console.log(a.dim("\u2500".repeat(50)));
|
|
1228
|
-
console.log(a.dim(isZh ? "\u{1F4A1} \u63A8\u8350: \u4F7F\u7528 minimal \u9884\u8BBE\u53EF\u663E\u8457\u63D0\u5347\u6027\u80FD" : "\u{1F4A1} Tip: Use minimal profile for best performance"));
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
export { listProfiles, mcpDoctor, mcpHelp, mcpInstall, mcpList, mcpRelease, mcpSearch, mcpStatus, mcpUninstall, useProfile };
|