ccjk 12.0.11 → 12.0.12

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,15 @@ 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({
142
+ id: "ccjk-cli",
143
+ name: "ccjk",
144
+ version: "1.0.0",
145
+ capabilities: ["fetch", "report", "publish"]
146
+ });
173
147
  switch (action) {
174
148
  case "top":
175
149
  await showTopCapabilities(client, options);
@@ -193,14 +167,6 @@ async function handleEvolutionCommand(action, args, options) {
193
167
  }
194
168
  }
195
169
  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
170
  const fetchingMsg = i18n.t("evolution:fetching", "Fetching top capabilities...");
205
171
  console.log(a.blue("\u{1F4CA} " + fetchingMsg));
206
172
  const genes = await client.fetch(
@@ -237,12 +203,6 @@ async function showTopCapabilities(client, options) {
237
203
  async function searchSolutions(client, query, options) {
238
204
  const searchingMsg = i18n.t("evolution:searching", "Searching for: {{query}}", { query });
239
205
  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"]
245
- });
246
206
  const genes = await client.fetch(
247
207
  {
248
208
  signature: query,
@@ -271,13 +231,7 @@ async function searchSolutions(client, query, options) {
271
231
  });
272
232
  }
273
233
  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: [] });
234
+ const genes = await client.fetch({ signature: geneId, context: [] }, 5);
281
235
  const gene = genes.find((g) => g.id.startsWith(geneId));
282
236
  if (!gene) {
283
237
  const notFoundMsg = i18n.t("evolution:geneNotFound", "Gene not found");
@@ -289,12 +243,6 @@ async function showGeneDetails(client, geneId) {
289
243
  async function showStats(client) {
290
244
  const fetchingMsg = i18n.t("evolution:fetchingStats", "Fetching statistics...");
291
245
  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
246
  const allGenes = await client.fetch({ signature: "*", context: [] }, 1e3);
299
247
  const totalGenes = allGenes.length;
300
248
  const avgGDI = allGenes.reduce((sum, g) => sum + g.quality.gdi, 0) / totalGenes;
@@ -1,3 +1,3 @@
1
- const version = "12.0.10";
1
+ const version = "12.0.11";
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.12",
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": {