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