specdojo 0.6.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 (366) hide show
  1. package/.github/agents/specdojo-orchestrator.md +3 -2
  2. package/CHANGELOG.md +193 -0
  3. package/README.md +2 -2
  4. package/dist/catalog/build.js +24 -1
  5. package/dist/catalog/plan.js +1 -1
  6. package/dist/catalog/scaffold.js +4 -1
  7. package/dist/commands/agent.js +33 -0
  8. package/dist/commands/init.js +6 -1
  9. package/dist/commands/night-orchestrator.js +6 -4
  10. package/dist/commands/orchestrator.js +10 -1
  11. package/dist/dashboard/dashboard-timeline.js +18 -16
  12. package/dist/dashboard/dashboard.js +612 -259
  13. package/dist/dashboard/epic-plan.js +81 -0
  14. package/dist/dashboard/exec-records.js +16 -20
  15. package/dist/dashboard/routines.js +8 -6
  16. package/dist/dashboard/timeline-build.js +5 -9
  17. package/dist/dashboard/timeline.js +9 -4
  18. package/dist/devcontainer/command.js +18 -0
  19. package/dist/devcontainer/host-script.js +21 -0
  20. package/dist/devcontainer/scaffold.js +22 -3
  21. package/dist/docs/frontmatter-namespace.js +1 -48
  22. package/dist/docs/yaml-pages.js +125 -3
  23. package/dist/exec/agent-config.js +22 -0
  24. package/dist/exec/agent-plan.js +3 -2
  25. package/dist/exec/antigravity-session.js +154 -0
  26. package/dist/exec/commands.js +69 -21
  27. package/dist/exec/commit-hook-skips.js +78 -0
  28. package/dist/exec/core.js +19 -7
  29. package/dist/exec/events.js +159 -8
  30. package/dist/exec/evidence.js +64 -16
  31. package/dist/exec/handoff.js +9 -13
  32. package/dist/exec/limit.js +1 -1
  33. package/dist/exec/mechanical-result.js +45 -0
  34. package/dist/exec/migrate-records.js +249 -0
  35. package/dist/exec/parent-validation.js +160 -12
  36. package/dist/exec/pipeline-state.js +27 -5
  37. package/dist/exec/plan-markdownlint.js +89 -0
  38. package/dist/exec/plans-condense-findings.js +89 -0
  39. package/dist/exec/plans-core.js +24 -17
  40. package/dist/exec/plans-generation.js +52 -25
  41. package/dist/exec/plans-grade-findings.js +8 -3
  42. package/dist/exec/plans-kata-findings.js +61 -0
  43. package/dist/exec/plans-planning.js +3 -3
  44. package/dist/exec/plans-storage.js +12 -24
  45. package/dist/exec/register-resume.js +69 -42
  46. package/dist/exec/register.js +26 -22
  47. package/dist/exec/repo-integration-sync.js +8 -4
  48. package/dist/exec/repo-integration.js +21 -1
  49. package/dist/exec/reporter.js +121 -23
  50. package/dist/exec/results.js +85 -24
  51. package/dist/exec/review-completion.js +47 -0
  52. package/dist/exec/review-kata.js +109 -0
  53. package/dist/exec/run/agent-pipeline.js +75 -6
  54. package/dist/exec/run/agent.js +20 -7
  55. package/dist/exec/run/in-place.js +69 -32
  56. package/dist/exec/run/job.js +81 -24
  57. package/dist/exec/run/lifecycle-commands.js +264 -43
  58. package/dist/exec/run/mode-shared.js +11 -3
  59. package/dist/exec/run/register-command.js +12 -10
  60. package/dist/exec/run/register-core.js +20 -13
  61. package/dist/exec/run/register-mode.js +12 -12
  62. package/dist/exec/run/register-post-review.js +21 -9
  63. package/dist/exec/run/register-resume.js +28 -18
  64. package/dist/exec/run/register-state.js +10 -7
  65. package/dist/exec/run/register-worktree.js +60 -30
  66. package/dist/exec/run/schedule-mode.js +26 -6
  67. package/dist/exec/run/schedule-prepare.js +228 -45
  68. package/dist/exec/run/schedule-task.js +132 -25
  69. package/dist/exec/run/shared.js +4 -3
  70. package/dist/exec/run/trailing-records.js +35 -0
  71. package/dist/exec/run-records.js +2 -0
  72. package/dist/exec/strategy.js +1 -0
  73. package/dist/exec/trailing-records.js +242 -0
  74. package/dist/exec/trial-commands.js +3 -2
  75. package/dist/exec/validate-records-commit.js +110 -0
  76. package/dist/exec/validate-records.js +148 -0
  77. package/dist/exec/worktree-command.js +29 -16
  78. package/dist/exec/worktree-ops-commit.js +118 -59
  79. package/dist/exec/worktree-ops-lifecycle.js +77 -44
  80. package/dist/exec/worktree-ops-merge.js +13 -2
  81. package/dist/exec/worktree-ops.js +2 -2
  82. package/dist/exec/worktree.js +19 -2
  83. package/dist/grade/apply.js +32 -6
  84. package/dist/grade/command-inspect.js +2 -2
  85. package/dist/grade/command-run.js +2 -0
  86. package/dist/grade/command-shared.js +1 -1
  87. package/dist/grade/core.js +18 -5
  88. package/dist/grade/markdown.js +3 -3
  89. package/dist/grade/pipeline-state.js +15 -11
  90. package/dist/grade/plan.js +37 -17
  91. package/dist/grade/result.js +3 -3
  92. package/dist/grade/run.js +23 -3
  93. package/dist/grade/target-discovery.js +17 -4
  94. package/dist/grade/targets.js +12 -11
  95. package/dist/job/job.js +31 -17
  96. package/dist/job/noop.js +104 -0
  97. package/dist/register/core.js +2 -0
  98. package/dist/register/create-commands.js +28 -3
  99. package/dist/register/deliverable-target.js +9 -1
  100. package/dist/register/epic.js +104 -26
  101. package/dist/register/event-merge.js +3 -0
  102. package/dist/register/events.js +4 -0
  103. package/dist/register/external-project.js +3 -0
  104. package/dist/register/item.js +6 -0
  105. package/dist/register/maintenance-commands.js +4 -1
  106. package/dist/register/planning.js +7 -14
  107. package/dist/register/register.js +74 -32
  108. package/dist/register/track-domains.js +34 -0
  109. package/dist/register/track-plan.js +78 -0
  110. package/dist/register/transition-commands.js +8 -0
  111. package/dist/register/work-table.js +64 -0
  112. package/dist/review/grade.js +35 -13
  113. package/dist/routine/definition.js +4 -3
  114. package/dist/routine/failure.js +30 -0
  115. package/dist/routine/routine.js +56 -32
  116. package/dist/routine/storage.js +33 -0
  117. package/dist/schedule/schedule.js +1 -0
  118. package/dist/schedule/strategy-generate-document.js +26 -14
  119. package/dist/schedule/strategy-generate-scope.js +17 -45
  120. package/dist/schedule/strategy-generate.js +33 -3
  121. package/dist/schedule/strategy-profiles.js +86 -12
  122. package/dist/shared/agent-types.js +2 -0
  123. package/dist/shared/condense-records.js +25 -0
  124. package/dist/shared/deprecation.js +8 -0
  125. package/dist/shared/document-metadata.js +20 -0
  126. package/dist/shared/finding-cause.js +20 -0
  127. package/dist/shared/frontmatter-namespace.js +48 -0
  128. package/dist/shared/git.js +149 -15
  129. package/dist/shared/grade-result.js +17 -1
  130. package/dist/shared/local-state.js +20 -0
  131. package/dist/shared/markdownlint-config.js +8 -3
  132. package/dist/shared/plan-conventions.js +129 -0
  133. package/dist/shared/plan-templates.js +57 -41
  134. package/dist/shared/provider-scaffold.js +2 -0
  135. package/dist/shared/run-records.js +224 -0
  136. package/dist/shared/specdojo-config.js +39 -21
  137. package/dist/shared/specdojo-gitignore.js +1 -0
  138. package/dist/shared/text.js +65 -5
  139. package/dist/shared/timeline-index.js +2 -0
  140. package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +11 -2
  141. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +4 -74
  142. package/docs/ja/specdojo/exec-templates/xep-condense-template.md +50 -0
  143. package/docs/ja/specdojo/exec-templates/xep-draft-template.md +17 -5
  144. package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +16 -3
  145. package/docs/ja/specdojo/exec-templates/xep-recipe-guided-template.md +15 -5
  146. package/docs/ja/specdojo/exec-templates/xep-recipe-maintenance-template.md +6 -0
  147. package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -1
  148. package/docs/ja/specdojo/exec-templates/xep-rulebook-maintenance-template.md +6 -0
  149. package/docs/ja/specdojo/exec-templates/xep-sample-maintenance-template.md +6 -0
  150. package/docs/ja/specdojo/exec-templates/xep-template-maintenance-template.md +6 -0
  151. package/docs/ja/specdojo/exec-templates/xer-condense-template.md +25 -0
  152. package/docs/ja/specdojo/exec-templates/xp-common-conventions-template.md +50 -0
  153. package/docs/ja/specdojo/exec-templates/xrp-common-conventions-template.md +30 -0
  154. package/docs/ja/specdojo/guides/branch-workflow-guide.md +1 -1
  155. package/docs/ja/specdojo/guides/docs-editing-guide.md +48 -0
  156. package/docs/ja/specdojo/guides/docs-structure-guide.md +48 -15
  157. package/docs/ja/specdojo/guides/exec-config-guide.md +61 -28
  158. package/docs/ja/specdojo/guides/exec-operation-guide.md +61 -13
  159. package/docs/ja/specdojo/guides/exec-worktree-guide.md +20 -11
  160. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +4 -2
  161. package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +92 -55
  162. package/docs/ja/specdojo/guides/project-move-guide.md +381 -0
  163. package/docs/ja/specdojo/guides/quick-start-guide.md +589 -807
  164. package/docs/ja/specdojo/guides/register-operation-guide.md +26 -4
  165. package/docs/ja/specdojo/guides/remote-host-development-guide.md +33 -4
  166. package/docs/ja/specdojo/guides/review-guide.md +22 -19
  167. package/docs/ja/specdojo/guides/routine-operation-guide.md +14 -8
  168. package/docs/ja/specdojo/guides/ryu-guide.md +23 -13
  169. package/docs/ja/specdojo/guides/schedule-design-guide.md +7 -4
  170. package/docs/ja/specdojo/guides/schedule-operation-guide.md +41 -3
  171. package/docs/ja/specdojo/guides/specdojo-overview-guide.md +5 -4
  172. package/docs/ja/specdojo/guides/timeline-design-guide.md +27 -144
  173. package/docs/ja/specdojo/guides/use-case-guide.md +471 -74
  174. package/docs/ja/specdojo/recipes/bac-recipe.md +94 -0
  175. package/docs/ja/specdojo/recipes/bes-recipe.md +105 -0
  176. package/docs/ja/specdojo/recipes/br-recipe.md +84 -0
  177. package/docs/ja/specdojo/recipes/cdfd-overview-recipe.md +88 -86
  178. package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +108 -122
  179. package/docs/ja/specdojo/recipes/cnd-recipe.md +125 -0
  180. package/docs/ja/specdojo/recipes/cpd-recipe.md +126 -0
  181. package/docs/ja/specdojo/recipes/cxd-recipe.md +145 -0
  182. package/docs/ja/specdojo/recipes/ifd-recipe.md +134 -0
  183. package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +135 -86
  184. package/docs/ja/specdojo/recipes/ifx-index-recipe.md +130 -0
  185. package/docs/ja/specdojo/recipes/pm-organization-recipe.md +29 -26
  186. package/docs/ja/specdojo/recipes/pm-plan-recipe.md +35 -26
  187. package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +38 -28
  188. package/docs/ja/specdojo/recipes/pm-raci-recipe.md +39 -31
  189. package/docs/ja/specdojo/recipes/pm-roles-recipe.md +26 -28
  190. package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +10 -8
  191. package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +18 -17
  192. package/docs/ja/specdojo/recipes/stsd-recipe.md +100 -62
  193. package/docs/ja/specdojo/recipes/sysd-critical-flows-recipe.md +106 -0
  194. package/docs/ja/specdojo/recipes/sysd-cross-cutting-policy-recipe.md +137 -0
  195. package/docs/ja/specdojo/recipes/sysd-index-recipe.md +122 -0
  196. package/docs/ja/specdojo/references/command-reference.md +146 -99
  197. package/docs/ja/specdojo/references/deliverables-reference.md +9 -4
  198. package/docs/ja/specdojo/references/directory-layout-reference.md +3 -2
  199. package/docs/ja/specdojo/references/specdojo-config-reference.md +17 -16
  200. package/docs/ja/specdojo/rulebooks/bac-rulebook.md +72 -290
  201. package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +212 -79
  202. package/docs/ja/specdojo/rulebooks/bds-rulebook.md +138 -154
  203. package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +147 -59
  204. package/docs/ja/specdojo/rulebooks/bes-rulebook.md +100 -96
  205. package/docs/ja/specdojo/rulebooks/br-rulebook.md +88 -108
  206. package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +126 -211
  207. package/docs/ja/specdojo/rulebooks/cdfd-d2-rulebook.md +367 -0
  208. package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +6 -5
  209. package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +96 -100
  210. package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +38 -47
  211. package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +132 -106
  212. package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +102 -68
  213. package/docs/ja/specdojo/rulebooks/cdt-rulebook.md +152 -0
  214. package/docs/ja/specdojo/rulebooks/cld-rulebook.md +9 -184
  215. package/docs/ja/specdojo/rulebooks/clis-rulebook.md +187 -0
  216. package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +93 -247
  217. package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +104 -241
  218. package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +124 -257
  219. package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +87 -98
  220. package/docs/ja/specdojo/rulebooks/dct-rulebook.md +9 -7
  221. package/docs/ja/specdojo/rulebooks/dec-rulebook.md +2 -1
  222. package/docs/ja/specdojo/rulebooks/dss-rulebook.md +193 -0
  223. package/docs/ja/specdojo/rulebooks/gl-rulebook.md +100 -54
  224. package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +69 -252
  225. package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +91 -76
  226. package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +252 -226
  227. package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +118 -40
  228. package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +11 -11
  229. package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +9 -9
  230. package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +4 -4
  231. package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +11 -11
  232. package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +11 -11
  233. package/docs/ja/specdojo/rulebooks/mm-rulebook.md +4 -3
  234. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +34 -29
  235. package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +8 -8
  236. package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +2 -2
  237. package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +50 -56
  238. package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +46 -55
  239. package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +57 -54
  240. package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +50 -65
  241. package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +2 -2
  242. package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +70 -97
  243. package/docs/ja/specdojo/rulebooks/pr-rulebook.md +2 -1
  244. package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +47 -56
  245. package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +61 -135
  246. package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +116 -32
  247. package/docs/ja/specdojo/rulebooks/sf-rulebook.md +118 -61
  248. package/docs/ja/specdojo/rulebooks/sld-rulebook.md +152 -57
  249. package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +51 -39
  250. package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +101 -46
  251. package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +72 -329
  252. package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +74 -263
  253. package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +78 -195
  254. package/docs/ja/specdojo/rulebooks/tml-rulebook.md +4 -9
  255. package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +3 -4
  256. package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +3 -3
  257. package/docs/ja/specdojo/rulebooks/uis-rulebook.md +140 -143
  258. package/docs/ja/specdojo/samples/bac-sample.md +106 -21
  259. package/docs/ja/specdojo/samples/bdd-sample.yaml +143 -35
  260. package/docs/ja/specdojo/samples/bds-sample.md +100 -21
  261. package/docs/ja/specdojo/samples/bes-index-sample.md +59 -20
  262. package/docs/ja/specdojo/samples/bes-sample.md +80 -21
  263. package/docs/ja/specdojo/samples/br-sample.md +68 -14
  264. package/docs/ja/specdojo/samples/ccd-sample.md +81 -19
  265. package/docs/ja/specdojo/samples/cdfd-overview-sample.md +248 -140
  266. package/docs/ja/specdojo/samples/cdfd-sample.md +172 -99
  267. package/docs/ja/specdojo/samples/cdfd-uc-sample.md +130 -97
  268. package/docs/ja/specdojo/samples/cdsd-sample.md +89 -20
  269. package/docs/ja/specdojo/samples/cdt-sample.md +116 -0
  270. package/docs/ja/specdojo/samples/cld-sample.md +3 -30
  271. package/docs/ja/specdojo/samples/clis-sample.md +132 -0
  272. package/docs/ja/specdojo/samples/cnd-sample.md +127 -21
  273. package/docs/ja/specdojo/samples/cpd-sample.md +136 -22
  274. package/docs/ja/specdojo/samples/cxd-sample.md +108 -22
  275. package/docs/ja/specdojo/samples/dct-index-sample.yaml +63 -17
  276. package/docs/ja/specdojo/samples/dss-sample.md +175 -0
  277. package/docs/ja/specdojo/samples/gl-sample.yaml +50 -14
  278. package/docs/ja/specdojo/samples/ifd-sample.md +105 -21
  279. package/docs/ja/specdojo/samples/ifx-cmd-sample.yaml +91 -60
  280. package/docs/ja/specdojo/samples/ifx-file-sample.md +462 -21
  281. package/docs/ja/specdojo/samples/ifx-index-sample.yaml +87 -19
  282. package/docs/ja/specdojo/samples/pm-members-sample.yaml +37 -13
  283. package/docs/ja/specdojo/samples/pm-organization-sample.md +52 -20
  284. package/docs/ja/specdojo/samples/pm-plan-sample.md +84 -26
  285. package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +55 -22
  286. package/docs/ja/specdojo/samples/pm-raci-sample.md +69 -28
  287. package/docs/ja/specdojo/samples/pm-roles-sample.yaml +13 -12
  288. package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +50 -26
  289. package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +89 -62
  290. package/docs/ja/specdojo/samples/sf-index-sample.md +89 -20
  291. package/docs/ja/specdojo/samples/sf-sample.md +121 -21
  292. package/docs/ja/specdojo/samples/sld-sample.md +107 -21
  293. package/docs/ja/specdojo/samples/stsd-sample.md +54 -26
  294. package/docs/ja/specdojo/samples/sysd-critical-flows-sample.md +166 -21
  295. package/docs/ja/specdojo/samples/sysd-cross-cutting-policy-sample.md +178 -21
  296. package/docs/ja/specdojo/samples/sysd-index-sample.md +82 -21
  297. package/docs/ja/specdojo/samples/tml-sample.yaml +4 -1
  298. package/docs/ja/specdojo/samples/uis-sample.md +164 -20
  299. package/docs/ja/specdojo/standards/document-metadata-standard.md +33 -4
  300. package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +3 -1
  301. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +1 -0
  302. package/docs/ja/specdojo/templates/bac-template.md +76 -0
  303. package/docs/ja/specdojo/templates/bes-template.md +56 -0
  304. package/docs/ja/specdojo/templates/br-template.md +64 -0
  305. package/docs/ja/specdojo/templates/cdfd-overview-template.md +161 -83
  306. package/docs/ja/specdojo/templates/cdfd-template.md +81 -54
  307. package/docs/ja/specdojo/templates/cdfd-uc-template.md +130 -89
  308. package/docs/ja/specdojo/templates/cnd-template.md +137 -0
  309. package/docs/ja/specdojo/templates/cpd-template.md +129 -0
  310. package/docs/ja/specdojo/templates/cxd-template.md +105 -0
  311. package/docs/ja/specdojo/templates/dct-data-model-cdt-template.yaml +40 -0
  312. package/docs/ja/specdojo/templates/dct-data-model-cld-template.yaml +7 -14
  313. package/docs/ja/specdojo/templates/dct-index-template.md +9 -20
  314. package/docs/ja/specdojo/templates/dct-project-management-template.yaml +5 -1
  315. package/docs/ja/specdojo/templates/ifd-template.md +86 -0
  316. package/docs/ja/specdojo/templates/ifx-cmd-template.yaml +44 -28
  317. package/docs/ja/specdojo/templates/ifx-index-template.yaml +40 -0
  318. package/docs/ja/specdojo/templates/opr-template.md +2 -4
  319. package/docs/ja/specdojo/templates/pm-organization-template.md +9 -3
  320. package/docs/ja/specdojo/templates/pm-plan-template.md +4 -4
  321. package/docs/ja/specdojo/templates/pm-quality-management-plan-template.md +17 -9
  322. package/docs/ja/specdojo/templates/pm-raci-template.md +24 -13
  323. package/docs/ja/specdojo/templates/pm-roles-template.yaml +3 -2
  324. package/docs/ja/specdojo/templates/prj-assumptions-constraints-dependencies-template.md +6 -3
  325. package/docs/ja/specdojo/templates/prj-comparison-of-alternatives-template.md +22 -19
  326. package/docs/ja/specdojo/templates/stsd-template.md +46 -21
  327. package/docs/ja/specdojo/templates/sysd-critical-flows-template.md +94 -0
  328. package/docs/ja/specdojo/templates/sysd-cross-cutting-policy-template.md +122 -0
  329. package/docs/ja/specdojo/templates/sysd-index-template.md +89 -0
  330. package/docs/specdojo/lib/yaml-metadata.cjs +7 -0
  331. package/docs/specdojo/schemas/v1/bdd.schema.yaml +25 -57
  332. package/docs/specdojo/schemas/v1/condense-records.schema.yaml +26 -0
  333. package/docs/specdojo/schemas/v1/dct.schema.yaml +10 -0
  334. package/docs/specdojo/schemas/v1/deliverable-frontmatter.schema.yaml +3 -0
  335. package/docs/specdojo/schemas/v1/esil.schema.yaml +7 -141
  336. package/docs/specdojo/schemas/v1/exec-common.schema.yaml +3 -0
  337. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +54 -3
  338. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +3 -0
  339. package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +14 -0
  340. package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +18 -0
  341. package/docs/specdojo/schemas/v1/finding-cause.schema.yaml +22 -0
  342. package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +1 -1
  343. package/docs/specdojo/schemas/v1/grade-result.schema.yaml +2 -0
  344. package/docs/specdojo/schemas/v1/ifx-cmd.schema.yaml +65 -5
  345. package/docs/specdojo/schemas/v1/ifx-index.schema.yaml +142 -0
  346. package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
  347. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +17 -1
  348. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +1 -0
  349. package/package.json +6 -3
  350. package/templates/antigravity/README.md +19 -46
  351. package/templates/antigravity/exec-defaults-snippet.yaml +5 -6
  352. package/templates/antigravity/orchestrator.md +3 -2
  353. package/templates/antigravity/settings.edit.json +73 -0
  354. package/templates/antigravity/settings.orchestrator.json +15 -0
  355. package/templates/antigravity/settings.report.json +7 -0
  356. package/templates/antigravity/settings.review.json +7 -0
  357. package/templates/claude/agents/specdojo-orchestrator.md +3 -2
  358. package/templates/codex/agents/specdojo-orchestrator.toml +3 -2
  359. package/templates/codex/orchestrator.md +3 -2
  360. package/templates/devcontainer/remote-host/devcontainer-tmux.sh +217 -0
  361. package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +8 -96
  362. package/templates/devcontainer/remote-host/ssh-config.sample +3 -1
  363. package/templates/devcontainer/tmux.conf +6 -0
  364. package/templates/init-agent-members.yaml +1 -0
  365. package/templates/init-exec-defaults.yaml +1 -1
  366. package/templates/opencode/agents/specdojo-orchestrator.md +3 -2
@@ -1,14 +1,17 @@
1
1
  import { execFileSync } from "node:child_process";
2
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
2
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join, resolve, sep } from "node:path";
4
4
  import { isDeepStrictEqual } from "node:util";
5
5
  import { buildSpecdojoFrontmatter, parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
6
- import { escapeMarkdownInline, expandTemplate, stripTerminalControlSequences } from "./shared.js";
7
- import { formatMarkdownFile } from "./format.js";
8
- import { deriveReporterFacts, mechanicallyNotApplicableReason, runnerOwnedValidationReason, } from "./reporter.js";
9
6
  import { resolveSpecdojoPath, resolveSpecdojoPathIfExists } from "../docs/template-resolution.js";
10
- import { dump } from "../shared/yaml.js";
11
7
  import { gitEnvironment } from "../shared/git-environment.js";
8
+ import { dump } from "../shared/yaml.js";
9
+ import { formatMarkdownFile } from "./format.js";
10
+ import { deriveReporterFacts, mechanicallyNotApplicableReason, runnerOwnedValidationReason, } from "./reporter.js";
11
+ import { isRunRecordPath, listRunRecords, recordPathForRead, recordStem, resolveRunPlanRef, resultForPlan, taskRecordPaths, } from "./run-records.js";
12
+ import { escapeMarkdownInline, expandTemplate, stripTerminalControlSequences } from "./shared.js";
13
+ import { isCondenseRecords } from "../shared/condense-records.js";
14
+ import { inlineCode } from "./plans-grade-findings.js";
12
15
  export const MAX_INDIVIDUAL_CHANGED_FILES = 50;
13
16
  // ---------------------------------------------------------------------------
14
17
  // Frontmatter helpers
@@ -56,6 +59,11 @@ function serializeFrontmatter(meta) {
56
59
  for (const target of meta.targets)
57
60
  inner.push(` - ${serializeYamlString(target)}`);
58
61
  }
62
+ if (meta.condense_records) {
63
+ inner.push(...dump({ condense_records: meta.condense_records }, { lineWidth: -1, noRefs: true })
64
+ .trimEnd()
65
+ .split("\n"));
66
+ }
59
67
  // reason は agent stderr や subprocess の生出力由来で任意文字を含みうる。まず ANSI エスケープ
60
68
  // シーケンスや制御文字を除去し(色付き hook 出力が result 表示を壊すのを防ぐ)、JSON の
61
69
  // 文字列形式で YAML へ埋め込む。改行・引用符・バックスラッシュも値を変えずに保持できる。
@@ -84,7 +92,12 @@ function parseFrontmatter(content) {
84
92
  else if (typeof value === "number" || typeof value === "boolean")
85
93
  meta[key] = String(value);
86
94
  }
87
- return { meta, ...(targets ? { targets } : {}), body };
95
+ return {
96
+ meta,
97
+ ...(targets ? { targets } : {}),
98
+ body,
99
+ ...(isCondenseRecords(data.condense_records) ? { condenseRecords: data.condense_records } : {}),
100
+ };
88
101
  }
89
102
  function frontmatterWithBody(frontmatter, body) {
90
103
  return `${frontmatter}\n\n${body.replace(/^\n+/, "")}`;
@@ -111,6 +124,9 @@ function loadResultTemplate(mode, approach, execution) {
111
124
  if (mode === "edit" && execution === "human" && approach === "draft") {
112
125
  return readFileSync(resolveSpecdojoPath("docs/ja/specdojo/exec-templates/xer-human-draft-template.md"), "utf8");
113
126
  }
127
+ if (mode === "edit" && approach === "condense") {
128
+ return readFileSync(resolveSpecdojoPath("docs/ja/specdojo/exec-templates/xer-condense-template.md"), "utf8");
129
+ }
114
130
  if (mode === "edit" && approach === "cross-deliverable-dedup") {
115
131
  const crossDeliverablePath = resolveSpecdojoPathIfExists("docs/ja/specdojo/exec-templates/xer-cross-deliverable-dedup-template.md");
116
132
  if (crossDeliverablePath)
@@ -128,17 +144,14 @@ function loadResultTemplate(mode, approach, execution) {
128
144
  // Public API
129
145
  // ---------------------------------------------------------------------------
130
146
  export function resultPathForTask(executionPath, nameBase) {
131
- return join(executionPath, "exec", "results", `${nameBase}-result.md`);
147
+ return recordPathForRead(executionPath, "result", nameBase);
132
148
  }
133
149
  // A unique-name run retains every attempt as a separate result. When a new result is scaffolded,
134
150
  // close older unfinished attempts for the same task so they no longer look active or actionable.
135
151
  // Fixed-name runs return before this helper is reached and continue to reuse their single result.
136
152
  async function supersedePriorResults(resultsDir, taskId, nextResultPath, supersededAt) {
137
153
  const supersededPaths = [];
138
- for (const fileName of readdirSync(resultsDir).sort()) {
139
- if (!fileName.endsWith("-result.md"))
140
- continue;
141
- const candidatePath = join(resultsDir, fileName);
154
+ for (const candidatePath of listRunRecords(resultsDir, "result")) {
142
155
  if (candidatePath === nextResultPath)
143
156
  continue;
144
157
  let meta;
@@ -172,13 +185,18 @@ const APPROACH_SECTION_WITHOUT_APPROACH = [
172
185
  ].join("\n");
173
186
  export async function scaffoldResult(opts) {
174
187
  const { executionPath, taskId, mode, projectId, planRef, agent, startedAt, approach } = opts;
175
- const stem = opts.stem ?? taskId;
176
- const resultPath = resultPathForTask(executionPath, stem);
188
+ if (approach === "condense" && (mode !== "edit" || opts.targets?.length !== 1)) {
189
+ throw new Error("condense requires edit mode and exactly one target");
190
+ }
191
+ const stem = opts.stem ?? (planRef && isRunRecordPath(planRef) ? recordStem(planRef) : taskId);
192
+ const resultPath = planRef && isRunRecordPath(planRef)
193
+ ? resultForPlan(resolveRunPlanRef(executionPath, planRef))
194
+ : taskRecordPaths(executionPath, taskId, opts.runId ?? stem, opts.origin).result;
177
195
  // Idempotent: claim and exec run can both reach this; never clobber an in-progress result.
178
196
  if (existsSync(resultPath)) {
179
197
  return { resultPath, created: false, supersededPaths: [] };
180
198
  }
181
- const resultsDir = join(executionPath, "exec", "results");
199
+ const resultsDir = dirname(resultPath);
182
200
  if (!existsSync(resultsDir))
183
201
  mkdirSync(resultsDir, { recursive: true });
184
202
  const template = loadResultTemplate(mode, approach, opts.execution);
@@ -197,6 +215,7 @@ export async function scaffoldResult(opts) {
197
215
  ...(planRef ? { plan_ref: planRef } : {}),
198
216
  ...(opts.execution ? { execution: opts.execution } : {}),
199
217
  ...(approach ? { approach } : {}),
218
+ ...(approach === "condense" ? { condense_records: [] } : {}),
200
219
  ...(opts.targets && opts.targets.length > 0 ? { targets: opts.targets } : {}),
201
220
  };
202
221
  const values = {
@@ -218,7 +237,7 @@ export async function scaffoldResult(opts) {
218
237
  }
219
238
  writeFileSync(resultPath, content, "utf8");
220
239
  await formatMarkdownFile(resultPath);
221
- const supersededPaths = await supersedePriorResults(resultsDir, taskId, resultPath, startedAt);
240
+ const supersededPaths = await supersedePriorResults(executionPath, taskId, resultPath, startedAt);
222
241
  return { resultPath, created: true, supersededPaths };
223
242
  }
224
243
  // 必須節が未記入(テンプレートのプレースホルダのまま)かを検知するためのマーカー。
@@ -295,10 +314,24 @@ export function isResultUnfilled(resultPath, mode, scaffoldFrontmatter, original
295
314
  return true;
296
315
  if (!hasNonEmptyScaffoldFields(current.data, mode))
297
316
  return true;
317
+ if (current.data.approach === "condense" &&
318
+ (mode !== "edit" ||
319
+ !isCondenseRecords(current.data.condense_records) ||
320
+ !Array.isArray(current.data.targets) ||
321
+ current.data.targets.length !== 1))
322
+ return true;
323
+ // Condense records are executor facts, filled after scaffolding. Identity and lifecycle
324
+ // fields retain the same comparisons as every other approach.
325
+ const comparable = (data) => {
326
+ const copy = { ...data };
327
+ if (data.approach === "condense" && isCondenseRecords(data.condense_records))
328
+ delete copy.condense_records;
329
+ return copy;
330
+ };
298
331
  if (scaffoldFrontmatter !== undefined) {
299
332
  if (!hasNonEmptyScaffoldFields(scaffoldFrontmatter, mode))
300
333
  return true;
301
- if (!isDeepStrictEqual(current.data, scaffoldFrontmatter))
334
+ if (!isDeepStrictEqual(comparable(current.data), comparable(scaffoldFrontmatter)))
302
335
  return true;
303
336
  }
304
337
  // resume 時は、実行直前の worktree result を上の厳密比較に使う。さらに root に保持した
@@ -307,7 +340,7 @@ export function isResultUnfilled(resultPath, mode, scaffoldFrontmatter, original
307
340
  if (originalScaffoldFrontmatter !== undefined) {
308
341
  if (!hasNonEmptyScaffoldFields(originalScaffoldFrontmatter, mode))
309
342
  return true;
310
- if (!isDeepStrictEqual(immutableScaffoldFields(current.data), immutableScaffoldFields(originalScaffoldFrontmatter))) {
343
+ if (!isDeepStrictEqual(immutableScaffoldFields(comparable(current.data)), immutableScaffoldFields(comparable(originalScaffoldFrontmatter)))) {
311
344
  return true;
312
345
  }
313
346
  }
@@ -610,7 +643,7 @@ export function renderEditReporterBody(output, evidence, options) {
610
643
  ? `rate limit 後に ${event.resume_at ?? "再開可能時刻"} まで待ち、${event.to_actor} で ${event.resumed_at} に再開`
611
644
  : `${event.trigger === "connection_error" ? "接続エラー" : "rate limit"}後に ${event.from_actor} から ${event.to_actor} へ切り替え、${event.resumed_at} に再開`);
612
645
  return [
613
- "# Edit Result",
646
+ options?.approach === "condense" ? "# Condense Result" : "# Edit Result",
614
647
  "",
615
648
  "## 1. 実施内容",
616
649
  "",
@@ -667,9 +700,24 @@ function renderReviewReporterBody(output, evidence) {
667
700
  `- verdict: ${output.verdict}`,
668
701
  ].join("\n");
669
702
  }
703
+ function renderCondenseRecords(records) {
704
+ if (!records.length)
705
+ return "なし";
706
+ const cell = (text) => inlineCode(text).replaceAll("|", "\\|");
707
+ return [
708
+ "| 場所(修正前) | 種類 | 直し方 | 残した理由/意味の維持 | 原因 |",
709
+ "| --- | --- | --- | --- | --- |",
710
+ ...records.map((record) => {
711
+ const cause = record.cause.type === "kata"
712
+ ? `kata:${record.cause.kind}; location=${record.cause.location}`
713
+ : "document";
714
+ return `| ${[record.location, record.category, record.action, record.reason, cause].map(cell).join(" | ")} |`;
715
+ }),
716
+ ].join("\n");
717
+ }
670
718
  /**
671
- * Replaces only the result body from schema-validated reporter data. The scaffolded frontmatter
672
- * remains byte-for-byte runner-owned until the lifecycle status update serializes it.
719
+ * Renders reporter prose and runner-owned facts. Condense records come only from validated
720
+ * executor evidence; all other approaches preserve the scaffold frontmatter byte-for-byte.
673
721
  */
674
722
  export async function renderReporterResult(resultPath, output, evidence, options) {
675
723
  if (!existsSync(resultPath))
@@ -679,7 +727,7 @@ export async function renderReporterResult(resultPath, output, evidence, options
679
727
  if (parsed.data.mode !== output.mode) {
680
728
  throw new Error(`reporter mode does not match result scaffold: ${output.mode}`);
681
729
  }
682
- const frontmatter = content.match(/^---\r?\n[\s\S]*?\r?\n---/)?.[0];
730
+ let frontmatter = content.match(/^---\r?\n[\s\S]*?\r?\n---/)?.[0];
683
731
  if (!frontmatter)
684
732
  throw new Error(`Result frontmatter not found: ${resultPath}`);
685
733
  const approach = options?.approach ??
@@ -691,17 +739,27 @@ export async function renderReporterResult(resultPath, output, evidence, options
691
739
  ...(approach ? { approach } : {}),
692
740
  worktreeDir: options?.worktreeDir ?? findGitRoot(dirname(resultPath)) ?? undefined,
693
741
  };
742
+ let recordsBody = "";
743
+ if (approach === "condense" && output.mode === "edit") {
744
+ if (!isCondenseRecords(evidence.condense_records)) {
745
+ throw new Error("condense requires valid executor condense_records (use [] when no candidates)");
746
+ }
747
+ // Preserve scaffold ownership; add only validated executor facts, never reporter prose.
748
+ const scaffold = { ...parsed.data, condense_records: evidence.condense_records };
749
+ frontmatter = `---\n${dump({ specdojo: scaffold }, { lineWidth: -1, noRefs: true }).trimEnd()}\n---`;
750
+ recordsBody = `\n\n## 5. 修正・保持の記録\n\n${renderCondenseRecords(evidence.condense_records)}`;
751
+ }
694
752
  const body = output.mode === "edit"
695
753
  ? renderEditReporterBody(output, evidence, resolvedOptions)
696
754
  : renderReviewReporterBody(output, evidence);
697
- writeFileSync(resultPath, frontmatterWithBody(frontmatter, body), "utf8");
755
+ writeFileSync(resultPath, frontmatterWithBody(frontmatter, body + recordsBody), "utf8");
698
756
  await formatMarkdownFile(resultPath);
699
757
  }
700
758
  export async function updateResultStatus(resultPath, status, completedAt, reason) {
701
759
  if (!existsSync(resultPath))
702
760
  return;
703
761
  const content = readFileSync(resultPath, "utf8");
704
- const { meta: existingMeta, targets: existingTargets, body } = parseFrontmatter(content);
762
+ const { meta: existingMeta, targets: existingTargets, condenseRecords, body, } = parseFrontmatter(content);
705
763
  // block 理由は blocked のときのみ保持する。新しい reason を優先し、無ければ既存値を残す。
706
764
  // complete へ遷移した場合は理由を消す。
707
765
  const blockReason = status === "blocked" ? (reason ?? existingMeta.block_reason ?? undefined) : undefined;
@@ -724,6 +782,7 @@ export async function updateResultStatus(resultPath, status, completedAt, reason
724
782
  : {}),
725
783
  approach: existingMeta.approach ? existingMeta.approach : undefined,
726
784
  ...(existingTargets ? { targets: existingTargets } : {}),
785
+ ...(condenseRecords ? { condense_records: condenseRecords } : {}),
727
786
  ...(blockReason ? { block_reason: blockReason } : {}),
728
787
  };
729
788
  writeFileSync(resultPath, frontmatterWithBody(serializeFrontmatter(updatedMeta), body), "utf8");
@@ -736,7 +795,7 @@ export async function resetResultForClaim(resultPath, agent, startedAt, executio
736
795
  if (!existsSync(resultPath))
737
796
  return;
738
797
  const content = readFileSync(resultPath, "utf8");
739
- const { meta: existingMeta, targets: existingTargets, body } = parseFrontmatter(content);
798
+ const { meta: existingMeta, targets: existingTargets, condenseRecords, body, } = parseFrontmatter(content);
740
799
  const existingExecution = existingMeta.execution === "human" || existingMeta.execution === "agent"
741
800
  ? existingMeta.execution
742
801
  : undefined;
@@ -757,6 +816,7 @@ export async function resetResultForClaim(resultPath, agent, startedAt, executio
757
816
  ...(nextExecution ? { execution: nextExecution } : {}),
758
817
  approach: existingMeta.approach ? existingMeta.approach : undefined,
759
818
  ...(existingTargets ? { targets: existingTargets } : {}),
819
+ ...(condenseRecords ? { condense_records: condenseRecords } : {}),
760
820
  };
761
821
  writeFileSync(resultPath, frontmatterWithBody(serializeFrontmatter(updatedMeta), body), "utf8");
762
822
  await formatMarkdownFile(resultPath);
@@ -775,6 +835,7 @@ export function parseResultTaskIdentity(resultContent) {
775
835
  [
776
836
  "draft",
777
837
  "fully-guided",
838
+ "condense",
778
839
  "recipe-guided",
779
840
  "freeform",
780
841
  "bootstrap",
@@ -0,0 +1,47 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { isReviewVerdict } from "../review/types.js";
3
+ // review の verdict のうち、タスクの完了可否を判断していない(保留を表す)値。review result を
4
+ // 記録できても、runner はこの verdict のタスクを done にせず blocked にする(PJR-M18B)。
5
+ export const PENDING_REVIEW_VERDICTS = new Set([
6
+ "grade-stale",
7
+ "grade-unavailable",
8
+ "changed-during-review",
9
+ ]);
10
+ const PENDING_VERDICT_NEXT_ACTION = {
11
+ "grade-stale": "run `specdojo grade run` for the review subject until it succeeds, then re-run the review task",
12
+ "grade-unavailable": "repair the unreadable grade result sidecar or re-run `specdojo grade run`, then re-run the review task",
13
+ "changed-during-review": "re-run the review task against the current content of the review subject",
14
+ };
15
+ /** Read the review verdict recorded in a review result. */
16
+ export function reviewResultVerdict(resultPath) {
17
+ if (!existsSync(resultPath))
18
+ return undefined;
19
+ const value = readFileSync(resultPath, "utf8").match(/^- verdict:\s*(\S+)\s*$/m)?.[1];
20
+ return isReviewVerdict(value) ? value : undefined;
21
+ }
22
+ /**
23
+ * Decide whether a review task must be blocked instead of completed. A grade that still failed
24
+ * after its retries, or a pending verdict, leaves the subject without a usable grade.
25
+ * Returns the block reason with the next action, or undefined when completion may proceed.
26
+ */
27
+ export function reviewCompletionBlockReason(params) {
28
+ const { verdict, gradeOutcome } = params;
29
+ if (gradeOutcome?.action === "failed") {
30
+ return (`review grade failed after ${gradeOutcome.attempts} attempt(s): ${gradeOutcome.detail}` +
31
+ `; need=fix the grade failure (for example the grade output format) and re-run the review task` +
32
+ `; ref=grade run ${gradeOutcome.runId}`);
33
+ }
34
+ if (verdict && PENDING_REVIEW_VERDICTS.has(verdict)) {
35
+ return `review verdict is ${verdict}; need=${PENDING_VERDICT_NEXT_ACTION[verdict]}`;
36
+ }
37
+ return undefined;
38
+ }
39
+ /** Read the result verdict and decide the block reason for a review-mode task. */
40
+ export function reviewTaskBlockReason(params) {
41
+ if (params.mode !== "review")
42
+ return undefined;
43
+ return reviewCompletionBlockReason({
44
+ verdict: reviewResultVerdict(params.resultPath),
45
+ ...(params.gradeOutcome ? { gradeOutcome: params.gradeOutcome } : {}),
46
+ });
47
+ }
@@ -0,0 +1,109 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { basename, dirname, isAbsolute, join, relative } from "node:path";
3
+ import { declaredKata, loadRulebookRefs, resolveKataRefs } from "../kata/kata.js";
4
+ import { reviewGradeFreshness, renderReviewGradeSummary } from "../review/grade.js";
5
+ import { getProjectSchedulePath, loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
6
+ import { load } from "../shared/yaml.js";
7
+ /**
8
+ * `schedule_file` in ready/cpm snapshots is relative to the project's schedule directory, not to
9
+ * the process cwd (PJR-X05N). Resolve it against the configured schedule path first and keep the
10
+ * cwd-relative and absolute forms for callers that already pass a resolvable path.
11
+ */
12
+ function strategyDirectories(scheduleFile, projectId) {
13
+ const directories = [];
14
+ if (!isAbsolute(scheduleFile) && projectId) {
15
+ const rootDir = specdojoRootDir();
16
+ const project = loadConfig(rootDir).config?.projects[projectId];
17
+ if (project)
18
+ directories.push(join(rootDir, getProjectSchedulePath(project), dirname(scheduleFile)));
19
+ }
20
+ directories.push(dirname(scheduleFile));
21
+ return directories;
22
+ }
23
+ /** Read the intent from the task's own track, even when the review approach is fully-guided. */
24
+ export function scheduleKataReviewSubjects(task, deliverable, projectId) {
25
+ if (!task.local_id || !task.schedule_file)
26
+ return [];
27
+ const track = basename(task.schedule_file).match(/^sch-track-(.+)\.ya?ml$/)?.[1];
28
+ if (!track || !task.id.startsWith(`T-${track.toUpperCase()}-`))
29
+ return [];
30
+ const strategyPath = strategyDirectories(task.schedule_file, projectId)
31
+ .flatMap((directory) => ["yaml", "yml"].map((ext) => join(directory, `sch-strategy-${track}.${ext}`)))
32
+ .find(existsSync);
33
+ if (!strategyPath)
34
+ return [];
35
+ const strategy = load(readFileSync(strategyPath, "utf8"));
36
+ const rule = strategy.approach_rules?.find((rule) => rule.local_ids.includes(task.local_id));
37
+ if (!rule || !["improve-kata", "bootstrap-kata-set"].includes(rule.intent))
38
+ return [];
39
+ const rulebook = deliverable?.deliverable.rulebook;
40
+ const refs = resolveKataRefs(rulebook, deliverable?.deliverable.kind);
41
+ const subjects = [{ path: refs.rulebook, label: "rulebook" }];
42
+ const declarations = rulebook ? loadRulebookRefs(rulebook) : {};
43
+ const declared = rulebook ? declaredKata(rulebook) : [];
44
+ for (const kind of ["recipe", "sample", "template"]) {
45
+ const matches = declared.filter((item) => item.kind === kind);
46
+ if (matches.length) {
47
+ subjects.push(...matches.map((item) => ({
48
+ path: relative(specdojoRootDir(), item.fsPath).replaceAll("\\", "/"),
49
+ label: `${kind}: ${item.id}`,
50
+ })));
51
+ }
52
+ else if ((kind === "sample" && declarations.sample !== "not-needed") ||
53
+ rule.bootstrap_scope?.includes(kind)) {
54
+ // An absent/undecided required reference must hold the review, not disappear from it.
55
+ subjects.push({ path: "_MISSING_", label: kind });
56
+ }
57
+ }
58
+ return subjects.filter((subject, index) => subjects.findIndex((other) => other.path === subject.path && other.label === subject.label) === index);
59
+ }
60
+ export function kataReviewVerdict(subjects, projectId, rootDir) {
61
+ const grades = subjects.map((subject) => reviewGradeFreshness({
62
+ subjectPath: subject.path === "_MISSING_" ? "" : subject.path,
63
+ projectId,
64
+ rootDir,
65
+ }));
66
+ if (grades.some((grade) => grade.state === "unreadable"))
67
+ return "grade-unavailable";
68
+ if (grades.some((grade) => grade.state !== "fresh"))
69
+ return "grade-stale";
70
+ if (grades.some((grade) => grade.state === "fresh" &&
71
+ (grade.result.target !== "kata" || grade.result.verdict !== "pass")))
72
+ return "incomplete";
73
+ return undefined;
74
+ }
75
+ export function kataReviewSummary(subjects, projectId) {
76
+ if (!subjects.length)
77
+ return "";
78
+ return [
79
+ "型の整備を含む schedule の追加完了条件: 以下の型すべてに最新の `--target kata` の `pass` が必要。`needs-work` / `fail` は `incomplete` とし、`complete-with-findings` でも完了扱いにしない。未評価・未解決・古い結果は `grade-stale`、読取不能は `grade-unavailable` とする。各対象の鮮度を判定前にも確認し、review 中の変更は `changed-during-review` とする。",
80
+ ...subjects.flatMap((subject) => {
81
+ const freshness = reviewGradeFreshness({
82
+ subjectPath: subject.path === "_MISSING_" ? "" : subject.path,
83
+ projectId,
84
+ rootDir: specdojoRootDir(),
85
+ });
86
+ return [
87
+ "",
88
+ `型の評価対象(\`${subject.label}\`、\`--target kata\`): \`${subject.path}\``,
89
+ "sidecarPath" in freshness && freshness.sidecarPath
90
+ ? `評価結果サイドカー: \`${relative(specdojoRootDir(), freshness.sidecarPath).replaceAll("\\", "/")}\``
91
+ : "評価結果サイドカー: 解決できない",
92
+ "",
93
+ renderReviewGradeSummary(freshness),
94
+ ];
95
+ }),
96
+ ].join("\n");
97
+ }
98
+ /** Guard the recorded verdict as well as the reviewer prompt, including legacy non-pipeline runs. */
99
+ export function enforceKataReviewVerdict(resultPath, subjects, projectId, rootDir) {
100
+ if (!subjects.length || !existsSync(resultPath))
101
+ return;
102
+ const verdict = kataReviewVerdict(subjects, projectId, rootDir);
103
+ if (!verdict)
104
+ return;
105
+ const content = readFileSync(resultPath, "utf8");
106
+ const updated = content.replace(/^- verdict:\s*(complete|complete-with-findings)\s*$/m, `- verdict: ${verdict}`);
107
+ if (updated !== content)
108
+ writeFileSync(resultPath, `${updated.trimEnd()}\n\n型の grade の追加完了条件を満たさないため、runner が verdict を \`${verdict}\` に制限した。\n`);
109
+ }
@@ -1,9 +1,11 @@
1
1
  import { relative, sep } from "node:path";
2
- import { executorCompletionFailure, recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "../evidence.js";
3
- import { failedParentValidationReason, hasRecordedParentValidations, parentValidationRoots, replaceParentValidationResults, } from "../parent-validation.js";
2
+ import { enforceExecutorReportContract, executorCompletionFailure, recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "../evidence.js";
3
+ import { failedParentValidationReason, hasRecordedParentValidations, parentValidationRoots, parentValidationSelectionForEvidence, replaceParentValidationResults, } from "../parent-validation.js";
4
4
  import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "../pipeline-state.js";
5
5
  import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "../reporter.js";
6
- import { renderReporterResult } from "../results.js";
6
+ import { mechanicalEditReporterOutput } from "../mechanical-result.js";
7
+ import { readResultFrontmatterSnapshot, renderReporterResult } from "../results.js";
8
+ import { isRunRecordPath, recordStem, snapshotRunAttempt } from "../run-records.js";
7
9
  import { randomHex } from "../shared.js";
8
10
  import { withProductRepoPrompt } from "../task-repos.js";
9
11
  import { worktreeStatusPaths } from "../worktree-ops.js";
@@ -18,7 +20,11 @@ export async function refreshParentValidationsForReporterResume(params) {
18
20
  }
19
21
  process.stdout.write(` Refreshing parent validations before ${params.stageLabel ?? "reporter"} resume` +
20
22
  `${force ? " (integration targets were merged into the worktree)" : ""}.\n`);
21
- const parentValidationBatch = await runConfiguredParentValidationBatch(params.execDefaults, parentValidationRoots(params.cwd, params.productWorktrees), { label: params.evidence.task_id });
23
+ const parentValidationBatch = await runConfiguredParentValidationBatch(params.execDefaults, parentValidationRoots(params.cwd, params.productWorktrees), {
24
+ label: params.evidence.task_id,
25
+ // 統合先を取り込んだ後は executor の変更以外も入るため、変更の種類で選ばずすべて流す。
26
+ ...(force ? {} : { selection: parentValidationSelectionForEvidence(params.evidence) }),
27
+ });
22
28
  const evidenceWithValidations = replaceParentValidationResults(params.evidence, parentValidationBatch.validations);
23
29
  const evidence = recordParentValidationFailureOutput({
24
30
  worktreePath: params.cwd,
@@ -32,11 +38,48 @@ export async function refreshParentValidationsForReporterResume(params) {
32
38
  process.stdout.write(` Refreshed executor evidence: ${relative(params.cwd, params.evidencePath).split(sep).join("/")}\n`);
33
39
  return evidence;
34
40
  }
41
+ // PJR-T01P: 決まった形の edit result は reporter を起動せずに runner が作る。作れない場合や
42
+ // 描画に失敗した場合は undefined を返し、呼び出し側は従来どおり reporter を起動する。
43
+ async function writeMechanicalResult(params) {
44
+ if (!params.enabled)
45
+ return false;
46
+ const output = mechanicalEditReporterOutput(params.evidence, params.mode);
47
+ if (!output)
48
+ return false;
49
+ try {
50
+ await renderReporterResult(params.resultPath, output, params.evidence);
51
+ return true;
52
+ }
53
+ catch (error) {
54
+ process.stdout.write(` Mechanical result failed; running the reporter instead: ${error instanceof Error ? error.message : String(error)}\n`);
55
+ return false;
56
+ }
57
+ }
58
+ const DEFAULT_EXECUTOR_RESUME_HINT = "resume the executor stage with --resume-from executor (add --executor-by <nickname> to switch the executor agent)";
35
59
  // register pipeline の reporter 段だけを実行する。executor 直後の通常経路と、executor が
36
60
  // 成功したまま reporter だけが失敗した run の再開経路の双方から共有し、reporter 起動・
37
61
  // result 描画・pipeline-state 更新のみを担う(register の状態遷移と commit は呼び出し側)。
38
62
  export async function runReporterStage(params) {
39
63
  const { repoRoot, cwd, schedulePath, executionPath, reporterCandidates, execDefaults } = params;
64
+ // PJR-1GCD: an envelope missing an approach-required field is an executor failure. Checking it
65
+ // here also covers reporter-only resumes of evidence recorded before this check existed.
66
+ const resultApproach = readResultFrontmatterSnapshot(params.resultPath).approach;
67
+ const contractFailure = enforceExecutorReportContract({
68
+ evidence: params.evidence,
69
+ evidencePath: params.evidencePath,
70
+ contract: {
71
+ ...(typeof resultApproach === "string" ? { approach: resultApproach } : {}),
72
+ mode: params.mode ?? "edit",
73
+ },
74
+ resumeHint: params.executorResumeHint ?? DEFAULT_EXECUTOR_RESUME_HINT,
75
+ });
76
+ if (contractFailure) {
77
+ const blockedAt = new Date().toISOString();
78
+ const state = updatePipelineStage(params.state, "executor", { status: "blocked", completed_at: blockedAt }, blockedAt);
79
+ writePipelineState(params.statePath, state);
80
+ process.stdout.write(` Executor report rejected before the reporter: ${contractFailure}\n`);
81
+ return { exitCode: 1, runResult: "failure", blockReason: contractFailure, state };
82
+ }
40
83
  const env = agentEnvironment(repoRoot, cwd, schedulePath, executionPath, params.productWorktrees);
41
84
  const reporterEvidence = evidenceForReporter(params.evidence, {
42
85
  repoRoot,
@@ -46,6 +89,27 @@ export async function runReporterStage(params) {
46
89
  ...(params.registerPaths ? { registerPaths: params.registerPaths } : {}),
47
90
  });
48
91
  let state = params.state;
92
+ const mechanical = await writeMechanicalResult({
93
+ enabled: execDefaults.pipeline?.mechanical_result === true,
94
+ mode: params.mode ?? "edit",
95
+ resultPath: params.resultPath,
96
+ evidence: reporterEvidence,
97
+ });
98
+ if (mechanical) {
99
+ const completedAt = new Date().toISOString();
100
+ state = updatePipelineStage(state, "reporter", {
101
+ status: "succeeded",
102
+ // register の遷移と再開は reporter の actor を実行者として使うため、割り当てた reporter を
103
+ // 記録する。runner が書いたことは result の「進め方」とログに残る。
104
+ actor: reporterCandidates[0]?.actor ?? null,
105
+ started_at: completedAt,
106
+ completed_at: completedAt,
107
+ artifact_ref: relative(cwd, params.resultPath).split(sep).join("/"),
108
+ }, completedAt);
109
+ writePipelineState(params.statePath, state);
110
+ process.stdout.write(" Reporter skipped: the runner wrote the result from executor evidence (pipeline.mechanical_result).\n");
111
+ return { exitCode: 0, runResult: "success", state };
112
+ }
49
113
  const reporterStartedAt = new Date().toISOString();
50
114
  state = updatePipelineStage(state, "reporter", {
51
115
  status: "running",
@@ -130,13 +194,15 @@ export async function runReporterStage(params) {
130
194
  // 1件の plan/result を executor→reporter の2段階で実行する。register 項目と Job Run の
131
195
  // 双方が使い、in-place(cwd: repoRoot)・worktree(cwd: worktree.path)から共有する。
132
196
  // evidence・pipeline-state の記録先は
133
- // Schedule タスクの pipeline と同じ形式(exec/evidence/<taskId>/<runId>/)にすることで、
197
+ // Schedule タスクの pipeline と同じ run ディレクトリにすることで、
134
198
  // 監査証跡のフォーマットを実行経路によらず統一する。state には plan / result の参照も
135
199
  // 記録し、reporter だけが失敗した場合に `--resume` が入力を復元できるようにする。
136
200
  export async function runAgentPipeline(params) {
137
201
  const { repoRoot, cwd, schedulePath, executionPath, taskId, executor, reporterCandidates, planPrompt, resultPath, execDefaults, } = params;
138
202
  const startedAt = new Date().toISOString();
139
- const runId = params.runId ?? `${new Date().toISOString().replace(/[-:.]/g, "")}-${randomHex(4)}`;
203
+ const runId = isRunRecordPath(params.planPath)
204
+ ? recordStem(params.planPath)
205
+ : (params.runId ?? `${new Date().toISOString().replace(/[-:.]/g, "")}-${randomHex(4)}`);
140
206
  const stateLocation = pipelineStateLocation({
141
207
  repoRoot,
142
208
  worktreePath: cwd,
@@ -144,6 +210,8 @@ export async function runAgentPipeline(params) {
144
210
  taskId,
145
211
  runId,
146
212
  });
213
+ if (params.resumedExecutor)
214
+ snapshotRunAttempt(stateLocation.path);
147
215
  let state = createPipelineState({
148
216
  taskId,
149
217
  runId,
@@ -269,6 +337,7 @@ export async function runAgentPipeline(params) {
269
337
  productWorktrees: params.productWorktrees,
270
338
  mode: params.mode,
271
339
  rateLimitOptions: params.reporterRateLimitOptions,
340
+ ...(params.executorResumeHint ? { executorResumeHint: params.executorResumeHint } : {}),
272
341
  });
273
342
  return {
274
343
  exitCode: reporterOutcome.exitCode,
@@ -6,7 +6,7 @@ import { decidePinnedWait, normalizeAgentLimit, } from "../limit.js";
6
6
  import { replaceDocIndexRefs } from "../../docs/doc-index.js";
7
7
  import { loadPlan, parsePlanTaskIdentity } from "../plans.js";
8
8
  import { recordParentValidationFailureOutput, validateResumedTargetCoverage, writeExecutorEvidence, } from "../evidence.js";
9
- import { parentValidationDisplayCommands, parentValidationGateFor, parentValidationLabels, parentValidationRoots, recordedParentValidationLabel, replaceParentValidationResults, runParentValidationBatch, } from "../parent-validation.js";
9
+ import { parentValidationDisplayCommands, parentValidationGateFor, parentValidationLabels, parentValidationRoots, parentValidationSelectionForEvidence, recordedParentValidationLabel, replaceParentValidationResults, runParentValidationBatch, } from "../parent-validation.js";
10
10
  import { getProjectExecutionPath, loadConfig, loadMemberRoster, specdojoRootDir, } from "../../shared/specdojo-config.js";
11
11
  import { agentProtectedConfigViolation, captureAgentProtectedConfigAcrossRepos, changedAgentProtectedConfigAcrossRepos, qualifiedRepoPaths, } from "../agent-protected-config.js";
12
12
  import { agentGitStateViolation, captureAgentGitStateAcrossRepos, changedAgentGitStateAcrossRepos, qualifiedGitStateFields, } from "../agent-git-state.js";
@@ -51,7 +51,7 @@ function executorEvidenceContract(parentValidations, options = {}) {
51
51
  const parentValidationLabelList = parentValidationLabels(parentValidations);
52
52
  const parentValidationCommands = parentValidationDisplayCommands(parentValidations);
53
53
  const parentValidationInstruction = parentValidationLabelList.length > 0
54
- ? `\nThe SpecDojo parent runner will execute these allowlisted validations after you exit: ${parentValidationLabelList.join(", ")} (${parentValidationCommands.join(", ")}). Do not run those commands inside the agent sandbox or report duplicate executor results for them. Run only the remaining sandbox-safe validations required by the plan. Parent-run results will be appended to evidence with source=runner and are authoritative.\n`
54
+ ? `\nThe SpecDojo parent runner will execute these allowlisted validations after you exit: ${parentValidationLabelList.join(", ")} (${parentValidationCommands.join(", ")}). Do not run those commands inside the agent sandbox or report duplicate executor results for them. If you still list one, use one validation entry per command with its exact command; never combine several parent validations into one entry. Run only the remaining sandbox-safe validations required by the plan. Parent-run results will be appended to evidence with source=runner and are authoritative.\n`
55
55
  : "";
56
56
  const coverage = {
57
57
  source: options.coverageSource ?? "none",
@@ -153,17 +153,27 @@ blocking completion, but rejects the claim when it can confirm the check applies
153
153
  change-type condition below is met.
154
154
  - \`npm run validate:schema:file\` requires a changed \`*.yaml\` or \`*.yml\` file; Prettier
155
155
  requires a changed \`*.md\`, \`*.ts\`, \`*.js\`, \`*.json\`, \`*.yaml\`, or \`*.yml\` file;
156
- markdownlint requires a changed \`*.md\` file.
156
+ markdownlint requires a changed \`*.md\` file; \`npm run validate:history-links\` requires a
157
+ changed history file (\`docs/ja/projects/**/controls/project-register/pjr-*.md\` excluding
158
+ \`pjr-index.md\`, or an existing \`plan.md\` / \`result.md\` under
159
+ \`execution/runs/<origin>/<item>/<run>/\` or legacy \`exec/plans/**/*.md\` /
160
+ \`exec/results/**/*.md\` that you changed yourself).
157
161
  - A command that targets a declared product repository (a \`<repo>:<path>\` argument or
158
162
  \`--prefix <repo>\`) is judged by that repository's package.json, not the project repository's.
159
- - \`specdojo catalog validate\`: the run's target project (or \`--project <id>\`) sets \`catalog_path\`
160
- and your changes reach \`docs/ja/projects/\`. A project without \`catalog_path\`, or changes
163
+ - \`specdojo catalog validate\` / \`npm run validate:catalog\`: the run's target project (or
164
+ \`--project <id>\`) sets \`catalog_path\` and your deliverable changes reach \`docs/ja/projects/\`.
165
+ Runner-managed files under \`exec/\` (\`plans/\`, \`results/\`, \`evidence/\`, \`events/\`, \`.locks/\`)
166
+ do not count as your changes. A project without \`catalog_path\`, or changes
161
167
  outside \`docs/ja/projects/\`, is a valid reason; state it in \`reason\`.
162
168
 
163
169
  Do not run or report \`specdojo index build\`. It writes \`.specdojo/doc-index.json\`, which the
164
170
  agent may not write, and the runner regenerates the index while preparing the worktree and before
165
171
  integration.
166
172
 
173
+ For a plan with approach \`condense\`, also include \`condense_records\` in this envelope
174
+ as specified by the plan (an empty array if there are no candidates). The runner writes those
175
+ validated executor facts to the result frontmatter and table; do not edit the result yourself.
176
+
167
177
  End the final response with exactly one machine-readable report using this envelope. Do not place
168
178
  Markdown fences around the JSON.
169
179
 
@@ -203,7 +213,7 @@ export async function runConfiguredParentValidationBatch(execDefaults, cwd, opti
203
213
  const label = options.label ?? basename(typeof cwd === "string" ? cwd : cwd.project);
204
214
  const batch = await parentValidationGateFor(execDefaults).run(label, labels, async () => {
205
215
  process.stdout.write(` Running parent validations (${label}): ${labels.join(", ")}\n`);
206
- return await runParentValidationBatch(entries, cwd, options.invoke);
216
+ return await runParentValidationBatch(entries, cwd, options.invoke, options.selection);
207
217
  });
208
218
  for (const validation of batch.validations) {
209
219
  process.stdout.write(` Parent validation ${recordedParentValidationLabel(validation)}: ${validation.status}\n`);
@@ -217,7 +227,10 @@ export async function runConfiguredParentValidations(execDefaults, cwd, options
217
227
  // その途中で runner が終了しても agent 出力と変更一覧を失わないよう、ここでは保存済み evidence
218
228
  // へ runner-owned validation だけを追記する。
219
229
  export async function appendParentValidationsToExecutorEvidence(params) {
220
- const parentValidationBatch = await runConfiguredParentValidationBatch(params.execDefaults, parentValidationRoots(params.cwd, params.productWorktrees), { label: params.evidence.task_id });
230
+ const parentValidationBatch = await runConfiguredParentValidationBatch(params.execDefaults, parentValidationRoots(params.cwd, params.productWorktrees), {
231
+ label: params.evidence.task_id,
232
+ selection: parentValidationSelectionForEvidence(params.evidence),
233
+ });
221
234
  const evidenceWithValidations = replaceParentValidationResults(params.evidence, parentValidationBatch.validations);
222
235
  const evidence = recordParentValidationFailureOutput({
223
236
  worktreePath: params.cwd,