ccjk 12.0.11 → 12.0.13

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.
@@ -66,6 +66,9 @@ function getCloudApiUrl(endpoint) {
66
66
  const config = CLOUD_ENDPOINTS[endpoint];
67
67
  return `${config.BASE_URL}${config.API_VERSION}`;
68
68
  }
69
+ function getCloudBaseUrl(endpoint) {
70
+ return CLOUD_ENDPOINTS[endpoint].BASE_URL;
71
+ }
69
72
  const CCJK_CLOUD_API_URL = getCloudApiUrl("PLUGINS");
70
73
  const LEGACY_ZCF_CONFIG_DIR = join(homedir(), ".ufomiao", "zcf");
71
74
  const LEGACY_ZCF_CONFIG_FILE = join(LEGACY_ZCF_CONFIG_DIR, "config.toml");
@@ -130,4 +133,4 @@ function getAiOutputLanguageLabel(lang) {
130
133
  return lang;
131
134
  }
132
135
 
133
- export { AIDER_DIR, AI_OUTPUT_LANGUAGES, API_DEFAULT_URL, CCJK_CLOUD_API_URL, CCJK_CLOUD_PLUGINS_CACHE_DIR, CCJK_CLOUD_PLUGINS_DIR, CCJK_CLOUD_PLUGINS_INSTALLED_DIR, CCJK_CONFIG_DIR, CCJK_CONFIG_FILE, CCJK_PLUGINS_DIR, CCJK_SKILLS_DIR, CLAUDE_AGENTS_DIR, CLAUDE_DIR, CLAUDE_VSC_CONFIG_FILE, CLINE_DIR, CLOUD_ENDPOINTS, CODEX_AGENTS_FILE, CODEX_AUTH_FILE, CODEX_CONFIG_FILE, CODEX_DIR, CODEX_PROMPTS_DIR, CODE_TOOL_ALIASES, CODE_TOOL_BANNERS, CODE_TOOL_TYPES, CONTINUE_DIR, CURSOR_DIR, ClAUDE_CONFIG_FILE, DEFAULT_CODE_TOOL_TYPE, LANG_LABELS, LEGACY_ZCF_CONFIG_DIR, LEGACY_ZCF_CONFIG_FILE, LEGACY_ZCF_CONFIG_FILES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_DIR, ZCF_CONFIG_FILE, getAiOutputLanguageLabel, getCloudApiUrl, isCodeToolType, resolveCodeToolType };
136
+ export { AIDER_DIR, AI_OUTPUT_LANGUAGES, API_DEFAULT_URL, CCJK_CLOUD_API_URL, CCJK_CLOUD_PLUGINS_CACHE_DIR, CCJK_CLOUD_PLUGINS_DIR, CCJK_CLOUD_PLUGINS_INSTALLED_DIR, CCJK_CONFIG_DIR, CCJK_CONFIG_FILE, CCJK_PLUGINS_DIR, CCJK_SKILLS_DIR, CLAUDE_AGENTS_DIR, CLAUDE_DIR, CLAUDE_VSC_CONFIG_FILE, CLINE_DIR, CLOUD_ENDPOINTS, CODEX_AGENTS_FILE, CODEX_AUTH_FILE, CODEX_CONFIG_FILE, CODEX_DIR, CODEX_PROMPTS_DIR, CODE_TOOL_ALIASES, CODE_TOOL_BANNERS, CODE_TOOL_TYPES, CONTINUE_DIR, CURSOR_DIR, ClAUDE_CONFIG_FILE, DEFAULT_CODE_TOOL_TYPE, LANG_LABELS, LEGACY_ZCF_CONFIG_DIR, LEGACY_ZCF_CONFIG_FILE, LEGACY_ZCF_CONFIG_FILES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_DIR, ZCF_CONFIG_FILE, getAiOutputLanguageLabel, getCloudApiUrl, getCloudBaseUrl, isCodeToolType, resolveCodeToolType };
@@ -1,17 +1,30 @@
1
1
  import a from './index2.mjs';
2
+ import { getCloudBaseUrl } from './constants.mjs';
2
3
  import { i18n } from './index5.mjs';
3
4
  import '../shared/ccjk.BAGoDD49.mjs';
5
+ import 'node:os';
6
+ import '../shared/ccjk.bQ7Dh1g4.mjs';
4
7
  import 'node:fs';
5
8
  import 'node:process';
6
9
  import 'node:url';
7
- import '../shared/ccjk.bQ7Dh1g4.mjs';
8
10
 
9
11
  class A2AClient {
10
12
  baseUrl;
11
13
  token = null;
12
14
  agentId = null;
13
- constructor(baseUrl = "http://localhost:3005") {
14
- this.baseUrl = baseUrl;
15
+ constructor(baseUrl) {
16
+ const resolved = baseUrl || process.env.CCJK_SERVER_URL;
17
+ if (!resolved) {
18
+ if (process.env.NODE_ENV === "production") {
19
+ throw new Error("CCJK_SERVER_URL is required in production");
20
+ }
21
+ this.baseUrl = "http://localhost:3005";
22
+ return;
23
+ }
24
+ if (process.env.NODE_ENV === "production" && !resolved.startsWith("https://")) {
25
+ throw new Error("CCJK_SERVER_URL must use https:// in production");
26
+ }
27
+ this.baseUrl = resolved;
15
28
  }
16
29
  /**
17
30
  * Register agent (hello)
@@ -75,9 +88,9 @@ class A2AClient {
75
88
  */
76
89
  async revoke(geneId, reason) {
77
90
  this.ensureAuthenticated();
78
- await this.request(`/a2a/genes/${geneId}`, {
79
- method: "DELETE",
80
- body: { reason },
91
+ await this.request("/a2a/revoke", {
92
+ method: "POST",
93
+ body: { type: "revoke", geneId, reason },
81
94
  auth: true
82
95
  });
83
96
  }
@@ -122,54 +135,10 @@ class A2AClient {
122
135
  }
123
136
  }
124
137
 
125
- const PROTOCOL_CACHE_TTL_MS = 10 * 60 * 1e3;
126
- const HEALTH_PATH = "/health";
127
- const API_CANDIDATES = [
128
- "https://remote-api.claudehome.cn",
129
- "http://remote-api.claudehome.cn"
130
- ];
131
- let protocolCache = null;
132
- async function resolveRemoteApiBaseUrl(timeoutMs = 5e3) {
133
- const now = Date.now();
134
- if (protocolCache && protocolCache.expiresAt > now) {
135
- return protocolCache.baseUrl;
136
- }
137
- for (const baseUrl of API_CANDIDATES) {
138
- const ok = await probeHealth(baseUrl, timeoutMs);
139
- if (ok) {
140
- protocolCache = {
141
- baseUrl,
142
- expiresAt: now + PROTOCOL_CACHE_TTL_MS
143
- };
144
- return baseUrl;
145
- }
146
- }
147
- throw new Error("Remote API unavailable");
148
- }
149
- async function probeHealth(baseUrl, timeoutMs) {
150
- const controller = new AbortController();
151
- const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
152
- try {
153
- const response = await fetch(`${baseUrl}${HEALTH_PATH}`, {
154
- method: "GET",
155
- signal: controller.signal
156
- });
157
- if (!response.ok) {
158
- return false;
159
- }
160
- const data = await response.json().catch(() => null);
161
- return data?.status === "ok";
162
- } catch {
163
- return false;
164
- } finally {
165
- clearTimeout(timeoutId);
166
- }
167
- }
168
-
169
138
  async function handleEvolutionCommand(action, args, options) {
170
139
  try {
171
- const resolvedBaseUrl = await resolveRemoteApiBaseUrl();
172
- const client = new A2AClient(resolvedBaseUrl);
140
+ const client = new A2AClient(getCloudBaseUrl("MAIN"));
141
+ await client.hello("ccjk", "1.0.0", ["fetch", "report", "publish"]);
173
142
  switch (action) {
174
143
  case "top":
175
144
  await showTopCapabilities(client, options);
@@ -193,24 +162,12 @@ async function handleEvolutionCommand(action, args, options) {
193
162
  }
194
163
  }
195
164
  async function showTopCapabilities(client, options) {
196
- const connectingMsg = i18n.t("evolution:connecting", "Connecting to Evolution Layer...");
197
- console.log(a.blue("\u{1F517} " + connectingMsg));
198
- await client.hello({
199
- id: "claude-code-cli",
200
- name: "claude-code",
201
- version: "1.0.0",
202
- capabilities: ["fetch", "report"]
203
- });
204
165
  const fetchingMsg = i18n.t("evolution:fetching", "Fetching top capabilities...");
205
166
  console.log(a.blue("\u{1F4CA} " + fetchingMsg));
206
- const genes = await client.fetch(
207
- {
208
- signature: "*",
209
- context: [],
210
- minGDI: Number.parseInt(options.minGdi || "70")
211
- },
212
- Number.parseInt(options.limit || "30")
213
- );
167
+ const genes = await client.fetch({
168
+ minGDI: Number.parseInt(options.minGdi || "70"),
169
+ limit: Number.parseInt(options.limit || "30")
170
+ });
214
171
  const foundMsg = i18n.t("evolution:found", "Found {{count}} capabilities", { count: genes.length });
215
172
  console.log(a.green("\n\u2705 " + foundMsg + "\n"));
216
173
  if (genes.length === 0) {
@@ -219,17 +176,17 @@ async function showTopCapabilities(client, options) {
219
176
  return;
220
177
  }
221
178
  genes.forEach((gene, index) => {
222
- console.log(a.bold(`${index + 1}. ${gene.id.substring(0, 8)}`));
179
+ console.log(a.bold(`${index + 1}. ${gene.geneId.substring(0, 8)}`));
223
180
  const problemLabel = a.cyan(i18n.t("evolution:problem", "Problem"));
224
- console.log(" " + problemLabel + ": " + gene.problem.signature);
181
+ console.log(" " + problemLabel + ": " + gene.problemSignature);
225
182
  const solutionLabel = a.yellow(i18n.t("evolution:solution", "Solution"));
226
- console.log(" " + solutionLabel + ": " + gene.solution.strategy);
227
- console.log(" " + a.green("GDI") + ": " + gene.quality.gdi.toFixed(1));
183
+ console.log(" " + solutionLabel + ": " + gene.solutionStrategy);
184
+ console.log(" " + a.green("GDI") + ": " + gene.gdi.toFixed(1));
228
185
  const usedLabel = a.gray(i18n.t("evolution:used", "Used"));
229
186
  const timesLabel = i18n.t("evolution:times", "times");
230
- console.log(" " + usedLabel + ": " + gene.quality.usageCount + " " + timesLabel);
187
+ console.log(" " + usedLabel + ": " + gene.usageCount + " " + timesLabel);
231
188
  const successLabel = a.gray(i18n.t("evolution:success", "Success"));
232
- const successRate = (gene.quality.successRate * 100).toFixed(1);
189
+ const successRate = (gene.successRate * 100).toFixed(1);
233
190
  console.log(" " + successLabel + ": " + successRate + "%");
234
191
  console.log();
235
192
  });
@@ -237,20 +194,11 @@ async function showTopCapabilities(client, options) {
237
194
  async function searchSolutions(client, query, options) {
238
195
  const searchingMsg = i18n.t("evolution:searching", "Searching for: {{query}}", { query });
239
196
  console.log(a.blue("\u{1F50D} " + searchingMsg));
240
- await client.hello({
241
- id: "claude-code-cli",
242
- name: "claude-code",
243
- version: "1.0.0",
244
- capabilities: ["fetch", "report"]
197
+ const genes = await client.fetch({
198
+ signature: query,
199
+ minGDI: Number.parseInt(options.minGdi || "60"),
200
+ limit: Number.parseInt(options.limit || "10")
245
201
  });
246
- const genes = await client.fetch(
247
- {
248
- signature: query,
249
- context: [],
250
- minGDI: Number.parseInt(options.minGdi || "60")
251
- },
252
- Number.parseInt(options.limit || "10")
253
- );
254
202
  if (genes.length === 0) {
255
203
  const noSolutionsMsg = i18n.t("evolution:noSolutions", "No solutions found");
256
204
  console.log(a.yellow("\n" + noSolutionsMsg));
@@ -259,26 +207,20 @@ async function searchSolutions(client, query, options) {
259
207
  const foundMsg = i18n.t("evolution:foundSolutions", "Found {{count}} solutions", { count: genes.length });
260
208
  console.log(a.green("\n\u2705 " + foundMsg + "\n"));
261
209
  genes.forEach((gene, index) => {
262
- console.log(a.bold(`${index + 1}. ${gene.problem.signature}`));
263
- console.log(" " + gene.solution.strategy);
210
+ console.log(a.bold(`${index + 1}. ${gene.problemSignature}`));
211
+ console.log(" " + gene.solutionStrategy);
264
212
  const usedLabel = i18n.t("evolution:used", "Used");
265
- console.log(" GDI: " + gene.quality.gdi.toFixed(1) + " | " + usedLabel + ": " + gene.quality.usageCount + "x");
266
- if (gene.problem.context.length > 0) {
267
- const contextLabel = a.gray(i18n.t("evolution:context", "Context"));
268
- console.log(" " + contextLabel + ": " + gene.problem.context.join(", "));
213
+ console.log(" GDI: " + gene.gdi.toFixed(1) + " | " + usedLabel + ": " + gene.usageCount + "x");
214
+ if (gene.tags.length > 0) {
215
+ const tagsLabel = a.gray(i18n.t("evolution:tags", "Tags"));
216
+ console.log(" " + tagsLabel + ": " + gene.tags.join(", "));
269
217
  }
270
218
  console.log();
271
219
  });
272
220
  }
273
221
  async function showGeneDetails(client, geneId) {
274
- await client.hello({
275
- id: "claude-code-cli",
276
- name: "claude-code",
277
- version: "1.0.0",
278
- capabilities: ["fetch", "report"]
279
- });
280
- const genes = await client.fetch({ signature: "*", context: [] });
281
- const gene = genes.find((g) => g.id.startsWith(geneId));
222
+ const genes = await client.fetch({ geneId, limit: 5 });
223
+ const gene = genes.find((g) => g.geneId.startsWith(geneId));
282
224
  if (!gene) {
283
225
  const notFoundMsg = i18n.t("evolution:geneNotFound", "Gene not found");
284
226
  console.log(a.red(notFoundMsg));
@@ -289,94 +231,61 @@ async function showGeneDetails(client, geneId) {
289
231
  async function showStats(client) {
290
232
  const fetchingMsg = i18n.t("evolution:fetchingStats", "Fetching statistics...");
291
233
  console.log(a.blue("\u{1F4CA} " + fetchingMsg));
292
- await client.hello({
293
- id: "claude-code-cli",
294
- name: "claude-code",
295
- version: "1.0.0",
296
- capabilities: ["fetch", "report"]
297
- });
298
- const allGenes = await client.fetch({ signature: "*", context: [] }, 1e3);
299
- const totalGenes = allGenes.length;
300
- const avgGDI = allGenes.reduce((sum, g) => sum + g.quality.gdi, 0) / totalGenes;
301
- const totalUsage = allGenes.reduce((sum, g) => sum + g.quality.usageCount, 0);
302
- const avgSuccessRate = allGenes.reduce((sum, g) => sum + g.quality.successRate, 0) / totalGenes;
303
- const typeCount = allGenes.reduce((acc, g) => {
304
- acc[g.type] = (acc[g.type] || 0) + 1;
305
- return acc;
306
- }, {});
234
+ const stats = await client.stats();
307
235
  console.log(a.bold("\n\u{1F4C8} Evolution Layer Statistics\n"));
308
- const totalLabel = a.cyan(i18n.t("evolution:totalGenes", "Total Genes"));
309
- console.log(totalLabel + ": " + totalGenes);
310
- const avgGdiLabel = a.cyan(i18n.t("evolution:avgGDI", "Average GDI"));
311
- console.log(avgGdiLabel + ": " + avgGDI.toFixed(1));
312
- const totalUsageLabel = a.cyan(i18n.t("evolution:totalUsage", "Total Usage"));
313
- console.log(totalUsageLabel + ": " + totalUsage);
314
- const avgSuccessLabel = a.cyan(i18n.t("evolution:avgSuccess", "Average Success Rate"));
315
- console.log(avgSuccessLabel + ": " + (avgSuccessRate * 100).toFixed(1) + "%");
316
- console.log();
317
- const byTypeLabel = i18n.t("evolution:byType", "By Type");
318
- console.log(a.bold(byTypeLabel + ":"));
319
- Object.entries(typeCount).forEach(([type, count]) => {
320
- console.log(" " + type + ": " + count);
321
- });
236
+ const totalLabel = a.cyan(i18n.t("evolution:totalGenes", "Total Genes in Pool"));
237
+ console.log(totalLabel + ": " + stats.totalGenesInPool);
238
+ const myLabel = a.cyan(i18n.t("evolution:myContributions", "My Contributions"));
239
+ console.log(myLabel + ": " + stats.myContributions);
240
+ const reportsLabel = a.cyan(i18n.t("evolution:reportsSubmitted", "Reports Submitted"));
241
+ console.log(reportsLabel + ": " + stats.reportsSubmitted);
242
+ const successLabel = a.cyan(i18n.t("evolution:successRate", "Success Rate"));
243
+ console.log(successLabel + ": " + (stats.successRate * 100).toFixed(1) + "%");
322
244
  }
323
245
  function displayGene(gene) {
324
246
  const detailsLabel = i18n.t("evolution:geneDetails", "Gene Details");
325
247
  console.log(a.bold("\n\u{1F4E6} " + detailsLabel + "\n"));
326
- console.log(a.cyan("ID") + ": " + gene.id);
327
- const typeLabel = i18n.t("evolution:type", "Type");
328
- console.log(a.cyan(typeLabel) + ": " + gene.type);
329
- console.log(a.cyan("SHA256") + ": " + gene.sha256);
248
+ console.log(a.cyan("ID") + ": " + gene.geneId);
249
+ console.log(a.cyan("Version") + ": " + gene.version);
330
250
  console.log();
331
251
  const problemLabel = i18n.t("evolution:problem", "Problem");
332
252
  console.log(a.bold(problemLabel + ":"));
333
- const sigLabel = i18n.t("evolution:signature", "Signature");
334
- console.log(" " + sigLabel + ": " + gene.problem.signature);
335
- if (gene.problem.context.length > 0) {
336
- const contextLabel = i18n.t("evolution:context", "Context");
337
- console.log(" " + contextLabel + ": " + gene.problem.context.join(", "));
338
- }
253
+ console.log(" " + gene.problemSignature);
339
254
  console.log();
340
255
  const solutionLabel = i18n.t("evolution:solution", "Solution");
341
256
  console.log(a.bold(solutionLabel + ":"));
342
257
  const strategyLabel = i18n.t("evolution:strategy", "Strategy");
343
- console.log(" " + strategyLabel + ": " + gene.solution.strategy);
344
- if (gene.solution.code) {
258
+ console.log(" " + strategyLabel + ": " + gene.solutionStrategy);
259
+ if (gene.solutionCode) {
345
260
  const codeLabel = i18n.t("evolution:code", "Code");
346
261
  console.log(" " + codeLabel + ":");
347
- const codeLines = gene.solution.code.split("\n").map((line) => " " + line).join("\n");
262
+ const codeLines = gene.solutionCode.split("\n").map((line) => " " + line).join("\n");
348
263
  console.log(a.gray(codeLines));
349
264
  }
350
- if (gene.solution.steps.length > 0) {
265
+ if (gene.solutionSteps.length > 0) {
351
266
  const stepsLabel = i18n.t("evolution:steps", "Steps");
352
267
  console.log(" " + stepsLabel + ":");
353
- gene.solution.steps.forEach((step, i) => {
268
+ gene.solutionSteps.forEach((step, i) => {
354
269
  console.log(" " + (i + 1) + ". " + step);
355
270
  });
356
271
  }
357
272
  console.log();
358
273
  const qualityLabel = i18n.t("evolution:quality", "Quality");
359
274
  console.log(a.bold(qualityLabel + ":"));
360
- console.log(" GDI: " + gene.quality.gdi.toFixed(1));
275
+ console.log(" GDI: " + gene.gdi.toFixed(1));
361
276
  const successRateLabel = i18n.t("evolution:successRate", "Success Rate");
362
- console.log(" " + successRateLabel + ": " + (gene.quality.successRate * 100).toFixed(1) + "%");
277
+ console.log(" " + successRateLabel + ": " + (gene.successRate * 100).toFixed(1) + "%");
363
278
  const usageCountLabel = i18n.t("evolution:usageCount", "Usage Count");
364
- console.log(" " + usageCountLabel + ": " + gene.quality.usageCount);
365
- const avgTimeLabel = i18n.t("evolution:avgTime", "Average Time");
366
- console.log(" " + avgTimeLabel + ": " + gene.quality.avgTime + "s");
367
- if (gene.metadata) {
279
+ console.log(" " + usageCountLabel + ": " + gene.usageCount);
280
+ const passRateLabel = i18n.t("evolution:passRate", "Pass Rate");
281
+ console.log(" " + passRateLabel + ": " + (gene.passRate * 100).toFixed(1) + "%");
282
+ if (gene.tags.length > 0) {
368
283
  console.log();
369
- const metadataLabel = i18n.t("evolution:metadata", "Metadata");
370
- console.log(a.bold(metadataLabel + ":"));
371
- const authorLabel = i18n.t("evolution:author", "Author");
372
- console.log(" " + authorLabel + ": " + (gene.metadata.author || "-"));
373
- const createdLabel = i18n.t("evolution:createdAt", "Created At");
374
- console.log(" " + createdLabel + ": " + (gene.metadata.createdAt || "-"));
375
- if (gene.metadata.tags && gene.metadata.tags.length > 0) {
376
- const tagsLabel = i18n.t("evolution:tags", "Tags");
377
- console.log(" " + tagsLabel + ": " + gene.metadata.tags.join(", "));
378
- }
284
+ const tagsLabel = i18n.t("evolution:tags", "Tags");
285
+ console.log(" " + tagsLabel + ": " + gene.tags.join(", "));
379
286
  }
287
+ const createdLabel = i18n.t("evolution:createdAt", "Created At");
288
+ console.log(" " + createdLabel + ": " + gene.createdAt);
380
289
  }
381
290
 
382
291
  export { handleEvolutionCommand };
@@ -1,3 +1,3 @@
1
- const version = "12.0.10";
1
+ const version = "12.0.12";
2
2
 
3
3
  export { version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ccjk",
3
3
  "type": "module",
4
- "version": "12.0.11",
4
+ "version": "12.0.13",
5
5
  "packageManager": "pnpm@10.17.1",
6
6
  "description": "CLI toolkit for Claude Code and Codex setup. Simplifies MCP service installation, API configuration, workflow management, and multi-provider support with guided interactive setup.",
7
7
  "author": {