ccg-workflow 2.1.16 → 3.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.
Files changed (45) hide show
  1. package/README.md +120 -270
  2. package/README.zh-CN.md +119 -269
  3. package/dist/cli.mjs +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/dist/shared/{ccg-workflow.CewMlBCj.mjs → ccg-workflow.81OoN8XX.mjs} +160 -34
  6. package/package.json +6 -30
  7. package/templates/commands/go.md +199 -0
  8. package/templates/commands-legacy/team.md +475 -0
  9. package/templates/engine/model-router.md +117 -0
  10. package/templates/engine/phase-guide.md +95 -0
  11. package/templates/engine/strategies/debug-investigate.md +156 -0
  12. package/templates/engine/strategies/deep-research.md +141 -0
  13. package/templates/engine/strategies/direct-fix.md +108 -0
  14. package/templates/engine/strategies/full-collaborate.md +291 -0
  15. package/templates/engine/strategies/git-action.md +43 -0
  16. package/templates/engine/strategies/guided-develop.md +208 -0
  17. package/templates/engine/strategies/optimize-measure.md +103 -0
  18. package/templates/engine/strategies/quick-implement.md +96 -0
  19. package/templates/engine/strategies/refactor-safely.md +157 -0
  20. package/templates/engine/strategies/review-audit.md +116 -0
  21. package/templates/hooks/session-start.js +100 -0
  22. package/templates/hooks/skill-router.js +144 -0
  23. package/templates/hooks/subagent-context.js +118 -0
  24. package/templates/hooks/task-utils.js +113 -0
  25. package/templates/hooks/workflow-state.js +39 -0
  26. package/templates/spec/backend/index.md +31 -0
  27. package/templates/spec/frontend/index.md +31 -0
  28. package/templates/spec/guides/index.md +30 -0
  29. /package/templates/{commands → commands-legacy}/analyze.md +0 -0
  30. /package/templates/{commands → commands-legacy}/backend.md +0 -0
  31. /package/templates/{commands → commands-legacy}/codex-exec.md +0 -0
  32. /package/templates/{commands → commands-legacy}/debug.md +0 -0
  33. /package/templates/{commands → commands-legacy}/enhance.md +0 -0
  34. /package/templates/{commands → commands-legacy}/execute.md +0 -0
  35. /package/templates/{commands → commands-legacy}/feat.md +0 -0
  36. /package/templates/{commands → commands-legacy}/frontend.md +0 -0
  37. /package/templates/{commands → commands-legacy}/optimize.md +0 -0
  38. /package/templates/{commands → commands-legacy}/plan.md +0 -0
  39. /package/templates/{commands → commands-legacy}/review.md +0 -0
  40. /package/templates/{commands → commands-legacy}/team-exec.md +0 -0
  41. /package/templates/{commands → commands-legacy}/team-plan.md +0 -0
  42. /package/templates/{commands → commands-legacy}/team-research.md +0 -0
  43. /package/templates/{commands → commands-legacy}/team-review.md +0 -0
  44. /package/templates/{commands → commands-legacy}/test.md +0 -0
  45. /package/templates/{commands → commands-legacy}/workflow.md +0 -0
@@ -10,7 +10,7 @@ import fs from 'fs-extra';
10
10
  import { parse, stringify } from 'smol-toml';
11
11
  import i18next from 'i18next';
12
12
 
13
- const version = "2.1.16";
13
+ const version = "3.0.0";
14
14
 
15
15
  function cmd(id, order, category, name, nameEn, description, descriptionEn, cmdOverride) {
16
16
  return {
@@ -25,8 +25,25 @@ function cmd(id, order, category, name, nameEn, description, descriptionEn, cmdO
25
25
  descriptionEn
26
26
  };
27
27
  }
28
- const WORKFLOW_CONFIGS = [
29
- // ── Development ──────────────────────────────────────
28
+ const CORE_CONFIGS = [
29
+ // ── Smart Entry ──────────────────────────────────────
30
+ cmd("go", 0, "development", "CCG \u667A\u80FD\u5165\u53E3", "CCG Smart Entry", "\u63CF\u8FF0\u4F60\u8981\u505A\u4EC0\u4E48\uFF0CAI \u81EA\u52A8\u9009\u62E9\u6700\u4F73\u7B56\u7565\u6267\u884C", "Describe what you want, AI picks the best strategy"),
31
+ // ── Independent Tools ────────────────────────────────
32
+ cmd("init-project", 10, "init", "\u9879\u76EE\u521D\u59CB\u5316", "Project Init", "\u521D\u59CB\u5316\u9879\u76EE AI \u4E0A\u4E0B\u6587\uFF0C\u751F\u6210 CLAUDE.md", "Initialize project AI context, generate CLAUDE.md", "init"),
33
+ cmd("context", 11, "development", "\u9879\u76EE\u4E0A\u4E0B\u6587\u7BA1\u7406", "Project Context Manager", "\u521D\u59CB\u5316 .context \u76EE\u5F55\u3001\u8BB0\u5F55\u51B3\u7B56\u65E5\u5FD7\u3001\u538B\u7F29\u5F52\u6863\u3001\u67E5\u770B\u5386\u53F2", "Init .context dir, log decisions, compress, view history"),
34
+ // ── Git ──────────────────────────────────────────────
35
+ cmd("commit", 20, "git", "Git \u63D0\u4EA4", "Git Commit", "\u667A\u80FD\u751F\u6210 conventional commit \u4FE1\u606F", "Smart conventional commit message generation"),
36
+ cmd("rollback", 21, "git", "Git \u56DE\u6EDA", "Git Rollback", "\u4EA4\u4E92\u5F0F\u56DE\u6EDA\u5206\u652F\u5230\u5386\u53F2\u7248\u672C", "Interactive rollback to historical version"),
37
+ cmd("clean-branches", 22, "git", "Git \u6E05\u7406\u5206\u652F", "Git Clean Branches", "\u5B89\u5168\u6E05\u7406\u5DF2\u5408\u5E76\u6216\u8FC7\u671F\u5206\u652F", "Safely clean merged or stale branches"),
38
+ cmd("worktree", 23, "git", "Git Worktree", "Git Worktree", "\u7BA1\u7406 Git worktree", "Manage Git worktree"),
39
+ // ── Spec (OpenSpec / OPSX) ───────────────────────────
40
+ cmd("spec-init", 30, "spec", "OpenSpec \u521D\u59CB\u5316", "OpenSpec Init", "\u521D\u59CB\u5316 OpenSpec \u73AF\u5883 + \u9A8C\u8BC1\u591A\u6A21\u578B MCP \u5DE5\u5177", "Initialize OpenSpec environment with multi-model MCP validation"),
41
+ cmd("spec-research", 31, "spec", "\u9700\u6C42\u7814\u7A76", "Spec Research", "\u9700\u6C42 \u2192 \u7EA6\u675F\u96C6\uFF08\u5E76\u884C\u63A2\u7D22 + OpenSpec \u63D0\u6848\uFF09", "Transform requirements into constraint sets via parallel exploration"),
42
+ cmd("spec-plan", 32, "spec", "\u96F6\u51B3\u7B56\u89C4\u5212", "Spec Plan", "\u591A\u6A21\u578B\u5206\u6790 \u2192 \u6D88\u9664\u6B67\u4E49 \u2192 \u96F6\u51B3\u7B56\u53EF\u6267\u884C\u8BA1\u5212", "Refine proposals into zero-decision executable plans"),
43
+ cmd("spec-impl", 33, "spec", "\u89C4\u8303\u9A71\u52A8\u5B9E\u73B0", "Spec Implementation", "\u6309\u89C4\u8303\u6267\u884C + \u591A\u6A21\u578B\u534F\u4F5C + \u5F52\u6863", "Execute changes via multi-model collaboration with spec compliance"),
44
+ cmd("spec-review", 34, "spec", "\u5F52\u6863\u524D\u5BA1\u67E5", "Spec Review", "\u53CC\u6A21\u578B\u4EA4\u53C9\u5BA1\u67E5 \u2192 Critical \u5FC5\u987B\u4FEE\u590D \u2192 \u5141\u8BB8\u5F52\u6863", "Multi-model compliance review before archiving")
45
+ ];
46
+ const LEGACY_CONFIGS = [
30
47
  cmd("workflow", 1, "development", "\u5B8C\u6574\u5F00\u53D1\u5DE5\u4F5C\u6D41", "Full Development Workflow", "\u5B8C\u65746\u9636\u6BB5\u5F00\u53D1\u5DE5\u4F5C\u6D41\uFF08\u7814\u7A76\u2192\u6784\u601D\u2192\u8BA1\u5212\u2192\u6267\u884C\u2192\u4F18\u5316\u2192\u8BC4\u5BA1\uFF09", "Full 6-phase development workflow"),
31
48
  cmd("plan", 1.5, "development", "\u591A\u6A21\u578B\u534F\u4F5C\u89C4\u5212", "Multi-Model Planning", "\u4E0A\u4E0B\u6587\u68C0\u7D22 + \u53CC\u6A21\u578B\u5206\u6790 \u2192 \u751F\u6210 Step-by-step \u5B9E\u65BD\u8BA1\u5212", "Context retrieval + dual-model analysis \u2192 Step-by-step plan"),
32
49
  cmd("execute", 1.6, "development", "\u591A\u6A21\u578B\u534F\u4F5C\u6267\u884C", "Multi-Model Execution", "\u6839\u636E\u8BA1\u5212\u83B7\u53D6\u539F\u578B \u2192 Claude \u91CD\u6784\u5B9E\u65BD \u2192 \u591A\u6A21\u578B\u5BA1\u8BA1\u4EA4\u4ED8", "Get prototype from plan \u2192 Claude refactor \u2192 Multi-model audit"),
@@ -37,7 +54,6 @@ const WORKFLOW_CONFIGS = [
37
54
  cmd("team-review", 1.95, "development", "Agent Teams \u5BA1\u67E5", "Agent Teams Review", "\u53CC\u6A21\u578B\u4EA4\u53C9\u5BA1\u67E5\u5E76\u884C\u5B9E\u65BD\u4EA7\u51FA\uFF0C\u5206\u7EA7\u5904\u7406 Critical/Warning/Info", "Dual-model cross-review with severity classification"),
38
55
  cmd("frontend", 2, "development", "\u524D\u7AEF\u4E13\u9879", "Frontend Tasks", "\u524D\u7AEF\u4E13\u9879\u4EFB\u52A1\uFF08Gemini\u4E3B\u5BFC\uFF0C\u66F4\u5FEB\u66F4\u7CBE\u51C6\uFF09", "Frontend tasks (Gemini-led, faster)"),
39
56
  cmd("codex-exec", 2.5, "development", "Codex \u6267\u884C\u8BA1\u5212", "Codex Plan Executor", "\u8BFB\u53D6 /ccg:plan \u8BA1\u5212\u6587\u4EF6\uFF0CCodex \u5168\u6743\u6267\u884C + \u591A\u6A21\u578B\u5BA1\u6838", "Read plan file from /ccg:plan, Codex executes + multi-model review"),
40
- cmd("context", 2.6, "development", "\u9879\u76EE\u4E0A\u4E0B\u6587\u7BA1\u7406", "Project Context Manager", "\u521D\u59CB\u5316 .context \u76EE\u5F55\u3001\u8BB0\u5F55\u51B3\u7B56\u65E5\u5FD7\u3001\u538B\u7F29\u5F52\u6863\u3001\u67E5\u770B\u5386\u53F2", "Init .context dir, log decisions, compress, view history"),
41
57
  cmd("backend", 3, "development", "\u540E\u7AEF\u4E13\u9879", "Backend Tasks", "\u540E\u7AEF\u4E13\u9879\u4EFB\u52A1\uFF08Codex\u4E3B\u5BFC\uFF0C\u66F4\u5FEB\u66F4\u7CBE\u51C6\uFF09", "Backend tasks (Codex-led, faster)"),
42
58
  cmd("feat", 4, "development", "\u667A\u80FD\u529F\u80FD\u5F00\u53D1", "Smart Feature Development", "\u667A\u80FD\u529F\u80FD\u5F00\u53D1 - \u81EA\u52A8\u89C4\u5212\u3001\u8BBE\u8BA1\u3001\u5B9E\u65BD", "Smart feature development - auto plan, design, implement"),
43
59
  cmd("analyze", 5, "development", "\u6280\u672F\u5206\u6790", "Technical Analysis", "\u53CC\u6A21\u578B\u6280\u672F\u5206\u6790\uFF0C\u4EC5\u5206\u6790\u4E0D\u4FEE\u6539\u4EE3\u7801", "Dual-model technical analysis, analysis only"),
@@ -45,27 +61,21 @@ const WORKFLOW_CONFIGS = [
45
61
  cmd("optimize", 7, "development", "\u6027\u80FD\u4F18\u5316", "Performance Optimization", "\u591A\u6A21\u578B\u6027\u80FD\u4F18\u5316", "Multi-model performance optimization"),
46
62
  cmd("test", 8, "development", "\u6D4B\u8BD5\u751F\u6210", "Test Generation", "\u667A\u80FD\u8DEF\u7531\u6D4B\u8BD5\u751F\u6210", "Smart routing test generation"),
47
63
  cmd("review", 9, "development", "\u4EE3\u7801\u5BA1\u67E5", "Code Review", "\u53CC\u6A21\u578B\u4EE3\u7801\u5BA1\u67E5\uFF0C\u65E0\u53C2\u6570\u65F6\u81EA\u52A8\u5BA1\u67E5 git diff", "Dual-model code review, auto-review git diff when no args"),
48
- cmd("enhance", 9.5, "development", "Prompt \u589E\u5F3A", "Prompt Enhancement", "ace-tool Prompt \u589E\u5F3A\u5DE5\u5177", "ace-tool prompt enhancement"),
49
- // ── Init ─────────────────────────────────────────────
50
- cmd("init-project", 10, "init", "\u9879\u76EE\u521D\u59CB\u5316", "Project Init", "\u521D\u59CB\u5316\u9879\u76EE AI \u4E0A\u4E0B\u6587\uFF0C\u751F\u6210 CLAUDE.md", "Initialize project AI context, generate CLAUDE.md", "init"),
51
- // ── Git ──────────────────────────────────────────────
52
- cmd("commit", 20, "git", "Git \u63D0\u4EA4", "Git Commit", "\u667A\u80FD\u751F\u6210 conventional commit \u4FE1\u606F", "Smart conventional commit message generation"),
53
- cmd("rollback", 21, "git", "Git \u56DE\u6EDA", "Git Rollback", "\u4EA4\u4E92\u5F0F\u56DE\u6EDA\u5206\u652F\u5230\u5386\u53F2\u7248\u672C", "Interactive rollback to historical version"),
54
- cmd("clean-branches", 22, "git", "Git \u6E05\u7406\u5206\u652F", "Git Clean Branches", "\u5B89\u5168\u6E05\u7406\u5DF2\u5408\u5E76\u6216\u8FC7\u671F\u5206\u652F", "Safely clean merged or stale branches"),
55
- cmd("worktree", 23, "git", "Git Worktree", "Git Worktree", "\u7BA1\u7406 Git worktree", "Manage Git worktree"),
56
- // ── Spec (OpenSpec / OPSX) ───────────────────────────
57
- cmd("spec-init", 30, "spec", "OpenSpec \u521D\u59CB\u5316", "OpenSpec Init", "\u521D\u59CB\u5316 OpenSpec \u73AF\u5883 + \u9A8C\u8BC1\u591A\u6A21\u578B MCP \u5DE5\u5177", "Initialize OpenSpec environment with multi-model MCP validation"),
58
- cmd("spec-research", 31, "spec", "\u9700\u6C42\u7814\u7A76", "Spec Research", "\u9700\u6C42 \u2192 \u7EA6\u675F\u96C6\uFF08\u5E76\u884C\u63A2\u7D22 + OpenSpec \u63D0\u6848\uFF09", "Transform requirements into constraint sets via parallel exploration"),
59
- cmd("spec-plan", 32, "spec", "\u96F6\u51B3\u7B56\u89C4\u5212", "Spec Plan", "\u591A\u6A21\u578B\u5206\u6790 \u2192 \u6D88\u9664\u6B67\u4E49 \u2192 \u96F6\u51B3\u7B56\u53EF\u6267\u884C\u8BA1\u5212", "Refine proposals into zero-decision executable plans"),
60
- cmd("spec-impl", 33, "spec", "\u89C4\u8303\u9A71\u52A8\u5B9E\u73B0", "Spec Implementation", "\u6309\u89C4\u8303\u6267\u884C + \u591A\u6A21\u578B\u534F\u4F5C + \u5F52\u6863", "Execute changes via multi-model collaboration with spec compliance"),
61
- cmd("spec-review", 34, "spec", "\u5F52\u6863\u524D\u5BA1\u67E5", "Spec Review", "\u53CC\u6A21\u578B\u4EA4\u53C9\u5BA1\u67E5 \u2192 Critical \u5FC5\u987B\u4FEE\u590D \u2192 \u5141\u8BB8\u5F52\u6863", "Multi-model compliance review before archiving")
64
+ cmd("enhance", 9.5, "development", "Prompt \u589E\u5F3A", "Prompt Enhancement", "ace-tool Prompt \u589E\u5F3A\u5DE5\u5177", "ace-tool prompt enhancement")
62
65
  ];
66
+ const WORKFLOW_CONFIGS = [...CORE_CONFIGS, ...LEGACY_CONFIGS];
63
67
  function getWorkflowConfigs() {
64
68
  return WORKFLOW_CONFIGS.sort((a, b) => a.order - b.order);
65
69
  }
66
70
  function getWorkflowById(id) {
67
71
  return WORKFLOW_CONFIGS.find((w) => w.id === id);
68
72
  }
73
+ function getCoreCommandIds() {
74
+ return CORE_CONFIGS.map((w) => w.id);
75
+ }
76
+ function getLegacyCommandIds() {
77
+ return LEGACY_CONFIGS.map((w) => w.id);
78
+ }
69
79
  function getAllCommandIds() {
70
80
  return WORKFLOW_CONFIGS.map((w) => w.id);
71
81
  }
@@ -886,6 +896,7 @@ async function copyMdTemplates(ctx, srcDir, destDir, options = {}) {
886
896
  }
887
897
  async function installCommandFiles(ctx, workflowIds) {
888
898
  const commandsDir = join(ctx.installDir, "commands", "ccg");
899
+ const legacyIds = new Set(getLegacyCommandIds());
889
900
  for (const workflowId of workflowIds) {
890
901
  const workflow = getWorkflowById(workflowId);
891
902
  if (!workflow) {
@@ -893,7 +904,8 @@ async function installCommandFiles(ctx, workflowIds) {
893
904
  continue;
894
905
  }
895
906
  for (const cmd of workflow.commands) {
896
- const srcFile = join(ctx.templateDir, "commands", `${cmd}.md`);
907
+ const srcSubdir = legacyIds.has(workflowId) ? "commands-legacy" : "commands";
908
+ const srcFile = join(ctx.templateDir, srcSubdir, `${cmd}.md`);
897
909
  const destFile = join(commandsDir, `${cmd}.md`);
898
910
  try {
899
911
  if (await fs.pathExists(srcFile)) {
@@ -1198,6 +1210,88 @@ async function installBinaryFile(ctx) {
1198
1210
  ctx.result.errors.push(`Failed to install codeagent-wrapper (non-blocking): ${error}`);
1199
1211
  }
1200
1212
  }
1213
+ async function installEngineFiles(ctx) {
1214
+ const engineSrcDir = join(ctx.templateDir, "engine");
1215
+ if (!await fs.pathExists(engineSrcDir)) return;
1216
+ const engineDestDir = join(ctx.installDir, ".ccg", "engine");
1217
+ try {
1218
+ await copyMdTemplates(ctx, engineSrcDir, engineDestDir, { inject: true });
1219
+ const strategiesSrc = join(engineSrcDir, "strategies");
1220
+ const strategiesDest = join(engineDestDir, "strategies");
1221
+ if (await fs.pathExists(strategiesSrc)) {
1222
+ await copyMdTemplates(ctx, strategiesSrc, strategiesDest, { inject: true });
1223
+ }
1224
+ } catch (error) {
1225
+ ctx.result.errors.push(`Failed to install engine files: ${error}`);
1226
+ }
1227
+ }
1228
+ const HOOK_FILES = ["task-utils.js", "workflow-state.js", "session-start.js", "subagent-context.js", "skill-router.js"];
1229
+ async function installHookScripts(ctx) {
1230
+ const hooksSrcDir = join(ctx.templateDir, "hooks");
1231
+ if (!await fs.pathExists(hooksSrcDir)) return;
1232
+ const hooksDestDir = join(ctx.installDir, "hooks", "ccg");
1233
+ await fs.ensureDir(hooksDestDir);
1234
+ try {
1235
+ for (const file of HOOK_FILES) {
1236
+ const src = join(hooksSrcDir, file);
1237
+ const dest = join(hooksDestDir, file);
1238
+ if (await fs.pathExists(src)) {
1239
+ await fs.copy(src, dest, { overwrite: true });
1240
+ }
1241
+ }
1242
+ } catch (error) {
1243
+ ctx.result.errors.push(`Failed to install hook scripts: ${error}`);
1244
+ }
1245
+ }
1246
+ async function registerHooksInSettings(ctx) {
1247
+ const settingsPath = join(ctx.installDir, "settings.json");
1248
+ const hooksDir = join(ctx.installDir, "hooks", "ccg");
1249
+ try {
1250
+ let settings = {};
1251
+ if (await fs.pathExists(settingsPath)) {
1252
+ try {
1253
+ settings = JSON.parse(await fs.readFile(settingsPath, "utf-8"));
1254
+ } catch {
1255
+ settings = {};
1256
+ }
1257
+ }
1258
+ const hooks = settings.hooks || {};
1259
+ const ccgHookDefs = {
1260
+ UserPromptSubmit: {
1261
+ hooks: [
1262
+ { type: "command", command: `node ${join(hooksDir, "workflow-state.js")}`, timeout: 1e4 },
1263
+ { type: "command", command: `node ${join(hooksDir, "skill-router.js")}`, timeout: 5e3 }
1264
+ ]
1265
+ },
1266
+ SessionStart: {
1267
+ matcher: "startup|clear|compact",
1268
+ hooks: [{ type: "command", command: `node ${join(hooksDir, "session-start.js")}`, timeout: 15e3 }]
1269
+ },
1270
+ PreToolUse: {
1271
+ matcher: "Bash|Agent",
1272
+ hooks: [{ type: "command", command: `node ${join(hooksDir, "subagent-context.js")}`, timeout: 15e3 }]
1273
+ }
1274
+ };
1275
+ for (const [event, def] of Object.entries(ccgHookDefs)) {
1276
+ const eventHooks = hooks[event] || [];
1277
+ const ccgCommand = def.hooks[0].command;
1278
+ const existingIdx = eventHooks.findIndex((h) => {
1279
+ const hHooks = h.hooks || [];
1280
+ return hHooks.some((hh) => typeof hh.command === "string" && hh.command.includes("hooks/ccg/"));
1281
+ });
1282
+ if (existingIdx >= 0) {
1283
+ eventHooks[existingIdx] = def;
1284
+ } else {
1285
+ eventHooks.push(def);
1286
+ }
1287
+ hooks[event] = eventHooks;
1288
+ }
1289
+ settings.hooks = hooks;
1290
+ await fs.writeFile(settingsPath, JSON.stringify(settings, null, 2), "utf-8");
1291
+ } catch (error) {
1292
+ ctx.result.errors.push(`Failed to register hooks in settings.json: ${error}`);
1293
+ }
1294
+ }
1201
1295
  async function installWorkflows(workflowIds, installDir, force = false, config) {
1202
1296
  const ctx = {
1203
1297
  installDir,
@@ -1210,7 +1304,7 @@ async function installWorkflows(workflowIds, installDir, force = false, config)
1210
1304
  review: { models: ["codex", "gemini"] }
1211
1305
  },
1212
1306
  liteMode: config?.liteMode || false,
1213
- mcpProvider: config?.mcpProvider || "ace-tool",
1307
+ mcpProvider: config?.mcpProvider || "fast-context",
1214
1308
  skipImpeccable: config?.skipImpeccable || false
1215
1309
  },
1216
1310
  templateDir: join(PACKAGE_ROOT$1, "templates"),
@@ -1231,7 +1325,11 @@ async function installWorkflows(workflowIds, installDir, force = false, config)
1231
1325
  await fs.ensureDir(join(installDir, "commands", "ccg"));
1232
1326
  await fs.ensureDir(join(installDir, ".ccg"));
1233
1327
  await fs.ensureDir(join(installDir, ".ccg", "prompts"));
1328
+ await fs.ensureDir(join(installDir, ".ccg", "engine", "strategies"));
1234
1329
  await installCommandFiles(ctx, workflowIds);
1330
+ await installEngineFiles(ctx);
1331
+ await installHookScripts(ctx);
1332
+ await registerHooksInSettings(ctx);
1235
1333
  await installAgentFiles(ctx);
1236
1334
  await installPromptFiles(ctx);
1237
1335
  await installSkillFiles(ctx);
@@ -1327,6 +1425,8 @@ const installer = {
1327
1425
  collectInvocableSkills: collectInvocableSkills,
1328
1426
  collectSkills: collectSkills,
1329
1427
  getAllCommandIds: getAllCommandIds,
1428
+ getCoreCommandIds: getCoreCommandIds,
1429
+ getLegacyCommandIds: getLegacyCommandIds,
1330
1430
  getWorkflowById: getWorkflowById,
1331
1431
  getWorkflowConfigs: getWorkflowConfigs,
1332
1432
  injectConfigVariables: injectConfigVariables,
@@ -2747,7 +2847,7 @@ function createDefaultConfig(options) {
2747
2847
  backup: join(CCG_DIR, "backup")
2748
2848
  },
2749
2849
  mcp: {
2750
- provider: options.mcpProvider || "ace-tool",
2850
+ provider: options.mcpProvider || "fast-context",
2751
2851
  setup_url: "https://augmentcode.com/"
2752
2852
  },
2753
2853
  performance: {
@@ -3010,7 +3110,7 @@ async function init(options = {}) {
3010
3110
  let backendModels = ["codex"];
3011
3111
  let geminiModel = "gemini-3.1-pro-preview";
3012
3112
  const mode = "smart";
3013
- const selectedWorkflows = getAllCommandIds();
3113
+ let selectedWorkflows = getCoreCommandIds();
3014
3114
  if (options.skipPrompt) {
3015
3115
  const existingConfig = await readCcgConfig();
3016
3116
  if (existingConfig?.routing) {
@@ -3018,10 +3118,18 @@ async function init(options = {}) {
3018
3118
  backendModels = existingConfig.routing.backend?.models || ["codex"];
3019
3119
  geminiModel = existingConfig.routing.geminiModel || "gemini-3.1-pro-preview";
3020
3120
  }
3121
+ if (existingConfig?.workflows?.installed) {
3122
+ const hadLegacy = existingConfig.workflows.installed.some(
3123
+ (w) => ["workflow", "plan", "execute", "frontend", "backend", "feat", "debug", "team"].includes(w)
3124
+ );
3125
+ if (hadLegacy) {
3126
+ selectedWorkflows = getAllCommandIds();
3127
+ }
3128
+ }
3021
3129
  }
3022
3130
  let liteMode = false;
3023
3131
  let skipImpeccable = false;
3024
- let mcpProvider = "ace-tool";
3132
+ let mcpProvider = "fast-context";
3025
3133
  let aceToolBaseUrl = "";
3026
3134
  let aceToolToken = "";
3027
3135
  let contextWeaverApiKey = "";
@@ -3217,13 +3325,13 @@ async function init(options = {}) {
3217
3325
  message: i18n.t("init:mcp.selectTools"),
3218
3326
  choices: [
3219
3327
  {
3220
- name: `ace-tool ${ansis.green(`(${i18n.t("common:info")})`)} ${ansis.gray("\u2014 search_context \u4EE3\u7801\u68C0\u7D22")}`,
3221
- value: "ace-tool",
3328
+ name: `fast-context ${ansis.green(`(${i18n.t("common:recommended")})`)} ${ansis.gray("\u2014 AI \u9A71\u52A8\u8BED\u4E49\u641C\u7D22")}`,
3329
+ value: "fast-context",
3222
3330
  checked: true
3223
3331
  },
3224
3332
  {
3225
- name: `fast-context ${ansis.gray("\u2014 AI \u9A71\u52A8\u8BED\u4E49\u641C\u7D22")}`,
3226
- value: "fast-context"
3333
+ name: `ace-tool ${ansis.gray("\u2014 search_context \u4EE3\u7801\u68C0\u7D22")}`,
3334
+ value: "ace-tool"
3227
3335
  },
3228
3336
  {
3229
3337
  name: `context7 ${ansis.green("(free)")} ${ansis.gray("\u2014 \u5E93\u6587\u6863\u67E5\u8BE2")}`,
@@ -3362,13 +3470,29 @@ async function init(options = {}) {
3362
3470
  if (perfMode === CANCEL_SENTINEL)
3363
3471
  return "cancel";
3364
3472
  liteMode = perfMode === "lite";
3365
- const { includeImpeccable } = await inquirer.prompt([{
3366
- type: "confirm",
3367
- name: "includeImpeccable",
3368
- message: i18n.t("init:commands.includeImpeccable"),
3369
- default: !skipImpeccable
3473
+ const { versionMode } = await inquirer.prompt([{
3474
+ type: "list",
3475
+ name: "versionMode",
3476
+ message: "\u5B89\u88C5\u6A21\u5F0F",
3477
+ choices: [
3478
+ { name: `${ansis.green("v3 \u65B0\u7248")} \u2014 /ccg:go \u667A\u80FD\u5165\u53E3 + Hook \u5F15\u64CE + 12 \u6838\u5FC3\u547D\u4EE4\uFF08\u63A8\u8350\uFF09`, value: "v3" },
3479
+ { name: `${ansis.gray("\u65E7\u7248\u517C\u5BB9")} \u2014 \u65B0\u7248\u5168\u90E8 + 18 \u4E2A\u65E7\u7248\u547D\u4EE4\uFF08workflow/debug/team \u7B49\uFF09`, value: "legacy" }
3480
+ ],
3481
+ default: "v3"
3370
3482
  }]);
3371
- skipImpeccable = !includeImpeccable;
3483
+ if (versionMode === "legacy") {
3484
+ selectedWorkflows = getAllCommandIds();
3485
+ const { includeImpeccable } = await inquirer.prompt([{
3486
+ type: "confirm",
3487
+ name: "includeImpeccable",
3488
+ message: i18n.t("init:commands.includeImpeccable"),
3489
+ default: !skipImpeccable
3490
+ }]);
3491
+ skipImpeccable = !includeImpeccable;
3492
+ } else {
3493
+ selectedWorkflows = getCoreCommandIds();
3494
+ skipImpeccable = true;
3495
+ }
3372
3496
  return "next";
3373
3497
  }
3374
3498
  const runSummaryStep = async (workflowsCount) => {
@@ -4037,7 +4161,9 @@ async function performUpdate(fromVersion, toVersion, isNewVersion) {
4037
4161
  const backupTargets = [
4038
4162
  join(installDir, "commands", "ccg"),
4039
4163
  join(installDir, "agents", "ccg"),
4040
- join(installDir, "skills", "ccg")
4164
+ join(installDir, "skills", "ccg"),
4165
+ join(installDir, "hooks", "ccg"),
4166
+ join(installDir, ".ccg", "engine")
4041
4167
  ];
4042
4168
  spinner = ora(i18n.t("update:removingOld")).start();
4043
4169
  const backedUp = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccg-workflow",
3
- "version": "2.1.16",
3
+ "version": "3.0.0",
4
4
  "description": "Claude + Codex + Gemini multi-model collaboration system - smart routing development workflow",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.17.1",
@@ -27,35 +27,11 @@
27
27
  "files": [
28
28
  "bin/ccg.mjs",
29
29
  "dist",
30
- "templates/commands/analyze.md",
31
- "templates/commands/backend.md",
32
- "templates/commands/clean-branches.md",
33
- "templates/commands/commit.md",
34
- "templates/commands/debug.md",
35
- "templates/commands/enhance.md",
36
- "templates/commands/execute.md",
37
- "templates/commands/feat.md",
38
- "templates/commands/frontend.md",
39
- "templates/commands/init.md",
40
- "templates/commands/optimize.md",
41
- "templates/commands/plan.md",
42
- "templates/commands/review.md",
43
- "templates/commands/rollback.md",
44
- "templates/commands/test.md",
45
- "templates/commands/workflow.md",
46
- "templates/commands/worktree.md",
47
- "templates/commands/spec-init.md",
48
- "templates/commands/spec-research.md",
49
- "templates/commands/spec-plan.md",
50
- "templates/commands/spec-impl.md",
51
- "templates/commands/spec-review.md",
52
- "templates/commands/team-research.md",
53
- "templates/commands/team-plan.md",
54
- "templates/commands/team-exec.md",
55
- "templates/commands/team-review.md",
56
- "templates/commands/codex-exec.md",
57
- "templates/commands/context.md",
58
- "templates/commands/agents/",
30
+ "templates/commands/",
31
+ "templates/commands-legacy/",
32
+ "templates/engine/",
33
+ "templates/hooks/",
34
+ "templates/spec/",
59
35
  "templates/prompts/codex/",
60
36
  "templates/prompts/gemini/analyzer.md",
61
37
  "templates/prompts/gemini/architect.md",
@@ -0,0 +1,199 @@
1
+ ---
2
+ description: 'CCG 智能入口 — 描述你要做什么,AI 自动选择最佳策略执行'
3
+ ---
4
+
5
+ # /ccg:go — CCG 智能入口
6
+
7
+ $ARGUMENTS
8
+
9
+ ---
10
+
11
+ ## 你的角色
12
+
13
+ 你是 **CCG Engine**,一个智能编排器。你的职责是:分析用户的自然语言意图,自动选择最优的开发策略,然后严格按策略执行。用户不需要记住任何命令,只需要描述他们想做什么。
14
+
15
+ 语言:中文交流,技术术语保留英文。
16
+
17
+ ---
18
+
19
+ ## Phase 0: 逃生舱检测
20
+
21
+ 在开始分析之前,先检查 `$ARGUMENTS` 是否命中逃生舱:
22
+
23
+ **直接执行短语**(跳过所有分析,Claude 直接处理):
24
+ - "直接做" / "just do it" / "skip" / "不用分析" / "别分析了" / "小修一下"
25
+
26
+ **快捷路由**(跳过意图分析,直接加载对应策略):
27
+ - 以 `commit` 开头 → 加载 `git-action` 策略
28
+ - 以 `rollback` / `回滚` 开头 → 加载 `git-action` 策略
29
+ - 以 `review` / `审查` 开头 → 加载 `review-audit` 策略
30
+ - 以 `clean` 开头且含 `branch` → 加载 `git-action` 策略
31
+
32
+ 如果命中逃生舱或快捷路由,跳到 Phase 3。否则继续 Phase 1。
33
+
34
+ ---
35
+
36
+ ## Phase 1: 意图分析 [required]
37
+
38
+ ### 1.1 获取项目上下文 [required · 不可跳过]
39
+
40
+ **先行动,再判断**。必须执行以下操作获取上下文:
41
+
42
+ 1. `git status` — 当前变更状态、分支信息
43
+ 2. 读取项目配置文件(`package.json` / `go.mod` / `pyproject.toml` / `Cargo.toml` 等,取存在的第一个)— 技术栈
44
+ 3. 快速浏览目录结构(`ls` 或 `find . -maxdepth 2 -type f | head -30`)— 项目规模
45
+
46
+ ### 1.2 任务类型分类
47
+
48
+ 根据 `$ARGUMENTS` 中的关键词和语义判断:
49
+
50
+ | 类型 | 信号词(中/英) |
51
+ |------|----------------|
52
+ | **bug-fix** | fix, bug, error, 500, crash, 报错, 修复, broken, 坏了, 失败, failed |
53
+ | **feature** | add, implement, create, 新增, 添加, 开发, build, 做一个, 加一个 |
54
+ | **refactor** | refactor, restructure, 重构, extract, simplify, clean up, 整理 |
55
+ | **research** | what, how, compare, 分析, 研究, 方案, 调研, 评估, 对比, 怎么做 |
56
+ | **optimize** | performance, optimize, speed, slow, 优化, 性能, latency, 慢 |
57
+ | **review** | review, audit, check quality, 审查, 审计, 看看代码 |
58
+ | **git** | commit, rollback, branch, merge, push, clean, worktree, 提交, 回滚 |
59
+
60
+ 如果多个类型匹配,选择最核心的那个(动词决定类型,形容词/名词决定领域)。
61
+
62
+ ### 1.3 复杂度评估
63
+
64
+ **基于 Phase 1.1 获取的项目上下文**评估,不是凭空猜测:
65
+
66
+ | 级别 | 判定标准 |
67
+ |------|---------|
68
+ | **S** | 单文件变更,范围清晰,预估 <30 行 |
69
+ | **M** | 2-5 文件,单模块内,路径明确 |
70
+ | **L** | 5+ 文件,跨模块,需要规划和协调 |
71
+ | **XL** | 架构级变更,API/Schema 变动,多模块协作 |
72
+
73
+ **不确定时默认选高一级**。
74
+
75
+ ### 1.4 风险评估
76
+
77
+ | 级别 | 判定标准 |
78
+ |------|---------|
79
+ | **low** | 无生产影响,可逆,有测试覆盖 |
80
+ | **medium** | 修改现有行为,需要测试验证 |
81
+ | **high** | API 契约变更,数据库迁移,认证/加密逻辑 |
82
+
83
+ ### 1.5 领域检测
84
+
85
+ 从 `$ARGUMENTS` + 项目上下文推断:
86
+ - **frontend** — UI, component, CSS, React, Vue, Angular, style, layout, 页面, 组件
87
+ - **backend** — API, database, server, endpoint, auth, queue, 接口, 数据库
88
+ - **fullstack** — 同时涉及前后端
89
+ - **security** — vulnerability, auth, injection, encryption, 漏洞, 认证
90
+ - **devops** — CI/CD, Docker, deploy, infrastructure, 部署, 运维
91
+
92
+ ---
93
+
94
+ ## Phase 2: 策略选择
95
+
96
+ 展示分析结果,用户可纠正:
97
+
98
+ ```
99
+ 📋 CCG 分析
100
+ 任务: [type] 复杂度: [S/M/L/XL] 领域: [domain] 风险: [level]
101
+ 策略: [strategy] — [一句话说明]
102
+ 📍 Next: 加载策略并开始执行
103
+ ```
104
+
105
+ ### 决策矩阵
106
+
107
+ | 类型 \ 复杂度 | S | M | L / XL |
108
+ |--------------|---|---|--------|
109
+ | **bug-fix** | direct-fix | debug-investigate | debug-investigate |
110
+ | **feature** | quick-implement | guided-develop | full-collaborate |
111
+ | **refactor** | direct-fix | refactor-safely | refactor-safely |
112
+ | **research** | deep-research | deep-research | deep-research |
113
+ | **optimize** | optimize-measure | optimize-measure | optimize-measure |
114
+ | **review** | review-audit | review-audit | review-audit |
115
+ | **git** | git-action | git-action | git-action |
116
+
117
+ **风险修正**:如果风险为 high 且策略不含外部模型审查,升级一档(如 direct-fix → debug-investigate)。
118
+
119
+ ### ⛔ 创建任务 [required · 策略加载前必须完成]
120
+
121
+ 如果复杂度 ≥ M **且策略不是 git-action**,**必须先创建任务目录再加载策略**:
122
+
123
+ **Step 1**: 生成任务名 — 用户请求核心词转 kebab-case(如 `add-oauth2-login`、`fix-api-timeout`)
124
+ **Step 2**: 执行命令创建目录和文件:
125
+
126
+ ```bash
127
+ mkdir -p .ccg/tasks/{task-name}
128
+ ```
129
+
130
+ **Step 3**: 写入 `.ccg/tasks/{task-name}/task.json`:
131
+
132
+ ```json
133
+ {
134
+ "id": "{task-name}",
135
+ "title": "{用户请求一句话摘要}",
136
+ "status": "in_progress",
137
+ "strategy": "{selected-strategy}",
138
+ "currentPhase": "1",
139
+ "nextAction": "{策略第一阶段的描述}",
140
+ "gate": null,
141
+ "createdAt": "{当前 ISO 日期时间}"
142
+ }
143
+ ```
144
+
145
+ **Step 4**: 如果 `.ccg/spec/` 目录存在,创建 `.ccg/tasks/{task-name}/context.jsonl`,列出相关 spec 文件。
146
+
147
+ **复杂度 S → 跳过任务创建**(保持轻量)。
148
+
149
+ **确认任务已创建后**,输出:
150
+ ```
151
+ ✅ Task created: .ccg/tasks/{task-name}/
152
+ ```
153
+
154
+ ### 加载策略
155
+
156
+ ```
157
+ Read("~/.claude/.ccg/engine/strategies/{selected-strategy}.md")
158
+ ```
159
+
160
+ 如果用户对分析结果提出异议(如"用完整协作模式"),**接受用户覆盖**,加载指定策略。
161
+
162
+ ---
163
+
164
+ ## Phase 3: 执行策略
165
+
166
+ 严格按照加载的策略文件执行。遵守以下原则:
167
+
168
+ 1. 标记为 `[required]` 的阶段**不可跳过**
169
+ 2. 标记为 `HARD STOP` 的 Gate **必须等待用户确认**
170
+ 3. 策略文件底部的 `## 铁律` 区块必须遵守
171
+ 4. 如需调用外部模型,先 `Read("~/.claude/.ccg/engine/model-router.md")` 获取调用模板
172
+
173
+ ---
174
+
175
+ ## 铁律(MUST NOT)
176
+
177
+ 1. **不可在未获取项目上下文的情况下评估复杂度** — Phase 1.1 不可跳过
178
+ 2. **不可自行发明逃生舱** — 只有 Phase 0 明确列出的短语才能跳过分析
179
+ 3. **不可在用户未确认的情况下降级策略** — 可升级,不可降级
180
+ 4. **M+ 复杂度必须先创建 Task 再加载策略** — 没有 `task.json` 就没有 Hook 面包屑注入,等于丢失状态追踪
181
+ 4. **不可跳过策略中 [required] 标记的阶段** — 即使"看起来很简单"
182
+ 5. **复杂度有疑问时,默认选高一级** — 宁可多做一步,不可漏掉关键步骤
183
+
184
+ ---
185
+
186
+ ## 附录:策略一览
187
+
188
+ | 策略 | 适用场景 | 外部模型 |
189
+ |------|---------|---------|
190
+ | `direct-fix` | 简单修复,范围清晰 | 无 |
191
+ | `quick-implement` | 小功能,单文件/组件 | 无 |
192
+ | `guided-develop` | 中等功能,需要规划 | 可选单模型 |
193
+ | `full-collaborate` | 复杂功能,需要多模型协作 | 双模型并行 |
194
+ | `debug-investigate` | 复杂调试,原因不明 | 双模型并行 |
195
+ | `refactor-safely` | 代码重构,需要安全保障 | 可选 |
196
+ | `deep-research` | 技术研究,方案对比 | 双模型探索 |
197
+ | `optimize-measure` | 性能优化,需要度量 | 可选 |
198
+ | `review-audit` | 代码审查 | 双模型交叉 |
199
+ | `git-action` | Git 操作 | 无(委托现有命令) |