specdojo 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/.github/agents/specdojo-orchestrator.md +3 -2
  2. package/CHANGELOG.md +153 -0
  3. package/dist/catalog/build.js +24 -1
  4. package/dist/catalog/plan.js +1 -1
  5. package/dist/catalog/scaffold.js +4 -1
  6. package/dist/commands/init.js +5 -1
  7. package/dist/commands/night-orchestrator.js +6 -4
  8. package/dist/dashboard/dashboard-timeline.js +18 -16
  9. package/dist/dashboard/dashboard.js +612 -259
  10. package/dist/dashboard/epic-plan.js +81 -0
  11. package/dist/dashboard/exec-records.js +16 -20
  12. package/dist/dashboard/routines.js +8 -6
  13. package/dist/dashboard/timeline-build.js +5 -9
  14. package/dist/dashboard/timeline.js +9 -4
  15. package/dist/devcontainer/scaffold.js +18 -0
  16. package/dist/docs/frontmatter-namespace.js +1 -48
  17. package/dist/docs/yaml-pages.js +125 -3
  18. package/dist/exec/agent-config.js +22 -0
  19. package/dist/exec/agent-plan.js +3 -2
  20. package/dist/exec/commands.js +69 -21
  21. package/dist/exec/commit-hook-skips.js +78 -0
  22. package/dist/exec/core.js +19 -7
  23. package/dist/exec/events.js +159 -8
  24. package/dist/exec/evidence.js +64 -16
  25. package/dist/exec/handoff.js +9 -13
  26. package/dist/exec/limit.js +1 -1
  27. package/dist/exec/mechanical-result.js +45 -0
  28. package/dist/exec/migrate-records.js +249 -0
  29. package/dist/exec/parent-validation.js +153 -12
  30. package/dist/exec/pipeline-state.js +27 -5
  31. package/dist/exec/plans-condense-findings.js +89 -0
  32. package/dist/exec/plans-core.js +24 -17
  33. package/dist/exec/plans-generation.js +48 -25
  34. package/dist/exec/plans-grade-findings.js +8 -3
  35. package/dist/exec/plans-kata-findings.js +61 -0
  36. package/dist/exec/plans-planning.js +3 -3
  37. package/dist/exec/plans-storage.js +12 -24
  38. package/dist/exec/register-resume.js +55 -56
  39. package/dist/exec/register.js +26 -22
  40. package/dist/exec/repo-integration-sync.js +8 -4
  41. package/dist/exec/repo-integration.js +21 -1
  42. package/dist/exec/reporter.js +121 -23
  43. package/dist/exec/results.js +85 -24
  44. package/dist/exec/review-completion.js +47 -0
  45. package/dist/exec/review-kata.js +109 -0
  46. package/dist/exec/run/agent-pipeline.js +75 -6
  47. package/dist/exec/run/agent.js +20 -7
  48. package/dist/exec/run/in-place.js +69 -32
  49. package/dist/exec/run/job.js +81 -24
  50. package/dist/exec/run/lifecycle-commands.js +188 -36
  51. package/dist/exec/run/mode-shared.js +11 -3
  52. package/dist/exec/run/register-command.js +6 -10
  53. package/dist/exec/run/register-core.js +20 -13
  54. package/dist/exec/run/register-mode.js +12 -12
  55. package/dist/exec/run/register-post-review.js +21 -9
  56. package/dist/exec/run/register-resume.js +28 -18
  57. package/dist/exec/run/register-state.js +10 -7
  58. package/dist/exec/run/register-worktree.js +60 -30
  59. package/dist/exec/run/schedule-mode.js +4 -4
  60. package/dist/exec/run/schedule-prepare.js +201 -59
  61. package/dist/exec/run/schedule-task.js +129 -25
  62. package/dist/exec/run/shared.js +4 -3
  63. package/dist/exec/run/trailing-records.js +35 -0
  64. package/dist/exec/run-records.js +2 -0
  65. package/dist/exec/strategy.js +1 -0
  66. package/dist/exec/trailing-records.js +242 -0
  67. package/dist/exec/trial-commands.js +3 -2
  68. package/dist/exec/validate-records-commit.js +110 -0
  69. package/dist/exec/validate-records.js +148 -0
  70. package/dist/exec/worktree-command.js +29 -16
  71. package/dist/exec/worktree-ops-commit.js +119 -48
  72. package/dist/exec/worktree-ops-lifecycle.js +77 -48
  73. package/dist/exec/worktree-ops-merge.js +13 -2
  74. package/dist/exec/worktree-ops.js +2 -2
  75. package/dist/exec/worktree.js +19 -2
  76. package/dist/grade/apply.js +32 -6
  77. package/dist/grade/command-inspect.js +2 -2
  78. package/dist/grade/command-run.js +2 -0
  79. package/dist/grade/command-shared.js +1 -1
  80. package/dist/grade/core.js +18 -5
  81. package/dist/grade/markdown.js +3 -3
  82. package/dist/grade/pipeline-state.js +15 -11
  83. package/dist/grade/plan.js +37 -17
  84. package/dist/grade/result.js +3 -3
  85. package/dist/grade/run.js +23 -3
  86. package/dist/grade/target-discovery.js +17 -4
  87. package/dist/grade/targets.js +12 -11
  88. package/dist/job/job.js +31 -17
  89. package/dist/job/noop.js +104 -0
  90. package/dist/register/core.js +2 -0
  91. package/dist/register/create-commands.js +28 -3
  92. package/dist/register/deliverable-target.js +9 -1
  93. package/dist/register/epic.js +104 -26
  94. package/dist/register/event-merge.js +3 -0
  95. package/dist/register/events.js +4 -0
  96. package/dist/register/external-project.js +3 -0
  97. package/dist/register/item.js +6 -0
  98. package/dist/register/maintenance-commands.js +4 -1
  99. package/dist/register/planning.js +7 -14
  100. package/dist/register/register.js +43 -9
  101. package/dist/register/track-domains.js +34 -0
  102. package/dist/register/track-plan.js +78 -0
  103. package/dist/register/transition-commands.js +8 -0
  104. package/dist/register/work-table.js +64 -0
  105. package/dist/review/grade.js +35 -13
  106. package/dist/routine/definition.js +4 -3
  107. package/dist/routine/failure.js +30 -0
  108. package/dist/routine/routine.js +56 -32
  109. package/dist/routine/storage.js +33 -0
  110. package/dist/schedule/schedule.js +1 -0
  111. package/dist/schedule/strategy-generate-document.js +26 -14
  112. package/dist/schedule/strategy-generate-scope.js +17 -45
  113. package/dist/schedule/strategy-generate.js +33 -3
  114. package/dist/schedule/strategy-profiles.js +86 -12
  115. package/dist/shared/agent-types.js +2 -0
  116. package/dist/shared/condense-records.js +25 -0
  117. package/dist/shared/deprecation.js +8 -0
  118. package/dist/shared/document-metadata.js +20 -0
  119. package/dist/shared/finding-cause.js +20 -0
  120. package/dist/shared/frontmatter-namespace.js +48 -0
  121. package/dist/shared/git.js +142 -15
  122. package/dist/shared/grade-result.js +17 -1
  123. package/dist/shared/local-state.js +20 -0
  124. package/dist/shared/markdownlint-config.js +8 -3
  125. package/dist/shared/plan-conventions.js +129 -0
  126. package/dist/shared/plan-templates.js +57 -41
  127. package/dist/shared/run-records.js +224 -0
  128. package/dist/shared/specdojo-config.js +39 -21
  129. package/dist/shared/text.js +65 -5
  130. package/dist/shared/timeline-index.js +2 -0
  131. package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +9 -2
  132. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +4 -74
  133. package/docs/ja/specdojo/exec-templates/xep-condense-template.md +50 -0
  134. package/docs/ja/specdojo/exec-templates/xep-draft-template.md +17 -5
  135. package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +16 -3
  136. package/docs/ja/specdojo/exec-templates/xep-recipe-guided-template.md +15 -5
  137. package/docs/ja/specdojo/exec-templates/xep-recipe-maintenance-template.md +6 -0
  138. package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -1
  139. package/docs/ja/specdojo/exec-templates/xep-rulebook-maintenance-template.md +6 -0
  140. package/docs/ja/specdojo/exec-templates/xep-sample-maintenance-template.md +6 -0
  141. package/docs/ja/specdojo/exec-templates/xep-template-maintenance-template.md +6 -0
  142. package/docs/ja/specdojo/exec-templates/xer-condense-template.md +25 -0
  143. package/docs/ja/specdojo/exec-templates/xp-common-conventions-template.md +50 -0
  144. package/docs/ja/specdojo/exec-templates/xrp-common-conventions-template.md +30 -0
  145. package/docs/ja/specdojo/guides/branch-workflow-guide.md +1 -1
  146. package/docs/ja/specdojo/guides/docs-editing-guide.md +12 -0
  147. package/docs/ja/specdojo/guides/docs-structure-guide.md +48 -15
  148. package/docs/ja/specdojo/guides/exec-config-guide.md +47 -16
  149. package/docs/ja/specdojo/guides/exec-operation-guide.md +53 -17
  150. package/docs/ja/specdojo/guides/exec-worktree-guide.md +20 -11
  151. package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +92 -55
  152. package/docs/ja/specdojo/guides/project-move-guide.md +381 -0
  153. package/docs/ja/specdojo/guides/quick-start-guide.md +70 -14
  154. package/docs/ja/specdojo/guides/register-operation-guide.md +25 -5
  155. package/docs/ja/specdojo/guides/remote-host-development-guide.md +2 -0
  156. package/docs/ja/specdojo/guides/review-guide.md +22 -19
  157. package/docs/ja/specdojo/guides/routine-operation-guide.md +14 -8
  158. package/docs/ja/specdojo/guides/ryu-guide.md +23 -13
  159. package/docs/ja/specdojo/guides/schedule-design-guide.md +7 -4
  160. package/docs/ja/specdojo/guides/schedule-operation-guide.md +27 -3
  161. package/docs/ja/specdojo/guides/specdojo-overview-guide.md +5 -4
  162. package/docs/ja/specdojo/guides/timeline-design-guide.md +27 -144
  163. package/docs/ja/specdojo/guides/use-case-guide.md +92 -155
  164. package/docs/ja/specdojo/recipes/bac-recipe.md +94 -0
  165. package/docs/ja/specdojo/recipes/bes-recipe.md +105 -0
  166. package/docs/ja/specdojo/recipes/br-recipe.md +84 -0
  167. package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +36 -24
  168. package/docs/ja/specdojo/recipes/cnd-recipe.md +125 -0
  169. package/docs/ja/specdojo/recipes/cpd-recipe.md +126 -0
  170. package/docs/ja/specdojo/recipes/cxd-recipe.md +145 -0
  171. package/docs/ja/specdojo/recipes/ifd-recipe.md +134 -0
  172. package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +135 -86
  173. package/docs/ja/specdojo/recipes/ifx-index-recipe.md +130 -0
  174. package/docs/ja/specdojo/recipes/pm-organization-recipe.md +29 -26
  175. package/docs/ja/specdojo/recipes/pm-plan-recipe.md +35 -26
  176. package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +38 -28
  177. package/docs/ja/specdojo/recipes/pm-raci-recipe.md +39 -31
  178. package/docs/ja/specdojo/recipes/pm-roles-recipe.md +26 -28
  179. package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +10 -8
  180. package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +18 -17
  181. package/docs/ja/specdojo/recipes/stsd-recipe.md +100 -62
  182. package/docs/ja/specdojo/recipes/sysd-critical-flows-recipe.md +106 -0
  183. package/docs/ja/specdojo/recipes/sysd-cross-cutting-policy-recipe.md +137 -0
  184. package/docs/ja/specdojo/recipes/sysd-index-recipe.md +122 -0
  185. package/docs/ja/specdojo/references/command-reference.md +79 -64
  186. package/docs/ja/specdojo/references/deliverables-reference.md +9 -4
  187. package/docs/ja/specdojo/references/directory-layout-reference.md +3 -2
  188. package/docs/ja/specdojo/references/specdojo-config-reference.md +17 -16
  189. package/docs/ja/specdojo/rulebooks/bac-rulebook.md +72 -290
  190. package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +212 -79
  191. package/docs/ja/specdojo/rulebooks/bds-rulebook.md +138 -154
  192. package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +147 -59
  193. package/docs/ja/specdojo/rulebooks/bes-rulebook.md +100 -96
  194. package/docs/ja/specdojo/rulebooks/br-rulebook.md +88 -108
  195. package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +126 -211
  196. package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +56 -35
  197. package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +102 -68
  198. package/docs/ja/specdojo/rulebooks/cdt-rulebook.md +152 -0
  199. package/docs/ja/specdojo/rulebooks/cld-rulebook.md +9 -184
  200. package/docs/ja/specdojo/rulebooks/clis-rulebook.md +187 -0
  201. package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +93 -247
  202. package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +104 -241
  203. package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +124 -257
  204. package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +87 -98
  205. package/docs/ja/specdojo/rulebooks/dct-rulebook.md +9 -7
  206. package/docs/ja/specdojo/rulebooks/dec-rulebook.md +2 -1
  207. package/docs/ja/specdojo/rulebooks/dss-rulebook.md +193 -0
  208. package/docs/ja/specdojo/rulebooks/gl-rulebook.md +100 -54
  209. package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +69 -252
  210. package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +91 -76
  211. package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +252 -226
  212. package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +118 -40
  213. package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +11 -11
  214. package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +9 -9
  215. package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +4 -4
  216. package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +11 -11
  217. package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +11 -11
  218. package/docs/ja/specdojo/rulebooks/mm-rulebook.md +4 -3
  219. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +34 -29
  220. package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +8 -8
  221. package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +2 -2
  222. package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +50 -56
  223. package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +46 -55
  224. package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +57 -54
  225. package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +50 -65
  226. package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +2 -2
  227. package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +70 -97
  228. package/docs/ja/specdojo/rulebooks/pr-rulebook.md +2 -1
  229. package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +47 -56
  230. package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +61 -135
  231. package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +116 -32
  232. package/docs/ja/specdojo/rulebooks/sf-rulebook.md +118 -61
  233. package/docs/ja/specdojo/rulebooks/sld-rulebook.md +152 -57
  234. package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +51 -39
  235. package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +101 -46
  236. package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +72 -329
  237. package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +74 -263
  238. package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +78 -195
  239. package/docs/ja/specdojo/rulebooks/tml-rulebook.md +4 -9
  240. package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +3 -4
  241. package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +3 -3
  242. package/docs/ja/specdojo/rulebooks/uis-rulebook.md +140 -143
  243. package/docs/ja/specdojo/samples/bac-sample.md +106 -21
  244. package/docs/ja/specdojo/samples/bdd-sample.yaml +143 -35
  245. package/docs/ja/specdojo/samples/bds-sample.md +100 -21
  246. package/docs/ja/specdojo/samples/bes-index-sample.md +59 -20
  247. package/docs/ja/specdojo/samples/bes-sample.md +80 -21
  248. package/docs/ja/specdojo/samples/br-sample.md +68 -14
  249. package/docs/ja/specdojo/samples/ccd-sample.md +81 -19
  250. package/docs/ja/specdojo/samples/cdfd-sample.md +172 -99
  251. package/docs/ja/specdojo/samples/cdfd-uc-sample.md +9 -7
  252. package/docs/ja/specdojo/samples/cdsd-sample.md +89 -20
  253. package/docs/ja/specdojo/samples/cdt-sample.md +116 -0
  254. package/docs/ja/specdojo/samples/cld-sample.md +3 -30
  255. package/docs/ja/specdojo/samples/clis-sample.md +132 -0
  256. package/docs/ja/specdojo/samples/cnd-sample.md +127 -21
  257. package/docs/ja/specdojo/samples/cpd-sample.md +136 -22
  258. package/docs/ja/specdojo/samples/cxd-sample.md +108 -22
  259. package/docs/ja/specdojo/samples/dct-index-sample.yaml +63 -17
  260. package/docs/ja/specdojo/samples/dss-sample.md +175 -0
  261. package/docs/ja/specdojo/samples/gl-sample.yaml +50 -14
  262. package/docs/ja/specdojo/samples/ifd-sample.md +105 -21
  263. package/docs/ja/specdojo/samples/ifx-cmd-sample.yaml +91 -60
  264. package/docs/ja/specdojo/samples/ifx-file-sample.md +462 -21
  265. package/docs/ja/specdojo/samples/ifx-index-sample.yaml +87 -19
  266. package/docs/ja/specdojo/samples/pm-members-sample.yaml +37 -13
  267. package/docs/ja/specdojo/samples/pm-organization-sample.md +52 -20
  268. package/docs/ja/specdojo/samples/pm-plan-sample.md +84 -26
  269. package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +55 -22
  270. package/docs/ja/specdojo/samples/pm-raci-sample.md +69 -28
  271. package/docs/ja/specdojo/samples/pm-roles-sample.yaml +13 -12
  272. package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +50 -26
  273. package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +89 -62
  274. package/docs/ja/specdojo/samples/sf-index-sample.md +89 -20
  275. package/docs/ja/specdojo/samples/sf-sample.md +121 -21
  276. package/docs/ja/specdojo/samples/sld-sample.md +107 -21
  277. package/docs/ja/specdojo/samples/stsd-sample.md +54 -26
  278. package/docs/ja/specdojo/samples/sysd-critical-flows-sample.md +166 -21
  279. package/docs/ja/specdojo/samples/sysd-cross-cutting-policy-sample.md +178 -21
  280. package/docs/ja/specdojo/samples/sysd-index-sample.md +82 -21
  281. package/docs/ja/specdojo/samples/tml-sample.yaml +4 -1
  282. package/docs/ja/specdojo/samples/uis-sample.md +164 -20
  283. package/docs/ja/specdojo/standards/document-metadata-standard.md +33 -4
  284. package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +3 -1
  285. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +1 -0
  286. package/docs/ja/specdojo/templates/bac-template.md +76 -0
  287. package/docs/ja/specdojo/templates/bes-template.md +56 -0
  288. package/docs/ja/specdojo/templates/br-template.md +64 -0
  289. package/docs/ja/specdojo/templates/cdfd-template.md +81 -54
  290. package/docs/ja/specdojo/templates/cdfd-uc-template.md +9 -5
  291. package/docs/ja/specdojo/templates/cnd-template.md +137 -0
  292. package/docs/ja/specdojo/templates/cpd-template.md +129 -0
  293. package/docs/ja/specdojo/templates/cxd-template.md +105 -0
  294. package/docs/ja/specdojo/templates/dct-data-model-cdt-template.yaml +40 -0
  295. package/docs/ja/specdojo/templates/dct-data-model-cld-template.yaml +7 -14
  296. package/docs/ja/specdojo/templates/dct-index-template.md +9 -20
  297. package/docs/ja/specdojo/templates/dct-project-management-template.yaml +5 -1
  298. package/docs/ja/specdojo/templates/ifd-template.md +86 -0
  299. package/docs/ja/specdojo/templates/ifx-cmd-template.yaml +44 -28
  300. package/docs/ja/specdojo/templates/ifx-index-template.yaml +40 -0
  301. package/docs/ja/specdojo/templates/opr-template.md +2 -4
  302. package/docs/ja/specdojo/templates/pm-organization-template.md +9 -3
  303. package/docs/ja/specdojo/templates/pm-plan-template.md +4 -4
  304. package/docs/ja/specdojo/templates/pm-quality-management-plan-template.md +17 -9
  305. package/docs/ja/specdojo/templates/pm-raci-template.md +24 -13
  306. package/docs/ja/specdojo/templates/pm-roles-template.yaml +3 -2
  307. package/docs/ja/specdojo/templates/prj-assumptions-constraints-dependencies-template.md +6 -3
  308. package/docs/ja/specdojo/templates/prj-comparison-of-alternatives-template.md +22 -19
  309. package/docs/ja/specdojo/templates/stsd-template.md +46 -21
  310. package/docs/ja/specdojo/templates/sysd-critical-flows-template.md +94 -0
  311. package/docs/ja/specdojo/templates/sysd-cross-cutting-policy-template.md +122 -0
  312. package/docs/ja/specdojo/templates/sysd-index-template.md +89 -0
  313. package/docs/specdojo/lib/yaml-metadata.cjs +7 -0
  314. package/docs/specdojo/schemas/v1/bdd.schema.yaml +25 -57
  315. package/docs/specdojo/schemas/v1/condense-records.schema.yaml +26 -0
  316. package/docs/specdojo/schemas/v1/dct.schema.yaml +10 -0
  317. package/docs/specdojo/schemas/v1/deliverable-frontmatter.schema.yaml +3 -0
  318. package/docs/specdojo/schemas/v1/esil.schema.yaml +7 -141
  319. package/docs/specdojo/schemas/v1/exec-common.schema.yaml +3 -0
  320. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +53 -3
  321. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +3 -0
  322. package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +14 -0
  323. package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +18 -0
  324. package/docs/specdojo/schemas/v1/finding-cause.schema.yaml +22 -0
  325. package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +1 -1
  326. package/docs/specdojo/schemas/v1/grade-result.schema.yaml +2 -0
  327. package/docs/specdojo/schemas/v1/ifx-cmd.schema.yaml +65 -5
  328. package/docs/specdojo/schemas/v1/ifx-index.schema.yaml +142 -0
  329. package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
  330. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +17 -1
  331. package/package.json +2 -2
  332. package/templates/antigravity/orchestrator.md +3 -2
  333. package/templates/claude/agents/specdojo-orchestrator.md +3 -2
  334. package/templates/codex/agents/specdojo-orchestrator.toml +3 -2
  335. package/templates/codex/orchestrator.md +3 -2
  336. package/templates/devcontainer/tmux.conf +6 -0
  337. package/templates/opencode/agents/specdojo-orchestrator.md +3 -2
@@ -1,18 +1,20 @@
1
1
  import { spawnSync } from "node:child_process";
2
2
  import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
- import { join, resolve } from "node:path";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { repoRelative, stageCommitTargets, worktreeStatusPaths as statusPaths, } from "../shared/git.js";
5
+ import { DEFAULT_MARKDOWNLINT_CONFIG, hasMarkdownlintConfig, } from "../shared/markdownlint-config.js";
6
+ import { specdojoPackageRootDir } from "../shared/package-paths.js";
4
7
  import { load } from "../shared/yaml.js";
8
+ import { agentProtectedConfigPaths, agentProtectedConfigViolation, qualifiedRepoPaths, } from "./agent-protected-config.js";
5
9
  import { deliverableDocPath, parsePlanTaskIdentity, targetReferenceDirsForApproach, } from "./plans.js";
10
+ import { recordProtectedConfigBlockAcrossRepos, recordProtectionHandoff, } from "./protection-handoff.js";
6
11
  import { parseResultTaskIdentity } from "./results.js";
12
+ import { isOtherRunRecord, isPlanOrResultRecord, isRunRecordPath, recordPathForRead, recordStem, runRecordPrefixes, taskRecordPrefixes, } from "./run-records.js";
13
+ import { lefthookExcludeEnvironment } from "./commit-hook-skips.js";
7
14
  import { stripTerminalControlSequences } from "./shared.js";
8
- import { agentProtectedConfigPaths, agentProtectedConfigViolation, qualifiedRepoPaths, } from "./agent-protected-config.js";
9
- import { recordProtectedConfigBlockAcrossRepos } from "./protection-handoff.js";
10
15
  import { assertNoPendingProductChanges, productIntegrationTarget } from "./task-repos.js";
11
- import { specdojoPackageRootDir } from "../shared/package-paths.js";
12
- import { DEFAULT_MARKDOWNLINT_CONFIG, hasMarkdownlintConfig, } from "../shared/markdownlint-config.js";
13
- import { repoRelative, stageCommitTargets, worktreeStatusPaths as statusPaths, } from "../shared/git.js";
16
+ import { appendGitFailureLog, appendGitResultFailureLog, formatGitResultFailure, gitEnvironment, gitOutput, gitResult, summarizeGitHookFailure, } from "./worktree.js";
14
17
  export { repoRelative, selectStageablePaths, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "../shared/git.js";
15
- import { appendGitFailureLog, appendGitResultFailureLog, formatGitResultFailure, gitEnvironment, gitOutput, gitResult, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./worktree.js";
16
18
  const MAX_COMMIT_STABILIZATION_ATTEMPTS = 3;
17
19
  export function currentBranch(repoRoot) {
18
20
  const branch = gitOutput(repoRoot, ["branch", "--show-current"]).trim();
@@ -20,27 +22,31 @@ export function currentBranch(repoRoot) {
20
22
  throw new Error("Detached HEAD is not supported for exec worktree commands.");
21
23
  return branch;
22
24
  }
23
- export function taskPaths(context, taskId) {
25
+ export function taskPaths(context, taskId, worktreePath = context.repoRoot) {
24
26
  const executionRel = repoRelative(context.repoRoot, context.executionPath);
27
+ const executionPath = resolve(worktreePath, executionRel);
25
28
  return {
26
29
  executionRel,
27
- planRel: `${executionRel}/exec/plans/${taskId}-plan.md`,
28
- resultRel: `${executionRel}/exec/results/${taskId}-result.md`,
30
+ planRel: repoRelative(worktreePath, recordPathForRead(executionPath, "plan", taskId)),
31
+ resultRel: repoRelative(worktreePath, recordPathForRead(executionPath, "result", taskId)),
29
32
  };
30
33
  }
31
- export function isCommitTargetPath(path, executionRel, resultRel) {
34
+ export function isCommitTargetPath(path, executionRel, resultRel, allowedPlanRel, currentRunPrefixes = []) {
32
35
  const normalized = path.replaceAll("\\", "/");
33
36
  if (normalized === resultRel)
34
37
  return true;
38
+ if (allowedPlanRel && normalized === allowedPlanRel)
39
+ return true;
35
40
  // doc-index は root と worktree の双方で再生成される生成物。commit-target に含めると
36
41
  // merge 時の overlap ガードで衝突するため除外する。
37
42
  if (normalized === ".specdojo/doc-index.json")
38
43
  return false;
39
44
  if (normalized === "tmp" || normalized.startsWith("tmp/"))
40
45
  return false;
41
- if (normalized.startsWith(`${executionRel}/exec/plans/`))
46
+ if (isPlanOrResultRecord(normalized))
42
47
  return false;
43
- if (normalized.startsWith(`${executionRel}/exec/results/`))
48
+ if (isOtherRunRecord(normalized, resultRel) &&
49
+ !currentRunPrefixes.some((prefix) => normalized.startsWith(prefix)))
44
50
  return false;
45
51
  if (normalized.startsWith(`${executionRel}/exec/events/`))
46
52
  return false;
@@ -48,6 +54,13 @@ export function isCommitTargetPath(path, executionRel, resultRel) {
48
54
  return false;
49
55
  return true;
50
56
  }
57
+ // Commit evidence and logs only from the run containing the selected result.
58
+ function currentRunPrefixes(context, worktree, taskId, resultRel) {
59
+ const { executionRel, planRel } = taskPaths(context, taskId, worktree.path);
60
+ const plan = readWorktreeHeadFile(worktree.path, planRel);
61
+ const recordTaskId = (plan ? parsePlanTaskIdentity(plan)?.taskId : undefined) ?? taskId;
62
+ return runRecordPrefixes(executionRel, recordTaskId, recordStem(resultRel));
63
+ }
51
64
  // Reads a deliverable's frontmatter `status`. Markdown deliverables carry it in the
52
65
  // leading `---` frontmatter block; yaml/json deliverables carry it as a top-level field.
53
66
  // Returns undefined when absent or unparsable (treated as "not ready").
@@ -84,14 +97,14 @@ export function deliverableStatus(content, relPath) {
84
97
  // that transitions a deliverable to "ready" here; humans promote out-of-band via a direct
85
98
  // edit and git commit, which never passes through this path.
86
99
  function assertNoAgentReadyPromotion(context, worktree, taskId, paths) {
87
- const { resultRel } = taskPaths(context, taskId);
100
+ const { planRel, resultRel } = taskPaths(context, taskId, worktree.path);
88
101
  const resultContent = readWorktreeHeadFile(worktree.path, resultRel);
89
102
  if (resultContent && parseResultTaskIdentity(resultContent)?.execution === "human") {
90
103
  return;
91
104
  }
92
105
  const promoted = [];
93
106
  for (const relPath of paths) {
94
- if (relPath === resultRel)
107
+ if (relPath === resultRel || relPath === planRel)
95
108
  continue;
96
109
  const absPath = resolve(worktree.path, relPath);
97
110
  if (!existsSync(absPath))
@@ -110,7 +123,7 @@ function assertNoAgentReadyPromotion(context, worktree, taskId, paths) {
110
123
  }
111
124
  }
112
125
  function isHumanWorktreeExecution(context, worktree, taskId) {
113
- const { resultRel } = taskPaths(context, taskId);
126
+ const { resultRel } = taskPaths(context, taskId, worktree.path);
114
127
  const resultContent = readWorktreeHeadFile(worktree.path, resultRel);
115
128
  return !!resultContent && parseResultTaskIdentity(resultContent)?.execution === "human";
116
129
  }
@@ -120,7 +133,7 @@ function isHumanWorktreeExecution(context, worktree, taskId) {
120
133
  function assertNoAgentProtectedConfigChanges(context, worktree, taskId) {
121
134
  if (isHumanWorktreeExecution(context, worktree, taskId))
122
135
  return;
123
- const { resultRel } = taskPaths(context, taskId);
136
+ const { resultRel } = taskPaths(context, taskId, worktree.path);
124
137
  const rootHead = gitOutput(context.repoRoot, ["rev-parse", "HEAD"]).trim();
125
138
  const compareBase = gitOutput(worktree.path, ["merge-base", "HEAD", rootHead]).trim();
126
139
  const committed = zeroSeparatedPaths(worktree.path, [
@@ -213,8 +226,8 @@ function headDocIndexLookup(worktreePath) {
213
226
  // 導出する。いずれも task 識別を復元できない場合は null を返し、呼び出し側は従来の
214
227
  // 除外リスト方式へフォールバックする。checkpoint 済みの HEAD を読むため、agent の
215
228
  // working tree 改変からは影響を受けない。
216
- export function resolveCommitScope(context, worktree, taskId) {
217
- const { executionRel, planRel, resultRel } = taskPaths(context, taskId);
229
+ export function resolveCommitScope(context, worktree, taskId, options = {}) {
230
+ const { executionRel, planRel, resultRel } = taskPaths(context, taskId, worktree.path);
218
231
  const resultContent = readWorktreeHeadFile(worktree.path, resultRel);
219
232
  const resultIdentity = resultContent ? parseResultTaskIdentity(resultContent) : null;
220
233
  const planContent = readWorktreeHeadFile(worktree.path, planRel);
@@ -226,7 +239,11 @@ export function resolveCommitScope(context, worktree, taskId) {
226
239
  return { scope: null, unresolvedTargets: [] };
227
240
  if (identity.mode === "review") {
228
241
  return {
229
- scope: { mode: "review", allowedFiles: [resultRel], allowedDirPrefixes: [] },
242
+ scope: {
243
+ mode: "review",
244
+ allowedFiles: [resultRel, ...(options.allowEditedPlan ? [planRel] : [])],
245
+ allowedDirPrefixes: taskRecordPrefixes(executionRel, taskId),
246
+ },
230
247
  unresolvedTargets: [],
231
248
  };
232
249
  }
@@ -243,7 +260,7 @@ export function resolveCommitScope(context, worktree, taskId) {
243
260
  `Schedule-originated edit tasks must declare targets; ` +
244
261
  `register-originated tasks must declare "origin: register".`);
245
262
  }
246
- const allowedFiles = new Set([resultRel]);
263
+ const allowedFiles = new Set([resultRel, ...(options.allowEditedPlan ? [planRel] : [])]);
247
264
  const unresolvedTargets = [];
248
265
  const lookup = headDocIndexLookup(worktree.path);
249
266
  for (const target of identity.targets ?? []) {
@@ -273,7 +290,7 @@ export function resolveCommitScope(context, worktree, taskId) {
273
290
  // Pipeline evidence is runner-owned and stored per task/run. It must be committed together with
274
291
  // the eventual reporter-generated result so the structured executor record survives worktree
275
292
  // removal. Legacy tasks create no files under this prefix, so their commit scope is unchanged.
276
- allowedDirPrefixes.push(`${executionRel}/exec/evidence/${worktreeNameFromTaskId(taskId)}/`);
293
+ allowedDirPrefixes.push(...taskRecordPrefixes(executionRel, taskId));
277
294
  return {
278
295
  scope: { mode: "edit", allowedFiles: [...allowedFiles], allowedDirPrefixes },
279
296
  unresolvedTargets,
@@ -282,7 +299,7 @@ export function resolveCommitScope(context, worktree, taskId) {
282
299
  // checkpoint 済みの HEAD の plan(human は result)frontmatter の targets。agent の working tree
283
300
  // 改変の影響を受けない。プロダクトリポジトリの commit 対象(`<repo>:<path>`)の導出に使う。
284
301
  export function taskTargetsAtHead(context, worktree, taskId) {
285
- const { planRel, resultRel } = taskPaths(context, taskId);
302
+ const { planRel, resultRel } = taskPaths(context, taskId, worktree.path);
286
303
  const resultContent = readWorktreeHeadFile(worktree.path, resultRel);
287
304
  const resultIdentity = resultContent ? parseResultTaskIdentity(resultContent) : null;
288
305
  if (resultIdentity?.execution === "human")
@@ -314,7 +331,7 @@ export const REGISTER_NEW_FILE_DIR_PREFIXES = [
314
331
  // evidence 配下・個票 targets から解決したパスに限り、それ以外を commit 範囲外とする。
315
332
  // 既存ファイルの変更と削除は従来どおり除外リスト方式で判定する。
316
333
  function registerNewFileIsAllowed(worktree, context, taskId) {
317
- const { executionRel, planRel, resultRel } = taskPaths(context, taskId);
334
+ const { executionRel, planRel, resultRel } = taskPaths(context, taskId, worktree.path);
318
335
  const topLevelDirs = zeroSeparatedPaths(worktree.path, [
319
336
  "ls-tree",
320
337
  "-d",
@@ -325,7 +342,7 @@ function registerNewFileIsAllowed(worktree, context, taskId) {
325
342
  const allowedDirPrefixes = [
326
343
  ...REGISTER_NEW_FILE_DIR_PREFIXES,
327
344
  ...topLevelDirs,
328
- `${executionRel}/exec/evidence/${worktreeNameFromTaskId(taskId)}/`,
345
+ ...taskRecordPrefixes(executionRel, taskId),
329
346
  ];
330
347
  const planContent = readWorktreeHeadFile(worktree.path, planRel);
331
348
  const targets = (planContent ? parsePlanTaskIdentity(planContent) : null)?.targets ?? [];
@@ -355,42 +372,90 @@ function pathsTrackedAtHead(worktreePath, paths) {
355
372
  ]));
356
373
  }
357
374
  function isRegisterOriginTask(context, worktree, taskId) {
358
- const planContent = readWorktreeHeadFile(worktree.path, taskPaths(context, taskId).planRel);
375
+ const planContent = readWorktreeHeadFile(worktree.path, taskPaths(context, taskId, worktree.path).planRel);
359
376
  return (planContent ? parsePlanTaskIdentity(planContent) : null)?.origin === "register";
360
377
  }
361
378
  // worktree の変更を「commit するパス」「許可リスト外のため commit しないパス」に分ける。
362
379
  // 除外リスト(isCommitTargetPath)は許可リストの内側でも引き続き適用する。
363
- export function partitionCommitTargets(context, worktree, taskId) {
364
- const { executionRel, resultRel } = taskPaths(context, taskId);
365
- const candidates = statusPaths(worktree.path).filter((path) => isCommitTargetPath(path, executionRel, resultRel));
366
- const { scope, unresolvedTargets } = resolveCommitScope(context, worktree, taskId);
380
+ export function partitionCommitTargets(context, worktree, taskId, options = {}) {
381
+ const { executionRel, planRel, resultRel } = taskPaths(context, taskId, worktree.path);
382
+ const allowedPlanRel = options.allowEditedPlan ? planRel : undefined;
383
+ const runPrefixes = currentRunPrefixes(context, worktree, taskId, resultRel);
384
+ const changes = statusPaths(worktree.path);
385
+ const candidates = changes.filter((path) => isCommitTargetPath(path, executionRel, resultRel, allowedPlanRel, runPrefixes));
386
+ // Do not silently discard run records via the exclusion filter: report them using
387
+ // the same stdout/integrate.log warning as other changes outside the commit scope.
388
+ const excludedRecords = changes.filter((path) => isRunRecordPath(path) && !candidates.includes(path));
389
+ const { scope, unresolvedTargets } = resolveCommitScope(context, worktree, taskId, options);
367
390
  if (!scope) {
368
391
  // 人間の作業は agent の一時ファイル対策の対象外とし、従来どおり除外リスト方式で commit する。
369
392
  if (!isRegisterOriginTask(context, worktree, taskId) ||
370
393
  isHumanWorktreeExecution(context, worktree, taskId)) {
371
- return { targets: candidates, outOfScope: [], unresolvedTargets };
394
+ return { targets: candidates, outOfScope: excludedRecords, unresolvedTargets };
372
395
  }
373
396
  const tracked = pathsTrackedAtHead(worktree.path, candidates);
374
397
  const isAllowedNewFile = registerNewFileIsAllowed(worktree, context, taskId);
375
398
  const targets = [];
376
- const outOfScope = [];
399
+ const outOfScope = [...excludedRecords];
377
400
  for (const path of candidates) {
378
- const allowed = tracked.has(path) || isAllowedNewFile(path);
401
+ const allowed = runPrefixes.some((prefix) => path.startsWith(prefix)) ||
402
+ tracked.has(path) ||
403
+ isAllowedNewFile(path);
379
404
  (allowed ? targets : outOfScope).push(path);
380
405
  }
381
406
  return { targets, outOfScope, unresolvedTargets };
382
407
  }
383
408
  const targets = [];
384
- const outOfScope = [];
409
+ const outOfScope = [...excludedRecords];
385
410
  for (const path of candidates) {
386
- const allowed = scope.allowedFiles.includes(path) ||
411
+ const allowed = runPrefixes.some((prefix) => path.startsWith(prefix)) ||
412
+ scope.allowedFiles.includes(path) ||
387
413
  scope.allowedDirPrefixes.some((prefix) => path.startsWith(prefix));
388
414
  (allowed ? targets : outOfScope).push(path);
389
415
  }
390
416
  return { targets, outOfScope, unresolvedTargets };
391
417
  }
392
- export function commitTargetPaths(context, worktree, taskId) {
393
- return partitionCommitTargets(context, worktree, taskId).targets;
418
+ export function commitTargetPaths(context, worktree, taskId, options = {}) {
419
+ return partitionCommitTargets(context, worktree, taskId, options).targets;
420
+ }
421
+ export class UncommittedChangesError extends Error {
422
+ files;
423
+ constructor(files, logPath) {
424
+ const sample = files.slice(0, 3).join(", ");
425
+ super(`uncommitted=${files.length}; log=${logPath}; files=${sample}${files.length > 3 ? ", …" : ""}`);
426
+ this.files = files;
427
+ this.name = "UncommittedChangesError";
428
+ }
429
+ }
430
+ // Agent integration must retain every non-target change for review, regardless of origin.
431
+ // In particular, dropping an untracked move destination loses the deliverable.
432
+ export function assertCommitScope(context, worktree, taskId, options = {}) {
433
+ // Human schedule tasks retain their explicit result-based selection behavior.
434
+ if (isHumanWorktreeExecution(context, worktree, taskId) &&
435
+ !isRegisterOriginTask(context, worktree, taskId))
436
+ return;
437
+ const { outOfScope } = partitionCommitTargets(context, worktree, taskId, options);
438
+ if (outOfScope.length === 0)
439
+ return;
440
+ const { resultRel } = taskPaths(context, taskId, worktree.path);
441
+ const logPath = options.scopeLogPath ?? join(dirname(resolve(worktree.path, resultRel)), "integrate.log");
442
+ const warning = `commit-scope: integration blocked; ${outOfScope.length} non-target changes (worktree kept):\n` +
443
+ `${outOfScope.map((path) => ` ${path}`).join("\n")}\n`;
444
+ process.stdout.write(warning);
445
+ if (!options.dryRun) {
446
+ mkdirSync(resolve(logPath, ".."), { recursive: true });
447
+ appendFileSync(logPath, warning, "utf8");
448
+ recordProtectionHandoff(resolve(worktree.path, resultRel), {
449
+ mechanism: "agent-commit-scope",
450
+ subjectLabel: "commit 対象外のパス",
451
+ subjects: outOfScope,
452
+ reason: warning.trim(),
453
+ evidenceLabel: "次のアクション",
454
+ evidenceLanguage: "text",
455
+ evidence: "worktree を保持して統合を停止した。対象外の変更を確認し、必要な変更は targets の見直しまたは別タスクで取り込む。型のカタログ・schema・メニューなどの対象外ファイルは、変更理由と提案差分を報告してから executor を再開する。",
456
+ });
457
+ }
458
+ throw new UncommittedChangesError(outOfScope, repoRelative(worktree.path, logPath));
394
459
  }
395
460
  // markdownlint-cli の終了コード。1 だけが記法違反を表し、それ以外は実行環境の問題である。
396
461
  const MARKDOWNLINT_EXIT_LINT_ERRORS = 1;
@@ -416,7 +481,7 @@ export function normalizeResultWhitespace(resultPath) {
416
481
  writeFileSync(resultPath, normalized, "utf8");
417
482
  }
418
483
  export function assertResultMarkdownlint(context, worktree, taskId) {
419
- const { resultRel } = taskPaths(context, taskId);
484
+ const { resultRel } = taskPaths(context, taskId, worktree.path);
420
485
  const resultPath = resolve(worktree.path, resultRel);
421
486
  if (!existsSync(resultPath)) {
422
487
  process.stdout.write(`result-markdownlint: result ${resultRel} not found; skipped pre-commit lint\n`);
@@ -571,16 +636,17 @@ export function recordRootNewFilesHandoff(resultPath, files) {
571
636
  }
572
637
  // Commit the task result and deliverable changes inside the worktree onto its exec branch.
573
638
  // The commit is limited to the mode-based allowlist (resolveCommitScope); out-of-scope
574
- // changes stay uncommitted in the worktree and are reported. Excludes plans, events,
639
+ // changes block agent commits. Excludes plans, events,
575
640
  // generated files, and other tasks' results (see isCommitTargetPath).
576
641
  export function commitWorktreeChanges(params) {
577
- const { context, worktree, taskId } = params;
642
+ const { context, worktree, taskId, allowEditedPlan } = params;
578
643
  assertNoAgentProtectedConfigChanges(context, worktree, taskId);
579
644
  if (!params.productsIntegratedByCaller)
580
645
  assertNoPendingProductChanges(worktree);
581
- let partition = partitionCommitTargets(context, worktree, taskId);
646
+ assertCommitScope(context, worktree, taskId, params);
647
+ let partition = partitionCommitTargets(context, worktree, taskId, { allowEditedPlan });
582
648
  const scopeWarnings = [
583
- ...partition.unresolvedTargets.map((target) => `commit-scope: unresolved target doc id (not committable): ${target}\n`),
649
+ ...partition.unresolvedTargets.map((target) => `commit-scope: unresolved target doc id (no individual path; approach directory permissions still apply): ${target}\n`),
584
650
  ...(partition.outOfScope.length > 0
585
651
  ? [
586
652
  `commit-scope: skipped non-target changes (left in worktree):\n${partition.outOfScope
@@ -595,9 +661,9 @@ export function commitWorktreeChanges(params) {
595
661
  mkdirSync(resolve(params.scopeLogPath, ".."), { recursive: true });
596
662
  appendFileSync(params.scopeLogPath, scopeWarnings.join(""), "utf8");
597
663
  // 追記したログ自体を commit 対象に含めるため、分類をやり直す。
598
- partition = partitionCommitTargets(context, worktree, taskId);
664
+ partition = partitionCommitTargets(context, worktree, taskId, { allowEditedPlan });
599
665
  }
600
- const { resultRel } = taskPaths(context, taskId);
666
+ const { resultRel } = taskPaths(context, taskId, worktree.path);
601
667
  const trackedAtHead = pathsTrackedAtHead(worktree.path, partition.targets);
602
668
  const projectRootNewFiles = partition.targets.filter((path) => !path.includes("/") && !trackedAtHead.has(path) && path !== resultRel);
603
669
  if (projectRootNewFiles.length > 0) {
@@ -607,14 +673,14 @@ export function commitWorktreeChanges(params) {
607
673
  if (params.scopeLogPath && !params.dryRun) {
608
674
  mkdirSync(resolve(params.scopeLogPath, ".."), { recursive: true });
609
675
  appendFileSync(params.scopeLogPath, rootNewWarning, "utf8");
610
- partition = partitionCommitTargets(context, worktree, taskId);
676
+ partition = partitionCommitTargets(context, worktree, taskId, { allowEditedPlan });
611
677
  }
612
678
  }
613
679
  const allRootNewFiles = [...(params.productRootNewFiles ?? []), ...projectRootNewFiles];
614
680
  if (allRootNewFiles.length > 0 && !params.dryRun) {
615
681
  const resultPath = resolve(worktree.path, resultRel);
616
682
  if (recordRootNewFilesHandoff(resultPath, allRootNewFiles)) {
617
- partition = partitionCommitTargets(context, worktree, taskId);
683
+ partition = partitionCommitTargets(context, worktree, taskId, { allowEditedPlan });
618
684
  }
619
685
  }
620
686
  const paths = partition.targets;
@@ -645,7 +711,11 @@ export function commitWorktreeChanges(params) {
645
711
  "--",
646
712
  ...paths,
647
713
  ];
648
- const commit = gitResult(worktree.path, commitArgs);
714
+ const hookEnvironment = lefthookExcludeEnvironment(params.skipHooks ?? []);
715
+ if (hookEnvironment) {
716
+ process.stdout.write(`commit hooks skipped (covered by passed parent validations): ${(params.skipHooks ?? []).join(", ")}\n`);
717
+ }
718
+ const commit = gitResult(worktree.path, commitArgs, undefined, hookEnvironment);
649
719
  if (commit.status !== 0) {
650
720
  const output = [commit.stdout, commit.stderr]
651
721
  .filter((part) => typeof part === "string" && part.length > 0)
@@ -661,6 +731,7 @@ export function commitWorktreeChanges(params) {
661
731
  ]);
662
732
  throw new Error(`git commit failed: ${summarizeGitHookFailure(output)}`);
663
733
  }
664
- stabilizeCommitTargets(worktree.path, () => commitTargetPaths(context, worktree, taskId), undefined, params.failureLogPath);
734
+ stabilizeCommitTargets(worktree.path, () => commitTargetPaths(context, worktree, taskId, { allowEditedPlan }), undefined, params.failureLogPath);
735
+ assertCommitScope(context, worktree, taskId, params);
665
736
  return { targets: paths, committed: true };
666
737
  }
@@ -1,9 +1,10 @@
1
- import { copyFileSync, existsSync, lstatSync, mkdirSync, rmSync } from "node:fs";
1
+ import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, rmSync } from "node:fs";
2
+ import { withPlanConventionsFiles } from "../shared/plan-conventions.js";
2
3
  import { resolve } from "node:path";
3
4
  import { stripTerminalControlSequences } from "./shared.js";
4
5
  import { discardStaleProductWorktrees, ensureProductWorktrees, projectRepoDirName, productWorktreeRemovalBlockers, removeEmptyTaskDirectory, removeProductWorktrees, } from "./task-repos.js";
5
6
  import { appendGitFailureLog, appendGitResultFailureLog, ensureExecWorktree, execBranchExists, findExecWorktree, formatGitResultFailure, generateWorktreeArtifacts, gitOutput, gitResult, listRegisteredWorktrees, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./worktree.js";
6
- import { commitTargetPaths, currentBranch, repoRelative, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, zeroSeparatedPaths, } from "./worktree-ops-commit.js";
7
+ import { assertCommitScope, commitTargetPaths, currentBranch, repoRelative, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, zeroSeparatedPaths, } from "./worktree-ops-commit.js";
7
8
  // Remove a task worktree once its commit-target changes are committed and merged.
8
9
  export function removeWorktree(params) {
9
10
  const { context, worktree, taskId } = params;
@@ -11,6 +12,8 @@ export function removeWorktree(params) {
11
12
  throw new Error("Run remove from the merge-target worktree, not the task worktree.");
12
13
  }
13
14
  const dirty = commitTargetPaths(context, worktree, taskId);
15
+ if (!params.force)
16
+ assertCommitScope(context, worktree, taskId, { dryRun: params.dryRun });
14
17
  const merged = gitResult(context.repoRoot, ["merge-base", "--is-ancestor", worktree.branch, "HEAD"]).status ===
15
18
  0;
16
19
  if (!params.force && dirty.length > 0) {
@@ -234,7 +237,7 @@ function checkpointAndEnsureProjectWorktree(params, repoDirName, ensureSiblingWo
234
237
  if (currentBranch(context.repoRoot) === branch) {
235
238
  throw new Error(`Prepare must run from a branch other than ${branch}.`);
236
239
  }
237
- const paths = params.checkpointPaths.map((path) => repoRelative(context.repoRoot, path));
240
+ const paths = withPlanConventionsFiles(params.checkpointPaths).map((path) => repoRelative(context.repoRoot, path));
238
241
  const stagedFiles = zeroSeparatedPaths(context.repoRoot, [
239
242
  "diff",
240
243
  "--cached",
@@ -252,52 +255,78 @@ function checkpointAndEnsureProjectWorktree(params, repoDirName, ensureSiblingWo
252
255
  `${stagedFiles.map((path) => ` ${path}`).join("\n")}\n`);
253
256
  }
254
257
  const worktree = ensureProjectWorktree();
255
- for (const path of paths)
256
- copyCheckpointPath(context.repoRoot, worktree.path, path);
257
- try {
258
- stageCommitTargets(worktree.path, paths);
259
- const checkpointArgs = ["diff", "--cached", "--quiet", "--", ...paths];
260
- const checkpoint = gitResult(worktree.path, checkpointArgs);
261
- assertCheckpointInspection(checkpointArgs, checkpoint, params.failureLogPath);
262
- if (checkpoint.status === 1) {
263
- const committed = gitResult(worktree.path, [
264
- "commit",
265
- "-m",
266
- params.commitMessage,
267
- "--",
268
- ...paths,
269
- ]);
270
- if (committed.status !== 0) {
271
- // hook(lefthook 等)の生出力には ANSI エスケープや制御文字が含まれうる。この detail は
272
- // register 経路で pjr-index の結論列・result の理由欄へ伝播するため、ここで除去して
273
- // 表示崩れを防ぐ(register 側の sanitize と二重だが、非 register の呼び出し元も守る)。
274
- const output = [committed.stdout, committed.stderr]
275
- .map((part) => typeof part === "string" ? stripTerminalControlSequences(part).trim() : "")
276
- .filter(Boolean)
277
- .join("\n");
278
- appendGitFailureLog(params.failureLogPath, [
279
- `=== ${new Date().toISOString()} git commit checkpoint ===`,
280
- `exit: ${committed.status ?? "unknown"}`,
281
- "--- stdout ---",
282
- typeof committed.stdout === "string" ? committed.stdout : "",
283
- "--- stderr ---",
284
- typeof committed.stderr === "string" ? committed.stderr : "",
285
- "",
286
- ]);
287
- throw new Error(
288
- // register の短い block_reason にも step とエラーが残るよう、補足より先に要約を置く。
289
- `Checkpoint commit failed: ${summarizeGitHookFailure(output)} ` +
290
- `(${params.commitMessage}; staged changes rolled back; likely a failing git hook)`);
291
- }
292
- }
293
- }
294
- catch (error) {
295
- // stage 後の検査や hook が失敗しても、この checkpoint の対象だけを戻す。
296
- // root の index と、hook が別途 stage した無関係なパスには触れない。
297
- unstageCommitTargets(worktree.path, paths);
298
- throw error;
299
- }
258
+ commitCheckpointPaths(context.repoRoot, worktree.path, paths, params);
300
259
  return worktree;
301
260
  }
302
261
  return ensureProjectWorktree();
303
262
  }
263
+ // Copy root-side checkpoint files into the worktree and commit them on the exec branch.
264
+ function commitCheckpointPaths(repoRoot, worktreePath, paths, params) {
265
+ for (const path of paths)
266
+ copyCheckpointPath(repoRoot, worktreePath, path);
267
+ try {
268
+ stageCommitTargets(worktreePath, [...paths]);
269
+ const checkpointArgs = ["diff", "--cached", "--quiet", "--", ...paths];
270
+ const checkpoint = gitResult(worktreePath, checkpointArgs);
271
+ assertCheckpointInspection(checkpointArgs, checkpoint, params.failureLogPath);
272
+ if (checkpoint.status !== 1)
273
+ return;
274
+ const committed = gitResult(worktreePath, [
275
+ "commit",
276
+ "-m",
277
+ params.commitMessage,
278
+ "--",
279
+ ...paths,
280
+ ]);
281
+ if (committed.status === 0)
282
+ return;
283
+ // hook(lefthook 等)の生出力には ANSI エスケープや制御文字が含まれうる。この detail は
284
+ // register 経路で pjr-index の結論列・result の理由欄へ伝播するため、ここで除去して
285
+ // 表示崩れを防ぐ(register 側の sanitize と二重だが、非 register の呼び出し元も守る)。
286
+ const output = [committed.stdout, committed.stderr]
287
+ .map((part) => (typeof part === "string" ? stripTerminalControlSequences(part).trim() : ""))
288
+ .filter(Boolean)
289
+ .join("\n");
290
+ appendGitFailureLog(params.failureLogPath, [
291
+ `=== ${new Date().toISOString()} git commit checkpoint ===`,
292
+ `exit: ${committed.status ?? "unknown"}`,
293
+ "--- stdout ---",
294
+ typeof committed.stdout === "string" ? committed.stdout : "",
295
+ "--- stderr ---",
296
+ typeof committed.stderr === "string" ? committed.stderr : "",
297
+ "",
298
+ ]);
299
+ throw new Error(
300
+ // register の短い block_reason にも step とエラーが残るよう、補足より先に要約を置く。
301
+ `Checkpoint commit failed: ${summarizeGitHookFailure(output)} ` +
302
+ `(${params.commitMessage}; staged changes rolled back; likely a failing git hook)`);
303
+ }
304
+ catch (error) {
305
+ // stage 後の検査や hook が失敗しても、この checkpoint の対象だけを戻す。
306
+ // root の index と、hook が別途 stage した無関係なパスには触れない。
307
+ unstageCommitTargets(worktreePath, [...paths]);
308
+ throw error;
309
+ }
310
+ }
311
+ /**
312
+ * Bring root-side files that changed after the exec branch was prepared (for example a grade the
313
+ * runner re-ran before resuming a review, PJR-ZSRD) into the existing worktree as a checkpoint
314
+ * commit. Only files that exist at the root and differ from the worktree are copied. Returns the
315
+ * repo-relative paths that were refreshed.
316
+ */
317
+ export function refreshWorktreeCheckpoint(params) {
318
+ const changed = [
319
+ ...new Set(params.paths.map((path) => repoRelative(params.repoRoot, path))),
320
+ ].filter((path) => {
321
+ const source = resolve(params.repoRoot, path);
322
+ if (!existsSync(source) || !lstatSync(source).isFile())
323
+ return false;
324
+ const target = resolve(params.worktreePath, path);
325
+ return !existsSync(target) || !readFileSync(source).equals(readFileSync(target));
326
+ });
327
+ changed.sort();
328
+ if (changed.length === 0)
329
+ return [];
330
+ commitCheckpointPaths(params.repoRoot, params.worktreePath, changed, params);
331
+ return changed;
332
+ }
@@ -6,8 +6,9 @@ import { rebuildRegisterTicketFromEvents, unionRegisterEventLogs, } from "../reg
6
6
  import { displayIdFromRegisterEventFilename, REGISTER_EVENTS_DIRNAME } from "../register/events.js";
7
7
  import { displayIdFromTicketFilename } from "../register/item.js";
8
8
  import { isGradeCheckpointPath } from "./grade-checkpoint.js";
9
+ import { stagedMergeBlocker } from "../shared/git.js";
9
10
  import { appendGitFailureLog, gitOutput, gitResult, summarizeGitHookFailure, } from "./worktree.js";
10
- import { commitTargetPaths, currentBranch, repoRelative, rootDirtyPaths, zeroSeparatedPaths, } from "./worktree-ops-commit.js";
11
+ import { assertCommitScope, commitTargetPaths, currentBranch, repoRelative, rootDirtyPaths, zeroSeparatedPaths, } from "./worktree-ops-commit.js";
11
12
  const DEFAULT_LOCK_TIMEOUT_MS = 10_000;
12
13
  const DEFAULT_LOCK_STALE_MS = 300_000;
13
14
  // A successful `git merge` runs post-merge, but a merge completed by the bookkeeping-conflict
@@ -192,6 +193,7 @@ function resolveBranchOwnedConflicts(params) {
192
193
  // carries (see releaseRootWorkingCopies); they are restored when the merge does not complete.
193
194
  export function mergeWorktreeIntoCurrent(params) {
194
195
  const { context, worktree, taskId } = params;
196
+ assertCommitScope(context, worktree, taskId, { dryRun: params.dryRun });
195
197
  const targetBranch = currentBranch(context.repoRoot);
196
198
  if (targetBranch === worktree.branch) {
197
199
  throw new Error(`Merge must run from a branch other than ${worktree.branch}.`);
@@ -208,6 +210,11 @@ export function mergeWorktreeIntoCurrent(params) {
208
210
  lockTimeoutMs: DEFAULT_LOCK_TIMEOUT_MS,
209
211
  lockStaleMs: DEFAULT_LOCK_STALE_MS,
210
212
  });
213
+ }
214
+ const stagedBlocker = stagedMergeBlocker(context.repoRoot);
215
+ if (stagedBlocker)
216
+ throw new Error(stagedBlocker);
217
+ if (!params.dryRun) {
211
218
  // Canonical grades may have been refreshed in the root after branching. Release only
212
219
  // the checkpoint copies; refuse to discard a newer root-side evaluation.
213
220
  const gradePaths = releasePaths.filter((path) => isGradeCheckpointPath(path, repoRelative(context.repoRoot, context.executionPath)));
@@ -240,7 +247,11 @@ export function mergeWorktreeIntoCurrent(params) {
240
247
  const expected = gitResult(context.repoRoot, ["show", `${checkpoint}:${path}`]);
241
248
  const absolute = resolve(context.repoRoot, path);
242
249
  const current = existsSync(absolute) ? readFileSync(absolute, "utf8") : undefined;
243
- if ((expected.status === 0 ? expected.stdout : undefined) !== current) {
250
+ // A resumed review may have refreshed the grade onto the branch (PJR-ZSRD). The root
251
+ // copy equal to the branch tip loses nothing when released.
252
+ const merged = gitResult(context.repoRoot, ["show", `${worktree.branch}:${path}`]);
253
+ if ((expected.status === 0 ? expected.stdout : undefined) !== current &&
254
+ (merged.status === 0 ? merged.stdout : undefined) !== current) {
244
255
  throw new Error(`Grade sidecar changed after checkpoint; reconcile before merge: ${path}`);
245
256
  }
246
257
  }
@@ -1,3 +1,3 @@
1
- export { REGISTER_NEW_FILE_DIR_PREFIXES, ROOT_NEW_FILES_HANDOFF_LABEL, applyRootNewFilesHandoff, assertResultMarkdownlint, commitTargetPaths, commitWorktreeChanges, currentBranch, deliverableStatus, isCommitTargetPath, normalizeResultWhitespace, partitionCommitTargets, recordRootNewFilesHandoff, repoRelative, resolveCommitScope, selectStageablePaths, stabilizeCommitTargets, stageCommitTargets, taskPaths, taskTargetsAtHead, unstageCommitTargets, worktreeStatusPaths, } from "./worktree-ops-commit.js";
1
+ export { REGISTER_NEW_FILE_DIR_PREFIXES, ROOT_NEW_FILES_HANDOFF_LABEL, applyRootNewFilesHandoff, assertResultMarkdownlint, assertCommitScope, commitTargetPaths, commitWorktreeChanges, currentBranch, deliverableStatus, isCommitTargetPath, normalizeResultWhitespace, partitionCommitTargets, recordRootNewFilesHandoff, repoRelative, resolveCommitScope, selectStageablePaths, stabilizeCommitTargets, stageCommitTargets, taskPaths, taskTargetsAtHead, unstageCommitTargets, worktreeStatusPaths, UncommittedChangesError, } from "./worktree-ops-commit.js";
2
2
  export { abortMerge, isExecBranchMergedIntoCurrent, mergeWorktreeIntoCurrent, releaseRootWorkingCopies, restoreRootWorkingCopies, } from "./worktree-ops-merge.js";
3
- export { WorktreeRemovedBranchDeletionError, checkpointAndEnsureWorktree, discardStaleExecWorktree, listOrphanedExecBranches, pruneOrphanedExecBranches, removeWorktree, } from "./worktree-ops-lifecycle.js";
3
+ export { WorktreeRemovedBranchDeletionError, checkpointAndEnsureWorktree, discardStaleExecWorktree, listOrphanedExecBranches, pruneOrphanedExecBranches, refreshWorktreeCheckpoint, removeWorktree, } from "./worktree-ops-lifecycle.js";
@@ -15,7 +15,15 @@ export function worktreeNameFromTaskId(value) {
15
15
  }
16
16
  export function resolveWorktreeBase(repoRoot, override, configured) {
17
17
  const value = override?.trim() || configured?.trim() || "../worktrees";
18
- return isAbsolute(value) ? resolve(value) : resolve(repoRoot, value);
18
+ if (isAbsolute(value))
19
+ return resolve(value);
20
+ // An explicit CLI override remains relative to the invoking checkout. Persistent
21
+ // configuration and the default use the main checkout, also from a Job worktree.
22
+ if (override?.trim())
23
+ return resolve(repoRoot, value);
24
+ const listed = gitResult(repoRoot, ["worktree", "list", "--porcelain"]);
25
+ const mainPath = listed.status === 0 ? String(listed.stdout ?? "").match(/^worktree (.+)$/m)?.[1] : undefined;
26
+ return resolve(mainPath ?? repoRoot, value);
19
27
  }
20
28
  export function listRegisteredWorktrees(repoRoot) {
21
29
  const output = gitOutput(repoRoot, ["worktree", "list", "--porcelain"]);
@@ -80,9 +88,18 @@ function trackedPackageLockDirs(worktreePath) {
80
88
  }
81
89
  return [...dirs].sort();
82
90
  }
91
+ export const NPM_CI_ARGS = [
92
+ "ci",
93
+ "--include=dev",
94
+ "--prefer-offline",
95
+ "--no-audit",
96
+ "--no-fund",
97
+ ];
83
98
  function runNpmCi(packageDir) {
84
99
  const command = process.platform === "win32" ? "npm.cmd" : "npm";
85
- const result = spawnSync(command, ["ci", "--include=dev"], {
100
+ // PJR-T01P: lock から入れる依存は主の作業ツリーと同じになるため、cache にある tarball を
101
+ // 再検証せずに使い(--prefer-offline)、準備に要らない audit と fund の問い合わせを省く。
102
+ const result = spawnSync(command, NPM_CI_ARGS, {
86
103
  cwd: packageDir,
87
104
  env: { ...gitEnvironment(), CI: "true", LEFTHOOK: "0" },
88
105
  stdio: "inherit",