claude-code-workflow 6.3.48 → 6.3.49

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 (211) hide show
  1. package/.claude/CLAUDE.md +6 -8
  2. package/.claude/agents/action-planning-agent.md +28 -45
  3. package/.claude/agents/cli-lite-planning-agent.md +93 -1
  4. package/.claude/agents/code-developer.md +144 -27
  5. package/.claude/commands/ccw-coordinator.md +175 -21
  6. package/.claude/commands/ccw-debug.md +832 -0
  7. package/.claude/commands/ccw.md +90 -9
  8. package/.claude/commands/cli/cli-init.md +1 -0
  9. package/.claude/commands/issue/convert-to-plan.md +718 -0
  10. package/.claude/commands/issue/from-brainstorm.md +382 -0
  11. package/.claude/commands/memory/tips.md +332 -0
  12. package/.claude/commands/workflow/analyze-with-file.md +804 -0
  13. package/.claude/commands/workflow/brainstorm/auto-parallel.md +18 -43
  14. package/.claude/commands/workflow/brainstorm/role-analysis.md +705 -0
  15. package/.claude/commands/workflow/brainstorm-with-file.md +1153 -0
  16. package/.claude/commands/workflow/debug-with-file.md +7 -5
  17. package/.claude/commands/workflow/execute.md +6 -4
  18. package/.claude/commands/workflow/lite-plan.md +2 -2
  19. package/.claude/commands/workflow/plan-verify.md +162 -327
  20. package/.claude/commands/workflow/plan.md +162 -26
  21. package/.claude/commands/workflow/replan.md +78 -2
  22. package/.claude/commands/workflow/{review-fix.md → review-cycle-fix.md} +6 -6
  23. package/.claude/commands/workflow/review-module-cycle.md +2 -2
  24. package/.claude/commands/workflow/review-session-cycle.md +2 -2
  25. package/.claude/commands/workflow/tools/conflict-resolution.md +16 -26
  26. package/.claude/commands/workflow/tools/context-gather.md +81 -118
  27. package/.claude/commands/workflow/tools/task-generate-agent.md +94 -10
  28. package/.claude/skills/ccw-help/command.json +4 -4
  29. package/.claude/skills/lite-skill-generator/SKILL.md +650 -0
  30. package/.claude/skills/lite-skill-generator/templates/simple-skill.md +68 -0
  31. package/.claude/skills/lite-skill-generator/templates/style-guide.md +64 -0
  32. package/.claude/skills/skill-generator/SKILL.md +277 -85
  33. package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +4 -15
  34. package/.claude/skills/skill-generator/phases/02-structure-generation.md +72 -17
  35. package/.claude/skills/skill-generator/phases/03-phase-generation.md +218 -51
  36. package/.claude/skills/skill-generator/phases/04-specs-templates.md +111 -41
  37. package/.claude/skills/skill-generator/phases/05-validation.md +139 -56
  38. package/.claude/skills/skill-generator/templates/autonomous-action.md +78 -268
  39. package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +14 -0
  40. package/.claude/skills/skill-generator/templates/code-analysis-action.md +12 -0
  41. package/.claude/skills/skill-generator/templates/llm-action.md +12 -0
  42. package/.claude/skills/skill-generator/templates/script-template.md +368 -0
  43. package/.claude/skills/skill-generator/templates/sequential-phase.md +14 -0
  44. package/.claude/skills/skill-generator/templates/skill-md.md +14 -0
  45. package/.claude/skills/skill-tuning/SKILL.md +130 -266
  46. package/.claude/skills/skill-tuning/phases/orchestrator.md +95 -283
  47. package/.claude/skills/skill-tuning/specs/problem-taxonomy.md +90 -198
  48. package/.claude/skills/skill-tuning/specs/tuning-strategies.md +193 -1345
  49. package/.claude/workflows/cli-templates/schemas/plan-verify-agent-schema.json +47 -0
  50. package/.claude/workflows/cli-templates/schemas/verify-json-schema.json +158 -0
  51. package/.claude/workflows/cli-tools-usage.md +1 -1
  52. package/.codex/AGENTS.md +1 -3
  53. package/.codex/prompts/analyze-with-file.md +607 -0
  54. package/.codex/prompts/brainstorm-to-cycle.md +455 -0
  55. package/.codex/prompts/brainstorm-with-file.md +933 -0
  56. package/.codex/prompts/debug-with-file.md +15 -20
  57. package/.codex/skills/ccw-cli-tools/SKILL.md +559 -0
  58. package/ccw/dist/commands/cli.d.ts.map +1 -1
  59. package/ccw/dist/commands/cli.js +29 -5
  60. package/ccw/dist/commands/cli.js.map +1 -1
  61. package/ccw/dist/commands/issue.d.ts +2 -0
  62. package/ccw/dist/commands/issue.d.ts.map +1 -1
  63. package/ccw/dist/commands/issue.js +62 -20
  64. package/ccw/dist/commands/issue.js.map +1 -1
  65. package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
  66. package/ccw/dist/config/litellm-api-config-manager.js +5 -3
  67. package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
  68. package/ccw/dist/config/litellm-provider-models.d.ts +73 -0
  69. package/ccw/dist/config/litellm-provider-models.d.ts.map +1 -0
  70. package/ccw/dist/config/litellm-provider-models.js +172 -0
  71. package/ccw/dist/config/litellm-provider-models.js.map +1 -0
  72. package/ccw/dist/config/provider-models.d.ts +25 -51
  73. package/ccw/dist/config/provider-models.d.ts.map +1 -1
  74. package/ccw/dist/config/provider-models.js +84 -149
  75. package/ccw/dist/config/provider-models.js.map +1 -1
  76. package/ccw/dist/config/storage-paths.d.ts.map +1 -1
  77. package/ccw/dist/config/storage-paths.js +23 -5
  78. package/ccw/dist/config/storage-paths.js.map +1 -1
  79. package/ccw/dist/core/auth/csrf-middleware.js +3 -3
  80. package/ccw/dist/core/auth/csrf-middleware.js.map +1 -1
  81. package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
  82. package/ccw/dist/core/dashboard-generator.js +3 -1
  83. package/ccw/dist/core/dashboard-generator.js.map +1 -1
  84. package/ccw/dist/core/routes/claude-routes.d.ts.map +1 -1
  85. package/ccw/dist/core/routes/claude-routes.js +206 -14
  86. package/ccw/dist/core/routes/claude-routes.js.map +1 -1
  87. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  88. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  89. package/ccw/dist/core/routes/commands-routes.d.ts +7 -0
  90. package/ccw/dist/core/routes/commands-routes.d.ts.map +1 -0
  91. package/ccw/dist/core/routes/commands-routes.js +480 -0
  92. package/ccw/dist/core/routes/commands-routes.js.map +1 -0
  93. package/ccw/dist/core/routes/model-routes.d.ts +11 -0
  94. package/ccw/dist/core/routes/model-routes.d.ts.map +1 -0
  95. package/ccw/dist/core/routes/model-routes.js +112 -0
  96. package/ccw/dist/core/routes/model-routes.js.map +1 -0
  97. package/ccw/dist/core/routes/nav-status-routes.d.ts.map +1 -1
  98. package/ccw/dist/core/routes/nav-status-routes.js +84 -1
  99. package/ccw/dist/core/routes/nav-status-routes.js.map +1 -1
  100. package/ccw/dist/core/routes/provider-routes.d.ts +11 -0
  101. package/ccw/dist/core/routes/provider-routes.d.ts.map +1 -0
  102. package/ccw/dist/core/routes/provider-routes.js +67 -0
  103. package/ccw/dist/core/routes/provider-routes.js.map +1 -0
  104. package/ccw/dist/core/routes/skills-routes.d.ts.map +1 -1
  105. package/ccw/dist/core/routes/skills-routes.js +219 -7
  106. package/ccw/dist/core/routes/skills-routes.js.map +1 -1
  107. package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
  108. package/ccw/dist/core/routes/system-routes.js +58 -6
  109. package/ccw/dist/core/routes/system-routes.js.map +1 -1
  110. package/ccw/dist/core/server.d.ts.map +1 -1
  111. package/ccw/dist/core/server.js +13 -0
  112. package/ccw/dist/core/server.js.map +1 -1
  113. package/ccw/dist/mcp-server/index.js +2 -2
  114. package/ccw/dist/mcp-server/index.js.map +1 -1
  115. package/ccw/dist/tools/claude-cli-tools.d.ts +48 -11
  116. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  117. package/ccw/dist/tools/claude-cli-tools.js +146 -50
  118. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  119. package/ccw/dist/tools/cli-config-manager.d.ts +1 -13
  120. package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
  121. package/ccw/dist/tools/cli-config-manager.js +3 -27
  122. package/ccw/dist/tools/cli-config-manager.js.map +1 -1
  123. package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
  124. package/ccw/dist/tools/cli-executor-core.js +7 -2
  125. package/ccw/dist/tools/cli-executor-core.js.map +1 -1
  126. package/ccw/dist/tools/cli-executor-state.d.ts.map +1 -1
  127. package/ccw/dist/tools/cli-history-store.d.ts +11 -0
  128. package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
  129. package/ccw/dist/tools/cli-history-store.js +82 -2
  130. package/ccw/dist/tools/cli-history-store.js.map +1 -1
  131. package/ccw/dist/tools/command-registry.d.ts +7 -0
  132. package/ccw/dist/tools/command-registry.d.ts.map +1 -1
  133. package/ccw/dist/tools/command-registry.js +14 -1
  134. package/ccw/dist/tools/command-registry.js.map +1 -1
  135. package/ccw/dist/tools/generate-module-docs.d.ts.map +1 -1
  136. package/ccw/dist/tools/generate-module-docs.js +11 -7
  137. package/ccw/dist/tools/generate-module-docs.js.map +1 -1
  138. package/ccw/dist/tools/litellm-executor.d.ts +1 -0
  139. package/ccw/dist/tools/litellm-executor.d.ts.map +1 -1
  140. package/ccw/dist/tools/litellm-executor.js +11 -9
  141. package/ccw/dist/tools/litellm-executor.js.map +1 -1
  142. package/ccw/dist/types/skill-types.d.ts +97 -0
  143. package/ccw/dist/types/skill-types.d.ts.map +1 -0
  144. package/ccw/dist/types/skill-types.js +6 -0
  145. package/ccw/dist/types/skill-types.js.map +1 -0
  146. package/ccw/src/commands/cli.ts +36 -5
  147. package/ccw/src/commands/issue.ts +81 -26
  148. package/ccw/src/config/litellm-api-config-manager.ts +5 -3
  149. package/ccw/src/config/litellm-provider-models.ts +222 -0
  150. package/ccw/src/config/provider-models.ts +91 -190
  151. package/ccw/src/config/storage-paths.ts +20 -5
  152. package/ccw/src/core/auth/csrf-middleware.ts +3 -3
  153. package/ccw/src/core/dashboard-generator.ts +3 -1
  154. package/ccw/src/core/routes/claude-routes.ts +233 -15
  155. package/ccw/src/core/routes/cli-routes.ts +2 -3
  156. package/ccw/src/core/routes/commands-routes.ts +620 -0
  157. package/ccw/src/core/routes/nav-status-routes.ts +95 -1
  158. package/ccw/src/core/routes/provider-routes.ts +78 -0
  159. package/ccw/src/core/routes/skills-routes.ts +266 -45
  160. package/ccw/src/core/routes/system-routes.ts +102 -50
  161. package/ccw/src/core/server.ts +13 -0
  162. package/ccw/src/mcp-server/index.ts +2 -2
  163. package/ccw/src/templates/dashboard-css/18-cli-settings.css +35 -0
  164. package/ccw/src/templates/dashboard-css/37-commands.css +193 -0
  165. package/ccw/src/templates/dashboard-js/components/navigation.js +4 -0
  166. package/ccw/src/templates/dashboard-js/i18n.js +116 -0
  167. package/ccw/src/templates/dashboard-js/views/cli-manager.js +249 -4
  168. package/ccw/src/templates/dashboard-js/views/commands-manager.js +503 -0
  169. package/ccw/src/templates/dashboard-js/views/issue-manager.js +7 -7
  170. package/ccw/src/templates/dashboard-js/views/mcp-manager.js +2 -7
  171. package/ccw/src/templates/dashboard-js/views/skills-manager.js +164 -23
  172. package/ccw/src/templates/dashboard.html +7 -0
  173. package/ccw/src/tools/claude-cli-tools.ts +170 -56
  174. package/ccw/src/tools/cli-config-manager.ts +2 -33
  175. package/ccw/src/tools/cli-executor-core.ts +8 -2
  176. package/ccw/src/tools/cli-history-store.ts +92 -2
  177. package/ccw/src/tools/command-registry.ts +16 -1
  178. package/ccw/src/tools/generate-module-docs.ts +11 -7
  179. package/ccw/src/tools/litellm-executor.ts +13 -9
  180. package/ccw/src/types/skill-types.ts +99 -0
  181. package/package.json +1 -1
  182. package/.claude/commands/enhance-prompt.md +0 -93
  183. package/.claude/commands/memory/code-map-memory.md +0 -687
  184. package/.claude/commands/memory/docs.md +0 -615
  185. package/.claude/commands/memory/load-skill-memory.md +0 -182
  186. package/.claude/commands/memory/skill-memory.md +0 -525
  187. package/.claude/commands/memory/swagger-docs.md +0 -773
  188. package/.claude/commands/memory/tech-research-rules.md +0 -310
  189. package/.claude/commands/memory/workflow-skill-memory.md +0 -517
  190. package/.claude/commands/task/breakdown.md +0 -208
  191. package/.claude/commands/task/create.md +0 -152
  192. package/.claude/commands/task/execute.md +0 -270
  193. package/.claude/commands/task/replan.md +0 -441
  194. package/.claude/commands/version.md +0 -254
  195. package/.claude/commands/workflow/action-plan-verify.md +0 -485
  196. package/.claude/commands/workflow/brainstorm/api-designer.md +0 -587
  197. package/.claude/commands/workflow/brainstorm/data-architect.md +0 -220
  198. package/.claude/commands/workflow/brainstorm/product-manager.md +0 -200
  199. package/.claude/commands/workflow/brainstorm/product-owner.md +0 -200
  200. package/.claude/commands/workflow/brainstorm/scrum-master.md +0 -200
  201. package/.claude/commands/workflow/brainstorm/subject-matter-expert.md +0 -200
  202. package/.claude/commands/workflow/brainstorm/system-architect.md +0 -389
  203. package/.claude/commands/workflow/brainstorm/ui-designer.md +0 -221
  204. package/.claude/commands/workflow/brainstorm/ux-expert.md +0 -221
  205. package/.claude/commands/workflow/debug.md +0 -331
  206. package/.claude/commands/workflow/develop-with-file.md +0 -1044
  207. package/.claude/skills/ccw-loop/README.md +0 -303
  208. package/.claude/skills/skill-generator/templates/script-bash.md +0 -277
  209. package/.claude/skills/skill-generator/templates/script-python.md +0 -198
  210. package/.codex/prompts/debug.md +0 -318
  211. package/ccw/src/core/routes/mcp-routes.ts.backup +0 -549
@@ -8,9 +8,7 @@
8
8
  - 生成 SKILL.md 入口文件
9
9
  - 根据执行模式创建对应的子目录
10
10
 
11
- ## Input
12
11
 
13
- - 依赖: `skill-config.json` (Phase 1 产出)
14
12
 
15
13
  ## Execution Steps
16
14
 
@@ -23,19 +21,79 @@ const skillDir = `.claude/skills/${config.skill_name}`;
23
21
 
24
22
  ### Step 2: 创建目录结构
25
23
 
24
+ #### 基础目录(所有模式)
25
+
26
26
  ```javascript
27
- // 基础目录
28
- Bash(`mkdir -p "${skillDir}/phases"`);
29
- Bash(`mkdir -p "${skillDir}/specs"`);
30
- Bash(`mkdir -p "${skillDir}/templates"`);
27
+ // 基础架构
28
+ Bash(`mkdir -p "${skillDir}/{phases,specs,templates,scripts}"`);
29
+ ```
30
+
31
+ #### 执行模式特定目录
32
+
33
+ ```
34
+ config.execution_mode
35
+
36
+ ├─ "sequential"
37
+ │ ↓ Creates:
38
+ │ └─ phases/ (基础目录已包含)
39
+ │ ├─ _orchestrator.md
40
+ │ └─ workflow.json
41
+
42
+ └─ "autonomous" | "hybrid"
43
+ ↓ Creates:
44
+ └─ phases/actions/
45
+ ├─ state-schema.md
46
+ └─ *.md (动作文件)
47
+ ```
31
48
 
32
- // Autonomous 模式额外目录
49
+ ```javascript
50
+ // Autonomous/Hybrid 模式额外目录
33
51
  if (config.execution_mode === 'autonomous' || config.execution_mode === 'hybrid') {
34
52
  Bash(`mkdir -p "${skillDir}/phases/actions"`);
35
53
  }
54
+ ```
55
+
56
+ #### Context Strategy 特定目录 (P0 增强)
57
+
58
+ ```javascript
59
+ // ========== P0: 根据上下文策略创建目录 ==========
60
+ const contextStrategy = config.context_strategy || 'file';
61
+
62
+ if (contextStrategy === 'file') {
63
+ // 文件策略:创建上下文持久化目录
64
+ Bash(`mkdir -p "${skillDir}/.scratchpad-template/context"`);
65
+
66
+ // 创建上下文模板文件
67
+ Write(
68
+ `${skillDir}/.scratchpad-template/context/.gitkeep`,
69
+ "# Runtime context storage for file-based strategy"
70
+ );
71
+ }
72
+ // 内存策略无需创建目录 (in-memory only)
73
+ ```
74
+
75
+ **目录树视图**:
36
76
 
37
- // scripts 目录(默认创建,用于存放确定性脚本)
38
- Bash(`mkdir -p "${skillDir}/scripts"`);
77
+ ```
78
+ Sequential + File Strategy:
79
+ .claude/skills/{skill-name}/
80
+ ├── phases/
81
+ │ ├── _orchestrator.md
82
+ │ ├── workflow.json
83
+ │ ├── 01-*.md
84
+ │ └── 02-*.md
85
+ ├── .scratchpad-template/
86
+ │ └── context/ ← File strategy persistent storage
87
+ └── specs/
88
+
89
+ Autonomous + Memory Strategy:
90
+ .claude/skills/{skill-name}/
91
+ ├── phases/
92
+ │ ├── orchestrator.md
93
+ │ ├── state-schema.md
94
+ │ └── actions/
95
+ │ └── *.md
96
+ └── specs/
39
97
  ```
40
98
 
41
99
  ### Step 3: 生成 SKILL.md
@@ -192,16 +250,13 @@ function generateReferenceTable(config) {
192
250
  }
193
251
  ```
194
252
 
195
- ## Output
196
253
 
197
- - **Directory**: `.claude/skills/{skill-name}/`
198
- - **Files**:
199
- - `SKILL.md` (入口文件)
200
- - `phases/` (执行阶段目录)
201
- - `specs/` (规范文档目录)
202
- - `templates/` (模板目录)
203
- - `scripts/` (脚本目录,存放 Python/Bash 确定性脚本)
204
254
 
205
255
  ## Next Phase
206
256
 
207
257
  → [Phase 3: Phase Generation](03-phase-generation.md)
258
+
259
+ **Data Flow to Phase 3**:
260
+ - Complete directory structure in .claude/skills/{skill-name}/
261
+ - SKILL.md entry file ready for phase/action generation
262
+ - skill-config.json for template population
@@ -8,10 +8,7 @@
8
8
  - Autonomous 模式:生成编排器和动作文件
9
9
  - 支持 **文件上下文** 和 **内存上下文** 两种策略
10
10
 
11
- ## Input
12
11
 
13
- - 依赖: `skill-config.json`, SKILL.md (Phase 1-2 产出)
14
- - 模板: `templates/sequential-phase.md`, `templates/autonomous-*.md`
15
12
 
16
13
  ## 上下文策略 (P0 增强)
17
14
 
@@ -55,66 +52,93 @@ const skillRoot = '.claude/skills/skill-generator';
55
52
  ```javascript
56
53
  if (config.execution_mode === 'sequential') {
57
54
  const phases = config.sequential_config.phases;
58
-
55
+
59
56
  // ========== P0 增强: 生成声明式编排器 ==========
60
57
  const workflowOrchestrator = generateSequentialOrchestrator(config, phases);
61
58
  Write(`${skillDir}/phases/_orchestrator.md`, workflowOrchestrator);
62
-
59
+
63
60
  // ========== P0 增强: 生成工作流定义 ==========
64
61
  const workflowDef = generateWorkflowDefinition(config, phases);
65
62
  Write(`${skillDir}/workflow.json`, JSON.stringify(workflowDef, null, 2));
66
-
67
- // 生成各阶段文件
63
+
64
+ // ========== P0 增强: 生成 Phase 0 (强制规范研读) ==========
65
+ const phase0Content = generatePhase0Spec(config);
66
+ Write(`${skillDir}/phases/00-spec-study.md`, phase0Content);
67
+
68
+ // ========== 生成用户定义的各阶段文件 ==========
68
69
  for (let i = 0; i < phases.length; i++) {
69
70
  const phase = phases[i];
70
71
  const prevPhase = i > 0 ? phases[i-1] : null;
71
72
  const nextPhase = i < phases.length - 1 ? phases[i+1] : null;
72
-
73
+
73
74
  const content = generateSequentialPhase({
74
75
  phaseNumber: i + 1,
75
76
  phaseId: phase.id,
76
77
  phaseName: phase.name,
77
78
  phaseDescription: phase.description || `Execute ${phase.name}`,
78
- input: prevPhase ? prevPhase.output : "user input",
79
+ input: prevPhase ? prevPhase.output : "phase 0 output", // Phase 0 为首个输入源
79
80
  output: phase.output,
80
81
  nextPhase: nextPhase ? nextPhase.id : null,
81
82
  config: config,
82
83
  contextStrategy: contextStrategy
83
84
  });
84
-
85
+
85
86
  Write(`${skillDir}/phases/${phase.id}.md`, content);
86
87
  }
87
88
  }
88
89
 
89
90
  // ========== P0 增强: 声明式工作流定义 ==========
90
91
  function generateWorkflowDefinition(config, phases) {
92
+ // ========== P0: 添加强制 Phase 0 ==========
93
+ const phase0 = {
94
+ id: '00-spec-study',
95
+ name: 'Specification Study',
96
+ order: 0,
97
+ input: null,
98
+ output: 'spec-study-complete.flag',
99
+ description: '⚠️ MANDATORY: Read all specification documents before execution',
100
+ parallel: false,
101
+ condition: null,
102
+ agent: {
103
+ type: 'universal-executor',
104
+ run_in_background: false
105
+ }
106
+ };
107
+
91
108
  return {
92
109
  skill_name: config.skill_name,
93
110
  version: "1.0.0",
94
111
  execution_mode: "sequential",
95
112
  context_strategy: config.context_strategy || "file",
96
-
97
- // 声明式阶段列表 (类似 software-manual agents_to_run)
98
- phases_to_run: phases.map(p => p.id),
99
-
100
- // 阶段配置
101
- phases: phases.map((p, i) => ({
102
- id: p.id,
103
- name: p.name,
104
- order: i + 1,
105
- input: i > 0 ? phases[i-1].output : null,
106
- output: p.output,
107
- // 可选的并行配置
108
- parallel: p.parallel || false,
109
- // 可选的条件执行
110
- condition: p.condition || null,
111
- // Agent 配置
112
- agent: p.agent || {
113
- type: "universal-executor",
114
- run_in_background: false
115
- }
116
- })),
117
-
113
+
114
+ // ========== P0: Phase 0 置于首位 ==========
115
+ phases_to_run: ['00-spec-study', ...phases.map(p => p.id)],
116
+
117
+ // ========== P0: Phase 0 + 用户定义阶段 ==========
118
+ phases: [
119
+ phase0,
120
+ ...phases.map((p, i) => ({
121
+ id: p.id,
122
+ name: p.name,
123
+ order: i + 1,
124
+ input: i === 0 ? phase0.output : phases[i-1].output, // 第一个阶段依赖 Phase 0
125
+ output: p.output,
126
+ parallel: p.parallel || false,
127
+ condition: p.condition || null,
128
+ // Agent 配置 (支持 LLM 集成)
129
+ agent: p.agent || (config.llm_integration?.enabled ? {
130
+ type: "llm",
131
+ tool: config.llm_integration.default_tool,
132
+ mode: config.llm_integration.mode || "analysis",
133
+ fallback_chain: config.llm_integration.fallback_chain || [],
134
+ run_in_background: false
135
+ } : {
136
+ type: "universal-executor",
137
+ run_in_background: false
138
+ })
139
+ }))
140
+ ],
141
+
118
142
  // 终止条件
119
143
  termination: {
120
144
  on_success: "all_phases_completed",
@@ -236,10 +260,30 @@ async function executePhase(phaseId, phaseConfig, workDir) {
236
260
 
237
261
  ## 阶段执行计划
238
262
 
263
+ **执行流程**:
264
+
265
+ \`\`\`
266
+ START
267
+
268
+ Phase 0: Specification Study
269
+ ↓ Output: spec-study-complete.flag
270
+
271
+ Phase 1: ${phases[0]?.name || 'First Phase'}
272
+ ↓ Output: ${phases[0]?.output || 'phase-1.json'}
273
+ ${phases.slice(1).map((p, i) => ` ↓
274
+ Phase ${i+2}: ${p.name}
275
+ ↓ Output: ${p.output}`).join('\n')}
276
+
277
+ COMPLETE
278
+ \`\`\`
279
+
280
+ **阶段列表**:
281
+
239
282
  | Order | Phase | Input | Output | Agent |
240
283
  |-------|-------|-------|--------|-------|
241
- ${phases.map((p, i) =>
242
- `| ${i+1} | ${p.id} | ${i > 0 ? phases[i-1].output : '-'} | ${p.output} | ${p.agent?.type || 'universal-executor'} |`
284
+ | 0 | 00-spec-study | - | spec-study-complete.flag | universal-executor |
285
+ ${phases.map((p, i) =>
286
+ `| ${i+1} | ${p.id} | ${i === 0 ? 'spec-study-complete.flag' : phases[i-1].output} | ${p.output} | ${p.agent?.type || 'universal-executor'} |`
243
287
  ).join('\n')}
244
288
 
245
289
  ## 错误恢复
@@ -754,6 +798,146 @@ ${actions.sort((a, b) => (b.priority || 0) - (a.priority || 0)).map(a =>
754
798
  ### Step 4: 辅助函数
755
799
 
756
800
  ```javascript
801
+ // ========== P0: Phase 0 生成函数 ==========
802
+ function generatePhase0Spec(config) {
803
+ const skillRoot = '.claude/skills/skill-generator';
804
+ const specsToRead = [
805
+ '../_shared/SKILL-DESIGN-SPEC.md',
806
+ `${skillRoot}/templates/*.md`
807
+ ];
808
+
809
+ return `# Phase 0: Specification Study
810
+
811
+ ⚠️ **MANDATORY PREREQUISITE** - 此阶段不可跳过
812
+
813
+ ## Objective
814
+
815
+ 在生成任何文件前,完整阅读所有规范文档,理解 Skill 设计标准。
816
+
817
+ ## Why This Matters
818
+
819
+ **不研读规范 (❌)**:
820
+ \`\`\`
821
+ 跳过规范
822
+ ├─ ✗ 不符合标准
823
+ ├─ ✗ 结构混乱
824
+ └─ ✗ 质量问题
825
+ \`\`\`
826
+
827
+ **研读规范 (✅)**:
828
+ \`\`\`
829
+ 完整研读
830
+ ├─ ✓ 标准化输出
831
+ ├─ ✓ 高质量代码
832
+ └─ ✓ 易于维护
833
+ \`\`\`
834
+
835
+ ## Required Reading
836
+
837
+ ### P0 - 核心设计规范
838
+
839
+ \`\`\`javascript
840
+ // 通用设计标准 (MUST READ)
841
+ const designSpec = Read('.claude/skills/_shared/SKILL-DESIGN-SPEC.md');
842
+
843
+ // 关键内容检查点:
844
+ const checkpoints = {
845
+ structure: '目录结构约定',
846
+ naming: '命名规范',
847
+ quality: '质量标准',
848
+ output: '输出格式要求'
849
+ };
850
+ \`\`\`
851
+
852
+ ### P1 - 模板文件 (生成前必读)
853
+
854
+ \`\`\`javascript
855
+ // 根据执行模式加载对应模板
856
+ const templates = {
857
+ all: [
858
+ 'templates/skill-md.md' // SKILL.md 入口文件模板
859
+ ],
860
+ sequential: [
861
+ 'templates/sequential-phase.md'
862
+ ],
863
+ autonomous: [
864
+ 'templates/autonomous-orchestrator.md',
865
+ 'templates/autonomous-action.md'
866
+ ]
867
+ };
868
+
869
+ const mode = '${config.execution_mode}';
870
+ const requiredTemplates = [...templates.all, ...templates[mode]];
871
+
872
+ requiredTemplates.forEach(template => {
873
+ const content = Read(\`.claude/skills/skill-generator/\${template}\`);
874
+ // 理解模板结构、变量位置、生成规则
875
+ });
876
+ \`\`\`
877
+
878
+ ## Execution
879
+
880
+ \`\`\`javascript
881
+ // ========== 加载规范 ==========
882
+ const specs = [];
883
+
884
+ // 1. 设计规范 (P0)
885
+ specs.push({
886
+ file: '../_shared/SKILL-DESIGN-SPEC.md',
887
+ content: Read('.claude/skills/_shared/SKILL-DESIGN-SPEC.md'),
888
+ priority: 'P0'
889
+ });
890
+
891
+ // 2. 模板文件 (P1)
892
+ const templateFiles = Glob('.claude/skills/skill-generator/templates/*.md');
893
+ templateFiles.forEach(file => {
894
+ specs.push({
895
+ file: file,
896
+ content: Read(file),
897
+ priority: 'P1'
898
+ });
899
+ });
900
+
901
+ // ========== 内化规范 ==========
902
+ console.log('📖 Reading specifications...');
903
+ specs.forEach(spec => {
904
+ console.log(\` [\${spec.priority}] \${spec.file}\`);
905
+ // 理解内容(无需生成文件,仅内存处理)
906
+ });
907
+
908
+ // ========== 生成完成标记 ==========
909
+ const result = {
910
+ status: 'completed',
911
+ specs_loaded: specs.length,
912
+ timestamp: new Date().toISOString()
913
+ };
914
+
915
+ Write(\`\${workDir}/spec-study-complete.flag\`, JSON.stringify(result, null, 2));
916
+ \`\`\`
917
+
918
+ ## Output
919
+
920
+ - **标记文件**: \`spec-study-complete.flag\` (证明已完成阅读)
921
+ - **副作用**: 内化规范知识,后续阶段遵循标准
922
+
923
+ ## Success Criteria
924
+
925
+ ✅ **通过标准**:
926
+ - [ ] 已阅读 SKILL-DESIGN-SPEC.md
927
+ - [ ] 已阅读执行模式对应的模板文件
928
+ - [ ] 理解目录结构约定
929
+ - [ ] 理解命名规范
930
+ - [ ] 理解质量标准
931
+
932
+ ## Next Phase
933
+
934
+ → [Phase 1: Requirements Discovery](01-requirements-discovery.md)
935
+
936
+ **关键**: 只有完成规范研读后,Phase 1 才能正确收集需求并生成符合标准的配置。
937
+ `;
938
+ }
939
+
940
+ // ========== 其他辅助函数 ==========
757
941
  function toPascalCase(str) {
758
942
  return str.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join('');
759
943
  }
@@ -782,21 +966,4 @@ function getPreconditionCheck(action) {
782
966
  }
783
967
  ```
784
968
 
785
- ## Output
786
-
787
- ### Sequential 模式
788
-
789
- - `phases/_orchestrator.md` (声明式编排器)
790
- - `workflow.json` (工作流定义)
791
- - `phases/01-{step}.md`, `02-{step}.md`, ...
792
-
793
- ### Autonomous 模式
794
-
795
- - `phases/orchestrator.md` (增强版编排器)
796
- - `phases/state-schema.md`
797
- - `specs/action-catalog.md` (声明式动作目录)
798
- - `phases/actions/action-{name}.md` (多个)
799
-
800
- ## Next Phase
801
969
 
802
- → [Phase 4: Specs & Templates](04-specs-templates.md)
@@ -1,26 +1,107 @@
1
- # Phase 4: Specs & Templates Generation
1
+ # Phase 4: Specifications & Templates Generation
2
2
 
3
- 生成规范文件和模板文件。
3
+ Generate domain requirements, quality standards, agent templates, and action catalogs.
4
4
 
5
5
  ## Objective
6
6
 
7
- - 生成领域规范 (`specs/{domain}-requirements.md`)
8
- - 生成质量标准 (`specs/quality-standards.md`)
9
- - 生成 Agent 模板 (`templates/agent-base.md`)
10
- - Autonomous 模式额外生成动作目录 (`specs/action-catalog.md`)
7
+ Generate comprehensive specifications and templates:
8
+ - Domain requirements document with validation function
9
+ - Quality standards with automated check system
10
+ - Agent base template with prompt structure
11
+ - Action catalog for autonomous mode (conditional)
11
12
 
12
13
  ## Input
13
14
 
14
- - 依赖: `skill-config.json`, SKILL.md, phases/*.md
15
+ **File Dependencies**:
16
+ - `skill-config.json` (from Phase 1)
17
+ - `.claude/skills/{skill-name}/` directory (from Phase 2)
18
+ - Generated phase/action files (from Phase 3)
15
19
 
16
- ## Execution Steps
20
+ **Required Information**:
21
+ - Skill name, display name, description
22
+ - Execution mode (determines if action-catalog.md is generated)
23
+ - Output format and location
24
+ - Phase/action definitions
17
25
 
18
- ### Step 1: 生成领域规范
26
+ ## Output
27
+
28
+ **Generated Files**:
29
+
30
+ | File | Purpose | Generation Condition |
31
+ |------|---------|---------------------|
32
+ | `specs/{skill-name}-requirements.md` | Domain requirements with validation | Always |
33
+ | `specs/quality-standards.md` | Quality evaluation criteria | Always |
34
+ | `templates/agent-base.md` | Agent prompt template | Always |
35
+ | `specs/action-catalog.md` | Action dependency graph and selection priority | Autonomous/Hybrid mode only |
36
+
37
+ **File Structure**:
38
+
39
+ **Domain Requirements** (`specs/{skill-name}-requirements.md`):
40
+ ```markdown
41
+ # {display_name} Requirements
42
+ - When to Use (phase/action reference table)
43
+ - Domain Requirements (功能要求, 输出要求, 质量要求)
44
+ - Validation Function (JavaScript code)
45
+ - Error Handling (recovery strategies)
46
+ ```
47
+
48
+ **Quality Standards** (`specs/quality-standards.md`):
49
+ ```markdown
50
+ # Quality Standards
51
+ - Quality Dimensions (Completeness 25%, Consistency 25%, Accuracy 25%, Usability 25%)
52
+ - Quality Gates (Pass ≥80%, Review 60-79%, Fail <60%)
53
+ - Issue Classification (Errors, Warnings, Info)
54
+ - Automated Checks (runQualityChecks function)
55
+ ```
56
+
57
+ **Agent Base** (`templates/agent-base.md`):
58
+ ```markdown
59
+ # Agent Base Template
60
+ - 通用 Prompt 结构 (ROLE, PROJECT CONTEXT, TASK, CONSTRAINTS, OUTPUT_FORMAT, QUALITY_CHECKLIST)
61
+ - 变量说明 (workDir, output_path)
62
+ - 返回格式 (AgentReturn interface)
63
+ - 角色定义参考 (phase/action specific agents)
64
+ ```
65
+
66
+ **Action Catalog** (`specs/action-catalog.md`, Autonomous/Hybrid only):
67
+ ```markdown
68
+ # Action Catalog
69
+ - Available Actions (table with Purpose, Preconditions, Effects)
70
+ - Action Dependencies (Mermaid diagram)
71
+ - State Transitions (state machine table)
72
+ - Selection Priority (ordered action list)
73
+ ```
74
+
75
+ ## Decision Logic
76
+
77
+ ```
78
+ Decision (execution_mode check):
79
+ ├─ mode === 'sequential' → Generate 3 files only
80
+ │ └─ Files: requirements.md, quality-standards.md, agent-base.md
81
+
82
+ ├─ mode === 'autonomous' → Generate 4 files
83
+ │ ├─ Files: requirements.md, quality-standards.md, agent-base.md
84
+ │ └─ Additional: action-catalog.md (with action dependencies)
85
+
86
+ └─ mode === 'hybrid' → Generate 4 files
87
+ ├─ Files: requirements.md, quality-standards.md, agent-base.md
88
+ └─ Additional: action-catalog.md (with hybrid logic)
89
+ ```
90
+
91
+ ## Execution Protocol
19
92
 
20
93
  ```javascript
94
+ // Phase 4: Generate Specifications & Templates
95
+ // Reference: phases/04-specs-templates.md
96
+
97
+ // Load config and setup
21
98
  const config = JSON.parse(Read(`${workDir}/skill-config.json`));
22
99
  const skillDir = `.claude/skills/${config.skill_name}`;
23
100
 
101
+ // Ensure specs and templates directories exist (created in Phase 2)
102
+ // skillDir structure: phases/, specs/, templates/
103
+
104
+ // Step 1: Generate domain requirements
24
105
  const domainRequirements = `# ${config.display_name} Requirements
25
106
 
26
107
  ${config.description}
@@ -29,8 +110,8 @@ ${config.description}
29
110
 
30
111
  | Phase | Usage | Reference |
31
112
  |-------|-------|-----------|
32
- ${config.execution_mode === 'sequential' ?
33
- config.sequential_config.phases.map((p, i) =>
113
+ ${config.execution_mode === 'sequential' ?
114
+ config.sequential_config.phases.map((p, i) =>
34
115
  `| Phase ${i+1} | ${p.name} | ${p.id}.md |`
35
116
  ).join('\n') :
36
117
  `| Orchestrator | 动作选择 | orchestrator.md |
@@ -67,7 +148,7 @@ function validate${toPascalCase(config.skill_name)}(output) {
67
148
  { name: "格式正确", pass: output.format === "${config.output.format}" },
68
149
  { name: "内容完整", pass: output.content?.length > 0 }
69
150
  ];
70
-
151
+
71
152
  return {
72
153
  passed: checks.filter(c => c.pass).length,
73
154
  total: checks.length,
@@ -86,11 +167,8 @@ function validate${toPascalCase(config.skill_name)}(output) {
86
167
  `;
87
168
 
88
169
  Write(`${skillDir}/specs/${config.skill_name}-requirements.md`, domainRequirements);
89
- ```
90
170
 
91
- ### Step 2: 生成质量标准
92
-
93
- ```javascript
171
+ // Step 2: Generate quality standards
94
172
  const qualityStandards = `# Quality Standards
95
173
 
96
174
  ${config.display_name} 的质量评估标准。
@@ -176,7 +254,7 @@ function runQualityChecks(workDir) {
176
254
 
177
255
  return {
178
256
  score: results.overall,
179
- gate: results.overall >= 80 ? 'pass' :
257
+ gate: results.overall >= 80 ? 'pass' :
180
258
  results.overall >= 60 ? 'review' : 'fail',
181
259
  details: results
182
260
  };
@@ -185,11 +263,8 @@ function runQualityChecks(workDir) {
185
263
  `;
186
264
 
187
265
  Write(`${skillDir}/specs/quality-standards.md`, qualityStandards);
188
- ```
189
-
190
- ### Step 3: 生成 Agent 模板
191
266
 
192
- ```javascript
267
+ // Step 3: Generate agent base template
193
268
  const agentBase = `# Agent Base Template
194
269
 
195
270
  ${config.display_name} 的 Agent 基础模板。
@@ -246,20 +321,17 @@ interface AgentReturn {
246
321
  ## 角色定义参考
247
322
 
248
323
  ${config.execution_mode === 'sequential' ?
249
- config.sequential_config.phases.map((p, i) =>
324
+ config.sequential_config.phases.map((p, i) =>
250
325
  `- **Phase ${i+1} Agent**: ${p.name} 专家`
251
326
  ).join('\n') :
252
- config.autonomous_config.actions.map(a =>
327
+ config.autonomous_config.actions.map(a =>
253
328
  `- **${a.name} Agent**: ${a.description || a.name + ' 执行者'}`
254
329
  ).join('\n')}
255
330
  `;
256
331
 
257
332
  Write(`${skillDir}/templates/agent-base.md`, agentBase);
258
- ```
259
-
260
- ### Step 4: Autonomous 模式 - 动作目录
261
333
 
262
- ```javascript
334
+ // Step 4: Conditional - Generate action catalog for autonomous/hybrid mode
263
335
  if (config.execution_mode === 'autonomous' || config.execution_mode === 'hybrid') {
264
336
  const actionCatalog = `# Action Catalog
265
337
 
@@ -269,7 +341,7 @@ ${config.display_name} 的可用动作目录。
269
341
 
270
342
  | Action | Purpose | Preconditions | Effects |
271
343
  |--------|---------|---------------|---------|
272
- ${config.autonomous_config.actions.map(a =>
344
+ ${config.autonomous_config.actions.map(a =>
273
345
  `| [${a.id}](../phases/actions/${a.id}.md) | ${a.description || a.name} | ${a.preconditions?.join(', ') || '-'} | ${a.effects?.join(', ') || '-'} |`
274
346
  ).join('\n')}
275
347
 
@@ -289,7 +361,7 @@ ${config.autonomous_config.actions.map((a, i, arr) => {
289
361
  | From State | Action | To State |
290
362
  |------------|--------|----------|
291
363
  | pending | action-init | running |
292
- ${config.autonomous_config.actions.slice(1).map(a =>
364
+ ${config.autonomous_config.actions.slice(1).map(a =>
293
365
  `| running | ${a.id} | running |`
294
366
  ).join('\n')}
295
367
  | running | action-complete | completed |
@@ -299,30 +371,28 @@ ${config.autonomous_config.actions.slice(1).map(a =>
299
371
 
300
372
  当多个动作的前置条件都满足时,按以下优先级选择:
301
373
 
302
- ${config.autonomous_config.actions.map((a, i) =>
374
+ ${config.autonomous_config.actions.map((a, i) =>
303
375
  `${i + 1}. \`${a.id}\` - ${a.name}`
304
376
  ).join('\n')}
305
377
  `;
306
378
 
307
379
  Write(`${skillDir}/specs/action-catalog.md`, actionCatalog);
308
380
  }
309
- ```
310
-
311
- ### Step 5: 辅助函数
312
381
 
313
- ```javascript
382
+ // Helper function
314
383
  function toPascalCase(str) {
315
384
  return str.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join('');
316
385
  }
317
- ```
318
386
 
319
- ## Output
320
-
321
- - `specs/{skill-name}-requirements.md` - 领域规范
322
- - `specs/quality-standards.md` - 质量标准
323
- - `specs/action-catalog.md` - 动作目录 (Autonomous 模式)
324
- - `templates/agent-base.md` - Agent 模板
387
+ // Phase output summary
388
+ console.log('Phase 4 complete: Generated specs and templates');
389
+ ```
325
390
 
326
391
  ## Next Phase
327
392
 
328
393
  → [Phase 5: Validation](05-validation.md)
394
+
395
+ **Data Flow to Phase 5**:
396
+ - All generated files in `specs/` and `templates/`
397
+ - skill-config.json for validation reference
398
+ - Complete skill directory structure ready for final validation