ccjk 12.0.10 → 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.
@@ -1,6 +1,6 @@
1
1
  import a from './index2.mjs';
2
2
  import { c as consola } from '../shared/ccjk.UIvifqNE.mjs';
3
- import { c as createCompleteCloudClient } from '../shared/ccjk.B364Fu0N.mjs';
3
+ import { c as createCompleteCloudClient } from '../shared/ccjk.CtXhbEqb.mjs';
4
4
  import { i18n, ensureI18nInitialized } from './index5.mjs';
5
5
  import { createHash } from 'node:crypto';
6
6
  import { promises, readFileSync } from 'node:fs';
@@ -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;
@@ -301,7 +301,7 @@ async function mcpDoctor(options = {}) {
301
301
  console.log("");
302
302
  }
303
303
 
304
- const DEFAULT_API_URL = "https://api.claudehome.cn/api/v1/mcp-marketplace";
304
+ const DEFAULT_API_URL = "https://api.claudehome.cn/api/v1/skills";
305
305
  const REQUEST_TIMEOUT = 3e4;
306
306
  const MAX_RETRY_ATTEMPTS = 3;
307
307
  const RETRY_DELAY = 1e3;
@@ -355,7 +355,7 @@ class MarketplaceClient {
355
355
  async search(options = {}) {
356
356
  this.log("Searching packages with options:", options);
357
357
  const params = this.buildSearchParams(options);
358
- const response = await this.request("/search", {
358
+ const response = await this.request("", {
359
359
  method: "GET",
360
360
  params
361
361
  });
@@ -660,7 +660,7 @@ class MarketplaceClient {
660
660
  */
661
661
  buildSearchParams(options) {
662
662
  return {
663
- q: options.query,
663
+ keyword: options.query,
664
664
  category: options.category,
665
665
  tags: options.tags,
666
666
  sortBy: options.sortBy,
@@ -1,3 +1,3 @@
1
- const version = "12.0.10";
1
+ const version = "12.0.11";
2
2
 
3
3
  export { version };
@@ -318,7 +318,7 @@ class LocalPluginCache {
318
318
  }
319
319
  }
320
320
 
321
- const DEFAULT_CLOUD_API_URL = "https://api.claudehome.cn/api/v1/plugins";
321
+ const DEFAULT_CLOUD_API_URL = "https://api.claudehome.cn/api/v1/skills";
322
322
  const REQUEST_TIMEOUT = 3e4;
323
323
  const MAX_RETRY_ATTEMPTS = 3;
324
324
  const RETRY_DELAY = 1e3;
package/dist/index.d.mts CHANGED
@@ -3244,6 +3244,15 @@ declare class CloudClient {
3244
3244
  * Calculate retry delay with exponential backoff
3245
3245
  */
3246
3246
  private calculateRetryDelay;
3247
+ /**
3248
+ * Parse server response — handles all 5 response formats from Miaoda API:
3249
+ * 1. { success: true, data: {} } — auth/user/config/admin modules
3250
+ * 2. { success: false, error: { message } } — error from above modules
3251
+ * 3. { data: {} } — usage/license/skill modules
3252
+ * 4. bare object — subscription/llm/storage modules
3253
+ * 5. { error: "..." } — bare error
3254
+ */
3255
+ parseResponse<T>(raw: unknown): T;
3247
3256
  /**
3248
3257
  * Handle fetch errors and convert to CloudClientError
3249
3258
  */
package/dist/index.d.ts CHANGED
@@ -3244,6 +3244,15 @@ declare class CloudClient {
3244
3244
  * Calculate retry delay with exponential backoff
3245
3245
  */
3246
3246
  private calculateRetryDelay;
3247
+ /**
3248
+ * Parse server response — handles all 5 response formats from Miaoda API:
3249
+ * 1. { success: true, data: {} } — auth/user/config/admin modules
3250
+ * 2. { success: false, error: { message } } — error from above modules
3251
+ * 3. { data: {} } — usage/license/skill modules
3252
+ * 4. bare object — subscription/llm/storage modules
3253
+ * 5. { error: "..." } — bare error
3254
+ */
3255
+ parseResponse<T>(raw: unknown): T;
3247
3256
  /**
3248
3257
  * Handle fetch errors and convert to CloudClientError
3249
3258
  */
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as createCloudClient } from './shared/ccjk.B364Fu0N.mjs';
2
- export { C as CachedCloudClient, b as CloudCache, d as CloudClient, F as FallbackCloudClient, R as RetryableCloudClient, T as TelemetryReporter, c as createCompleteCloudClient, g as getTelemetry, i as initializeTelemetry, r as retryUtils, s as stopTelemetry, t as telemetryUtils, e as trackEvent, w as withRetry } from './shared/ccjk.B364Fu0N.mjs';
1
+ import { a as createCloudClient } from './shared/ccjk.CtXhbEqb.mjs';
2
+ export { C as CachedCloudClient, b as CloudCache, d as CloudClient, F as FallbackCloudClient, R as RetryableCloudClient, T as TelemetryReporter, c as createCompleteCloudClient, g as getTelemetry, i as initializeTelemetry, r as retryUtils, s as stopTelemetry, t as telemetryUtils, e as trackEvent, w as withRetry } from './shared/ccjk.CtXhbEqb.mjs';
3
3
  export { C as CloudError, a as CloudErrorCode, b as CloudErrorFactory, f as formatErrorForLogging, g as getRetryDelay, h as handleCloudError, i as isAuthError, c as isRateLimitError, d as isRetryableError, e as isRetryableErrorCode } from './shared/ccjk.D8ZLYSZZ.mjs';
4
4
  export { T as TemplatesClient, a as createTemplatesClient, g as getTemplatesClient } from './shared/ccjk.UIvifqNE.mjs';
5
5
  import { e as extractString } from './shared/ccjk.C2jHOZVP.mjs';
@@ -924,6 +924,7 @@ try {
924
924
  } catch {
925
925
  }
926
926
  const API_PREFIX = "/api/v1";
927
+ const HEALTH_PATH = "/health";
927
928
  class CloudClient {
928
929
  fetch;
929
930
  config;
@@ -953,6 +954,26 @@ class CloudClient {
953
954
  const delays = [100, 200, 400, 800];
954
955
  return delays[Math.min(attempt, delays.length - 1)];
955
956
  }
957
+ /**
958
+ * Parse server response — handles all 5 response formats from Miaoda API:
959
+ * 1. { success: true, data: {} } — auth/user/config/admin modules
960
+ * 2. { success: false, error: { message } } — error from above modules
961
+ * 3. { data: {} } — usage/license/skill modules
962
+ * 4. bare object — subscription/llm/storage modules
963
+ * 5. { error: "..." } — bare error
964
+ */
965
+ parseResponse(raw) {
966
+ if (raw === null || raw === void 0) return raw;
967
+ const r = raw;
968
+ if (r.success === false) {
969
+ const msg = r.error?.message || r.message || r.error || "Unknown error";
970
+ throw new CloudClientError("API_ERROR", String(msg));
971
+ }
972
+ if (r.success === true && "data" in r) return r.data;
973
+ if (!("success" in r) && "data" in r) return r.data;
974
+ if (typeof r.error === "string" && !("data" in r)) throw new CloudClientError("API_ERROR", r.error);
975
+ return raw;
976
+ }
956
977
  /**
957
978
  * Handle fetch errors and convert to CloudClientError
958
979
  */
@@ -1014,7 +1035,7 @@ class CloudClient {
1014
1035
  async analyzeProject(request) {
1015
1036
  try {
1016
1037
  consola.debug("Analyzing project:", request.projectRoot);
1017
- const response = await this.fetch(`${API_PREFIX}/analysis/projects`, {
1038
+ const response = await this.fetch(`${API_PREFIX}/specs`, {
1018
1039
  method: "POST",
1019
1040
  body: request
1020
1041
  });
@@ -1078,7 +1099,7 @@ class CloudClient {
1078
1099
  async reportUsage(report) {
1079
1100
  try {
1080
1101
  consola.debug("Reporting usage:", report.metricType);
1081
- const response = await this.fetch(`${API_PREFIX}/telemetry/installation`, {
1102
+ const response = await this.fetch(`${API_PREFIX}/usage/current`, {
1082
1103
  method: "POST",
1083
1104
  body: report,
1084
1105
  timeout: 5e3
@@ -1105,7 +1126,7 @@ class CloudClient {
1105
1126
  async healthCheck() {
1106
1127
  try {
1107
1128
  consola.debug("Checking API health");
1108
- const response = await this.fetch(`${API_PREFIX}/health`, {
1129
+ const response = await this.fetch(HEALTH_PATH, {
1109
1130
  method: "GET"
1110
1131
  });
1111
1132
  consola.debug(`API health: ${response.status}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ccjk",
3
3
  "type": "module",
4
- "version": "12.0.10",
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": {