@michaelxwb/code-flow 0.8.1 → 1.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 (268) hide show
  1. package/README.md +73 -152
  2. package/bin/code-flow.js +12 -0
  3. package/docs/README.md +19 -0
  4. package/docs/USAGE.md +156 -1417
  5. package/docs/v1-design.md +1858 -0
  6. package/docs/v1-implementation.md +186 -0
  7. package/lib/adapters.js +126 -0
  8. package/lib/cli.js +258 -0
  9. package/lib/config.js +85 -0
  10. package/lib/doctor.js +283 -0
  11. package/lib/frontmatter.js +42 -0
  12. package/lib/fs.js +141 -0
  13. package/lib/glob.js +23 -0
  14. package/lib/hook.js +99 -0
  15. package/lib/init.js +132 -0
  16. package/lib/learn.js +170 -0
  17. package/lib/locks.js +52 -0
  18. package/lib/markdown.js +13 -0
  19. package/lib/process.js +116 -0
  20. package/lib/render.js +115 -0
  21. package/lib/repo.js +48 -0
  22. package/lib/runs.js +155 -0
  23. package/lib/session.js +40 -0
  24. package/lib/spec.js +80 -0
  25. package/lib/task.js +258 -0
  26. package/lib/taskdoc.js +308 -0
  27. package/lib/toml.js +140 -0
  28. package/lib/verify.js +168 -0
  29. package/lib/worktree.js +930 -0
  30. package/package.json +18 -21
  31. package/templates/adapters/opencode.mjs +65 -0
  32. package/templates/config.json +39 -0
  33. package/templates/instructions.md +13 -0
  34. package/templates/launcher/bridge.cjs +295 -0
  35. package/templates/launcher/hook.cmd +15 -0
  36. package/templates/launcher/hook.ps1 +10 -0
  37. package/templates/launcher/hook.sh +20 -0
  38. package/templates/skills/cf-check.md +19 -0
  39. package/templates/skills/cf-init.md +16 -0
  40. package/templates/skills/cf-spec.md +20 -0
  41. package/templates/skills/cf-task-align.md +19 -0
  42. package/templates/skills/cf-task-archive.md +20 -0
  43. package/templates/skills/cf-task-plan.md +31 -0
  44. package/templates/skills/cf-task-prd.md +14 -0
  45. package/templates/skills/cf-task-start.md +41 -0
  46. package/{src/core/code-flow/specs/shared/design → templates/workflow}/design-frontend.md +12 -12
  47. package/{src/core/code-flow/specs/shared/design → templates/workflow}/design-full.md +17 -19
  48. package/{src/core/code-flow/specs/shared/design → templates/workflow}/design-lite.md +12 -12
  49. package/{src/core/code-flow/specs/shared/prd-template.md → templates/workflow/prd.md} +1 -1
  50. package/templates/workflow/project-guidelines.md +48 -0
  51. package/templates/workflow/scenarios.md +67 -0
  52. package/templates/workflow/task.md +56 -0
  53. package/docs/acceptance-contract.md +0 -217
  54. package/docs/ci/acceptance-evidence.md +0 -77
  55. package/docs/migrations/runtime-0.7.0.md +0 -41
  56. package/docs/migrations/runtime-0.8.0.md +0 -154
  57. package/docs/migrations/runtime-0.9.0.md +0 -40
  58. package/docs/migrations/spec-workflow-0.6.0.md +0 -42
  59. package/docs/spec-injection-hardening.md +0 -54
  60. package/docs/spec-injection-performance.json +0 -73
  61. package/docs/spec-optimization.md +0 -12
  62. package/src/adapters/claude/CLAUDE.md +0 -45
  63. package/src/adapters/claude/commands/cf-init.md +0 -262
  64. package/src/adapters/claude/commands/cf-learn.md +0 -291
  65. package/src/adapters/claude/commands/cf-spec.md +0 -87
  66. package/src/adapters/claude/commands/cf-stats.md +0 -96
  67. package/src/adapters/claude/commands/cf-sync.md +0 -39
  68. package/src/adapters/claude/commands/cf-task/align.md +0 -331
  69. package/src/adapters/claude/commands/cf-task/archive.md +0 -155
  70. package/src/adapters/claude/commands/cf-task/block.md +0 -49
  71. package/src/adapters/claude/commands/cf-task/graph.md +0 -92
  72. package/src/adapters/claude/commands/cf-task/note.md +0 -248
  73. package/src/adapters/claude/commands/cf-task/plan.md +0 -477
  74. package/src/adapters/claude/commands/cf-task/prd.md +0 -173
  75. package/src/adapters/claude/commands/cf-task/start.md +0 -317
  76. package/src/adapters/claude/commands/cf-task/status.md +0 -71
  77. package/src/adapters/claude/commands/cf-task/verify-e2e.md +0 -148
  78. package/src/adapters/claude/commands/cf-validate.md +0 -100
  79. package/src/adapters/claude/settings.local.json +0 -50
  80. package/src/adapters/codex/AGENTS.md +0 -45
  81. package/src/adapters/codex/config.toml +0 -3
  82. package/src/adapters/codex/hooks.json +0 -54
  83. package/src/adapters/codex/skills/cf-init/SKILL.md +0 -273
  84. package/src/adapters/codex/skills/cf-learn/SKILL.md +0 -296
  85. package/src/adapters/codex/skills/cf-spec/SKILL.md +0 -88
  86. package/src/adapters/codex/skills/cf-stats/SKILL.md +0 -97
  87. package/src/adapters/codex/skills/cf-sync/SKILL.md +0 -45
  88. package/src/adapters/codex/skills/cf-task-align/SKILL.md +0 -332
  89. package/src/adapters/codex/skills/cf-task-archive/SKILL.md +0 -156
  90. package/src/adapters/codex/skills/cf-task-block/SKILL.md +0 -50
  91. package/src/adapters/codex/skills/cf-task-graph/SKILL.md +0 -93
  92. package/src/adapters/codex/skills/cf-task-note/SKILL.md +0 -245
  93. package/src/adapters/codex/skills/cf-task-plan/SKILL.md +0 -478
  94. package/src/adapters/codex/skills/cf-task-prd/SKILL.md +0 -174
  95. package/src/adapters/codex/skills/cf-task-start/SKILL.md +0 -318
  96. package/src/adapters/codex/skills/cf-task-status/SKILL.md +0 -72
  97. package/src/adapters/codex/skills/cf-task-verify-e2e/SKILL.md +0 -145
  98. package/src/adapters/codex/skills/cf-validate/SKILL.md +0 -102
  99. package/src/adapters/commands.json +0 -115
  100. package/src/adapters/costrict/CLAUDE.md +0 -45
  101. package/src/adapters/costrict/commands/cf-init.md +0 -262
  102. package/src/adapters/costrict/commands/cf-learn.md +0 -291
  103. package/src/adapters/costrict/commands/cf-spec.md +0 -87
  104. package/src/adapters/costrict/commands/cf-stats.md +0 -96
  105. package/src/adapters/costrict/commands/cf-sync.md +0 -39
  106. package/src/adapters/costrict/commands/cf-task/align.md +0 -331
  107. package/src/adapters/costrict/commands/cf-task/archive.md +0 -155
  108. package/src/adapters/costrict/commands/cf-task/block.md +0 -49
  109. package/src/adapters/costrict/commands/cf-task/graph.md +0 -92
  110. package/src/adapters/costrict/commands/cf-task/note.md +0 -248
  111. package/src/adapters/costrict/commands/cf-task/plan.md +0 -477
  112. package/src/adapters/costrict/commands/cf-task/prd.md +0 -173
  113. package/src/adapters/costrict/commands/cf-task/start.md +0 -317
  114. package/src/adapters/costrict/commands/cf-task/status.md +0 -71
  115. package/src/adapters/costrict/commands/cf-task/verify-e2e.md +0 -148
  116. package/src/adapters/costrict/commands/cf-validate.md +0 -100
  117. package/src/adapters/costrict/settings.local.json +0 -50
  118. package/src/adapters/install-plan.json +0 -100
  119. package/src/adapters/opencode/AGENTS.md +0 -45
  120. package/src/adapters/opencode/commands/cf-init.md +0 -281
  121. package/src/adapters/opencode/commands/cf-learn.md +0 -295
  122. package/src/adapters/opencode/commands/cf-spec.md +0 -91
  123. package/src/adapters/opencode/commands/cf-stats.md +0 -100
  124. package/src/adapters/opencode/commands/cf-sync.md +0 -44
  125. package/src/adapters/opencode/commands/cf-task/align.md +0 -331
  126. package/src/adapters/opencode/commands/cf-task/archive.md +0 -160
  127. package/src/adapters/opencode/commands/cf-task/block.md +0 -54
  128. package/src/adapters/opencode/commands/cf-task/graph.md +0 -97
  129. package/src/adapters/opencode/commands/cf-task/note.md +0 -253
  130. package/src/adapters/opencode/commands/cf-task/plan.md +0 -477
  131. package/src/adapters/opencode/commands/cf-task/prd.md +0 -178
  132. package/src/adapters/opencode/commands/cf-task/start.md +0 -317
  133. package/src/adapters/opencode/commands/cf-task/status.md +0 -76
  134. package/src/adapters/opencode/commands/cf-task/verify-e2e.md +0 -148
  135. package/src/adapters/opencode/commands/cf-validate.md +0 -105
  136. package/src/adapters/opencode/opencode.json +0 -3
  137. package/src/adapters/opencode/plugins/code-flow/index.js +0 -162
  138. package/src/adapters/opencode/plugins/code-flow/package.json +0 -6
  139. package/src/adapters/platform-bindings.json +0 -370
  140. package/src/cli.js +0 -1076
  141. package/src/core/code-flow/config.yml +0 -161
  142. package/src/core/code-flow/runtime-commands.json +0 -259
  143. package/src/core/code-flow/scripts/cf_acceptance_manifest.py +0 -10
  144. package/src/core/code-flow/scripts/cf_acceptance_runner.py +0 -10
  145. package/src/core/code-flow/scripts/cf_audit.py +0 -10
  146. package/src/core/code-flow/scripts/cf_codex_hook.py +0 -10
  147. package/src/core/code-flow/scripts/cf_design_lint.py +0 -10
  148. package/src/core/code-flow/scripts/cf_evidence_import.py +0 -10
  149. package/src/core/code-flow/scripts/cf_feedback.py +0 -10
  150. package/src/core/code-flow/scripts/cf_opencode_event.py +0 -10
  151. package/src/core/code-flow/scripts/cf_post_hook.py +0 -11
  152. package/src/core/code-flow/scripts/cf_pre_tool_hook.py +0 -11
  153. package/src/core/code-flow/scripts/cf_scenarios.py +0 -10
  154. package/src/core/code-flow/scripts/cf_spec_context.py +0 -10
  155. package/src/core/code-flow/scripts/cf_spec_gate.py +0 -10
  156. package/src/core/code-flow/scripts/cf_spec_session.py +0 -10
  157. package/src/core/code-flow/scripts/cf_stats.py +0 -10
  158. package/src/core/code-flow/scripts/cf_stop_hook.py +0 -11
  159. package/src/core/code-flow/scripts/cf_sync.py +0 -10
  160. package/src/core/code-flow/scripts/cf_task_index.py +0 -10
  161. package/src/core/code-flow/scripts/cf_task_parallel.py +0 -10
  162. package/src/core/code-flow/scripts/cf_task_workflow.py +0 -10
  163. package/src/core/code-flow/scripts/cf_user_prompt_hook.py +0 -11
  164. package/src/core/code-flow/scripts/cf_validation.py +0 -10
  165. package/src/core/code-flow/scripts/codeflow/__init__.py +0 -0
  166. package/src/core/code-flow/scripts/codeflow/acceptance/__init__.py +0 -0
  167. package/src/core/code-flow/scripts/codeflow/acceptance/cf_acceptance_evidence.py +0 -347
  168. package/src/core/code-flow/scripts/codeflow/acceptance/cf_acceptance_manifest_core.py +0 -660
  169. package/src/core/code-flow/scripts/codeflow/acceptance/cf_acceptance_plan.py +0 -202
  170. package/src/core/code-flow/scripts/codeflow/acceptance/cf_acceptance_registration.py +0 -60
  171. package/src/core/code-flow/scripts/codeflow/acceptance/cf_acceptance_risk.py +0 -73
  172. package/src/core/code-flow/scripts/codeflow/acceptance/cf_acceptance_schema.py +0 -282
  173. package/src/core/code-flow/scripts/codeflow/acceptance/cf_acceptance_selection.py +0 -266
  174. package/src/core/code-flow/scripts/codeflow/acceptance/cf_check_inputs.py +0 -172
  175. package/src/core/code-flow/scripts/codeflow/acceptance/cf_check_registration.py +0 -326
  176. package/src/core/code-flow/scripts/codeflow/acceptance/cf_checks.py +0 -333
  177. package/src/core/code-flow/scripts/codeflow/acceptance/cf_plan_quality.py +0 -197
  178. package/src/core/code-flow/scripts/codeflow/acceptance/cf_scenario_quality.py +0 -174
  179. package/src/core/code-flow/scripts/codeflow/acceptance/cf_scenario_source.py +0 -300
  180. package/src/core/code-flow/scripts/codeflow/acceptance/cf_traceability.py +0 -502
  181. package/src/core/code-flow/scripts/codeflow/cli/__init__.py +0 -0
  182. package/src/core/code-flow/scripts/codeflow/cli/cf_acceptance_manifest.py +0 -347
  183. package/src/core/code-flow/scripts/codeflow/cli/cf_acceptance_runner.py +0 -1490
  184. package/src/core/code-flow/scripts/codeflow/cli/cf_audit.py +0 -533
  185. package/src/core/code-flow/scripts/codeflow/cli/cf_design_lint.py +0 -172
  186. package/src/core/code-flow/scripts/codeflow/cli/cf_evidence_import.py +0 -607
  187. package/src/core/code-flow/scripts/codeflow/cli/cf_feedback.py +0 -53
  188. package/src/core/code-flow/scripts/codeflow/cli/cf_scenarios.py +0 -58
  189. package/src/core/code-flow/scripts/codeflow/cli/cf_spec_context.py +0 -1175
  190. package/src/core/code-flow/scripts/codeflow/cli/cf_spec_gate.py +0 -60
  191. package/src/core/code-flow/scripts/codeflow/cli/cf_spec_session.py +0 -46
  192. package/src/core/code-flow/scripts/codeflow/cli/cf_stats.py +0 -540
  193. package/src/core/code-flow/scripts/codeflow/cli/cf_sync.py +0 -144
  194. package/src/core/code-flow/scripts/codeflow/cli/cf_task_index.py +0 -177
  195. package/src/core/code-flow/scripts/codeflow/cli/cf_task_parallel.py +0 -1142
  196. package/src/core/code-flow/scripts/codeflow/cli/cf_task_workflow.py +0 -742
  197. package/src/core/code-flow/scripts/codeflow/cli/cf_validation.py +0 -31
  198. package/src/core/code-flow/scripts/codeflow/core/__init__.py +0 -0
  199. package/src/core/code-flow/scripts/codeflow/core/cf_context_cache.py +0 -67
  200. package/src/core/code-flow/scripts/codeflow/core/cf_core.py +0 -609
  201. package/src/core/code-flow/scripts/codeflow/core/cf_exec_base.py +0 -325
  202. package/src/core/code-flow/scripts/codeflow/core/cf_fs.py +0 -57
  203. package/src/core/code-flow/scripts/codeflow/core/cf_git.py +0 -92
  204. package/src/core/code-flow/scripts/codeflow/core/cf_log.py +0 -160
  205. package/src/core/code-flow/scripts/codeflow/core/cf_markdown.py +0 -77
  206. package/src/core/code-flow/scripts/codeflow/core/cf_native_paths.py +0 -26
  207. package/src/core/code-flow/scripts/codeflow/core/cf_patch.py +0 -33
  208. package/src/core/code-flow/scripts/codeflow/core/cf_runtime_install.py +0 -32
  209. package/src/core/code-flow/scripts/codeflow/core/cf_session_state.py +0 -37
  210. package/src/core/code-flow/scripts/codeflow/core/cf_stop_guard.py +0 -53
  211. package/src/core/code-flow/scripts/codeflow/core/cf_task_state.py +0 -9
  212. package/src/core/code-flow/scripts/codeflow/core/cf_validators.py +0 -408
  213. package/src/core/code-flow/scripts/codeflow/core/cf_worktree_env.py +0 -253
  214. package/src/core/code-flow/scripts/codeflow/evidence/__init__.py +0 -0
  215. package/src/core/code-flow/scripts/codeflow/evidence/cf_evidence_store.py +0 -527
  216. package/src/core/code-flow/scripts/codeflow/hooks/__init__.py +0 -0
  217. package/src/core/code-flow/scripts/codeflow/hooks/cf_codex_hook.py +0 -95
  218. package/src/core/code-flow/scripts/codeflow/hooks/cf_opencode_event.py +0 -98
  219. package/src/core/code-flow/scripts/codeflow/hooks/cf_post_hook.py +0 -30
  220. package/src/core/code-flow/scripts/codeflow/hooks/cf_pre_tool_hook.py +0 -41
  221. package/src/core/code-flow/scripts/codeflow/hooks/cf_stop_hook.py +0 -292
  222. package/src/core/code-flow/scripts/codeflow/hooks/cf_user_prompt_hook.py +0 -161
  223. package/src/core/code-flow/scripts/codeflow/spec/__init__.py +0 -0
  224. package/src/core/code-flow/scripts/codeflow/spec/cf_active_task.py +0 -412
  225. package/src/core/code-flow/scripts/codeflow/spec/cf_context_refresh.py +0 -301
  226. package/src/core/code-flow/scripts/codeflow/spec/cf_edit_service.py +0 -149
  227. package/src/core/code-flow/scripts/codeflow/spec/cf_injection.py +0 -111
  228. package/src/core/code-flow/scripts/codeflow/spec/cf_rule_readiness.py +0 -114
  229. package/src/core/code-flow/scripts/codeflow/spec/cf_scan.py +0 -367
  230. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_budget.py +0 -55
  231. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_context_model.py +0 -477
  232. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_impact.py +0 -119
  233. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_metadata.py +0 -387
  234. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_migrate.py +0 -529
  235. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_optimize.py +0 -193
  236. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_optimize_apply.py +0 -187
  237. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_resolver.py +0 -369
  238. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_router.py +0 -304
  239. package/src/core/code-flow/scripts/codeflow/spec/cf_spec_verify.py +0 -687
  240. package/src/core/code-flow/scripts/codeflow/spec/cf_stage_gate.py +0 -330
  241. package/src/core/code-flow/scripts/codeflow/spec/cf_task_projection.py +0 -83
  242. package/src/core/code-flow/scripts/codeflow/spec/cf_workflow_service.py +0 -755
  243. package/src/core/code-flow/scripts/codeflow/spec/cf_workflow_transaction.py +0 -110
  244. package/src/core/code-flow/scripts/codeflow/task/__init__.py +0 -0
  245. package/src/core/code-flow/scripts/codeflow/task/cf_requirement_verification.py +0 -867
  246. package/src/core/code-flow/scripts/codeflow/task/cf_task_doc.py +0 -178
  247. package/src/core/code-flow/scripts/codeflow/task/cf_task_merge.py +0 -635
  248. package/src/core/code-flow/scripts/codeflow/task/cf_task_plan.py +0 -251
  249. package/src/core/code-flow/scripts/codeflow/task/cf_task_runtime.py +0 -570
  250. package/src/core/code-flow/scripts/codeflow/task/cf_validation_service.py +0 -73
  251. package/src/core/code-flow/scripts/runtime-resources.json +0 -29
  252. package/src/core/code-flow/specs/backend/_map.md +0 -56
  253. package/src/core/code-flow/specs/backend/code-quality-performance.md +0 -59
  254. package/src/core/code-flow/specs/backend/database.md +0 -51
  255. package/src/core/code-flow/specs/backend/directory-structure.md +0 -54
  256. package/src/core/code-flow/specs/backend/logging.md +0 -50
  257. package/src/core/code-flow/specs/backend/platform-rules.md +0 -55
  258. package/src/core/code-flow/specs/frontend/_map.md +0 -52
  259. package/src/core/code-flow/specs/frontend/component-specs.md +0 -68
  260. package/src/core/code-flow/specs/frontend/directory-structure.md +0 -53
  261. package/src/core/code-flow/specs/frontend/quality-standards.md +0 -58
  262. package/src/core/code-flow/specs/shared/_map.md +0 -57
  263. package/src/core/code-flow/specs/shared/scenarios-template.md +0 -55
  264. package/src/core/code-flow/tasks/.gitkeep +0 -0
  265. package/src/core/code-flow/validation.yml +0 -59
  266. package/src/migrate/runtime.js +0 -213
  267. package/src/migrate/spec-workflow.js +0 -253
  268. package/src/runtime.js +0 -219
@@ -1,50 +0,0 @@
1
- {
2
- "hooks": {
3
- "PreToolUse": [
4
- {
5
- "matcher": "Edit|Write|MultiEdit",
6
- "hooks": [
7
- {
8
- "type": "command",
9
- "command": "d=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}\"; f=\"$d/.code-flow/scripts/cf_pre_tool_hook.py\"; if [ -f \"$f\" ]; then cd \"$d\" && python3 \"$f\"; fi",
10
- "timeout": 5
11
- }
12
- ]
13
- }
14
- ],
15
- "PostToolUse": [
16
- {
17
- "matcher": "Edit|Write|MultiEdit",
18
- "hooks": [
19
- {
20
- "type": "command",
21
- "command": "d=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}\"; f=\"$d/.code-flow/scripts/cf_post_hook.py\"; if [ -f \"$f\" ]; then cd \"$d\" && python3 \"$f\"; fi",
22
- "timeout": 5
23
- }
24
- ]
25
- }
26
- ],
27
- "UserPromptSubmit": [
28
- {
29
- "hooks": [
30
- {
31
- "type": "command",
32
- "command": "d=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}\"; f=\"$d/.code-flow/scripts/cf_user_prompt_hook.py\"; if [ -f \"$f\" ]; then cd \"$d\" && python3 \"$f\"; fi",
33
- "timeout": 5
34
- }
35
- ]
36
- }
37
- ],
38
- "Stop": [
39
- {
40
- "hooks": [
41
- {
42
- "type": "command",
43
- "command": "d=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}\"; f=\"$d/.code-flow/scripts/cf_stop_hook.py\"; if [ -f \"$f\" ]; then cd \"$d\" && python3 \"$f\"; fi",
44
- "timeout": 35
45
- }
46
- ]
47
- }
48
- ]
49
- }
50
- }
@@ -1,100 +0,0 @@
1
- {
2
- "schema_version": 1,
3
- "core": {
4
- "source": "core/code-flow",
5
- "dest": ".code-flow",
6
- "prefix": ".code-flow",
7
- "category": null
8
- },
9
- "summary": [
10
- { "key": "updated", "title": "Updated (tool-managed):", "marker": "↑" },
11
- { "key": "merged", "title": "Merged (new sections added):", "marker": "⊕" },
12
- { "key": "created", "title": "Created:", "marker": "+" },
13
- { "key": "skipped", "title": "Skipped (user-customized):", "marker": "·" },
14
- { "key": "removed", "title": "Removed (deprecated):", "marker": "✕" }
15
- ],
16
- "platforms": {
17
- "claude": {
18
- "markers": [".claude/commands"],
19
- "entries": [
20
- { "kind": "file", "src": "claude/CLAUDE.md", "dest": "CLAUDE.md", "label": "CLAUDE.md", "category": "merge", "merger": "claudeMd" },
21
- { "kind": "dir", "src": "claude/commands", "dest": ".claude/commands", "prefix": ".claude/commands", "category": "tool", "ensure": true },
22
- { "kind": "file", "src": "claude/settings.local.json", "dest": ".claude/settings.local.json", "label": ".claude/settings.local.json", "category": "merge", "merger": "settingsJson" }
23
- ],
24
- "next_steps": {
25
- "fresh": [
26
- " 1. Edit CLAUDE.md — fill in team/project info",
27
- " 2. Run /cf-init in Claude Code to auto-scan and populate specs",
28
- " Or manually edit .code-flow/specs/ to fill in your coding standards"
29
- ],
30
- "upgrade": [
31
- " Run /cf-learn in Claude Code to update specs with project conventions",
32
- " Run /cf-learn --map to update retrieval maps"
33
- ]
34
- }
35
- },
36
- "costrict": {
37
- "markers": [".costrict/commands"],
38
- "entries": [
39
- { "kind": "file", "src": "costrict/CLAUDE.md", "dest": "CLAUDE.md", "label": "CLAUDE.md", "category": "merge", "merger": "claudeMd" },
40
- { "kind": "dir", "src": "costrict/commands", "dest": ".costrict/commands", "prefix": ".costrict/commands", "category": "tool", "ensure": true },
41
- { "kind": "file", "src": "costrict/settings.local.json", "dest": ".costrict/settings.local.json", "label": ".costrict/settings.local.json", "category": "merge", "merger": "settingsJson" }
42
- ],
43
- "next_steps": {
44
- "fresh": [
45
- " 1. Edit CLAUDE.md — fill in team/project info",
46
- " 2. Run /cf-init in Costrict to auto-scan and populate specs",
47
- " Or manually edit .code-flow/specs/ to fill in your coding standards"
48
- ],
49
- "upgrade": [
50
- " Run /cf-learn in Costrict to update specs with project conventions",
51
- " Run /cf-learn --map to update retrieval maps"
52
- ]
53
- }
54
- },
55
- "codex": {
56
- "markers": [".agents/skills"],
57
- "entries": [
58
- { "kind": "file", "src": "codex/AGENTS.md", "dest": "AGENTS.md", "label": "AGENTS.md", "category": "merge", "merger": "claudeMd" },
59
- { "kind": "file", "src": "codex/hooks.json", "dest": ".codex/hooks.json", "label": ".codex/hooks.json", "category": "merge", "merger": "codexHooksJson" },
60
- { "kind": "file", "src": "codex/config.toml", "dest": ".codex/config.toml", "label": ".codex/config.toml", "category": "merge", "merger": "codexConfigToml" },
61
- { "kind": "dir", "src": "codex/skills", "dest": ".agents/skills", "prefix": ".agents/skills", "category": "tool" }
62
- ],
63
- "next_steps": {
64
- "fresh": [
65
- " 1. Edit AGENTS.md — fill in team/project info",
66
- " 2. Run /hooks in Codex CLI and trust the code-flow hooks if prompted",
67
- " 3. Run $cf-init in Codex CLI to auto-scan and populate specs",
68
- " Or manually edit .code-flow/specs/ to fill in your coding standards"
69
- ],
70
- "upgrade": [
71
- " Run /hooks in Codex CLI and trust changed code-flow hooks if prompted",
72
- " Run $cf-learn in Codex CLI to update specs with project conventions",
73
- " Run $cf-learn --map to update retrieval maps"
74
- ]
75
- }
76
- },
77
- "opencode": {
78
- "markers": [".opencode/commands"],
79
- "entries": [
80
- { "kind": "file", "src": "opencode/AGENTS.md", "dest": "AGENTS.md", "label": "AGENTS.md", "category": "merge", "merger": "claudeMd" },
81
- { "kind": "dir", "src": "opencode/plugins", "dest": ".opencode/plugins", "prefix": ".opencode/plugins", "category": "tool" },
82
- { "kind": "stamp", "path": ".opencode/plugins/code-flow/package.json", "category": "tool" },
83
- { "kind": "dir", "src": "opencode/commands", "dest": ".opencode/commands", "prefix": ".opencode/commands", "category": "tool" },
84
- { "kind": "file", "src": "opencode/opencode.json", "dest": "opencode.json", "label": "opencode.json", "category": "merge", "merger": "opencodeJson" }
85
- ],
86
- "next_steps": {
87
- "fresh": [
88
- " 1. Edit AGENTS.md — fill in team/project info",
89
- " 2. Start opencode in this directory — the plugin auto-loads",
90
- " 3. Run /cf-init in OpenCode to auto-scan and populate specs",
91
- " Or manually edit .code-flow/specs/ to fill in your coding standards"
92
- ],
93
- "upgrade": [
94
- " Run /cf-learn in OpenCode to update specs with project conventions",
95
- " Run /cf-learn --map to update retrieval maps"
96
- ]
97
- }
98
- }
99
- }
100
- }
@@ -1,45 +0,0 @@
1
- # Project Guidelines
2
-
3
- ## Team Identity
4
- - Team: [team name]
5
- - Project: [project name]
6
- - Language: [primary language]
7
-
8
- ## Core Principles
9
- - All changes must include tests
10
- - Single responsibility per function (<= 50 lines)
11
- - No loose typing or silent exception handling
12
- - Handle errors explicitly
13
-
14
- ## Forbidden Patterns
15
- - Hard-coded secrets or credentials
16
- - Unparameterized SQL
17
- - Network calls inside tight loops
18
-
19
- <!-- code-flow:spec-loading schema=1 start -->
20
- ## Spec Workflow (schema 1)
21
-
22
- - If `.code-flow/.active-task.json` exists, validate it and `spec-context.yml`, then use only the active TASK's `Spec-Refs`, Design refs, and Acceptance Contract. Never reselect Specs from Catalog.
23
- - Without an active TASK, explicit file paths use deterministic `path_mapping` constraints; prompts without paths receive the Spec Catalog for exploration or creation of the next Context.
24
- - PRD, Design, Plan, Start, Coding, and Done inherit one persisted Context. Required rules must be applied and verified before their stage gate passes.
25
- - A corrupt marker, Context hash drift, or required scope expansion is `SPEC_WORKFLOW_BLOCKED`; run `cf-spec refresh/doctor` instead of falling back.
26
- - Tier 0 `_map.md` files are navigation only. Rule constraints live in metadata-bearing Tier 1 Specs.
27
-
28
- Do NOT ask the user which Specs to load—the Context-first router is authoritative.
29
- <!-- code-flow:spec-loading schema=1 end -->
30
-
31
- ## 合规反馈协议(quality_loop)
32
-
33
- 1. 编辑代码后收到 **Spec 合规反馈 (auto-check)** 时,先按提示修正违规,再继续当前任务
34
- 2. 用户表示某条反馈是误报("这是误报"/"忽略这个检查")时,代为执行:
35
- `code-flow feedback ignore <check-id>`
36
- (check-id 见反馈中的 `规则: <spec>#<check-id>`;同一规则误报达阈值会自动停用)
37
- 3. 会话收尾被校验拦回(cf-stop 反馈未过项)时,修复后再结束;不要绕过
38
- 4. 新增/修改规范时优先用 ✅/❌ 代码对照示例表达(见 spec 模板 Examples 段)
39
-
40
- ## Task Documents (cf-task workflow)
41
-
42
- - `.code-flow/specs/shared/` holds PRD/design templates(含前端 `design-frontend.md`)used by `/cf-task:prd` and `/cf-task:align`
43
- - 一个需求的 prd / design / tasks 同放需求目录 `.code-flow/tasks/<日期>/<需求>/`;全栈需求可有 `<需求>.frontend.design.md` + `<需求>.backend.design.md`,`/cf-task:plan <需求目录>` 合并拆解,`/cf-task:archive` 按整个需求目录归档(旧扁平布局仍兼容)
44
- - Workflow: `/cf-task:prd` → `.prd.md` → `/cf-task:align <.prd.md>` → `.design.md`(s) → `/cf-task:plan <需求目录>` → tasks
45
- - Templates are read by the commands themselves; you do not need to pre-load them
@@ -1,281 +0,0 @@
1
- ---
2
- description: 一键初始化项目规范体系,检测技术栈,生成 spec 模板和配置
3
- ---
4
-
5
- # cf-init
6
-
7
- 项目规范体系一键初始化。检测技术栈,基于 `code-flow init` 已部署的核心模板完成裁剪与填充,生成可检索、可注入、可维护的 specs。
8
-
9
- ## 输入
10
-
11
- - `/cf-init` — 自动检测技术栈
12
- - `/cf-init frontend` — 强制前端项目
13
- - `/cf-init backend` — 强制后端项目
14
- - `/cf-init fullstack` — 强制全栈项目
15
- - `/cf-init --skip-learn` — 跳过自动扫描,仅生成/修补模板
16
-
17
- ## 执行步骤
18
-
19
- ### 1. 检测技术栈
20
-
21
- 先用文件清单扫描项目根目录,再读取关键配置文件交叉判断。不要只因为 `package.json` 存在就判定为前端。
22
-
23
- **扫描信号**:
24
- - 前端依赖:`react`、`vue`、`@angular/core`、`svelte`、`next`、`nuxt`、`vite`、`webpack`
25
- - Node 后端依赖:`express`、`fastify`、`koa`、`@nestjs/*`、`hapi`、`prisma`、`typeorm`
26
- - Python 后端:`pyproject.toml`、`requirements.txt`、`setup.cfg`,以及 `fastapi`、`django`、`flask`、`sqlalchemy`、`pytest`、`ruff`、`mypy`
27
- - Go 后端:`go.mod`、`cmd/`、`internal/`、`pkg/`
28
- - Rust/Java 后端:`Cargo.toml`、`pom.xml`、`build.gradle`
29
- - 前端目录:`src/components`、`src/pages`、`src/hooks`、`app/`、`pages/`、`components/`、`styles/`
30
- - 后端目录:`api/`、`services/`、`handlers/`、`controllers/`、`models/`、`migrations/`、`routes/`
31
- - Monorepo:`apps/`、`packages/`、`frontend/`、`backend/`、`client/`、`server/`
32
-
33
- **判定规则**:
34
- - 用户指定 `frontend|backend|fullstack` 时,以用户参数为准,但仍记录检测到的框架和语言。
35
- - 同时命中明确前端和后端信号 → `fullstack`。
36
- - 只有前端框架/目录信号 → `frontend`。
37
- - 只有后端框架/目录信号 → `backend`。
38
- - 只有 `package.json` 且命中 Node 后端依赖 → `backend`;只有 `package.json` 但无框架信号 → `generic`,不要强行写前端规范。
39
- - 无明确技术栈 → `generic`,生成 frontend + backend 基础模板,但在摘要中标注“需人工确认”。
40
-
41
- ### 2. 校准 .code-flow/config.yml
42
-
43
- `code-flow init` 已从 `src/core/code-flow/config.yml` 复制当前核心模板。cf-init 不要复制或手写旧版 YAML;应该读取现有 `.code-flow/config.yml`,只做保守修补。
44
-
45
- 必须保持或补齐这些核心能力:
46
- - `spec_workflow.schema_version: 1`
47
- - `spec_workflow.catalog.dedup_window: 5`
48
- - `quality_loop.compress: true`
49
- - 完整 `skip_extensions`,包括图片、压缩包、PDF 等非代码文件
50
- - `skip_paths` 中的平台目录:`.claude/**`、`.codex/**`、`.costrict/**`、`.opencode/**`
51
- - `path_mapping.shared`,包括 `shared/_map.md`、`shared/prd-template.md`、`shared/design/design-lite.md`、`shared/design/design-full.md`、`shared/design/design-frontend.md`
52
- - backend patterns 中同时包含 `*.py` 与 `**/*.py`
53
- - 按检测到的前端框架动态补 `frontend.patterns`:Vue→`**/*.vue`、Svelte→`**/*.svelte`、Next→`app/**` 等(保守追加,按检测结果,不预塞所有框架)
54
-
55
- 根据技术栈只裁剪 `frontend` / `backend` 域:
56
- - `frontend`:保留 `shared` + `frontend`,删除 `backend`
57
- - `backend`:保留 `shared` + `backend`,删除 `frontend`
58
- - `fullstack` / `generic`:保留 `shared` + `frontend` + `backend`
59
- - 用户已有自定义域(如 `infra`、`mobile`、`cli`、`scripts`)必须保留,不得删除
60
-
61
- 如果发现 `.code-flow/config.yml` 缺失,提示用户先运行 `code-flow init --platform=<platform>`,不要手工拼装整份 YAML。
62
-
63
- ### 3. 裁剪 .code-flow/validation.yml
64
-
65
- `code-flow init` 已复制默认 `.code-flow/validation.yml`。读取并按技术栈删除不相关 validator,保持 YAML 结构和已有用户修改。
66
-
67
- - 纯前端项目:删除 `Python 类型检查`、`Pytest`
68
- - Python 后端项目:删除 `TypeScript 类型检查`、`Vue 类型检查`、`ESLint`、`Stylelint`、`前端单元测试`
69
- - Go/Rust/Java 后端:删除前端 validator;如果没有对应语言 validator,保留文件并在摘要中提示用户补充
70
- - fullstack / generic:全部保留,除非项目明确没有对应语言文件
71
- - 全量测试 / e2e 等慢命令(`pytest`、`vitest run`、Playwright 等)标 `heavy: true`:Stop 每轮跳过,任务 finish 自动执行一次,也可 `/cf-validate` 手动执行
72
-
73
- 若 `.code-flow/validation.yml` 缺失,提示用户重跑 `code-flow init`,不要手工拼装 YAML。
74
-
75
- ### 4. 生成 spec 文件
76
-
77
- 严格按步骤 1 的 stack 生成,禁止超出范围:
78
-
79
- | stack | 生成目录 | 禁止生成 |
80
- |-------|---------|---------|
81
- | `frontend` | `specs/frontend/` + `specs/shared/` | `specs/backend/` |
82
- | `backend` | `specs/backend/` + `specs/shared/` | `specs/frontend/` |
83
- | `fullstack` / `generic` | `specs/frontend/` + `specs/backend/` + `specs/shared/` | — |
84
-
85
- shared 模板必须存在:
86
- - `.code-flow/specs/shared/_map.md`
87
- - `.code-flow/specs/shared/prd-template.md`
88
- - `.code-flow/specs/shared/design/design-lite.md`
89
- - `.code-flow/specs/shared/design/design-full.md`
90
- - `.code-flow/specs/shared/design/design-frontend.md`
91
-
92
- 约束规范格式:
93
-
94
- ```markdown
95
- # [规范名称]
96
-
97
- ## Rules
98
- - 规则1
99
-
100
- ## Patterns
101
- - 推荐模式
102
-
103
- ## Anti-Patterns
104
- - 禁止模式
105
- ```
106
-
107
- 导航地图(`_map.md`)格式:
108
-
109
- ```markdown
110
- # [Domain] Retrieval Map
111
-
112
- > AI 导航地图:帮助快速定位代码结构和关键模块。
113
-
114
- ## Purpose
115
- [项目角色描述]
116
-
117
- ## Architecture
118
- [技术栈和架构模式]
119
-
120
- ## Key Files
121
- | File | Purpose |
122
- |------|---------|
123
-
124
- ## Module Map
125
- [目录树形图]
126
-
127
- ## Data Flow
128
- [数据流向]
129
-
130
- ## Navigation Guide
131
- [做 X 去哪里的快速指引]
132
- ```
133
-
134
- 前端域文件:
135
- - `.code-flow/specs/frontend/_map.md`
136
- - `.code-flow/specs/frontend/directory-structure.md`
137
- - `.code-flow/specs/frontend/quality-standards.md`
138
- - `.code-flow/specs/frontend/component-specs.md`
139
-
140
- 后端域文件:
141
- - `.code-flow/specs/backend/_map.md`
142
- - `.code-flow/specs/backend/directory-structure.md`
143
- - `.code-flow/specs/backend/logging.md`
144
- - `.code-flow/specs/backend/database.md`
145
- - `.code-flow/specs/backend/platform-rules.md`
146
- - `.code-flow/specs/backend/code-quality-performance.md`
147
-
148
- 已存在的 spec 文件不覆盖;只补缺失文件。填充已有空模板时要先展示 diff。
149
-
150
- ### 5. 校准 AGENTS.md
151
-
152
- AGENTS.md 的完整内容由适配器模板统一定义,`code-flow init` 已部署到项目根;cf-init 不再内嵌副本,避免双份维护导致不一致。
153
-
154
- - 读取现有 AGENTS.md,根据检测到的技术栈填充 `## Team Identity` 占位符(team / project / language)。
155
- - 若用户已自定义,只补充缺失的 `##` 段落,不覆盖已有内容;写入前展示 diff 供确认。
156
- - 若 AGENTS.md 缺失,提示用户先运行 `code-flow init --platform=opencode`,不要手工拼装完整模板。
157
-
158
- ### 6. 生成 OpenCode 插件配置
159
-
160
- OpenCode v2 会自动加载 `.opencode/plugins/` 下的插件目录,无需在 `opencode.json` 中声明。
161
- 检查 `opencode.json` 是否存在。如果不存在,创建:
162
-
163
- ```json
164
- {
165
- "$schema": "https://opencode.ai/config.json"
166
- }
167
- ```
168
-
169
- 如果 `opencode.json` 已存在,只做 v1→v2 迁移,保留用户已有配置:
170
- - 删除遗留的顶层 `plugin` 键(v1 写法,如 `".opencode/plugins/code-flow"`);其中非本地的用户条目搬入 `plugins`。
171
- - 不要向 `plugins` 写入 `.opencode/plugins/code-flow`(自动发现已覆盖,显式声明会导致重复加载或包解析告警)。
172
-
173
- 确保 `.opencode/plugins/code-flow/` 已存在且为 v2 形态(默认导出 `{ id: "code-flow", setup }`,不依赖 `@opencode/plugin` 包),
174
- 注册 `session.prompt` / `tool.execute.before` / `tool.execute.after` / `session.context` hooks,并通过 `event.subscribe` 订阅 `session.idle` 和 `session.deleted`。
175
- 插件直接调用原生 RPC 入口 `cf_opencode_event.py`,使用 OpenCode 的 sessionID、input.path 和 input.patchText,经 context hook 注入 specs。
176
-
177
- ### 7. 安装 pyyaml
178
-
179
- 先探测依赖,不要直接安装:
180
-
181
- ```bash
182
- python3 -c "import yaml"
183
- ```
184
-
185
- 如果探测失败,再按顺序尝试:
186
-
187
- ```bash
188
- python3 -m pip install --user pyyaml
189
- python3 -m pip install pyyaml
190
- python3 -m pip install --user --break-system-packages pyyaml
191
- ```
192
-
193
- 全部失败时只输出 warning 和手动安装建议,不阻塞 cf-init 主流程。
194
-
195
- ### 8. 自动扫描项目规范(Auto-learn)
196
-
197
- 如果传入 `--skip-learn`,跳过此步骤。否则自动执行扫描,但必须遵守“证据优先”:只写入能从配置、代码、CI、测试或目录结构中找到依据的规范;不确定的内容写入 TODO 或留空,禁止编造项目规范。
198
-
199
- #### 8.1 扫描输入
200
-
201
- 读取以下配置文件(存在才使用):
202
-
203
- **前端配置**:
204
- - `.eslintrc*` / `eslint.config.*` — lint 规则
205
- - `tsconfig.json` — strict 模式、path alias、target
206
- - `.prettierrc*` / `prettier.config.*` — 格式化规则
207
- - `tailwind.config.*` — 自定义 theme
208
- - `next.config.*` / `nuxt.config.*` / `vite.config.*` — 框架约束
209
- - `jest.config.*` / `vitest.config.*` — 测试配置
210
-
211
- **后端配置**:
212
- - `pyproject.toml` — ruff/mypy/pytest 配置、Python 版本
213
- - `.golangci.yml` — Go lint 规则
214
- - `Makefile` — 构建和测试命令
215
- - `Dockerfile` / `docker-compose.yml` — 运行时约束
216
-
217
- **通用配置**:
218
- - `.github/workflows/*.yml` / `.gitlab-ci.yml` — CI 检查步骤
219
- - `.editorconfig` — 编辑器配置
220
- - `package.json` scripts — 常用命令
221
- - `README*` — 项目用途和运行方式
222
-
223
- 扫描代码结构和模式:
224
- - 目录结构、入口文件、路由、handler/service/model 调用链 → 写入 `_map.md`
225
- - 错误处理、日志、测试、导入、命名模式 → 写入对应约束 specs
226
- - 纯格式化规则(formatter 自动处理)默认不写入 Rules,除非项目明确要求人工遵守
227
-
228
- #### 8.2 写入策略
229
-
230
- 先展示扫描摘要和拟写入内容,等待用户确认。用户确认 `all` 后再写入;用户输入 `skip` 时保留模板不填充。
231
-
232
- 写入规则:
233
- - `_map.md`:Purpose、Architecture、Key Files、Module Map、Data Flow、Navigation Guide 必须来自实际文件或配置
234
- - `Rules`:只放强制约束,如 strict mode、CI 必跑命令、禁止模式
235
- - `Patterns`:只放代码中重复出现的成熟模式,并标注来源
236
- - `Anti-Patterns`:只放配置或代码审查中明确禁止的做法
237
- - 每条自动提取内容建议带来源,如 `[tsconfig.json] strict=true`、`[CI] npm test`
238
- - 去重:不要重复模板已有规则;不要把同一规则写入多个 spec,除非它确实跨域
239
-
240
- 展示格式:
241
-
242
- ```text
243
- 项目规范扫描完成:
244
-
245
- 导航地图 (Retrieval Map):
246
- frontend/_map.md:
247
- Purpose: ...
248
- Architecture: ...
249
- Key Files: ...
250
-
251
- 编码约束 (从配置和代码中提取):
252
- frontend/quality-standards.md:
253
- 1. [tsconfig.json] strict 模式已启用
254
- backend/code-quality-performance.md:
255
- 2. [pyproject.toml] pytest 配置存在
256
-
257
- 确认写入?(all 全部写入 / 输入编号选择 / skip 跳过):
258
- ```
259
-
260
- ### 9. 输出摘要
261
-
262
- ```text
263
- cf-init 完成
264
-
265
- 技术栈: <检测结果>
266
- 文件结构:
267
- Created: ...
268
- Updated: ...
269
- Skipped: ...
270
- Token 估算: ...
271
-
272
- 下一步:
273
- - 审阅并补充 spec 文件中的 TODO
274
- - 运行 cf-learn 补充更多规范
275
- - 运行 cf-learn --map 更新导航地图
276
- - 开始开发: cf-task-plan <设计文档>
277
- ```
278
-
279
- ## v0.5 质量闭环部署说明
280
-
281
- init/upgrade 后新增:PostToolUse / Stop hook 注册(合规反馈与收尾守门)、`.code-flow/.gitignore`(运行时数据不入库)。运行时数据 `.session-log.jsonl` / `.check-state.json` 首次使用自动创建,仅存本地。规范写作建议:frontmatter 加 `description`(Spec Catalog 行)与 `checks`(机检标注),规则优先用 ✅/❌ Examples 段表达(cf-learn 候选自动生成草稿)。