@pzy560117/codex-harness 0.1.3 → 0.1.4

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 (546) hide show
  1. package/README.md +164 -27
  2. package/bin/harness.js +7 -7
  3. package/lib/commands/doctor.js +12 -12
  4. package/lib/commands/init.js +105 -105
  5. package/lib/commands/run.js +22 -22
  6. package/lib/commands/verify.js +12 -12
  7. package/lib/main.js +62 -62
  8. package/lib/powershell/find-powershell.js +20 -20
  9. package/lib/powershell/invoke-script.js +34 -34
  10. package/lib/project/assert-initialized.js +20 -20
  11. package/lib/project/detect-project-root.js +5 -5
  12. package/lib/release/cache-layout.js +34 -34
  13. package/lib/release/download-release.js +25 -25
  14. package/lib/release/package-source-layout.js +13 -13
  15. package/lib/release/release-config.js +6 -6
  16. package/lib/release/release-manifest.js +76 -76
  17. package/lib/release/resolve-package-source.js +21 -21
  18. package/lib/release/resolve-version.js +26 -26
  19. package/lib/release/unpack-zip.js +25 -25
  20. package/lib/release/verify-sha256.js +16 -16
  21. package/package-source/docs/codex-harness-engineering/templates/README.md +21 -20
  22. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/init-autopilot/SKILL.md +17 -15
  23. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/log-analysis-optimization/SKILL.md +5 -5
  24. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/prd-writer-skill/SKILL.md +28 -28
  25. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qa-e2e-planner/SKILL.md +11 -11
  26. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qa-e2e-runner/SKILL.md +6 -6
  27. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qa-mock-cleaner/SKILL.md +4 -4
  28. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qoder-codex-api-config/SKILL.md +67 -67
  29. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qoder-codex-api-config/agents/openai.yaml +7 -7
  30. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qoder-codex-api-config/scripts/configure-qoder-codex-api.ps1 +278 -278
  31. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/requirements-design-template/SKILL.md +87 -87
  32. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/skills-index.md +12 -12
  33. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-analyze/SKILL.md +34 -34
  34. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-checklist/SKILL.md +8 -8
  35. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-clarify/SKILL.md +28 -28
  36. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-e2e-tasks/SKILL.md +12 -12
  37. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-implement/SKILL.md +37 -37
  38. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-plan/SKILL.md +140 -138
  39. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-specify/SKILL.md +100 -100
  40. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-tasks/SKILL.md +86 -86
  41. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-verify/SKILL.md +144 -142
  42. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/sync-project-root-docs/SKILL.md +145 -143
  43. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/sync-project-root-docs/references/current-repo-notes.md +42 -41
  44. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/sync-project-root-docs/references/github-samples.md +33 -33
  45. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/sync-project-root-docs/scripts/collect-root-doc-facts.ps1 +174 -145
  46. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/ai-integrity-and-originality.md +191 -191
  47. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/citation-templates.md +99 -99
  48. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/final-checklist.md +60 -60
  49. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/photographer-booking-paper.md +85 -85
  50. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/test-result-templates.md +22 -22
  51. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/thesis-analysis-template.md +63 -63
  52. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/update-codemaps/SKILL.md +31 -31
  53. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/README.md +15 -15
  54. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.analyze.md +60 -60
  55. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.checklist.md +8 -8
  56. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.clarify.md +28 -28
  57. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.e2e-testing.md +10 -10
  58. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.implement.md +56 -56
  59. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.plan.md +137 -134
  60. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.specify.md +100 -100
  61. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.tasks.md +86 -86
  62. package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.verify.md +130 -130
  63. package/package-source/docs/codex-harness-engineering/templates/product/AGENTS.md +19 -0
  64. package/package-source/docs/codex-harness-engineering/templates/product/acceptance-criteria.md +47 -47
  65. package/package-source/docs/codex-harness-engineering/templates/product/difficulty-research.md +47 -47
  66. package/package-source/docs/codex-harness-engineering/templates/product/page-inventory.md +21 -21
  67. package/package-source/docs/codex-harness-engineering/templates/product/prd-lite.md +166 -158
  68. package/package-source/docs/codex-harness-engineering/templates/product/requirement-interface-matrix.md +37 -37
  69. package/package-source/docs/codex-harness-engineering/templates/product/state-matrix.yaml +116 -105
  70. package/package-source/docs/codex-harness-engineering/templates/prompts/AGENTS.md +15 -0
  71. package/package-source/docs/codex-harness-engineering/templates/prompts/controller-loop.md +88 -88
  72. package/package-source/docs/codex-harness-engineering/templates/prompts/failure-triage.md +71 -69
  73. package/package-source/docs/codex-harness-engineering/templates/prompts/harness-audit.md +54 -52
  74. package/package-source/docs/codex-harness-engineering/templates/prompts/implement-one-task.md +150 -148
  75. package/package-source/docs/codex-harness-engineering/templates/prompts/repair-one-finding.md +70 -67
  76. package/package-source/docs/codex-harness-engineering/templates/prompts/review-one-task.md +45 -43
  77. package/package-source/docs/codex-harness-engineering/templates/prompts/review-stage1-spec.md +111 -109
  78. package/package-source/docs/codex-harness-engineering/templates/prompts/review-stage2-quality.md +82 -80
  79. package/package-source/docs/codex-harness-engineering/templates/prompts/visual-evaluator.md +80 -78
  80. package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/backend-worker.md +41 -41
  81. package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/docs-worker.md +28 -28
  82. package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/frontend-worker.md +46 -46
  83. package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/harness-writer.md +40 -40
  84. package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/test-runner.md +27 -27
  85. package/package-source/docs/codex-harness-engineering/templates/runtime/AGENTS.md +66 -50
  86. package/package-source/docs/codex-harness-engineering/templates/runtime/codex-loop.ps1 +2129 -231
  87. package/package-source/docs/codex-harness-engineering/templates/runtime/doctor.ps1 +224 -224
  88. package/package-source/docs/codex-harness-engineering/templates/runtime/project-task-template.json +42 -39
  89. package/package-source/docs/codex-harness-engineering/templates/runtime/scripts/test-install-modes.ps1 +2 -2
  90. package/package-source/docs/codex-harness-engineering/templates/runtime/smoke-task.json +52 -52
  91. package/package-source/docs/codex-harness-engineering/templates/runtime/task-run-profile.json +86 -86
  92. package/package-source/docs/codex-harness-engineering/templates/runtime/task.json +11 -8
  93. package/package-source/docs/codex-harness-engineering/templates/runtime/verify.ps1 +21 -21
  94. package/package-source/docs/codex-harness-engineering/templates/scripts/AGENTS.md +15 -0
  95. package/package-source/docs/codex-harness-engineering/templates/scripts/ai-workflow/check-ai-sync-drift.ps1 +205 -205
  96. package/package-source/docs/codex-harness-engineering/templates/scripts/harness/harness-governance-check.ps1 +864 -366
  97. package/package-source/docs/codex-harness-engineering/templates/spec/10-data-model.md +23 -7
  98. package/package-source/docs/codex-harness-engineering/templates/spec/11-security-design.md +30 -13
  99. package/package-source/docs/codex-harness-engineering/templates/spec/AGENTS.md +15 -0
  100. package/package-source/docs/codex-harness-engineering/templates/testing/ACCEPTANCE_CRITERIA.md +39 -39
  101. package/package-source/docs/codex-harness-engineering/templates/testing/ACCEPTANCE_EXAMPLES.md +37 -37
  102. package/package-source/docs/codex-harness-engineering/templates/testing/AGENTS.md +19 -0
  103. package/package-source/docs/codex-harness-engineering/templates/testing/EVIDENCE_PROTOCOL.md +54 -48
  104. package/package-source/docs/codex-harness-engineering/templates/testing/NATURAL_LANGUAGE_TEST_CASES.md +5 -4
  105. package/package-source/docs/codex-harness-engineering/templates/testing/REGRESSION_PLAN.md +28 -20
  106. package/package-source/docs/codex-harness-engineering/templates/testing/RISK_BASED_TEST_PLAN.md +16 -16
  107. package/package-source/docs/codex-harness-engineering/templates/testing/TEST_STRATEGY.md +98 -97
  108. package/package-source/docs/codex-harness-engineering/templates/testing/TRACEABILITY_MATRIX.md +6 -5
  109. package/package-source/docs/codex-harness-engineering/templates/testing/coverage-policy.md +25 -25
  110. package/package-source/docs/codex-harness-engineering/templates/testing/e2e-plan.md +139 -139
  111. package/package-source/docs/codex-harness-engineering/templates/testing/failure-findings.example.json +3 -3
  112. package/package-source/docs/codex-harness-engineering/templates/testing/failure-triage.md +62 -62
  113. package/package-source/docs/codex-harness-engineering/templates/testing/test-data-plan.md +36 -36
  114. package/package-source/docs/codex-harness-engineering/templates/testing/test-report.md +85 -41
  115. package/package-source/docs/codex-harness-engineering/templates/testing/verify-matrix.md +15 -5
  116. package/package-source/docs/codex-harness-engineering/templates/tools/AGENTS.md +14 -0
  117. package/package-source/docs/codex-harness-engineering/templates/tools/harness/acceptance-lint.ps1 +37 -0
  118. package/package-source/docs/codex-harness-engineering/templates/tools/harness/architecture-lint.ps1 +150 -0
  119. package/package-source/docs/codex-harness-engineering/templates/tools/harness/backend-lint.ps1 +137 -0
  120. package/package-source/docs/codex-harness-engineering/templates/tools/harness/business-lint.ps1 +148 -0
  121. package/package-source/docs/codex-harness-engineering/templates/tools/harness/component-lint.ps1 +148 -0
  122. package/package-source/docs/codex-harness-engineering/templates/tools/harness/config-lint.ps1 +159 -0
  123. package/package-source/docs/codex-harness-engineering/templates/tools/harness/context-lint.ps1 +187 -0
  124. package/package-source/docs/codex-harness-engineering/templates/tools/harness/contract-lint.ps1 +148 -0
  125. package/package-source/docs/codex-harness-engineering/templates/tools/harness/data-lint.ps1 +37 -0
  126. package/package-source/docs/codex-harness-engineering/templates/tools/harness/directory-lint.ps1 +152 -0
  127. package/package-source/docs/codex-harness-engineering/templates/tools/harness/docs-lint.ps1 +40 -0
  128. package/package-source/docs/codex-harness-engineering/templates/tools/harness/impact-lint.ps1 +148 -0
  129. package/package-source/docs/codex-harness-engineering/templates/tools/harness/integration-lint.ps1 +37 -0
  130. package/package-source/docs/codex-harness-engineering/templates/tools/harness/mobile-lint.ps1 +37 -0
  131. package/package-source/docs/codex-harness-engineering/templates/tools/harness/observability-lint.ps1 +137 -0
  132. package/package-source/docs/codex-harness-engineering/templates/tools/harness/performance-lint.ps1 +148 -0
  133. package/package-source/docs/codex-harness-engineering/templates/tools/harness/refactor-lint.ps1 +137 -0
  134. package/package-source/docs/codex-harness-engineering/templates/tools/harness/security-lint.ps1 +159 -0
  135. package/package-source/docs/codex-harness-engineering/templates/tools/harness/session-lint.ps1 +126 -0
  136. package/package-source/docs/codex-harness-engineering/templates/tools/harness/spec-lint.ps1 +285 -0
  137. package/package-source/docs/codex-harness-engineering/templates/tools/harness/state-lint.ps1 +137 -0
  138. package/package-source/docs/codex-harness-engineering/templates/tools/harness/style-lint.ps1 +155 -0
  139. package/package-source/docs/codex-harness-engineering/templates/tools/harness/testing-lint.ps1 +192 -0
  140. package/package-source/docs/codex-harness-engineering/templates/tools/harness/ui-lint.ps1 +148 -0
  141. package/package-source/docs/codex-harness-engineering/templates/trace/AGENTS.md +16 -0
  142. package/package-source/docs/codex-harness-engineering/templates/trace/eval-case.yaml +24 -24
  143. package/package-source/docs/codex-harness-engineering/templates/trace/trace.schema.json +101 -101
  144. package/package.json +23 -23
  145. package/package-source/AGENTS.md +0 -57
  146. package/package-source/PACKAGE.md +0 -49
  147. package/package-source/README.md +0 -81
  148. package/package-source/docs/codex-harness-engineering/templates/bootstrap-codex-harness.ps1 +0 -746
  149. package/package-source/docs/codex-harness-engineering/templates/ci/github-action-codex-review.yml +0 -110
  150. package/package-source/docs/codex-harness-engineering/templates/ci/github-action-codex-task.yml +0 -46
  151. package/package-source/docs/codex-harness-engineering/templates/config/agents/architect.toml +0 -17
  152. package/package-source/docs/codex-harness-engineering/templates/config/agents/backend-worker.toml +0 -14
  153. package/package-source/docs/codex-harness-engineering/templates/config/agents/docs-researcher.toml +0 -13
  154. package/package-source/docs/codex-harness-engineering/templates/config/agents/docs-worker.toml +0 -15
  155. package/package-source/docs/codex-harness-engineering/templates/config/agents/explorer.toml +0 -14
  156. package/package-source/docs/codex-harness-engineering/templates/config/agents/failure-triage.toml +0 -18
  157. package/package-source/docs/codex-harness-engineering/templates/config/agents/frontend-worker.toml +0 -14
  158. package/package-source/docs/codex-harness-engineering/templates/config/agents/harness-writer.toml +0 -15
  159. package/package-source/docs/codex-harness-engineering/templates/config/agents/planner.toml +0 -15
  160. package/package-source/docs/codex-harness-engineering/templates/config/agents/readonly-research.toml +0 -13
  161. package/package-source/docs/codex-harness-engineering/templates/config/agents/reviewer.toml +0 -13
  162. package/package-source/docs/codex-harness-engineering/templates/config/agents/security-reviewer.toml +0 -15
  163. package/package-source/docs/codex-harness-engineering/templates/config/agents/stage1-reviewer.toml +0 -15
  164. package/package-source/docs/codex-harness-engineering/templates/config/agents/stage2-reviewer.toml +0 -16
  165. package/package-source/docs/codex-harness-engineering/templates/config/agents/test-planner.toml +0 -17
  166. package/package-source/docs/codex-harness-engineering/templates/config/agents/test-runner.toml +0 -14
  167. package/package-source/docs/codex-harness-engineering/templates/config/agents/visual-reviewer.toml +0 -15
  168. package/package-source/docs/codex-harness-engineering/templates/config/codex-agent-roles.md +0 -24
  169. package/package-source/docs/codex-harness-engineering/templates/config/codex-config.toml +0 -38
  170. package/package-source/docs/codex-harness-engineering/templates/config/codex-readme.md +0 -67
  171. package/package-source/docs/codex-harness-engineering/templates/config/env-check.ps1 +0 -40
  172. package/package-source/docs/codex-harness-engineering/templates/config/env.example +0 -12
  173. package/package-source/docs/codex-harness-engineering/templates/config/global-AGENTS.md +0 -40
  174. package/package-source/docs/codex-harness-engineering/templates/config/global-config.toml +0 -19
  175. package/package-source/docs/codex-harness-engineering/templates/config/mcp-config.toml +0 -38
  176. package/package-source/docs/codex-harness-engineering/templates/config/rules/agents.md +0 -115
  177. package/package-source/docs/codex-harness-engineering/templates/config/rules/coding-style.md +0 -74
  178. package/package-source/docs/codex-harness-engineering/templates/config/rules/constitution.md +0 -290
  179. package/package-source/docs/codex-harness-engineering/templates/config/rules/git.rules +0 -41
  180. package/package-source/docs/codex-harness-engineering/templates/config/rules/harness.rules +0 -29
  181. package/package-source/docs/codex-harness-engineering/templates/config/rules/patterns.md +0 -59
  182. package/package-source/docs/codex-harness-engineering/templates/config/rules/safety.rules +0 -35
  183. package/package-source/docs/codex-harness-engineering/templates/config/rules/testing.md +0 -34
  184. package/package-source/docs/codex-harness-engineering/templates/context/architecture-brief.md +0 -58
  185. package/package-source/docs/codex-harness-engineering/templates/context/dev-plan.md +0 -160
  186. package/package-source/docs/codex-harness-engineering/templates/context/feature-pack.md +0 -101
  187. package/package-source/docs/codex-harness-engineering/templates/context/repo-map.md +0 -78
  188. package/package-source/docs/codex-harness-engineering/templates/context/service-dependency-matrix.yaml +0 -25
  189. package/package-source/docs/codex-harness-engineering/templates/contracts/README.md +0 -16
  190. package/package-source/docs/codex-harness-engineering/templates/contracts/openapi.yaml +0 -182
  191. package/package-source/docs/codex-harness-engineering/templates/contracts/orval.config.ts +0 -20
  192. package/package-source/docs/codex-harness-engineering/templates/contracts/prism-usage.md +0 -34
  193. package/package-source/docs/codex-harness-engineering/templates/design/ai-image-brief.md +0 -122
  194. package/package-source/docs/codex-harness-engineering/templates/design/assets/README.md +0 -24
  195. package/package-source/docs/codex-harness-engineering/templates/design/component-map.md +0 -31
  196. package/package-source/docs/codex-harness-engineering/templates/design/design-brief.md +0 -178
  197. package/package-source/docs/codex-harness-engineering/templates/design/design-tokens.json +0 -88
  198. package/package-source/docs/codex-harness-engineering/templates/design/frontend-architecture.md +0 -147
  199. package/package-source/docs/codex-harness-engineering/templates/design/image-to-frontend-spec.md +0 -108
  200. package/package-source/docs/codex-harness-engineering/templates/design/screen-states.md +0 -122
  201. package/package-source/docs/codex-harness-engineering/templates/design/ui-image-review.md +0 -60
  202. package/package-source/docs/codex-harness-engineering/templates/design/visual-parity-review.md +0 -124
  203. package/package-source/docs/codex-harness-engineering/templates/docs/architecture-constraints.md +0 -83
  204. package/package-source/docs/codex-harness-engineering/templates/docs/demo-readme.md +0 -73
  205. package/package-source/docs/codex-harness-engineering/templates/docs/frontend-quality-rules.md +0 -138
  206. package/package-source/docs/codex-harness-engineering/templates/docs/governance-auto-repair.md +0 -80
  207. package/package-source/docs/codex-harness-engineering/templates/docs/harness-architecture.md +0 -78
  208. package/package-source/docs/codex-harness-engineering/templates/docs/install-manifest-governance.md +0 -307
  209. package/package-source/docs/codex-harness-engineering/templates/docs/knowledge-architecture.md +0 -219
  210. package/package-source/docs/codex-harness-engineering/templates/docs/knowledge-import.md +0 -108
  211. package/package-source/docs/codex-harness-engineering/templates/docs/knowledge-lint.md +0 -98
  212. package/package-source/docs/codex-harness-engineering/templates/docs/new-project-checklist.md +0 -7
  213. package/package-source/docs/codex-harness-engineering/templates/docs/new-project-usage.md +0 -152
  214. package/package-source/docs/codex-harness-engineering/templates/docs/project-agents-template.md +0 -154
  215. package/package-source/docs/codex-harness-engineering/templates/docs/prompt-knowledge-integration.md +0 -89
  216. package/package-source/docs/codex-harness-engineering/templates/docs/regression-rules.md +0 -45
  217. package/package-source/docs/codex-harness-engineering/templates/docs/requirement-prep-kit/README.md +0 -3
  218. package/package-source/docs/codex-harness-engineering/templates/docs/rule-governance.md +0 -98
  219. package/package-source/docs/codex-harness-engineering/templates/docs/service-dependency-matrix.md +0 -55
  220. package/package-source/docs/codex-harness-engineering/templates/docs/spec-to-ui-to-code-workflow.md +0 -196
  221. package/package-source/docs/codex-harness-engineering/templates/docs/task-session-strategy.md +0 -116
  222. package/package-source/docs/codex-harness-engineering/templates/docs/team-knowledge-sync.md +0 -187
  223. package/package-source/docs/codex-harness-engineering/templates/docs/trace-format.md +0 -74
  224. package/package-source/docs/codex-harness-engineering/templates/governance/branch-protection-checklist.md +0 -50
  225. package/package-source/docs/codex-harness-engineering/templates/governance/feedback-evolution-loop.md +0 -55
  226. package/package-source/docs/codex-harness-engineering/templates/governance/retry-budget.yaml +0 -30
  227. package/package-source/docs/codex-harness-engineering/templates/governance/risk-levels.yaml +0 -53
  228. package/package-source/docs/codex-harness-engineering/templates/governance/sandbox-policy.md +0 -13
  229. package/package-source/docs/codex-harness-engineering/templates/hooks/hook-stop-verify.ps1 +0 -818
  230. package/package-source/docs/codex-harness-engineering/templates/hooks/hooks.json +0 -40
  231. package/package-source/docs/codex-harness-engineering/templates/knowledge/catalog.md +0 -6
  232. package/package-source/docs/codex-harness-engineering/templates/knowledge/decisions/DECISION-HARNESS-001.md +0 -39
  233. package/package-source/docs/codex-harness-engineering/templates/knowledge/guidelines/GUIDELINE-RULES-001.md +0 -30
  234. package/package-source/docs/codex-harness-engineering/templates/knowledge/knowledge-catalog.md +0 -41
  235. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/memory/constitution.md +0 -72
  236. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/scripts/powershell/check-prerequisites.ps1 +0 -148
  237. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/scripts/powershell/common.ps1 +0 -137
  238. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/scripts/powershell/create-new-feature.ps1 +0 -279
  239. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/scripts/powershell/setup-plan.ps1 +0 -61
  240. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/scripts/powershell/update-agent-context.ps1 +0 -448
  241. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/templates/agent-file-template.md +0 -28
  242. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/templates/checklist-template.md +0 -40
  243. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/templates/e2e-plan-template.md +0 -38
  244. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/templates/plan-template.md +0 -393
  245. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/templates/spec-template.md +0 -307
  246. package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/templates/tasks-template.md +0 -244
  247. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/architecture/constraints.md +0 -98
  248. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/README.md +0 -122
  249. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/START-HERE.md +0 -53
  250. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/agent-ecosystem-practices.md +0 -140
  251. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/best-practices.md +0 -267
  252. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/codex-global-rules-example.md +0 -292
  253. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/goal-templates.md +0 -380
  254. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/README.md +0 -64
  255. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/contracts/openapi.yaml +0 -25
  256. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/contracts/orval.config.ts +0 -20
  257. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/ai-image-brief.md +0 -44
  258. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/component-map.md +0 -17
  259. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/design-brief.md +0 -58
  260. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/frontend-architecture.md +0 -107
  261. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/image-to-frontend-spec.md +0 -72
  262. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/screen-states.md +0 -25
  263. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/ui-image-review.md +0 -38
  264. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/difficulty-research.md +0 -39
  265. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/page-inventory.md +0 -5
  266. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/prd-lite.md +0 -41
  267. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/requirement-interface-matrix.md +0 -32
  268. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/state-matrix.yaml +0 -14
  269. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/packages/api-client/generated/model/Ticket.ts +0 -6
  270. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/packages/api-client/generated/ticket-api.ts +0 -35
  271. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/packages/api-client/http-client.ts +0 -8
  272. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/packages/ui/TicketFilterBar.tsx +0 -72
  273. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/plans/features/ticket-filter.dev-plan.md +0 -48
  274. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/progress.txt +0 -1
  275. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/stories/TicketFilterBar.stories.tsx +0 -33
  276. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/task.json +0 -54
  277. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/traces/DEMO-TICKET-FILTER-001-20260422-120000.json +0 -74
  278. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/verify.ps1 +0 -42
  279. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/global-rules-and-bootstrap.md +0 -415
  280. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/goal-harness-integration-guide.md +0 -364
  281. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/implementation-flow.md +0 -288
  282. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/implementation-guide.md +0 -25
  283. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/mode-matrix.md +0 -57
  284. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/project-agents-template.md +0 -154
  285. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/spec-to-ui-to-code-workflow.md +0 -196
  286. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/superpowers-codex-solo-builder-playbook.md +0 -676
  287. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/component-map.md +0 -31
  288. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/design-brief.md +0 -178
  289. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/design-tokens.json +0 -88
  290. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/frontend-architecture.md +0 -147
  291. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/image-to-frontend-spec.md +0 -108
  292. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/screen-states.md +0 -122
  293. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/visual-parity-review.md +0 -124
  294. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/docs/frontend-quality-rules.md +0 -138
  295. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/AGENTS.md +0 -165
  296. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/CHANGELOG.md +0 -149
  297. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/CLAUDE.md +0 -61
  298. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/CODE_OF_CONDUCT.md +0 -83
  299. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/CONTRIBUTING.md +0 -465
  300. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/README.md +0 -1390
  301. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/SECURITY.md +0 -53
  302. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/SPONSORING.md +0 -43
  303. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/SPONSORS.md +0 -59
  304. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/TROUBLESHOOTING.md +0 -446
  305. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/architect.md +0 -232
  306. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/build-error-resolver.md +0 -119
  307. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/chief-of-staff.md +0 -155
  308. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/code-reviewer.md +0 -238
  309. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/cpp-build-resolver.md +0 -91
  310. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/cpp-reviewer.md +0 -79
  311. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/database-reviewer.md +0 -94
  312. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/doc-updater.md +0 -110
  313. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/docs-lookup.md +0 -68
  314. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/e2e-runner.md +0 -110
  315. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/go-build-resolver.md +0 -95
  316. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/go-reviewer.md +0 -83
  317. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/harness-optimizer.md +0 -35
  318. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/java-build-resolver.md +0 -154
  319. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/java-reviewer.md +0 -105
  320. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/kotlin-build-resolver.md +0 -119
  321. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/loop-operator.md +0 -37
  322. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/planner.md +0 -215
  323. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/python-reviewer.md +0 -106
  324. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/pytorch-build-resolver.md +0 -122
  325. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/refactor-cleaner.md +0 -92
  326. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/rust-build-resolver.md +0 -149
  327. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/rust-reviewer.md +0 -95
  328. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/security-reviewer.md +0 -112
  329. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/tdd-guide.md +0 -96
  330. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/agents/typescript-reviewer.md +0 -122
  331. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/aside.md +0 -173
  332. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/build-fix.md +0 -64
  333. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/checkpoint.md +0 -78
  334. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/claw.md +0 -51
  335. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/code-review.md +0 -43
  336. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/context-budget.md +0 -29
  337. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/cpp-build.md +0 -173
  338. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/cpp-review.md +0 -140
  339. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/cpp-test.md +0 -257
  340. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/docs.md +0 -32
  341. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/e2e.md +0 -389
  342. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/eval.md +0 -122
  343. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/evolve.md +0 -194
  344. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/go-build.md +0 -183
  345. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/go-review.md +0 -156
  346. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/go-test.md +0 -274
  347. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/gradle-build.md +0 -72
  348. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/harness-audit.md +0 -72
  349. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/instinct-export.md +0 -67
  350. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/instinct-import.md +0 -117
  351. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/instinct-status.md +0 -59
  352. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/kotlin-build.md +0 -176
  353. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/kotlin-review.md +0 -144
  354. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/kotlin-test.md +0 -315
  355. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/learn-eval.md +0 -117
  356. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/learn.md +0 -70
  357. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/loop-start.md +0 -33
  358. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/loop-status.md +0 -25
  359. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/model-route.md +0 -27
  360. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/multi-backend.md +0 -162
  361. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/multi-execute.md +0 -321
  362. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/multi-frontend.md +0 -162
  363. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/multi-plan.md +0 -278
  364. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/plan.md +0 -118
  365. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/pm2.md +0 -283
  366. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/projects.md +0 -39
  367. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/promote.md +0 -41
  368. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/prompt-optimize.md +0 -37
  369. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/prune.md +0 -31
  370. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/python-review.md +0 -319
  371. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/quality-gate.md +0 -30
  372. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/refactor-clean.md +0 -83
  373. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/resume-session.md +0 -154
  374. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/rules-distill.md +0 -11
  375. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/rust-build.md +0 -189
  376. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/rust-review.md +0 -146
  377. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/rust-test.md +0 -311
  378. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/setup-pm.md +0 -83
  379. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/skill-create.md +0 -176
  380. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/skill-health.md +0 -54
  381. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/tdd.md +0 -330
  382. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/test-coverage.md +0 -69
  383. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/update-codemaps.md +0 -73
  384. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/update-docs.md +0 -86
  385. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/verify.md +0 -60
  386. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/contexts/dev.md +0 -23
  387. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/contexts/research.md +0 -30
  388. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/contexts/review.md +0 -25
  389. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/examples/CLAUDE.md +0 -100
  390. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/examples/django-api-CLAUDE.md +0 -308
  391. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/examples/go-microservice-CLAUDE.md +0 -267
  392. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/examples/rust-api-CLAUDE.md +0 -285
  393. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/examples/saas-nextjs-CLAUDE.md +0 -166
  394. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/examples/user-CLAUDE.md +0 -118
  395. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/hooks/README.md +0 -220
  396. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/plugins/README.md +0 -89
  397. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/the-openclaw-guide.md +0 -471
  398. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/the-security-guide.md +0 -206
  399. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/README.md +0 -60
  400. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/app/Mobile_App_Production_Readiness_Framework_/347/247/273/345/212/250/347/253/257/345/205/250/345/271/263/345/217/260/347/224/237/344/272/247/345/217/257/344/270/212/347/272/277/350/247/204/350/214/203.md +0 -2457
  401. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/app/catalog.md +0 -33
  402. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/architecture.md +0 -358
  403. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/common/AI_Coding_Production_Control_Framework_AI/345/206/231/345/256/214/347/232/204/344/273/243/347/240/201/345/246/202/344/275/225/344/270/215/345/244/261/346/216/247.md +0 -2055
  404. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/common/catalog.md +0 -34
  405. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/initial-content.md +0 -296
  406. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/integration-roadmap.md +0 -221
  407. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/architecture-constraints.md +0 -83
  408. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/frontend-quality-rules.md +0 -138
  409. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/governance-auto-repair.md +0 -80
  410. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/service-dependency-matrix.md +0 -55
  411. package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/speckit-requirements-gate.md +0 -260
  412. package/package-source/docs/codex-harness-engineering/templates/package-assets/root/PACKAGE.md +0 -49
  413. package/package-source/docs/codex-harness-engineering/templates/package-assets/root/README.md +0 -52
  414. package/package-source/docs/codex-harness-engineering/templates/package-assets/root/init-project.ps1 +0 -51
  415. package/package-source/docs/codex-harness-engineering/templates/package-assets/root/install-agent-here.ps1 +0 -57
  416. package/package-source/docs/codex-harness-engineering/templates/package-assets/root/install-agent.ps1 +0 -2506
  417. package/package-source/docs/codex-harness-engineering/templates/package-assets/root/install-user.ps1 +0 -29
  418. package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/agents.md +0 -115
  419. package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/coding-style.md +0 -74
  420. package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/constitution.md +0 -290
  421. package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/git.rules +0 -41
  422. package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/harness.rules +0 -29
  423. package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/patterns.md +0 -59
  424. package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/safety.rules +0 -35
  425. package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/testing.md +0 -34
  426. package/package-source/docs/codex-harness-engineering/templates/package-assets/scripts/ai-workflow/check-ai-sync-drift.ps1 +0 -205
  427. package/package-source/docs/codex-harness-engineering/templates/package-assets/scripts/ai-workflow/sync-ai-config-to-targets.ps1 +0 -826
  428. package/package-source/docs/codex-harness-engineering/templates/package-assets/scripts/ai-workflow/sync-targets.example.json +0 -35
  429. package/package-source/docs/codex-harness-engineering/templates/package-assets/scripts/harness/harness-governance-check.ps1 +0 -366
  430. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/HOW_TO_USE_SKILLS.md +0 -91
  431. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/academic-mermaid-diagrams/SKILL.md +0 -172
  432. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/ai-config-git-sync/SKILL.md +0 -152
  433. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/ai-config-git-sync/references/command-recipes.md +0 -92
  434. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/ai-ui-prompts/SKILL.md +0 -350
  435. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/allure-report/SKILL.md +0 -230
  436. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/allure-report/examples/usage.md +0 -99
  437. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/allure-report/scripts/view-allure.ps1 +0 -28
  438. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/api-auto-testing/SKILL.md +0 -329
  439. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/api-contract-template/SKILL.md +0 -88
  440. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/api-design/SKILL.md +0 -139
  441. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/api-integration/SKILL.md +0 -302
  442. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/architect/SKILL.md +0 -211
  443. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/auto-commit/SKILL.md +0 -322
  444. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/backend-patterns/SKILL.md +0 -582
  445. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/baseline-ui/SKILL.md +0 -85
  446. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/better-icons/SKILL.md +0 -129
  447. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/brand-design-md/README.md +0 -215
  448. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/brand-design-md/SKILL.md +0 -191
  449. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/browser-e2e-testing/SKILL.md +0 -305
  450. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/build-error-resolver/SKILL.md +0 -532
  451. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/build-fix/SKILL.md +0 -34
  452. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/business-rule-spec/SKILL.md +0 -99
  453. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/celery-tasks/SKILL.md +0 -95
  454. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/checkpoint/SKILL.md +0 -79
  455. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/cicd/SKILL.md +0 -167
  456. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/claude-openrouter-clash-debug/SKILL.md +0 -100
  457. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/claude-openrouter-clash-debug/references/windows-openrouter-clash-playbook.md +0 -94
  458. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/claude-openrouter-clash-debug/scripts/diagnose-openrouter-route.ps1 +0 -282
  459. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/claude-openrouter-clash-debug/scripts/ensure-openrouter-rule.ps1 +0 -101
  460. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/clickhouse-io/SKILL.md +0 -429
  461. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/code-review/SKILL.md +0 -171
  462. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/code-reviewer/SKILL.md +0 -104
  463. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/coding-standards/SKILL.md +0 -520
  464. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/consistency-checklist/SKILL.md +0 -57
  465. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/continuous-learning/SKILL.md +0 -80
  466. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/continuous-learning/config.json +0 -18
  467. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/continuous-learning/evaluate-session.sh +0 -60
  468. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/core-rules/SKILL.md +0 -78
  469. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/data-flow-spec/SKILL.md +0 -63
  470. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/database/SKILL.md +0 -147
  471. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/deep-interview/SKILL.md +0 -154
  472. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/django-drf/SKILL.md +0 -97
  473. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/doc-updater/SKILL.md +0 -452
  474. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/docker/SKILL.md +0 -216
  475. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/docx/SKILL.md +0 -105
  476. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/e2e/SKILL.md +0 -364
  477. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/e2e-runner/SKILL.md +0 -708
  478. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/error-handling/SKILL.md +0 -245
  479. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/eval/SKILL.md +0 -125
  480. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/eval-harness/SKILL.md +0 -226
  481. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/example-skill/README.md +0 -37
  482. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/example-skill/SKILL.md +0 -141
  483. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/example-skill/examples/usage.md +0 -76
  484. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/example-skill/resources/config.json +0 -21
  485. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/example-skill/scripts/helper.py +0 -24
  486. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/exception-handling-spec/SKILL.md +0 -88
  487. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/find-skill/SKILL.md +0 -95
  488. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/fixing-accessibility/SKILL.md +0 -136
  489. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/fixing-metadata/SKILL.md +0 -111
  490. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/fixing-motion-performance/SKILL.md +0 -151
  491. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/frontend-design/SKILL.md +0 -58
  492. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/frontend-first-workflow/SKILL.md +0 -187
  493. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/frontend-patterns/SKILL.md +0 -631
  494. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/fullstack-workflow/SKILL.md +0 -85
  495. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/git-workflow/SKILL.md +0 -108
  496. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/git-xianyu-analyzer/SKILL.md +0 -346
  497. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/git-xianyu-analyzer/scripts/download_images.py +0 -112
  498. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/github-research/SKILL.md +0 -213
  499. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/glue-coding/SKILL.md +0 -389
  500. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/glue-coding-workflow/SKILL.md +0 -230
  501. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/harness-surface-sync/SKILL.md +0 -188
  502. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/harness-surface-sync/references/current-repo-sync-matrix.md +0 -110
  503. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/harness-surface-sync/references/stale-patterns.md +0 -65
  504. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/agents/openai.yaml +0 -4
  505. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/adapt.md +0 -190
  506. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/animate.md +0 -173
  507. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/audit.md +0 -134
  508. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/bolder.md +0 -113
  509. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/brand.md +0 -104
  510. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/clarify.md +0 -174
  511. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/cognitive-load.md +0 -106
  512. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/color-and-contrast.md +0 -105
  513. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/colorize.md +0 -154
  514. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/craft.md +0 -138
  515. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/critique.md +0 -213
  516. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/delight.md +0 -302
  517. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/distill.md +0 -111
  518. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/document.md +0 -427
  519. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/extract.md +0 -70
  520. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/harden.md +0 -347
  521. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/heuristics-scoring.md +0 -234
  522. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/interaction-design.md +0 -195
  523. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/layout.md +0 -141
  524. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/live.md +0 -513
  525. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/motion-design.md +0 -99
  526. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/onboard.md +0 -234
  527. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/optimize.md +0 -258
  528. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/overdrive.md +0 -130
  529. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/personas.md +0 -178
  530. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/polish.md +0 -232
  531. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/product.md +0 -62
  532. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/quieter.md +0 -99
  533. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/responsive-design.md +0 -114
  534. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/shape.md +0 -136
  535. package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/impeccable/reference/spatial-design.md +0 -100
  536. package/package-source/install-manifest.json +0 -453
  537. package/package-source/install-manifest.schema.json +0 -80
  538. package/package-source/tools/install/ai-workflow/check-ai-sync-drift.ps1 +0 -205
  539. package/package-source/tools/install/ai-workflow/sync-ai-config-to-targets.ps1 +0 -826
  540. package/package-source/tools/install/ai-workflow/sync-targets.example.json +0 -35
  541. package/package-source/tools/install/bootstrap-codex-harness.ps1 +0 -760
  542. package/package-source/tools/install/env-check.ps1 +0 -40
  543. package/package-source/tools/install/init-project.ps1 +0 -51
  544. package/package-source/tools/install/install-agent-here.ps1 +0 -57
  545. package/package-source/tools/install/install-agent.ps1 +0 -2511
  546. package/package-source/tools/install/install-user.ps1 +0 -29
@@ -15,9 +15,9 @@ $utf8NoBom = New-Object System.Text.UTF8Encoding($false)
15
15
  [Console]::OutputEncoding = $utf8NoBom
16
16
  $OutputEncoding = $utf8NoBom
17
17
 
18
- if ([string]::IsNullOrWhiteSpace($ProjectRoot)) {
19
- $ProjectRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "..\.."))
20
- }
18
+ if ([string]::IsNullOrWhiteSpace($ProjectRoot)) {
19
+ $ProjectRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "..\.."))
20
+ }
21
21
 
22
22
  function Write-Step {
23
23
  <#
@@ -29,7 +29,7 @@ function Write-Step {
29
29
  Write-Host "[$timestamp] $Message"
30
30
  }
31
31
 
32
- function Get-TextFileContent {
32
+ function Get-TextFileContent {
33
33
  <#
34
34
  读取 UTF-8 文本文件,文件不存在时返回空字符串。
35
35
  #>
@@ -39,8 +39,116 @@ function Get-TextFileContent {
39
39
  return ""
40
40
  }
41
41
 
42
- return Get-Content -LiteralPath $Path -Raw -Encoding UTF8
43
- }
42
+ return Get-Content -LiteralPath $Path -Raw -Encoding UTF8
43
+ }
44
+
45
+ function Get-HarnessStateConfigPath {
46
+ <#
47
+ 返回 harness 安装状态配置文件路径。
48
+ #>
49
+ param([string]$Root)
50
+
51
+ return (Join-Path $Root ".codex-harness\state\config.json")
52
+ }
53
+
54
+ function Get-HarnessPackageRoot {
55
+ <#
56
+ 读取 thin project 对应的用户级 packageRoot;不存在时返回空字符串。
57
+ #>
58
+ param([string]$Root)
59
+
60
+ $configPath = Get-HarnessStateConfigPath -Root $Root
61
+ if (-not (Test-Path -LiteralPath $configPath)) {
62
+ return ""
63
+ }
64
+
65
+ try {
66
+ $configDocument = Get-Content -LiteralPath $configPath -Raw | ConvertFrom-Json
67
+ $packageRoot = [string](Get-ObjectPropertyValue -InputObject $configDocument -Name "packageRoot" -Default "")
68
+ if ([string]::IsNullOrWhiteSpace($packageRoot)) {
69
+ return ""
70
+ }
71
+
72
+ return [System.IO.Path]::GetFullPath($packageRoot)
73
+ }
74
+ catch {
75
+ return ""
76
+ }
77
+ }
78
+
79
+ function Resolve-HarnessProjectOrPackagePath {
80
+ <#
81
+ 优先解析项目内路径;若 thin project 未安装该文档,则回退到 packageRoot。
82
+ #>
83
+ param(
84
+ [string]$Root,
85
+ [string]$RelativePath
86
+ )
87
+
88
+ if ([string]::IsNullOrWhiteSpace($RelativePath)) {
89
+ return $null
90
+ }
91
+
92
+ if ([System.IO.Path]::IsPathRooted($RelativePath)) {
93
+ return $RelativePath
94
+ }
95
+
96
+ $normalizedRelativePath = $RelativePath.Replace("/", "\")
97
+ $projectPath = Join-Path $Root $normalizedRelativePath
98
+ if (Test-Path -LiteralPath $projectPath) {
99
+ return $projectPath
100
+ }
101
+
102
+ $packageRoot = Get-HarnessPackageRoot -Root $Root
103
+ if (-not [string]::IsNullOrWhiteSpace($packageRoot)) {
104
+ $packagePath = Join-Path $packageRoot $normalizedRelativePath
105
+ if (Test-Path -LiteralPath $packagePath) {
106
+ return $packagePath
107
+ }
108
+ }
109
+
110
+ return $projectPath
111
+ }
112
+
113
+ function Get-HarnessDisplayReference {
114
+ <#
115
+ 返回给 prompt / reviewer 显示的引用路径;项目内不存在时显示 package 绝对路径。
116
+ #>
117
+ param(
118
+ [string]$Root,
119
+ [string]$RelativePath
120
+ )
121
+
122
+ $resolvedPath = Resolve-HarnessProjectOrPackagePath -Root $Root -RelativePath $RelativePath
123
+ if ([string]::IsNullOrWhiteSpace($resolvedPath)) {
124
+ return $RelativePath
125
+ }
126
+
127
+ $projectRootFull = ([System.IO.Path]::GetFullPath($Root)).TrimEnd('\', '/') + '\'
128
+ $resolvedFull = [System.IO.Path]::GetFullPath($resolvedPath)
129
+ if ($resolvedFull.StartsWith($projectRootFull, [System.StringComparison]::OrdinalIgnoreCase)) {
130
+ return $RelativePath.Replace("/", "\")
131
+ }
132
+
133
+ return $resolvedFull
134
+ }
135
+
136
+ function ConvertTo-HarnessDisplayReferences {
137
+ <#
138
+ 批量解析给 prompt 展示的 truth source / context source 路径。
139
+ #>
140
+ param(
141
+ [string]$Root,
142
+ [string[]]$RelativePaths
143
+ )
144
+
145
+ $references = @()
146
+ foreach ($relativePath in @(ConvertTo-StringArray -Value $RelativePaths)) {
147
+ $references += Get-HarnessDisplayReference -Root $Root -RelativePath $relativePath
148
+ }
149
+
150
+ return @(ConvertTo-UniqueStringArray -Items $references)
151
+ }
44
152
 
45
153
  function Show-LogTail {
46
154
  <#
@@ -127,7 +235,7 @@ function Get-ObjectPropertyValue {
127
235
  return $property.Value
128
236
  }
129
237
 
130
- function ConvertTo-StringArray {
238
+ function ConvertTo-StringArray {
131
239
  <#
132
240
  归一化为字符串数组。
133
241
  #>
@@ -161,8 +269,46 @@ function ConvertTo-StringArray {
161
269
  return $result
162
270
  }
163
271
 
164
- return @([string]$Value)
165
- }
272
+ return @([string]$Value)
273
+ }
274
+
275
+ function Resolve-CodexStartProcessPath {
276
+ <#
277
+ 在 Windows 下把 codex 命令解析成适合 Start-Process 的可执行文件。
278
+ 避免直接把 npm 生成的 codex.ps1 传给 Start-Process。
279
+ #>
280
+ param([string]$Command)
281
+
282
+ if ([string]::IsNullOrWhiteSpace($Command)) {
283
+ throw "CodexCommand 不能为空。"
284
+ }
285
+
286
+ $resolvedCommand = $null
287
+ try {
288
+ $resolvedCommand = Get-Command $Command -ErrorAction Stop | Select-Object -First 1
289
+ }
290
+ catch {
291
+ return $Command
292
+ }
293
+
294
+ $resolvedPath = [string]$resolvedCommand.Path
295
+ if ([string]::IsNullOrWhiteSpace($resolvedPath)) {
296
+ return $Command
297
+ }
298
+
299
+ if (-not $resolvedPath.EndsWith(".ps1", [System.StringComparison]::OrdinalIgnoreCase)) {
300
+ return $resolvedPath
301
+ }
302
+
303
+ $basePath = ([System.IO.Path]::ChangeExtension($resolvedPath, $null)).TrimEnd('.')
304
+ foreach ($candidate in @("$basePath.cmd", "$basePath.exe")) {
305
+ if (Test-Path -LiteralPath $candidate -PathType Leaf) {
306
+ return $candidate
307
+ }
308
+ }
309
+
310
+ return $resolvedPath
311
+ }
166
312
 
167
313
  function Normalize-GitRelativePath {
168
314
  <#
@@ -419,18 +565,18 @@ function Get-TaskDefinitionDefaults {
419
565
  $defaultGateProfile = "spec_required"
420
566
  $defaultTruthSources = @("product", "testing")
421
567
  }
422
- "feature_plan" {
423
- $defaultGateProfile = "spec_required"
424
- $defaultTruthSources = @("product", "design", "testing", "repo_context")
425
- }
426
- "feature_impl" {
427
- $defaultGateProfile = "spec_required"
428
- $defaultTruthSources = @("product", "design", "plan", "testing", "repo_context")
429
- }
430
- "release" {
431
- $defaultGateProfile = "release_required"
432
- $defaultTruthSources = @("product", "design", "plan", "testing", "repo_context")
433
- }
568
+ "feature_plan" {
569
+ $defaultGateProfile = "spec_required"
570
+ $defaultTruthSources = @("product", "design", "testing", "repo_context")
571
+ }
572
+ "feature_impl" {
573
+ $defaultGateProfile = "spec_required"
574
+ $defaultTruthSources = @("product", "design", "plan", "testing", "repo_context")
575
+ }
576
+ "release" {
577
+ $defaultGateProfile = "release_required"
578
+ $defaultTruthSources = @("product", "design", "plan", "testing", "repo_context")
579
+ }
434
580
  "archive" {
435
581
  $defaultGateProfile = "lightweight"
436
582
  $defaultTruthSources = @("knowledge")
@@ -467,7 +613,7 @@ function Get-TaskDefinitionDefaults {
467
613
  }
468
614
  }
469
615
 
470
- function Get-DefaultRunProfile {
616
+ function Get-DefaultRunProfile {
471
617
  <#
472
618
  返回默认 task 会话与子代理策略。
473
619
  #>
@@ -595,7 +741,7 @@ function Resolve-RunProfilePath {
595
741
  return Join-Path $Root $candidate
596
742
  }
597
743
 
598
- function Get-TaskExecutionPolicy {
744
+ function Get-TaskExecutionPolicy {
599
745
  <#
600
746
  组合默认 profile、runtime 默认项和 task 覆盖项。
601
747
  #>
@@ -614,21 +760,24 @@ function Get-TaskExecutionPolicy {
614
760
  }
615
761
 
616
762
  $runtime = Get-ObjectPropertyValue -InputObject $TaskDocument -Name "runtime"
617
- $runtimeSession = Get-ObjectPropertyValue -InputObject $runtime -Name "session"
618
- $runtimeSubagents = Get-ObjectPropertyValue -InputObject $runtime -Name "subagents"
619
- $runtimeGit = Get-ObjectPropertyValue -InputObject $runtime -Name "git"
620
- $runtimeCodex = Get-ObjectPropertyValue -InputObject $runtime -Name "codex"
763
+ $runtimeSession = Get-ObjectPropertyValue -InputObject $runtime -Name "session"
764
+ $runtimeSubagents = Get-ObjectPropertyValue -InputObject $runtime -Name "subagents"
765
+ $runtimeGit = Get-ObjectPropertyValue -InputObject $runtime -Name "git"
766
+ $runtimeCodex = Get-ObjectPropertyValue -InputObject $runtime -Name "codex"
767
+ $runtimeContentGates = Get-ObjectPropertyValue -InputObject $runtime -Name "content_gates"
621
768
 
622
769
  $taskExecution = Get-ObjectPropertyValue -InputObject $Task -Name "execution"
623
- $taskSession = Get-ObjectPropertyValue -InputObject $taskExecution -Name "session"
624
- $taskSubagents = Get-ObjectPropertyValue -InputObject $taskExecution -Name "subagents"
625
- $taskGit = Get-ObjectPropertyValue -InputObject $taskExecution -Name "git"
626
- $taskCodex = Get-ObjectPropertyValue -InputObject $taskExecution -Name "codex"
627
-
628
- $session = Merge-PolicySection -BaseSection $defaultProfile.session -OverrideSection (Get-ObjectPropertyValue -InputObject $profileOverrides -Name "session")
629
- $session = Merge-PolicySection -BaseSection $session -OverrideSection $runtimeSession
630
- $session = Merge-PolicySection -BaseSection $session -OverrideSection $taskSession
631
- $session.context_sources = ConvertTo-StringArray -Value (Get-ObjectPropertyValue -InputObject $session -Name "context_sources")
770
+ $taskSession = Get-ObjectPropertyValue -InputObject $taskExecution -Name "session"
771
+ $taskSubagents = Get-ObjectPropertyValue -InputObject $taskExecution -Name "subagents"
772
+ $taskGit = Get-ObjectPropertyValue -InputObject $taskExecution -Name "git"
773
+ $taskCodex = Get-ObjectPropertyValue -InputObject $taskExecution -Name "codex"
774
+ $taskContentGates = Get-ObjectPropertyValue -InputObject $taskExecution -Name "content_gates"
775
+
776
+ $session = Merge-PolicySection -BaseSection $defaultProfile.session -OverrideSection (Get-ObjectPropertyValue -InputObject $profileOverrides -Name "session")
777
+ $session = Merge-PolicySection -BaseSection $session -OverrideSection $runtimeSession
778
+ $session = Merge-PolicySection -BaseSection $session -OverrideSection $taskSession
779
+ $session.context_sources = ConvertTo-StringArray -Value (Get-ObjectPropertyValue -InputObject $session -Name "context_sources")
780
+ $session.context_source_references = ConvertTo-HarnessDisplayReferences -Root $Root -RelativePaths $session.context_sources
632
781
 
633
782
  $subagents = Merge-PolicySection -BaseSection $defaultProfile.subagents -OverrideSection (Get-ObjectPropertyValue -InputObject $profileOverrides -Name "subagents")
634
783
  $subagents = Merge-PolicySection -BaseSection $subagents -OverrideSection $runtimeSubagents
@@ -641,9 +790,36 @@ function Get-TaskExecutionPolicy {
641
790
  $gitPolicy = Merge-PolicySection -BaseSection $gitPolicy -OverrideSection $taskGit
642
791
  $gitPolicy.non_blocking_dirty_paths = ConvertTo-StringArray -Value (Get-ObjectPropertyValue -InputObject $gitPolicy -Name "non_blocking_dirty_paths")
643
792
 
644
- $codexPolicy = Merge-PolicySection -BaseSection $defaultProfile.codex -OverrideSection (Get-ObjectPropertyValue -InputObject $profileOverrides -Name "codex")
645
- $codexPolicy = Merge-PolicySection -BaseSection $codexPolicy -OverrideSection $runtimeCodex
646
- $codexPolicy = Merge-PolicySection -BaseSection $codexPolicy -OverrideSection $taskCodex
793
+ $codexPolicy = Merge-PolicySection -BaseSection $defaultProfile.codex -OverrideSection (Get-ObjectPropertyValue -InputObject $profileOverrides -Name "codex")
794
+ $codexPolicy = Merge-PolicySection -BaseSection $codexPolicy -OverrideSection $runtimeCodex
795
+ $codexPolicy = Merge-PolicySection -BaseSection $codexPolicy -OverrideSection $taskCodex
796
+
797
+ $contentGateDefaults = Get-DefaultContentGateSettings
798
+ $contentGates = Merge-PolicySection -BaseSection $contentGateDefaults -OverrideSection $runtimeContentGates
799
+ $contentGates = Merge-PolicySection -BaseSection $contentGates -OverrideSection $taskContentGates
800
+ $runtimeContentGateMode = [string](Get-ObjectPropertyValue -InputObject $runtimeContentGates -Name "mode" -Default "")
801
+ if ([string]::IsNullOrWhiteSpace($runtimeContentGateMode)) {
802
+ $runtimeContentGateMode = [string](Get-ObjectPropertyValue -InputObject $runtimeContentGates -Name "default_mode" -Default "")
803
+ }
804
+ if (-not [string]::IsNullOrWhiteSpace($runtimeContentGateMode)) {
805
+ $contentGates.mode = $runtimeContentGateMode
806
+ }
807
+ $taskContentGateMode = [string](Get-ObjectPropertyValue -InputObject $Task -Name "content_gate_mode" -Default "")
808
+ if (-not [string]::IsNullOrWhiteSpace($taskContentGateMode)) {
809
+ $contentGates.mode = $taskContentGateMode
810
+ }
811
+
812
+ $taskRiskTags = ConvertTo-LowerUniqueStringArray -Value (Get-ObjectPropertyValue -InputObject $Task -Name "risk_tags")
813
+ $contentGates.mode = Normalize-ContentGateMode -Mode ([string](Get-ObjectPropertyValue -InputObject $contentGates -Name "mode" -Default "core"))
814
+ $contentGates.risk_tags = ConvertTo-LowerUniqueStringArray -Value @(
815
+ (Get-ObjectPropertyValue -InputObject $contentGates -Name "risk_tags"),
816
+ $taskRiskTags
817
+ )
818
+
819
+ $changeKind = [string](Get-ObjectPropertyValue -InputObject $Task -Name "change_kind" -Default "")
820
+ if ($changeKind.Trim().ToLowerInvariant() -eq "refactor" -and $contentGates.risk_tags -notcontains "refactor") {
821
+ $contentGates.risk_tags = @($contentGates.risk_tags + @("refactor"))
822
+ }
647
823
 
648
824
  $contextFiles = ConvertTo-StringArray -Value (Get-ObjectPropertyValue -InputObject $Task -Name "context_files")
649
825
  $taskDefaults = Get-TaskDefinitionDefaults -Task $Task
@@ -651,10 +827,11 @@ function Get-TaskExecutionPolicy {
651
827
  return [PSCustomObject]@{
652
828
  run_profile_path = $resolvedProfilePath
653
829
  session = $session
654
- subagents = $subagents
655
- git = $gitPolicy
656
- codex = $codexPolicy
657
- context_files = $contextFiles
830
+ subagents = $subagents
831
+ git = $gitPolicy
832
+ codex = $codexPolicy
833
+ content_gates = $contentGates
834
+ context_files = $contextFiles
658
835
  task_kind = $taskDefaults.task_kind
659
836
  gate_profile = $taskDefaults.gate_profile
660
837
  required_truth_sources = $taskDefaults.required_truth_sources
@@ -865,20 +1042,20 @@ function Assert-CleanGitWorkspace {
865
1042
  }
866
1043
  }
867
1044
 
868
- function Invoke-RuntimeDoctor {
1045
+ function Invoke-RuntimeDoctor {
869
1046
  <#
870
1047
  在任务执行前检查 runtime 入口、.codex 配置和 harness 深文档是否完整。
871
1048
  #>
872
1049
  param([string]$Root)
873
1050
 
874
- $doctorPath = Join-Path $Root "tools\\harness/doctor.ps1"
1051
+ $doctorPath = Join-Path $Root "tools\harness\doctor.ps1"
875
1052
  if (-not (Test-Path -LiteralPath $doctorPath)) {
876
1053
  throw "找不到 runtime doctor: $doctorPath"
877
1054
  }
878
1055
 
879
1056
  Push-Location $Root
880
1057
  try {
881
- $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\\harness/doctor.ps1 2>&1
1058
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\doctor.ps1 2>&1
882
1059
  $exitCode = $LASTEXITCODE
883
1060
  return [PSCustomObject]@{
884
1061
  ExitCode = $exitCode
@@ -922,7 +1099,7 @@ function New-ImplementationPrompt {
922
1099
  $steps = ($Task.steps | ForEach-Object { "- $_" }) -join "`n"
923
1100
  $acceptance = ($Task.acceptance | ForEach-Object { "- $_" }) -join "`n"
924
1101
  $dependencies = @(ConvertTo-StringArray -Value (Get-ObjectPropertyValue -InputObject $Task -Name "dependencies"))
925
- $contextSourcesText = ConvertTo-BulletLines -Items $ExecutionPolicy.session.context_sources
1102
+ $contextSourcesText = ConvertTo-BulletLines -Items $ExecutionPolicy.session.context_source_references
926
1103
  $contextFilesText = ConvertTo-BulletLines -Items $ExecutionPolicy.context_files -EmptyText "- 无显式任务文件列表;仅按需读取与当前任务直接相关的文件"
927
1104
  $allowedRoles = @(ConvertTo-StringArray -Value $ExecutionPolicy.subagents.allowed_roles)
928
1105
  $allowedRolesText = if ($allowedRoles.Count -eq 0) { "none" } else { $allowedRoles -join ", " }
@@ -1005,7 +1182,7 @@ $($Task.test_command)
1005
1182
  "@
1006
1183
  }
1007
1184
 
1008
- function Get-ExistingRelativePaths {
1185
+ function Get-ExistingRelativePaths {
1009
1186
  <#
1010
1187
  返回工作区内实际存在的相对路径列表。
1011
1188
  #>
@@ -1020,16 +1197,16 @@ function Get-ExistingRelativePaths {
1020
1197
  continue
1021
1198
  }
1022
1199
 
1023
- $fullPath = Join-Path $Root $relativePath
1024
- if (Test-Path -LiteralPath $fullPath) {
1025
- $existing += $relativePath
1026
- }
1027
- }
1200
+ $fullPath = Resolve-HarnessProjectOrPackagePath -Root $Root -RelativePath $relativePath
1201
+ if (Test-Path -LiteralPath $fullPath) {
1202
+ $existing += Get-HarnessDisplayReference -Root $Root -RelativePath $relativePath
1203
+ }
1204
+ }
1028
1205
 
1029
1206
  return $existing
1030
1207
  }
1031
1208
 
1032
- function Get-FirstExistingRelativePath {
1209
+ function Get-FirstExistingRelativePath {
1033
1210
  <#
1034
1211
  返回候选路径中第一个实际存在的相对路径。
1035
1212
  #>
@@ -1038,12 +1215,12 @@ function Get-FirstExistingRelativePath {
1038
1215
  [string[]]$Candidates
1039
1216
  )
1040
1217
 
1041
- foreach ($candidate in @(ConvertTo-StringArray -Value $Candidates)) {
1042
- $fullPath = Join-Path $Root $candidate
1043
- if (Test-Path -LiteralPath $fullPath) {
1044
- return $candidate
1045
- }
1046
- }
1218
+ foreach ($candidate in @(ConvertTo-StringArray -Value $Candidates)) {
1219
+ $fullPath = Resolve-HarnessProjectOrPackagePath -Root $Root -RelativePath $candidate
1220
+ if (Test-Path -LiteralPath $fullPath) {
1221
+ return (Get-HarnessDisplayReference -Root $Root -RelativePath $candidate)
1222
+ }
1223
+ }
1047
1224
 
1048
1225
  return $null
1049
1226
  }
@@ -1545,7 +1722,7 @@ $($TestResult.Output)
1545
1722
  "@
1546
1723
  }
1547
1724
 
1548
- function Invoke-CodexTask {
1725
+ function Invoke-CodexTask {
1549
1726
  <#
1550
1727
  调用 codex exec 运行单任务。
1551
1728
  原始输出写入日志文件,终端只显示 driver 摘要。
@@ -1593,15 +1770,17 @@ function Invoke-CodexTask {
1593
1770
  $Root,
1594
1771
  "-"
1595
1772
  )
1596
- if ($CaptureJsonEvents) {
1597
- $arguments += "--json"
1598
- }
1599
-
1600
- $process = Start-Process `
1601
- -FilePath $Command `
1602
- -ArgumentList $arguments `
1603
- -WorkingDirectory $Root `
1604
- -RedirectStandardInput $promptPath `
1773
+ if ($CaptureJsonEvents) {
1774
+ $arguments += "--json"
1775
+ }
1776
+
1777
+ $resolvedCommand = Resolve-CodexStartProcessPath -Command $Command
1778
+
1779
+ $process = Start-Process `
1780
+ -FilePath $resolvedCommand `
1781
+ -ArgumentList $arguments `
1782
+ -WorkingDirectory $Root `
1783
+ -RedirectStandardInput $promptPath `
1605
1784
  -RedirectStandardOutput $stdoutPath `
1606
1785
  -RedirectStandardError $stderrPath `
1607
1786
  -NoNewWindow `
@@ -1724,7 +1903,7 @@ function Add-TraceDurableFields {
1724
1903
  return $Trace
1725
1904
  }
1726
1905
 
1727
- function Invoke-TestCommand {
1906
+ function Invoke-TestCommand {
1728
1907
  <#
1729
1908
  执行任务指定的验证命令,并在需要时持久化测试输出。
1730
1909
  #>
@@ -1764,117 +1943,773 @@ function Invoke-TestCommand {
1764
1943
  finally {
1765
1944
  Pop-Location
1766
1945
  }
1767
- }
1768
-
1769
- function Invoke-FailureTriage {
1770
- <#
1771
- 在测试失败后运行只读失败归因链路,输出结构化 triage 结果。
1772
- #>
1773
- param(
1774
- [object]$Task,
1775
- [string]$Root,
1776
- [object]$ExecutionPolicy,
1777
- [object]$ReviewContext,
1778
- [object]$CodexResult,
1779
- [object]$Stage1Result,
1780
- [object]$TestResult,
1781
- [string]$CodexCommand,
1782
- [string]$LogDirectory,
1783
- [switch]$CaptureJsonEvents
1784
- )
1785
-
1786
- $template = Get-PromptTemplate -Root $Root -TemplateName "failure-triage.md"
1787
- $requirementIdsText = ConvertTo-BulletLines -Items (ConvertTo-StringArray -Value (Get-ObjectPropertyValue -InputObject $Task -Name "requirement_ids")) -EmptyText "- 未显式声明 Requirement IDs"
1788
- $acceptanceText = ConvertTo-BulletLines -Items (ConvertTo-StringArray -Value $Task.acceptance)
1789
- $contextFilesText = ConvertTo-BulletLines -Items $ReviewContext.task_context
1790
- $testingText = ConvertTo-BulletLines -Items $ReviewContext.testing
1791
- $truthSourceStateText = Convert-TruthSourceStateToBulletLines -States $ReviewContext.truth_source_state
1792
- $triageOutputPath = Join-Path $LogDirectory "$($Task.id)-failure-triage.json"
1793
- $testOutputPathText = if ([string]::IsNullOrWhiteSpace($TestResult.OutputLog)) { "- 无测试日志文件" } else { "- $($TestResult.OutputLog)" }
1794
-
1795
- $prompt = @"
1796
- $template
1797
-
1798
- ## Driver Context
1799
-
1800
- - Task ID: $($Task.id)
1801
- - 描述: $($Task.description)
1802
- - Requirement IDs:
1803
- $requirementIdsText
1804
- - 验收标准:
1805
- $acceptanceText
1806
- - 失败来源: test
1807
- - 测试命令: $($Task.test_command)
1808
- - 测试退出码: $($TestResult.ExitCode)
1809
-
1810
- ### Task Context Files
1811
- $contextFilesText
1812
-
1813
- ### Testing Truth Sources
1814
- $testingText
1815
-
1816
- ### Truth Source Completeness
1817
- $truthSourceStateText
1818
-
1819
- ### Evidence Files
1820
- - 实现 stdout: $($CodexResult.StdoutLog)
1821
- - 实现 stderr: $($CodexResult.StderrLog)
1822
- - Stage 1 stdout: $($Stage1Result.StdoutLog)
1823
- - Stage 1 stderr: $($Stage1Result.StderrLog)
1824
- $testOutputPathText
1825
-
1826
- ### Raw Test Output
1827
- ```text
1828
- $($TestResult.Output)
1829
- ```
1830
-
1831
- 输出要求:
1832
- - 只输出一个合法 JSON 对象。
1833
- - 必须包含 findings 数组;没有 finding 也要输出空数组。
1834
- - 优先把失败归类为 `TEST_CODE_ISSUE`、`PRODUCT_BUG`、`REQUIREMENT_CHANGE`、`ENV_OR_DATA_ISSUE` 或 `FLAKY`。
1835
- "@
1836
-
1837
- $triageResult = Invoke-CodexTask `
1838
- -Prompt $prompt `
1839
- -Root $Root `
1840
- -Command $CodexCommand `
1841
- -LogDirectory $LogDirectory `
1842
- -TaskId "$($Task.id)-failure-triage" `
1843
- -Sandbox $ExecutionPolicy.codex.review_sandbox `
1844
- -ActivityLabel "Failure Triage" `
1845
- -DisableHooks $ExecutionPolicy.codex.disable_hooks `
1846
- -CaptureJsonEvents:$CaptureJsonEvents
1847
-
1848
- $triageJson = $triageResult.Output
1849
- if ([string]::IsNullOrWhiteSpace($triageJson)) {
1850
- $triageJson = $triageResult.LastMessage
1851
- }
1852
-
1853
- $reportPath = $null
1854
- $parseError = $null
1855
- if (-not [string]::IsNullOrWhiteSpace($triageJson)) {
1856
- try {
1857
- $triageObject = $triageJson | ConvertFrom-Json -ErrorAction Stop
1858
- $triageObject | ConvertTo-Json -Depth 12 | Set-Content -LiteralPath $triageOutputPath -Encoding UTF8
1859
- $reportPath = $triageOutputPath
1860
- }
1861
- catch {
1862
- $parseError = $_.Exception.Message
1863
- }
1864
- }
1865
-
1866
- return [PSCustomObject]@{
1867
- ExitCode = $triageResult.ExitCode
1868
- Output = $triageResult.Output
1869
- LastMessage = $triageResult.LastMessage
1870
- StdoutLog = $triageResult.StdoutLog
1871
- StderrLog = $triageResult.StderrLog
1872
- PromptLog = $triageResult.PromptLog
1873
- LastMessageLog = $triageResult.LastMessageLog
1874
- ReportPath = $reportPath
1875
- ParseError = $parseError
1876
- }
1877
- }
1946
+ }
1947
+
1948
+ function Invoke-SpecLintPrecheck {
1949
+ <#
1950
+ 对需要 spec 真相源的任务执行内容级门禁,避免 TBD 规格直接进入实现闭环。
1951
+ #>
1952
+ param([string]$Root)
1953
+
1954
+ $specLintPath = Join-Path $Root "tools\harness\spec-lint.ps1"
1955
+ if (-not (Test-Path -LiteralPath $specLintPath)) {
1956
+ throw "找不到 spec lint: $specLintPath"
1957
+ }
1958
+
1959
+ Push-Location $Root
1960
+ try {
1961
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\spec-lint.ps1 -ProjectRoot . 2>&1
1962
+ $exitCode = $LASTEXITCODE
1963
+ return [PSCustomObject]@{
1964
+ ExitCode = $exitCode
1965
+ Output = ($output -join "`n")
1966
+ }
1967
+ }
1968
+ finally {
1969
+ Pop-Location
1970
+ }
1971
+ }
1972
+
1973
+ function Test-ContentGateModeEnabled {
1974
+ <#
1975
+ core < recommended < full
1976
+ #>
1977
+ param(
1978
+ [object]$ExecutionPolicy,
1979
+ [string]$MinimumMode
1980
+ )
1981
+
1982
+ $order = @{
1983
+ core = 1
1984
+ recommended = 2
1985
+ full = 3
1986
+ }
1987
+
1988
+ $currentMode = Normalize-ContentGateMode -Mode ([string](Get-ObjectPropertyValue -InputObject $ExecutionPolicy.content_gates -Name "mode" -Default "core"))
1989
+ $requiredMode = Normalize-ContentGateMode -Mode $MinimumMode
1990
+ return $order[$currentMode] -ge $order[$requiredMode]
1991
+ }
1992
+
1993
+ function Test-TaskHasRiskTag {
1994
+ param(
1995
+ [object]$ExecutionPolicy,
1996
+ [string[]]$Tags
1997
+ )
1998
+
1999
+ $riskTags = ConvertTo-LowerUniqueStringArray -Value (Get-ObjectPropertyValue -InputObject $ExecutionPolicy.content_gates -Name "risk_tags")
2000
+ foreach ($tag in @(ConvertTo-LowerUniqueStringArray -Value $Tags)) {
2001
+ if ($riskTags -contains $tag) {
2002
+ return $true
2003
+ }
2004
+ }
2005
+
2006
+ return $false
2007
+ }
2008
+
2009
+ function Get-DefaultContentGateSettings {
2010
+ <#
2011
+ 默认只启用 core 档位,避免新项目冷启动时被大量非关键门禁阻塞。
2012
+ #>
2013
+ return [PSCustomObject]@{
2014
+ mode = "core"
2015
+ risk_tags = @()
2016
+ }
2017
+ }
2018
+
2019
+ function Normalize-ContentGateMode {
2020
+ param([string]$Mode)
2021
+
2022
+ $value = if ([string]::IsNullOrWhiteSpace($Mode)) { "core" } else { $Mode.Trim().ToLowerInvariant() }
2023
+ if (@("core", "recommended", "full") -notcontains $value) {
2024
+ return "core"
2025
+ }
2026
+
2027
+ return $value
2028
+ }
2029
+
2030
+ function ConvertTo-LowerUniqueStringArray {
2031
+ param([object]$Value)
2032
+
2033
+ $result = @()
2034
+ foreach ($item in @(ConvertTo-StringArray -Value $Value)) {
2035
+ $normalized = $item.Trim().ToLowerInvariant()
2036
+ if (-not [string]::IsNullOrWhiteSpace($normalized) -and $result -notcontains $normalized) {
2037
+ $result += $normalized
2038
+ }
2039
+ }
2040
+
2041
+ return $result
2042
+ }
2043
+
2044
+ function Invoke-ContextLintPrecheck {
2045
+ <#
2046
+ 对需要上下文导航的任务执行内容级门禁,避免在缺少项目导航索引时直接实现。
2047
+ #>
2048
+ param([string]$Root)
2049
+
2050
+ $contextLintPath = Join-Path $Root "tools\harness\context-lint.ps1"
2051
+ if (-not (Test-Path -LiteralPath $contextLintPath)) {
2052
+ throw "找不到 context lint: $contextLintPath"
2053
+ }
2054
+
2055
+ Push-Location $Root
2056
+ try {
2057
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\context-lint.ps1 -ProjectRoot . 2>&1
2058
+ $exitCode = $LASTEXITCODE
2059
+ return [PSCustomObject]@{
2060
+ ExitCode = $exitCode
2061
+ Output = ($output -join "`n")
2062
+ }
2063
+ }
2064
+ finally {
2065
+ Pop-Location
2066
+ }
2067
+ }
2068
+
2069
+ function Invoke-ArchitectureLintPrecheck {
2070
+ <#
2071
+ 对需要架构门禁的任务执行轻量架构模板检查,避免缺少分层/复用/边界约束就进入实现。
2072
+ #>
2073
+ param([string]$Root)
2074
+
2075
+ $architectureLintPath = Join-Path $Root "tools\harness\architecture-lint.ps1"
2076
+ if (-not (Test-Path -LiteralPath $architectureLintPath)) {
2077
+ throw "找不到 architecture lint: $architectureLintPath"
2078
+ }
2079
+
2080
+ Push-Location $Root
2081
+ try {
2082
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\architecture-lint.ps1 -ProjectRoot . 2>&1
2083
+ $exitCode = $LASTEXITCODE
2084
+ return [PSCustomObject]@{
2085
+ ExitCode = $exitCode
2086
+ Output = ($output -join "`n")
2087
+ }
2088
+ }
2089
+ finally {
2090
+ Pop-Location
2091
+ }
2092
+ }
2093
+
2094
+ function Invoke-DirectoryLintPrecheck {
2095
+ <#
2096
+ 对需要目录结构规则的任务执行轻量目录模板检查,避免在缺少目录规范时直接实现。
2097
+ #>
2098
+ param([string]$Root)
2099
+
2100
+ $directoryLintPath = Join-Path $Root "tools\harness\directory-lint.ps1"
2101
+ if (-not (Test-Path -LiteralPath $directoryLintPath)) {
2102
+ throw "找不到 directory lint: $directoryLintPath"
2103
+ }
2104
+
2105
+ Push-Location $Root
2106
+ try {
2107
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\directory-lint.ps1 -ProjectRoot . 2>&1
2108
+ $exitCode = $LASTEXITCODE
2109
+ return [PSCustomObject]@{
2110
+ ExitCode = $exitCode
2111
+ Output = ($output -join "`n")
2112
+ }
2113
+ }
2114
+ finally {
2115
+ Pop-Location
2116
+ }
2117
+ }
2118
+
2119
+ function Invoke-StyleLintPrecheck {
2120
+ <#
2121
+ 对需要代码风格与命名规则的任务执行轻量模板检查,避免缺少业务词典和命名边界时直接实现。
2122
+ #>
2123
+ param([string]$Root)
2124
+
2125
+ $styleLintPath = Join-Path $Root "tools\harness\style-lint.ps1"
2126
+ if (-not (Test-Path -LiteralPath $styleLintPath)) {
2127
+ throw "找不到 style lint: $styleLintPath"
2128
+ }
2129
+
2130
+ Push-Location $Root
2131
+ try {
2132
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\style-lint.ps1 -ProjectRoot . 2>&1
2133
+ $exitCode = $LASTEXITCODE
2134
+ return [PSCustomObject]@{
2135
+ ExitCode = $exitCode
2136
+ Output = ($output -join "`n")
2137
+ }
2138
+ }
2139
+ finally {
2140
+ Pop-Location
2141
+ }
2142
+ }
2143
+
2144
+ function Invoke-ComponentLintPrecheck {
2145
+ <#
2146
+ 对需要公共组件复用规则的任务执行轻量模板检查,避免没盘点组件和兼容影响就直接实现。
2147
+ #>
2148
+ param([string]$Root)
2149
+
2150
+ $componentLintPath = Join-Path $Root "tools\harness\component-lint.ps1"
2151
+ if (-not (Test-Path -LiteralPath $componentLintPath)) {
2152
+ throw "找不到 component lint: $componentLintPath"
2153
+ }
2154
+
2155
+ Push-Location $Root
2156
+ try {
2157
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\component-lint.ps1 -ProjectRoot . 2>&1
2158
+ $exitCode = $LASTEXITCODE
2159
+ return [PSCustomObject]@{
2160
+ ExitCode = $exitCode
2161
+ Output = ($output -join "`n")
2162
+ }
2163
+ }
2164
+ finally {
2165
+ Pop-Location
2166
+ }
2167
+ }
2168
+
2169
+ function Invoke-BusinessLintPrecheck {
2170
+ <#
2171
+ 对需要业务规则一致性的任务执行轻量模板检查,避免缺少业务规则、边界状态和异常路径约束就直接实现。
2172
+ #>
2173
+ param([string]$Root)
2174
+
2175
+ $businessLintPath = Join-Path $Root "tools\harness\business-lint.ps1"
2176
+ if (-not (Test-Path -LiteralPath $businessLintPath)) {
2177
+ throw "找不到 business lint: $businessLintPath"
2178
+ }
2179
+
2180
+ Push-Location $Root
2181
+ try {
2182
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\business-lint.ps1 -ProjectRoot . 2>&1
2183
+ $exitCode = $LASTEXITCODE
2184
+ return [PSCustomObject]@{
2185
+ ExitCode = $exitCode
2186
+ Output = ($output -join "`n")
2187
+ }
2188
+ }
2189
+ finally {
2190
+ Pop-Location
2191
+ }
2192
+ }
2193
+
2194
+ function Invoke-ContractLintPrecheck {
2195
+ <#
2196
+ 对需要接口与数据结构约束的任务执行轻量模板检查,避免缺少请求入口、响应包装和契约追溯时直接实现。
2197
+ #>
2198
+ param([string]$Root)
2199
+
2200
+ $contractLintPath = Join-Path $Root "tools\harness\contract-lint.ps1"
2201
+ if (-not (Test-Path -LiteralPath $contractLintPath)) {
2202
+ throw "找不到 contract lint: $contractLintPath"
2203
+ }
2204
+
2205
+ Push-Location $Root
2206
+ try {
2207
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\contract-lint.ps1 -ProjectRoot . 2>&1
2208
+ $exitCode = $LASTEXITCODE
2209
+ return [PSCustomObject]@{
2210
+ ExitCode = $exitCode
2211
+ Output = ($output -join "`n")
2212
+ }
2213
+ }
2214
+ finally {
2215
+ Pop-Location
2216
+ }
2217
+ }
2218
+
2219
+ function Invoke-StateLintPrecheck {
2220
+ <#
2221
+ 对需要状态管理一致性的任务执行轻量模板检查,避免缺少状态分层、唯一来源和缓存失效规则时直接实现。
2222
+ #>
2223
+ param([string]$Root)
2224
+
2225
+ $stateLintPath = Join-Path $Root "tools\harness\state-lint.ps1"
2226
+ if (-not (Test-Path -LiteralPath $stateLintPath)) {
2227
+ throw "找不到 state lint: $stateLintPath"
2228
+ }
2229
+
2230
+ Push-Location $Root
2231
+ try {
2232
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\state-lint.ps1 -ProjectRoot . 2>&1
2233
+ $exitCode = $LASTEXITCODE
2234
+ return [PSCustomObject]@{
2235
+ ExitCode = $exitCode
2236
+ Output = ($output -join "`n")
2237
+ }
2238
+ }
2239
+ finally {
2240
+ Pop-Location
2241
+ }
2242
+ }
2243
+
2244
+ function Invoke-UiLintPrecheck {
2245
+ <#
2246
+ 对需要前端 UI 与交互质量约束的任务执行轻量模板检查,避免缺少设计系统、移动端和表单体验规则时直接实现。
2247
+ #>
2248
+ param([string]$Root)
2249
+
2250
+ $uiLintPath = Join-Path $Root "tools\harness\ui-lint.ps1"
2251
+ if (-not (Test-Path -LiteralPath $uiLintPath)) {
2252
+ throw "找不到 ui lint: $uiLintPath"
2253
+ }
2254
+
2255
+ Push-Location $Root
2256
+ try {
2257
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\ui-lint.ps1 -ProjectRoot . 2>&1
2258
+ $exitCode = $LASTEXITCODE
2259
+ return [PSCustomObject]@{
2260
+ ExitCode = $exitCode
2261
+ Output = ($output -join "`n")
2262
+ }
2263
+ }
2264
+ finally {
2265
+ Pop-Location
2266
+ }
2267
+ }
2268
+
2269
+ function Invoke-BackendLintPrecheck {
2270
+ <#
2271
+ 对需要后端服务分层质量约束的任务执行轻量模板检查,避免缺少 Controller/Service/Repository、事务和异常策略时直接实现。
2272
+ #>
2273
+ param([string]$Root)
2274
+
2275
+ $backendLintPath = Join-Path $Root "tools\harness\backend-lint.ps1"
2276
+ if (-not (Test-Path -LiteralPath $backendLintPath)) {
2277
+ throw "找不到 backend lint: $backendLintPath"
2278
+ }
2279
+
2280
+ Push-Location $Root
2281
+ try {
2282
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\backend-lint.ps1 -ProjectRoot . 2>&1
2283
+ $exitCode = $LASTEXITCODE
2284
+ return [PSCustomObject]@{
2285
+ ExitCode = $exitCode
2286
+ Output = ($output -join "`n")
2287
+ }
2288
+ }
2289
+ finally {
2290
+ Pop-Location
2291
+ }
2292
+ }
2293
+
2294
+ function Invoke-SecurityLintPrecheck {
2295
+ <#
2296
+ 对需要安全设计约束的任务执行轻量模板检查,避免缺少权限、输入校验、脱敏和风控策略时直接实现。
2297
+ #>
2298
+ param([string]$Root)
2299
+
2300
+ $securityLintPath = Join-Path $Root "tools\harness\security-lint.ps1"
2301
+ if (-not (Test-Path -LiteralPath $securityLintPath)) {
2302
+ throw "找不到 security lint: $securityLintPath"
2303
+ }
2304
+
2305
+ Push-Location $Root
2306
+ try {
2307
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\security-lint.ps1 -ProjectRoot . 2>&1
2308
+ $exitCode = $LASTEXITCODE
2309
+ return [PSCustomObject]@{
2310
+ ExitCode = $exitCode
2311
+ Output = ($output -join "`n")
2312
+ }
2313
+ }
2314
+ finally {
2315
+ Pop-Location
2316
+ }
2317
+ }
2318
+
2319
+ function Invoke-TestingLintPrecheck {
2320
+ <#
2321
+ 对需要测试左移和验证完整性的任务执行轻量模板检查,避免缺少测试真相源时直接实现。
2322
+ #>
2323
+ param([string]$Root)
2324
+
2325
+ $testingLintPath = Join-Path $Root "tools\harness\testing-lint.ps1"
2326
+ if (-not (Test-Path -LiteralPath $testingLintPath)) {
2327
+ throw "找不到 testing lint: $testingLintPath"
2328
+ }
2329
+
2330
+ Push-Location $Root
2331
+ try {
2332
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\testing-lint.ps1 -ProjectRoot . 2>&1
2333
+ $exitCode = $LASTEXITCODE
2334
+ return [PSCustomObject]@{
2335
+ ExitCode = $exitCode
2336
+ Output = ($output -join "`n")
2337
+ }
2338
+ }
2339
+ finally {
2340
+ Pop-Location
2341
+ }
2342
+ }
2343
+
2344
+ function Invoke-ImpactLintPrecheck {
2345
+ <#
2346
+ 对需要影响面分析的任务执行轻量模板检查,避免缺少调用链、受影响对象和回归范围时直接实现。
2347
+ #>
2348
+ param([string]$Root)
2349
+
2350
+ $impactLintPath = Join-Path $Root "tools\harness\impact-lint.ps1"
2351
+ if (-not (Test-Path -LiteralPath $impactLintPath)) {
2352
+ throw "找不到 impact lint: $impactLintPath"
2353
+ }
2354
+
2355
+ Push-Location $Root
2356
+ try {
2357
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\impact-lint.ps1 -ProjectRoot . 2>&1
2358
+ $exitCode = $LASTEXITCODE
2359
+ return [PSCustomObject]@{
2360
+ ExitCode = $exitCode
2361
+ Output = ($output -join "`n")
2362
+ }
2363
+ }
2364
+ finally {
2365
+ Pop-Location
2366
+ }
2367
+ }
2368
+
2369
+ function Invoke-PerformanceLintPrecheck {
2370
+ <#
2371
+ 对需要性能预算与性能风险约束的任务执行轻量模板检查,避免缺少性能预算时直接实现。
2372
+ #>
2373
+ param([string]$Root)
2374
+
2375
+ $performanceLintPath = Join-Path $Root "tools\harness\performance-lint.ps1"
2376
+ if (-not (Test-Path -LiteralPath $performanceLintPath)) {
2377
+ throw "找不到 performance lint: $performanceLintPath"
2378
+ }
2379
+
2380
+ Push-Location $Root
2381
+ try {
2382
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\performance-lint.ps1 -ProjectRoot . 2>&1
2383
+ $exitCode = $LASTEXITCODE
2384
+ return [PSCustomObject]@{
2385
+ ExitCode = $exitCode
2386
+ Output = ($output -join "`n")
2387
+ }
2388
+ }
2389
+ finally {
2390
+ Pop-Location
2391
+ }
2392
+ }
2393
+
2394
+ function Invoke-ConfigLintPrecheck {
2395
+ <#
2396
+ 对需要配置与环境约束的任务执行轻量模板检查,避免缺少环境变量、构建和部署说明时直接实现。
2397
+ #>
2398
+ param([string]$Root)
2399
+
2400
+ $configLintPath = Join-Path $Root "tools\harness\config-lint.ps1"
2401
+ if (-not (Test-Path -LiteralPath $configLintPath)) {
2402
+ throw "找不到 config lint: $configLintPath"
2403
+ }
2404
+
2405
+ Push-Location $Root
2406
+ try {
2407
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\config-lint.ps1 -ProjectRoot . 2>&1
2408
+ $exitCode = $LASTEXITCODE
2409
+ return [PSCustomObject]@{
2410
+ ExitCode = $exitCode
2411
+ Output = ($output -join "`n")
2412
+ }
2413
+ }
2414
+ finally {
2415
+ Pop-Location
2416
+ }
2417
+ }
2418
+
2419
+ function Invoke-ObservabilityLintPrecheck {
2420
+ <#
2421
+ 对需要日志与可观测性约束的任务执行轻量模板检查,避免缺少日志字段、审计和告警说明时直接实现。
2422
+ #>
2423
+ param([string]$Root)
2424
+
2425
+ $observabilityLintPath = Join-Path $Root "tools\harness\observability-lint.ps1"
2426
+ if (-not (Test-Path -LiteralPath $observabilityLintPath)) {
2427
+ throw "找不到 observability lint: $observabilityLintPath"
2428
+ }
2429
+
2430
+ Push-Location $Root
2431
+ try {
2432
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\observability-lint.ps1 -ProjectRoot . 2>&1
2433
+ $exitCode = $LASTEXITCODE
2434
+ return [PSCustomObject]@{
2435
+ ExitCode = $exitCode
2436
+ Output = ($output -join "`n")
2437
+ }
2438
+ }
2439
+ finally {
2440
+ Pop-Location
2441
+ }
2442
+ }
2443
+
2444
+ function Invoke-RefactorLintPrecheck {
2445
+ <#
2446
+ 对需要重构与维护约束的任务执行轻量模板检查,避免缺少任务类型、行为不变约束和死代码清理范围时直接实现。
2447
+ #>
2448
+ param([string]$Root)
2449
+
2450
+ $refactorLintPath = Join-Path $Root "tools\harness\refactor-lint.ps1"
2451
+ if (-not (Test-Path -LiteralPath $refactorLintPath)) {
2452
+ throw "找不到 refactor lint: $refactorLintPath"
2453
+ }
2454
+
2455
+ Push-Location $Root
2456
+ try {
2457
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\refactor-lint.ps1 -ProjectRoot . 2>&1
2458
+ $exitCode = $LASTEXITCODE
2459
+ return [PSCustomObject]@{
2460
+ ExitCode = $exitCode
2461
+ Output = ($output -join "`n")
2462
+ }
2463
+ }
2464
+ finally {
2465
+ Pop-Location
2466
+ }
2467
+ }
2468
+
2469
+ function Invoke-SessionLintPrecheck {
2470
+ <#
2471
+ 对需要多轮协作与交接约束的任务执行轻量模板检查,避免缺少会话交接字段和同文件隔离规则时直接实现。
2472
+ #>
2473
+ param([string]$Root)
2474
+
2475
+ $sessionLintPath = Join-Path $Root "tools\harness\session-lint.ps1"
2476
+ if (-not (Test-Path -LiteralPath $sessionLintPath)) {
2477
+ throw "找不到 session lint: $sessionLintPath"
2478
+ }
2479
+
2480
+ Push-Location $Root
2481
+ try {
2482
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\session-lint.ps1 -ProjectRoot . 2>&1
2483
+ $exitCode = $LASTEXITCODE
2484
+ return [PSCustomObject]@{
2485
+ ExitCode = $exitCode
2486
+ Output = ($output -join "`n")
2487
+ }
2488
+ }
2489
+ finally {
2490
+ Pop-Location
2491
+ }
2492
+ }
2493
+
2494
+ function Invoke-DocsLintPrecheck {
2495
+ <#
2496
+ 对需要文档与规范约束的任务执行轻量模板检查,避免核心文档集和文档更新字段缺失时直接实现。
2497
+ #>
2498
+ param([string]$Root)
2499
+
2500
+ $docsLintPath = Join-Path $Root "tools\harness\docs-lint.ps1"
2501
+ if (-not (Test-Path -LiteralPath $docsLintPath)) {
2502
+ throw "找不到 docs lint: $docsLintPath"
2503
+ }
2504
+
2505
+ Push-Location $Root
2506
+ try {
2507
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\docs-lint.ps1 -ProjectRoot . 2>&1
2508
+ $exitCode = $LASTEXITCODE
2509
+ return [PSCustomObject]@{ ExitCode = $exitCode; Output = ($output -join "`n") }
2510
+ }
2511
+ finally {
2512
+ Pop-Location
2513
+ }
2514
+ }
2515
+
2516
+ function Invoke-DataLintPrecheck {
2517
+ <#
2518
+ 对需要数据库与迁移约束的任务执行轻量模板检查,避免缺少 migration、历史数据和回滚口径时直接实现。
2519
+ #>
2520
+ param([string]$Root)
2521
+
2522
+ $dataLintPath = Join-Path $Root "tools\harness\data-lint.ps1"
2523
+ if (-not (Test-Path -LiteralPath $dataLintPath)) {
2524
+ throw "找不到 data lint: $dataLintPath"
2525
+ }
2526
+
2527
+ Push-Location $Root
2528
+ try {
2529
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\data-lint.ps1 -ProjectRoot . 2>&1
2530
+ $exitCode = $LASTEXITCODE
2531
+ return [PSCustomObject]@{ ExitCode = $exitCode; Output = ($output -join "`n") }
2532
+ }
2533
+ finally {
2534
+ Pop-Location
2535
+ }
2536
+ }
2537
+
2538
+ function Invoke-IntegrationLintPrecheck {
2539
+ <#
2540
+ 对需要第三方服务集成约束的任务执行轻量模板检查,避免缺少回调、凭据和失败策略时直接实现。
2541
+ #>
2542
+ param([string]$Root)
2543
+
2544
+ $integrationLintPath = Join-Path $Root "tools\harness\integration-lint.ps1"
2545
+ if (-not (Test-Path -LiteralPath $integrationLintPath)) {
2546
+ throw "找不到 integration lint: $integrationLintPath"
2547
+ }
2548
+
2549
+ Push-Location $Root
2550
+ try {
2551
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\integration-lint.ps1 -ProjectRoot . 2>&1
2552
+ $exitCode = $LASTEXITCODE
2553
+ return [PSCustomObject]@{ ExitCode = $exitCode; Output = ($output -join "`n") }
2554
+ }
2555
+ finally {
2556
+ Pop-Location
2557
+ }
2558
+ }
2559
+
2560
+ function Invoke-MobileLintPrecheck {
2561
+ <#
2562
+ 对需要移动端专项约束的任务执行轻量模板检查,避免缺少平台差异、权限和生命周期口径时直接实现。
2563
+ #>
2564
+ param([string]$Root)
2565
+
2566
+ $mobileLintPath = Join-Path $Root "tools\harness\mobile-lint.ps1"
2567
+ if (-not (Test-Path -LiteralPath $mobileLintPath)) {
2568
+ throw "找不到 mobile lint: $mobileLintPath"
2569
+ }
2570
+
2571
+ Push-Location $Root
2572
+ try {
2573
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\mobile-lint.ps1 -ProjectRoot . 2>&1
2574
+ $exitCode = $LASTEXITCODE
2575
+ return [PSCustomObject]@{ ExitCode = $exitCode; Output = ($output -join "`n") }
2576
+ }
2577
+ finally {
2578
+ Pop-Location
2579
+ }
2580
+ }
2581
+
2582
+ function Invoke-AcceptanceLintPrecheck {
2583
+ <#
2584
+ 对需要交付验收报告约束的任务执行轻量模板检查,避免缺少需求对照和回滚信息时直接实现。
2585
+ #>
2586
+ param([string]$Root)
2587
+
2588
+ $acceptanceLintPath = Join-Path $Root "tools\harness\acceptance-lint.ps1"
2589
+ if (-not (Test-Path -LiteralPath $acceptanceLintPath)) {
2590
+ throw "找不到 acceptance lint: $acceptanceLintPath"
2591
+ }
2592
+
2593
+ Push-Location $Root
2594
+ try {
2595
+ $output = powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\harness\acceptance-lint.ps1 -ProjectRoot . 2>&1
2596
+ $exitCode = $LASTEXITCODE
2597
+ return [PSCustomObject]@{ ExitCode = $exitCode; Output = ($output -join "`n") }
2598
+ }
2599
+ finally {
2600
+ Pop-Location
2601
+ }
2602
+ }
2603
+
2604
+ function Invoke-FailureTriage {
2605
+ <#
2606
+ 在测试失败后运行只读失败归因链路,输出结构化 triage 结果。
2607
+ #>
2608
+ param(
2609
+ [object]$Task,
2610
+ [string]$Root,
2611
+ [object]$ExecutionPolicy,
2612
+ [object]$ReviewContext,
2613
+ [object]$CodexResult,
2614
+ [object]$Stage1Result,
2615
+ [object]$TestResult,
2616
+ [string]$CodexCommand,
2617
+ [string]$LogDirectory,
2618
+ [switch]$CaptureJsonEvents
2619
+ )
2620
+
2621
+ $template = Get-PromptTemplate -Root $Root -TemplateName "failure-triage.md"
2622
+ $requirementIdsText = ConvertTo-BulletLines -Items (ConvertTo-StringArray -Value (Get-ObjectPropertyValue -InputObject $Task -Name "requirement_ids")) -EmptyText "- 未显式声明 Requirement IDs"
2623
+ $acceptanceText = ConvertTo-BulletLines -Items (ConvertTo-StringArray -Value $Task.acceptance)
2624
+ $contextFilesText = ConvertTo-BulletLines -Items $ReviewContext.task_context
2625
+ $testingText = ConvertTo-BulletLines -Items $ReviewContext.testing
2626
+ $truthSourceStateText = Convert-TruthSourceStateToBulletLines -States $ReviewContext.truth_source_state
2627
+ $triageOutputPath = Join-Path $LogDirectory "$($Task.id)-failure-triage.json"
2628
+ $testOutputPathText = if ([string]::IsNullOrWhiteSpace($TestResult.OutputLog)) { "- 无测试日志文件" } else { "- $($TestResult.OutputLog)" }
2629
+
2630
+ $prompt = @"
2631
+ $template
2632
+
2633
+ ## Driver Context
2634
+
2635
+ - Task ID: $($Task.id)
2636
+ - 描述: $($Task.description)
2637
+ - Requirement IDs:
2638
+ $requirementIdsText
2639
+ - 验收标准:
2640
+ $acceptanceText
2641
+ - 失败来源: test
2642
+ - 测试命令: $($Task.test_command)
2643
+ - 测试退出码: $($TestResult.ExitCode)
2644
+
2645
+ ### Task Context Files
2646
+ $contextFilesText
2647
+
2648
+ ### Testing Truth Sources
2649
+ $testingText
2650
+
2651
+ ### Truth Source Completeness
2652
+ $truthSourceStateText
2653
+
2654
+ ### Evidence Files
2655
+ - 实现 stdout: $($CodexResult.StdoutLog)
2656
+ - 实现 stderr: $($CodexResult.StderrLog)
2657
+ - Stage 1 stdout: $($Stage1Result.StdoutLog)
2658
+ - Stage 1 stderr: $($Stage1Result.StderrLog)
2659
+ $testOutputPathText
2660
+
2661
+ ### Raw Test Output
2662
+ ```text
2663
+ $($TestResult.Output)
2664
+ ```
2665
+
2666
+ 输出要求:
2667
+ - 只输出一个合法 JSON 对象。
2668
+ - 必须包含 findings 数组;没有 finding 也要输出空数组。
2669
+ - 优先把失败归类为 `TEST_CODE_ISSUE`、`PRODUCT_BUG`、`REQUIREMENT_CHANGE`、`ENV_OR_DATA_ISSUE` 或 `FLAKY`。
2670
+ "@
2671
+
2672
+ $triageResult = Invoke-CodexTask `
2673
+ -Prompt $prompt `
2674
+ -Root $Root `
2675
+ -Command $CodexCommand `
2676
+ -LogDirectory $LogDirectory `
2677
+ -TaskId "$($Task.id)-failure-triage" `
2678
+ -Sandbox $ExecutionPolicy.codex.review_sandbox `
2679
+ -ActivityLabel "Failure Triage" `
2680
+ -DisableHooks $ExecutionPolicy.codex.disable_hooks `
2681
+ -CaptureJsonEvents:$CaptureJsonEvents
2682
+
2683
+ $triageJson = $triageResult.Output
2684
+ if ([string]::IsNullOrWhiteSpace($triageJson)) {
2685
+ $triageJson = $triageResult.LastMessage
2686
+ }
2687
+
2688
+ $reportPath = $null
2689
+ $parseError = $null
2690
+ if (-not [string]::IsNullOrWhiteSpace($triageJson)) {
2691
+ try {
2692
+ $triageObject = $triageJson | ConvertFrom-Json -ErrorAction Stop
2693
+ $triageObject | ConvertTo-Json -Depth 12 | Set-Content -LiteralPath $triageOutputPath -Encoding UTF8
2694
+ $reportPath = $triageOutputPath
2695
+ }
2696
+ catch {
2697
+ $parseError = $_.Exception.Message
2698
+ }
2699
+ }
2700
+
2701
+ return [PSCustomObject]@{
2702
+ ExitCode = $triageResult.ExitCode
2703
+ Output = $triageResult.Output
2704
+ LastMessage = $triageResult.LastMessage
2705
+ StdoutLog = $triageResult.StdoutLog
2706
+ StderrLog = $triageResult.StderrLog
2707
+ PromptLog = $triageResult.PromptLog
2708
+ LastMessageLog = $triageResult.LastMessageLog
2709
+ ReportPath = $reportPath
2710
+ ParseError = $parseError
2711
+ }
2712
+ }
1878
2713
 
1879
2714
  function Write-ProgressEntry {
1880
2715
  <#
@@ -2027,7 +2862,7 @@ function Invoke-OneTask {
2027
2862
  }
2028
2863
 
2029
2864
  $initialReviewContext = Get-ReviewContextPaths -Root $ProjectRoot -ExecutionPolicy $executionPolicy
2030
- if ($executionPolicy.gate_profile -ne "lightweight" -and $initialReviewContext.missing_truth_sources.Count -gt 0) {
2865
+ if ($executionPolicy.gate_profile -ne "lightweight" -and $initialReviewContext.missing_truth_sources.Count -gt 0) {
2031
2866
  $truthSourceSummary = Convert-TruthSourceStateToBulletLines -States $initialReviewContext.truth_source_state
2032
2867
  $blockedReason = "缺少前置 truth sources: $($initialReviewContext.missing_truth_sources -join ', ')"
2033
2868
  Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,前置 truth source 检查未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$truthSourceSummary" -Stage1Summary "NOT_RUN - truth source precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
@@ -2072,10 +2907,1073 @@ function Invoke-OneTask {
2072
2907
  Status = "blocked"
2073
2908
  TaskId = $task.id
2074
2909
  ExitCode = 2
2075
- }
2076
- }
2077
-
2078
- Write-Step "选择任务: $($task.id) $($task.description)"
2910
+ }
2911
+ }
2912
+
2913
+ $needsSpecLint = @("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile
2914
+ if ($needsSpecLint) {
2915
+ $specLintResult = Invoke-SpecLintPrecheck -Root $ProjectRoot
2916
+ if ($specLintResult.ExitCode -ne 0) {
2917
+ $blockedReason = "spec 内容级门禁未通过,请先补齐需求范围、验收标准、边界与追溯。"
2918
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,spec 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($specLintResult.Output)" -Stage1Summary "NOT_RUN - spec lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
2919
+ $tracePayload = [PSCustomObject]@{
2920
+ task_id = $task.id
2921
+ task_session_id = $taskSessionId
2922
+ task_kind = $executionPolicy.task_kind
2923
+ gate_profile = $executionPolicy.gate_profile
2924
+ required_truth_sources = $executionPolicy.required_truth_sources
2925
+ agent = "codex"
2926
+ started_at = $startedAt.ToString("o")
2927
+ ended_at = (Get-Date).ToString("o")
2928
+ status = "blocked"
2929
+ test_command = $task.test_command
2930
+ failed_stage = "spec_lint_precheck"
2931
+ stage1_review = [PSCustomObject]@{
2932
+ verdict = "NOT_RUN"
2933
+ exit_code = $null
2934
+ summary = "spec lint precheck 未通过。"
2935
+ }
2936
+ stage2_review = [PSCustomObject]@{
2937
+ verdict = "NOT_RUN"
2938
+ exit_code = $null
2939
+ summary = "未进入 Stage 2 审查。"
2940
+ }
2941
+ session_policy = $executionPolicy.session
2942
+ subagent_policy = $executionPolicy.subagents
2943
+ context_files = $executionPolicy.context_files
2944
+ run_profile_path = $executionPolicy.run_profile_path
2945
+ review_context = $initialReviewContext
2946
+ commands = @(@{ cmd = "spec_lint_precheck"; exit_code = $specLintResult.ExitCode })
2947
+ blocked_reason = $blockedReason
2948
+ final_message = $blockedReason
2949
+ logs = @{
2950
+ spec_lint = $specLintResult.Output
2951
+ }
2952
+ }
2953
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
2954
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
2955
+ Write-Step "BLOCKED: spec 内容级门禁未通过。"
2956
+ Write-Output $specLintResult.Output
2957
+ return [PSCustomObject]@{
2958
+ Status = "blocked"
2959
+ TaskId = $task.id
2960
+ ExitCode = 2
2961
+ }
2962
+ }
2963
+ }
2964
+
2965
+ $needsContextLint = @("research_required", "spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile
2966
+ if ($needsContextLint) {
2967
+ $contextLintResult = Invoke-ContextLintPrecheck -Root $ProjectRoot
2968
+ if ($contextLintResult.ExitCode -eq 1) {
2969
+ $blockedReason = "context 内容级门禁未通过,请先补齐 docs/ai 导航索引与当前任务上下文。"
2970
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,context 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($contextLintResult.Output)" -Stage1Summary "NOT_RUN - context lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
2971
+ $tracePayload = [PSCustomObject]@{
2972
+ task_id = $task.id
2973
+ task_session_id = $taskSessionId
2974
+ task_kind = $executionPolicy.task_kind
2975
+ gate_profile = $executionPolicy.gate_profile
2976
+ required_truth_sources = $executionPolicy.required_truth_sources
2977
+ agent = "codex"
2978
+ started_at = $startedAt.ToString("o")
2979
+ ended_at = (Get-Date).ToString("o")
2980
+ status = "blocked"
2981
+ test_command = $task.test_command
2982
+ failed_stage = "context_lint_precheck"
2983
+ stage1_review = [PSCustomObject]@{
2984
+ verdict = "NOT_RUN"
2985
+ exit_code = $null
2986
+ summary = "context lint precheck 未通过。"
2987
+ }
2988
+ stage2_review = [PSCustomObject]@{
2989
+ verdict = "NOT_RUN"
2990
+ exit_code = $null
2991
+ summary = "未进入 Stage 2 审查。"
2992
+ }
2993
+ session_policy = $executionPolicy.session
2994
+ subagent_policy = $executionPolicy.subagents
2995
+ context_files = $executionPolicy.context_files
2996
+ run_profile_path = $executionPolicy.run_profile_path
2997
+ review_context = $initialReviewContext
2998
+ commands = @(@{ cmd = "context_lint_precheck"; exit_code = $contextLintResult.ExitCode })
2999
+ blocked_reason = $blockedReason
3000
+ final_message = $blockedReason
3001
+ logs = @{
3002
+ context_lint = $contextLintResult.Output
3003
+ }
3004
+ }
3005
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3006
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3007
+ Write-Step "BLOCKED: context 内容级门禁未通过。"
3008
+ Write-Output $contextLintResult.Output
3009
+ return [PSCustomObject]@{
3010
+ Status = "blocked"
3011
+ TaskId = $task.id
3012
+ ExitCode = 2
3013
+ }
3014
+ }
3015
+ }
3016
+
3017
+ $needsSessionLint = @("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile
3018
+ if ($needsSessionLint) {
3019
+ $sessionLintResult = Invoke-SessionLintPrecheck -Root $ProjectRoot
3020
+ if ($sessionLintResult.ExitCode -eq 1) {
3021
+ $blockedReason = "session 内容级门禁未通过,请先补齐 CURRENT_TASK 交接字段和多 Agent 同文件隔离规则。"
3022
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,session 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($sessionLintResult.Output)" -Stage1Summary "NOT_RUN - session lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3023
+ $tracePayload = [PSCustomObject]@{
3024
+ task_id = $task.id
3025
+ task_session_id = $taskSessionId
3026
+ task_kind = $executionPolicy.task_kind
3027
+ gate_profile = $executionPolicy.gate_profile
3028
+ required_truth_sources = $executionPolicy.required_truth_sources
3029
+ agent = "codex"
3030
+ started_at = $startedAt.ToString("o")
3031
+ ended_at = (Get-Date).ToString("o")
3032
+ status = "blocked"
3033
+ test_command = $task.test_command
3034
+ failed_stage = "session_lint_precheck"
3035
+ stage1_review = [PSCustomObject]@{
3036
+ verdict = "NOT_RUN"
3037
+ exit_code = $null
3038
+ summary = "session lint precheck 未通过。"
3039
+ }
3040
+ stage2_review = [PSCustomObject]@{
3041
+ verdict = "NOT_RUN"
3042
+ exit_code = $null
3043
+ summary = "未进入 Stage 2 审查。"
3044
+ }
3045
+ session_policy = $executionPolicy.session
3046
+ subagent_policy = $executionPolicy.subagents
3047
+ context_files = $executionPolicy.context_files
3048
+ run_profile_path = $executionPolicy.run_profile_path
3049
+ review_context = $initialReviewContext
3050
+ commands = @(@{ cmd = "session_lint_precheck"; exit_code = $sessionLintResult.ExitCode })
3051
+ blocked_reason = $blockedReason
3052
+ final_message = $blockedReason
3053
+ logs = @{
3054
+ session_lint = $sessionLintResult.Output
3055
+ }
3056
+ }
3057
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3058
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3059
+ Write-Step "BLOCKED: session 内容级门禁未通过。"
3060
+ Write-Output $sessionLintResult.Output
3061
+ return [PSCustomObject]@{
3062
+ Status = "blocked"
3063
+ TaskId = $task.id
3064
+ ExitCode = 2
3065
+ }
3066
+ }
3067
+ }
3068
+
3069
+ $needsDocsLint = (Test-ContentGateModeEnabled -ExecutionPolicy $executionPolicy -MinimumMode "recommended") -and (@("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile)
3070
+ if ($needsDocsLint) {
3071
+ $docsLintResult = Invoke-DocsLintPrecheck -Root $ProjectRoot
3072
+ if ($docsLintResult.ExitCode -eq 1) {
3073
+ $blockedReason = "docs 内容级门禁未通过,请先补齐核心文档集、文档分层入口和文档更新字段。"
3074
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,docs 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($docsLintResult.Output)" -Stage1Summary "NOT_RUN - docs lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3075
+ $tracePayload = [PSCustomObject]@{ task_id = $task.id; task_session_id = $taskSessionId; task_kind = $executionPolicy.task_kind; gate_profile = $executionPolicy.gate_profile; required_truth_sources = $executionPolicy.required_truth_sources; agent = "codex"; started_at = $startedAt.ToString("o"); ended_at = (Get-Date).ToString("o"); status = "blocked"; test_command = $task.test_command; failed_stage = "docs_lint_precheck"; stage1_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "docs lint precheck 未通过。" }; stage2_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "未进入 Stage 2 审查。" }; session_policy = $executionPolicy.session; subagent_policy = $executionPolicy.subagents; context_files = $executionPolicy.context_files; run_profile_path = $executionPolicy.run_profile_path; review_context = $initialReviewContext; commands = @(@{ cmd = "docs_lint_precheck"; exit_code = $docsLintResult.ExitCode }); blocked_reason = $blockedReason; final_message = $blockedReason; logs = @{ docs_lint = $docsLintResult.Output } }
3076
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3077
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3078
+ Write-Step "BLOCKED: docs 内容级门禁未通过。"
3079
+ Write-Output $docsLintResult.Output
3080
+ return [PSCustomObject]@{ Status = "blocked"; TaskId = $task.id; ExitCode = 2 }
3081
+ }
3082
+ }
3083
+
3084
+ $needsDataLint = Test-TaskHasRiskTag -ExecutionPolicy $executionPolicy -Tags @("data", "database", "migration")
3085
+ if ($needsDataLint) {
3086
+ $dataLintResult = Invoke-DataLintPrecheck -Root $ProjectRoot
3087
+ if ($dataLintResult.ExitCode -eq 1) {
3088
+ $blockedReason = "data 内容级门禁未通过,请先补齐 migration、历史数据兼容和回滚策略。"
3089
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,data 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($dataLintResult.Output)" -Stage1Summary "NOT_RUN - data lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3090
+ $tracePayload = [PSCustomObject]@{ task_id = $task.id; task_session_id = $taskSessionId; task_kind = $executionPolicy.task_kind; gate_profile = $executionPolicy.gate_profile; required_truth_sources = $executionPolicy.required_truth_sources; agent = "codex"; started_at = $startedAt.ToString("o"); ended_at = (Get-Date).ToString("o"); status = "blocked"; test_command = $task.test_command; failed_stage = "data_lint_precheck"; stage1_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "data lint precheck 未通过。" }; stage2_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "未进入 Stage 2 审查。" }; session_policy = $executionPolicy.session; subagent_policy = $executionPolicy.subagents; context_files = $executionPolicy.context_files; run_profile_path = $executionPolicy.run_profile_path; review_context = $initialReviewContext; commands = @(@{ cmd = "data_lint_precheck"; exit_code = $dataLintResult.ExitCode }); blocked_reason = $blockedReason; final_message = $blockedReason; logs = @{ data_lint = $dataLintResult.Output } }
3091
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3092
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3093
+ Write-Step "BLOCKED: data 内容级门禁未通过。"
3094
+ Write-Output $dataLintResult.Output
3095
+ return [PSCustomObject]@{ Status = "blocked"; TaskId = $task.id; ExitCode = 2 }
3096
+ }
3097
+ }
3098
+
3099
+ $needsIntegrationLint = Test-TaskHasRiskTag -ExecutionPolicy $executionPolicy -Tags @("integration", "third_party", "third-party", "external")
3100
+ if ($needsIntegrationLint) {
3101
+ $integrationLintResult = Invoke-IntegrationLintPrecheck -Root $ProjectRoot
3102
+ if ($integrationLintResult.ExitCode -eq 1) {
3103
+ $blockedReason = "integration 内容级门禁未通过,请先补齐第三方回调、凭据、重试和上传边界。"
3104
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,integration 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($integrationLintResult.Output)" -Stage1Summary "NOT_RUN - integration lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3105
+ $tracePayload = [PSCustomObject]@{ task_id = $task.id; task_session_id = $taskSessionId; task_kind = $executionPolicy.task_kind; gate_profile = $executionPolicy.gate_profile; required_truth_sources = $executionPolicy.required_truth_sources; agent = "codex"; started_at = $startedAt.ToString("o"); ended_at = (Get-Date).ToString("o"); status = "blocked"; test_command = $task.test_command; failed_stage = "integration_lint_precheck"; stage1_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "integration lint precheck 未通过。" }; stage2_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "未进入 Stage 2 审查。" }; session_policy = $executionPolicy.session; subagent_policy = $executionPolicy.subagents; context_files = $executionPolicy.context_files; run_profile_path = $executionPolicy.run_profile_path; review_context = $initialReviewContext; commands = @(@{ cmd = "integration_lint_precheck"; exit_code = $integrationLintResult.ExitCode }); blocked_reason = $blockedReason; final_message = $blockedReason; logs = @{ integration_lint = $integrationLintResult.Output } }
3106
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3107
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3108
+ Write-Step "BLOCKED: integration 内容级门禁未通过。"
3109
+ Write-Output $integrationLintResult.Output
3110
+ return [PSCustomObject]@{ Status = "blocked"; TaskId = $task.id; ExitCode = 2 }
3111
+ }
3112
+ }
3113
+
3114
+ $needsMobileLint = Test-TaskHasRiskTag -ExecutionPolicy $executionPolicy -Tags @("mobile", "app", "ios", "android", "h5", "miniapp")
3115
+ if ($needsMobileLint) {
3116
+ $mobileLintResult = Invoke-MobileLintPrecheck -Root $ProjectRoot
3117
+ if ($mobileLintResult.ExitCode -eq 1) {
3118
+ $blockedReason = "mobile 内容级门禁未通过,请先补齐平台差异、权限弹窗、生命周期和真机矩阵。"
3119
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,mobile 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($mobileLintResult.Output)" -Stage1Summary "NOT_RUN - mobile lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3120
+ $tracePayload = [PSCustomObject]@{ task_id = $task.id; task_session_id = $taskSessionId; task_kind = $executionPolicy.task_kind; gate_profile = $executionPolicy.gate_profile; required_truth_sources = $executionPolicy.required_truth_sources; agent = "codex"; started_at = $startedAt.ToString("o"); ended_at = (Get-Date).ToString("o"); status = "blocked"; test_command = $task.test_command; failed_stage = "mobile_lint_precheck"; stage1_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "mobile lint precheck 未通过。" }; stage2_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "未进入 Stage 2 审查。" }; session_policy = $executionPolicy.session; subagent_policy = $executionPolicy.subagents; context_files = $executionPolicy.context_files; run_profile_path = $executionPolicy.run_profile_path; review_context = $initialReviewContext; commands = @(@{ cmd = "mobile_lint_precheck"; exit_code = $mobileLintResult.ExitCode }); blocked_reason = $blockedReason; final_message = $blockedReason; logs = @{ mobile_lint = $mobileLintResult.Output } }
3121
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3122
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3123
+ Write-Step "BLOCKED: mobile 内容级门禁未通过。"
3124
+ Write-Output $mobileLintResult.Output
3125
+ return [PSCustomObject]@{ Status = "blocked"; TaskId = $task.id; ExitCode = 2 }
3126
+ }
3127
+ }
3128
+
3129
+ $needsAcceptanceLint = (Test-ContentGateModeEnabled -ExecutionPolicy $executionPolicy -MinimumMode "recommended") -and (@("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile)
3130
+ if ($needsAcceptanceLint) {
3131
+ $acceptanceLintResult = Invoke-AcceptanceLintPrecheck -Root $ProjectRoot
3132
+ if ($acceptanceLintResult.ExitCode -eq 1) {
3133
+ $blockedReason = "acceptance 内容级门禁未通过,请先补齐验收报告、需求对照和回滚说明。"
3134
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,acceptance 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($acceptanceLintResult.Output)" -Stage1Summary "NOT_RUN - acceptance lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3135
+ $tracePayload = [PSCustomObject]@{ task_id = $task.id; task_session_id = $taskSessionId; task_kind = $executionPolicy.task_kind; gate_profile = $executionPolicy.gate_profile; required_truth_sources = $executionPolicy.required_truth_sources; agent = "codex"; started_at = $startedAt.ToString("o"); ended_at = (Get-Date).ToString("o"); status = "blocked"; test_command = $task.test_command; failed_stage = "acceptance_lint_precheck"; stage1_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "acceptance lint precheck 未通过。" }; stage2_review = [PSCustomObject]@{ verdict = "NOT_RUN"; exit_code = $null; summary = "未进入 Stage 2 审查。" }; session_policy = $executionPolicy.session; subagent_policy = $executionPolicy.subagents; context_files = $executionPolicy.context_files; run_profile_path = $executionPolicy.run_profile_path; review_context = $initialReviewContext; commands = @(@{ cmd = "acceptance_lint_precheck"; exit_code = $acceptanceLintResult.ExitCode }); blocked_reason = $blockedReason; final_message = $blockedReason; logs = @{ acceptance_lint = $acceptanceLintResult.Output } }
3136
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3137
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3138
+ Write-Step "BLOCKED: acceptance 内容级门禁未通过。"
3139
+ Write-Output $acceptanceLintResult.Output
3140
+ return [PSCustomObject]@{ Status = "blocked"; TaskId = $task.id; ExitCode = 2 }
3141
+ }
3142
+ }
3143
+
3144
+ $needsArchitectureLint = @("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile
3145
+ if ($needsArchitectureLint) {
3146
+ $architectureLintResult = Invoke-ArchitectureLintPrecheck -Root $ProjectRoot
3147
+ if ($architectureLintResult.ExitCode -eq 1) {
3148
+ $blockedReason = "architecture 内容级门禁未通过,请先补齐分层规则、复用检查和复杂功能技术方案字段。"
3149
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,architecture 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($architectureLintResult.Output)" -Stage1Summary "NOT_RUN - architecture lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3150
+ $tracePayload = [PSCustomObject]@{
3151
+ task_id = $task.id
3152
+ task_session_id = $taskSessionId
3153
+ task_kind = $executionPolicy.task_kind
3154
+ gate_profile = $executionPolicy.gate_profile
3155
+ required_truth_sources = $executionPolicy.required_truth_sources
3156
+ agent = "codex"
3157
+ started_at = $startedAt.ToString("o")
3158
+ ended_at = (Get-Date).ToString("o")
3159
+ status = "blocked"
3160
+ test_command = $task.test_command
3161
+ failed_stage = "architecture_lint_precheck"
3162
+ stage1_review = [PSCustomObject]@{
3163
+ verdict = "NOT_RUN"
3164
+ exit_code = $null
3165
+ summary = "architecture lint precheck 未通过。"
3166
+ }
3167
+ stage2_review = [PSCustomObject]@{
3168
+ verdict = "NOT_RUN"
3169
+ exit_code = $null
3170
+ summary = "未进入 Stage 2 审查。"
3171
+ }
3172
+ session_policy = $executionPolicy.session
3173
+ subagent_policy = $executionPolicy.subagents
3174
+ context_files = $executionPolicy.context_files
3175
+ run_profile_path = $executionPolicy.run_profile_path
3176
+ review_context = $initialReviewContext
3177
+ commands = @(@{ cmd = "architecture_lint_precheck"; exit_code = $architectureLintResult.ExitCode })
3178
+ blocked_reason = $blockedReason
3179
+ final_message = $blockedReason
3180
+ logs = @{
3181
+ architecture_lint = $architectureLintResult.Output
3182
+ }
3183
+ }
3184
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3185
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3186
+ Write-Step "BLOCKED: architecture 内容级门禁未通过。"
3187
+ Write-Output $architectureLintResult.Output
3188
+ return [PSCustomObject]@{
3189
+ Status = "blocked"
3190
+ TaskId = $task.id
3191
+ ExitCode = 2
3192
+ }
3193
+ }
3194
+ }
3195
+
3196
+ $needsDirectoryLint = (Test-ContentGateModeEnabled -ExecutionPolicy $executionPolicy -MinimumMode "recommended") -and (@("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile)
3197
+ if ($needsDirectoryLint) {
3198
+ $directoryLintResult = Invoke-DirectoryLintPrecheck -Root $ProjectRoot
3199
+ if ($directoryLintResult.ExitCode -eq 1) {
3200
+ $blockedReason = "directory 内容级门禁未通过,请先补齐目录规范、目录新增规则和本地规则索引。"
3201
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,directory 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($directoryLintResult.Output)" -Stage1Summary "NOT_RUN - directory lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3202
+ $tracePayload = [PSCustomObject]@{
3203
+ task_id = $task.id
3204
+ task_session_id = $taskSessionId
3205
+ task_kind = $executionPolicy.task_kind
3206
+ gate_profile = $executionPolicy.gate_profile
3207
+ required_truth_sources = $executionPolicy.required_truth_sources
3208
+ agent = "codex"
3209
+ started_at = $startedAt.ToString("o")
3210
+ ended_at = (Get-Date).ToString("o")
3211
+ status = "blocked"
3212
+ test_command = $task.test_command
3213
+ failed_stage = "directory_lint_precheck"
3214
+ stage1_review = [PSCustomObject]@{
3215
+ verdict = "NOT_RUN"
3216
+ exit_code = $null
3217
+ summary = "directory lint precheck 未通过。"
3218
+ }
3219
+ stage2_review = [PSCustomObject]@{
3220
+ verdict = "NOT_RUN"
3221
+ exit_code = $null
3222
+ summary = "未进入 Stage 2 审查。"
3223
+ }
3224
+ session_policy = $executionPolicy.session
3225
+ subagent_policy = $executionPolicy.subagents
3226
+ context_files = $executionPolicy.context_files
3227
+ run_profile_path = $executionPolicy.run_profile_path
3228
+ review_context = $initialReviewContext
3229
+ commands = @(@{ cmd = "directory_lint_precheck"; exit_code = $directoryLintResult.ExitCode })
3230
+ blocked_reason = $blockedReason
3231
+ final_message = $blockedReason
3232
+ logs = @{
3233
+ directory_lint = $directoryLintResult.Output
3234
+ }
3235
+ }
3236
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3237
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3238
+ Write-Step "BLOCKED: directory 内容级门禁未通过。"
3239
+ Write-Output $directoryLintResult.Output
3240
+ return [PSCustomObject]@{
3241
+ Status = "blocked"
3242
+ TaskId = $task.id
3243
+ ExitCode = 2
3244
+ }
3245
+ }
3246
+ }
3247
+
3248
+ $needsStyleLint = (Test-ContentGateModeEnabled -ExecutionPolicy $executionPolicy -MinimumMode "recommended") -and (@("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile)
3249
+ if ($needsStyleLint) {
3250
+ $styleLintResult = Invoke-StyleLintPrecheck -Root $ProjectRoot
3251
+ if ($styleLintResult.ExitCode -eq 1) {
3252
+ $blockedReason = "style 内容级门禁未通过,请先补齐业务词典、命名规则和类型边界。"
3253
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,style 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($styleLintResult.Output)" -Stage1Summary "NOT_RUN - style lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3254
+ $tracePayload = [PSCustomObject]@{
3255
+ task_id = $task.id
3256
+ task_session_id = $taskSessionId
3257
+ task_kind = $executionPolicy.task_kind
3258
+ gate_profile = $executionPolicy.gate_profile
3259
+ required_truth_sources = $executionPolicy.required_truth_sources
3260
+ agent = "codex"
3261
+ started_at = $startedAt.ToString("o")
3262
+ ended_at = (Get-Date).ToString("o")
3263
+ status = "blocked"
3264
+ test_command = $task.test_command
3265
+ failed_stage = "style_lint_precheck"
3266
+ stage1_review = [PSCustomObject]@{
3267
+ verdict = "NOT_RUN"
3268
+ exit_code = $null
3269
+ summary = "style lint precheck 未通过。"
3270
+ }
3271
+ stage2_review = [PSCustomObject]@{
3272
+ verdict = "NOT_RUN"
3273
+ exit_code = $null
3274
+ summary = "未进入 Stage 2 审查。"
3275
+ }
3276
+ session_policy = $executionPolicy.session
3277
+ subagent_policy = $executionPolicy.subagents
3278
+ context_files = $executionPolicy.context_files
3279
+ run_profile_path = $executionPolicy.run_profile_path
3280
+ review_context = $initialReviewContext
3281
+ commands = @(@{ cmd = "style_lint_precheck"; exit_code = $styleLintResult.ExitCode })
3282
+ blocked_reason = $blockedReason
3283
+ final_message = $blockedReason
3284
+ logs = @{
3285
+ style_lint = $styleLintResult.Output
3286
+ }
3287
+ }
3288
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3289
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3290
+ Write-Step "BLOCKED: style 内容级门禁未通过。"
3291
+ Write-Output $styleLintResult.Output
3292
+ return [PSCustomObject]@{
3293
+ Status = "blocked"
3294
+ TaskId = $task.id
3295
+ ExitCode = 2
3296
+ }
3297
+ }
3298
+ }
3299
+
3300
+ $needsComponentLint = (Test-ContentGateModeEnabled -ExecutionPolicy $executionPolicy -MinimumMode "recommended") -and (@("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile)
3301
+ if ($needsComponentLint) {
3302
+ $componentLintResult = Invoke-ComponentLintPrecheck -Root $ProjectRoot
3303
+ if ($componentLintResult.ExitCode -eq 1) {
3304
+ $blockedReason = "component 内容级门禁未通过,请先补齐组件清单、复用决策和公共组件兼容影响面。"
3305
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,component 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($componentLintResult.Output)" -Stage1Summary "NOT_RUN - component lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3306
+ $tracePayload = [PSCustomObject]@{
3307
+ task_id = $task.id
3308
+ task_session_id = $taskSessionId
3309
+ task_kind = $executionPolicy.task_kind
3310
+ gate_profile = $executionPolicy.gate_profile
3311
+ required_truth_sources = $executionPolicy.required_truth_sources
3312
+ agent = "codex"
3313
+ started_at = $startedAt.ToString("o")
3314
+ ended_at = (Get-Date).ToString("o")
3315
+ status = "blocked"
3316
+ test_command = $task.test_command
3317
+ failed_stage = "component_lint_precheck"
3318
+ stage1_review = [PSCustomObject]@{
3319
+ verdict = "NOT_RUN"
3320
+ exit_code = $null
3321
+ summary = "component lint precheck 未通过。"
3322
+ }
3323
+ stage2_review = [PSCustomObject]@{
3324
+ verdict = "NOT_RUN"
3325
+ exit_code = $null
3326
+ summary = "未进入 Stage 2 审查。"
3327
+ }
3328
+ session_policy = $executionPolicy.session
3329
+ subagent_policy = $executionPolicy.subagents
3330
+ context_files = $executionPolicy.context_files
3331
+ run_profile_path = $executionPolicy.run_profile_path
3332
+ review_context = $initialReviewContext
3333
+ commands = @(@{ cmd = "component_lint_precheck"; exit_code = $componentLintResult.ExitCode })
3334
+ blocked_reason = $blockedReason
3335
+ final_message = $blockedReason
3336
+ logs = @{
3337
+ component_lint = $componentLintResult.Output
3338
+ }
3339
+ }
3340
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3341
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3342
+ Write-Step "BLOCKED: component 内容级门禁未通过。"
3343
+ Write-Output $componentLintResult.Output
3344
+ return [PSCustomObject]@{
3345
+ Status = "blocked"
3346
+ TaskId = $task.id
3347
+ ExitCode = 2
3348
+ }
3349
+ }
3350
+ }
3351
+
3352
+ $needsBusinessLint = (Test-ContentGateModeEnabled -ExecutionPolicy $executionPolicy -MinimumMode "recommended") -and (@("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile)
3353
+ if ($needsBusinessLint) {
3354
+ $businessLintResult = Invoke-BusinessLintPrecheck -Root $ProjectRoot
3355
+ if ($businessLintResult.ExitCode -eq 1) {
3356
+ $blockedReason = "business 内容级门禁未通过,请先补齐业务规则、边界状态和异常路径测试约束。"
3357
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,business 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($businessLintResult.Output)" -Stage1Summary "NOT_RUN - business lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3358
+ $tracePayload = [PSCustomObject]@{
3359
+ task_id = $task.id
3360
+ task_session_id = $taskSessionId
3361
+ task_kind = $executionPolicy.task_kind
3362
+ gate_profile = $executionPolicy.gate_profile
3363
+ required_truth_sources = $executionPolicy.required_truth_sources
3364
+ agent = "codex"
3365
+ started_at = $startedAt.ToString("o")
3366
+ ended_at = (Get-Date).ToString("o")
3367
+ status = "blocked"
3368
+ test_command = $task.test_command
3369
+ failed_stage = "business_lint_precheck"
3370
+ stage1_review = [PSCustomObject]@{
3371
+ verdict = "NOT_RUN"
3372
+ exit_code = $null
3373
+ summary = "business lint precheck 未通过。"
3374
+ }
3375
+ stage2_review = [PSCustomObject]@{
3376
+ verdict = "NOT_RUN"
3377
+ exit_code = $null
3378
+ summary = "未进入 Stage 2 审查。"
3379
+ }
3380
+ session_policy = $executionPolicy.session
3381
+ subagent_policy = $executionPolicy.subagents
3382
+ context_files = $executionPolicy.context_files
3383
+ run_profile_path = $executionPolicy.run_profile_path
3384
+ review_context = $initialReviewContext
3385
+ commands = @(@{ cmd = "business_lint_precheck"; exit_code = $businessLintResult.ExitCode })
3386
+ blocked_reason = $blockedReason
3387
+ final_message = $blockedReason
3388
+ logs = @{
3389
+ business_lint = $businessLintResult.Output
3390
+ }
3391
+ }
3392
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3393
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3394
+ Write-Step "BLOCKED: business 内容级门禁未通过。"
3395
+ Write-Output $businessLintResult.Output
3396
+ return [PSCustomObject]@{
3397
+ Status = "blocked"
3398
+ TaskId = $task.id
3399
+ ExitCode = 2
3400
+ }
3401
+ }
3402
+ }
3403
+
3404
+ $needsContractLint = @("contract_required", "release_required") -contains $executionPolicy.gate_profile
3405
+ if ($needsContractLint) {
3406
+ $contractLintResult = Invoke-ContractLintPrecheck -Root $ProjectRoot
3407
+ if ($contractLintResult.ExitCode -eq 1) {
3408
+ $blockedReason = "contract 内容级门禁未通过,请先补齐统一请求入口、响应包装、错误模型和契约追溯。"
3409
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,contract 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($contractLintResult.Output)" -Stage1Summary "NOT_RUN - contract lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3410
+ $tracePayload = [PSCustomObject]@{
3411
+ task_id = $task.id
3412
+ task_session_id = $taskSessionId
3413
+ task_kind = $executionPolicy.task_kind
3414
+ gate_profile = $executionPolicy.gate_profile
3415
+ required_truth_sources = $executionPolicy.required_truth_sources
3416
+ agent = "codex"
3417
+ started_at = $startedAt.ToString("o")
3418
+ ended_at = (Get-Date).ToString("o")
3419
+ status = "blocked"
3420
+ test_command = $task.test_command
3421
+ failed_stage = "contract_lint_precheck"
3422
+ stage1_review = [PSCustomObject]@{
3423
+ verdict = "NOT_RUN"
3424
+ exit_code = $null
3425
+ summary = "contract lint precheck 未通过。"
3426
+ }
3427
+ stage2_review = [PSCustomObject]@{
3428
+ verdict = "NOT_RUN"
3429
+ exit_code = $null
3430
+ summary = "未进入 Stage 2 审查。"
3431
+ }
3432
+ session_policy = $executionPolicy.session
3433
+ subagent_policy = $executionPolicy.subagents
3434
+ context_files = $executionPolicy.context_files
3435
+ run_profile_path = $executionPolicy.run_profile_path
3436
+ review_context = $initialReviewContext
3437
+ commands = @(@{ cmd = "contract_lint_precheck"; exit_code = $contractLintResult.ExitCode })
3438
+ blocked_reason = $blockedReason
3439
+ final_message = $blockedReason
3440
+ logs = @{
3441
+ contract_lint = $contractLintResult.Output
3442
+ }
3443
+ }
3444
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3445
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3446
+ Write-Step "BLOCKED: contract 内容级门禁未通过。"
3447
+ Write-Output $contractLintResult.Output
3448
+ return [PSCustomObject]@{
3449
+ Status = "blocked"
3450
+ TaskId = $task.id
3451
+ ExitCode = 2
3452
+ }
3453
+ }
3454
+ }
3455
+
3456
+ $needsStateLint = (Test-ContentGateModeEnabled -ExecutionPolicy $executionPolicy -MinimumMode "recommended") -and (@("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile)
3457
+ if ($needsStateLint) {
3458
+ $stateLintResult = Invoke-StateLintPrecheck -Root $ProjectRoot
3459
+ if ($stateLintResult.ExitCode -eq 1) {
3460
+ $blockedReason = "state 内容级门禁未通过,请先补齐状态分层、唯一状态来源和缓存失效策略。"
3461
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,state 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($stateLintResult.Output)" -Stage1Summary "NOT_RUN - state lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3462
+ $tracePayload = [PSCustomObject]@{
3463
+ task_id = $task.id
3464
+ task_session_id = $taskSessionId
3465
+ task_kind = $executionPolicy.task_kind
3466
+ gate_profile = $executionPolicy.gate_profile
3467
+ required_truth_sources = $executionPolicy.required_truth_sources
3468
+ agent = "codex"
3469
+ started_at = $startedAt.ToString("o")
3470
+ ended_at = (Get-Date).ToString("o")
3471
+ status = "blocked"
3472
+ test_command = $task.test_command
3473
+ failed_stage = "state_lint_precheck"
3474
+ stage1_review = [PSCustomObject]@{
3475
+ verdict = "NOT_RUN"
3476
+ exit_code = $null
3477
+ summary = "state lint precheck 未通过。"
3478
+ }
3479
+ stage2_review = [PSCustomObject]@{
3480
+ verdict = "NOT_RUN"
3481
+ exit_code = $null
3482
+ summary = "未进入 Stage 2 审查。"
3483
+ }
3484
+ session_policy = $executionPolicy.session
3485
+ subagent_policy = $executionPolicy.subagents
3486
+ context_files = $executionPolicy.context_files
3487
+ run_profile_path = $executionPolicy.run_profile_path
3488
+ review_context = $initialReviewContext
3489
+ commands = @(@{ cmd = "state_lint_precheck"; exit_code = $stateLintResult.ExitCode })
3490
+ blocked_reason = $blockedReason
3491
+ final_message = $blockedReason
3492
+ logs = @{
3493
+ state_lint = $stateLintResult.Output
3494
+ }
3495
+ }
3496
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3497
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3498
+ Write-Step "BLOCKED: state 内容级门禁未通过。"
3499
+ Write-Output $stateLintResult.Output
3500
+ return [PSCustomObject]@{
3501
+ Status = "blocked"
3502
+ TaskId = $task.id
3503
+ ExitCode = 2
3504
+ }
3505
+ }
3506
+ }
3507
+
3508
+ $needsUiLint = (Test-ContentGateModeEnabled -ExecutionPolicy $executionPolicy -MinimumMode "recommended") -and (@("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile)
3509
+ if ($needsUiLint) {
3510
+ $uiLintResult = Invoke-UiLintPrecheck -Root $ProjectRoot
3511
+ if ($uiLintResult.ExitCode -eq 1) {
3512
+ $blockedReason = "ui 内容级门禁未通过,请先补齐设计系统、移动端安全区、交互状态和表单体验规则。"
3513
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,ui 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($uiLintResult.Output)" -Stage1Summary "NOT_RUN - ui lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3514
+ $tracePayload = [PSCustomObject]@{
3515
+ task_id = $task.id
3516
+ task_session_id = $taskSessionId
3517
+ task_kind = $executionPolicy.task_kind
3518
+ gate_profile = $executionPolicy.gate_profile
3519
+ required_truth_sources = $executionPolicy.required_truth_sources
3520
+ agent = "codex"
3521
+ started_at = $startedAt.ToString("o")
3522
+ ended_at = (Get-Date).ToString("o")
3523
+ status = "blocked"
3524
+ test_command = $task.test_command
3525
+ failed_stage = "ui_lint_precheck"
3526
+ stage1_review = [PSCustomObject]@{
3527
+ verdict = "NOT_RUN"
3528
+ exit_code = $null
3529
+ summary = "ui lint precheck 未通过。"
3530
+ }
3531
+ stage2_review = [PSCustomObject]@{
3532
+ verdict = "NOT_RUN"
3533
+ exit_code = $null
3534
+ summary = "未进入 Stage 2 审查。"
3535
+ }
3536
+ session_policy = $executionPolicy.session
3537
+ subagent_policy = $executionPolicy.subagents
3538
+ context_files = $executionPolicy.context_files
3539
+ run_profile_path = $executionPolicy.run_profile_path
3540
+ review_context = $initialReviewContext
3541
+ commands = @(@{ cmd = "ui_lint_precheck"; exit_code = $uiLintResult.ExitCode })
3542
+ blocked_reason = $blockedReason
3543
+ final_message = $blockedReason
3544
+ logs = @{
3545
+ ui_lint = $uiLintResult.Output
3546
+ }
3547
+ }
3548
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3549
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3550
+ Write-Step "BLOCKED: ui 内容级门禁未通过。"
3551
+ Write-Output $uiLintResult.Output
3552
+ return [PSCustomObject]@{
3553
+ Status = "blocked"
3554
+ TaskId = $task.id
3555
+ ExitCode = 2
3556
+ }
3557
+ }
3558
+ }
3559
+
3560
+ $needsBackendLint = Test-TaskHasRiskTag -ExecutionPolicy $executionPolicy -Tags @("backend", "api", "worker", "service")
3561
+ if ($needsBackendLint) {
3562
+ $backendLintResult = Invoke-BackendLintPrecheck -Root $ProjectRoot
3563
+ if ($backendLintResult.ExitCode -eq 1) {
3564
+ $blockedReason = "backend 内容级门禁未通过,请先补齐 Controller/Service/Repository 边界、事务/幂等和异常处理策略。"
3565
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,backend 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($backendLintResult.Output)" -Stage1Summary "NOT_RUN - backend lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3566
+ $tracePayload = [PSCustomObject]@{
3567
+ task_id = $task.id
3568
+ task_session_id = $taskSessionId
3569
+ task_kind = $executionPolicy.task_kind
3570
+ gate_profile = $executionPolicy.gate_profile
3571
+ required_truth_sources = $executionPolicy.required_truth_sources
3572
+ agent = "codex"
3573
+ started_at = $startedAt.ToString("o")
3574
+ ended_at = (Get-Date).ToString("o")
3575
+ status = "blocked"
3576
+ test_command = $task.test_command
3577
+ failed_stage = "backend_lint_precheck"
3578
+ stage1_review = [PSCustomObject]@{
3579
+ verdict = "NOT_RUN"
3580
+ exit_code = $null
3581
+ summary = "backend lint precheck 未通过。"
3582
+ }
3583
+ stage2_review = [PSCustomObject]@{
3584
+ verdict = "NOT_RUN"
3585
+ exit_code = $null
3586
+ summary = "未进入 Stage 2 审查。"
3587
+ }
3588
+ session_policy = $executionPolicy.session
3589
+ subagent_policy = $executionPolicy.subagents
3590
+ context_files = $executionPolicy.context_files
3591
+ run_profile_path = $executionPolicy.run_profile_path
3592
+ review_context = $initialReviewContext
3593
+ commands = @(@{ cmd = "backend_lint_precheck"; exit_code = $backendLintResult.ExitCode })
3594
+ blocked_reason = $blockedReason
3595
+ final_message = $blockedReason
3596
+ logs = @{
3597
+ backend_lint = $backendLintResult.Output
3598
+ }
3599
+ }
3600
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3601
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3602
+ Write-Step "BLOCKED: backend 内容级门禁未通过。"
3603
+ Write-Output $backendLintResult.Output
3604
+ return [PSCustomObject]@{
3605
+ Status = "blocked"
3606
+ TaskId = $task.id
3607
+ ExitCode = 2
3608
+ }
3609
+ }
3610
+ }
3611
+
3612
+ $needsSecurityLint = Test-TaskHasRiskTag -ExecutionPolicy $executionPolicy -Tags @("security", "auth", "permission", "payment", "privacy")
3613
+ if ($needsSecurityLint) {
3614
+ $securityLintResult = Invoke-SecurityLintPrecheck -Root $ProjectRoot
3615
+ if ($securityLintResult.ExitCode -eq 1) {
3616
+ $blockedReason = "security 内容级门禁未通过,请先补齐权限校验、输入校验、脱敏和风控策略。"
3617
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,security 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($securityLintResult.Output)" -Stage1Summary "NOT_RUN - security lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3618
+ $tracePayload = [PSCustomObject]@{
3619
+ task_id = $task.id
3620
+ task_session_id = $taskSessionId
3621
+ task_kind = $executionPolicy.task_kind
3622
+ gate_profile = $executionPolicy.gate_profile
3623
+ required_truth_sources = $executionPolicy.required_truth_sources
3624
+ agent = "codex"
3625
+ started_at = $startedAt.ToString("o")
3626
+ ended_at = (Get-Date).ToString("o")
3627
+ status = "blocked"
3628
+ test_command = $task.test_command
3629
+ failed_stage = "security_lint_precheck"
3630
+ stage1_review = [PSCustomObject]@{
3631
+ verdict = "NOT_RUN"
3632
+ exit_code = $null
3633
+ summary = "security lint precheck 未通过。"
3634
+ }
3635
+ stage2_review = [PSCustomObject]@{
3636
+ verdict = "NOT_RUN"
3637
+ exit_code = $null
3638
+ summary = "未进入 Stage 2 审查。"
3639
+ }
3640
+ session_policy = $executionPolicy.session
3641
+ subagent_policy = $executionPolicy.subagents
3642
+ context_files = $executionPolicy.context_files
3643
+ run_profile_path = $executionPolicy.run_profile_path
3644
+ review_context = $initialReviewContext
3645
+ commands = @(@{ cmd = "security_lint_precheck"; exit_code = $securityLintResult.ExitCode })
3646
+ blocked_reason = $blockedReason
3647
+ final_message = $blockedReason
3648
+ logs = @{
3649
+ security_lint = $securityLintResult.Output
3650
+ }
3651
+ }
3652
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3653
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3654
+ Write-Step "BLOCKED: security 内容级门禁未通过。"
3655
+ Write-Output $securityLintResult.Output
3656
+ return [PSCustomObject]@{
3657
+ Status = "blocked"
3658
+ TaskId = $task.id
3659
+ ExitCode = 2
3660
+ }
3661
+ }
3662
+ }
3663
+
3664
+ $needsTestingLint = @("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile
3665
+ if ($needsTestingLint) {
3666
+ $testingLintResult = Invoke-TestingLintPrecheck -Root $ProjectRoot
3667
+ if ($testingLintResult.ExitCode -eq 1) {
3668
+ $blockedReason = "testing 内容级门禁未通过,请先补齐验收、追溯、测试策略、验证矩阵和假测试约束。"
3669
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,testing 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($testingLintResult.Output)" -Stage1Summary "NOT_RUN - testing lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3670
+ $tracePayload = [PSCustomObject]@{
3671
+ task_id = $task.id
3672
+ task_session_id = $taskSessionId
3673
+ task_kind = $executionPolicy.task_kind
3674
+ gate_profile = $executionPolicy.gate_profile
3675
+ required_truth_sources = $executionPolicy.required_truth_sources
3676
+ agent = "codex"
3677
+ started_at = $startedAt.ToString("o")
3678
+ ended_at = (Get-Date).ToString("o")
3679
+ status = "blocked"
3680
+ test_command = $task.test_command
3681
+ failed_stage = "testing_lint_precheck"
3682
+ stage1_review = [PSCustomObject]@{
3683
+ verdict = "NOT_RUN"
3684
+ exit_code = $null
3685
+ summary = "testing lint precheck 未通过。"
3686
+ }
3687
+ stage2_review = [PSCustomObject]@{
3688
+ verdict = "NOT_RUN"
3689
+ exit_code = $null
3690
+ summary = "未进入 Stage 2 审查。"
3691
+ }
3692
+ session_policy = $executionPolicy.session
3693
+ subagent_policy = $executionPolicy.subagents
3694
+ context_files = $executionPolicy.context_files
3695
+ run_profile_path = $executionPolicy.run_profile_path
3696
+ review_context = $initialReviewContext
3697
+ commands = @(@{ cmd = "testing_lint_precheck"; exit_code = $testingLintResult.ExitCode })
3698
+ blocked_reason = $blockedReason
3699
+ final_message = $blockedReason
3700
+ logs = @{
3701
+ testing_lint = $testingLintResult.Output
3702
+ }
3703
+ }
3704
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3705
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3706
+ Write-Step "BLOCKED: testing 内容级门禁未通过。"
3707
+ Write-Output $testingLintResult.Output
3708
+ return [PSCustomObject]@{
3709
+ Status = "blocked"
3710
+ TaskId = $task.id
3711
+ ExitCode = 2
3712
+ }
3713
+ }
3714
+ }
3715
+
3716
+ $needsImpactLint = @("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile
3717
+ if ($needsImpactLint) {
3718
+ $impactLintResult = Invoke-ImpactLintPrecheck -Root $ProjectRoot
3719
+ if ($impactLintResult.ExitCode -eq 1) {
3720
+ $blockedReason = "impact 内容级门禁未通过,请先补齐调用链、直接/间接影响和回归范围。"
3721
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,impact 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($impactLintResult.Output)" -Stage1Summary "NOT_RUN - impact lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3722
+ $tracePayload = [PSCustomObject]@{
3723
+ task_id = $task.id
3724
+ task_session_id = $taskSessionId
3725
+ task_kind = $executionPolicy.task_kind
3726
+ gate_profile = $executionPolicy.gate_profile
3727
+ required_truth_sources = $executionPolicy.required_truth_sources
3728
+ agent = "codex"
3729
+ started_at = $startedAt.ToString("o")
3730
+ ended_at = (Get-Date).ToString("o")
3731
+ status = "blocked"
3732
+ test_command = $task.test_command
3733
+ failed_stage = "impact_lint_precheck"
3734
+ stage1_review = [PSCustomObject]@{
3735
+ verdict = "NOT_RUN"
3736
+ exit_code = $null
3737
+ summary = "impact lint precheck 未通过。"
3738
+ }
3739
+ stage2_review = [PSCustomObject]@{
3740
+ verdict = "NOT_RUN"
3741
+ exit_code = $null
3742
+ summary = "未进入 Stage 2 审查。"
3743
+ }
3744
+ session_policy = $executionPolicy.session
3745
+ subagent_policy = $executionPolicy.subagents
3746
+ context_files = $executionPolicy.context_files
3747
+ run_profile_path = $executionPolicy.run_profile_path
3748
+ review_context = $initialReviewContext
3749
+ commands = @(@{ cmd = "impact_lint_precheck"; exit_code = $impactLintResult.ExitCode })
3750
+ blocked_reason = $blockedReason
3751
+ final_message = $blockedReason
3752
+ logs = @{
3753
+ impact_lint = $impactLintResult.Output
3754
+ }
3755
+ }
3756
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3757
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3758
+ Write-Step "BLOCKED: impact 内容级门禁未通过。"
3759
+ Write-Output $impactLintResult.Output
3760
+ return [PSCustomObject]@{
3761
+ Status = "blocked"
3762
+ TaskId = $task.id
3763
+ ExitCode = 2
3764
+ }
3765
+ }
3766
+ }
3767
+
3768
+ $needsPerformanceLint = (Test-ContentGateModeEnabled -ExecutionPolicy $executionPolicy -MinimumMode "recommended") -and (@("spec_required", "contract_required", "release_required") -contains $executionPolicy.gate_profile)
3769
+ if ($needsPerformanceLint) {
3770
+ $performanceLintResult = Invoke-PerformanceLintPrecheck -Root $ProjectRoot
3771
+ if ($performanceLintResult.ExitCode -eq 1) {
3772
+ $blockedReason = "performance 内容级门禁未通过,请先补齐性能预算、复杂列表策略和后端性能约束。"
3773
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,performance 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($performanceLintResult.Output)" -Stage1Summary "NOT_RUN - performance lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3774
+ $tracePayload = [PSCustomObject]@{
3775
+ task_id = $task.id
3776
+ task_session_id = $taskSessionId
3777
+ task_kind = $executionPolicy.task_kind
3778
+ gate_profile = $executionPolicy.gate_profile
3779
+ required_truth_sources = $executionPolicy.required_truth_sources
3780
+ agent = "codex"
3781
+ started_at = $startedAt.ToString("o")
3782
+ ended_at = (Get-Date).ToString("o")
3783
+ status = "blocked"
3784
+ test_command = $task.test_command
3785
+ failed_stage = "performance_lint_precheck"
3786
+ stage1_review = [PSCustomObject]@{
3787
+ verdict = "NOT_RUN"
3788
+ exit_code = $null
3789
+ summary = "performance lint precheck 未通过。"
3790
+ }
3791
+ stage2_review = [PSCustomObject]@{
3792
+ verdict = "NOT_RUN"
3793
+ exit_code = $null
3794
+ summary = "未进入 Stage 2 审查。"
3795
+ }
3796
+ session_policy = $executionPolicy.session
3797
+ subagent_policy = $executionPolicy.subagents
3798
+ context_files = $executionPolicy.context_files
3799
+ run_profile_path = $executionPolicy.run_profile_path
3800
+ review_context = $initialReviewContext
3801
+ commands = @(@{ cmd = "performance_lint_precheck"; exit_code = $performanceLintResult.ExitCode })
3802
+ blocked_reason = $blockedReason
3803
+ final_message = $blockedReason
3804
+ logs = @{
3805
+ performance_lint = $performanceLintResult.Output
3806
+ }
3807
+ }
3808
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3809
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3810
+ Write-Step "BLOCKED: performance 内容级门禁未通过。"
3811
+ Write-Output $performanceLintResult.Output
3812
+ return [PSCustomObject]@{
3813
+ Status = "blocked"
3814
+ TaskId = $task.id
3815
+ ExitCode = 2
3816
+ }
3817
+ }
3818
+ }
3819
+
3820
+ $needsConfigLint = Test-TaskHasRiskTag -ExecutionPolicy $executionPolicy -Tags @("config", "deploy", "env", "infra", "ci", "ops")
3821
+ if ($needsConfigLint) {
3822
+ $configLintResult = Invoke-ConfigLintPrecheck -Root $ProjectRoot
3823
+ if ($configLintResult.ExitCode -eq 1) {
3824
+ $blockedReason = "config 内容级门禁未通过,请先补齐环境变量、构建命令和部署影响说明。"
3825
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,config 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($configLintResult.Output)" -Stage1Summary "NOT_RUN - config lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3826
+ $tracePayload = [PSCustomObject]@{
3827
+ task_id = $task.id
3828
+ task_session_id = $taskSessionId
3829
+ task_kind = $executionPolicy.task_kind
3830
+ gate_profile = $executionPolicy.gate_profile
3831
+ required_truth_sources = $executionPolicy.required_truth_sources
3832
+ agent = "codex"
3833
+ started_at = $startedAt.ToString("o")
3834
+ ended_at = (Get-Date).ToString("o")
3835
+ status = "blocked"
3836
+ test_command = $task.test_command
3837
+ failed_stage = "config_lint_precheck"
3838
+ stage1_review = [PSCustomObject]@{
3839
+ verdict = "NOT_RUN"
3840
+ exit_code = $null
3841
+ summary = "config lint precheck 未通过。"
3842
+ }
3843
+ stage2_review = [PSCustomObject]@{
3844
+ verdict = "NOT_RUN"
3845
+ exit_code = $null
3846
+ summary = "未进入 Stage 2 审查。"
3847
+ }
3848
+ session_policy = $executionPolicy.session
3849
+ subagent_policy = $executionPolicy.subagents
3850
+ context_files = $executionPolicy.context_files
3851
+ run_profile_path = $executionPolicy.run_profile_path
3852
+ review_context = $initialReviewContext
3853
+ commands = @(@{ cmd = "config_lint_precheck"; exit_code = $configLintResult.ExitCode })
3854
+ blocked_reason = $blockedReason
3855
+ final_message = $blockedReason
3856
+ logs = @{
3857
+ config_lint = $configLintResult.Output
3858
+ }
3859
+ }
3860
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3861
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3862
+ Write-Step "BLOCKED: config 内容级门禁未通过。"
3863
+ Write-Output $configLintResult.Output
3864
+ return [PSCustomObject]@{
3865
+ Status = "blocked"
3866
+ TaskId = $task.id
3867
+ ExitCode = 2
3868
+ }
3869
+ }
3870
+ }
3871
+
3872
+ $needsObservabilityLint = Test-TaskHasRiskTag -ExecutionPolicy $executionPolicy -Tags @("observability", "logging", "metrics", "trace", "alerting")
3873
+ if ($needsObservabilityLint) {
3874
+ $observabilityLintResult = Invoke-ObservabilityLintPrecheck -Root $ProjectRoot
3875
+ if ($observabilityLintResult.ExitCode -eq 1) {
3876
+ $blockedReason = "observability 内容级门禁未通过,请先补齐日志字段、trace 证据和告警策略。"
3877
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,observability 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($observabilityLintResult.Output)" -Stage1Summary "NOT_RUN - observability lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3878
+ $tracePayload = [PSCustomObject]@{
3879
+ task_id = $task.id
3880
+ task_session_id = $taskSessionId
3881
+ task_kind = $executionPolicy.task_kind
3882
+ gate_profile = $executionPolicy.gate_profile
3883
+ required_truth_sources = $executionPolicy.required_truth_sources
3884
+ agent = "codex"
3885
+ started_at = $startedAt.ToString("o")
3886
+ ended_at = (Get-Date).ToString("o")
3887
+ status = "blocked"
3888
+ test_command = $task.test_command
3889
+ failed_stage = "observability_lint_precheck"
3890
+ stage1_review = [PSCustomObject]@{
3891
+ verdict = "NOT_RUN"
3892
+ exit_code = $null
3893
+ summary = "observability lint precheck 未通过。"
3894
+ }
3895
+ stage2_review = [PSCustomObject]@{
3896
+ verdict = "NOT_RUN"
3897
+ exit_code = $null
3898
+ summary = "未进入 Stage 2 审查。"
3899
+ }
3900
+ session_policy = $executionPolicy.session
3901
+ subagent_policy = $executionPolicy.subagents
3902
+ context_files = $executionPolicy.context_files
3903
+ run_profile_path = $executionPolicy.run_profile_path
3904
+ review_context = $initialReviewContext
3905
+ commands = @(@{ cmd = "observability_lint_precheck"; exit_code = $observabilityLintResult.ExitCode })
3906
+ blocked_reason = $blockedReason
3907
+ final_message = $blockedReason
3908
+ logs = @{
3909
+ observability_lint = $observabilityLintResult.Output
3910
+ }
3911
+ }
3912
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3913
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3914
+ Write-Step "BLOCKED: observability 内容级门禁未通过。"
3915
+ Write-Output $observabilityLintResult.Output
3916
+ return [PSCustomObject]@{
3917
+ Status = "blocked"
3918
+ TaskId = $task.id
3919
+ ExitCode = 2
3920
+ }
3921
+ }
3922
+ }
3923
+
3924
+ $needsRefactorLint = Test-TaskHasRiskTag -ExecutionPolicy $executionPolicy -Tags @("refactor")
3925
+ if ($needsRefactorLint) {
3926
+ $refactorLintResult = Invoke-RefactorLintPrecheck -Root $ProjectRoot
3927
+ if ($refactorLintResult.ExitCode -eq 1) {
3928
+ $blockedReason = "refactor 内容级门禁未通过,请先补齐任务类型、行为不变约束和死代码清理范围。"
3929
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "未进入实现阶段,refactor 内容级门禁未通过。" -TestSummary "未运行测试。" -Notes "$blockedReason`n$($refactorLintResult.Output)" -Stage1Summary "NOT_RUN - refactor lint precheck 未通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
3930
+ $tracePayload = [PSCustomObject]@{
3931
+ task_id = $task.id
3932
+ task_session_id = $taskSessionId
3933
+ task_kind = $executionPolicy.task_kind
3934
+ gate_profile = $executionPolicy.gate_profile
3935
+ required_truth_sources = $executionPolicy.required_truth_sources
3936
+ agent = "codex"
3937
+ started_at = $startedAt.ToString("o")
3938
+ ended_at = (Get-Date).ToString("o")
3939
+ status = "blocked"
3940
+ test_command = $task.test_command
3941
+ failed_stage = "refactor_lint_precheck"
3942
+ stage1_review = [PSCustomObject]@{
3943
+ verdict = "NOT_RUN"
3944
+ exit_code = $null
3945
+ summary = "refactor lint precheck 未通过。"
3946
+ }
3947
+ stage2_review = [PSCustomObject]@{
3948
+ verdict = "NOT_RUN"
3949
+ exit_code = $null
3950
+ summary = "未进入 Stage 2 审查。"
3951
+ }
3952
+ session_policy = $executionPolicy.session
3953
+ subagent_policy = $executionPolicy.subagents
3954
+ context_files = $executionPolicy.context_files
3955
+ run_profile_path = $executionPolicy.run_profile_path
3956
+ review_context = $initialReviewContext
3957
+ commands = @(@{ cmd = "refactor_lint_precheck"; exit_code = $refactorLintResult.ExitCode })
3958
+ blocked_reason = $blockedReason
3959
+ final_message = $blockedReason
3960
+ logs = @{
3961
+ refactor_lint = $refactorLintResult.Output
3962
+ }
3963
+ }
3964
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $null -LogFiles @() | Out-Null
3965
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
3966
+ Write-Step "BLOCKED: refactor 内容级门禁未通过。"
3967
+ Write-Output $refactorLintResult.Output
3968
+ return [PSCustomObject]@{
3969
+ Status = "blocked"
3970
+ TaskId = $task.id
3971
+ ExitCode = 2
3972
+ }
3973
+ }
3974
+ }
3975
+
3976
+ Write-Step "选择任务: $($task.id) $($task.description)"
2079
3977
  Write-Step "启动新 task 会话: $taskSessionId ($($executionPolicy.session.mode))"
2080
3978
 
2081
3979
  $prompt = New-ImplementationPrompt -Task $task -ExecutionPolicy $executionPolicy -TaskSessionId $taskSessionId
@@ -2209,16 +4107,16 @@ function Invoke-OneTask {
2209
4107
  }
2210
4108
  }
2211
4109
 
2212
- Write-Step "Stage 1 审查通过,开始运行测试。"
2213
- $testResult = Invoke-TestCommand -Command $task.test_command -Root $ProjectRoot -LogDirectory $taskLogDirectory -TaskId $task.id
2214
-
2215
- if ($testResult.ExitCode -ne 0) {
2216
- Write-Step "测试失败,开始自动失败归因。"
2217
- $triageResult = Invoke-FailureTriage -Task $task -Root $ProjectRoot -ExecutionPolicy $executionPolicy -ReviewContext $reviewContext -CodexResult $codexResult -Stage1Result $stage1Result -TestResult $testResult -CodexCommand $CodexCommand -LogDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents
2218
- $triageNote = if ($null -ne $triageResult.ReportPath) { "failure triage: $($triageResult.ReportPath)" } elseif (-not [string]::IsNullOrWhiteSpace($triageResult.ParseError)) { "failure triage parse failed: $($triageResult.ParseError)" } else { "failure triage did not produce a structured report" }
2219
- Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "Codex 已产生改动。" -TestSummary "测试失败,退出码 $($testResult.ExitCode)。" -Notes "禁止标记 passes=true,请人工查看 trace;$triageNote" -Stage1Summary "PASS - 审查通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
2220
- $tracePayload = [PSCustomObject]@{
2221
- task_id = $task.id
4110
+ Write-Step "Stage 1 审查通过,开始运行测试。"
4111
+ $testResult = Invoke-TestCommand -Command $task.test_command -Root $ProjectRoot -LogDirectory $taskLogDirectory -TaskId $task.id
4112
+
4113
+ if ($testResult.ExitCode -ne 0) {
4114
+ Write-Step "测试失败,开始自动失败归因。"
4115
+ $triageResult = Invoke-FailureTriage -Task $task -Root $ProjectRoot -ExecutionPolicy $executionPolicy -ReviewContext $reviewContext -CodexResult $codexResult -Stage1Result $stage1Result -TestResult $testResult -CodexCommand $CodexCommand -LogDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents
4116
+ $triageNote = if ($null -ne $triageResult.ReportPath) { "failure triage: $($triageResult.ReportPath)" } elseif (-not [string]::IsNullOrWhiteSpace($triageResult.ParseError)) { "failure triage parse failed: $($triageResult.ParseError)" } else { "failure triage did not produce a structured report" }
4117
+ Write-ProgressEntry -Path $ProgressPath -Task $task -WorkSummary "Codex 已产生改动。" -TestSummary "测试失败,退出码 $($testResult.ExitCode)。" -Notes "禁止标记 passes=true,请人工查看 trace;$triageNote" -Stage1Summary "PASS - 审查通过。" -Stage2Summary "NOT_RUN - 未进入 Stage 2 审查。"
4118
+ $tracePayload = [PSCustomObject]@{
4119
+ task_id = $task.id
2222
4120
  task_session_id = $taskSessionId
2223
4121
  task_kind = $executionPolicy.task_kind
2224
4122
  gate_profile = $executionPolicy.gate_profile
@@ -2244,45 +4142,45 @@ function Invoke-OneTask {
2244
4142
  subagent_policy = $executionPolicy.subagents
2245
4143
  context_files = $executionPolicy.context_files
2246
4144
  run_profile_path = $executionPolicy.run_profile_path
2247
- review_context = $reviewContext
2248
- commands = @(
2249
- @{ cmd = "codex exec"; exit_code = $codexResult.ExitCode },
2250
- @{ cmd = "stage1 review"; exit_code = $stage1Result.ExitCode; verdict = $stage1Verdict },
2251
- @{ cmd = $task.test_command; exit_code = $testResult.ExitCode },
2252
- @{ cmd = "failure triage"; exit_code = $triageResult.ExitCode; report = $triageResult.ReportPath }
2253
- )
2254
- final_message = $codexResult.Output
2255
- logs = @{
2256
- implementation_stdout = $codexResult.StdoutLog
4145
+ review_context = $reviewContext
4146
+ commands = @(
4147
+ @{ cmd = "codex exec"; exit_code = $codexResult.ExitCode },
4148
+ @{ cmd = "stage1 review"; exit_code = $stage1Result.ExitCode; verdict = $stage1Verdict },
4149
+ @{ cmd = $task.test_command; exit_code = $testResult.ExitCode },
4150
+ @{ cmd = "failure triage"; exit_code = $triageResult.ExitCode; report = $triageResult.ReportPath }
4151
+ )
4152
+ final_message = $codexResult.Output
4153
+ logs = @{
4154
+ implementation_stdout = $codexResult.StdoutLog
2257
4155
  implementation_stderr = $codexResult.StderrLog
2258
4156
  implementation_prompt = $codexResult.PromptLog
2259
4157
  implementation_last_message = $codexResult.LastMessageLog
2260
4158
  stage1_stdout = $stage1Result.StdoutLog
2261
4159
  stage1_stderr = $stage1Result.StderrLog
2262
- stage1_prompt = $stage1Result.PromptLog
2263
- stage1_last_message = $stage1Result.LastMessageLog
2264
- test_output = $testResult.OutputLog
2265
- failure_triage_stdout = $triageResult.StdoutLog
2266
- failure_triage_stderr = $triageResult.StderrLog
2267
- failure_triage_prompt = $triageResult.PromptLog
2268
- failure_triage_last_message = $triageResult.LastMessageLog
2269
- }
2270
- failure_triage_report = $triageResult.ReportPath
2271
- failure_triage_parse_error = $triageResult.ParseError
2272
- }
2273
- Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $codexResult -LogFiles (@(Get-TraceLogFiles -CodexResults @($codexResult, $stage1Result, $triageResult)) + @(ConvertTo-StringArray -Value $testResult.OutputLog) + @(ConvertTo-StringArray -Value $triageResult.ReportPath)) | Out-Null
2274
- Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
2275
- Write-Step "FAILED: 测试失败,退出码 $($testResult.ExitCode)。"
2276
- Write-Output ""
2277
- Write-Output "测试输出:"
2278
- Write-Output $testResult.Output
2279
- Write-Output ""
2280
- Write-Output "Failure triage:"
2281
- Write-Output $triageNote
2282
- Write-Output ""
2283
- Write-Output "Codex 完整日志: $($codexResult.StdoutLog)"
2284
- return [PSCustomObject]@{
2285
- Status = "failed"
4160
+ stage1_prompt = $stage1Result.PromptLog
4161
+ stage1_last_message = $stage1Result.LastMessageLog
4162
+ test_output = $testResult.OutputLog
4163
+ failure_triage_stdout = $triageResult.StdoutLog
4164
+ failure_triage_stderr = $triageResult.StderrLog
4165
+ failure_triage_prompt = $triageResult.PromptLog
4166
+ failure_triage_last_message = $triageResult.LastMessageLog
4167
+ }
4168
+ failure_triage_report = $triageResult.ReportPath
4169
+ failure_triage_parse_error = $triageResult.ParseError
4170
+ }
4171
+ Add-TraceDurableFields -Trace $tracePayload -SessionDirectory $taskLogDirectory -CaptureJsonEvents:$CaptureJsonEvents -EventsSource $codexResult -LogFiles (@(Get-TraceLogFiles -CodexResults @($codexResult, $stage1Result, $triageResult)) + @(ConvertTo-StringArray -Value $testResult.OutputLog) + @(ConvertTo-StringArray -Value $triageResult.ReportPath)) | Out-Null
4172
+ Save-Trace -Directory $TracePath -Trace $tracePayload | Out-Null
4173
+ Write-Step "FAILED: 测试失败,退出码 $($testResult.ExitCode)。"
4174
+ Write-Output ""
4175
+ Write-Output "测试输出:"
4176
+ Write-Output $testResult.Output
4177
+ Write-Output ""
4178
+ Write-Output "Failure triage:"
4179
+ Write-Output $triageNote
4180
+ Write-Output ""
4181
+ Write-Output "Codex 完整日志: $($codexResult.StdoutLog)"
4182
+ return [PSCustomObject]@{
4183
+ Status = "failed"
2286
4184
  TaskId = $task.id
2287
4185
  ExitCode = 1
2288
4186
  }