ccjk 2.4.3 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/api-providers.mjs +73 -1
- package/dist/chunks/ccjk-config.mjs +13 -77
- package/dist/chunks/ccr.mjs +9 -4
- package/dist/chunks/check-updates.mjs +4 -2
- package/dist/chunks/claude-code-config-manager.mjs +9 -15
- package/dist/chunks/claude-code-incremental-manager.mjs +5 -8
- package/dist/chunks/codex.mjs +10 -569
- package/dist/chunks/config-switch.mjs +7 -5
- package/dist/chunks/config.mjs +573 -0
- package/dist/chunks/config2.mjs +451 -0
- package/dist/chunks/doctor.mjs +89 -1
- package/dist/chunks/features.mjs +13 -10
- package/dist/chunks/index.mjs +10 -1164
- package/dist/chunks/index2.mjs +8 -2
- package/dist/chunks/init.mjs +14 -11
- package/dist/chunks/json-config.mjs +59 -0
- package/dist/chunks/mcp-server.mjs +776 -0
- package/dist/chunks/mcp.mjs +10 -8
- package/dist/chunks/menu.mjs +5 -5
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/permissions.mjs +420 -0
- package/dist/chunks/prompts.mjs +2 -1
- package/dist/chunks/providers.mjs +261 -0
- package/dist/chunks/session.mjs +484 -41
- package/dist/chunks/skills.mjs +553 -0
- package/dist/chunks/stats.mjs +411 -0
- package/dist/chunks/uninstall.mjs +4 -3
- package/dist/chunks/update.mjs +6 -3
- package/dist/chunks/workflows2.mjs +140 -0
- package/dist/cli.mjs +316 -10
- package/dist/i18n/locales/en/hooks.json +47 -0
- package/dist/i18n/locales/en/mcp.json +55 -0
- package/dist/i18n/locales/en/permissions.json +43 -0
- package/dist/i18n/locales/en/sandbox.json +44 -0
- package/dist/i18n/locales/en/skills.json +89 -129
- package/dist/i18n/locales/en/stats.json +20 -0
- package/dist/i18n/locales/zh-CN/hooks.json +47 -0
- package/dist/i18n/locales/zh-CN/mcp.json +55 -0
- package/dist/i18n/locales/zh-CN/permissions.json +43 -0
- package/dist/i18n/locales/zh-CN/sandbox.json +44 -0
- package/dist/i18n/locales/zh-CN/skills.json +88 -128
- package/dist/i18n/locales/zh-CN/stats.json +20 -0
- package/dist/index.mjs +12 -8
- package/dist/shared/ccjk.B-lZxV2u.mjs +1162 -0
- package/dist/shared/{ccjk.CURU8gbR.mjs → ccjk.CUdzQluX.mjs} +1 -1
- package/dist/shared/{ccjk.ByTIGCUC.mjs → ccjk.Dut3wyoP.mjs} +1 -1
- package/dist/shared/ccjk.J8YiPsOw.mjs +259 -0
- package/dist/shared/{ccjk.CGTmRqsu.mjs → ccjk.rLRHmcqD.mjs} +5 -134
- package/dist/shared/{ccjk.QbS8EAOd.mjs → ccjk.uVUeWAt8.mjs} +2 -1
- package/package.json +1 -1
- package/templates/common/skills/code-review.md +343 -0
- package/templates/common/skills/summarize.md +312 -0
- package/templates/common/skills/translate.md +202 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import ansis from 'ansis';
|
|
2
|
+
import { getApiProviderPresets } from './api-providers.mjs';
|
|
3
|
+
import { i18n } from './index2.mjs';
|
|
4
|
+
import { P as ProviderHealthMonitor } from '../shared/ccjk.J8YiPsOw.mjs';
|
|
5
|
+
import './constants.mjs';
|
|
6
|
+
import 'node:os';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import 'node:fs';
|
|
9
|
+
import 'node:process';
|
|
10
|
+
import 'node:url';
|
|
11
|
+
import 'i18next';
|
|
12
|
+
import 'i18next-fs-backend';
|
|
13
|
+
|
|
14
|
+
async function listProviders(options = {}) {
|
|
15
|
+
const isZh = i18n.language === "zh-CN";
|
|
16
|
+
const codeType = options.codeType || "claude-code";
|
|
17
|
+
console.log("");
|
|
18
|
+
console.log(ansis.bold.cyan(isZh ? "\u{1F4CB} \u53EF\u7528\u7684 API \u4F9B\u5E94\u5546" : "\u{1F4CB} Available API Providers"));
|
|
19
|
+
console.log(ansis.dim("\u2500".repeat(60)));
|
|
20
|
+
console.log("");
|
|
21
|
+
try {
|
|
22
|
+
const providers = await getApiProviderPresets(codeType);
|
|
23
|
+
if (providers.length === 0) {
|
|
24
|
+
console.log(ansis.yellow(isZh ? "\u672A\u627E\u5230\u4F9B\u5E94\u5546" : "No providers found"));
|
|
25
|
+
console.log("");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const cloudProviders = providers.filter((p) => p.isCloud);
|
|
29
|
+
const localProviders = providers.filter((p) => !p.isCloud);
|
|
30
|
+
if (cloudProviders.length > 0) {
|
|
31
|
+
console.log(ansis.bold.green(isZh ? "\u2601\uFE0F \u4E91\u7AEF\u4F9B\u5E94\u5546" : "\u2601\uFE0F Cloud Providers"));
|
|
32
|
+
console.log("");
|
|
33
|
+
for (const provider of cloudProviders) {
|
|
34
|
+
displayProvider(provider, codeType, options.verbose || false, isZh);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (localProviders.length > 0) {
|
|
38
|
+
if (cloudProviders.length > 0) {
|
|
39
|
+
console.log("");
|
|
40
|
+
}
|
|
41
|
+
console.log(ansis.bold.blue(isZh ? "\u{1F4BE} \u672C\u5730\u4F9B\u5E94\u5546" : "\u{1F4BE} Local Providers"));
|
|
42
|
+
console.log("");
|
|
43
|
+
for (const provider of localProviders) {
|
|
44
|
+
displayProvider(provider, codeType, options.verbose || false, isZh);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
console.log("");
|
|
48
|
+
console.log(ansis.dim("\u2500".repeat(60)));
|
|
49
|
+
console.log(ansis.dim(isZh ? `\u603B\u8BA1: ${providers.length} \u4E2A\u4F9B\u5E94\u5546 (${cloudProviders.length} \u4E91\u7AEF, ${localProviders.length} \u672C\u5730)` : `Total: ${providers.length} providers (${cloudProviders.length} cloud, ${localProviders.length} local)`));
|
|
50
|
+
console.log("");
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(ansis.red(isZh ? "\u274C \u83B7\u53D6\u4F9B\u5E94\u5546\u5217\u8868\u5931\u8D25" : "\u274C Failed to fetch providers"));
|
|
53
|
+
if (options.verbose && error instanceof Error) {
|
|
54
|
+
console.error(ansis.dim(error.message));
|
|
55
|
+
}
|
|
56
|
+
console.log("");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function displayProvider(provider, codeType, verbose, isZh) {
|
|
60
|
+
const config = codeType === "codex" ? provider.codex : provider.claudeCode;
|
|
61
|
+
console.log(` ${ansis.bold(provider.name)} ${ansis.dim(`(${provider.id})`)}`);
|
|
62
|
+
if (provider.description) {
|
|
63
|
+
console.log(` ${ansis.dim(provider.description)}`);
|
|
64
|
+
}
|
|
65
|
+
if (config) {
|
|
66
|
+
console.log(` ${ansis.cyan(isZh ? "\u63A5\u53E3\u5730\u5740" : "Base URL")}: ${config.baseUrl}`);
|
|
67
|
+
if (codeType === "claude-code" && config.authType) {
|
|
68
|
+
console.log(` ${ansis.cyan(isZh ? "\u8BA4\u8BC1\u65B9\u5F0F" : "Auth Type")}: ${config.authType}`);
|
|
69
|
+
}
|
|
70
|
+
if (codeType === "codex" && config.wireApi) {
|
|
71
|
+
console.log(` ${ansis.cyan(isZh ? "\u534F\u8BAE\u7C7B\u578B" : "Wire API")}: ${config.wireApi}`);
|
|
72
|
+
}
|
|
73
|
+
if (verbose) {
|
|
74
|
+
if (config.defaultModels && config.defaultModels.length > 0) {
|
|
75
|
+
console.log(` ${ansis.cyan(isZh ? "\u9ED8\u8BA4\u6A21\u578B" : "Default Models")}: ${config.defaultModels.join(", ")}`);
|
|
76
|
+
}
|
|
77
|
+
if (config.defaultModel) {
|
|
78
|
+
console.log(` ${ansis.cyan(isZh ? "\u9ED8\u8BA4\u6A21\u578B" : "Default Model")}: ${config.defaultModel}`);
|
|
79
|
+
}
|
|
80
|
+
if (provider.website) {
|
|
81
|
+
console.log(` ${ansis.cyan(isZh ? "\u5B98\u7F51" : "Website")}: ${provider.website}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
console.log("");
|
|
86
|
+
}
|
|
87
|
+
async function checkProvidersHealth(options = {}) {
|
|
88
|
+
const isZh = i18n.language === "zh-CN";
|
|
89
|
+
const codeType = options.codeType || "claude-code";
|
|
90
|
+
console.log("");
|
|
91
|
+
console.log(ansis.bold.cyan(isZh ? "\u{1F3E5} \u4F9B\u5E94\u5546\u5065\u5EB7\u68C0\u67E5" : "\u{1F3E5} Provider Health Check"));
|
|
92
|
+
console.log(ansis.dim("\u2500".repeat(60)));
|
|
93
|
+
console.log("");
|
|
94
|
+
try {
|
|
95
|
+
const providers = await getApiProviderPresets(codeType);
|
|
96
|
+
if (providers.length === 0) {
|
|
97
|
+
console.log(ansis.yellow(isZh ? "\u672A\u627E\u5230\u4F9B\u5E94\u5546" : "No providers found"));
|
|
98
|
+
console.log("");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const monitor = new ProviderHealthMonitor({
|
|
102
|
+
timeout: 5e3,
|
|
103
|
+
degradedLatencyThreshold: 1e3,
|
|
104
|
+
unhealthyLatencyThreshold: 3e3
|
|
105
|
+
});
|
|
106
|
+
monitor.setProviders(providers);
|
|
107
|
+
console.log(ansis.dim(isZh ? "\u6B63\u5728\u68C0\u67E5\u4F9B\u5E94\u5546\u5065\u5EB7\u72B6\u6001..." : "Checking provider health..."));
|
|
108
|
+
console.log("");
|
|
109
|
+
const results = await Promise.all(
|
|
110
|
+
providers.map(async (provider) => {
|
|
111
|
+
const result = await monitor.checkHealth(provider);
|
|
112
|
+
return { provider, result };
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
for (const { provider, result } of results) {
|
|
116
|
+
const statusIcon = result.success ? ansis.green("\u2705") : ansis.red("\u274C");
|
|
117
|
+
const latencyColor = result.latency < 1e3 ? ansis.green : result.latency < 3e3 ? ansis.yellow : ansis.red;
|
|
118
|
+
console.log(`${statusIcon} ${ansis.bold(provider.name)}`);
|
|
119
|
+
if (result.success) {
|
|
120
|
+
console.log(` ${ansis.cyan(isZh ? "\u5EF6\u8FDF" : "Latency")}: ${latencyColor(`${result.latency}ms`)}`);
|
|
121
|
+
console.log(` ${ansis.green(isZh ? "\u72B6\u6001: \u6B63\u5E38" : "Status: Healthy")}`);
|
|
122
|
+
} else {
|
|
123
|
+
console.log(` ${ansis.red(isZh ? "\u72B6\u6001: \u4E0D\u53EF\u7528" : "Status: Unavailable")}`);
|
|
124
|
+
if (result.error) {
|
|
125
|
+
console.log(` ${ansis.dim(isZh ? "\u9519\u8BEF" : "Error")}: ${result.error}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
console.log("");
|
|
129
|
+
}
|
|
130
|
+
const healthyCount = results.filter((r) => r.result.success).length;
|
|
131
|
+
const unhealthyCount = results.length - healthyCount;
|
|
132
|
+
console.log(ansis.dim("\u2500".repeat(60)));
|
|
133
|
+
console.log(ansis.bold(isZh ? "\u6458\u8981" : "Summary"));
|
|
134
|
+
console.log(` ${ansis.green("\u2705")} ${isZh ? "\u5065\u5EB7" : "Healthy"}: ${healthyCount}`);
|
|
135
|
+
console.log(` ${ansis.red("\u274C")} ${isZh ? "\u4E0D\u53EF\u7528" : "Unavailable"}: ${unhealthyCount}`);
|
|
136
|
+
console.log("");
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error(ansis.red(isZh ? "\u274C \u5065\u5EB7\u68C0\u67E5\u5931\u8D25" : "\u274C Health check failed"));
|
|
139
|
+
if (options.verbose && error instanceof Error) {
|
|
140
|
+
console.error(ansis.dim(error.message));
|
|
141
|
+
}
|
|
142
|
+
console.log("");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function recommendProvider(options = {}) {
|
|
146
|
+
const isZh = i18n.language === "zh-CN";
|
|
147
|
+
const codeType = options.codeType || "claude-code";
|
|
148
|
+
console.log("");
|
|
149
|
+
console.log(ansis.bold.cyan(isZh ? "\u{1F3AF} \u4F9B\u5E94\u5546\u63A8\u8350" : "\u{1F3AF} Provider Recommendation"));
|
|
150
|
+
console.log(ansis.dim("\u2500".repeat(60)));
|
|
151
|
+
console.log("");
|
|
152
|
+
try {
|
|
153
|
+
const providers = await getApiProviderPresets(codeType);
|
|
154
|
+
if (providers.length === 0) {
|
|
155
|
+
console.log(ansis.yellow(isZh ? "\u672A\u627E\u5230\u4F9B\u5E94\u5546" : "No providers found"));
|
|
156
|
+
console.log("");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const monitor = new ProviderHealthMonitor({
|
|
160
|
+
timeout: 5e3,
|
|
161
|
+
degradedLatencyThreshold: 1e3,
|
|
162
|
+
unhealthyLatencyThreshold: 3e3
|
|
163
|
+
});
|
|
164
|
+
monitor.setProviders(providers);
|
|
165
|
+
console.log(ansis.dim(isZh ? "\u6B63\u5728\u5206\u6790\u4F9B\u5E94\u5546\u6027\u80FD..." : "Analyzing provider performance..."));
|
|
166
|
+
console.log("");
|
|
167
|
+
await Promise.all(
|
|
168
|
+
providers.map(async (provider) => {
|
|
169
|
+
const result = await monitor.checkHealth(provider);
|
|
170
|
+
return result;
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
const sortedProviders = monitor.getProvidersByHealth();
|
|
174
|
+
const bestProvider = sortedProviders[0];
|
|
175
|
+
if (!bestProvider) {
|
|
176
|
+
console.log(ansis.yellow(isZh ? "\u65E0\u6CD5\u786E\u5B9A\u6700\u4F73\u4F9B\u5E94\u5546" : "Unable to determine best provider"));
|
|
177
|
+
console.log("");
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
console.log(ansis.bold.green(isZh ? "\u{1F3C6} \u63A8\u8350\u4F9B\u5E94\u5546" : "\u{1F3C6} Recommended Provider"));
|
|
181
|
+
console.log("");
|
|
182
|
+
console.log(` ${ansis.bold.cyan(bestProvider.name)} ${ansis.dim(`(${bestProvider.id})`)}`);
|
|
183
|
+
if (bestProvider.description) {
|
|
184
|
+
console.log(` ${ansis.dim(bestProvider.description)}`);
|
|
185
|
+
}
|
|
186
|
+
const health = monitor.getProviderHealth(bestProvider.id);
|
|
187
|
+
if (health) {
|
|
188
|
+
console.log("");
|
|
189
|
+
console.log(ansis.bold(isZh ? "\u6027\u80FD\u6307\u6807" : "Performance Metrics"));
|
|
190
|
+
console.log(` ${ansis.cyan(isZh ? "\u5EF6\u8FDF" : "Latency")}: ${health.latency.toFixed(0)}ms`);
|
|
191
|
+
console.log(` ${ansis.cyan(isZh ? "\u6210\u529F\u7387" : "Success Rate")}: ${(health.successRate * 100).toFixed(1)}%`);
|
|
192
|
+
console.log(` ${ansis.cyan(isZh ? "\u72B6\u6001" : "Status")}: ${getStatusDisplay(health.status, isZh)}`);
|
|
193
|
+
}
|
|
194
|
+
if (sortedProviders.length > 1) {
|
|
195
|
+
console.log("");
|
|
196
|
+
console.log(ansis.bold(isZh ? "\u5907\u9009\u4F9B\u5E94\u5546" : "Alternative Providers"));
|
|
197
|
+
console.log("");
|
|
198
|
+
for (let i = 1; i < Math.min(4, sortedProviders.length); i++) {
|
|
199
|
+
const provider = sortedProviders[i];
|
|
200
|
+
const health2 = monitor.getProviderHealth(provider.id);
|
|
201
|
+
console.log(` ${i}. ${ansis.bold(provider.name)} ${ansis.dim(`(${provider.id})`)}`);
|
|
202
|
+
if (health2) {
|
|
203
|
+
console.log(` ${ansis.dim(`${health2.latency.toFixed(0)}ms | ${(health2.successRate * 100).toFixed(1)}% | ${health2.status}`)}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
console.log("");
|
|
208
|
+
console.log(ansis.dim("\u2500".repeat(60)));
|
|
209
|
+
console.log(ansis.dim(isZh ? '\u{1F4A1} \u63D0\u793A: \u4F7F\u7528 "ccjk config set provider <id>" \u5207\u6362\u4F9B\u5E94\u5546' : '\u{1F4A1} Tip: Use "ccjk config set provider <id>" to switch provider'));
|
|
210
|
+
console.log("");
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error(ansis.red(isZh ? "\u274C \u63A8\u8350\u5931\u8D25" : "\u274C Recommendation failed"));
|
|
213
|
+
if (options.verbose && error instanceof Error) {
|
|
214
|
+
console.error(ansis.dim(error.message));
|
|
215
|
+
}
|
|
216
|
+
console.log("");
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function getStatusDisplay(status, isZh) {
|
|
220
|
+
const statusMap = {
|
|
221
|
+
healthy: { en: "Healthy", zh: "\u5065\u5EB7", color: ansis.green },
|
|
222
|
+
degraded: { en: "Degraded", zh: "\u964D\u7EA7", color: ansis.yellow },
|
|
223
|
+
unhealthy: { en: "Unhealthy", zh: "\u4E0D\u5065\u5EB7", color: ansis.red },
|
|
224
|
+
unknown: { en: "Unknown", zh: "\u672A\u77E5", color: ansis.dim }
|
|
225
|
+
};
|
|
226
|
+
const info = statusMap[status] || statusMap.unknown;
|
|
227
|
+
const text = isZh ? info.zh : info.en;
|
|
228
|
+
return info.color(text);
|
|
229
|
+
}
|
|
230
|
+
async function providersCommand(action, options = {}) {
|
|
231
|
+
switch (action) {
|
|
232
|
+
case "list":
|
|
233
|
+
case "ls":
|
|
234
|
+
await listProviders(options);
|
|
235
|
+
break;
|
|
236
|
+
case "health":
|
|
237
|
+
case "check":
|
|
238
|
+
await checkProvidersHealth(options);
|
|
239
|
+
break;
|
|
240
|
+
case "recommend":
|
|
241
|
+
case "rec":
|
|
242
|
+
await recommendProvider(options);
|
|
243
|
+
break;
|
|
244
|
+
default: {
|
|
245
|
+
const isZh = i18n.language === "zh-CN";
|
|
246
|
+
console.log("");
|
|
247
|
+
console.log(ansis.bold.cyan(isZh ? "\u{1F4E6} \u4F9B\u5E94\u5546\u7BA1\u7406\u547D\u4EE4" : "\u{1F4E6} Provider Management Commands"));
|
|
248
|
+
console.log("");
|
|
249
|
+
console.log(` ${ansis.cyan("ccjk providers list")} ${isZh ? "\u5217\u51FA\u6240\u6709\u4F9B\u5E94\u5546" : "List all providers"}`);
|
|
250
|
+
console.log(` ${ansis.cyan("ccjk providers health")} ${isZh ? "\u68C0\u67E5\u4F9B\u5E94\u5546\u5065\u5EB7\u72B6\u6001" : "Check provider health"}`);
|
|
251
|
+
console.log(` ${ansis.cyan("ccjk providers recommend")} ${isZh ? "\u63A8\u8350\u6700\u4F73\u4F9B\u5E94\u5546" : "Recommend best provider"}`);
|
|
252
|
+
console.log("");
|
|
253
|
+
console.log(ansis.bold(isZh ? "\u9009\u9879" : "Options"));
|
|
254
|
+
console.log(` ${ansis.green("--code-type, -T")} <type> ${isZh ? "\u4EE3\u7801\u5DE5\u5177\u7C7B\u578B (claude-code, codex)" : "Code tool type (claude-code, codex)"}`);
|
|
255
|
+
console.log(` ${ansis.green("--verbose, -v")} ${isZh ? "\u8BE6\u7EC6\u8F93\u51FA" : "Verbose output"}`);
|
|
256
|
+
console.log("");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export { checkProvidersHealth, listProviders, providersCommand, recommendProvider };
|