ccjk 2.3.2 → 2.4.2

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.
Files changed (37) hide show
  1. package/README.md +270 -444
  2. package/README.zh-CN.md +273 -447
  3. package/dist/chunks/api-providers.mjs +5 -35
  4. package/dist/chunks/auto-bootstrap.mjs +1 -1
  5. package/dist/chunks/ccr.mjs +5 -2
  6. package/dist/chunks/claude-wrapper.mjs +442 -0
  7. package/dist/chunks/cloud-sync.mjs +29 -0
  8. package/dist/chunks/constants.mjs +1 -1
  9. package/dist/chunks/context-manager.mjs +641 -0
  10. package/dist/chunks/context.mjs +248 -0
  11. package/dist/chunks/index2.mjs +2 -0
  12. package/dist/chunks/index3.mjs +19 -19
  13. package/dist/chunks/init.mjs +18 -8
  14. package/dist/chunks/marketplace.mjs +6 -2
  15. package/dist/chunks/mcp.mjs +1 -1
  16. package/dist/chunks/menu.mjs +3 -3
  17. package/dist/chunks/notification.mjs +27 -27
  18. package/dist/chunks/package.mjs +1 -1
  19. package/dist/chunks/platform.mjs +70 -21
  20. package/dist/chunks/skills-sync.mjs +1 -1
  21. package/dist/chunks/version-checker.mjs +31 -31
  22. package/dist/cli.mjs +55 -5
  23. package/dist/i18n/locales/en/context.json +32 -0
  24. package/dist/i18n/locales/en/marketplace.json +1 -0
  25. package/dist/i18n/locales/en/mcp.json +12 -1
  26. package/dist/i18n/locales/en/superpowers.json +46 -0
  27. package/dist/i18n/locales/zh-CN/context.json +32 -0
  28. package/dist/i18n/locales/zh-CN/marketplace.json +1 -0
  29. package/dist/i18n/locales/zh-CN/mcp.json +12 -1
  30. package/dist/i18n/locales/zh-CN/superpowers.json +46 -0
  31. package/dist/index.d.mts +2 -2
  32. package/dist/index.d.ts +2 -2
  33. package/dist/shared/ccjk.QbS8EAOd.mjs +1019 -0
  34. package/dist/shared/ccjk.RR9TS76h.mjs +698 -0
  35. package/package.json +4 -1
  36. package/dist/shared/ccjk.Bi-m3LKY.mjs +0 -357
  37. package/dist/shared/ccjk.D-RZS4E2.mjs +0 -416
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ccjk",
3
3
  "type": "module",
4
- "version": "2.3.2",
4
+ "version": "2.4.2",
5
5
  "packageManager": "pnpm@10.17.1",
6
6
  "description": "Claude Code JinKu - Advanced AI-powered development assistant with skills, agents, and LLM-driven audit",
7
7
  "author": {
@@ -121,8 +121,10 @@
121
121
  "docs:preview": "pnpm -F @ccjk/docs preview"
122
122
  },
123
123
  "dependencies": {
124
+ "@anthropic-ai/sdk": "^0.52.0",
124
125
  "@iarna/toml": "^2.2.5",
125
126
  "@types/semver": "^7.7.1",
127
+ "@types/tar": "^6.1.13",
126
128
  "ansis": "^4.1.0",
127
129
  "cac": "^6.7.14",
128
130
  "chalk": "^5.6.2",
@@ -141,6 +143,7 @@
141
143
  "pathe": "^2.0.3",
142
144
  "semver": "^7.7.2",
143
145
  "smol-toml": "^1.4.2",
146
+ "tar": "^7.5.2",
144
147
  "tinyexec": "^1.0.1",
145
148
  "trash": "^10.0.0"
146
149
  },
@@ -1,357 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { readFile, mkdir, rm } from 'node:fs/promises';
3
- import { homedir } from 'node:os';
4
- import { join } from 'pathe';
5
- import { i18n } from '../chunks/index2.mjs';
6
- import { writeFileAtomicAsync } from '../chunks/fs-operations.mjs';
7
-
8
- const DEFAULT_REGISTRY_URL = "https://registry.ccjk.dev/v1";
9
- const DEFAULT_CACHE_CONFIG = {
10
- cacheDir: join(homedir(), ".ccjk", "cache"),
11
- ttl: 3600,
12
- // 1 hour
13
- enabled: true
14
- };
15
- const BUILTIN_PACKAGES = [
16
- // Built-in packages will be added here in future versions
17
- ];
18
- function getCacheFilePath(cacheDir) {
19
- return join(cacheDir, "registry-cache.json");
20
- }
21
- async function isCacheValid(cacheDir, ttl) {
22
- const cachePath = getCacheFilePath(cacheDir);
23
- if (!existsSync(cachePath)) {
24
- return false;
25
- }
26
- try {
27
- const content = await readFile(cachePath, "utf-8");
28
- const cache = JSON.parse(content);
29
- const cacheTime = new Date(cache.lastUpdated).getTime();
30
- const now = Date.now();
31
- return now - cacheTime < ttl * 1e3;
32
- } catch {
33
- return false;
34
- }
35
- }
36
- async function readCachedRegistry(cacheDir) {
37
- const cachePath = getCacheFilePath(cacheDir);
38
- if (!existsSync(cachePath)) {
39
- return null;
40
- }
41
- try {
42
- const content = await readFile(cachePath, "utf-8");
43
- return JSON.parse(content);
44
- } catch {
45
- return null;
46
- }
47
- }
48
- async function writeCacheRegistry(cacheDir, registry) {
49
- await mkdir(cacheDir, { recursive: true });
50
- const cachePath = getCacheFilePath(cacheDir);
51
- await writeFileAtomicAsync(cachePath, JSON.stringify(registry, null, 2));
52
- }
53
- async function fetchRemoteRegistry(registryUrl = DEFAULT_REGISTRY_URL, timeout = 3e4) {
54
- const controller = new AbortController();
55
- const timeoutId = setTimeout(() => controller.abort(), timeout);
56
- try {
57
- const response = await fetch(`${registryUrl}/registry.json`, {
58
- signal: controller.signal,
59
- headers: {
60
- "Accept": "application/json",
61
- "User-Agent": "ccjk-cli"
62
- }
63
- });
64
- if (!response.ok) {
65
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
66
- }
67
- return await response.json();
68
- } finally {
69
- clearTimeout(timeoutId);
70
- }
71
- }
72
- async function getRegistry(options = {}) {
73
- const cacheConfig = { ...DEFAULT_CACHE_CONFIG, ...options.cache };
74
- const registryUrl = options.registryUrl || DEFAULT_REGISTRY_URL;
75
- if (cacheConfig.enabled && !options.forceRefresh) {
76
- const cacheValid = await isCacheValid(cacheConfig.cacheDir, cacheConfig.ttl);
77
- if (cacheValid) {
78
- const cached = await readCachedRegistry(cacheConfig.cacheDir);
79
- if (cached) {
80
- return cached;
81
- }
82
- }
83
- }
84
- try {
85
- const registry = await fetchRemoteRegistry(registryUrl);
86
- if (cacheConfig.enabled) {
87
- await writeCacheRegistry(cacheConfig.cacheDir, registry);
88
- }
89
- return registry;
90
- } catch {
91
- const cached = await readCachedRegistry(cacheConfig.cacheDir);
92
- if (cached) {
93
- return cached;
94
- }
95
- return {
96
- version: "1.0.0",
97
- lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
98
- url: registryUrl,
99
- packages: BUILTIN_PACKAGES,
100
- categories: {
101
- "plugin": 0,
102
- "skill": 0,
103
- "workflow": 0,
104
- "agent": 0,
105
- "mcp-service": 0,
106
- "output-style": 0,
107
- "bundle": 0
108
- }
109
- };
110
- }
111
- }
112
- async function searchPackages(options = {}) {
113
- const registry = await getRegistry();
114
- let packages = [...registry.packages];
115
- if (options.query) {
116
- const query = options.query.toLowerCase();
117
- packages = packages.filter(
118
- (pkg) => pkg.name.toLowerCase().includes(query) || pkg.id.toLowerCase().includes(query) || pkg.keywords.some((k) => k.toLowerCase().includes(query)) || Object.values(pkg.description).some((d) => d.toLowerCase().includes(query))
119
- );
120
- }
121
- if (options.category) {
122
- packages = packages.filter((pkg) => pkg.category === options.category);
123
- }
124
- if (options.author) {
125
- packages = packages.filter(
126
- (pkg) => pkg.author.toLowerCase().includes(options.author.toLowerCase())
127
- );
128
- }
129
- if (options.verified) {
130
- packages = packages.filter((pkg) => pkg.verified === options.verified);
131
- }
132
- if (options.keywords?.length) {
133
- packages = packages.filter(
134
- (pkg) => options.keywords.some((k) => pkg.keywords.includes(k))
135
- );
136
- }
137
- if (options.minRating) {
138
- packages = packages.filter((pkg) => pkg.rating >= options.minRating);
139
- }
140
- if (options.supportedTool) {
141
- packages = packages.filter(
142
- (pkg) => pkg.supportedTools?.includes(options.supportedTool)
143
- );
144
- }
145
- const sortBy = options.sortBy || "downloads";
146
- const sortDir = options.sortDir || "desc";
147
- packages.sort((a, b) => {
148
- let comparison = 0;
149
- switch (sortBy) {
150
- case "downloads":
151
- comparison = a.downloads - b.downloads;
152
- break;
153
- case "rating":
154
- comparison = a.rating - b.rating;
155
- break;
156
- case "updated":
157
- comparison = new Date(a.updatedAt).getTime() - new Date(b.updatedAt).getTime();
158
- break;
159
- case "created":
160
- comparison = new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
161
- break;
162
- case "name":
163
- comparison = a.name.localeCompare(b.name);
164
- break;
165
- }
166
- return sortDir === "desc" ? -comparison : comparison;
167
- });
168
- const total = packages.length;
169
- const offset = options.offset || 0;
170
- const limit = options.limit || 20;
171
- packages = packages.slice(offset, offset + limit);
172
- return {
173
- packages,
174
- total,
175
- offset,
176
- limit,
177
- query: options.query,
178
- filters: options
179
- };
180
- }
181
- async function getPackage(packageId) {
182
- const registry = await getRegistry();
183
- return registry.packages.find((pkg) => pkg.id === packageId) || null;
184
- }
185
-
186
- const DEFAULT_INSTALL_DIR = join(homedir(), ".ccjk", "packages");
187
- const INSTALLED_MANIFEST = join(homedir(), ".ccjk", "installed-packages.json");
188
- async function getInstalledPackages() {
189
- if (!existsSync(INSTALLED_MANIFEST)) {
190
- return [];
191
- }
192
- try {
193
- const content = await readFile(INSTALLED_MANIFEST, "utf-8");
194
- return JSON.parse(content);
195
- } catch {
196
- return [];
197
- }
198
- }
199
- async function saveInstalledPackages(packages) {
200
- const dir = join(homedir(), ".ccjk");
201
- await mkdir(dir, { recursive: true });
202
- await writeFileAtomicAsync(INSTALLED_MANIFEST, JSON.stringify(packages, null, 2));
203
- }
204
- async function isPackageInstalled(packageId) {
205
- const installed = await getInstalledPackages();
206
- return installed.some((pkg) => pkg.package.id === packageId);
207
- }
208
- async function installPackage(packageId, options = {}) {
209
- const startTime = Date.now();
210
- try {
211
- const alreadyInstalled = await isPackageInstalled(packageId);
212
- if (alreadyInstalled && !options.force) {
213
- const pkg2 = await getPackage(packageId);
214
- if (!pkg2) {
215
- return {
216
- success: false,
217
- package: {},
218
- error: i18n.t("marketplace:packageNotFound", { name: packageId })
219
- };
220
- }
221
- return {
222
- success: true,
223
- package: pkg2,
224
- alreadyInstalled: true,
225
- durationMs: Date.now() - startTime
226
- };
227
- }
228
- const pkg = await getPackage(packageId);
229
- if (!pkg) {
230
- return {
231
- success: false,
232
- package: {},
233
- error: i18n.t("marketplace:packageNotFound", { name: packageId })
234
- };
235
- }
236
- const warnings = [];
237
- if (options.codeToolType && pkg.supportedTools) {
238
- if (!pkg.supportedTools.includes(options.codeToolType)) {
239
- warnings.push(
240
- i18n.t("marketplace:incompatibleTool", {
241
- tool: options.codeToolType,
242
- supported: pkg.supportedTools.join(", ")
243
- })
244
- );
245
- }
246
- }
247
- const targetDir = options.targetDir || DEFAULT_INSTALL_DIR;
248
- const installPath = join(targetDir, pkg.id);
249
- await mkdir(installPath, { recursive: true });
250
- const installed = await getInstalledPackages();
251
- const installedPackage = {
252
- package: pkg,
253
- path: installPath,
254
- installedAt: (/* @__PURE__ */ new Date()).toISOString(),
255
- source: "marketplace",
256
- enabled: true
257
- };
258
- const existingIndex = installed.findIndex((p) => p.package.id === pkg.id);
259
- if (existingIndex >= 0) {
260
- installed[existingIndex] = installedPackage;
261
- } else {
262
- installed.push(installedPackage);
263
- }
264
- await saveInstalledPackages(installed);
265
- return {
266
- success: true,
267
- package: pkg,
268
- installedPath: installPath,
269
- warnings: warnings.length > 0 ? warnings : void 0,
270
- durationMs: Date.now() - startTime
271
- };
272
- } catch (error) {
273
- return {
274
- success: false,
275
- package: {},
276
- error: error instanceof Error ? error.message : String(error),
277
- durationMs: Date.now() - startTime
278
- };
279
- }
280
- }
281
- async function uninstallPackage(packageId, options = {}) {
282
- try {
283
- const installed = await getInstalledPackages();
284
- const pkg = installed.find((p) => p.package.id === packageId);
285
- if (!pkg) {
286
- return {
287
- success: false,
288
- packageId,
289
- error: i18n.t("marketplace:packageNotInstalled", { name: packageId })
290
- };
291
- }
292
- if (!options.force) {
293
- const dependents = installed.filter(
294
- (p) => p.package.dependencies && Object.keys(p.package.dependencies).includes(packageId)
295
- );
296
- if (dependents.length > 0) {
297
- return {
298
- success: false,
299
- packageId,
300
- error: i18n.t("marketplace:packageHasDependents", {
301
- name: packageId,
302
- dependents: dependents.map((p) => p.package.name).join(", ")
303
- })
304
- };
305
- }
306
- }
307
- if (existsSync(pkg.path)) {
308
- await rm(pkg.path, { recursive: true, force: true });
309
- }
310
- const updated = installed.filter((p) => p.package.id !== packageId);
311
- await saveInstalledPackages(updated);
312
- return {
313
- success: true,
314
- packageId
315
- };
316
- } catch (error) {
317
- return {
318
- success: false,
319
- packageId,
320
- error: error instanceof Error ? error.message : String(error)
321
- };
322
- }
323
- }
324
- async function updatePackage(packageId) {
325
- const uninstallResult = await uninstallPackage(packageId, { keepConfig: true });
326
- if (!uninstallResult.success) {
327
- return {
328
- success: false,
329
- package: {},
330
- error: uninstallResult.error
331
- };
332
- }
333
- return await installPackage(packageId, { force: true });
334
- }
335
- async function checkForUpdates() {
336
- const installed = await getInstalledPackages();
337
- const updates = [];
338
- for (const installedPkg of installed) {
339
- const latestPkg = await getPackage(installedPkg.package.id);
340
- if (!latestPkg)
341
- continue;
342
- if (latestPkg.version !== installedPkg.package.version) {
343
- updates.push({
344
- id: installedPkg.package.id,
345
- currentVersion: installedPkg.package.version,
346
- latestVersion: latestPkg.version,
347
- breaking: false,
348
- // TODO: Implement semver comparison
349
- changelog: latestPkg.changelog,
350
- releaseDate: latestPkg.updatedAt
351
- });
352
- }
353
- }
354
- return updates;
355
- }
356
-
357
- export { getPackage as a, uninstallPackage as b, checkForUpdates as c, installPackage as d, getInstalledPackages as g, isPackageInstalled as i, searchPackages as s, updatePackage as u };