ccjk 2.2.4 → 2.2.5

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.
Files changed (65) hide show
  1. package/dist/chunks/auto-updater.mjs +15 -1
  2. package/dist/chunks/ccjk-config.mjs +77 -13
  3. package/dist/chunks/ccr.mjs +7 -10
  4. package/dist/chunks/ccu.mjs +4 -4
  5. package/dist/chunks/check-updates.mjs +4 -7
  6. package/dist/chunks/claude-code-config-manager.mjs +8 -11
  7. package/dist/chunks/claude-code-incremental-manager.mjs +4 -7
  8. package/dist/chunks/codex.mjs +496 -17
  9. package/dist/chunks/commands.mjs +392 -89
  10. package/dist/chunks/commands2.mjs +109 -0
  11. package/dist/chunks/config-consolidator.mjs +2 -2
  12. package/dist/chunks/config-switch.mjs +5 -8
  13. package/dist/chunks/doctor.mjs +6 -6
  14. package/dist/chunks/features.mjs +654 -35
  15. package/dist/chunks/help.mjs +339 -0
  16. package/dist/chunks/index.mjs +323 -10
  17. package/dist/chunks/index2.mjs +3 -3
  18. package/dist/chunks/index3.mjs +1171 -0
  19. package/dist/chunks/init.mjs +21 -24
  20. package/dist/chunks/installer.mjs +178 -0
  21. package/dist/chunks/interview.mjs +6 -6
  22. package/dist/chunks/mcp-performance.mjs +82 -2
  23. package/dist/chunks/mcp.mjs +500 -0
  24. package/dist/chunks/menu.mjs +10 -10
  25. package/dist/chunks/notification.mjs +5 -5
  26. package/dist/chunks/onboarding.mjs +6 -6
  27. package/dist/chunks/package.mjs +1 -1
  28. package/dist/chunks/platform.mjs +10 -10
  29. package/dist/chunks/prompts.mjs +7 -8
  30. package/dist/chunks/session.mjs +2 -2
  31. package/dist/chunks/skills-sync.mjs +2 -2
  32. package/dist/chunks/uninstall.mjs +4 -5
  33. package/dist/chunks/update.mjs +4 -7
  34. package/dist/chunks/upgrade-manager.mjs +2 -2
  35. package/dist/chunks/version-checker.mjs +88 -7
  36. package/dist/cli.mjs +293 -53
  37. package/dist/i18n/locales/en/agentBrowser.json +79 -0
  38. package/dist/i18n/locales/en/mcp.json +2 -4
  39. package/dist/i18n/locales/en/updater.json +3 -1
  40. package/dist/i18n/locales/zh/agentBrowser.json +79 -0
  41. package/dist/i18n/locales/zh-CN/common.json +1 -1
  42. package/dist/i18n/locales/zh-CN/mcp.json +2 -4
  43. package/dist/i18n/locales/zh-CN/updater.json +3 -1
  44. package/dist/index.d.mts +8 -584
  45. package/dist/index.d.ts +8 -584
  46. package/dist/index.mjs +9 -13
  47. package/dist/shared/{ccjk.DJM5aVQJ.mjs → ccjk.ByTIGCUC.mjs} +3 -3
  48. package/dist/shared/{ccjk.qYAnUMuy.mjs → ccjk.CGTmRqsu.mjs} +2 -3
  49. package/dist/shared/{ccjk.CUdzQluX.mjs → ccjk.CURU8gbR.mjs} +1 -1
  50. package/dist/{chunks/mcp-market.mjs → shared/ccjk.D-RZS4E2.mjs} +6 -65
  51. package/dist/shared/{ccjk.B7169qud.mjs → ccjk.tB4-Y4Qb.mjs} +3 -3
  52. package/package.json +4 -1
  53. package/templates/common/skills/en/agent-browser.md +258 -0
  54. package/templates/common/skills/zh-CN/agent-browser.md +260 -0
  55. package/dist/chunks/claude-config.mjs +0 -228
  56. package/dist/chunks/features2.mjs +0 -661
  57. package/dist/chunks/json-config.mjs +0 -59
  58. package/dist/chunks/mcp-doctor.mjs +0 -160
  59. package/dist/chunks/mcp-profile.mjs +0 -220
  60. package/dist/chunks/mcp-release.mjs +0 -138
  61. package/dist/chunks/shencha.mjs +0 -320
  62. package/dist/chunks/tools.mjs +0 -169
  63. package/dist/shared/ccjk.COdsoe-Y.mjs +0 -64
  64. package/dist/shared/ccjk.DwDtZ5cK.mjs +0 -266
  65. package/dist/shared/ccjk.n_AtlHzB.mjs +0 -186
@@ -1,59 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import { join } from 'pathe';
3
- import { exists, readFile, writeFileAtomic, writeFile, ensureDir, copyFile } from './fs-operations.mjs';
4
- import 'node:crypto';
5
- import 'node:fs';
6
- import 'node:fs/promises';
7
-
8
- function readJsonConfig(path, options = {}) {
9
- const { defaultValue = null, validate, sanitize } = options;
10
- if (!exists(path)) {
11
- return defaultValue;
12
- }
13
- try {
14
- const content = readFile(path);
15
- const data = JSON.parse(content);
16
- if (validate && !validate(data)) {
17
- console.log(`Invalid configuration: ${path}`);
18
- return defaultValue;
19
- }
20
- if (sanitize) {
21
- return sanitize(data);
22
- }
23
- return data;
24
- } catch (error) {
25
- console.error(`Failed to parse JSON: ${path}`, error);
26
- return defaultValue;
27
- }
28
- }
29
- function writeJsonConfig(path, data, options = {}) {
30
- const { pretty = true, backup = false, backupDir, atomic = true } = options;
31
- if (backup && exists(path)) {
32
- backupJsonConfig(path, backupDir);
33
- }
34
- const content = pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data);
35
- if (atomic) {
36
- writeFileAtomic(path, content);
37
- } else {
38
- writeFile(path, content);
39
- }
40
- }
41
- function backupJsonConfig(path, backupDir) {
42
- if (!exists(path)) {
43
- return null;
44
- }
45
- const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
46
- const fileName = path.split("/").pop() || "config.json";
47
- const baseDir = backupDir || join(path, "..", "backup");
48
- const backupPath = join(baseDir, `${fileName}.backup_${timestamp}`);
49
- try {
50
- ensureDir(baseDir);
51
- copyFile(path, backupPath);
52
- return backupPath;
53
- } catch (error) {
54
- console.error("Failed to backup config", error);
55
- return null;
56
- }
57
- }
58
-
59
- export { backupJsonConfig, readJsonConfig, writeJsonConfig };
@@ -1,160 +0,0 @@
1
- import ansis from 'ansis';
2
- import { g as getServicesByTier, M as MCP_SERVICE_TIERS, a as getMcpTierConfig } from '../shared/ccjk.COdsoe-Y.mjs';
3
- import { i18n } from './index2.mjs';
4
- import { r as readMcpConfig } from './claude-config.mjs';
5
- import { checkMcpPerformance, formatPerformanceWarning, calculateResourceUsage, getOptimizationSuggestions } from './mcp-performance.mjs';
6
- import 'node:fs';
7
- import 'node:process';
8
- import 'node:url';
9
- import 'i18next';
10
- import 'i18next-fs-backend';
11
- import 'pathe';
12
- import './constants.mjs';
13
- import 'node:os';
14
- import './json-config.mjs';
15
- import 'dayjs';
16
- import './fs-operations.mjs';
17
- import 'node:crypto';
18
- import 'node:fs/promises';
19
- import './platform.mjs';
20
- import 'tinyexec';
21
-
22
- function checkServiceHealth(serviceId, configuredServices) {
23
- const tierConfig = getMcpTierConfig(serviceId);
24
- const tier = MCP_SERVICE_TIERS[serviceId] || "ondemand";
25
- const isConfigured = configuredServices.includes(serviceId);
26
- const issues = [];
27
- const suggestions = [];
28
- let status = "healthy";
29
- if (isConfigured && !MCP_SERVICE_TIERS[serviceId]) {
30
- issues.push("Service not in tier system (using default: ondemand)");
31
- status = "warning";
32
- }
33
- if (serviceId === "Playwright" && configuredServices.includes("puppeteer")) {
34
- issues.push("Both Playwright and Puppeteer are enabled");
35
- suggestions.push("Consider using only one browser automation service");
36
- status = "warning";
37
- }
38
- if (serviceId === "puppeteer" && configuredServices.includes("Playwright")) {
39
- issues.push("Both Puppeteer and Playwright are enabled");
40
- suggestions.push("Consider using only one browser automation service");
41
- status = "warning";
42
- }
43
- if (tier === "scenario" && isConfigured) {
44
- suggestions.push("Scenario service - consider disabling when not needed");
45
- }
46
- return {
47
- serviceId,
48
- status,
49
- tier,
50
- autoStart: tierConfig.autoStart,
51
- idleTimeout: tierConfig.idleTimeout,
52
- issues,
53
- suggestions
54
- };
55
- }
56
- async function mcpDoctor(options = {}) {
57
- const lang = options.lang || i18n.language || "en";
58
- const isZh = lang === "zh-CN";
59
- console.log("");
60
- console.log(ansis.bold.cyan(isZh ? "\u{1F50D} MCP \u5065\u5EB7\u68C0\u67E5" : "\u{1F50D} MCP Health Check"));
61
- console.log(ansis.dim("\u2550".repeat(60)));
62
- console.log("");
63
- const config = readMcpConfig();
64
- const configuredServices = config?.mcpServers ? Object.keys(config.mcpServers) : [];
65
- console.log(ansis.bold(isZh ? "\u{1F4CA} \u670D\u52A1\u7EDF\u8BA1" : "\u{1F4CA} Service Statistics"));
66
- console.log(ansis.dim("\u2500".repeat(40)));
67
- const coreServices = getServicesByTier("core");
68
- const ondemandServices = getServicesByTier("ondemand");
69
- const scenarioServices = getServicesByTier("scenario");
70
- const configuredCore = configuredServices.filter((s) => coreServices.includes(s));
71
- const configuredOndemand = configuredServices.filter((s) => ondemandServices.includes(s));
72
- const configuredScenario = configuredServices.filter((s) => scenarioServices.includes(s));
73
- console.log(` ${isZh ? "\u603B\u8BA1" : "Total"}: ${ansis.bold(configuredServices.length.toString())} ${isZh ? "\u4E2A\u670D\u52A1" : "services"}`);
74
- console.log(` ${ansis.green("Core")}: ${configuredCore.length}/${coreServices.length}`);
75
- console.log(` ${ansis.yellow("OnDemand")}: ${configuredOndemand.length}/${ondemandServices.length}`);
76
- console.log(` ${ansis.blue("Scenario")}: ${configuredScenario.length}/${scenarioServices.length}`);
77
- console.log("");
78
- const perfWarning = checkMcpPerformance(configuredServices.length);
79
- if (perfWarning) {
80
- console.log(ansis.bold(isZh ? "\u26A0\uFE0F \u6027\u80FD\u8B66\u544A" : "\u26A0\uFE0F Performance Warning"));
81
- console.log(ansis.dim("\u2500".repeat(40)));
82
- console.log(formatPerformanceWarning(perfWarning, lang));
83
- console.log("");
84
- }
85
- const resourceUsage = calculateResourceUsage(configuredServices.length);
86
- console.log(ansis.bold(isZh ? "\u{1F4BB} \u8D44\u6E90\u4F7F\u7528\u4F30\u7B97" : "\u{1F4BB} Resource Usage Estimate"));
87
- console.log(ansis.dim("\u2500".repeat(40)));
88
- const ratingColors = {
89
- low: ansis.green,
90
- medium: ansis.yellow,
91
- high: ansis.red,
92
- critical: ansis.bgRed.white
93
- };
94
- const ratingLabels = {
95
- low: isZh ? "\u4F4E" : "Low",
96
- medium: isZh ? "\u4E2D" : "Medium",
97
- high: isZh ? "\u9AD8" : "High",
98
- critical: isZh ? "\u4E25\u91CD" : "Critical"
99
- };
100
- console.log(` ${isZh ? "\u5185\u5B58" : "Memory"}: ~${resourceUsage.memory.value}${resourceUsage.memory.unit}`);
101
- console.log(` ${isZh ? "CPU" : "CPU"}: ~${resourceUsage.cpu.value}${resourceUsage.cpu.unit}`);
102
- console.log(` ${isZh ? "\u8BC4\u7EA7" : "Rating"}: ${ratingColors[resourceUsage.rating](ratingLabels[resourceUsage.rating])}`);
103
- console.log("");
104
- if (options.verbose || options.service) {
105
- console.log(ansis.bold(isZh ? "\u{1F527} \u670D\u52A1\u8BE6\u60C5" : "\u{1F527} Service Details"));
106
- console.log(ansis.dim("\u2500".repeat(40)));
107
- const servicesToCheck = options.service ? [options.service] : configuredServices;
108
- for (const serviceId of servicesToCheck) {
109
- const health = checkServiceHealth(serviceId, configuredServices);
110
- const statusIcon = {
111
- healthy: ansis.green("\u2714"),
112
- warning: ansis.yellow("\u26A0"),
113
- error: ansis.red("\u2716"),
114
- unknown: ansis.gray("?")
115
- };
116
- const tierColor = {
117
- core: ansis.green,
118
- ondemand: ansis.yellow,
119
- scenario: ansis.blue
120
- };
121
- console.log(` ${statusIcon[health.status]} ${ansis.bold(serviceId)}`);
122
- console.log(` ${isZh ? "\u5C42\u7EA7" : "Tier"}: ${(tierColor[health.tier] || ansis.gray)(health.tier)}`);
123
- if (health.idleTimeout) {
124
- console.log(` ${isZh ? "\u7A7A\u95F2\u8D85\u65F6" : "Idle Timeout"}: ${health.idleTimeout}s`);
125
- }
126
- if (health.issues.length > 0) {
127
- for (const issue of health.issues) {
128
- console.log(` ${ansis.yellow("!")} ${issue}`);
129
- }
130
- }
131
- if (health.suggestions.length > 0) {
132
- for (const suggestion of health.suggestions) {
133
- console.log(` ${ansis.dim("\u2192")} ${suggestion}`);
134
- }
135
- }
136
- console.log("");
137
- }
138
- }
139
- const suggestions = getOptimizationSuggestions(configuredServices);
140
- if (suggestions.length > 0) {
141
- console.log(ansis.bold(isZh ? "\u{1F4A1} \u4F18\u5316\u5EFA\u8BAE" : "\u{1F4A1} Optimization Suggestions"));
142
- console.log(ansis.dim("\u2500".repeat(40)));
143
- for (const suggestion of suggestions) {
144
- console.log(` \u2022 ${suggestion}`);
145
- }
146
- console.log("");
147
- }
148
- console.log(ansis.bold(isZh ? "\u{1F680} \u5FEB\u901F\u64CD\u4F5C" : "\u{1F680} Quick Actions"));
149
- console.log(ansis.dim("\u2500".repeat(40)));
150
- console.log(` ${ansis.cyan("ccjk mcp profile use minimal")} - ${isZh ? "\u5207\u6362\u5230\u6781\u7B80\u6A21\u5F0F" : "Switch to minimal mode"}`);
151
- console.log(` ${ansis.cyan("ccjk mcp profile list")} - ${isZh ? "\u67E5\u770B\u6240\u6709\u9884\u8BBE" : "View all profiles"}`);
152
- console.log(` ${ansis.cyan("ccjk mcp release")} - ${isZh ? "\u91CA\u653E\u7A7A\u95F2\u670D\u52A1" : "Release idle services"}`);
153
- console.log("");
154
- console.log(ansis.dim("\u2550".repeat(60)));
155
- const summaryStatus = perfWarning?.level === "critical" ? ansis.red(isZh ? "\u9700\u8981\u4F18\u5316" : "Needs Optimization") : perfWarning?.level === "warning" ? ansis.yellow(isZh ? "\u5EFA\u8BAE\u4F18\u5316" : "Optimization Recommended") : ansis.green(isZh ? "\u72B6\u6001\u826F\u597D" : "Healthy");
156
- console.log(`${isZh ? "\u603B\u4F53\u72B6\u6001" : "Overall Status"}: ${summaryStatus}`);
157
- console.log("");
158
- }
159
-
160
- export { mcpDoctor };
@@ -1,220 +0,0 @@
1
- import ansis from 'ansis';
2
- import { M as MCP_SERVICE_CONFIGS } from '../shared/ccjk.DwDtZ5cK.mjs';
3
- import { i18n } from './index2.mjs';
4
- import { b as backupMcpConfig, r as readMcpConfig, w as writeMcpConfig } from './claude-config.mjs';
5
- import { checkMcpPerformance, formatPerformanceWarning } from './mcp-performance.mjs';
6
- import 'node:child_process';
7
- import 'node:os';
8
- import 'node:process';
9
- import 'pathe';
10
- import 'node:fs';
11
- import 'node:url';
12
- import 'i18next';
13
- import 'i18next-fs-backend';
14
- import './constants.mjs';
15
- import './json-config.mjs';
16
- import 'dayjs';
17
- import './fs-operations.mjs';
18
- import 'node:crypto';
19
- import 'node:fs/promises';
20
- import './platform.mjs';
21
- import 'tinyexec';
22
- import '../shared/ccjk.COdsoe-Y.mjs';
23
-
24
- const MCP_PROFILES = [
25
- {
26
- id: "minimal",
27
- name: "Minimal",
28
- nameZh: "\u6781\u7B80\u6A21\u5F0F",
29
- description: "Core services only, best performance",
30
- descriptionZh: "\u4EC5\u6838\u5FC3\u670D\u52A1\uFF0C\u6700\u4F73\u6027\u80FD",
31
- services: ["context7", "open-websearch"],
32
- maxServices: 3,
33
- tier: "core"
34
- },
35
- {
36
- id: "development",
37
- name: "Development",
38
- nameZh: "\u5F00\u53D1\u6A21\u5F0F",
39
- description: "Suitable for daily development",
40
- descriptionZh: "\u9002\u5408\u65E5\u5E38\u5F00\u53D1",
41
- services: ["context7", "open-websearch", "mcp-deepwiki", "filesystem"],
42
- maxServices: 5,
43
- tier: "ondemand",
44
- isDefault: true
45
- },
46
- {
47
- id: "testing",
48
- name: "Testing",
49
- nameZh: "\u6D4B\u8BD5\u6A21\u5F0F",
50
- description: "Includes browser automation",
51
- descriptionZh: "\u5305\u542B\u6D4F\u89C8\u5668\u81EA\u52A8\u5316",
52
- services: ["context7", "open-websearch", "Playwright"],
53
- maxServices: 4,
54
- tier: "ondemand"
55
- },
56
- {
57
- id: "research",
58
- name: "Research",
59
- nameZh: "\u7814\u7A76\u6A21\u5F0F",
60
- description: "Enhanced documentation and search",
61
- descriptionZh: "\u589E\u5F3A\u6587\u6863\u548C\u641C\u7D22\u529F\u80FD",
62
- services: ["context7", "open-websearch", "mcp-deepwiki", "memory", "sequential-thinking"],
63
- maxServices: 6,
64
- tier: "ondemand"
65
- },
66
- {
67
- id: "full",
68
- name: "Full",
69
- nameZh: "\u5168\u529F\u80FD\u6A21\u5F0F",
70
- description: "All services (high resource usage)",
71
- descriptionZh: "\u6240\u6709\u670D\u52A1\uFF08\u9AD8\u8D44\u6E90\u6D88\u8017\uFF09",
72
- services: [],
73
- // Empty means all services
74
- maxServices: void 0,
75
- tier: "scenario"
76
- }
77
- ];
78
- function getProfileById(id) {
79
- return MCP_PROFILES.find((p) => p.id === id);
80
- }
81
- function getProfileIds() {
82
- return MCP_PROFILES.map((p) => p.id);
83
- }
84
- function getProfileName(profile, lang = "en") {
85
- return lang === "zh-CN" ? profile.nameZh : profile.name;
86
- }
87
- function getProfileDescription(profile, lang = "en") {
88
- return lang === "zh-CN" ? profile.descriptionZh : profile.description;
89
- }
90
-
91
- async function listProfiles(options = {}) {
92
- const lang = options.lang || i18n.language || "en";
93
- const isZh = lang === "zh-CN";
94
- console.log("");
95
- console.log(ansis.bold.cyan(isZh ? "\u{1F4CB} \u53EF\u7528\u7684 MCP \u914D\u7F6E\u9884\u8BBE" : "\u{1F4CB} Available MCP Profiles"));
96
- console.log(ansis.dim("\u2500".repeat(50)));
97
- console.log("");
98
- for (const profile of MCP_PROFILES) {
99
- const name = getProfileName(profile, lang);
100
- const desc = getProfileDescription(profile, lang);
101
- const serviceCount = profile.services.length === 0 ? isZh ? "\u5168\u90E8" : "All" : profile.services.length.toString();
102
- const defaultBadge = profile.isDefault ? ansis.green(isZh ? " [\u9ED8\u8BA4]" : " [default]") : "";
103
- console.log(`${ansis.bold.green(profile.id)}${defaultBadge}`);
104
- console.log(` ${ansis.white(name)} - ${ansis.dim(desc)}`);
105
- console.log(` ${ansis.dim(isZh ? "\u670D\u52A1\u6570\u91CF" : "Services")}: ${serviceCount}`);
106
- if (profile.services.length > 0 && profile.services.length <= 6) {
107
- console.log(` ${ansis.dim(profile.services.join(", "))}`);
108
- }
109
- console.log("");
110
- }
111
- console.log(ansis.dim("\u2500".repeat(50)));
112
- console.log(ansis.dim(isZh ? "\u4F7F\u7528 `ccjk mcp profile use <id>` \u5207\u6362\u914D\u7F6E" : "Use `ccjk mcp profile use <id>` to switch profile"));
113
- console.log("");
114
- }
115
- async function showCurrentProfile(options = {}) {
116
- const lang = options.lang || i18n.language || "en";
117
- const isZh = lang === "zh-CN";
118
- const config = readMcpConfig();
119
- const currentServices = config?.mcpServers ? Object.keys(config.mcpServers) : [];
120
- console.log("");
121
- console.log(ansis.bold.cyan(isZh ? "\u{1F4CA} \u5F53\u524D MCP \u914D\u7F6E\u72B6\u6001" : "\u{1F4CA} Current MCP Configuration"));
122
- console.log(ansis.dim("\u2500".repeat(50)));
123
- console.log("");
124
- console.log(`${ansis.bold(isZh ? "\u5DF2\u914D\u7F6E\u670D\u52A1" : "Configured Services")}: ${currentServices.length}`);
125
- if (currentServices.length > 0) {
126
- console.log(ansis.dim(` ${currentServices.join(", ")}`));
127
- }
128
- const warning = checkMcpPerformance(currentServices.length);
129
- if (warning) {
130
- console.log("");
131
- console.log(formatPerformanceWarning(warning, lang));
132
- }
133
- const matchedProfile = MCP_PROFILES.find((profile) => {
134
- if (profile.services.length === 0)
135
- return false;
136
- if (profile.services.length !== currentServices.length)
137
- return false;
138
- return profile.services.every((s) => currentServices.includes(s));
139
- });
140
- if (matchedProfile) {
141
- console.log("");
142
- console.log(`${ansis.bold(isZh ? "\u5339\u914D\u9884\u8BBE" : "Matched Profile")}: ${ansis.green(matchedProfile.id)}`);
143
- } else {
144
- console.log("");
145
- console.log(ansis.dim(isZh ? "\u5F53\u524D\u914D\u7F6E\u4E0D\u5339\u914D\u4EFB\u4F55\u9884\u8BBE" : "Current config does not match any profile"));
146
- }
147
- console.log("");
148
- }
149
- async function useProfile(profileId, options = {}) {
150
- const lang = options.lang || i18n.language || "en";
151
- const isZh = lang === "zh-CN";
152
- const profile = getProfileById(profileId);
153
- if (!profile) {
154
- console.log(ansis.red(isZh ? `\u274C \u672A\u627E\u5230\u914D\u7F6E\u9884\u8BBE: ${profileId}` : `\u274C Profile not found: ${profileId}`));
155
- console.log(ansis.dim(isZh ? `\u53EF\u7528\u9884\u8BBE: ${getProfileIds().join(", ")}` : `Available profiles: ${getProfileIds().join(", ")}`));
156
- return;
157
- }
158
- const backupPath = backupMcpConfig();
159
- if (backupPath) {
160
- console.log(ansis.gray(`\u2714 ${isZh ? "\u5DF2\u5907\u4EFD\u5F53\u524D\u914D\u7F6E" : "Backed up current config"}: ${backupPath}`));
161
- }
162
- let servicesToEnable;
163
- if (profile.services.length === 0) {
164
- servicesToEnable = MCP_SERVICE_CONFIGS.filter((s) => !s.requiresApiKey).map((s) => s.id);
165
- } else {
166
- servicesToEnable = profile.services;
167
- }
168
- const newServers = {};
169
- for (const serviceId of servicesToEnable) {
170
- const serviceConfig = MCP_SERVICE_CONFIGS.find((s) => s.id === serviceId);
171
- if (serviceConfig) {
172
- newServers[serviceId] = serviceConfig.config;
173
- }
174
- }
175
- const existingConfig = readMcpConfig() || {};
176
- const newConfig = {
177
- ...existingConfig,
178
- mcpServers: newServers
179
- };
180
- writeMcpConfig(newConfig);
181
- const profileName = getProfileName(profile, lang);
182
- console.log(ansis.green(`\u2714 ${isZh ? "\u5DF2\u5207\u6362\u5230\u914D\u7F6E\u9884\u8BBE" : "Switched to profile"}: ${profileName}`));
183
- console.log(ansis.dim(` ${isZh ? "\u5DF2\u542F\u7528\u670D\u52A1" : "Enabled services"}: ${servicesToEnable.length}`));
184
- const warning = checkMcpPerformance(servicesToEnable.length);
185
- if (warning) {
186
- console.log("");
187
- console.log(formatPerformanceWarning(warning, lang));
188
- }
189
- console.log("");
190
- console.log(ansis.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"));
191
- }
192
- async function mcpProfile(action, args, options = {}) {
193
- switch (action) {
194
- case "list":
195
- case "ls":
196
- await listProfiles(options);
197
- break;
198
- case "current":
199
- case "status":
200
- await showCurrentProfile(options);
201
- break;
202
- case "use":
203
- case "switch":
204
- if (!args[0]) {
205
- const isZh = (options.lang || i18n.language) === "zh-CN";
206
- console.log(ansis.red(isZh ? "\u8BF7\u6307\u5B9A\u914D\u7F6E\u9884\u8BBE ID" : "Please specify a profile ID"));
207
- console.log(ansis.dim(isZh ? `\u53EF\u7528\u9884\u8BBE: ${getProfileIds().join(", ")}` : `Available profiles: ${getProfileIds().join(", ")}`));
208
- return;
209
- }
210
- await useProfile(args[0], options);
211
- break;
212
- default: {
213
- const isZh = (options.lang || i18n.language) === "zh-CN";
214
- console.log(ansis.yellow(isZh ? `\u672A\u77E5\u64CD\u4F5C: ${action}` : `Unknown action: ${action}`));
215
- console.log(ansis.dim(isZh ? "\u53EF\u7528\u64CD\u4F5C: list, current, use <profile-id>" : "Available actions: list, current, use <profile-id>"));
216
- }
217
- }
218
- }
219
-
220
- export { listProfiles, mcpProfile, showCurrentProfile, useProfile };
@@ -1,138 +0,0 @@
1
- import 'node:child_process';
2
- import 'node:process';
3
- import ansis from 'ansis';
4
- import { M as MCP_SERVICE_TIERS, i as isCoreService } from '../shared/ccjk.COdsoe-Y.mjs';
5
- import { i18n } from './index2.mjs';
6
- import { r as readMcpConfig, b as backupMcpConfig, w as writeMcpConfig } from './claude-config.mjs';
7
- import 'node:fs';
8
- import 'node:url';
9
- import 'i18next';
10
- import 'i18next-fs-backend';
11
- import 'pathe';
12
- import './constants.mjs';
13
- import 'node:os';
14
- import './json-config.mjs';
15
- import 'dayjs';
16
- import './fs-operations.mjs';
17
- import 'node:crypto';
18
- import 'node:fs/promises';
19
- import './platform.mjs';
20
- import 'tinyexec';
21
-
22
- function getReleasableServices(configuredServices, tier) {
23
- return configuredServices.filter((serviceId) => {
24
- if (isCoreService(serviceId)) {
25
- return false;
26
- }
27
- const serviceTier = MCP_SERVICE_TIERS[serviceId] || "ondemand";
28
- if (tier === "all") {
29
- return true;
30
- }
31
- if (tier) {
32
- return serviceTier === tier;
33
- }
34
- return serviceTier === "ondemand" || serviceTier === "scenario";
35
- });
36
- }
37
- async function releaseServices(servicesToRelease, options = {}) {
38
- const result = {
39
- success: true,
40
- releasedServices: [],
41
- skippedServices: [],
42
- errors: []
43
- };
44
- if (servicesToRelease.length === 0) {
45
- return result;
46
- }
47
- const config = readMcpConfig();
48
- if (!config?.mcpServers) {
49
- result.errors.push("No MCP configuration found");
50
- result.success = false;
51
- return result;
52
- }
53
- if (!options.dryRun) {
54
- backupMcpConfig();
55
- }
56
- const newServers = { ...config.mcpServers };
57
- for (const serviceId of servicesToRelease) {
58
- if (isCoreService(serviceId) && !options.force) {
59
- result.skippedServices.push(serviceId);
60
- continue;
61
- }
62
- if (!newServers[serviceId]) {
63
- result.skippedServices.push(serviceId);
64
- continue;
65
- }
66
- if (!options.dryRun) {
67
- delete newServers[serviceId];
68
- }
69
- result.releasedServices.push(serviceId);
70
- }
71
- if (!options.dryRun && result.releasedServices.length > 0) {
72
- try {
73
- writeMcpConfig({ ...config, mcpServers: newServers });
74
- } catch (error) {
75
- result.errors.push(`Failed to write config: ${error}`);
76
- result.success = false;
77
- }
78
- }
79
- return result;
80
- }
81
- async function mcpRelease(options = {}) {
82
- const lang = options.lang || i18n.language || "en";
83
- const isZh = lang === "zh-CN";
84
- console.log("");
85
- console.log(ansis.bold.cyan(isZh ? "\u{1F9F9} MCP \u670D\u52A1\u91CA\u653E" : "\u{1F9F9} MCP Service Release"));
86
- console.log(ansis.dim("\u2500".repeat(50)));
87
- console.log("");
88
- const config = readMcpConfig();
89
- const configuredServices = config?.mcpServers ? Object.keys(config.mcpServers) : [];
90
- if (configuredServices.length === 0) {
91
- console.log(ansis.yellow(isZh ? "\u6CA1\u6709\u914D\u7F6E\u4EFB\u4F55 MCP \u670D\u52A1" : "No MCP services configured"));
92
- return;
93
- }
94
- let servicesToRelease;
95
- if (options.service) {
96
- servicesToRelease = [options.service];
97
- } else if (options.tier) {
98
- servicesToRelease = getReleasableServices(configuredServices, options.tier);
99
- } else {
100
- servicesToRelease = getReleasableServices(configuredServices, "all");
101
- }
102
- if (servicesToRelease.length === 0) {
103
- console.log(ansis.green(isZh ? "\u2714 \u6CA1\u6709\u53EF\u91CA\u653E\u7684\u670D\u52A1" : "\u2714 No services to release"));
104
- return;
105
- }
106
- console.log(isZh ? "\u5C06\u91CA\u653E\u4EE5\u4E0B\u670D\u52A1:" : "Services to release:");
107
- for (const serviceId of servicesToRelease) {
108
- const tier = MCP_SERVICE_TIERS[serviceId] || "ondemand";
109
- console.log(` ${ansis.yellow("\u2022")} ${serviceId} ${ansis.dim(`[${tier}]`)}`);
110
- }
111
- console.log("");
112
- if (options.dryRun) {
113
- console.log(ansis.blue(isZh ? "(\u6A21\u62DF\u8FD0\u884C - \u4E0D\u4F1A\u5B9E\u9645\u4FEE\u6539\u914D\u7F6E)" : "(Dry run - no changes will be made)"));
114
- return;
115
- }
116
- const result = await releaseServices(servicesToRelease, options);
117
- if (result.success) {
118
- console.log(ansis.green(`\u2714 ${isZh ? "\u5DF2\u91CA\u653E" : "Released"} ${result.releasedServices.length} ${isZh ? "\u4E2A\u670D\u52A1" : "services"}`));
119
- if (result.skippedServices.length > 0) {
120
- console.log(ansis.yellow(`${isZh ? "\u8DF3\u8FC7" : "Skipped"}: ${result.skippedServices.join(", ")}`));
121
- }
122
- const remaining = configuredServices.filter((s) => !result.releasedServices.includes(s));
123
- console.log("");
124
- console.log(ansis.dim(`${isZh ? "\u5269\u4F59\u670D\u52A1" : "Remaining services"}: ${remaining.length}`));
125
- if (remaining.length > 0) {
126
- console.log(ansis.dim(` ${remaining.join(", ")}`));
127
- }
128
- console.log("");
129
- console.log(ansis.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"));
130
- } else {
131
- console.log(ansis.red(`\u2716 ${isZh ? "\u91CA\u653E\u5931\u8D25" : "Release failed"}`));
132
- for (const error of result.errors) {
133
- console.log(ansis.red(` ${error}`));
134
- }
135
- }
136
- }
137
-
138
- export { getReleasableServices, mcpRelease, releaseServices };