ccjk 12.0.7 → 12.0.8

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 (299) hide show
  1. package/package.json +1 -1
  2. package/dist/chunks/agent-teams.mjs +0 -136
  3. package/dist/chunks/agent.mjs +0 -1439
  4. package/dist/chunks/agents.mjs +0 -3778
  5. package/dist/chunks/api-cli.mjs +0 -132
  6. package/dist/chunks/api-providers.mjs +0 -129
  7. package/dist/chunks/api.mjs +0 -112
  8. package/dist/chunks/auto-bootstrap.mjs +0 -358
  9. package/dist/chunks/auto-init.mjs +0 -7584
  10. package/dist/chunks/auto-updater.mjs +0 -410
  11. package/dist/chunks/banner.mjs +0 -188
  12. package/dist/chunks/bash.mjs +0 -187
  13. package/dist/chunks/boost.mjs +0 -397
  14. package/dist/chunks/ccjk-agents.mjs +0 -414
  15. package/dist/chunks/ccjk-all.mjs +0 -1028
  16. package/dist/chunks/ccjk-config.mjs +0 -261
  17. package/dist/chunks/ccjk-hooks.mjs +0 -1074
  18. package/dist/chunks/ccjk-mcp.mjs +0 -761
  19. package/dist/chunks/ccjk-setup.mjs +0 -763
  20. package/dist/chunks/ccjk-skills.mjs +0 -514
  21. package/dist/chunks/ccr.mjs +0 -98
  22. package/dist/chunks/ccu.mjs +0 -40
  23. package/dist/chunks/check-updates.mjs +0 -108
  24. package/dist/chunks/claude-code-config-manager.mjs +0 -750
  25. package/dist/chunks/claude-code-incremental-manager.mjs +0 -623
  26. package/dist/chunks/claude-config.mjs +0 -236
  27. package/dist/chunks/claude-wrapper.mjs +0 -85
  28. package/dist/chunks/cleanup-migration.mjs +0 -20
  29. package/dist/chunks/cli-hook.mjs +0 -2285
  30. package/dist/chunks/cloud-sync.mjs +0 -29
  31. package/dist/chunks/codex-config-switch.mjs +0 -451
  32. package/dist/chunks/codex-provider-manager.mjs +0 -236
  33. package/dist/chunks/codex-uninstaller.mjs +0 -404
  34. package/dist/chunks/codex.mjs +0 -2077
  35. package/dist/chunks/commands.mjs +0 -108
  36. package/dist/chunks/commands2.mjs +0 -413
  37. package/dist/chunks/commit.mjs +0 -138
  38. package/dist/chunks/completion.mjs +0 -515
  39. package/dist/chunks/config-consolidator.mjs +0 -172
  40. package/dist/chunks/config-switch.mjs +0 -317
  41. package/dist/chunks/config.mjs +0 -379
  42. package/dist/chunks/config2.mjs +0 -477
  43. package/dist/chunks/config3.mjs +0 -470
  44. package/dist/chunks/constants.mjs +0 -133
  45. package/dist/chunks/context-loader.mjs +0 -343
  46. package/dist/chunks/context.mjs +0 -372
  47. package/dist/chunks/convoy-manager.mjs +0 -880
  48. package/dist/chunks/dashboard.mjs +0 -476
  49. package/dist/chunks/doctor.mjs +0 -964
  50. package/dist/chunks/evolution.mjs +0 -382
  51. package/dist/chunks/features.mjs +0 -698
  52. package/dist/chunks/fish.mjs +0 -181
  53. package/dist/chunks/fs-operations.mjs +0 -192
  54. package/dist/chunks/health-alerts.mjs +0 -304
  55. package/dist/chunks/health-check.mjs +0 -532
  56. package/dist/chunks/help.mjs +0 -340
  57. package/dist/chunks/hook-installer.mjs +0 -45
  58. package/dist/chunks/index.mjs +0 -24
  59. package/dist/chunks/index10.mjs +0 -1171
  60. package/dist/chunks/index11.mjs +0 -1008
  61. package/dist/chunks/index12.mjs +0 -193
  62. package/dist/chunks/index13.mjs +0 -218
  63. package/dist/chunks/index14.mjs +0 -663
  64. package/dist/chunks/index2.mjs +0 -19
  65. package/dist/chunks/index3.mjs +0 -19092
  66. package/dist/chunks/index4.mjs +0 -8
  67. package/dist/chunks/index5.mjs +0 -7600
  68. package/dist/chunks/index6.mjs +0 -171
  69. package/dist/chunks/index7.mjs +0 -3583
  70. package/dist/chunks/index8.mjs +0 -19
  71. package/dist/chunks/index9.mjs +0 -616
  72. package/dist/chunks/init.mjs +0 -1606
  73. package/dist/chunks/installer.mjs +0 -690
  74. package/dist/chunks/installer2.mjs +0 -179
  75. package/dist/chunks/interview.mjs +0 -2927
  76. package/dist/chunks/json-config.mjs +0 -60
  77. package/dist/chunks/linux.mjs +0 -3863
  78. package/dist/chunks/macos.mjs +0 -69
  79. package/dist/chunks/main.mjs +0 -635
  80. package/dist/chunks/manager.mjs +0 -1048
  81. package/dist/chunks/marketplace.mjs +0 -949
  82. package/dist/chunks/mcp-cli.mjs +0 -204
  83. package/dist/chunks/mcp-performance.mjs +0 -187
  84. package/dist/chunks/mcp.mjs +0 -1231
  85. package/dist/chunks/menu.mjs +0 -652
  86. package/dist/chunks/metrics-display.mjs +0 -153
  87. package/dist/chunks/migrator.mjs +0 -178
  88. package/dist/chunks/monitor.mjs +0 -1856
  89. package/dist/chunks/notification.mjs +0 -1864
  90. package/dist/chunks/onboarding.mjs +0 -385
  91. package/dist/chunks/package.mjs +0 -3
  92. package/dist/chunks/paradigm.mjs +0 -74
  93. package/dist/chunks/permission-manager.mjs +0 -132
  94. package/dist/chunks/permissions.mjs +0 -265
  95. package/dist/chunks/persistence-manager.mjs +0 -794
  96. package/dist/chunks/persistence.mjs +0 -667
  97. package/dist/chunks/platform.mjs +0 -391
  98. package/dist/chunks/plugin.mjs +0 -1936
  99. package/dist/chunks/powershell.mjs +0 -213
  100. package/dist/chunks/prompts.mjs +0 -241
  101. package/dist/chunks/providers.mjs +0 -260
  102. package/dist/chunks/quick-actions.mjs +0 -320
  103. package/dist/chunks/quick-provider.mjs +0 -682
  104. package/dist/chunks/quick-setup.mjs +0 -412
  105. package/dist/chunks/remote.mjs +0 -497
  106. package/dist/chunks/session.mjs +0 -878
  107. package/dist/chunks/sessions.mjs +0 -106
  108. package/dist/chunks/silent-updater.mjs +0 -396
  109. package/dist/chunks/simple-config.mjs +0 -98
  110. package/dist/chunks/skill.mjs +0 -117
  111. package/dist/chunks/skill2.mjs +0 -9003
  112. package/dist/chunks/skills-sync.mjs +0 -6460
  113. package/dist/chunks/skills.mjs +0 -567
  114. package/dist/chunks/slash-commands.mjs +0 -207
  115. package/dist/chunks/smart-defaults.mjs +0 -412
  116. package/dist/chunks/smart-guide.mjs +0 -194
  117. package/dist/chunks/startup.mjs +0 -487
  118. package/dist/chunks/stats.mjs +0 -410
  119. package/dist/chunks/status.mjs +0 -289
  120. package/dist/chunks/team.mjs +0 -63
  121. package/dist/chunks/thinking.mjs +0 -626
  122. package/dist/chunks/trace.mjs +0 -57
  123. package/dist/chunks/uninstall.mjs +0 -849
  124. package/dist/chunks/update.mjs +0 -167
  125. package/dist/chunks/upgrade-manager.mjs +0 -204
  126. package/dist/chunks/version-checker.mjs +0 -881
  127. package/dist/chunks/vim.mjs +0 -903
  128. package/dist/chunks/windows.mjs +0 -14
  129. package/dist/chunks/workflows.mjs +0 -633
  130. package/dist/chunks/wsl.mjs +0 -129
  131. package/dist/chunks/zero-config.mjs +0 -374
  132. package/dist/chunks/zsh.mjs +0 -182
  133. package/dist/cli.d.mts +0 -1
  134. package/dist/cli.d.ts +0 -1
  135. package/dist/cli.mjs +0 -2199
  136. package/dist/i18n/locales/en/agent-teams.json +0 -18
  137. package/dist/i18n/locales/en/agentBrowser.json +0 -79
  138. package/dist/i18n/locales/en/agents.json +0 -135
  139. package/dist/i18n/locales/en/api.json +0 -63
  140. package/dist/i18n/locales/en/ccjk-agents.json +0 -33
  141. package/dist/i18n/locales/en/ccjk-all.json +0 -23
  142. package/dist/i18n/locales/en/ccjk-skills.json +0 -22
  143. package/dist/i18n/locales/en/ccjk.json +0 -276
  144. package/dist/i18n/locales/en/ccr.json +0 -65
  145. package/dist/i18n/locales/en/claude-md.json +0 -73
  146. package/dist/i18n/locales/en/cli.json +0 -152
  147. package/dist/i18n/locales/en/cloud-setup.json +0 -31
  148. package/dist/i18n/locales/en/cloud-sync.json +0 -147
  149. package/dist/i18n/locales/en/cloud.json +0 -40
  150. package/dist/i18n/locales/en/cloudPlugins.json +0 -118
  151. package/dist/i18n/locales/en/codex.json +0 -127
  152. package/dist/i18n/locales/en/cometix.json +0 -29
  153. package/dist/i18n/locales/en/common.json +0 -68
  154. package/dist/i18n/locales/en/config.json +0 -108
  155. package/dist/i18n/locales/en/configuration.json +0 -226
  156. package/dist/i18n/locales/en/context.json +0 -85
  157. package/dist/i18n/locales/en/dashboard.json +0 -78
  158. package/dist/i18n/locales/en/errors.json +0 -26
  159. package/dist/i18n/locales/en/evolution.json +0 -54
  160. package/dist/i18n/locales/en/hooks.json +0 -74
  161. package/dist/i18n/locales/en/hooksSync.json +0 -133
  162. package/dist/i18n/locales/en/installation.json +0 -83
  163. package/dist/i18n/locales/en/interview.json +0 -104
  164. package/dist/i18n/locales/en/language.json +0 -19
  165. package/dist/i18n/locales/en/lsp.json +0 -78
  166. package/dist/i18n/locales/en/marketplace.json +0 -116
  167. package/dist/i18n/locales/en/mcp.json +0 -178
  168. package/dist/i18n/locales/en/memory.json +0 -92
  169. package/dist/i18n/locales/en/menu.json +0 -143
  170. package/dist/i18n/locales/en/multi-config.json +0 -79
  171. package/dist/i18n/locales/en/notification.json +0 -307
  172. package/dist/i18n/locales/en/permissions.json +0 -95
  173. package/dist/i18n/locales/en/persistence.json +0 -127
  174. package/dist/i18n/locales/en/plugins.json +0 -146
  175. package/dist/i18n/locales/en/quick-actions.json +0 -78
  176. package/dist/i18n/locales/en/registry.json +0 -54
  177. package/dist/i18n/locales/en/remote.json +0 -93
  178. package/dist/i18n/locales/en/sandbox.json +0 -44
  179. package/dist/i18n/locales/en/setup.json +0 -44
  180. package/dist/i18n/locales/en/shencha.json +0 -14
  181. package/dist/i18n/locales/en/skills.json +0 -100
  182. package/dist/i18n/locales/en/skillsSync.json +0 -74
  183. package/dist/i18n/locales/en/smartGuide.json +0 -49
  184. package/dist/i18n/locales/en/stats.json +0 -20
  185. package/dist/i18n/locales/en/subagent.json +0 -69
  186. package/dist/i18n/locales/en/superpowers.json +0 -117
  187. package/dist/i18n/locales/en/team.json +0 -7
  188. package/dist/i18n/locales/en/thinking.json +0 -65
  189. package/dist/i18n/locales/en/tools.json +0 -42
  190. package/dist/i18n/locales/en/uninstall.json +0 -56
  191. package/dist/i18n/locales/en/updater.json +0 -29
  192. package/dist/i18n/locales/en/vim.json +0 -169
  193. package/dist/i18n/locales/en/workflow.json +0 -55
  194. package/dist/i18n/locales/en/workspace.json +0 -108
  195. package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
  196. package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -79
  197. package/dist/i18n/locales/zh-CN/agents.json +0 -135
  198. package/dist/i18n/locales/zh-CN/api.json +0 -63
  199. package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
  200. package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
  201. package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
  202. package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
  203. package/dist/i18n/locales/zh-CN/ccr.json +0 -65
  204. package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
  205. package/dist/i18n/locales/zh-CN/cli.json +0 -152
  206. package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
  207. package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
  208. package/dist/i18n/locales/zh-CN/cloud.json +0 -40
  209. package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
  210. package/dist/i18n/locales/zh-CN/codex.json +0 -127
  211. package/dist/i18n/locales/zh-CN/cometix.json +0 -29
  212. package/dist/i18n/locales/zh-CN/common.json +0 -68
  213. package/dist/i18n/locales/zh-CN/config.json +0 -108
  214. package/dist/i18n/locales/zh-CN/configuration.json +0 -224
  215. package/dist/i18n/locales/zh-CN/context.json +0 -85
  216. package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
  217. package/dist/i18n/locales/zh-CN/errors.json +0 -26
  218. package/dist/i18n/locales/zh-CN/evolution.json +0 -54
  219. package/dist/i18n/locales/zh-CN/hooks.json +0 -74
  220. package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
  221. package/dist/i18n/locales/zh-CN/installation.json +0 -83
  222. package/dist/i18n/locales/zh-CN/interview.json +0 -104
  223. package/dist/i18n/locales/zh-CN/language.json +0 -19
  224. package/dist/i18n/locales/zh-CN/lsp.json +0 -78
  225. package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
  226. package/dist/i18n/locales/zh-CN/mcp.json +0 -178
  227. package/dist/i18n/locales/zh-CN/memory.json +0 -92
  228. package/dist/i18n/locales/zh-CN/menu.json +0 -143
  229. package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
  230. package/dist/i18n/locales/zh-CN/notification.json +0 -307
  231. package/dist/i18n/locales/zh-CN/permissions.json +0 -95
  232. package/dist/i18n/locales/zh-CN/persistence.json +0 -127
  233. package/dist/i18n/locales/zh-CN/plugins.json +0 -146
  234. package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
  235. package/dist/i18n/locales/zh-CN/registry.json +0 -54
  236. package/dist/i18n/locales/zh-CN/remote.json +0 -93
  237. package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
  238. package/dist/i18n/locales/zh-CN/setup.json +0 -44
  239. package/dist/i18n/locales/zh-CN/shencha.json +0 -14
  240. package/dist/i18n/locales/zh-CN/skills.json +0 -100
  241. package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
  242. package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
  243. package/dist/i18n/locales/zh-CN/stats.json +0 -20
  244. package/dist/i18n/locales/zh-CN/subagent.json +0 -69
  245. package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
  246. package/dist/i18n/locales/zh-CN/team.json +0 -7
  247. package/dist/i18n/locales/zh-CN/thinking.json +0 -65
  248. package/dist/i18n/locales/zh-CN/tools.json +0 -42
  249. package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
  250. package/dist/i18n/locales/zh-CN/updater.json +0 -29
  251. package/dist/i18n/locales/zh-CN/vim.json +0 -169
  252. package/dist/i18n/locales/zh-CN/workflow.json +0 -55
  253. package/dist/i18n/locales/zh-CN/workspace.json +0 -108
  254. package/dist/index.d.mts +0 -5295
  255. package/dist/index.d.ts +0 -5295
  256. package/dist/index.mjs +0 -4941
  257. package/dist/shared/ccjk.B364Fu0N.mjs +0 -1819
  258. package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
  259. package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
  260. package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
  261. package/dist/shared/ccjk.BFxsJM0k.mjs +0 -599
  262. package/dist/shared/ccjk.BIxuVL3_.mjs +0 -25
  263. package/dist/shared/ccjk.BRZ9ww8S.mjs +0 -142
  264. package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
  265. package/dist/shared/ccjk.BrPUmTqm.mjs +0 -266
  266. package/dist/shared/ccjk.BtB1e5jm.mjs +0 -171
  267. package/dist/shared/ccjk.BwfbSKN2.mjs +0 -1051
  268. package/dist/shared/ccjk.BxSmJ8B7.mjs +0 -243
  269. package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
  270. package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
  271. package/dist/shared/ccjk.CL4Yat0G.mjs +0 -303
  272. package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
  273. package/dist/shared/ccjk.CePkJq2S.mjs +0 -223
  274. package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
  275. package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
  276. package/dist/shared/ccjk.Cjj8SVrn.mjs +0 -54
  277. package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
  278. package/dist/shared/ccjk.D5MFQT7w.mjs +0 -400
  279. package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
  280. package/dist/shared/ccjk.D8ZLYSZZ.mjs +0 -299
  281. package/dist/shared/ccjk.DG_o24cZ.mjs +0 -88
  282. package/dist/shared/ccjk.DLLw-h4Y.mjs +0 -460
  283. package/dist/shared/ccjk.DOwtZMk8.mjs +0 -4019
  284. package/dist/shared/ccjk.DS7UESmF.mjs +0 -2451
  285. package/dist/shared/ccjk.DTdjs-qK.mjs +0 -1447
  286. package/dist/shared/ccjk.DXRAZcix.mjs +0 -66
  287. package/dist/shared/ccjk.DsYaCCx4.mjs +0 -317
  288. package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
  289. package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
  290. package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
  291. package/dist/shared/ccjk.SPoXMvZD.mjs +0 -1242
  292. package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
  293. package/dist/shared/ccjk.UIvifqNE.mjs +0 -1486
  294. package/dist/shared/ccjk._dESH4Rk.mjs +0 -111
  295. package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
  296. package/dist/shared/ccjk.c-ETfBZ_.mjs +0 -617
  297. package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
  298. package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
  299. package/dist/shared/ccjk.waa2ikKJ.mjs +0 -351
@@ -1,1819 +0,0 @@
1
- import { c as consola, o as ofetch } from './ccjk.UIvifqNE.mjs';
2
- import fs__default, { readFileSync } from 'node:fs';
3
- import path__default, { dirname, join } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import { randomUUID } from 'node:crypto';
6
-
7
- const defaults = Object.freeze({
8
- ignoreUnknown: false,
9
- respectType: false,
10
- respectFunctionNames: false,
11
- respectFunctionProperties: false,
12
- unorderedObjects: true,
13
- unorderedArrays: false,
14
- unorderedSets: false,
15
- excludeKeys: void 0,
16
- excludeValues: void 0,
17
- replacer: void 0
18
- });
19
- function objectHash(object, options) {
20
- if (options) {
21
- options = { ...defaults, ...options };
22
- } else {
23
- options = defaults;
24
- }
25
- const hasher = createHasher(options);
26
- hasher.dispatch(object);
27
- return hasher.toString();
28
- }
29
- const defaultPrototypesKeys = Object.freeze([
30
- "prototype",
31
- "__proto__",
32
- "constructor"
33
- ]);
34
- function createHasher(options) {
35
- let buff = "";
36
- let context = /* @__PURE__ */ new Map();
37
- const write = (str) => {
38
- buff += str;
39
- };
40
- return {
41
- toString() {
42
- return buff;
43
- },
44
- getContext() {
45
- return context;
46
- },
47
- dispatch(value) {
48
- if (options.replacer) {
49
- value = options.replacer(value);
50
- }
51
- const type = value === null ? "null" : typeof value;
52
- return this[type](value);
53
- },
54
- object(object) {
55
- if (object && typeof object.toJSON === "function") {
56
- return this.object(object.toJSON());
57
- }
58
- const objString = Object.prototype.toString.call(object);
59
- let objType = "";
60
- const objectLength = objString.length;
61
- if (objectLength < 10) {
62
- objType = "unknown:[" + objString + "]";
63
- } else {
64
- objType = objString.slice(8, objectLength - 1);
65
- }
66
- objType = objType.toLowerCase();
67
- let objectNumber = null;
68
- if ((objectNumber = context.get(object)) === void 0) {
69
- context.set(object, context.size);
70
- } else {
71
- return this.dispatch("[CIRCULAR:" + objectNumber + "]");
72
- }
73
- if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
74
- write("buffer:");
75
- return write(object.toString("utf8"));
76
- }
77
- if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
78
- if (this[objType]) {
79
- this[objType](object);
80
- } else if (!options.ignoreUnknown) {
81
- this.unkown(object, objType);
82
- }
83
- } else {
84
- let keys = Object.keys(object);
85
- if (options.unorderedObjects) {
86
- keys = keys.sort();
87
- }
88
- let extraKeys = [];
89
- if (options.respectType !== false && !isNativeFunction(object)) {
90
- extraKeys = defaultPrototypesKeys;
91
- }
92
- if (options.excludeKeys) {
93
- keys = keys.filter((key) => {
94
- return !options.excludeKeys(key);
95
- });
96
- extraKeys = extraKeys.filter((key) => {
97
- return !options.excludeKeys(key);
98
- });
99
- }
100
- write("object:" + (keys.length + extraKeys.length) + ":");
101
- const dispatchForKey = (key) => {
102
- this.dispatch(key);
103
- write(":");
104
- if (!options.excludeValues) {
105
- this.dispatch(object[key]);
106
- }
107
- write(",");
108
- };
109
- for (const key of keys) {
110
- dispatchForKey(key);
111
- }
112
- for (const key of extraKeys) {
113
- dispatchForKey(key);
114
- }
115
- }
116
- },
117
- array(arr, unordered) {
118
- unordered = unordered === void 0 ? options.unorderedArrays !== false : unordered;
119
- write("array:" + arr.length + ":");
120
- if (!unordered || arr.length <= 1) {
121
- for (const entry of arr) {
122
- this.dispatch(entry);
123
- }
124
- return;
125
- }
126
- const contextAdditions = /* @__PURE__ */ new Map();
127
- const entries = arr.map((entry) => {
128
- const hasher = createHasher(options);
129
- hasher.dispatch(entry);
130
- for (const [key, value] of hasher.getContext()) {
131
- contextAdditions.set(key, value);
132
- }
133
- return hasher.toString();
134
- });
135
- context = contextAdditions;
136
- entries.sort();
137
- return this.array(entries, false);
138
- },
139
- date(date) {
140
- return write("date:" + date.toJSON());
141
- },
142
- symbol(sym) {
143
- return write("symbol:" + sym.toString());
144
- },
145
- unkown(value, type) {
146
- write(type);
147
- if (!value) {
148
- return;
149
- }
150
- write(":");
151
- if (value && typeof value.entries === "function") {
152
- return this.array(
153
- Array.from(value.entries()),
154
- true
155
- /* ordered */
156
- );
157
- }
158
- },
159
- error(err) {
160
- return write("error:" + err.toString());
161
- },
162
- boolean(bool) {
163
- return write("bool:" + bool);
164
- },
165
- string(string) {
166
- write("string:" + string.length + ":");
167
- write(string);
168
- },
169
- function(fn) {
170
- write("fn:");
171
- if (isNativeFunction(fn)) {
172
- this.dispatch("[native]");
173
- } else {
174
- this.dispatch(fn.toString());
175
- }
176
- if (options.respectFunctionNames !== false) {
177
- this.dispatch("function-name:" + String(fn.name));
178
- }
179
- if (options.respectFunctionProperties) {
180
- this.object(fn);
181
- }
182
- },
183
- number(number) {
184
- return write("number:" + number);
185
- },
186
- xml(xml) {
187
- return write("xml:" + xml.toString());
188
- },
189
- null() {
190
- return write("Null");
191
- },
192
- undefined() {
193
- return write("Undefined");
194
- },
195
- regexp(regex) {
196
- return write("regex:" + regex.toString());
197
- },
198
- uint8array(arr) {
199
- write("uint8array:");
200
- return this.dispatch(Array.prototype.slice.call(arr));
201
- },
202
- uint8clampedarray(arr) {
203
- write("uint8clampedarray:");
204
- return this.dispatch(Array.prototype.slice.call(arr));
205
- },
206
- int8array(arr) {
207
- write("int8array:");
208
- return this.dispatch(Array.prototype.slice.call(arr));
209
- },
210
- uint16array(arr) {
211
- write("uint16array:");
212
- return this.dispatch(Array.prototype.slice.call(arr));
213
- },
214
- int16array(arr) {
215
- write("int16array:");
216
- return this.dispatch(Array.prototype.slice.call(arr));
217
- },
218
- uint32array(arr) {
219
- write("uint32array:");
220
- return this.dispatch(Array.prototype.slice.call(arr));
221
- },
222
- int32array(arr) {
223
- write("int32array:");
224
- return this.dispatch(Array.prototype.slice.call(arr));
225
- },
226
- float32array(arr) {
227
- write("float32array:");
228
- return this.dispatch(Array.prototype.slice.call(arr));
229
- },
230
- float64array(arr) {
231
- write("float64array:");
232
- return this.dispatch(Array.prototype.slice.call(arr));
233
- },
234
- arraybuffer(arr) {
235
- write("arraybuffer:");
236
- return this.dispatch(new Uint8Array(arr));
237
- },
238
- url(url) {
239
- return write("url:" + url.toString());
240
- },
241
- map(map) {
242
- write("map:");
243
- const arr = [...map];
244
- return this.array(arr, options.unorderedSets !== false);
245
- },
246
- set(set) {
247
- write("set:");
248
- const arr = [...set];
249
- return this.array(arr, options.unorderedSets !== false);
250
- },
251
- file(file) {
252
- write("file:");
253
- return this.dispatch([file.name, file.size, file.type, file.lastModfied]);
254
- },
255
- blob() {
256
- if (options.ignoreUnknown) {
257
- return write("[blob]");
258
- }
259
- throw new Error(
260
- 'Hashing Blob objects is currently not supported\nUse "options.replacer" or "options.ignoreUnknown"\n'
261
- );
262
- },
263
- domwindow() {
264
- return write("domwindow");
265
- },
266
- bigint(number) {
267
- return write("bigint:" + number.toString());
268
- },
269
- /* Node.js standard native objects */
270
- process() {
271
- return write("process");
272
- },
273
- timer() {
274
- return write("timer");
275
- },
276
- pipe() {
277
- return write("pipe");
278
- },
279
- tcp() {
280
- return write("tcp");
281
- },
282
- udp() {
283
- return write("udp");
284
- },
285
- tty() {
286
- return write("tty");
287
- },
288
- statwatcher() {
289
- return write("statwatcher");
290
- },
291
- securecontext() {
292
- return write("securecontext");
293
- },
294
- connection() {
295
- return write("connection");
296
- },
297
- zlib() {
298
- return write("zlib");
299
- },
300
- context() {
301
- return write("context");
302
- },
303
- nodescript() {
304
- return write("nodescript");
305
- },
306
- httpparser() {
307
- return write("httpparser");
308
- },
309
- dataview() {
310
- return write("dataview");
311
- },
312
- signal() {
313
- return write("signal");
314
- },
315
- fsevent() {
316
- return write("fsevent");
317
- },
318
- tlswrap() {
319
- return write("tlswrap");
320
- }
321
- };
322
- }
323
- const nativeFunc = "[native code] }";
324
- const nativeFuncLength = nativeFunc.length;
325
- function isNativeFunction(f) {
326
- if (typeof f !== "function") {
327
- return false;
328
- }
329
- return Function.prototype.toString.call(f).slice(-nativeFuncLength) === nativeFunc;
330
- }
331
-
332
- class WordArray {
333
- words;
334
- sigBytes;
335
- constructor(words, sigBytes) {
336
- words = this.words = words || [];
337
- this.sigBytes = sigBytes === void 0 ? words.length * 4 : sigBytes;
338
- }
339
- toString(encoder) {
340
- return (encoder || Hex).stringify(this);
341
- }
342
- concat(wordArray) {
343
- this.clamp();
344
- if (this.sigBytes % 4) {
345
- for (let i = 0; i < wordArray.sigBytes; i++) {
346
- const thatByte = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
347
- this.words[this.sigBytes + i >>> 2] |= thatByte << 24 - (this.sigBytes + i) % 4 * 8;
348
- }
349
- } else {
350
- for (let j = 0; j < wordArray.sigBytes; j += 4) {
351
- this.words[this.sigBytes + j >>> 2] = wordArray.words[j >>> 2];
352
- }
353
- }
354
- this.sigBytes += wordArray.sigBytes;
355
- return this;
356
- }
357
- clamp() {
358
- this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8;
359
- this.words.length = Math.ceil(this.sigBytes / 4);
360
- }
361
- clone() {
362
- return new WordArray([...this.words]);
363
- }
364
- }
365
- const Hex = {
366
- stringify(wordArray) {
367
- const hexChars = [];
368
- for (let i = 0; i < wordArray.sigBytes; i++) {
369
- const bite = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
370
- hexChars.push((bite >>> 4).toString(16), (bite & 15).toString(16));
371
- }
372
- return hexChars.join("");
373
- }
374
- };
375
- const Base64 = {
376
- stringify(wordArray) {
377
- const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
378
- const base64Chars = [];
379
- for (let i = 0; i < wordArray.sigBytes; i += 3) {
380
- const byte1 = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
381
- const byte2 = wordArray.words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
382
- const byte3 = wordArray.words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
383
- const triplet = byte1 << 16 | byte2 << 8 | byte3;
384
- for (let j = 0; j < 4 && i * 8 + j * 6 < wordArray.sigBytes * 8; j++) {
385
- base64Chars.push(keyStr.charAt(triplet >>> 6 * (3 - j) & 63));
386
- }
387
- }
388
- return base64Chars.join("");
389
- }
390
- };
391
- const Latin1 = {
392
- parse(latin1Str) {
393
- const latin1StrLength = latin1Str.length;
394
- const words = [];
395
- for (let i = 0; i < latin1StrLength; i++) {
396
- words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
397
- }
398
- return new WordArray(words, latin1StrLength);
399
- }
400
- };
401
- const Utf8 = {
402
- parse(utf8Str) {
403
- return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
404
- }
405
- };
406
- class BufferedBlockAlgorithm {
407
- _data = new WordArray();
408
- _nDataBytes = 0;
409
- _minBufferSize = 0;
410
- blockSize = 512 / 32;
411
- reset() {
412
- this._data = new WordArray();
413
- this._nDataBytes = 0;
414
- }
415
- _append(data) {
416
- if (typeof data === "string") {
417
- data = Utf8.parse(data);
418
- }
419
- this._data.concat(data);
420
- this._nDataBytes += data.sigBytes;
421
- }
422
- _doProcessBlock(_dataWords, _offset) {
423
- }
424
- _process(doFlush) {
425
- let processedWords;
426
- let nBlocksReady = this._data.sigBytes / (this.blockSize * 4);
427
- if (doFlush) {
428
- nBlocksReady = Math.ceil(nBlocksReady);
429
- } else {
430
- nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
431
- }
432
- const nWordsReady = nBlocksReady * this.blockSize;
433
- const nBytesReady = Math.min(nWordsReady * 4, this._data.sigBytes);
434
- if (nWordsReady) {
435
- for (let offset = 0; offset < nWordsReady; offset += this.blockSize) {
436
- this._doProcessBlock(this._data.words, offset);
437
- }
438
- processedWords = this._data.words.splice(0, nWordsReady);
439
- this._data.sigBytes -= nBytesReady;
440
- }
441
- return new WordArray(processedWords, nBytesReady);
442
- }
443
- }
444
- class Hasher extends BufferedBlockAlgorithm {
445
- update(messageUpdate) {
446
- this._append(messageUpdate);
447
- this._process();
448
- return this;
449
- }
450
- finalize(messageUpdate) {
451
- if (messageUpdate) {
452
- this._append(messageUpdate);
453
- }
454
- }
455
- }
456
-
457
- const H = [
458
- 1779033703,
459
- -1150833019,
460
- 1013904242,
461
- -1521486534,
462
- 1359893119,
463
- -1694144372,
464
- 528734635,
465
- 1541459225
466
- ];
467
- const K = [
468
- 1116352408,
469
- 1899447441,
470
- -1245643825,
471
- -373957723,
472
- 961987163,
473
- 1508970993,
474
- -1841331548,
475
- -1424204075,
476
- -670586216,
477
- 310598401,
478
- 607225278,
479
- 1426881987,
480
- 1925078388,
481
- -2132889090,
482
- -1680079193,
483
- -1046744716,
484
- -459576895,
485
- -272742522,
486
- 264347078,
487
- 604807628,
488
- 770255983,
489
- 1249150122,
490
- 1555081692,
491
- 1996064986,
492
- -1740746414,
493
- -1473132947,
494
- -1341970488,
495
- -1084653625,
496
- -958395405,
497
- -710438585,
498
- 113926993,
499
- 338241895,
500
- 666307205,
501
- 773529912,
502
- 1294757372,
503
- 1396182291,
504
- 1695183700,
505
- 1986661051,
506
- -2117940946,
507
- -1838011259,
508
- -1564481375,
509
- -1474664885,
510
- -1035236496,
511
- -949202525,
512
- -778901479,
513
- -694614492,
514
- -200395387,
515
- 275423344,
516
- 430227734,
517
- 506948616,
518
- 659060556,
519
- 883997877,
520
- 958139571,
521
- 1322822218,
522
- 1537002063,
523
- 1747873779,
524
- 1955562222,
525
- 2024104815,
526
- -2067236844,
527
- -1933114872,
528
- -1866530822,
529
- -1538233109,
530
- -1090935817,
531
- -965641998
532
- ];
533
- const W = [];
534
- class SHA256 extends Hasher {
535
- _hash = new WordArray([...H]);
536
- /**
537
- * Resets the internal state of the hash object to initial values.
538
- */
539
- reset() {
540
- super.reset();
541
- this._hash = new WordArray([...H]);
542
- }
543
- _doProcessBlock(M, offset) {
544
- const H2 = this._hash.words;
545
- let a = H2[0];
546
- let b = H2[1];
547
- let c = H2[2];
548
- let d = H2[3];
549
- let e = H2[4];
550
- let f = H2[5];
551
- let g = H2[6];
552
- let h = H2[7];
553
- for (let i = 0; i < 64; i++) {
554
- if (i < 16) {
555
- W[i] = M[offset + i] | 0;
556
- } else {
557
- const gamma0x = W[i - 15];
558
- const gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
559
- const gamma1x = W[i - 2];
560
- const gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
561
- W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
562
- }
563
- const ch = e & f ^ ~e & g;
564
- const maj = a & b ^ a & c ^ b & c;
565
- const sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
566
- const sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
567
- const t1 = h + sigma1 + ch + K[i] + W[i];
568
- const t2 = sigma0 + maj;
569
- h = g;
570
- g = f;
571
- f = e;
572
- e = d + t1 | 0;
573
- d = c;
574
- c = b;
575
- b = a;
576
- a = t1 + t2 | 0;
577
- }
578
- H2[0] = H2[0] + a | 0;
579
- H2[1] = H2[1] + b | 0;
580
- H2[2] = H2[2] + c | 0;
581
- H2[3] = H2[3] + d | 0;
582
- H2[4] = H2[4] + e | 0;
583
- H2[5] = H2[5] + f | 0;
584
- H2[6] = H2[6] + g | 0;
585
- H2[7] = H2[7] + h | 0;
586
- }
587
- /**
588
- * Finishes the hash calculation and returns the hash as a WordArray.
589
- *
590
- * @param {string} messageUpdate - Additional message content to include in the hash.
591
- * @returns {WordArray} The finalised hash as a WordArray.
592
- */
593
- finalize(messageUpdate) {
594
- super.finalize(messageUpdate);
595
- const nBitsTotal = this._nDataBytes * 8;
596
- const nBitsLeft = this._data.sigBytes * 8;
597
- this._data.words[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
598
- this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(
599
- nBitsTotal / 4294967296
600
- );
601
- this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
602
- this._data.sigBytes = this._data.words.length * 4;
603
- this._process();
604
- return this._hash;
605
- }
606
- }
607
- function sha256base64(message) {
608
- return new SHA256().finalize(message).toString(Base64);
609
- }
610
-
611
- function hash(object, options = {}) {
612
- const hashed = typeof object === "string" ? object : objectHash(object, options);
613
- return sha256base64(hashed).slice(0, 10);
614
- }
615
-
616
- class CloudCache {
617
- memoryCache;
618
- cacheDir;
619
- enabled;
620
- constructor(config) {
621
- this.memoryCache = /* @__PURE__ */ new Map();
622
- this.enabled = config.enableCache !== false;
623
- this.cacheDir = config.cacheDir || path__default.join(process.cwd(), ".ccjk-cache");
624
- if (this.enabled) {
625
- this.ensureCacheDir();
626
- this.loadCacheFromDisk();
627
- }
628
- }
629
- /**
630
- * Ensure cache directory exists
631
- */
632
- ensureCacheDir() {
633
- try {
634
- if (!fs__default.existsSync(this.cacheDir)) {
635
- fs__default.mkdirSync(this.cacheDir, { recursive: true });
636
- consola.debug("Created cache directory:", this.cacheDir);
637
- }
638
- } catch (error) {
639
- consola.warn("Failed to create cache directory, disabling cache:", error);
640
- this.enabled = false;
641
- }
642
- }
643
- /**
644
- * Load cache from disk
645
- */
646
- loadCacheFromDisk() {
647
- try {
648
- const cacheFile = path__default.join(this.cacheDir, "cache.json");
649
- if (fs__default.existsSync(cacheFile)) {
650
- const data = fs__default.readFileSync(cacheFile, "utf-8");
651
- const entries = JSON.parse(data);
652
- const now = Date.now();
653
- for (const [key, entry] of Object.entries(entries)) {
654
- if (entry.expiresAt > now) {
655
- this.memoryCache.set(key, entry);
656
- }
657
- }
658
- consola.debug(`Loaded ${this.memoryCache.size} cache entries from disk`);
659
- }
660
- } catch (error) {
661
- consola.warn("Failed to load cache from disk:", error);
662
- }
663
- }
664
- /**
665
- * Save cache to disk
666
- */
667
- saveCacheToDisk() {
668
- try {
669
- const cacheFile = path__default.join(this.cacheDir, "cache.json");
670
- const entries = Object.fromEntries(this.memoryCache);
671
- fs__default.writeFileSync(cacheFile, JSON.stringify(entries, null, 2));
672
- } catch (error) {
673
- consola.warn("Failed to save cache to disk:", error);
674
- }
675
- }
676
- /**
677
- * Generate cache key from parameters
678
- */
679
- generateKey(prefix, params) {
680
- const hashValue = hash(params);
681
- return `${prefix}:${hashValue}`;
682
- }
683
- /**
684
- * Get cached value
685
- *
686
- * @param key - Cache key
687
- * @returns Cached value or undefined if not found/expired
688
- */
689
- get(key) {
690
- if (!this.enabled) {
691
- return void 0;
692
- }
693
- const entry = this.memoryCache.get(key);
694
- if (!entry) {
695
- return void 0;
696
- }
697
- if (Date.now() > entry.expiresAt) {
698
- this.memoryCache.delete(key);
699
- this.saveCacheToDisk();
700
- return void 0;
701
- }
702
- consola.debug(`Cache hit: ${key}`);
703
- return entry.data;
704
- }
705
- /**
706
- * Set cached value with TTL
707
- *
708
- * @param key - Cache key
709
- * @param value - Value to cache
710
- * @param ttlSeconds - Time to live in seconds
711
- */
712
- set(key, value, ttlSeconds) {
713
- if (!this.enabled) {
714
- return;
715
- }
716
- const entry = {
717
- data: value,
718
- expiresAt: Date.now() + ttlSeconds * 1e3,
719
- key
720
- };
721
- this.memoryCache.set(key, entry);
722
- this.saveCacheToDisk();
723
- consola.debug(`Cache set: ${key} (TTL: ${ttlSeconds}s)`);
724
- }
725
- /**
726
- * Delete cache entry
727
- *
728
- * @param key - Cache key
729
- */
730
- delete(key) {
731
- this.memoryCache.delete(key);
732
- this.saveCacheToDisk();
733
- consola.debug(`Cache deleted: ${key}`);
734
- }
735
- /**
736
- * Clear all cache entries
737
- */
738
- clear() {
739
- this.memoryCache.clear();
740
- this.saveCacheToDisk();
741
- consola.debug("Cache cleared");
742
- }
743
- /**
744
- * Clean expired entries
745
- */
746
- cleanExpired() {
747
- const now = Date.now();
748
- let cleaned = 0;
749
- for (const [key, entry] of this.memoryCache.entries()) {
750
- if (now > entry.expiresAt) {
751
- this.memoryCache.delete(key);
752
- cleaned++;
753
- }
754
- }
755
- if (cleaned > 0) {
756
- this.saveCacheToDisk();
757
- consola.debug(`Cleaned ${cleaned} expired cache entries`);
758
- }
759
- }
760
- /**
761
- * Get cache statistics
762
- */
763
- getStats() {
764
- return {
765
- size: this.memoryCache.size,
766
- keys: Array.from(this.memoryCache.keys())
767
- };
768
- }
769
- }
770
- class CachedCloudClient {
771
- client;
772
- cache;
773
- constructor(client, cache) {
774
- this.client = client;
775
- this.cache = cache;
776
- }
777
- /**
778
- * Analyze project with caching (7-day TTL)
779
- */
780
- async analyzeProject(request) {
781
- const cacheKey = this.cache.generateKey("analyze", request);
782
- const cached = this.cache.get(cacheKey);
783
- if (cached) {
784
- return cached;
785
- }
786
- const result = await this.client.analyzeProject(request);
787
- this.cache.set(cacheKey, result, 7 * 24 * 60 * 60);
788
- return result;
789
- }
790
- /**
791
- * Get template with caching (30-day TTL)
792
- */
793
- async getTemplate(id, language) {
794
- const cacheKey = this.cache.generateKey("template", { id, language });
795
- const cached = this.cache.get(cacheKey);
796
- if (cached) {
797
- return cached;
798
- }
799
- const result = await this.client.getTemplate(id, language);
800
- this.cache.set(cacheKey, result, 30 * 24 * 60 * 60);
801
- return result;
802
- }
803
- /**
804
- * Get batch templates with caching (30-day TTL)
805
- */
806
- async getBatchTemplates(request) {
807
- const cacheKey = this.cache.generateKey("batch", request);
808
- const cached = this.cache.get(cacheKey);
809
- if (cached) {
810
- return cached;
811
- }
812
- const result = await this.client.getBatchTemplates(request);
813
- this.cache.set(cacheKey, result, 30 * 24 * 60 * 60);
814
- return result;
815
- }
816
- /**
817
- * Report usage (no caching)
818
- */
819
- async reportUsage(report) {
820
- return this.client.reportUsage(report);
821
- }
822
- /**
823
- * Health check with caching (5-minute TTL)
824
- */
825
- async healthCheck() {
826
- const cacheKey = "health:check";
827
- const cached = this.cache.get(cacheKey);
828
- if (cached) {
829
- return cached;
830
- }
831
- const result = await this.client.healthCheck();
832
- this.cache.set(cacheKey, result, 5 * 60);
833
- return result;
834
- }
835
- /**
836
- * Clear cache
837
- */
838
- clearCache() {
839
- this.cache.clear();
840
- }
841
- /**
842
- * Clean expired cache entries
843
- */
844
- cleanCache() {
845
- this.cache.cleanExpired();
846
- }
847
- /**
848
- * Get cache statistics
849
- */
850
- getCacheStats() {
851
- return this.cache.getStats();
852
- }
853
- /**
854
- * Get underlying client
855
- */
856
- getClient() {
857
- return this.client;
858
- }
859
- }
860
-
861
- class CloudClientError extends Error {
862
- /** Error type */
863
- type;
864
- /** HTTP status code if applicable */
865
- statusCode;
866
- /** Original error */
867
- originalError;
868
- constructor(type, message, statusCode, originalError) {
869
- super(message);
870
- this.name = "CloudClientError";
871
- this.type = type;
872
- this.statusCode = statusCode;
873
- this.originalError = originalError;
874
- }
875
- /**
876
- * Create error from HTTP response
877
- */
878
- static fromResponse(statusCode, message) {
879
- let type;
880
- if (statusCode === 401)
881
- type = "AUTH_ERROR";
882
- else if (statusCode === 429)
883
- type = "RATE_LIMIT_ERROR";
884
- else if (statusCode >= 500)
885
- type = "SERVER_ERROR";
886
- else if (statusCode >= 400)
887
- type = "API_ERROR";
888
- else type = "UNKNOWN_ERROR";
889
- return new CloudClientError(type, message, statusCode);
890
- }
891
- /**
892
- * Create network error
893
- */
894
- static network(error) {
895
- return new CloudClientError(
896
- "NETWORK_ERROR",
897
- error instanceof Error ? error.message : "Network connection failed",
898
- void 0,
899
- error
900
- );
901
- }
902
- /**
903
- * Create timeout error
904
- */
905
- static timeout(timeout) {
906
- return new CloudClientError(
907
- "TIMEOUT_ERROR",
908
- `Request timeout after ${timeout}ms`
909
- );
910
- }
911
- /**
912
- * Create validation error
913
- */
914
- static validation(message) {
915
- return new CloudClientError("VALIDATION_ERROR", message);
916
- }
917
- }
918
-
919
- const __dirname = dirname(fileURLToPath(import.meta.url));
920
- let CCJK_VERSION = "9.0.0";
921
- try {
922
- const packageJson = JSON.parse(readFileSync(join(__dirname, "../../package.json"), "utf-8"));
923
- CCJK_VERSION = packageJson.version;
924
- } catch {
925
- }
926
- const API_PREFIX = "/api/v1";
927
- class CloudClient {
928
- fetch;
929
- config;
930
- constructor(config) {
931
- this.config = {
932
- timeout: 1e4,
933
- enableRetry: true,
934
- maxRetries: 3,
935
- enableTelemetry: true,
936
- ...config
937
- };
938
- this.fetch = ofetch.create({
939
- baseURL: this.config.baseURL,
940
- timeout: this.config.timeout,
941
- headers: {
942
- "User-Agent": `CCJK/${this.config.version || CCJK_VERSION}`,
943
- ...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }
944
- },
945
- retry: this.config.enableRetry ? this.config.maxRetries : 0,
946
- retryDelay: (context) => this.calculateRetryDelay(context.options.retry || 0)
947
- });
948
- }
949
- /**
950
- * Calculate retry delay with exponential backoff
951
- */
952
- calculateRetryDelay(attempt) {
953
- const delays = [100, 200, 400, 800];
954
- return delays[Math.min(attempt, delays.length - 1)];
955
- }
956
- /**
957
- * Handle fetch errors and convert to CloudClientError
958
- */
959
- handleError(error, context) {
960
- if (error instanceof CloudClientError) {
961
- throw error;
962
- }
963
- if (error instanceof Error) {
964
- const errorMessage = error.message || "";
965
- if (errorMessage.includes("timeout") || errorMessage.includes("timed out")) {
966
- throw CloudClientError.timeout(this.config.timeout || 1e4);
967
- }
968
- if (errorMessage.includes("ECONNREFUSED") || errorMessage.includes("ENOTFOUND")) {
969
- throw CloudClientError.network(error);
970
- }
971
- const statusMatch = errorMessage.match(/(\d{3})\s+/);
972
- const statusCode = statusMatch ? Number.parseInt(statusMatch[1]) : void 0;
973
- let responseDetails = errorMessage;
974
- try {
975
- if (errorMessage.includes(":")) {
976
- const parts = errorMessage.split(":");
977
- if (parts.length > 1) {
978
- responseDetails = parts.slice(1).join(":").trim();
979
- }
980
- }
981
- } catch {
982
- }
983
- consola.warn(`Cloud API error in ${context}:`, {
984
- statusCode,
985
- message: responseDetails,
986
- originalError: error
987
- });
988
- if (statusCode) {
989
- throw CloudClientError.fromResponse(statusCode, responseDetails);
990
- }
991
- throw new CloudClientError(
992
- "UNKNOWN_ERROR",
993
- `Unexpected error during ${context}: ${responseDetails}`,
994
- void 0,
995
- error
996
- );
997
- }
998
- consola.warn(`Cloud API error in ${context}:`, error);
999
- throw new CloudClientError(
1000
- "UNKNOWN_ERROR",
1001
- `Unexpected error during ${context}`,
1002
- void 0,
1003
- error
1004
- );
1005
- }
1006
- /**
1007
- * Analyze project and get recommendations
1008
- *
1009
- * POST /api/v1/analysis/projects
1010
- *
1011
- * @param request - Project analysis request
1012
- * @returns Project analysis response with recommendations
1013
- */
1014
- async analyzeProject(request) {
1015
- try {
1016
- consola.debug("Analyzing project:", request.projectRoot);
1017
- const response = await this.fetch(`${API_PREFIX}/analysis/projects`, {
1018
- method: "POST",
1019
- body: request
1020
- });
1021
- consola.debug(`Received ${response.recommendations.length} recommendations`);
1022
- return response;
1023
- } catch (error) {
1024
- this.handleError(error, "project analysis");
1025
- }
1026
- }
1027
- /**
1028
- * Get a single template by ID
1029
- *
1030
- * GET /api/v1/templates/:id
1031
- *
1032
- * @param id - Template identifier
1033
- * @param language - Language for translations (optional)
1034
- * @returns Template response
1035
- */
1036
- async getTemplate(id, language) {
1037
- try {
1038
- consola.debug("Fetching template:", id);
1039
- const response = await this.fetch(`${API_PREFIX}/templates/${encodeURIComponent(id)}`, {
1040
- method: "GET",
1041
- params: language ? { language } : void 0
1042
- });
1043
- consola.debug(`Template ${id} fetched successfully`);
1044
- return response;
1045
- } catch (error) {
1046
- this.handleError(error, `template fetch: ${id}`);
1047
- }
1048
- }
1049
- /**
1050
- * Get multiple templates in batch
1051
- *
1052
- * POST /api/v1/templates/batch
1053
- *
1054
- * @param request - Batch template request
1055
- * @returns Batch template response
1056
- */
1057
- async getBatchTemplates(request) {
1058
- try {
1059
- consola.debug("Fetching batch templates:", request.ids.length);
1060
- const response = await this.fetch(`${API_PREFIX}/templates/batch`, {
1061
- method: "POST",
1062
- body: request
1063
- });
1064
- consola.debug(`Fetched ${Object.keys(response.templates).length} templates`);
1065
- return response;
1066
- } catch (error) {
1067
- this.handleError(error, "batch template fetch");
1068
- }
1069
- }
1070
- /**
1071
- * Report usage metrics (non-blocking with short timeout)
1072
- *
1073
- * POST /api/v1/telemetry/installation
1074
- *
1075
- * @param report - Usage report payload
1076
- * @returns Usage report response
1077
- */
1078
- async reportUsage(report) {
1079
- try {
1080
- consola.debug("Reporting usage:", report.metricType);
1081
- const response = await this.fetch(`${API_PREFIX}/telemetry/installation`, {
1082
- method: "POST",
1083
- body: report,
1084
- timeout: 5e3
1085
- // 5s timeout - telemetry should be fast
1086
- });
1087
- consola.debug("Usage report accepted");
1088
- return response;
1089
- } catch (error) {
1090
- consola.debug("Failed to report usage (non-blocking):", error);
1091
- return {
1092
- success: false,
1093
- requestId: "",
1094
- message: error instanceof Error ? error.message : "Unknown error"
1095
- };
1096
- }
1097
- }
1098
- /**
1099
- * Check API health status
1100
- *
1101
- * GET /api/v1/health
1102
- *
1103
- * @returns Health check response
1104
- */
1105
- async healthCheck() {
1106
- try {
1107
- consola.debug("Checking API health");
1108
- const response = await this.fetch(`${API_PREFIX}/health`, {
1109
- method: "GET"
1110
- });
1111
- consola.debug(`API health: ${response.status}`);
1112
- return response;
1113
- } catch (error) {
1114
- this.handleError(error, "health check");
1115
- }
1116
- }
1117
- /**
1118
- * Update client configuration
1119
- *
1120
- * @param config - Partial configuration to update
1121
- */
1122
- updateConfig(config) {
1123
- this.config = { ...this.config, ...config };
1124
- if (config.baseURL || config.timeout || config.apiKey) {
1125
- this.fetch = ofetch.create({
1126
- baseURL: this.config.baseURL,
1127
- timeout: this.config.timeout,
1128
- headers: {
1129
- "User-Agent": `CCJK/${this.config.version || CCJK_VERSION}`,
1130
- ...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }
1131
- },
1132
- retry: this.config.enableRetry ? this.config.maxRetries : 0,
1133
- retryDelay: (context) => this.calculateRetryDelay(context.options.retry || 0)
1134
- });
1135
- }
1136
- }
1137
- /**
1138
- * Get current configuration
1139
- */
1140
- getConfig() {
1141
- return { ...this.config };
1142
- }
1143
- }
1144
- function createCloudClient(config) {
1145
- return new CloudClient({
1146
- baseURL: "https://api.claudehome.cn",
1147
- timeout: 1e4,
1148
- version: CCJK_VERSION,
1149
- enableCache: true,
1150
- enableRetry: true,
1151
- maxRetries: 3,
1152
- enableTelemetry: true,
1153
- ...config
1154
- });
1155
- }
1156
-
1157
- const DEFAULT_RETRY_CONFIG = {
1158
- maxAttempts: 3,
1159
- initialDelay: 100,
1160
- multiplier: 2,
1161
- maxDelay: 800,
1162
- retryableStatusCodes: [500, 502, 503, 504, 408, 429]
1163
- };
1164
- async function withRetry(fn, config = {}) {
1165
- const retryConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
1166
- let lastError;
1167
- for (let attempt = 0; attempt < retryConfig.maxAttempts; attempt++) {
1168
- try {
1169
- return await fn();
1170
- } catch (error) {
1171
- lastError = error;
1172
- if (!shouldRetry(error, retryConfig, attempt)) {
1173
- throw error;
1174
- }
1175
- const delay = Math.min(
1176
- retryConfig.initialDelay * retryConfig.multiplier ** attempt,
1177
- retryConfig.maxDelay
1178
- );
1179
- consola.warn(
1180
- `Request failed (attempt ${attempt + 1}/${retryConfig.maxAttempts}), retrying in ${delay}ms:`,
1181
- error instanceof Error ? error.message : error
1182
- );
1183
- await sleep(delay);
1184
- }
1185
- }
1186
- throw lastError;
1187
- }
1188
- function shouldRetry(error, config, attempt) {
1189
- if (attempt >= config.maxAttempts - 1) {
1190
- return false;
1191
- }
1192
- if (error instanceof CloudClientError) {
1193
- if (error.type === "VALIDATION_ERROR" || error.type === "AUTH_ERROR") {
1194
- return false;
1195
- }
1196
- if (error.type === "NETWORK_ERROR" || error.type === "TIMEOUT_ERROR") {
1197
- return true;
1198
- }
1199
- if (error.statusCode && config.retryableStatusCodes.includes(error.statusCode)) {
1200
- return true;
1201
- }
1202
- }
1203
- if (error instanceof Error) {
1204
- const message = error.message.toLowerCase();
1205
- if (message.includes("network") || message.includes("connection") || message.includes("timeout") || message.includes("econnrefused") || message.includes("enotfound")) {
1206
- return true;
1207
- }
1208
- }
1209
- return false;
1210
- }
1211
- function sleep(ms) {
1212
- return new Promise((resolve) => setTimeout(resolve, ms));
1213
- }
1214
- class RetryableCloudClient {
1215
- client;
1216
- retryConfig;
1217
- constructor(client, retryConfig = {}) {
1218
- this.client = client;
1219
- this.retryConfig = retryConfig;
1220
- }
1221
- /**
1222
- * Analyze project with retry
1223
- */
1224
- analyzeProject = async (request) => {
1225
- return withRetry(
1226
- () => this.client.analyzeProject(request),
1227
- this.retryConfig
1228
- );
1229
- };
1230
- /**
1231
- * Get template with retry
1232
- */
1233
- getTemplate = async (id, language) => {
1234
- return withRetry(
1235
- () => this.client.getTemplate(id, language),
1236
- this.retryConfig
1237
- );
1238
- };
1239
- /**
1240
- * Get batch templates with retry
1241
- */
1242
- getBatchTemplates = async (request) => {
1243
- return withRetry(
1244
- () => this.client.getBatchTemplates(request),
1245
- this.retryConfig
1246
- );
1247
- };
1248
- /**
1249
- * Report usage (no retry)
1250
- */
1251
- reportUsage = async (report) => {
1252
- return this.client.reportUsage(report);
1253
- };
1254
- /**
1255
- * Health check (no retry)
1256
- */
1257
- healthCheck = async () => {
1258
- return withRetry(
1259
- () => this.client.healthCheck(),
1260
- this.retryConfig
1261
- );
1262
- };
1263
- /**
1264
- * Get underlying client
1265
- */
1266
- getClient() {
1267
- return this.client;
1268
- }
1269
- }
1270
- const retryUtils = {
1271
- /**
1272
- * Retry a function with exponential backoff
1273
- */
1274
- withRetry,
1275
- /**
1276
- * Calculate retry delay
1277
- */
1278
- calculateDelay(attempt, initialDelay = 100, multiplier = 2, maxDelay = 800) {
1279
- return Math.min(
1280
- initialDelay * multiplier ** attempt,
1281
- maxDelay
1282
- );
1283
- },
1284
- /**
1285
- * Check if error is retryable
1286
- */
1287
- isRetryable(error) {
1288
- if (error instanceof CloudClientError) {
1289
- return error.type === "NETWORK_ERROR" || error.type === "TIMEOUT_ERROR" || error.statusCode !== void 0 && [500, 502, 503, 504, 408, 429].includes(error.statusCode);
1290
- }
1291
- if (error instanceof Error) {
1292
- const message = error.message.toLowerCase();
1293
- return message.includes("network") || message.includes("connection") || message.includes("timeout") || message.includes("econnrefused") || message.includes("enotfound");
1294
- }
1295
- return false;
1296
- }
1297
- };
1298
-
1299
- const DEFAULT_TELEMETRY_CONFIG = {
1300
- enabled: true,
1301
- batchSize: 10,
1302
- flushInterval: 3e4
1303
- // 30 seconds
1304
- };
1305
- class TelemetryReporter {
1306
- client;
1307
- config;
1308
- events = [];
1309
- flushTimer;
1310
- userId;
1311
- constructor(client, config = {}) {
1312
- this.client = client;
1313
- this.config = { ...DEFAULT_TELEMETRY_CONFIG, ...config };
1314
- this.userId = this.config.userId || this.generateUserId();
1315
- if (this.config.enabled) {
1316
- this.startFlushTimer();
1317
- }
1318
- }
1319
- /**
1320
- * Generate or load anonymous user ID
1321
- */
1322
- generateUserId() {
1323
- const envUserId = process.env.CCJK_TELEMETRY_USER_ID;
1324
- if (envUserId) {
1325
- return envUserId;
1326
- }
1327
- return randomUUID();
1328
- }
1329
- /**
1330
- * Start periodic flush timer
1331
- */
1332
- startFlushTimer() {
1333
- this.flushTimer = setInterval(() => {
1334
- if (this.events.length > 0) {
1335
- this.flush().catch((error) => {
1336
- consola.debug("Failed to flush telemetry events:", error);
1337
- });
1338
- }
1339
- }, this.config.flushInterval);
1340
- this.flushTimer.unref();
1341
- }
1342
- /**
1343
- * Stop flush timer
1344
- */
1345
- stopFlushTimer() {
1346
- if (this.flushTimer) {
1347
- clearInterval(this.flushTimer);
1348
- this.flushTimer = void 0;
1349
- }
1350
- }
1351
- /**
1352
- * Check if telemetry is enabled
1353
- */
1354
- isEnabled() {
1355
- if (process.env.CCJK_TELEMETRY === "false") {
1356
- return false;
1357
- }
1358
- return this.config.enabled;
1359
- }
1360
- /**
1361
- * Track an event (non-blocking)
1362
- *
1363
- * @param type - Event type
1364
- * @param data - Additional event data
1365
- */
1366
- track(type, data) {
1367
- if (!this.isEnabled()) {
1368
- return;
1369
- }
1370
- const event = {
1371
- type,
1372
- data,
1373
- // Type assertion needed for flexible telemetry data
1374
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1375
- };
1376
- this.events.push(event);
1377
- consola.debug(`Telemetry event tracked: ${type}`, data);
1378
- if (this.events.length >= this.config.batchSize) {
1379
- this.flush().catch((error) => {
1380
- consola.debug("Telemetry flush failed (non-blocking):", error);
1381
- });
1382
- }
1383
- }
1384
- /**
1385
- * Track template download
1386
- */
1387
- trackTemplateDownload(templateId, templateType) {
1388
- this.track("template_download", {
1389
- templateId,
1390
- templateType,
1391
- timestamp: Date.now()
1392
- });
1393
- }
1394
- /**
1395
- * Track recommendation shown
1396
- */
1397
- trackRecommendationShown(recommendationId, category) {
1398
- this.track("recommendation_shown", {
1399
- recommendationId,
1400
- category,
1401
- timestamp: Date.now()
1402
- });
1403
- }
1404
- /**
1405
- * Track recommendation accepted
1406
- */
1407
- trackRecommendationAccepted(recommendationId, category) {
1408
- this.track("recommendation_accepted", {
1409
- recommendationId,
1410
- category,
1411
- timestamp: Date.now()
1412
- });
1413
- }
1414
- /**
1415
- * Track analysis completed
1416
- */
1417
- trackAnalysisCompleted(projectType, frameworks) {
1418
- this.track("analysis_completed", {
1419
- projectType,
1420
- frameworks,
1421
- recommendationCount: frameworks?.length || 0,
1422
- timestamp: Date.now()
1423
- });
1424
- }
1425
- /**
1426
- * Track error occurred
1427
- */
1428
- trackError(errorType, errorMessage, context) {
1429
- this.track("error_occurred", {
1430
- errorType,
1431
- errorMessage,
1432
- context,
1433
- timestamp: Date.now()
1434
- });
1435
- }
1436
- /**
1437
- * Flush pending events to server (non-blocking)
1438
- * Errors are caught and logged silently
1439
- */
1440
- async flush() {
1441
- if (!this.isEnabled() || this.events.length === 0) {
1442
- return;
1443
- }
1444
- const eventsToSend = [...this.events];
1445
- this.events = [];
1446
- try {
1447
- consola.debug(`Flushing ${eventsToSend.length} telemetry events`);
1448
- const batchSize = 100;
1449
- for (let i = 0; i < eventsToSend.length; i += batchSize) {
1450
- const batch = eventsToSend.slice(i, i + batchSize);
1451
- await this.sendBatch(batch);
1452
- }
1453
- consola.debug("Telemetry events flushed successfully");
1454
- } catch (error) {
1455
- consola.debug("Telemetry flush failed silently:", error);
1456
- }
1457
- }
1458
- /**
1459
- * Send a batch of events (non-blocking with retry budget)
1460
- */
1461
- async sendBatch(events) {
1462
- const report = {
1463
- reportId: randomUUID(),
1464
- metricType: "analysis_completed",
1465
- // Batch metric type
1466
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1467
- ccjkVersion: process.env.npm_package_version || "8.0.0",
1468
- nodeVersion: process.version,
1469
- platform: process.platform,
1470
- data: {
1471
- events,
1472
- batchSize: events.length,
1473
- userId: this.userId
1474
- }
1475
- };
1476
- await this.sendWithRetry(report, 3, 5e3);
1477
- }
1478
- /**
1479
- * Send telemetry with retry budget and short timeout
1480
- * Non-blocking: failures are logged but not thrown
1481
- */
1482
- async sendWithRetry(report, maxAttempts, timeout) {
1483
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1484
- try {
1485
- const timeoutPromise = new Promise((_, reject) => {
1486
- setTimeout(() => reject(new Error("Telemetry timeout")), timeout);
1487
- });
1488
- await Promise.race([
1489
- this.client.reportUsage(report),
1490
- timeoutPromise
1491
- ]);
1492
- consola.debug(`Telemetry sent successfully (attempt ${attempt}/${maxAttempts})`);
1493
- return;
1494
- } catch (error) {
1495
- consola.debug(
1496
- `Telemetry attempt ${attempt}/${maxAttempts} failed:`,
1497
- error instanceof Error ? error.message : error
1498
- );
1499
- if (attempt === maxAttempts) {
1500
- consola.debug("Telemetry failed after all retry attempts - giving up silently");
1501
- return;
1502
- }
1503
- const delay = 100 * 2 ** (attempt - 1);
1504
- await new Promise((resolve) => setTimeout(resolve, delay));
1505
- }
1506
- }
1507
- }
1508
- /**
1509
- * Stop telemetry and flush remaining events
1510
- */
1511
- async stop() {
1512
- this.stopFlushTimer();
1513
- if (this.events.length > 0) {
1514
- await this.flush();
1515
- }
1516
- }
1517
- /**
1518
- * Get current queue size
1519
- */
1520
- getQueueSize() {
1521
- return this.events.length;
1522
- }
1523
- /**
1524
- * Get telemetry status
1525
- */
1526
- getStatus() {
1527
- return {
1528
- enabled: this.isEnabled(),
1529
- queueSize: this.getQueueSize(),
1530
- userId: this.userId
1531
- };
1532
- }
1533
- /**
1534
- * Report usage directly (non-blocking)
1535
- * Fire-and-forget with retry budget and short timeout
1536
- *
1537
- * @param report - Usage report to send
1538
- */
1539
- reportUsage(report) {
1540
- if (!this.isEnabled()) {
1541
- return;
1542
- }
1543
- this.sendWithRetry(report, 3, 5e3).catch((error) => {
1544
- consola.debug("Direct usage report failed (non-blocking):", error);
1545
- });
1546
- }
1547
- }
1548
- let globalTelemetry;
1549
- function initializeTelemetry(client, config) {
1550
- if (globalTelemetry) {
1551
- globalTelemetry.stop().catch(() => {
1552
- });
1553
- }
1554
- globalTelemetry = new TelemetryReporter(client, config);
1555
- return globalTelemetry;
1556
- }
1557
- function getTelemetry() {
1558
- return globalTelemetry;
1559
- }
1560
- async function stopTelemetry() {
1561
- if (globalTelemetry) {
1562
- await globalTelemetry.stop();
1563
- globalTelemetry = void 0;
1564
- }
1565
- }
1566
- function trackEvent(type, data) {
1567
- if (globalTelemetry) {
1568
- globalTelemetry.track(type, data);
1569
- }
1570
- }
1571
- const telemetryUtils = {
1572
- /**
1573
- * Check if telemetry is enabled
1574
- */
1575
- isEnabled() {
1576
- if (globalTelemetry) {
1577
- return globalTelemetry.isEnabled();
1578
- }
1579
- return process.env.CCJK_TELEMETRY !== "false";
1580
- },
1581
- /**
1582
- * Track with automatic error handling
1583
- */
1584
- trackSafe(type, data) {
1585
- try {
1586
- trackEvent(type, data);
1587
- } catch (error) {
1588
- consola.debug("Failed to track telemetry event:", error);
1589
- }
1590
- },
1591
- /**
1592
- * Get telemetry status
1593
- */
1594
- getStatus() {
1595
- if (globalTelemetry) {
1596
- return globalTelemetry.getStatus();
1597
- }
1598
- return { enabled: false, queueSize: 0, userId: "" };
1599
- }
1600
- };
1601
-
1602
- class FallbackCloudClient {
1603
- client;
1604
- fallbackEnabled;
1605
- constructor(client, fallbackEnabled = true) {
1606
- this.client = client;
1607
- this.fallbackEnabled = fallbackEnabled;
1608
- }
1609
- /**
1610
- * Analyze project with fallback
1611
- */
1612
- async analyzeProject(request) {
1613
- try {
1614
- return await this.client.analyzeProject(request);
1615
- } catch (error) {
1616
- if (this.fallbackEnabled) {
1617
- consola.warn("Cloud API unavailable, using local recommendations");
1618
- return this.getLocalRecommendations(request);
1619
- }
1620
- throw error;
1621
- }
1622
- }
1623
- /**
1624
- * Get template with fallback
1625
- */
1626
- async getTemplate(id, language) {
1627
- try {
1628
- return await this.client.getTemplate(id, language);
1629
- } catch (error) {
1630
- if (this.fallbackEnabled) {
1631
- consola.warn("Cloud API unavailable, using local template");
1632
- return this.getLocalTemplate(id, language);
1633
- }
1634
- throw error;
1635
- }
1636
- }
1637
- /**
1638
- * Get batch templates with fallback
1639
- */
1640
- async getBatchTemplates(request) {
1641
- try {
1642
- return await this.client.getBatchTemplates(request);
1643
- } catch (error) {
1644
- if (this.fallbackEnabled) {
1645
- consola.warn("Cloud API unavailable, using local templates");
1646
- return this.getLocalBatchTemplates(request);
1647
- }
1648
- throw error;
1649
- }
1650
- }
1651
- /**
1652
- * Report usage (no fallback)
1653
- */
1654
- async reportUsage(report) {
1655
- return this.client.reportUsage(report);
1656
- }
1657
- /**
1658
- * Health check (no fallback)
1659
- */
1660
- async healthCheck() {
1661
- return this.client.healthCheck();
1662
- }
1663
- /**
1664
- * Get local fallback recommendations
1665
- */
1666
- getLocalRecommendations(request) {
1667
- const recommendations = [];
1668
- if (request.devDependencies?.typescript || request.devDependencies?.tslib) {
1669
- recommendations.push({
1670
- id: "typescript-workflow",
1671
- name: { "en": "TypeScript Workflow", "zh-CN": "TypeScript \u5DE5\u4F5C\u6D41" },
1672
- description: { "en": "Enhanced TypeScript support", "zh-CN": "\u589E\u5F3A\u7684 TypeScript \u652F\u6301" },
1673
- category: "skill",
1674
- relevanceScore: 0.9,
1675
- installCommand: "ccjk config switch typescript",
1676
- tags: ["typescript", "type-checking"]
1677
- });
1678
- }
1679
- if (request.dependencies?.react || request.dependencies?.["react-dom"]) {
1680
- recommendations.push({
1681
- id: "react-workflow",
1682
- name: { "en": "React Workflow", "zh-CN": "React \u5DE5\u4F5C\u6D41" },
1683
- description: { "en": "React development tools", "zh-CN": "React \u5F00\u53D1\u5DE5\u5177" },
1684
- category: "skill",
1685
- relevanceScore: 0.95,
1686
- installCommand: "ccjk config switch react",
1687
- tags: ["react", "jsx", "frontend"]
1688
- });
1689
- }
1690
- if (request.dependencies?.express || request.dependencies?.fastify) {
1691
- recommendations.push({
1692
- id: "nodejs-workflow",
1693
- name: { "en": "Node.js Workflow", "zh-CN": "Node.js \u5DE5\u4F5C\u6D41" },
1694
- description: { "en": "Node.js development tools", "zh-CN": "Node.js \u5F00\u53D1\u5DE5\u5177" },
1695
- category: "skill",
1696
- relevanceScore: 0.9,
1697
- installCommand: "ccjk config switch nodejs",
1698
- tags: ["nodejs", "backend", "server"]
1699
- });
1700
- }
1701
- if (request.gitRemote) {
1702
- recommendations.push({
1703
- id: "git-workflow",
1704
- name: { "en": "Git Workflow", "zh-CN": "Git \u5DE5\u4F5C\u6D41" },
1705
- description: { "en": "Git best practices", "zh-CN": "Git \u6700\u4F73\u5B9E\u8DF5" },
1706
- category: "skill",
1707
- relevanceScore: 0.8,
1708
- installCommand: "ccjk config switch git",
1709
- tags: ["git", "vcs"]
1710
- });
1711
- }
1712
- return {
1713
- requestId: "local-fallback",
1714
- recommendations,
1715
- projectType: this.detectProjectType(request),
1716
- frameworks: this.detectFrameworks(request)
1717
- };
1718
- }
1719
- /**
1720
- * Get local fallback template
1721
- */
1722
- getLocalTemplate(id, _language) {
1723
- const templates = {
1724
- "basic-workflow": {
1725
- id: "basic-workflow",
1726
- type: "workflow",
1727
- name: { "en": "Basic Workflow", "zh-CN": "\u57FA\u7840\u5DE5\u4F5C\u6D41" },
1728
- description: { "en": "Basic development workflow", "zh-CN": "\u57FA\u7840\u5F00\u53D1\u5DE5\u4F5C\u6D41" },
1729
- content: JSON.stringify({
1730
- name: "basic",
1731
- steps: ["init", "test", "build", "deploy"]
1732
- }, null, 2),
1733
- version: "1.0.0",
1734
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1735
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1736
- }
1737
- };
1738
- return templates[id] || {
1739
- id,
1740
- type: "workflow",
1741
- name: { "en": "Unknown Template", "zh-CN": "\u672A\u77E5\u6A21\u677F" },
1742
- description: { "en": "Template not found", "zh-CN": "\u6A21\u677F\u672A\u627E\u5230" },
1743
- content: "{}",
1744
- version: "1.0.0",
1745
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1746
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1747
- };
1748
- }
1749
- /**
1750
- * Get local fallback batch templates
1751
- */
1752
- getLocalBatchTemplates(request) {
1753
- const templates = {};
1754
- const notFound = [];
1755
- for (const id of request.ids) {
1756
- try {
1757
- templates[id] = this.getLocalTemplate(id, request.language);
1758
- } catch {
1759
- notFound.push(id);
1760
- }
1761
- }
1762
- return {
1763
- requestId: "local-fallback",
1764
- templates,
1765
- notFound
1766
- };
1767
- }
1768
- /**
1769
- * Detect project type
1770
- */
1771
- detectProjectType(request) {
1772
- if (request.dependencies?.react)
1773
- return "react";
1774
- if (request.dependencies?.vue)
1775
- return "vue";
1776
- if (request.dependencies?.express)
1777
- return "nodejs";
1778
- if (request.devDependencies?.typescript)
1779
- return "typescript";
1780
- return "generic";
1781
- }
1782
- /**
1783
- * Detect frameworks
1784
- */
1785
- detectFrameworks(request) {
1786
- const frameworks = [];
1787
- const deps = { ...request.dependencies, ...request.devDependencies };
1788
- if (deps.react)
1789
- frameworks.push("react");
1790
- if (deps.vue)
1791
- frameworks.push("vue");
1792
- if (deps.angular)
1793
- frameworks.push("angular");
1794
- if (deps.svelte)
1795
- frameworks.push("svelte");
1796
- if (deps.express)
1797
- frameworks.push("express");
1798
- if (deps.fastify)
1799
- frameworks.push("fastify");
1800
- if (deps.typescript)
1801
- frameworks.push("typescript");
1802
- if (deps.webpack)
1803
- frameworks.push("webpack");
1804
- if (deps.vite)
1805
- frameworks.push("vite");
1806
- return frameworks;
1807
- }
1808
- }
1809
- function createCompleteCloudClient(config) {
1810
- const baseClient = createCloudClient(config);
1811
- const retryClient = new RetryableCloudClient(baseClient);
1812
- const cache = new CloudCache(baseClient.getConfig());
1813
- const cachedClient = new CachedCloudClient(retryClient.getClient(), cache);
1814
- const fallbackClient = new FallbackCloudClient(cachedClient.getClient());
1815
- initializeTelemetry(baseClient);
1816
- return fallbackClient;
1817
- }
1818
-
1819
- export { CachedCloudClient as C, FallbackCloudClient as F, RetryableCloudClient as R, TelemetryReporter as T, createCloudClient as a, CloudCache as b, createCompleteCloudClient as c, CloudClient as d, trackEvent as e, getTelemetry as g, initializeTelemetry as i, retryUtils as r, stopTelemetry as s, telemetryUtils as t, withRetry as w };