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,1074 +0,0 @@
|
|
|
1
|
-
import { performance } from 'node:perf_hooks';
|
|
2
|
-
import { c as consola, P as ProjectAnalyzer, g as getTemplatesClient } from '../shared/ccjk.CoCHVXl3.mjs';
|
|
3
|
-
import { i as inquirer } from './index6.mjs';
|
|
4
|
-
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
5
|
-
import process__default from 'node:process';
|
|
6
|
-
import { exec } from 'node:child_process';
|
|
7
|
-
import { promisify } from 'node:util';
|
|
8
|
-
import { j as join, d as dirname } from '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
9
|
-
import { i18n } from './index2.mjs';
|
|
10
|
-
import './index10.mjs';
|
|
11
|
-
import 'tinyglobby';
|
|
12
|
-
import '../shared/ccjk.BBtCGd_g.mjs';
|
|
13
|
-
import './constants.mjs';
|
|
14
|
-
import 'node:os';
|
|
15
|
-
import 'node:url';
|
|
16
|
-
import 'node:readline';
|
|
17
|
-
import '../shared/ccjk.BAGoDD49.mjs';
|
|
18
|
-
import 'stream';
|
|
19
|
-
import 'node:tty';
|
|
20
|
-
import 'node:async_hooks';
|
|
21
|
-
import '../shared/ccjk.Cjgrln_h.mjs';
|
|
22
|
-
import 'tty';
|
|
23
|
-
import 'fs';
|
|
24
|
-
import 'child_process';
|
|
25
|
-
import 'node:path';
|
|
26
|
-
import 'node:crypto';
|
|
27
|
-
import 'buffer';
|
|
28
|
-
import 'string_decoder';
|
|
29
|
-
|
|
30
|
-
var HookType = /* @__PURE__ */ ((HookType2) => {
|
|
31
|
-
HookType2["PreRequest"] = "PreRequest";
|
|
32
|
-
HookType2["PostResponse"] = "PostResponse";
|
|
33
|
-
HookType2["ProviderSwitch"] = "ProviderSwitch";
|
|
34
|
-
HookType2["Error"] = "Error";
|
|
35
|
-
HookType2["SessionStart"] = "SessionStart";
|
|
36
|
-
HookType2["SessionEnd"] = "SessionEnd";
|
|
37
|
-
return HookType2;
|
|
38
|
-
})(HookType || {});
|
|
39
|
-
|
|
40
|
-
const execAsync = promisify(exec);
|
|
41
|
-
const DEFAULT_TIMEOUT = 5e3;
|
|
42
|
-
const MAX_TIMEOUT = 6e4;
|
|
43
|
-
class HookExecutor {
|
|
44
|
-
/**
|
|
45
|
-
* Execute a single hook with the given context
|
|
46
|
-
* @param hook - Hook configuration to execute
|
|
47
|
-
* @param context - Context data to pass to the hook
|
|
48
|
-
* @returns Promise resolving to execution result
|
|
49
|
-
*/
|
|
50
|
-
async execute(hook, context) {
|
|
51
|
-
const startTime = Date.now();
|
|
52
|
-
if (hook.enabled === false) {
|
|
53
|
-
return {
|
|
54
|
-
success: true,
|
|
55
|
-
hook,
|
|
56
|
-
executionTime: 0,
|
|
57
|
-
stdout: "",
|
|
58
|
-
stderr: "Hook is disabled"
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const timeout = this.validateTimeout(hook.timeout);
|
|
62
|
-
try {
|
|
63
|
-
const contextJson = JSON.stringify(context, null, 2);
|
|
64
|
-
const result = await this.executeCommand(hook.command, contextJson, timeout);
|
|
65
|
-
const executionTime = Date.now() - startTime;
|
|
66
|
-
return {
|
|
67
|
-
success: result.exitCode === 0,
|
|
68
|
-
hook,
|
|
69
|
-
executionTime,
|
|
70
|
-
stdout: result.stdout,
|
|
71
|
-
stderr: result.stderr,
|
|
72
|
-
exitCode: result.exitCode
|
|
73
|
-
};
|
|
74
|
-
} catch (error) {
|
|
75
|
-
const executionTime = Date.now() - startTime;
|
|
76
|
-
return {
|
|
77
|
-
success: false,
|
|
78
|
-
hook,
|
|
79
|
-
executionTime,
|
|
80
|
-
error: error instanceof Error ? error.message : String(error)
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Execute a command with timeout
|
|
86
|
-
* @param command - Command to execute
|
|
87
|
-
* @param contextJson - Context data as JSON string
|
|
88
|
-
* @param timeout - Timeout in milliseconds
|
|
89
|
-
* @returns Promise resolving to command output
|
|
90
|
-
*/
|
|
91
|
-
async executeCommand(command, contextJson, timeout) {
|
|
92
|
-
try {
|
|
93
|
-
const env = {
|
|
94
|
-
...process__default.env,
|
|
95
|
-
CCJK_HOOK_CONTEXT: contextJson
|
|
96
|
-
};
|
|
97
|
-
const { stdout, stderr } = await execAsync(command, {
|
|
98
|
-
timeout,
|
|
99
|
-
env,
|
|
100
|
-
maxBuffer: 1024 * 1024
|
|
101
|
-
// 1MB buffer
|
|
102
|
-
});
|
|
103
|
-
return {
|
|
104
|
-
stdout: stdout.trim(),
|
|
105
|
-
stderr: stderr.trim(),
|
|
106
|
-
exitCode: 0
|
|
107
|
-
};
|
|
108
|
-
} catch (error) {
|
|
109
|
-
return {
|
|
110
|
-
stdout: error.stdout?.trim() || "",
|
|
111
|
-
stderr: error.stderr?.trim() || error.message || "Unknown error",
|
|
112
|
-
exitCode: error.code || 1
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Execute a hook asynchronously without waiting for completion
|
|
118
|
-
* Used for hooks that should run in the background
|
|
119
|
-
* @param hook - Hook configuration to execute
|
|
120
|
-
* @param context - Context data to pass to the hook
|
|
121
|
-
*/
|
|
122
|
-
executeAsync(hook, context) {
|
|
123
|
-
this.execute(hook, context).catch((error) => {
|
|
124
|
-
console.error("[HookExecutor] Async hook execution failed:", error);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Validate and normalize timeout value
|
|
129
|
-
* @param timeout - Timeout value to validate
|
|
130
|
-
* @returns Validated timeout value
|
|
131
|
-
*/
|
|
132
|
-
validateTimeout(timeout) {
|
|
133
|
-
if (!timeout) {
|
|
134
|
-
return DEFAULT_TIMEOUT;
|
|
135
|
-
}
|
|
136
|
-
if (timeout < 0) {
|
|
137
|
-
return DEFAULT_TIMEOUT;
|
|
138
|
-
}
|
|
139
|
-
if (timeout > MAX_TIMEOUT) {
|
|
140
|
-
return MAX_TIMEOUT;
|
|
141
|
-
}
|
|
142
|
-
return timeout;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
const hookExecutor = new HookExecutor();
|
|
146
|
-
|
|
147
|
-
const DEFAULT_CONFIG_PATH = join(process__default.env.HOME || process__default.env.USERPROFILE || "~", ".ccjk", "hooks-config.json");
|
|
148
|
-
class HookManager {
|
|
149
|
-
hooks = {};
|
|
150
|
-
configPath;
|
|
151
|
-
enabled;
|
|
152
|
-
defaultTimeout;
|
|
153
|
-
/**
|
|
154
|
-
* Create a new HookManager instance
|
|
155
|
-
* @param options - Configuration options
|
|
156
|
-
*/
|
|
157
|
-
constructor(options = {}) {
|
|
158
|
-
this.configPath = options.configPath || DEFAULT_CONFIG_PATH;
|
|
159
|
-
this.enabled = options.enabled !== false;
|
|
160
|
-
this.defaultTimeout = options.defaultTimeout || 5e3;
|
|
161
|
-
this.loadHooksFromConfig();
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Register a new hook
|
|
165
|
-
* @param hook - Hook configuration to register
|
|
166
|
-
* @returns True if registration was successful
|
|
167
|
-
*/
|
|
168
|
-
registerHook(hook) {
|
|
169
|
-
try {
|
|
170
|
-
if (!this.hooks[hook.type]) {
|
|
171
|
-
this.hooks[hook.type] = [];
|
|
172
|
-
}
|
|
173
|
-
const existingIndex = this.hooks[hook.type].findIndex((h) => h.command === hook.command);
|
|
174
|
-
if (existingIndex >= 0) {
|
|
175
|
-
this.hooks[hook.type][existingIndex] = hook;
|
|
176
|
-
} else {
|
|
177
|
-
this.hooks[hook.type].push(hook);
|
|
178
|
-
}
|
|
179
|
-
this.saveHooksToConfig();
|
|
180
|
-
return true;
|
|
181
|
-
} catch (error) {
|
|
182
|
-
console.error("[HookManager] Failed to register hook:", error);
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Unregister a hook
|
|
188
|
-
* @param type - Hook type
|
|
189
|
-
* @param command - Command to unregister
|
|
190
|
-
* @returns True if unregistration was successful
|
|
191
|
-
*/
|
|
192
|
-
unregisterHook(type, command) {
|
|
193
|
-
try {
|
|
194
|
-
if (!this.hooks[type]) {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
const initialLength = this.hooks[type].length;
|
|
198
|
-
this.hooks[type] = this.hooks[type].filter((h) => h.command !== command);
|
|
199
|
-
if (this.hooks[type].length === initialLength) {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
this.saveHooksToConfig();
|
|
203
|
-
return true;
|
|
204
|
-
} catch (error) {
|
|
205
|
-
console.error("[HookManager] Failed to unregister hook:", error);
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Execute all hooks of a specific type
|
|
211
|
-
* @param type - Hook type to execute
|
|
212
|
-
* @param context - Context data to pass to hooks
|
|
213
|
-
* @returns Promise resolving to array of execution results
|
|
214
|
-
*/
|
|
215
|
-
async executeHooks(type, context) {
|
|
216
|
-
if (!this.enabled) {
|
|
217
|
-
return [];
|
|
218
|
-
}
|
|
219
|
-
const hooksToExecute = this.hooks[type] || [];
|
|
220
|
-
if (hooksToExecute.length === 0) {
|
|
221
|
-
return [];
|
|
222
|
-
}
|
|
223
|
-
const results = [];
|
|
224
|
-
for (const hook of hooksToExecute) {
|
|
225
|
-
const hookWithDefaults = {
|
|
226
|
-
...hook,
|
|
227
|
-
timeout: hook.timeout || this.defaultTimeout
|
|
228
|
-
};
|
|
229
|
-
if (hook.async) {
|
|
230
|
-
hookExecutor.executeAsync(hookWithDefaults, context);
|
|
231
|
-
results.push({
|
|
232
|
-
success: true,
|
|
233
|
-
hook: hookWithDefaults,
|
|
234
|
-
executionTime: 0,
|
|
235
|
-
stdout: "Executed asynchronously"
|
|
236
|
-
});
|
|
237
|
-
} else {
|
|
238
|
-
const result = await hookExecutor.execute(hookWithDefaults, context);
|
|
239
|
-
results.push(result);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return results;
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Get all registered hooks
|
|
246
|
-
* @returns All hooks organized by type
|
|
247
|
-
*/
|
|
248
|
-
getAllHooks() {
|
|
249
|
-
return { ...this.hooks };
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Get hooks of a specific type
|
|
253
|
-
* @param type - Hook type
|
|
254
|
-
* @returns Array of hooks for the specified type
|
|
255
|
-
*/
|
|
256
|
-
getHooksByType(type) {
|
|
257
|
-
return [...this.hooks[type] || []];
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Clear all hooks of a specific type
|
|
261
|
-
* @param type - Hook type to clear
|
|
262
|
-
* @returns True if clearing was successful
|
|
263
|
-
*/
|
|
264
|
-
clearHooksByType(type) {
|
|
265
|
-
try {
|
|
266
|
-
this.hooks[type] = [];
|
|
267
|
-
this.saveHooksToConfig();
|
|
268
|
-
return true;
|
|
269
|
-
} catch (error) {
|
|
270
|
-
console.error("[HookManager] Failed to clear hooks:", error);
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Clear all hooks
|
|
276
|
-
* @returns True if clearing was successful
|
|
277
|
-
*/
|
|
278
|
-
clearAllHooks() {
|
|
279
|
-
try {
|
|
280
|
-
this.hooks = {};
|
|
281
|
-
this.saveHooksToConfig();
|
|
282
|
-
return true;
|
|
283
|
-
} catch (error) {
|
|
284
|
-
console.error("[HookManager] Failed to clear all hooks:", error);
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Enable or disable hooks globally
|
|
290
|
-
* @param enabled - Whether to enable hooks
|
|
291
|
-
*/
|
|
292
|
-
setEnabled(enabled) {
|
|
293
|
-
this.enabled = enabled;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Check if hooks are enabled
|
|
297
|
-
* @returns True if hooks are enabled
|
|
298
|
-
*/
|
|
299
|
-
isEnabled() {
|
|
300
|
-
return this.enabled;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Load hooks from configuration file
|
|
304
|
-
*/
|
|
305
|
-
loadHooksFromConfig() {
|
|
306
|
-
try {
|
|
307
|
-
if (!existsSync(this.configPath)) {
|
|
308
|
-
this.hooks = {};
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
const configContent = readFileSync(this.configPath, "utf-8");
|
|
312
|
-
const config = JSON.parse(configContent);
|
|
313
|
-
this.hooks = this.validateHooksConfig(config);
|
|
314
|
-
} catch (error) {
|
|
315
|
-
console.error("[HookManager] Failed to load hooks from config:", error);
|
|
316
|
-
this.hooks = {};
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Save hooks to configuration file
|
|
321
|
-
*/
|
|
322
|
-
saveHooksToConfig() {
|
|
323
|
-
try {
|
|
324
|
-
const configDir = dirname(this.configPath);
|
|
325
|
-
if (!existsSync(configDir)) {
|
|
326
|
-
mkdirSync(configDir, { recursive: true });
|
|
327
|
-
}
|
|
328
|
-
const configContent = JSON.stringify(this.hooks, null, 2);
|
|
329
|
-
writeFileSync(this.configPath, configContent, "utf-8");
|
|
330
|
-
} catch (error) {
|
|
331
|
-
console.error("[HookManager] Failed to save hooks to config:", error);
|
|
332
|
-
throw error;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Validate hooks configuration
|
|
337
|
-
* @param config - Configuration to validate
|
|
338
|
-
* @returns Validated configuration
|
|
339
|
-
*/
|
|
340
|
-
validateHooksConfig(config) {
|
|
341
|
-
const validatedConfig = {};
|
|
342
|
-
for (const type of Object.values(HookType)) {
|
|
343
|
-
if (config[type] && Array.isArray(config[type])) {
|
|
344
|
-
validatedConfig[type] = config[type].filter((hook) => {
|
|
345
|
-
return hook && typeof hook === "object" && typeof hook.command === "string" && hook.command.length > 0;
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
return validatedConfig;
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Get configuration file path
|
|
353
|
-
* @returns Path to hooks configuration file
|
|
354
|
-
*/
|
|
355
|
-
getConfigPath() {
|
|
356
|
-
return this.configPath;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
const hookManager = new HookManager();
|
|
360
|
-
|
|
361
|
-
async function loadHookTemplates() {
|
|
362
|
-
const templates = [];
|
|
363
|
-
const templateDir = join(process.cwd(), "templates", "hooks");
|
|
364
|
-
if (!existsSync(templateDir)) {
|
|
365
|
-
return getDefaultTemplates();
|
|
366
|
-
}
|
|
367
|
-
try {
|
|
368
|
-
const hookTypes = ["pre-commit", "post-test", "lifecycle"];
|
|
369
|
-
for (const type of hookTypes) {
|
|
370
|
-
const typeDir = join(templateDir, type);
|
|
371
|
-
if (!existsSync(typeDir))
|
|
372
|
-
continue;
|
|
373
|
-
const files = require("node:fs").readdirSync(typeDir);
|
|
374
|
-
for (const file of files) {
|
|
375
|
-
if (!file.endsWith(".json"))
|
|
376
|
-
continue;
|
|
377
|
-
try {
|
|
378
|
-
const templatePath = join(typeDir, file);
|
|
379
|
-
const content = readFileSync(templatePath, "utf-8");
|
|
380
|
-
const template = JSON.parse(content);
|
|
381
|
-
templates.push(template);
|
|
382
|
-
} catch (error) {
|
|
383
|
-
console.error(`Failed to load template ${file}:`, error);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
} catch (error) {
|
|
388
|
-
console.error("Failed to load hook templates:", error);
|
|
389
|
-
}
|
|
390
|
-
return templates.length > 0 ? templates : getDefaultTemplates();
|
|
391
|
-
}
|
|
392
|
-
function getDefaultTemplates() {
|
|
393
|
-
return [
|
|
394
|
-
// Pre-commit hooks
|
|
395
|
-
{
|
|
396
|
-
name: "pre-commit-eslint",
|
|
397
|
-
description: "Run ESLint on staged files",
|
|
398
|
-
type: "pre-commit",
|
|
399
|
-
category: "pre-commit",
|
|
400
|
-
projectTypes: ["typescript", "javascript"],
|
|
401
|
-
trigger: {
|
|
402
|
-
matcher: "git:pre-commit",
|
|
403
|
-
condition: 'git diff --cached --name-only | grep -E "\\.(ts|js|tsx|jsx)$"'
|
|
404
|
-
},
|
|
405
|
-
action: {
|
|
406
|
-
command: "eslint",
|
|
407
|
-
args: ["--fix", "--staged"],
|
|
408
|
-
timeout: 3e4
|
|
409
|
-
},
|
|
410
|
-
enabled: true,
|
|
411
|
-
priority: 100
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
name: "pre-commit-prettier",
|
|
415
|
-
description: "Format code with Prettier",
|
|
416
|
-
type: "pre-commit",
|
|
417
|
-
category: "pre-commit",
|
|
418
|
-
projectTypes: ["typescript", "javascript"],
|
|
419
|
-
trigger: {
|
|
420
|
-
matcher: "git:pre-commit",
|
|
421
|
-
condition: 'git diff --cached --name-only | grep -E "\\.(ts|js|tsx|jsx|json|md)$"'
|
|
422
|
-
},
|
|
423
|
-
action: {
|
|
424
|
-
command: "prettier",
|
|
425
|
-
args: ["--write", "--staged"],
|
|
426
|
-
timeout: 15e3
|
|
427
|
-
},
|
|
428
|
-
enabled: true,
|
|
429
|
-
priority: 90
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
name: "pre-commit-types",
|
|
433
|
-
description: "Run TypeScript type checking",
|
|
434
|
-
type: "pre-commit",
|
|
435
|
-
category: "pre-commit",
|
|
436
|
-
projectTypes: ["typescript"],
|
|
437
|
-
trigger: {
|
|
438
|
-
matcher: "git:pre-commit"
|
|
439
|
-
},
|
|
440
|
-
action: {
|
|
441
|
-
command: "tsc",
|
|
442
|
-
args: ["--noEmit"],
|
|
443
|
-
timeout: 6e4
|
|
444
|
-
},
|
|
445
|
-
enabled: true,
|
|
446
|
-
priority: 80
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
name: "pre-commit-tests",
|
|
450
|
-
description: "Run relevant unit tests",
|
|
451
|
-
type: "pre-commit",
|
|
452
|
-
category: "pre-commit",
|
|
453
|
-
projectTypes: ["typescript", "javascript", "python", "rust"],
|
|
454
|
-
trigger: {
|
|
455
|
-
matcher: "git:pre-commit",
|
|
456
|
-
condition: 'git diff --cached --name-only | grep -E "(test|spec)"'
|
|
457
|
-
},
|
|
458
|
-
action: {
|
|
459
|
-
command: "npm",
|
|
460
|
-
args: ["test", "--", "--related"],
|
|
461
|
-
timeout: 12e4
|
|
462
|
-
},
|
|
463
|
-
enabled: false,
|
|
464
|
-
priority: 70
|
|
465
|
-
},
|
|
466
|
-
// Post-test hooks
|
|
467
|
-
{
|
|
468
|
-
name: "post-test-coverage",
|
|
469
|
-
description: "Generate coverage report after tests",
|
|
470
|
-
type: "post-test",
|
|
471
|
-
category: "post-test",
|
|
472
|
-
projectTypes: ["typescript", "javascript"],
|
|
473
|
-
trigger: {
|
|
474
|
-
matcher: "command:npm test"
|
|
475
|
-
},
|
|
476
|
-
action: {
|
|
477
|
-
command: "npm",
|
|
478
|
-
args: ["run", "coverage:report"],
|
|
479
|
-
timeout: 3e4
|
|
480
|
-
},
|
|
481
|
-
enabled: true,
|
|
482
|
-
priority: 100
|
|
483
|
-
},
|
|
484
|
-
{
|
|
485
|
-
name: "post-test-summary",
|
|
486
|
-
description: "Summarize test results",
|
|
487
|
-
type: "post-test",
|
|
488
|
-
category: "post-test",
|
|
489
|
-
projectTypes: ["typescript", "javascript", "python", "rust", "go"],
|
|
490
|
-
trigger: {
|
|
491
|
-
matcher: "command:*test*"
|
|
492
|
-
},
|
|
493
|
-
action: {
|
|
494
|
-
command: "ccjk",
|
|
495
|
-
args: ["test:summary"],
|
|
496
|
-
timeout: 1e4
|
|
497
|
-
},
|
|
498
|
-
enabled: true,
|
|
499
|
-
priority: 90
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
name: "post-test-notify",
|
|
503
|
-
description: "Send test result notifications",
|
|
504
|
-
type: "post-test",
|
|
505
|
-
category: "post-test",
|
|
506
|
-
projectTypes: ["typescript", "javascript", "python"],
|
|
507
|
-
trigger: {
|
|
508
|
-
matcher: "command:*test*",
|
|
509
|
-
condition: "exitCode != 0"
|
|
510
|
-
},
|
|
511
|
-
action: {
|
|
512
|
-
command: "ccjk",
|
|
513
|
-
args: ["notify", "--type", "test-failed"],
|
|
514
|
-
timeout: 5e3
|
|
515
|
-
},
|
|
516
|
-
enabled: false,
|
|
517
|
-
priority: 80
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
name: "post-test-benchmark",
|
|
521
|
-
description: "Track test performance metrics",
|
|
522
|
-
type: "post-test",
|
|
523
|
-
category: "post-test",
|
|
524
|
-
projectTypes: ["typescript", "javascript", "python", "rust"],
|
|
525
|
-
trigger: {
|
|
526
|
-
matcher: "command:*test*"
|
|
527
|
-
},
|
|
528
|
-
action: {
|
|
529
|
-
command: "ccjk",
|
|
530
|
-
args: ["benchmark:track", "--category", "test"],
|
|
531
|
-
timeout: 15e3
|
|
532
|
-
},
|
|
533
|
-
enabled: true,
|
|
534
|
-
priority: 70
|
|
535
|
-
},
|
|
536
|
-
// Lifecycle hooks
|
|
537
|
-
{
|
|
538
|
-
name: "post-install-setup",
|
|
539
|
-
description: "Run setup after dependencies install",
|
|
540
|
-
type: "post-install",
|
|
541
|
-
category: "lifecycle",
|
|
542
|
-
projectTypes: ["typescript", "javascript"],
|
|
543
|
-
trigger: {
|
|
544
|
-
matcher: "command:npm install"
|
|
545
|
-
},
|
|
546
|
-
action: {
|
|
547
|
-
command: "npm",
|
|
548
|
-
args: ["run", "postinstall"],
|
|
549
|
-
timeout: 6e4
|
|
550
|
-
},
|
|
551
|
-
enabled: true,
|
|
552
|
-
priority: 100
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
name: "pre-build-clean",
|
|
556
|
-
description: "Clean build directory before build",
|
|
557
|
-
type: "pre-build",
|
|
558
|
-
category: "lifecycle",
|
|
559
|
-
projectTypes: ["typescript", "javascript", "rust", "go"],
|
|
560
|
-
trigger: {
|
|
561
|
-
matcher: "command:*build*"
|
|
562
|
-
},
|
|
563
|
-
action: {
|
|
564
|
-
command: "rm",
|
|
565
|
-
args: ["-rf", "dist", "build"],
|
|
566
|
-
timeout: 5e3
|
|
567
|
-
},
|
|
568
|
-
enabled: true,
|
|
569
|
-
priority: 100
|
|
570
|
-
},
|
|
571
|
-
{
|
|
572
|
-
name: "post-build-size",
|
|
573
|
-
description: "Analyze build size after build",
|
|
574
|
-
type: "post-build",
|
|
575
|
-
category: "lifecycle",
|
|
576
|
-
projectTypes: ["typescript", "javascript"],
|
|
577
|
-
trigger: {
|
|
578
|
-
matcher: "command:*build*"
|
|
579
|
-
},
|
|
580
|
-
action: {
|
|
581
|
-
command: "ccjk",
|
|
582
|
-
args: ["build:analyze"],
|
|
583
|
-
timeout: 15e3
|
|
584
|
-
},
|
|
585
|
-
enabled: true,
|
|
586
|
-
priority: 90
|
|
587
|
-
},
|
|
588
|
-
{
|
|
589
|
-
name: "pre-push-checks",
|
|
590
|
-
description: "Run all checks before pushing",
|
|
591
|
-
type: "pre-push",
|
|
592
|
-
category: "lifecycle",
|
|
593
|
-
projectTypes: ["typescript", "javascript", "python", "rust"],
|
|
594
|
-
trigger: {
|
|
595
|
-
matcher: "git:pre-push"
|
|
596
|
-
},
|
|
597
|
-
action: {
|
|
598
|
-
command: "npm",
|
|
599
|
-
args: ["run", "ci"],
|
|
600
|
-
timeout: 3e5
|
|
601
|
-
},
|
|
602
|
-
enabled: true,
|
|
603
|
-
priority: 100
|
|
604
|
-
}
|
|
605
|
-
];
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
async function validateHookTrigger(trigger, projectInfo) {
|
|
609
|
-
try {
|
|
610
|
-
const { matcher, condition } = trigger;
|
|
611
|
-
if (!matcher || !matcher.includes(":")) {
|
|
612
|
-
throw new Error(`Invalid trigger matcher format: ${matcher}`);
|
|
613
|
-
}
|
|
614
|
-
const [type, pattern] = matcher.split(":", 2);
|
|
615
|
-
switch (type) {
|
|
616
|
-
case "git":
|
|
617
|
-
return await validateGitTrigger(pattern, condition, projectInfo);
|
|
618
|
-
case "file":
|
|
619
|
-
return await validateFileTrigger(pattern, condition, projectInfo);
|
|
620
|
-
case "command":
|
|
621
|
-
return await validateCommandTrigger(pattern, condition, projectInfo);
|
|
622
|
-
case "schedule":
|
|
623
|
-
return await validateScheduleTrigger(pattern, condition);
|
|
624
|
-
case "webhook":
|
|
625
|
-
return await validateWebhookTrigger(pattern, condition);
|
|
626
|
-
default:
|
|
627
|
-
throw new Error(`Unknown trigger type: ${type}`);
|
|
628
|
-
}
|
|
629
|
-
} catch (error) {
|
|
630
|
-
console.error(`Trigger validation failed: ${error}`);
|
|
631
|
-
return false;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
async function validateGitTrigger(pattern, condition, _projectInfo) {
|
|
635
|
-
const gitDir = join(process.cwd(), ".git");
|
|
636
|
-
if (!existsSync(gitDir)) {
|
|
637
|
-
throw new Error("Git repository not found");
|
|
638
|
-
}
|
|
639
|
-
const validGitHooks = [
|
|
640
|
-
"pre-commit",
|
|
641
|
-
"post-commit",
|
|
642
|
-
"commit-msg",
|
|
643
|
-
"prepare-commit-msg",
|
|
644
|
-
"pre-push",
|
|
645
|
-
"post-push",
|
|
646
|
-
"pre-merge",
|
|
647
|
-
"post-merge",
|
|
648
|
-
"pre-rebase",
|
|
649
|
-
"post-rebase",
|
|
650
|
-
"pre-checkout",
|
|
651
|
-
"post-checkout",
|
|
652
|
-
"pre-receive",
|
|
653
|
-
"post-receive",
|
|
654
|
-
"update",
|
|
655
|
-
"pre-applypatch",
|
|
656
|
-
"post-applypatch",
|
|
657
|
-
"applypatch-msg"
|
|
658
|
-
];
|
|
659
|
-
if (!validGitHooks.includes(pattern)) {
|
|
660
|
-
throw new Error(`Invalid git hook: ${pattern}`);
|
|
661
|
-
}
|
|
662
|
-
if (condition) {
|
|
663
|
-
const validConditions = [
|
|
664
|
-
"staged",
|
|
665
|
-
"unstaged",
|
|
666
|
-
"branch=",
|
|
667
|
-
"files=",
|
|
668
|
-
"message=",
|
|
669
|
-
"merge"
|
|
670
|
-
];
|
|
671
|
-
const hasValidCondition = validConditions.some((c) => condition.includes(c));
|
|
672
|
-
const isFilePatternCondition = /^[\w\-.*]+(\s*\|\|\s*[\w\-.*]+)*$/.test(condition.trim());
|
|
673
|
-
if (!hasValidCondition && !isFilePatternCondition) {
|
|
674
|
-
throw new Error(`Invalid git condition: ${condition}`);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
return true;
|
|
678
|
-
}
|
|
679
|
-
async function validateFileTrigger(pattern, condition, _projectInfo) {
|
|
680
|
-
if (!pattern || pattern.length === 0) {
|
|
681
|
-
throw new Error("File pattern cannot be empty");
|
|
682
|
-
}
|
|
683
|
-
const dangerousPatterns = [
|
|
684
|
-
"**/.git/**",
|
|
685
|
-
"**/node_modules/**",
|
|
686
|
-
"**/.ccjk/**",
|
|
687
|
-
"**/dist/**",
|
|
688
|
-
"**/build/**",
|
|
689
|
-
"**/*.{exe,dll,so,dylib}"
|
|
690
|
-
];
|
|
691
|
-
const isDangerous = dangerousPatterns.some((p) => pattern.includes(p));
|
|
692
|
-
if (isDangerous) {
|
|
693
|
-
console.warn(`Warning: Potentially dangerous file pattern: ${pattern}`);
|
|
694
|
-
}
|
|
695
|
-
if (condition) {
|
|
696
|
-
const validFileConditions = [
|
|
697
|
-
"created",
|
|
698
|
-
"modified",
|
|
699
|
-
"deleted",
|
|
700
|
-
"size>",
|
|
701
|
-
"size<",
|
|
702
|
-
"count>",
|
|
703
|
-
"count<"
|
|
704
|
-
];
|
|
705
|
-
const hasValidCondition = validFileConditions.some((c) => condition.includes(c));
|
|
706
|
-
if (!hasValidCondition) {
|
|
707
|
-
throw new Error(`Invalid file condition: ${condition}`);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
return true;
|
|
711
|
-
}
|
|
712
|
-
async function validateCommandTrigger(pattern, condition, _projectInfo) {
|
|
713
|
-
if (!pattern || pattern.length === 0) {
|
|
714
|
-
throw new Error("Command pattern cannot be empty");
|
|
715
|
-
}
|
|
716
|
-
const validPatterns = [
|
|
717
|
-
"npm",
|
|
718
|
-
"yarn",
|
|
719
|
-
"pnpm",
|
|
720
|
-
"pip",
|
|
721
|
-
"cargo",
|
|
722
|
-
"go",
|
|
723
|
-
"mvn",
|
|
724
|
-
"gradle",
|
|
725
|
-
"make",
|
|
726
|
-
"tsc",
|
|
727
|
-
"node",
|
|
728
|
-
"python",
|
|
729
|
-
"pytest",
|
|
730
|
-
"jest",
|
|
731
|
-
"vitest",
|
|
732
|
-
"mocha"
|
|
733
|
-
];
|
|
734
|
-
const isValidPattern = validPatterns.some((p) => pattern.includes(p));
|
|
735
|
-
if (!isValidPattern) {
|
|
736
|
-
console.warn(`Warning: Unusual command pattern: ${pattern}`);
|
|
737
|
-
}
|
|
738
|
-
if (condition) {
|
|
739
|
-
const validCommandConditions = [
|
|
740
|
-
"exitCode=",
|
|
741
|
-
"exitCode!=",
|
|
742
|
-
"duration>",
|
|
743
|
-
"duration<",
|
|
744
|
-
"stdout=",
|
|
745
|
-
"stderr=",
|
|
746
|
-
"output="
|
|
747
|
-
];
|
|
748
|
-
const hasValidCondition = validCommandConditions.some((c) => condition.includes(c));
|
|
749
|
-
if (!hasValidCondition) {
|
|
750
|
-
throw new Error(`Invalid command condition: ${condition}`);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
return true;
|
|
754
|
-
}
|
|
755
|
-
async function validateScheduleTrigger(pattern, _condition) {
|
|
756
|
-
const cronParts = pattern.split(" ");
|
|
757
|
-
if (cronParts.length !== 5) {
|
|
758
|
-
throw new Error(`Invalid cron pattern: ${pattern}. Expected 5 parts.`);
|
|
759
|
-
}
|
|
760
|
-
const validateCronPart = (part, min, max) => {
|
|
761
|
-
if (part === "*")
|
|
762
|
-
return true;
|
|
763
|
-
if (part.includes("/")) {
|
|
764
|
-
const [, step] = part.split("/");
|
|
765
|
-
const stepNum = Number.parseInt(step);
|
|
766
|
-
return !isNaN(stepNum) && stepNum > 0;
|
|
767
|
-
}
|
|
768
|
-
if (part.includes("-")) {
|
|
769
|
-
const [start, end] = part.split("-");
|
|
770
|
-
const startNum = Number.parseInt(start);
|
|
771
|
-
const endNum = Number.parseInt(end);
|
|
772
|
-
return !isNaN(startNum) && !isNaN(endNum) && startNum <= endNum;
|
|
773
|
-
}
|
|
774
|
-
if (part.includes(",")) {
|
|
775
|
-
return part.split(",").every((p) => validateCronPart(p, min, max));
|
|
776
|
-
}
|
|
777
|
-
const num = Number.parseInt(part);
|
|
778
|
-
return !isNaN(num) && num >= min && num <= max;
|
|
779
|
-
};
|
|
780
|
-
const validations = [
|
|
781
|
-
validateCronPart(cronParts[0], 0, 59),
|
|
782
|
-
// minutes
|
|
783
|
-
validateCronPart(cronParts[1], 0, 23),
|
|
784
|
-
// hours
|
|
785
|
-
validateCronPart(cronParts[2], 1, 31),
|
|
786
|
-
// days
|
|
787
|
-
validateCronPart(cronParts[3], 1, 12),
|
|
788
|
-
// months
|
|
789
|
-
validateCronPart(cronParts[4], 0, 7)
|
|
790
|
-
// weekdays
|
|
791
|
-
];
|
|
792
|
-
if (!validations.every((v) => v)) {
|
|
793
|
-
throw new Error(`Invalid cron pattern: ${pattern}`);
|
|
794
|
-
}
|
|
795
|
-
return true;
|
|
796
|
-
}
|
|
797
|
-
async function validateWebhookTrigger(pattern, condition) {
|
|
798
|
-
try {
|
|
799
|
-
const url = new URL(pattern);
|
|
800
|
-
if (!["http:", "https:"].includes(url.protocol)) {
|
|
801
|
-
throw new Error(`Invalid webhook protocol: ${url.protocol}`);
|
|
802
|
-
}
|
|
803
|
-
} catch {
|
|
804
|
-
throw new Error(`Invalid webhook URL: ${pattern}`);
|
|
805
|
-
}
|
|
806
|
-
if (condition) {
|
|
807
|
-
const validWebhookConditions = [
|
|
808
|
-
"method=",
|
|
809
|
-
"header=",
|
|
810
|
-
"body=",
|
|
811
|
-
"status=",
|
|
812
|
-
"content-type="
|
|
813
|
-
];
|
|
814
|
-
const hasValidCondition = validWebhookConditions.some((c) => condition.includes(c));
|
|
815
|
-
if (!hasValidCondition) {
|
|
816
|
-
throw new Error(`Invalid webhook condition: ${condition}`);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
return true;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
async function ccjkHooks(options = {}) {
|
|
823
|
-
const startTime = performance.now();
|
|
824
|
-
const { json = false, dryRun = false } = options;
|
|
825
|
-
if (!json) {
|
|
826
|
-
consola.log(i18n.t("hooks.analyzingProject"));
|
|
827
|
-
}
|
|
828
|
-
try {
|
|
829
|
-
const analyzer = new ProjectAnalyzer();
|
|
830
|
-
const projectInfo = await analyzer.analyze(process.cwd());
|
|
831
|
-
const projectType = projectInfo.projectType;
|
|
832
|
-
const framework = projectInfo.frameworks?.[0]?.name || "none";
|
|
833
|
-
if (!json) {
|
|
834
|
-
consola.success(i18n.t("hooks.projectDetected", {
|
|
835
|
-
type: projectType,
|
|
836
|
-
framework
|
|
837
|
-
}));
|
|
838
|
-
}
|
|
839
|
-
const isZh = i18n.language === "zh-CN";
|
|
840
|
-
const allHookTemplates = await loadHookTemplates();
|
|
841
|
-
let recommendedHooks = allHookTemplates.filter(
|
|
842
|
-
(template) => template.projectTypes.includes(projectType)
|
|
843
|
-
);
|
|
844
|
-
try {
|
|
845
|
-
const templatesClient = getTemplatesClient({ language: isZh ? "zh-CN" : "en" });
|
|
846
|
-
const cloudHooks = await Promise.race([
|
|
847
|
-
templatesClient.getHooks(),
|
|
848
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), 3e3))
|
|
849
|
-
]);
|
|
850
|
-
if (cloudHooks.length > 0) {
|
|
851
|
-
consola.success(isZh ? `\u4ECE\u4E91\u7AEF\u83B7\u53D6 ${cloudHooks.length} \u4E2A\u94A9\u5B50` : `Fetched ${cloudHooks.length} hooks from cloud`);
|
|
852
|
-
const languages = projectInfo.languages?.map((l) => l.language.toLowerCase()) || [];
|
|
853
|
-
const frameworks = projectInfo.frameworks?.map((f) => f.name.toLowerCase()) || [];
|
|
854
|
-
const relevantHooks = cloudHooks.filter((hook) => {
|
|
855
|
-
const tags = hook.tags || [];
|
|
856
|
-
const category = hook.category || "";
|
|
857
|
-
const compatibility = hook.compatibility || {};
|
|
858
|
-
return tags.some((tag) => languages.includes(tag) || frameworks.includes(tag) || projectType.includes(tag)) || (compatibility.languages || []).some((lang) => languages.includes(lang.toLowerCase())) || (compatibility.frameworks || []).some((fw) => frameworks.includes(fw.toLowerCase())) || category === "pre-commit" || category === "commit-msg";
|
|
859
|
-
});
|
|
860
|
-
const localHookNames = new Set(recommendedHooks.map((h) => h.name.toLowerCase()));
|
|
861
|
-
for (const hook of relevantHooks.length > 0 ? relevantHooks : cloudHooks.slice(0, 10)) {
|
|
862
|
-
const hookName = (hook.name_zh_cn && isZh ? hook.name_zh_cn : hook.name_en).toLowerCase();
|
|
863
|
-
if (localHookNames.has(hookName)) {
|
|
864
|
-
continue;
|
|
865
|
-
}
|
|
866
|
-
const hookConfig = {
|
|
867
|
-
name: hook.name_zh_cn && isZh ? hook.name_zh_cn : hook.name_en,
|
|
868
|
-
description: hook.description_zh_cn && isZh ? hook.description_zh_cn : hook.description_en || "",
|
|
869
|
-
type: hook.category || "pre-commit",
|
|
870
|
-
category: hook.category || "pre-commit",
|
|
871
|
-
projectTypes: ["all"],
|
|
872
|
-
trigger: {
|
|
873
|
-
matcher: `git:${hook.category || "pre-commit"}`,
|
|
874
|
-
condition: void 0
|
|
875
|
-
},
|
|
876
|
-
action: {
|
|
877
|
-
command: hook.install_command || "echo",
|
|
878
|
-
args: [hook.name_en],
|
|
879
|
-
timeout: 3e4
|
|
880
|
-
},
|
|
881
|
-
enabled: true,
|
|
882
|
-
priority: hook.rating_average ? Math.round(hook.rating_average * 20) : 50
|
|
883
|
-
};
|
|
884
|
-
recommendedHooks.push(hookConfig);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
} catch {
|
|
888
|
-
}
|
|
889
|
-
const filteredHooks = filterHooks(recommendedHooks, options);
|
|
890
|
-
if (filteredHooks.length === 0) {
|
|
891
|
-
if (json) {
|
|
892
|
-
return { success: true, hooks: [], message: "No hooks found matching criteria" };
|
|
893
|
-
}
|
|
894
|
-
consola.warn(i18n.t("hooks.noHooksFound"));
|
|
895
|
-
return;
|
|
896
|
-
}
|
|
897
|
-
const hooksByCategory = groupHooksByCategory(filteredHooks);
|
|
898
|
-
if (!json) {
|
|
899
|
-
displayHooks(hooksByCategory, options);
|
|
900
|
-
}
|
|
901
|
-
if (!dryRun && !json) {
|
|
902
|
-
const { shouldInstall } = await inquirer.prompt([{
|
|
903
|
-
type: "confirm",
|
|
904
|
-
name: "shouldInstall",
|
|
905
|
-
message: i18n.t("hooks.installPrompt", { count: filteredHooks.length }),
|
|
906
|
-
default: true
|
|
907
|
-
}]);
|
|
908
|
-
if (!shouldInstall) {
|
|
909
|
-
consola.info(i18n.t("hooks.installCancelled"));
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
if (!json) {
|
|
914
|
-
consola.log(i18n.t("hooks.installingHooks"));
|
|
915
|
-
}
|
|
916
|
-
const installedHooks = [];
|
|
917
|
-
const errors = [];
|
|
918
|
-
for (const hook of filteredHooks) {
|
|
919
|
-
try {
|
|
920
|
-
if (dryRun) {
|
|
921
|
-
if (json) {
|
|
922
|
-
installedHooks.push(hook.name);
|
|
923
|
-
} else {
|
|
924
|
-
consola.log(` ${i18n.t("hooks.wouldInstall", { name: hook.name })}`);
|
|
925
|
-
}
|
|
926
|
-
continue;
|
|
927
|
-
}
|
|
928
|
-
const isValid = await validateHookTrigger(hook.trigger, projectInfo);
|
|
929
|
-
if (!isValid) {
|
|
930
|
-
throw new Error(i18n.t("hooks.invalidTrigger", { trigger: hook.trigger.matcher }));
|
|
931
|
-
}
|
|
932
|
-
const hookForManager = {
|
|
933
|
-
command: hook.action.command,
|
|
934
|
-
args: hook.action.args || [],
|
|
935
|
-
type: hook.type,
|
|
936
|
-
// Type assertion to handle the mismatch
|
|
937
|
-
async: false,
|
|
938
|
-
timeout: hook.action.timeout || 5e3,
|
|
939
|
-
workingDir: hook.action.workingDirectory,
|
|
940
|
-
env: hook.action.environment,
|
|
941
|
-
description: hook.description
|
|
942
|
-
};
|
|
943
|
-
hookManager.registerHook(hookForManager);
|
|
944
|
-
installedHooks.push(hook.name);
|
|
945
|
-
if (!json) {
|
|
946
|
-
consola.success(` ${i18n.t("hooks.installed", { name: hook.name })}`);
|
|
947
|
-
}
|
|
948
|
-
} catch (error) {
|
|
949
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
950
|
-
errors.push({ hook: hook.name, error: errorMessage });
|
|
951
|
-
if (!json) {
|
|
952
|
-
consola.error(` ${i18n.t("hooks.installFailed", { name: hook.name })}: ${errorMessage}`);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
const duration = Math.round(performance.now() - startTime);
|
|
957
|
-
if (json) {
|
|
958
|
-
return {
|
|
959
|
-
success: errors.length === 0,
|
|
960
|
-
installed: installedHooks,
|
|
961
|
-
errors,
|
|
962
|
-
duration,
|
|
963
|
-
hooks: installedHooks.map((name) => ({ name, status: "installed" }))
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
if (installedHooks.length > 0) {
|
|
967
|
-
consola.success(
|
|
968
|
-
i18n.t("hooks.installSuccess", {
|
|
969
|
-
count: installedHooks.length,
|
|
970
|
-
duration
|
|
971
|
-
})
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
if (errors.length > 0) {
|
|
975
|
-
consola.warn(
|
|
976
|
-
i18n.t("hooks.installPartial", {
|
|
977
|
-
failed: errors.length,
|
|
978
|
-
total: filteredHooks.length
|
|
979
|
-
})
|
|
980
|
-
);
|
|
981
|
-
}
|
|
982
|
-
if (installedHooks.length > 0 && !dryRun) {
|
|
983
|
-
displayTestingInstructions(hooksByCategory);
|
|
984
|
-
}
|
|
985
|
-
} catch (error) {
|
|
986
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
987
|
-
if (json) {
|
|
988
|
-
return {
|
|
989
|
-
success: false,
|
|
990
|
-
error: errorMessage,
|
|
991
|
-
hooks: []
|
|
992
|
-
};
|
|
993
|
-
}
|
|
994
|
-
consola.error(i18n.t("hooks.installError", { error: errorMessage }));
|
|
995
|
-
throw error;
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
function filterHooks(hooks, options) {
|
|
999
|
-
let filtered = hooks;
|
|
1000
|
-
if (options.type && options.type !== "all") {
|
|
1001
|
-
filtered = filtered.filter((hook) => hook.type === options.type);
|
|
1002
|
-
}
|
|
1003
|
-
if (options.category && options.category !== "all") {
|
|
1004
|
-
filtered = filtered.filter((hook) => hook.category === options.category);
|
|
1005
|
-
}
|
|
1006
|
-
if (options.exclude && options.exclude.length > 0) {
|
|
1007
|
-
filtered = filtered.filter(
|
|
1008
|
-
(hook) => !options.exclude.includes(hook.name)
|
|
1009
|
-
);
|
|
1010
|
-
}
|
|
1011
|
-
if (options.enabled !== void 0) {
|
|
1012
|
-
filtered = filtered.filter((hook) => hook.enabled === options.enabled);
|
|
1013
|
-
}
|
|
1014
|
-
if (options.priority !== void 0) {
|
|
1015
|
-
filtered = filtered.sort((a, b) => {
|
|
1016
|
-
const priorityA = a.priority || 0;
|
|
1017
|
-
const priorityB = b.priority || 0;
|
|
1018
|
-
return priorityB - priorityA;
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
return filtered;
|
|
1022
|
-
}
|
|
1023
|
-
function groupHooksByCategory(hooks) {
|
|
1024
|
-
const groups = {
|
|
1025
|
-
"pre-commit": [],
|
|
1026
|
-
"post-test": [],
|
|
1027
|
-
"lifecycle": []
|
|
1028
|
-
};
|
|
1029
|
-
for (const hook of hooks) {
|
|
1030
|
-
const category = hook.category || "lifecycle";
|
|
1031
|
-
if (!groups[category]) {
|
|
1032
|
-
groups[category] = [];
|
|
1033
|
-
}
|
|
1034
|
-
groups[category].push(hook);
|
|
1035
|
-
}
|
|
1036
|
-
return groups;
|
|
1037
|
-
}
|
|
1038
|
-
function displayHooks(hooksByCategory, options) {
|
|
1039
|
-
const totalHooks = Object.values(hooksByCategory).flat().length;
|
|
1040
|
-
consola.log(i18n.t("hooks.foundHooks", { count: totalHooks }));
|
|
1041
|
-
consola.log("");
|
|
1042
|
-
for (const [category, hooks] of Object.entries(hooksByCategory)) {
|
|
1043
|
-
if (hooks.length === 0)
|
|
1044
|
-
continue;
|
|
1045
|
-
consola.log(`${i18n.t(`hooks.category.${category}`)}:`);
|
|
1046
|
-
for (const hook of hooks) {
|
|
1047
|
-
const status = hook.enabled ? "\u2705" : "\u23F8\uFE0F";
|
|
1048
|
-
consola.log(` ${status} ${hook.name.padEnd(25)} - ${hook.description}`);
|
|
1049
|
-
if (options.verbose) {
|
|
1050
|
-
consola.log(` ${i18n.t("hooks.trigger")}: ${hook.trigger.matcher}`);
|
|
1051
|
-
consola.log(` ${i18n.t("hooks.command")}: ${hook.action.command}`);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
consola.log("");
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
function displayTestingInstructions(hooksByCategory) {
|
|
1058
|
-
consola.log("");
|
|
1059
|
-
consola.info(i18n.t("hooks.testingInstructions"));
|
|
1060
|
-
consola.log("");
|
|
1061
|
-
if (hooksByCategory["pre-commit"].length > 0) {
|
|
1062
|
-
consola.log(` \u2022 ${i18n.t("hooks.testPreCommit")}`);
|
|
1063
|
-
}
|
|
1064
|
-
if (hooksByCategory["post-test"].length > 0) {
|
|
1065
|
-
consola.log(` \u2022 ${i18n.t("hooks.testPostTest")}`);
|
|
1066
|
-
}
|
|
1067
|
-
if (hooksByCategory.lifecycle.length > 0) {
|
|
1068
|
-
consola.log(` \u2022 ${i18n.t("hooks.testLifecycle")}`);
|
|
1069
|
-
}
|
|
1070
|
-
consola.log(` \u2022 ${i18n.t("hooks.listHooks")}: ccjk hooks list`);
|
|
1071
|
-
consola.log(` \u2022 ${i18n.t("hooks.testHooks")}: ccjk hooks test`);
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
export { ccjkHooks };
|