ai-delivery-workflow 0.2.2

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/LICENSE +21 -0
  2. package/README.md +112 -0
  3. package/bin/ai-delivery.mjs +138 -0
  4. package/bin/validate-skills.mjs +12 -0
  5. package/docs/DUAL-REPOSITORY-WORKSPACE.zh-CN.md +125 -0
  6. package/docs/EVOLUTION-MAINTENANCE.zh-CN.md +75 -0
  7. package/docs/EVOLUTION-USER-GUIDE.zh-CN.md +160 -0
  8. package/docs/FILE-REFERENCE.zh-CN.md +503 -0
  9. package/docs/PROJECT-MANUAL.zh-CN.md +931 -0
  10. package/docs/STATE-CLI-MAINTENANCE.zh-CN.md +135 -0
  11. package/docs/STATE-CLI-USER-GUIDE.zh-CN.md +186 -0
  12. package/docs/VIEWER-MAINTENANCE.zh-CN.md +373 -0
  13. package/docs/VIEWER-USER-GUIDE.zh-CN.md +235 -0
  14. package/lib/delivery-state.mjs +1220 -0
  15. package/lib/evolution.mjs +971 -0
  16. package/lib/project-bootstrap.mjs +927 -0
  17. package/lib/project-installer.mjs +1184 -0
  18. package/lib/skill-validator.mjs +154 -0
  19. package/lib/toml-hooks.mjs +97 -0
  20. package/lib/workspace.mjs +302 -0
  21. package/lib/yaml-runtime.mjs +18 -0
  22. package/package.json +39 -0
  23. package/skills/ai-delivery-assemble-release/SKILL.md +27 -0
  24. package/skills/ai-delivery-assemble-release/agents/openai.yaml +4 -0
  25. package/skills/ai-delivery-assemble-release/assets/release-candidate-manifest.yaml +22 -0
  26. package/skills/ai-delivery-assemble-release/assets/release-git-plan.yaml +9 -0
  27. package/skills/ai-delivery-assemble-release/assets/release-material-index.csv +2 -0
  28. package/skills/ai-delivery-assemble-release/assets/version-inclusion.csv +2 -0
  29. package/skills/ai-delivery-assemble-release/references/release-assembly-contract.md +7 -0
  30. package/skills/ai-delivery-assemble-release/scripts/plan-release.mjs +298 -0
  31. package/skills/ai-delivery-bootstrap/SKILL.md +59 -0
  32. package/skills/ai-delivery-bootstrap/agents/openai.yaml +4 -0
  33. package/skills/ai-delivery-bootstrap/references/bootstrap-contract.md +70 -0
  34. package/skills/ai-delivery-checkpoint-task/SKILL.md +63 -0
  35. package/skills/ai-delivery-checkpoint-task/agents/openai.yaml +4 -0
  36. package/skills/ai-delivery-checkpoint-task/assets/codex-hook-config.toml +92 -0
  37. package/skills/ai-delivery-checkpoint-task/assets/runtime-template/resume.md +15 -0
  38. package/skills/ai-delivery-checkpoint-task/assets/runtime-template/task.json +30 -0
  39. package/skills/ai-delivery-checkpoint-task/assets/runtime-template/version-archive.json +10 -0
  40. package/skills/ai-delivery-checkpoint-task/references/checkpoint-contract.md +95 -0
  41. package/skills/ai-delivery-checkpoint-task/references/checkpoint-recovery.zh-CN.md +111 -0
  42. package/skills/ai-delivery-checkpoint-task/scripts/hook-event.mjs +131 -0
  43. package/skills/ai-delivery-checkpoint-task/scripts/task-state.mjs +1073 -0
  44. package/skills/ai-delivery-close-version/SKILL.md +33 -0
  45. package/skills/ai-delivery-close-version/agents/openai.yaml +4 -0
  46. package/skills/ai-delivery-close-version/assets/line-advance-record.yaml +12 -0
  47. package/skills/ai-delivery-close-version/assets/version-lineage.yaml +12 -0
  48. package/skills/ai-delivery-close-version/assets/version-manifest.yaml +20 -0
  49. package/skills/ai-delivery-close-version/references/version-closeout-contract.md +20 -0
  50. package/skills/ai-delivery-define-product/SKILL.md +76 -0
  51. package/skills/ai-delivery-define-product/agents/openai.yaml +4 -0
  52. package/skills/ai-delivery-define-product/assets/product-template/acceptance-criteria.csv +1 -0
  53. package/skills/ai-delivery-define-product/assets/product-template/discovery-baseline.md +19 -0
  54. package/skills/ai-delivery-define-product/assets/product-template/feature-detail.md +19 -0
  55. package/skills/ai-delivery-define-product/assets/product-template/feature-terminals.csv +1 -0
  56. package/skills/ai-delivery-define-product/assets/product-template/features.csv +1 -0
  57. package/skills/ai-delivery-define-product/assets/product-template/product-baseline.yaml +8 -0
  58. package/skills/ai-delivery-define-product/assets/product-template/product-manual.md +24 -0
  59. package/skills/ai-delivery-define-product/assets/product-template/terminals.csv +1 -0
  60. package/skills/ai-delivery-define-product/assets/product-template/user-stories.csv +1 -0
  61. package/skills/ai-delivery-define-product/references/product-contract.md +57 -0
  62. package/skills/ai-delivery-deploy-production/SKILL.md +45 -0
  63. package/skills/ai-delivery-deploy-production/agents/openai.yaml +4 -0
  64. package/skills/ai-delivery-deploy-production/references/deployment-contract.md +7 -0
  65. package/skills/ai-delivery-design-architecture/SKILL.md +67 -0
  66. package/skills/ai-delivery-design-architecture/agents/openai.yaml +4 -0
  67. package/skills/ai-delivery-design-architecture/assets/architecture-template/architecture-baseline.md +25 -0
  68. package/skills/ai-delivery-design-architecture/assets/architecture-template/architecture-gate.yaml +15 -0
  69. package/skills/ai-delivery-design-architecture/assets/architecture-template/prototype-architecture-validation.yaml +58 -0
  70. package/skills/ai-delivery-design-architecture/references/architecture-contract.md +32 -0
  71. package/skills/ai-delivery-design-experience/SKILL.md +71 -0
  72. package/skills/ai-delivery-design-experience/agents/openai.yaml +4 -0
  73. package/skills/ai-delivery-design-experience/assets/experience-template/canvas-catalog.csv +1 -0
  74. package/skills/ai-delivery-design-experience/assets/experience-template/canvas-pages.csv +1 -0
  75. package/skills/ai-delivery-design-experience/assets/experience-template/component-state-matrix.csv +1 -0
  76. package/skills/ai-delivery-design-experience/assets/experience-template/design-tokens.json +19 -0
  77. package/skills/ai-delivery-design-experience/assets/experience-template/experience-baseline.yaml +17 -0
  78. package/skills/ai-delivery-design-experience/assets/experience-template/experience-change-domains.csv +1 -0
  79. package/skills/ai-delivery-design-experience/assets/experience-template/experience-change-set.csv +1 -0
  80. package/skills/ai-delivery-design-experience/assets/experience-template/feature-screen-coverage.csv +1 -0
  81. package/skills/ai-delivery-design-experience/assets/experience-template/formal-ui-confirmation.yaml +33 -0
  82. package/skills/ai-delivery-design-experience/assets/experience-template/interaction-contract.csv +1 -0
  83. package/skills/ai-delivery-design-experience/assets/experience-template/low-fidelity-confirmation.yaml +32 -0
  84. package/skills/ai-delivery-design-experience/assets/experience-template/page-catalog.csv +1 -0
  85. package/skills/ai-delivery-design-experience/assets/experience-template/page-component-map.csv +1 -0
  86. package/skills/ai-delivery-design-experience/assets/experience-template/product-prototype-reconciliation.yaml +28 -0
  87. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-adjustment-log.csv +1 -0
  88. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-confirmation.yaml +99 -0
  89. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-file-terminals.csv +1 -0
  90. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-files.csv +1 -0
  91. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-impact-assessment.yaml +25 -0
  92. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-manifest.yaml +74 -0
  93. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-product-coverage.csv +1 -0
  94. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-review-comments.csv +1 -0
  95. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-review-decision.yaml +29 -0
  96. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-review-sessions.csv +1 -0
  97. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-set.yaml +22 -0
  98. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-tool-candidates.csv +1 -0
  99. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-tool-selection.yaml +22 -0
  100. package/skills/ai-delivery-design-experience/assets/experience-template/prototype-traceability.csv +1 -0
  101. package/skills/ai-delivery-design-experience/assets/experience-template/requirement-change-set.csv +1 -0
  102. package/skills/ai-delivery-design-experience/assets/experience-template/screen-states.csv +1 -0
  103. package/skills/ai-delivery-design-experience/assets/experience-template/ui-framework-candidates.csv +1 -0
  104. package/skills/ai-delivery-design-experience/assets/experience-template/ui-framework-selection.yaml +18 -0
  105. package/skills/ai-delivery-design-experience/assets/experience-template/ui-handoff.yaml +44 -0
  106. package/skills/ai-delivery-design-experience/assets/experience-template/visual-direction.yaml +16 -0
  107. package/skills/ai-delivery-design-experience/assets/experience-template/visual-system-confirmation.yaml +31 -0
  108. package/skills/ai-delivery-design-experience/references/experience-contract.md +82 -0
  109. package/skills/ai-delivery-design-experience/references/prototype-management-contract.md +68 -0
  110. package/skills/ai-delivery-design-tests/SKILL.md +56 -0
  111. package/skills/ai-delivery-design-tests/agents/openai.yaml +4 -0
  112. package/skills/ai-delivery-design-tests/assets/test-design-template/iteration-test-contract.md +19 -0
  113. package/skills/ai-delivery-design-tests/assets/test-design-template/prototype-test-scope.csv +1 -0
  114. package/skills/ai-delivery-design-tests/assets/test-design-template/prototype-test-validation.yaml +73 -0
  115. package/skills/ai-delivery-design-tests/references/test-design-contract.md +31 -0
  116. package/skills/ai-delivery-develop-iteration/SKILL.md +66 -0
  117. package/skills/ai-delivery-develop-iteration/agents/openai.yaml +4 -0
  118. package/skills/ai-delivery-develop-iteration/assets/development-template/task-experience-change-traceability.csv +1 -0
  119. package/skills/ai-delivery-develop-iteration/assets/development-template/task-prototype-traceability.csv +1 -0
  120. package/skills/ai-delivery-develop-iteration/references/development-contract.md +39 -0
  121. package/skills/ai-delivery-evolve-workflow/SKILL.md +57 -0
  122. package/skills/ai-delivery-evolve-workflow/agents/openai.yaml +4 -0
  123. package/skills/ai-delivery-evolve-workflow/references/evolution-contract.md +42 -0
  124. package/skills/ai-delivery-execute-test/SKILL.md +34 -0
  125. package/skills/ai-delivery-execute-test/agents/openai.yaml +4 -0
  126. package/skills/ai-delivery-execute-test/references/test-execution-contract.md +7 -0
  127. package/skills/ai-delivery-execute-work-package/SKILL.md +53 -0
  128. package/skills/ai-delivery-execute-work-package/agents/openai.yaml +4 -0
  129. package/skills/ai-delivery-execute-work-package/references/work-package-contract.md +20 -0
  130. package/skills/ai-delivery-manage-git/SKILL.md +60 -0
  131. package/skills/ai-delivery-manage-git/agents/openai.yaml +4 -0
  132. package/skills/ai-delivery-manage-git/references/git-policy.md +42 -0
  133. package/skills/ai-delivery-manage-standards/SKILL.md +44 -0
  134. package/skills/ai-delivery-manage-standards/agents/openai.yaml +4 -0
  135. package/skills/ai-delivery-manage-standards/assets/standards-template/standard.md +25 -0
  136. package/skills/ai-delivery-manage-standards/references/standards-contract.md +20 -0
  137. package/skills/ai-delivery-orchestrate/SKILL.md +105 -0
  138. package/skills/ai-delivery-orchestrate/agents/openai.yaml +4 -0
  139. package/skills/ai-delivery-orchestrate/assets/project-template/.codex/config.toml +92 -0
  140. package/skills/ai-delivery-orchestrate/assets/project-template/.gitattributes +6 -0
  141. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/delivery/artifact-registry.yaml +3 -0
  142. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/delivery/project.yaml +6 -0
  143. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/delivery/standards-baseline.yaml +8 -0
  144. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/delivery/workflow-state.yaml +34 -0
  145. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/evolution/decisions/.gitkeep +0 -0
  146. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/evolution/experiments/.gitkeep +0 -0
  147. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/evolution/feedback/.gitkeep +0 -0
  148. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/evolution/index.yaml +7 -0
  149. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/evolution/promotion/.gitkeep +0 -0
  150. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/evolution/proposals/.gitkeep +0 -0
  151. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/extensions/.gitkeep +0 -0
  152. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/standards/STD-ARTIFACT-PATH-001.md +47 -0
  153. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/standards/STD-DOC-LANG-001.md +62 -0
  154. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/standards/STD-TEST-LOCATION-001.md +23 -0
  155. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/standards/index.yaml +36 -0
  156. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/bootstrap/bootstrap.mjs +33 -0
  157. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/evolution/evolve.mjs +15 -0
  158. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/hooks/hook-event.mjs +131 -0
  159. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/state/state.mjs +21 -0
  160. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/viewer/public/app.js +546 -0
  161. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/viewer/public/index.html +199 -0
  162. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/viewer/public/styles.css +529 -0
  163. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/viewer/server.mjs +780 -0
  164. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/viewer/start.cmd +4 -0
  165. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/viewer/start.ps1 +2 -0
  166. package/skills/ai-delivery-orchestrate/assets/project-template/.workflow/tools/viewer/start.sh +4 -0
  167. package/skills/ai-delivery-orchestrate/assets/project-template/AGENTS.md +44 -0
  168. package/skills/ai-delivery-orchestrate/references/formal-state-contract.md +64 -0
  169. package/skills/ai-delivery-orchestrate/references/workflow-model.md +29 -0
  170. package/skills/ai-delivery-orchestrate-release/SKILL.md +33 -0
  171. package/skills/ai-delivery-orchestrate-release/agents/openai.yaml +4 -0
  172. package/skills/ai-delivery-orchestrate-release/assets/release-request.yaml +9 -0
  173. package/skills/ai-delivery-orchestrate-release/assets/version-selection.yaml +16 -0
  174. package/skills/ai-delivery-orchestrate-release/references/release-workflow-contract.md +11 -0
  175. package/skills/ai-delivery-plan-iteration/SKILL.md +57 -0
  176. package/skills/ai-delivery-plan-iteration/agents/openai.yaml +4 -0
  177. package/skills/ai-delivery-plan-iteration/assets/planning-template/backlog.csv +1 -0
  178. package/skills/ai-delivery-plan-iteration/assets/planning-template/slice-dependencies.csv +1 -0
  179. package/skills/ai-delivery-plan-iteration/assets/planning-template/slice-experience-change-traceability.csv +1 -0
  180. package/skills/ai-delivery-plan-iteration/assets/planning-template/slice-prototype-traceability.csv +1 -0
  181. package/skills/ai-delivery-plan-iteration/assets/planning-template/slice-sources.csv +1 -0
  182. package/skills/ai-delivery-plan-iteration/assets/planning-template/vertical-slices.csv +1 -0
  183. package/skills/ai-delivery-plan-iteration/references/planning-contract.md +40 -0
  184. package/skills/ai-delivery-prepare-platform/SKILL.md +49 -0
  185. package/skills/ai-delivery-prepare-platform/agents/openai.yaml +4 -0
  186. package/skills/ai-delivery-prepare-platform/assets/platform-template/environment-ledger.csv +1 -0
  187. package/skills/ai-delivery-prepare-platform/references/platform-contract.md +18 -0
  188. package/skills/ai-delivery-prepare-release/SKILL.md +47 -0
  189. package/skills/ai-delivery-prepare-release/agents/openai.yaml +4 -0
  190. package/skills/ai-delivery-prepare-release/assets/release-template/delivery-items.csv +1 -0
  191. package/skills/ai-delivery-prepare-release/assets/release-template/release-manifest.yaml +18 -0
  192. package/skills/ai-delivery-prepare-release/references/release-contract.md +21 -0
  193. package/skills/ai-delivery-review-change/SKILL.md +40 -0
  194. package/skills/ai-delivery-review-change/agents/openai.yaml +4 -0
  195. package/skills/ai-delivery-review-change/references/review-contract.md +20 -0
  196. package/skills/ai-delivery-triage-failure/SKILL.md +45 -0
  197. package/skills/ai-delivery-triage-failure/agents/openai.yaml +4 -0
  198. package/skills/ai-delivery-triage-failure/references/failure-routing-contract.md +13 -0
  199. package/skills/ai-delivery-validate-artifacts/SKILL.md +37 -0
  200. package/skills/ai-delivery-validate-artifacts/agents/openai.yaml +4 -0
  201. package/skills/ai-delivery-validate-artifacts/references/artifact-contract.md +44 -0
  202. package/skills/ai-delivery-verify-candidate/SKILL.md +56 -0
  203. package/skills/ai-delivery-verify-candidate/agents/openai.yaml +4 -0
  204. package/skills/ai-delivery-verify-candidate/assets/verification-template/defect-artifacts.csv +1 -0
  205. package/skills/ai-delivery-verify-candidate/assets/verification-template/defects.csv +1 -0
  206. package/skills/ai-delivery-verify-candidate/assets/verification-template/test-work-packages.csv +1 -0
  207. package/skills/ai-delivery-verify-candidate/references/candidate-verification-contract.md +23 -0
  208. package/skills/ai-delivery-verify-production/SKILL.md +50 -0
  209. package/skills/ai-delivery-verify-production/agents/openai.yaml +4 -0
  210. package/skills/ai-delivery-verify-production/assets/production-verification-template/production-verification.md +15 -0
  211. package/skills/ai-delivery-verify-production/references/production-verification-contract.md +14 -0
@@ -0,0 +1,30 @@
1
+ {
2
+ "task_id": "TASK-0001",
3
+ "iteration_id": "ITER-0001",
4
+ "node": "development",
5
+ "skill": "ai-delivery-develop-iteration",
6
+ "status": "queued",
7
+ "sequence": 1,
8
+ "depends_on": [],
9
+ "attempt": 1,
10
+ "goal": "",
11
+ "scope": [],
12
+ "input_artifacts": [],
13
+ "standards": [],
14
+ "branch": null,
15
+ "worktree": null,
16
+ "state_root": null,
17
+ "planned_outputs": [],
18
+ "actual_outputs": [],
19
+ "completed_steps": [],
20
+ "blockers": [],
21
+ "next_action": "",
22
+ "next_action_owner": "agent",
23
+ "evidence": [],
24
+ "created_at": null,
25
+ "started_at": null,
26
+ "updated_at": null,
27
+ "finished_at": null,
28
+ "archived_at": null,
29
+ "archive_path": null
30
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "iteration_id": "ITER-0001",
3
+ "version_status": "released",
4
+ "release_id": "REL-0001",
5
+ "evidence": [],
6
+ "task_count": 0,
7
+ "archived_at": null,
8
+ "archive_path": null,
9
+ "tasks": []
10
+ }
@@ -0,0 +1,95 @@
1
+ # Task Checkpoint Contract
2
+
3
+ ## Runtime Layout
4
+
5
+ Portable, Git-tracked state:
6
+
7
+ ```text
8
+ .workflow/control/
9
+ tasks/<task-id>.yaml
10
+ checkpoints/<task-id>/<checkpoint-id>.yaml
11
+ archives/versions/<version-id>/
12
+ version-manifest.json
13
+ tasks/<task-id>/task.json
14
+ tasks/<task-id>/checkpoints/...
15
+ ```
16
+
17
+ Local ignored state:
18
+
19
+ ```text
20
+ .workflow/delivery/runtime/
21
+ tasks/<task-id>.json
22
+ checkpoints/<task-id>/<timestamp>.json
23
+ events/<task-or-session-id>.jsonl
24
+ heartbeats/<task-or-session-id>.json
25
+ resumes/<task-id>.md
26
+ archive/
27
+ index/versions/<iteration-id>.json
28
+ index/tasks/<task-id>.json
29
+ versions/<iteration-id>/version-manifest.json
30
+ versions/<iteration-id>/tasks/<task-id>/...
31
+ ```
32
+
33
+ Keep `.workflow/delivery/runtime/` local and ignored. Persist durable stage outputs and final evidence in `.workflow/iterations/<iteration-id>/<node-id>/`.
34
+
35
+ `task-state.mjs` is the only runtime-state writer. Do not directly edit task JSON, checkpoint JSON, active-task markers, recovery output, or archive indexes. Formal workflow and artifact state belong to `.workflow/tools/state/state.mjs`; do not edit its YAML or JSONL streams directly.
36
+
37
+ When the installed Evolution CLI exists, `init`, `activate`, `checkpoint`, `finish`, and `archive-version` emit idempotent schema 1 `task.before`, `task.after`, and `task.failed` events. An approved blocking `task.before` result stops the task command before mutation. Hook dispatch failures otherwise fail open as warnings and never replace checkpoint state as the completion authority.
38
+
39
+ ## Commands
40
+
41
+ Resolve `scripts/task-state.mjs` relative to this skill directory when invoking the bundled script.
42
+
43
+ ```text
44
+ node scripts/task-state.mjs init --task-id TASK-0001 --iteration-id ITER-0001 --node development --skill ai-delivery-develop-iteration --goal "Implement slice" --next-action "Derive work packages" --next-action-owner agent
45
+ node scripts/task-state.mjs init --task-id TASK-0002 --iteration-id ITER-0001 --node test --skill ai-delivery-verify-candidate --goal "Verify candidate" --status queued --sequence 2 --depends-on TASK-0001 --next-action "Run candidate verification"
46
+ node scripts/task-state.mjs recover --iteration-id ITER-0001
47
+ node scripts/task-state.mjs activate --task-id TASK-0002
48
+ node scripts/task-state.mjs checkpoint --task-id TASK-0001 --status checkpointed --completed-step "Public contract validated" --next-action "Create worktrees"
49
+ node scripts/task-state.mjs finish --task-id TASK-0001 --status completed --next-action "Run candidate verification"
50
+ node scripts/task-state.mjs finish --task-id TASK-0001 --status interrupted --next-action "Which user group is affected first?" --next-action-owner user
51
+ node scripts/task-state.mjs recover --mark-interrupted --stale-minutes 15
52
+ node scripts/task-state.mjs recover --include-closed
53
+ node scripts/task-state.mjs archive-version --iteration-id ITER-0001 --version-status released --release-id REL-0001 --evidence "production-verification@1"
54
+ node scripts/task-state.mjs archive-version --iteration-id VER-0002 --version-status release-ready --candidate-id CAND-0002 --evidence "candidate-verification@2"
55
+ node scripts/task-state.mjs archive-version --iteration-id VER-0003 --version-status release-ready --candidate-id CAND-0003 --evidence "candidate-verification@3" --portable-only
56
+ node scripts/task-state.mjs publish --task-id TASK-0001
57
+ node scripts/task-state.mjs publish --task-id TASK-0001 --push
58
+ ```
59
+
60
+ Every state transition writes both the local runtime snapshot and the portable task shard/checkpoint. `publish` refuses unrelated dirty paths, commits only the selected task scope, and does not push unless `--push` is explicit. When local runtime is missing, `recover` reconstructs an `agent`-owned task from shared shards; `user` and `external` wait states remain read-only until an explicit `activate` transfer. A revision or semantic-checksum mismatch is a hard conflict, not a last-writer-wins update.
61
+
62
+ For an installed dual-repository project, `task-state.mjs` resolves `code_branch` and `code_commit` from the authoritative `.workflow/config/workspace.yaml` and its configured nested code Git root. The install manifest and task worktree are not workspace identity fallbacks. The task's workflow worktree or workflow branch must never be persisted as code identity. If the workspace configuration is missing, its code path is not a direct child, or the configured code root is not an independent Git repository, the mutation fails instead of recording a fallback identity.
63
+
64
+ `blockers` represents current unresolved blockers. A `blocked` update replaces that list; any transition to another status clears it. Historical blocker text remains available in prior checkpoints and events.
65
+
66
+ `next_action_owner` is required in persisted state and has exactly three values: `agent`, `user`, or `external`; only a truly absent field in a legacy snapshot defaults to `agent`, while explicit null, empty, boolean, numeric, or unknown values are invalid. `user` and `external` are zero-mutation wait states. `recover` may report shared wait state but must not hydrate local task or resume files for it. After the required input arrives, `activate` requires both `--next-action-owner agent` and a new idempotent `--next-action`; it may atomically hydrate a missing local runtime snapshot from the matching shared shard and transfer ownership in the same transition. Same-revision local and shared content must have identical semantic checksums. Evidence arrays are ordered sets: replaying an already recorded `--evidence` value does not append a duplicate.
67
+
68
+ Pass `--state-root` when worktrees must write to one shared primary state directory. Pass `--worktree` during init so the script writes a local `.workflow/delivery/runtime/active-task.json` marker pointing to that state root. Later `checkpoint`, `finish`, and `recover` commands automatically use the marker's shared state root.
69
+
70
+ Use `finish` only with `completed`, `blocked`, `interrupted`, `failed`, or `abandoned`. Use `checkpoint` for all other statuses.
71
+
72
+ Register all known iteration tasks as `queued` before execution. `queued` registration does not write `.workflow/delivery/runtime/active-task.json`, so several future tasks may share a worktree safely. `activate` verifies that every `depends_on` task exists and is `completed`, changes the selected task to `running` or `preparing`, writes a new checkpoint, and creates the active task marker for Hook correlation.
73
+
74
+ `finish` closes an individual task but does not archive it. Default recovery omits closed tasks so they do not consume resume context. Archive the entire planned version after version closeout marks it `release-ready`, after historical production verification marks it `released`, or when explicitly `abandoned`. A release-ready archive requires the immutable candidate ID and verification evidence; a released archive requires release ID and production evidence. Every task in that version must be closed. Archival first writes the portable version package, then removes that version from active shared task/checkpoint collections; `recover` never scans `.workflow/control/archives/`.
75
+
76
+ ## Hook Events
77
+
78
+ The local Codex 0.144.2 CLI reports stable Hook support for `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PermissionRequest`, `PostToolUse`, `PreCompact`, `PostCompact`, `SubagentStart`, `SubagentStop`, and `Stop`. The project template logs all of them synchronously with a short timeout.
79
+
80
+ Hooks receive lifecycle JSON on stdin. Redact secrets, cap payload size, append JSONL, and update heartbeat atomically. A Hook may enforce mechanical policy, but it must not infer product completion or mutate approved artifacts.
81
+
82
+ ## Recovery Rules
83
+
84
+ - Reconcile recorded branch, worktree, dirty files, heartbeat, and next action.
85
+ - Stop without mutation when the recommended task's `next_action_owner` is `user` or `external`; only report the recorded question or wait condition.
86
+ - Keep closed tasks in the current version until version archival, but exclude them from normal recovery output.
87
+ - Determine iteration progress from all task snapshots, including the closed snapshots hidden from the normal task list.
88
+ - Prefer an existing active or interrupted task during recovery. If none exists, recommend the lowest-sequence queued task whose dependencies are all `completed`.
89
+ - Never activate a task with a missing, failed, abandoned, blocked, or otherwise incomplete dependency.
90
+ - Use one portable version archive under `.workflow/control/archives/versions/`; runtime archive copies are disposable and non-authoritative. Pass `--portable-only` when no local detailed copy should be created.
91
+ - Treat a stale `running` task as a recovery candidate, not automatically failed.
92
+ - Resume only from a documented idempotent next action.
93
+ - Re-read remote CI, registries, environments, and production before relying on cached status.
94
+ - Never replay deployment, migration, payment, notification, or destructive steps without readback and authority.
95
+ - Do not store full transcripts, chain-of-thought, credentials, secret values, cookies, or authorization headers.
@@ -0,0 +1,111 @@
1
+ # Checkpoint 中断恢复机制
2
+
3
+ ## 目标
4
+
5
+ 一个迭代版本包含 10 个任务,前 5 个已经完成,会话在第 6 个开始前中断。下次启动时,AI 必须从持久化状态得出以下结论,而不是依赖聊天记录:
6
+
7
+ - 迭代共有 10 个任务;
8
+ - `TASK-01` 至 `TASK-05` 已完成;
9
+ - 还有 5 个任务未完成;
10
+ - `TASK-06` 的依赖已经满足;
11
+ - 下一项推荐任务是 `TASK-06`。
12
+
13
+ ## 前提
14
+
15
+ 迭代规划产生的切片任务,以及开发阶段即时拆分出的技术任务,仍由各自正式 CSV 产物维护。Checkpoint 运行时不会替代这些正式计划,而是保存其可恢复执行状态。
16
+
17
+ 在执行一个任务组的第一项任务前,必须先登记该组的全部任务:
18
+
19
+ ```text
20
+ node task-state.mjs init --task-id TASK-01 --iteration-id ITER-01 --node development --skill ai-delivery-develop-iteration --status queued --sequence 1 --goal "任务 1" --next-action "执行任务 1"
21
+ node task-state.mjs init --task-id TASK-02 --iteration-id ITER-01 --node development --skill ai-delivery-develop-iteration --status queued --sequence 2 --depends-on TASK-01 --goal "任务 2" --next-action "执行任务 2"
22
+ ...
23
+ node task-state.mjs init --task-id TASK-10 --iteration-id ITER-01 --node development --skill ai-delivery-develop-iteration --status queued --sequence 10 --depends-on TASK-09 --goal "任务 10" --next-action "执行任务 10"
24
+ ```
25
+
26
+ `queued` 任务只登记状态,不占用 `.workflow/delivery/runtime/active-task.json` 活动任务标记。因此,可以安全地预先登记同一工作区中的 10 个任务。
27
+
28
+ ## 正常执行
29
+
30
+ 每个任务按以下顺序执行:
31
+
32
+ 1. `recover --iteration-id ITER-01` 读取迭代状态并取得 `recommended_task_id`。
33
+ 2. `activate --task-id <recommended_task_id>` 校验依赖并把任务变成 `running`。
34
+ 3. 在有意义的里程碑执行 `checkpoint`,记录已完成步骤、实际输出、证据和幂等下一动作。
35
+ 4. 交还控制权或发生可控中断前执行 `finish`,状态使用 `completed`、`blocked`、`failed` 或 `interrupted`。
36
+ 5. 下一个任务重新从 `recover` 开始,不能从聊天上下文猜测。
37
+
38
+ 示例:
39
+
40
+ ```text
41
+ node task-state.mjs activate --task-id TASK-05
42
+ node task-state.mjs checkpoint --task-id TASK-05 --status checkpointed --completed-step "测试通过" --evidence "test-result.json" --next-action "校验交付物"
43
+ node task-state.mjs finish --task-id TASK-05 --status completed --actual-output "artifact-05.yaml" --next-action "恢复迭代并选择下一任务"
44
+ ```
45
+
46
+ ## 重启恢复
47
+
48
+ 新会话启动时执行:
49
+
50
+ ```text
51
+ node task-state.mjs recover --iteration-id ITER-01
52
+ ```
53
+
54
+ 返回结果包含两层信息:
55
+
56
+ - `tasks`:默认只包含未关闭任务,已完成任务不会占用恢复上下文;
57
+ - `iterations`:使用全部任务快照计算的迭代进度摘要。
58
+
59
+ 前 5 个任务完成后的关键结果如下:
60
+
61
+ ```json
62
+ {
63
+ "iteration_id": "ITER-01",
64
+ "total_tasks": 10,
65
+ "completed_tasks": 5,
66
+ "remaining_tasks": 5,
67
+ "ready_task_ids": ["TASK-06"],
68
+ "recommended_task_id": "TASK-06",
69
+ "recommended_status": "queued"
70
+ }
71
+ ```
72
+
73
+ 然后执行:
74
+
75
+ ```text
76
+ node task-state.mjs activate --task-id TASK-06
77
+ ```
78
+
79
+ `activate` 只有在 `TASK-06` 的所有 `depends_on` 任务都存在且状态为 `completed` 时才会成功。缺失、失败、放弃、阻塞或尚未完成的依赖都会阻止激活。
80
+
81
+ ## 恢复选择规则
82
+
83
+ `recover` 按以下顺序确定 `recommended_task_id`:
84
+
85
+ 1. 优先恢复 `preparing`、`running`、`checkpointed`、`pending-review`、`blocked` 或 `interrupted` 的已有任务;
86
+ 2. 没有活动任务时,从依赖全部完成的 `queued` 任务中选择;
87
+ 3. 按 `sequence` 从小到大排序,相同顺序再按 `task_id` 排序;
88
+ 4. 没有可执行任务时返回 `null`,并在 `waiting_tasks` 中列出缺失或未完成依赖。
89
+
90
+ 对于生产部署、数据库迁移、付款、通知或破坏性操作,即使任务被推荐,也必须先读取外部真实状态和授权,禁止自动重放。
91
+
92
+ ## 文件职责
93
+
94
+ | 文件 | 是否持久 | 作用 |
95
+ | --- | --- | --- |
96
+ | 正式迭代计划和技术任务 CSV | 是 | 任务范围、顺序、依赖和交付要求的业务事实来源。 |
97
+ | `.workflow/delivery/workflow-state.yaml` | 是 | 已验证流程节点、Gate 和版本状态。 |
98
+ | `.workflow/delivery/runtime/tasks/<task-id>.json` | 当前版本本地保留 | 权威任务快照,包含 `sequence`、`depends_on`、状态、输出、证据和下一动作。 |
99
+ | `.workflow/delivery/runtime/checkpoints/<task-id>/<时间戳>.json` | 当前版本本地保留 | 每次初始化、激活、里程碑、完成或中断时的不可变状态副本。 |
100
+ | `.workflow/delivery/runtime/resumes/<task-id>.md` | 当前版本本地保留 | 面向 AI 和人的紧凑恢复摘要。 |
101
+ | `.workflow/delivery/runtime/events/<task-id>.jsonl` | 当前版本本地保留 | 初始化、激活、checkpoint、完成和 Hook 的仅追加审计事件。 |
102
+ | `.workflow/delivery/runtime/heartbeats/<task-id>.json` | 当前版本本地保留 | Hook 更新的最近活动心跳,只辅助判断中断,不能证明完成。 |
103
+ | `.workflow/delivery/runtime/active-task.json` | 活动任务期间本地存在 | 将当前工作区和 Hook 关联到唯一活动任务;任务完成后删除。 |
104
+ | `.workflow/control/archives/versions/<iteration-id>/` | 可携带版本归档 | 保存版本 Manifest、关闭任务和共享 checkpoint;归档完成后从活动集合移除,普通恢复不扫描此目录。 |
105
+ | `.workflow/delivery/runtime/archive/versions/<iteration-id>/` | 可丢弃本地副本 | 可保存事件、心跳和恢复摘要等详细本地证据,不作为跨 clone 的权威归档。 |
106
+
107
+ `.workflow/delivery/runtime/` 应加入 Git 忽略,但在当前项目本地必须保留到版本归档完成。不得忽略整个 `.workflow/`。需要跨机器恢复时,应将该目录保存到受控、加密且访问受限的状态存储,不能只依赖本机磁盘。
108
+
109
+ ## 自动化验证
110
+
111
+ 发行仓库的 `verification/checkpoint-task-state.test.mjs` 包含一个 10 任务场景:预先登记 10 个顺序依赖任务,完成前 5 个,执行恢复并断言推荐 `TASK-QUEUE-06`,随后成功激活第 6 个任务。该测试同时验证未满足依赖时不得提前启动后续任务。
@@ -0,0 +1,131 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { spawnSync } from "node:child_process";
4
+
5
+ const SECRET_KEY = /^(authorization|cookie|set-cookie|password|passwd|secret|access[_-]?token|refresh[_-]?token|api[_-]?key|private[_-]?key)$/i;
6
+ const MAX_STRING = 8_192;
7
+ const MAX_EVENT = 64 * 1024;
8
+
9
+ function now() {
10
+ return new Date().toISOString();
11
+ }
12
+
13
+ function findUp(start, relative) {
14
+ let current = path.resolve(start);
15
+ while (true) {
16
+ const candidate = path.join(current, relative);
17
+ if (fs.existsSync(candidate)) return candidate;
18
+ const parent = path.dirname(current);
19
+ if (parent === current) return null;
20
+ current = parent;
21
+ }
22
+ }
23
+
24
+ function redact(value, key = "") {
25
+ if (SECRET_KEY.test(key)) return "[REDACTED]";
26
+ if (typeof value === "string") {
27
+ return value
28
+ .replace(/Bearer\s+[A-Za-z0-9._~+\/-]+=*/gi, "Bearer [REDACTED]")
29
+ .replace(/\bsk-[A-Za-z0-9_-]{12,}\b/g, "[REDACTED_TOKEN]")
30
+ .slice(0, MAX_STRING);
31
+ }
32
+ if (Array.isArray(value)) return value.slice(0, 100).map((item) => redact(item));
33
+ if (value && typeof value === "object") {
34
+ return Object.fromEntries(Object.entries(value).slice(0, 200).map(([name, item]) => [name, redact(item, name)]));
35
+ }
36
+ return value;
37
+ }
38
+
39
+ function safeId(value) {
40
+ return String(value || "unassigned").replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 128);
41
+ }
42
+
43
+ function atomicWrite(file, value) {
44
+ fs.mkdirSync(path.dirname(file), { recursive: true });
45
+ const temp = `${file}.${process.pid}.${Date.now()}.tmp`;
46
+ fs.writeFileSync(temp, `${JSON.stringify(value, null, 2)}\n`, "utf8");
47
+ fs.renameSync(temp, file);
48
+ }
49
+
50
+ async function readStdin() {
51
+ const chunks = [];
52
+ for await (const chunk of process.stdin) chunks.push(chunk);
53
+ return Buffer.concat(chunks).toString("utf8");
54
+ }
55
+
56
+ try {
57
+ const currentProjectFile = findUp(process.cwd(), path.join(".workflow", "delivery", "project.yaml"));
58
+ const legacyProjectFile = currentProjectFile
59
+ ? null
60
+ : findUp(process.cwd(), path.join("delivery", "project.yaml"));
61
+ const projectFile = currentProjectFile || legacyProjectFile;
62
+ if (!projectFile) process.exit(0);
63
+ const projectRoot = currentProjectFile
64
+ ? path.dirname(path.dirname(path.dirname(projectFile)))
65
+ : path.dirname(path.dirname(projectFile));
66
+ const markerFile = path.join(projectRoot, ".workflow", "delivery", "runtime", "active-task.json");
67
+ const marker = fs.existsSync(markerFile) ? JSON.parse(fs.readFileSync(markerFile, "utf8")) : null;
68
+ const raw = await readStdin();
69
+ const input = raw.trim() ? JSON.parse(raw) : {};
70
+ const taskId = safeId(process.env.AI_DELIVERY_TASK_ID || marker?.task_id || input.turn_id || input.session_id);
71
+ const stateRoot = path.resolve(process.env.AI_DELIVERY_STATE_ROOT || marker?.state_root || projectRoot);
72
+ const workflowRoot = fs.existsSync(path.join(stateRoot, ".workflow", "delivery", "project.yaml"))
73
+ ? path.join(stateRoot, ".workflow")
74
+ : stateRoot;
75
+ if (input.schema_version === 1 && typeof input.event_type === "string") {
76
+ const evolutionProjectRoot = path.basename(workflowRoot) === ".workflow"
77
+ ? path.dirname(workflowRoot)
78
+ : projectRoot;
79
+ const evolutionCli = path.join(evolutionProjectRoot, ".workflow", "tools", "evolution", "evolve.mjs");
80
+ if (!fs.existsSync(evolutionCli)) throw new Error(`Evolution CLI is missing: ${evolutionCli}`);
81
+ const dispatched = spawnSync(process.execPath, [
82
+ evolutionCli,
83
+ "hook", "dispatch", "--input", "-", "--project", evolutionProjectRoot,
84
+ ], {
85
+ cwd: evolutionProjectRoot,
86
+ input: raw,
87
+ encoding: "utf8",
88
+ timeout: 15_000,
89
+ windowsHide: true,
90
+ });
91
+ if (dispatched.error || dispatched.status !== 0) {
92
+ throw new Error(dispatched.error?.message || dispatched.stderr || `Evolution Hook exited ${dispatched.status}`);
93
+ }
94
+ process.stdout.write(dispatched.stdout);
95
+ const outcome = JSON.parse(dispatched.stdout);
96
+ process.exit(outcome.decision === "block" ? 2 : 0);
97
+ }
98
+ const runtime = path.join(workflowRoot, "delivery", "runtime");
99
+ const event = redact({
100
+ at: now(),
101
+ task_id: taskId,
102
+ event_name: input.hook_event_name || input.hookEventName || "unknown",
103
+ session_id: input.session_id || null,
104
+ turn_id: input.turn_id || null,
105
+ agent_id: input.agent_id || null,
106
+ agent_type: input.agent_type || null,
107
+ tool_name: input.tool_name || null,
108
+ input_fields: Object.keys(input).sort(),
109
+ tool_input_fields: input.tool_input && typeof input.tool_input === "object"
110
+ ? Object.keys(input.tool_input).sort()
111
+ : [],
112
+ });
113
+ let line = JSON.stringify(event);
114
+ if (Buffer.byteLength(line, "utf8") > MAX_EVENT) {
115
+ line = JSON.stringify({ at: event.at, task_id: taskId, event_name: event.event_name, truncated: true });
116
+ }
117
+ const eventFile = path.join(runtime, "events", `${taskId}.jsonl`);
118
+ fs.mkdirSync(path.dirname(eventFile), { recursive: true });
119
+ fs.appendFileSync(eventFile, `${line}\n`, "utf8");
120
+ atomicWrite(path.join(runtime, "heartbeats", `${taskId}.json`), {
121
+ task_id: taskId,
122
+ updated_at: event.at,
123
+ event_name: event.event_name,
124
+ session_id: event.session_id,
125
+ turn_id: event.turn_id,
126
+ tool_name: event.tool_name,
127
+ });
128
+ } catch (error) {
129
+ process.stderr.write(`ai-delivery hook logger: ${error.message}\n`);
130
+ process.exitCode = 1;
131
+ }