ccjk 9.3.7 → 9.3.9

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.
@@ -4,13 +4,12 @@ import { i18n, ensureI18nInitialized } from './index.mjs';
4
4
  import fs__default, { promises, readFileSync } from 'node:fs';
5
5
  import path__default, { join, dirname } from 'node:path';
6
6
  import { randomUUID, createHash } from 'node:crypto';
7
- import { ccjkSkills } from './ccjk-skills.mjs';
7
+ import { C as CloudClientError, a as createCloudClient, c as ccjkSkills } from './ccjk-skills.mjs';
8
8
  import { ccjkMcp } from './ccjk-mcp.mjs';
9
9
  import { ccjkAgents } from './ccjk-agents.mjs';
10
10
  import { ccjkHooks } from './ccjk-hooks.mjs';
11
11
  import { fileURLToPath } from 'node:url';
12
12
  import { a as analyzeProject } from '../shared/ccjk.DKM8a98N.mjs';
13
- import { ofetch } from 'ofetch';
14
13
  import { hash } from 'ohash';
15
14
  import { a as extractString } from '../shared/ccjk.AqnXPAzw.mjs';
16
15
  import 'node:process';
@@ -19,13 +18,8 @@ import 'i18next-fs-backend';
19
18
  import 'pathe';
20
19
  import 'node:os';
21
20
  import 'inquirer';
21
+ import 'ofetch';
22
22
  import '../shared/ccjk.Bdhyg3X-.mjs';
23
- import 'fs-extra';
24
- import 'fs';
25
- import 'path';
26
- import 'url';
27
- import 'module';
28
- import 'smol-toml';
29
23
  import './claude-config.mjs';
30
24
  import './constants.mjs';
31
25
  import './json-config.mjs';
@@ -34,292 +28,16 @@ import './fs-operations.mjs';
34
28
  import 'node:fs/promises';
35
29
  import './platform.mjs';
36
30
  import 'tinyexec';
31
+ import 'fs-extra';
32
+ import 'fs';
33
+ import 'path';
34
+ import 'url';
35
+ import 'module';
36
+ import 'smol-toml';
37
37
  import 'node:child_process';
38
38
  import 'node:util';
39
39
  import 'node:perf_hooks';
40
40
 
41
- class CloudClientError extends Error {
42
- /** Error type */
43
- type;
44
- /** HTTP status code if applicable */
45
- statusCode;
46
- /** Original error */
47
- originalError;
48
- constructor(type, message, statusCode, originalError) {
49
- super(message);
50
- this.name = "CloudClientError";
51
- this.type = type;
52
- this.statusCode = statusCode;
53
- this.originalError = originalError;
54
- }
55
- /**
56
- * Create error from HTTP response
57
- */
58
- static fromResponse(statusCode, message) {
59
- let type;
60
- if (statusCode === 401) type = "AUTH_ERROR";
61
- else if (statusCode === 429) type = "RATE_LIMIT_ERROR";
62
- else if (statusCode >= 500) type = "SERVER_ERROR";
63
- else if (statusCode >= 400) type = "API_ERROR";
64
- else type = "UNKNOWN_ERROR";
65
- return new CloudClientError(type, message, statusCode);
66
- }
67
- /**
68
- * Create network error
69
- */
70
- static network(error) {
71
- return new CloudClientError(
72
- "NETWORK_ERROR",
73
- error instanceof Error ? error.message : "Network connection failed",
74
- void 0,
75
- error
76
- );
77
- }
78
- /**
79
- * Create timeout error
80
- */
81
- static timeout(timeout) {
82
- return new CloudClientError(
83
- "TIMEOUT_ERROR",
84
- `Request timeout after ${timeout}ms`
85
- );
86
- }
87
- /**
88
- * Create validation error
89
- */
90
- static validation(message) {
91
- return new CloudClientError("VALIDATION_ERROR", message);
92
- }
93
- }
94
-
95
- class CloudClient {
96
- fetch;
97
- config;
98
- constructor(config) {
99
- this.config = {
100
- timeout: 1e4,
101
- enableRetry: true,
102
- maxRetries: 3,
103
- enableTelemetry: true,
104
- ...config
105
- };
106
- this.fetch = ofetch.create({
107
- baseURL: this.config.baseURL,
108
- timeout: this.config.timeout,
109
- headers: {
110
- "User-Agent": `CCJK/${this.config.version || "8.0.0"}`,
111
- ...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }
112
- },
113
- retry: this.config.enableRetry ? this.config.maxRetries : 0,
114
- retryDelay: (context) => this.calculateRetryDelay(context.options.retry || 0)
115
- });
116
- }
117
- /**
118
- * Calculate retry delay with exponential backoff
119
- */
120
- calculateRetryDelay(attempt) {
121
- const delays = [100, 200, 400, 800];
122
- return delays[Math.min(attempt, delays.length - 1)];
123
- }
124
- /**
125
- * Handle fetch errors and convert to CloudClientError
126
- */
127
- handleError(error, context) {
128
- if (error instanceof CloudClientError) {
129
- throw error;
130
- }
131
- if (error instanceof Error) {
132
- const errorMessage = error.message || "";
133
- if (errorMessage.includes("timeout") || errorMessage.includes("timed out")) {
134
- throw CloudClientError.timeout(this.config.timeout || 1e4);
135
- }
136
- if (errorMessage.includes("ECONNREFUSED") || errorMessage.includes("ENOTFOUND")) {
137
- throw CloudClientError.network(error);
138
- }
139
- const statusMatch = errorMessage.match(/(\d{3})\s+/);
140
- const statusCode = statusMatch ? parseInt(statusMatch[1]) : void 0;
141
- let responseDetails = errorMessage;
142
- try {
143
- if (errorMessage.includes(":")) {
144
- const parts = errorMessage.split(":");
145
- if (parts.length > 1) {
146
- responseDetails = parts.slice(1).join(":").trim();
147
- }
148
- }
149
- } catch {
150
- }
151
- consola.warn(`Cloud API error in ${context}:`, {
152
- statusCode,
153
- message: responseDetails,
154
- originalError: error
155
- });
156
- if (statusCode) {
157
- throw CloudClientError.fromResponse(statusCode, responseDetails);
158
- }
159
- throw new CloudClientError(
160
- "UNKNOWN_ERROR",
161
- `Unexpected error during ${context}: ${responseDetails}`,
162
- void 0,
163
- error
164
- );
165
- }
166
- consola.warn(`Cloud API error in ${context}:`, error);
167
- throw new CloudClientError(
168
- "UNKNOWN_ERROR",
169
- `Unexpected error during ${context}`,
170
- void 0,
171
- error
172
- );
173
- }
174
- /**
175
- * Analyze project and get recommendations
176
- *
177
- * POST /v1/analyze
178
- *
179
- * @param request - Project analysis request
180
- * @returns Project analysis response with recommendations
181
- */
182
- async analyzeProject(request) {
183
- try {
184
- consola.debug("Analyzing project:", request.projectRoot);
185
- const response = await this.fetch("/api/v8/analysis/projects", {
186
- method: "POST",
187
- body: request
188
- });
189
- consola.debug(`Received ${response.recommendations.length} recommendations`);
190
- return response;
191
- } catch (error) {
192
- this.handleError(error, "project analysis");
193
- }
194
- }
195
- /**
196
- * Get a single template by ID
197
- *
198
- * GET /v1/templates/:id
199
- *
200
- * @param id - Template identifier
201
- * @param language - Language for translations (optional)
202
- * @returns Template response
203
- */
204
- async getTemplate(id, language) {
205
- try {
206
- consola.debug("Fetching template:", id);
207
- const response = await this.fetch(`/v1/templates/${encodeURIComponent(id)}`, {
208
- method: "GET",
209
- params: language ? { language } : void 0
210
- });
211
- consola.debug(`Template ${id} fetched successfully`);
212
- return response;
213
- } catch (error) {
214
- this.handleError(error, `template fetch: ${id}`);
215
- }
216
- }
217
- /**
218
- * Get multiple templates in batch
219
- *
220
- * POST /v1/templates/batch
221
- *
222
- * @param request - Batch template request
223
- * @returns Batch template response
224
- */
225
- async getBatchTemplates(request) {
226
- try {
227
- consola.debug("Fetching batch templates:", request.ids.length);
228
- const response = await this.fetch("/api/v8/templates/batch", {
229
- method: "POST",
230
- body: request
231
- });
232
- consola.debug(`Fetched ${Object.keys(response.templates).length} templates`);
233
- return response;
234
- } catch (error) {
235
- this.handleError(error, "batch template fetch");
236
- }
237
- }
238
- /**
239
- * Report usage metrics
240
- *
241
- * POST /v1/report
242
- *
243
- * @param report - Usage report payload
244
- * @returns Usage report response
245
- */
246
- async reportUsage(report) {
247
- try {
248
- consola.debug("Reporting usage:", report.metricType);
249
- const response = await this.fetch("/api/v8/telemetry/installation", {
250
- method: "POST",
251
- body: report
252
- });
253
- consola.debug("Usage report accepted");
254
- return response;
255
- } catch (error) {
256
- consola.warn("Failed to report usage:", error);
257
- return {
258
- success: false,
259
- requestId: "",
260
- message: error instanceof Error ? error.message : "Unknown error"
261
- };
262
- }
263
- }
264
- /**
265
- * Check API health status
266
- *
267
- * GET /v1/health
268
- *
269
- * @returns Health check response
270
- */
271
- async healthCheck() {
272
- try {
273
- consola.debug("Checking API health");
274
- const response = await this.fetch("/api/v8/health", {
275
- method: "GET"
276
- });
277
- consola.debug(`API health: ${response.status}`);
278
- return response;
279
- } catch (error) {
280
- this.handleError(error, "health check");
281
- }
282
- }
283
- /**
284
- * Update client configuration
285
- *
286
- * @param config - Partial configuration to update
287
- */
288
- updateConfig(config) {
289
- this.config = { ...this.config, ...config };
290
- if (config.baseURL || config.timeout || config.apiKey) {
291
- this.fetch = ofetch.create({
292
- baseURL: this.config.baseURL,
293
- timeout: this.config.timeout,
294
- headers: {
295
- "User-Agent": `CCJK/${this.config.version || "8.0.0"}`,
296
- ...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }
297
- },
298
- retry: this.config.enableRetry ? this.config.maxRetries : 0,
299
- retryDelay: (context) => this.calculateRetryDelay(context.options.retry || 0)
300
- });
301
- }
302
- }
303
- /**
304
- * Get current configuration
305
- */
306
- getConfig() {
307
- return { ...this.config };
308
- }
309
- }
310
- function createCloudClient(config) {
311
- return new CloudClient({
312
- baseURL: "https://api.claudehome.cn",
313
- timeout: 1e4,
314
- version: "8.0.0",
315
- enableCache: true,
316
- enableRetry: true,
317
- maxRetries: 3,
318
- enableTelemetry: true,
319
- ...config
320
- });
321
- }
322
-
323
41
  class CloudCache {
324
42
  memoryCache;
325
43
  cacheDir;
@@ -7,7 +7,7 @@ import { performance } from 'node:perf_hooks';
7
7
  import { promises } from 'node:fs';
8
8
  import { join } from 'pathe';
9
9
  import dayjs from 'dayjs';
10
- import { ccjkSkills } from './ccjk-skills.mjs';
10
+ import { c as ccjkSkills } from './ccjk-skills.mjs';
11
11
  import { ccjkMcp } from './ccjk-mcp.mjs';
12
12
  import { ccjkAgents } from './ccjk-agents.mjs';
13
13
  import { ccjkHooks } from './ccjk-hooks.mjs';
@@ -6,19 +6,290 @@ import consola from 'consola';
6
6
  import inquirer from 'inquirer';
7
7
  import { i18n } from './index.mjs';
8
8
  import { a as analyzeProject, g as getTemplatesClient } from '../shared/ccjk.DKM8a98N.mjs';
9
+ import { ofetch } from 'ofetch';
9
10
  import { g as getSkillParser } from '../shared/ccjk.Bdhyg3X-.mjs';
10
- import 'node:process';
11
- import 'node:url';
12
- import 'i18next';
13
- import 'i18next-fs-backend';
14
- import 'pathe';
15
- import 'fs-extra';
16
- import 'fs';
17
- import 'path';
18
- import 'url';
19
- import 'module';
20
- import 'smol-toml';
21
- import 'ofetch';
11
+
12
+ class CloudClientError extends Error {
13
+ /** Error type */
14
+ type;
15
+ /** HTTP status code if applicable */
16
+ statusCode;
17
+ /** Original error */
18
+ originalError;
19
+ constructor(type, message, statusCode, originalError) {
20
+ super(message);
21
+ this.name = "CloudClientError";
22
+ this.type = type;
23
+ this.statusCode = statusCode;
24
+ this.originalError = originalError;
25
+ }
26
+ /**
27
+ * Create error from HTTP response
28
+ */
29
+ static fromResponse(statusCode, message) {
30
+ let type;
31
+ if (statusCode === 401) type = "AUTH_ERROR";
32
+ else if (statusCode === 429) type = "RATE_LIMIT_ERROR";
33
+ else if (statusCode >= 500) type = "SERVER_ERROR";
34
+ else if (statusCode >= 400) type = "API_ERROR";
35
+ else type = "UNKNOWN_ERROR";
36
+ return new CloudClientError(type, message, statusCode);
37
+ }
38
+ /**
39
+ * Create network error
40
+ */
41
+ static network(error) {
42
+ return new CloudClientError(
43
+ "NETWORK_ERROR",
44
+ error instanceof Error ? error.message : "Network connection failed",
45
+ void 0,
46
+ error
47
+ );
48
+ }
49
+ /**
50
+ * Create timeout error
51
+ */
52
+ static timeout(timeout) {
53
+ return new CloudClientError(
54
+ "TIMEOUT_ERROR",
55
+ `Request timeout after ${timeout}ms`
56
+ );
57
+ }
58
+ /**
59
+ * Create validation error
60
+ */
61
+ static validation(message) {
62
+ return new CloudClientError("VALIDATION_ERROR", message);
63
+ }
64
+ }
65
+
66
+ class CloudClient {
67
+ fetch;
68
+ config;
69
+ constructor(config) {
70
+ this.config = {
71
+ timeout: 1e4,
72
+ enableRetry: true,
73
+ maxRetries: 3,
74
+ enableTelemetry: true,
75
+ ...config
76
+ };
77
+ this.fetch = ofetch.create({
78
+ baseURL: this.config.baseURL,
79
+ timeout: this.config.timeout,
80
+ headers: {
81
+ "User-Agent": `CCJK/${this.config.version || "8.0.0"}`,
82
+ ...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }
83
+ },
84
+ retry: this.config.enableRetry ? this.config.maxRetries : 0,
85
+ retryDelay: (context) => this.calculateRetryDelay(context.options.retry || 0)
86
+ });
87
+ }
88
+ /**
89
+ * Calculate retry delay with exponential backoff
90
+ */
91
+ calculateRetryDelay(attempt) {
92
+ const delays = [100, 200, 400, 800];
93
+ return delays[Math.min(attempt, delays.length - 1)];
94
+ }
95
+ /**
96
+ * Handle fetch errors and convert to CloudClientError
97
+ */
98
+ handleError(error, context) {
99
+ if (error instanceof CloudClientError) {
100
+ throw error;
101
+ }
102
+ if (error instanceof Error) {
103
+ const errorMessage = error.message || "";
104
+ if (errorMessage.includes("timeout") || errorMessage.includes("timed out")) {
105
+ throw CloudClientError.timeout(this.config.timeout || 1e4);
106
+ }
107
+ if (errorMessage.includes("ECONNREFUSED") || errorMessage.includes("ENOTFOUND")) {
108
+ throw CloudClientError.network(error);
109
+ }
110
+ const statusMatch = errorMessage.match(/(\d{3})\s+/);
111
+ const statusCode = statusMatch ? parseInt(statusMatch[1]) : void 0;
112
+ let responseDetails = errorMessage;
113
+ try {
114
+ if (errorMessage.includes(":")) {
115
+ const parts = errorMessage.split(":");
116
+ if (parts.length > 1) {
117
+ responseDetails = parts.slice(1).join(":").trim();
118
+ }
119
+ }
120
+ } catch {
121
+ }
122
+ consola.warn(`Cloud API error in ${context}:`, {
123
+ statusCode,
124
+ message: responseDetails,
125
+ originalError: error
126
+ });
127
+ if (statusCode) {
128
+ throw CloudClientError.fromResponse(statusCode, responseDetails);
129
+ }
130
+ throw new CloudClientError(
131
+ "UNKNOWN_ERROR",
132
+ `Unexpected error during ${context}: ${responseDetails}`,
133
+ void 0,
134
+ error
135
+ );
136
+ }
137
+ consola.warn(`Cloud API error in ${context}:`, error);
138
+ throw new CloudClientError(
139
+ "UNKNOWN_ERROR",
140
+ `Unexpected error during ${context}`,
141
+ void 0,
142
+ error
143
+ );
144
+ }
145
+ /**
146
+ * Analyze project and get recommendations
147
+ *
148
+ * POST /v1/analyze
149
+ *
150
+ * @param request - Project analysis request
151
+ * @returns Project analysis response with recommendations
152
+ */
153
+ async analyzeProject(request) {
154
+ try {
155
+ consola.debug("Analyzing project:", request.projectRoot);
156
+ const response = await this.fetch("/api/v8/analysis/projects", {
157
+ method: "POST",
158
+ body: request
159
+ });
160
+ consola.debug(`Received ${response.recommendations.length} recommendations`);
161
+ return response;
162
+ } catch (error) {
163
+ this.handleError(error, "project analysis");
164
+ }
165
+ }
166
+ /**
167
+ * Get a single template by ID
168
+ *
169
+ * GET /v1/templates/:id
170
+ *
171
+ * @param id - Template identifier
172
+ * @param language - Language for translations (optional)
173
+ * @returns Template response
174
+ */
175
+ async getTemplate(id, language) {
176
+ try {
177
+ consola.debug("Fetching template:", id);
178
+ const response = await this.fetch(`/v1/templates/${encodeURIComponent(id)}`, {
179
+ method: "GET",
180
+ params: language ? { language } : void 0
181
+ });
182
+ consola.debug(`Template ${id} fetched successfully`);
183
+ return response;
184
+ } catch (error) {
185
+ this.handleError(error, `template fetch: ${id}`);
186
+ }
187
+ }
188
+ /**
189
+ * Get multiple templates in batch
190
+ *
191
+ * POST /v1/templates/batch
192
+ *
193
+ * @param request - Batch template request
194
+ * @returns Batch template response
195
+ */
196
+ async getBatchTemplates(request) {
197
+ try {
198
+ consola.debug("Fetching batch templates:", request.ids.length);
199
+ const response = await this.fetch("/api/v8/templates/batch", {
200
+ method: "POST",
201
+ body: request
202
+ });
203
+ consola.debug(`Fetched ${Object.keys(response.templates).length} templates`);
204
+ return response;
205
+ } catch (error) {
206
+ this.handleError(error, "batch template fetch");
207
+ }
208
+ }
209
+ /**
210
+ * Report usage metrics
211
+ *
212
+ * POST /v1/report
213
+ *
214
+ * @param report - Usage report payload
215
+ * @returns Usage report response
216
+ */
217
+ async reportUsage(report) {
218
+ try {
219
+ consola.debug("Reporting usage:", report.metricType);
220
+ const response = await this.fetch("/api/v8/telemetry/installation", {
221
+ method: "POST",
222
+ body: report
223
+ });
224
+ consola.debug("Usage report accepted");
225
+ return response;
226
+ } catch (error) {
227
+ consola.warn("Failed to report usage:", error);
228
+ return {
229
+ success: false,
230
+ requestId: "",
231
+ message: error instanceof Error ? error.message : "Unknown error"
232
+ };
233
+ }
234
+ }
235
+ /**
236
+ * Check API health status
237
+ *
238
+ * GET /v1/health
239
+ *
240
+ * @returns Health check response
241
+ */
242
+ async healthCheck() {
243
+ try {
244
+ consola.debug("Checking API health");
245
+ const response = await this.fetch("/api/v8/health", {
246
+ method: "GET"
247
+ });
248
+ consola.debug(`API health: ${response.status}`);
249
+ return response;
250
+ } catch (error) {
251
+ this.handleError(error, "health check");
252
+ }
253
+ }
254
+ /**
255
+ * Update client configuration
256
+ *
257
+ * @param config - Partial configuration to update
258
+ */
259
+ updateConfig(config) {
260
+ this.config = { ...this.config, ...config };
261
+ if (config.baseURL || config.timeout || config.apiKey) {
262
+ this.fetch = ofetch.create({
263
+ baseURL: this.config.baseURL,
264
+ timeout: this.config.timeout,
265
+ headers: {
266
+ "User-Agent": `CCJK/${this.config.version || "8.0.0"}`,
267
+ ...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }
268
+ },
269
+ retry: this.config.enableRetry ? this.config.maxRetries : 0,
270
+ retryDelay: (context) => this.calculateRetryDelay(context.options.retry || 0)
271
+ });
272
+ }
273
+ }
274
+ /**
275
+ * Get current configuration
276
+ */
277
+ getConfig() {
278
+ return { ...this.config };
279
+ }
280
+ }
281
+ function createCloudClient(config) {
282
+ return new CloudClient({
283
+ baseURL: "https://api.claudehome.cn",
284
+ timeout: 1e4,
285
+ version: "8.0.0",
286
+ enableCache: true,
287
+ enableRetry: true,
288
+ maxRetries: 3,
289
+ enableTelemetry: true,
290
+ ...config
291
+ });
292
+ }
22
293
 
23
294
  async function ccjkSkills(options = {}) {
24
295
  const logger = consola.withTag("ccjk:skills");
@@ -408,6 +679,18 @@ async function installSkills(skills, options) {
408
679
  }
409
680
  async function loadSkillTemplate(templatePath) {
410
681
  try {
682
+ const isCloudTemplate = templatePath.startsWith("skill_") || templatePath.startsWith("tpl_");
683
+ if (isCloudTemplate) {
684
+ try {
685
+ const cloudClient = createCloudClient();
686
+ const template = await cloudClient.getTemplate(templatePath);
687
+ if (template && template.content) {
688
+ return template.content;
689
+ }
690
+ } catch (error) {
691
+ consola.warn(`Failed to fetch cloud template ${templatePath}:`, error);
692
+ }
693
+ }
411
694
  const localPath = join(process.cwd(), "templates", "skills", templatePath);
412
695
  if (await fileExists(localPath)) {
413
696
  return await promises.readFile(localPath, "utf-8");
@@ -466,4 +749,9 @@ function getCategoryIcon(category) {
466
749
  return icons[category] || "\u{1F4E6}";
467
750
  }
468
751
 
469
- export { ccjkSkills };
752
+ const ccjkSkills$1 = {
753
+ __proto__: null,
754
+ ccjkSkills: ccjkSkills
755
+ };
756
+
757
+ export { CloudClientError as C, createCloudClient as a, ccjkSkills$1 as b, ccjkSkills as c };
@@ -44,6 +44,7 @@ import './auto-updater.mjs';
44
44
  import './version-checker.mjs';
45
45
  import 'node:path';
46
46
  import './installer.mjs';
47
+ import '../shared/ccjk.DE91nClQ.mjs';
47
48
  import './commands.mjs';
48
49
  import './claude-code-config-manager.mjs';
49
50
  import './config-switch.mjs';
@@ -0,0 +1,195 @@
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import process__default from 'node:process';
4
+ import { join } from 'pathe';
5
+ import { i as installSuperpowers } from '../shared/ccjk.DE91nClQ.mjs';
6
+ import 'node:child_process';
7
+ import 'node:fs/promises';
8
+ import 'node:util';
9
+ import './index.mjs';
10
+ import 'node:url';
11
+ import 'i18next';
12
+ import 'i18next-fs-backend';
13
+
14
+ const CORE_SKILLS = [
15
+ "agent-browser",
16
+ "tdd",
17
+ "debugging",
18
+ "code-review",
19
+ "git-worktrees"
20
+ ];
21
+
22
+ function getSuperpowersDir$1() {
23
+ return join(homedir(), ".claude", "plugins", "superpowers");
24
+ }
25
+ function isSuperpowersInstalled() {
26
+ const superpowersDir = getSuperpowersDir$1();
27
+ return existsSync(superpowersDir) && existsSync(join(superpowersDir, "skills"));
28
+ }
29
+ function areCoreSkillsInstalled() {
30
+ const skillsDir = join(getSuperpowersDir$1(), "skills");
31
+ if (!existsSync(skillsDir)) {
32
+ return false;
33
+ }
34
+ for (const skill of CORE_SKILLS) {
35
+ const skillPath = join(skillsDir, skill);
36
+ if (!existsSync(skillPath) || !existsSync(join(skillPath, "skill.json"))) {
37
+ return false;
38
+ }
39
+ }
40
+ return true;
41
+ }
42
+ async function autoInstallSuperpowers(lang = "zh-CN") {
43
+ try {
44
+ if (isSuperpowersInstalled() && areCoreSkillsInstalled()) {
45
+ return true;
46
+ }
47
+ const result = await installSuperpowers({
48
+ lang,
49
+ skipPrompt: true
50
+ // Skip user prompts for silent installation
51
+ });
52
+ if (!result.success) {
53
+ if (process__default.env.DEBUG) {
54
+ console.error("[CCJK Zero-Config] Installation failed:", result.error || result.message);
55
+ }
56
+ return false;
57
+ }
58
+ return isSuperpowersInstalled() && areCoreSkillsInstalled();
59
+ } catch (error) {
60
+ if (process__default.env.DEBUG) {
61
+ console.error("[CCJK Zero-Config] Auto-install failed:", error);
62
+ }
63
+ return false;
64
+ }
65
+ }
66
+
67
+ function getSkillsDir() {
68
+ return join(homedir(), ".claude", "plugins", "superpowers", "skills");
69
+ }
70
+ function isSkillInstalled(skillName) {
71
+ const skillPath = join(getSkillsDir(), skillName);
72
+ return existsSync(skillPath) && existsSync(join(skillPath, "skill.json"));
73
+ }
74
+ async function loadSkill(skillName) {
75
+ try {
76
+ if (!isSkillInstalled(skillName)) {
77
+ return {
78
+ skill: skillName,
79
+ success: false,
80
+ error: "Skill not installed"
81
+ };
82
+ }
83
+ const skillJsonPath = join(getSkillsDir(), skillName, "skill.json");
84
+ const skillJson = JSON.parse(readFileSync(skillJsonPath, "utf-8"));
85
+ if (!skillJson.name || !skillJson.version) {
86
+ return {
87
+ skill: skillName,
88
+ success: false,
89
+ error: "Invalid skill.json format"
90
+ };
91
+ }
92
+ return {
93
+ skill: skillName,
94
+ success: true
95
+ };
96
+ } catch (error) {
97
+ return {
98
+ skill: skillName,
99
+ success: false,
100
+ error: error instanceof Error ? error.message : "Unknown error"
101
+ };
102
+ }
103
+ }
104
+ async function loadCoreSkills(_lang = "zh-CN") {
105
+ const results = await Promise.all(
106
+ CORE_SKILLS.map((skill) => loadSkill(skill))
107
+ );
108
+ if (process__default.env.DEBUG) {
109
+ const successful = results.filter((r) => r.success);
110
+ const failed = results.filter((r) => !r.success);
111
+ console.log(`[Zero-Config] Loaded ${successful.length}/${CORE_SKILLS.length} core skills`);
112
+ if (failed.length > 0) {
113
+ console.log(`[Zero-Config] Failed skills: ${failed.map((r) => r.skill).join(", ")}`);
114
+ }
115
+ }
116
+ return results;
117
+ }
118
+
119
+ function getActivationStatePath() {
120
+ return join(homedir(), ".claude", "plugins", "superpowers", ".activation-state.json");
121
+ }
122
+ function getSuperpowersDir() {
123
+ return join(homedir(), ".claude", "plugins", "superpowers");
124
+ }
125
+ function loadActivationState() {
126
+ try {
127
+ const statePath = getActivationStatePath();
128
+ if (!existsSync(statePath)) {
129
+ return null;
130
+ }
131
+ const stateJson = readFileSync(statePath, "utf-8");
132
+ return JSON.parse(stateJson);
133
+ } catch (error) {
134
+ if (process__default.env.DEBUG) {
135
+ console.error("[Zero-Config] Failed to load activation state:", error);
136
+ }
137
+ return null;
138
+ }
139
+ }
140
+ function saveActivationState(status) {
141
+ try {
142
+ const statePath = getActivationStatePath();
143
+ writeFileSync(statePath, JSON.stringify(status, null, 2), "utf-8");
144
+ } catch (error) {
145
+ if (process__default.env.DEBUG) {
146
+ console.error("[Zero-Config] Failed to save activation state:", error);
147
+ }
148
+ }
149
+ }
150
+ function checkActivationStatus() {
151
+ const superpowersInstalled = existsSync(getSuperpowersDir());
152
+ const savedState = loadActivationState();
153
+ if (savedState) {
154
+ return savedState;
155
+ }
156
+ return {
157
+ isInstalled: superpowersInstalled,
158
+ coreSkillsLoaded: false,
159
+ loadedSkills: [],
160
+ needsActivation: true,
161
+ lastActivation: void 0
162
+ };
163
+ }
164
+ async function activateSuperpowers(lang = "zh-CN") {
165
+ const currentStatus = checkActivationStatus();
166
+ if (!currentStatus.needsActivation) {
167
+ return currentStatus;
168
+ }
169
+ if (!currentStatus.isInstalled) {
170
+ const installSuccess = await autoInstallSuperpowers(lang);
171
+ if (!installSuccess) {
172
+ return {
173
+ isInstalled: false,
174
+ coreSkillsLoaded: false,
175
+ loadedSkills: [],
176
+ needsActivation: true,
177
+ lastActivation: void 0
178
+ };
179
+ }
180
+ }
181
+ const loadResults = await loadCoreSkills(lang);
182
+ const successfulLoads = loadResults.filter((r) => r.success);
183
+ const allCoreSkillsLoaded = successfulLoads.length === loadResults.length;
184
+ const newStatus = {
185
+ isInstalled: true,
186
+ coreSkillsLoaded: allCoreSkillsLoaded,
187
+ loadedSkills: successfulLoads.map((r) => r.skill),
188
+ needsActivation: false,
189
+ lastActivation: (/* @__PURE__ */ new Date()).toISOString()
190
+ };
191
+ saveActivationState(newStatus);
192
+ return newStatus;
193
+ }
194
+
195
+ export { activateSuperpowers, autoInstallSuperpowers, checkActivationStatus, loadCoreSkills, loadSkill };
@@ -24,21 +24,19 @@ import { h as handleExitPromptError, a as handleGeneralError } from '../shared/c
24
24
  import { getInstallationStatus, installClaudeCode } from './installer.mjs';
25
25
  import { a as addNumbersToChoices } from '../shared/ccjk.BFQ7yr5S.mjs';
26
26
  import { resolveAiOutputLanguage } from './prompts.mjs';
27
- import { readFile } from 'node:fs/promises';
28
- import { homedir } from 'node:os';
29
- import { join } from 'pathe';
27
+ import { c as checkSuperpowersInstalled, i as installSuperpowers } from '../shared/ccjk.DE91nClQ.mjs';
30
28
  import { p as promptBoolean } from '../shared/ccjk.DHbrGcgg.mjs';
31
29
  import { checkClaudeCodeVersionAndPrompt } from './version-checker.mjs';
32
30
 
33
- const execAsync$2 = promisify(exec);
31
+ const execAsync$1 = promisify(exec);
34
32
  async function isCcrInstalled() {
35
33
  let commandExists = false;
36
34
  try {
37
- await execAsync$2("ccr version");
35
+ await execAsync$1("ccr version");
38
36
  commandExists = true;
39
37
  } catch {
40
38
  try {
41
- await execAsync$2("which ccr");
39
+ await execAsync$1("which ccr");
42
40
  commandExists = true;
43
41
  } catch {
44
42
  commandExists = false;
@@ -46,7 +44,7 @@ async function isCcrInstalled() {
46
44
  }
47
45
  let hasCorrectPackage = false;
48
46
  try {
49
- await execAsync$2("npm list -g @musistudio/claude-code-router");
47
+ await execAsync$1("npm list -g @musistudio/claude-code-router");
50
48
  hasCorrectPackage = true;
51
49
  } catch {
52
50
  hasCorrectPackage = false;
@@ -66,10 +64,10 @@ async function installCcr() {
66
64
  }
67
65
  if (isInstalled && !hasCorrectPackage) {
68
66
  try {
69
- await execAsync$2("npm list -g claude-code-router");
67
+ await execAsync$1("npm list -g claude-code-router");
70
68
  console.log(ansis.yellow(`\u26A0 ${i18n.t("ccr:detectedIncorrectPackage")}`));
71
69
  try {
72
- await execAsync$2("npm uninstall -g claude-code-router");
70
+ await execAsync$1("npm uninstall -g claude-code-router");
73
71
  console.log(ansis.green(`\u2714 ${i18n.t("ccr:uninstalledIncorrectPackage")}`));
74
72
  } catch {
75
73
  console.log(ansis.yellow(`\u26A0 ${i18n.t("ccr:failedToUninstallIncorrectPackage")}`));
@@ -84,7 +82,7 @@ async function installCcr() {
84
82
  if (usedSudo) {
85
83
  console.log(ansis.yellow(`\u2139 ${i18n.t("installation:usingSudo")}`));
86
84
  }
87
- await execAsync$2([command, ...args].join(" "));
85
+ await execAsync$1([command, ...args].join(" "));
88
86
  console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrInstallSuccess")}`));
89
87
  } catch (error) {
90
88
  if (error.message?.includes("EEXIST")) {
@@ -142,10 +140,10 @@ function hasCCometixLineConfig() {
142
140
  }
143
141
  }
144
142
 
145
- const execAsync$1 = promisify(exec);
143
+ const execAsync = promisify(exec);
146
144
  async function isCometixLineInstalled() {
147
145
  try {
148
- await execAsync$1(COMETIX_COMMANDS.CHECK_INSTALL);
146
+ await execAsync(COMETIX_COMMANDS.CHECK_INSTALL);
149
147
  return true;
150
148
  } catch {
151
149
  return false;
@@ -159,7 +157,7 @@ async function installCometixLine() {
159
157
  if (usedSudo) {
160
158
  console.log(ansis.yellow(`\u2139 ${i18n.t("installation:usingSudo")}`));
161
159
  }
162
- await execAsync$1([command, ...args].join(" "));
160
+ await execAsync([command, ...args].join(" "));
163
161
  };
164
162
  const isInstalled = await isCometixLineInstalled();
165
163
  if (isInstalled) {
@@ -200,102 +198,6 @@ async function installCometixLine() {
200
198
  }
201
199
  }
202
200
 
203
- const execAsync = promisify(exec);
204
- function getClaudePluginDir() {
205
- return join(homedir(), ".claude", "plugins");
206
- }
207
- function getSuperpowersPath() {
208
- return join(getClaudePluginDir(), "superpowers");
209
- }
210
- async function checkSuperpowersInstalled() {
211
- const superpowersPath = getSuperpowersPath();
212
- if (!existsSync(superpowersPath)) {
213
- return { installed: false };
214
- }
215
- try {
216
- const packageJsonPath = join(superpowersPath, "package.json");
217
- if (existsSync(packageJsonPath)) {
218
- const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
219
- const skillsDir = join(superpowersPath, "skills");
220
- let skillCount = 0;
221
- if (existsSync(skillsDir)) {
222
- const { readdir } = await import('node:fs/promises');
223
- const entries = await readdir(skillsDir, { withFileTypes: true });
224
- skillCount = entries.filter((e) => e.isDirectory()).length;
225
- }
226
- return {
227
- installed: true,
228
- version: packageJson.version,
229
- skillCount,
230
- path: superpowersPath
231
- };
232
- }
233
- return { installed: true, path: superpowersPath };
234
- } catch {
235
- return { installed: true, path: superpowersPath };
236
- }
237
- }
238
- async function installSuperpowers(options) {
239
- try {
240
- const status = await checkSuperpowersInstalled();
241
- if (status.installed) {
242
- return {
243
- success: true,
244
- message: i18n.t("superpowers:alreadyInstalled")
245
- };
246
- }
247
- const result = await installSuperpowersViaGit();
248
- if (result.success && options.enableCloudSync && options.cloudProvider && options.cloudCredentials) {
249
- try {
250
- const { configureCloudSync } = await import('./cloud-sync.mjs');
251
- await configureCloudSync(options.cloudProvider, options.cloudCredentials);
252
- console.log(i18n.t("superpowers:cloudSync.configured"));
253
- } catch (error) {
254
- console.warn(i18n.t("superpowers:cloudSync.configFailed"), error);
255
- }
256
- }
257
- return result;
258
- } catch (error) {
259
- const errorMessage = error instanceof Error ? error.message : String(error);
260
- return {
261
- success: false,
262
- message: i18n.t("superpowers:installFailed"),
263
- error: errorMessage
264
- };
265
- }
266
- }
267
- async function installSuperpowersViaGit() {
268
- try {
269
- const pluginDir = getClaudePluginDir();
270
- const superpowersPath = getSuperpowersPath();
271
- const { mkdir } = await import('node:fs/promises');
272
- await mkdir(pluginDir, { recursive: true });
273
- console.log(i18n.t("superpowers:cloning"));
274
- await execAsync(
275
- `git clone https://github.com/obra/superpowers.git "${superpowersPath}"`,
276
- { timeout: 12e4 }
277
- );
278
- const status = await checkSuperpowersInstalled();
279
- if (status.installed) {
280
- return {
281
- success: true,
282
- message: i18n.t("superpowers:installSuccess")
283
- };
284
- }
285
- return {
286
- success: false,
287
- message: i18n.t("superpowers:installFailed")
288
- };
289
- } catch (error) {
290
- const errorMessage = error instanceof Error ? error.message : String(error);
291
- return {
292
- success: false,
293
- message: i18n.t("superpowers:installFailed"),
294
- error: errorMessage
295
- };
296
- }
297
- }
298
-
299
201
  async function validateSkipPromptOptions(options) {
300
202
  if (options.allLang) {
301
203
  if (options.allLang === "zh-CN" || options.allLang === "en") {
@@ -22,7 +22,7 @@ import { ClaudeCodeConfigManager } from './claude-code-config-manager.mjs';
22
22
  import { configSwitchCommand } from './config-switch.mjs';
23
23
  import { ccjkAgents } from './ccjk-agents.mjs';
24
24
  import { ccjkMcp } from './ccjk-mcp.mjs';
25
- import { ccjkSkills } from './ccjk-skills.mjs';
25
+ import { c as ccjkSkills } from './ccjk-skills.mjs';
26
26
  import { checkUpdates } from './check-updates.mjs';
27
27
  import { doctor } from './doctor.mjs';
28
28
  import { uninstall } from './uninstall.mjs';
@@ -1,4 +1,4 @@
1
- const version = "9.3.7";
1
+ const version = "9.3.9";
2
2
  const homepage = "https://github.com/miounet11/ccjk";
3
3
 
4
4
  export { homepage, version };
@@ -42,6 +42,7 @@ import '../shared/ccjk.SIo9I8q3.mjs';
42
42
  import '../shared/ccjk.KfIN1Sqj.mjs';
43
43
  import '../shared/ccjk.DvIrK0wz.mjs';
44
44
  import './installer.mjs';
45
+ import '../shared/ccjk.DE91nClQ.mjs';
45
46
 
46
47
  function displayHeader() {
47
48
  console.log("");
package/dist/cli.mjs CHANGED
@@ -1171,7 +1171,7 @@ ${chalk.yellow("By Status:")}`);
1171
1171
  ],
1172
1172
  loader: async () => {
1173
1173
  return async (options) => {
1174
- const { ccjkSkills } = await import('./chunks/ccjk-skills.mjs');
1174
+ const { ccjkSkills } = await import('./chunks/ccjk-skills.mjs').then(function (n) { return n.b; });
1175
1175
  await ccjkSkills({
1176
1176
  list: options.list,
1177
1177
  install: options.install,
@@ -1257,7 +1257,7 @@ ${chalk.yellow("By Status:")}`);
1257
1257
  ],
1258
1258
  loader: async () => {
1259
1259
  return async (options) => {
1260
- const { ccjkSkills } = await import('./chunks/ccjk-skills.mjs');
1260
+ const { ccjkSkills } = await import('./chunks/ccjk-skills.mjs').then(function (n) { return n.b; });
1261
1261
  await ccjkSkills({
1262
1262
  interactive: options.interactive !== false,
1263
1263
  category: options.category,
@@ -1698,6 +1698,8 @@ function bootstrapCloudServices() {
1698
1698
  await autoBootstrap();
1699
1699
  const { autoUpgrade } = await import('./chunks/silent-updater.mjs');
1700
1700
  await autoUpgrade();
1701
+ const { activateSuperpowers } = await import('./chunks/index3.mjs');
1702
+ await activateSuperpowers("zh-CN");
1701
1703
  } catch {
1702
1704
  }
1703
1705
  });
@@ -0,0 +1,111 @@
1
+ import { exec } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import { readFile } from 'node:fs/promises';
4
+ import { homedir } from 'node:os';
5
+ import { promisify } from 'node:util';
6
+ import { join } from 'pathe';
7
+ import { i18n } from '../chunks/index.mjs';
8
+
9
+ const execAsync = promisify(exec);
10
+ function getClaudePluginDir() {
11
+ return join(homedir(), ".claude", "plugins");
12
+ }
13
+ function getSuperpowersPath() {
14
+ return join(getClaudePluginDir(), "superpowers");
15
+ }
16
+ async function checkSuperpowersInstalled() {
17
+ const superpowersPath = getSuperpowersPath();
18
+ if (!existsSync(superpowersPath)) {
19
+ return { installed: false };
20
+ }
21
+ try {
22
+ const packageJsonPath = join(superpowersPath, "package.json");
23
+ if (existsSync(packageJsonPath)) {
24
+ const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
25
+ const skillsDir = join(superpowersPath, "skills");
26
+ let skillCount = 0;
27
+ if (existsSync(skillsDir)) {
28
+ const { readdir } = await import('node:fs/promises');
29
+ const entries = await readdir(skillsDir, { withFileTypes: true });
30
+ skillCount = entries.filter((e) => e.isDirectory()).length;
31
+ }
32
+ return {
33
+ installed: true,
34
+ version: packageJson.version,
35
+ skillCount,
36
+ path: superpowersPath
37
+ };
38
+ }
39
+ return { installed: true, path: superpowersPath };
40
+ } catch {
41
+ return { installed: true, path: superpowersPath };
42
+ }
43
+ }
44
+ async function installSuperpowers(options) {
45
+ try {
46
+ const status = await checkSuperpowersInstalled();
47
+ if (status.installed) {
48
+ return {
49
+ success: true,
50
+ message: i18n.t("superpowers:alreadyInstalled")
51
+ };
52
+ }
53
+ const result = await installSuperpowersViaGit(options.skipPrompt);
54
+ if (result.success && options.enableCloudSync && options.cloudProvider && options.cloudCredentials) {
55
+ try {
56
+ const { configureCloudSync } = await import('../chunks/cloud-sync.mjs');
57
+ await configureCloudSync(options.cloudProvider, options.cloudCredentials);
58
+ if (!options.skipPrompt) {
59
+ console.log(i18n.t("superpowers:cloudSync.configured"));
60
+ }
61
+ } catch (error) {
62
+ if (!options.skipPrompt) {
63
+ console.warn(i18n.t("superpowers:cloudSync.configFailed"), error);
64
+ }
65
+ }
66
+ }
67
+ return result;
68
+ } catch (error) {
69
+ const errorMessage = error instanceof Error ? error.message : String(error);
70
+ return {
71
+ success: false,
72
+ message: i18n.t("superpowers:installFailed"),
73
+ error: errorMessage
74
+ };
75
+ }
76
+ }
77
+ async function installSuperpowersViaGit(silent = false) {
78
+ try {
79
+ const pluginDir = getClaudePluginDir();
80
+ const superpowersPath = getSuperpowersPath();
81
+ const { mkdir } = await import('node:fs/promises');
82
+ await mkdir(pluginDir, { recursive: true });
83
+ if (!silent) {
84
+ console.log(i18n.t("superpowers:cloning"));
85
+ }
86
+ await execAsync(
87
+ `git clone https://github.com/obra/superpowers.git "${superpowersPath}"`,
88
+ { timeout: 12e4 }
89
+ );
90
+ const status = await checkSuperpowersInstalled();
91
+ if (status.installed) {
92
+ return {
93
+ success: true,
94
+ message: i18n.t("superpowers:installSuccess")
95
+ };
96
+ }
97
+ return {
98
+ success: false,
99
+ message: i18n.t("superpowers:installFailed")
100
+ };
101
+ } catch (error) {
102
+ const errorMessage = error instanceof Error ? error.message : String(error);
103
+ return {
104
+ success: false,
105
+ message: i18n.t("superpowers:installFailed"),
106
+ error: errorMessage
107
+ };
108
+ }
109
+ }
110
+
111
+ export { checkSuperpowersInstalled as c, installSuperpowers as i };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ccjk",
3
3
  "type": "module",
4
- "version": "9.3.7",
4
+ "version": "9.3.9",
5
5
  "packageManager": "pnpm@10.17.1",
6
6
  "description": "CCJK v9.0.0 - Revolutionary AI Development Platform with Enterprise Security, Streaming Cloud Sync, CRDT Conflict Resolution, and Unified V3 Architecture",
7
7
  "author": {