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
@@ -53,6 +53,133 @@ export function validateEventShape(obj, source) {
53
53
  export function isExecEventV1(value, source) {
54
54
  return validateEventShape(value, source).length === 0;
55
55
  }
56
+ function advanceTaskState(state, event) {
57
+ if (event.type === "claim")
58
+ return "doing";
59
+ if (event.type === "block")
60
+ return "blocked";
61
+ if (event.type === "unblock")
62
+ return "doing";
63
+ if (event.type === "complete")
64
+ return "done";
65
+ if (event.type === "reopen")
66
+ return state === "done" ? "todo" : state;
67
+ if (event.type === "release") {
68
+ return state === "doing" || state === "blocked" ? "todo" : state;
69
+ }
70
+ if (event.type === "cancel") {
71
+ if (state === "todo")
72
+ return "cancelled";
73
+ if (state === "doing" || state === "blocked")
74
+ return "todo";
75
+ return "cancelled";
76
+ }
77
+ return state;
78
+ }
79
+ function isTransitionValidForState(state, lastBy, candidate, remaining) {
80
+ const { type } = candidate;
81
+ if (type === "note" || type === "estimate" || type === "link")
82
+ return true;
83
+ if (state === "todo") {
84
+ if (type === "cancel")
85
+ return true;
86
+ if (type !== "claim")
87
+ return false;
88
+ const otherClaims = remaining.filter((item) => item.event !== candidate && item.event.type === "claim");
89
+ if (otherClaims.length === 0)
90
+ return true;
91
+ const isResumeClaim = candidate.meta?.pipeline_resume_claimed === "true";
92
+ if (isResumeClaim &&
93
+ otherClaims.some((item) => item.event.meta?.pipeline_resume_claimed !== "true")) {
94
+ return false;
95
+ }
96
+ const actorReleasedOrBlocked = (actor) => remaining.some((item) => (item.event.type === "release" || item.event.type === "block") && item.event.by === actor);
97
+ if (!actorReleasedOrBlocked(candidate.by) &&
98
+ otherClaims.some((item) => actorReleasedOrBlocked(item.event.by))) {
99
+ return false;
100
+ }
101
+ return true;
102
+ }
103
+ if (state === "doing") {
104
+ if (type !== "block" && type !== "complete" && type !== "release" && type !== "cancel") {
105
+ return false;
106
+ }
107
+ if (lastBy &&
108
+ candidate.by !== lastBy &&
109
+ remaining.some((item) => (item.event.type === "block" ||
110
+ item.event.type === "complete" ||
111
+ item.event.type === "release" ||
112
+ item.event.type === "cancel") &&
113
+ item.event.by === lastBy)) {
114
+ return false;
115
+ }
116
+ if (type === "complete" &&
117
+ remaining.some((item) => item.event.type === "unblock") &&
118
+ !remaining.some((item) => item.event.type === "reopen") &&
119
+ remaining.some((item) => item.event.type === "block" && (!lastBy || item.event.by === lastBy))) {
120
+ return false;
121
+ }
122
+ return true;
123
+ }
124
+ if (state === "blocked") {
125
+ return type === "unblock" || type === "release" || type === "cancel";
126
+ }
127
+ if (state === "done") {
128
+ return type === "reopen";
129
+ }
130
+ return false;
131
+ }
132
+ function orderSameTimestampEventsByState(items) {
133
+ const taskStates = new Map();
134
+ for (let start = 0; start < items.length;) {
135
+ const ts = items[start].event.ts;
136
+ let end = start + 1;
137
+ while (end < items.length && items[end].event.ts === ts)
138
+ end += 1;
139
+ if (end - start === 1) {
140
+ const { event } = items[start];
141
+ const cur = taskStates.get(event.task_id) ?? { state: "todo" };
142
+ taskStates.set(event.task_id, {
143
+ state: advanceTaskState(cur.state, event),
144
+ lastBy: event.by,
145
+ });
146
+ start = end;
147
+ continue;
148
+ }
149
+ const byTask = new Map();
150
+ for (let i = start; i < end; i += 1) {
151
+ const taskId = items[i].event.task_id;
152
+ const indices = byTask.get(taskId);
153
+ if (indices)
154
+ indices.push(i);
155
+ else
156
+ byTask.set(taskId, [i]);
157
+ }
158
+ for (const [taskId, indices] of byTask.entries()) {
159
+ let cur = taskStates.get(taskId) ?? { state: "todo" };
160
+ if (indices.length === 1) {
161
+ const { event } = items[indices[0]];
162
+ taskStates.set(taskId, {
163
+ state: advanceTaskState(cur.state, event),
164
+ lastBy: event.by,
165
+ });
166
+ continue;
167
+ }
168
+ const remaining = indices.map((idx) => items[idx]);
169
+ for (const targetIdx of indices) {
170
+ const validIdx = remaining.findIndex((candidate) => isTransitionValidForState(cur.state, cur.lastBy, candidate.event, remaining));
171
+ const [chosen] = remaining.splice(validIdx >= 0 ? validIdx : 0, 1);
172
+ items[targetIdx] = chosen;
173
+ cur = {
174
+ state: advanceTaskState(cur.state, chosen.event),
175
+ lastBy: chosen.event.by,
176
+ };
177
+ }
178
+ taskStates.set(taskId, cur);
179
+ }
180
+ start = end;
181
+ }
182
+ }
56
183
  export function readAllEventFiles(projectPath) {
57
184
  const dir = eventsDirForProject(projectPath);
58
185
  const files = listFilesRecursive(dir).filter((p) => extname(p).toLowerCase() === ".json");
@@ -92,6 +219,7 @@ export function readAllEventFiles(projectPath) {
92
219
  return orderA - orderB;
93
220
  return a.path.localeCompare(b.path);
94
221
  });
222
+ orderSameTimestampEventsByState(items);
95
223
  return items;
96
224
  }
97
225
  export function buildEvent(type, o) {
@@ -135,6 +263,17 @@ export function writeEventFile(projectPath, event, dependencies = {}) {
135
263
  }
136
264
  }
137
265
  }
266
+ // The actor that owns the claim of a doing/blocked task. Snapshots built before claimed_by existed
267
+ // (or hand-built ones) fall back to last_by.
268
+ export function claimOwnerOf(state) {
269
+ return state?.claimed_by ?? state?.last_by;
270
+ }
271
+ // `exec unblock --take-over` records take_over=true so the unblocking (human) actor becomes the claim
272
+ // owner. A plain unblock keeps the existing owner so the agent run can resume and complete.
273
+ export function isTakeOverEvent(event) {
274
+ const value = event.meta?.take_over;
275
+ return value === true || value === "true";
276
+ }
138
277
  export function foldEventsToState(events, schedule, projectPath, initialTasks) {
139
278
  const tasks = initialTasks ? { ...initialTasks } : {};
140
279
  function ensure(id) {
@@ -146,6 +285,7 @@ export function foldEventsToState(events, schedule, projectPath, initialTasks) {
146
285
  if (!schedule.nodes.has(event.task_id))
147
286
  continue;
148
287
  const cur = ensure(event.task_id);
288
+ const previousOwner = claimOwnerOf(cur);
149
289
  cur.last_ts = event.ts;
150
290
  cur.last_by = event.by;
151
291
  cur.last_type = event.type;
@@ -190,6 +330,13 @@ export function foldEventsToState(events, schedule, projectPath, initialTasks) {
190
330
  else
191
331
  cur.state = "cancelled";
192
332
  }
333
+ if (cur.state === "doing" || cur.state === "blocked") {
334
+ const movesClaim = event.type === "claim" || (event.type === "unblock" && isTakeOverEvent(event));
335
+ cur.claimed_by = movesClaim ? event.by : (previousOwner ?? event.by);
336
+ }
337
+ else {
338
+ delete cur.claimed_by;
339
+ }
193
340
  }
194
341
  for (const id of schedule.nodes.keys())
195
342
  ensure(id);
@@ -231,7 +378,7 @@ export function computeReadyIds(schedule, snapshot) {
231
378
  }
232
379
  export function findDoingTasksForActor(snapshot, actor) {
233
380
  return Object.entries(snapshot.tasks)
234
- .filter(([, st]) => st.state === "doing" && st.last_by === actor)
381
+ .filter(([, st]) => st.state === "doing" && claimOwnerOf(st) === actor)
235
382
  .map(([taskId]) => taskId)
236
383
  .sort();
237
384
  }
@@ -290,8 +437,8 @@ export function canCompleteTask(schedule, snapshot, taskId, actor, override) {
290
437
  return { ok: false, reason: `task cancelled: ${taskId}` };
291
438
  if (state !== "doing")
292
439
  return { ok: false, reason: `task is not doing: ${taskId}` };
293
- if (cur?.last_by !== actor && !canOverrideCrossActor(override)) {
294
- return { ok: false, reason: crossActorReason(cur?.last_by) };
440
+ if (claimOwnerOf(cur) !== actor && !canOverrideCrossActor(override)) {
441
+ return { ok: false, reason: crossActorReason(claimOwnerOf(cur)) };
295
442
  }
296
443
  return { ok: true };
297
444
  }
@@ -363,12 +510,12 @@ export function canBlockTask(schedule, snapshot, taskId, actor, override) {
363
510
  return { ok: false, reason: `task cancelled: ${taskId}` };
364
511
  if (state !== "doing")
365
512
  return { ok: false, reason: `task is not doing: ${taskId}` };
366
- if (cur?.last_by !== actor && !canOverrideCrossActor(override)) {
367
- return { ok: false, reason: crossActorReason(cur?.last_by) };
513
+ if (claimOwnerOf(cur) !== actor && !canOverrideCrossActor(override)) {
514
+ return { ok: false, reason: crossActorReason(claimOwnerOf(cur)) };
368
515
  }
369
516
  return { ok: true };
370
517
  }
371
- export function canUnblockTask(schedule, snapshot, taskId) {
518
+ export function canUnblockTask(schedule, snapshot, taskId, takeOver) {
372
519
  const node = schedule.nodes.get(taskId);
373
520
  if (!node)
374
521
  return { ok: false, reason: `task not found in schedule: ${taskId}` };
@@ -386,6 +533,10 @@ export function canUnblockTask(schedule, snapshot, taskId) {
386
533
  return { ok: false, reason: `task cancelled: ${taskId}` };
387
534
  if (state !== "blocked")
388
535
  return { ok: false, reason: `task is not blocked: ${taskId}` };
536
+ // Taking over moves the claim away from its owner, so it is limited to humans like --force.
537
+ if (takeOver?.requested && !takeOver.isHuman) {
538
+ return { ok: false, reason: `--take-over requires a human actor: ${taskId}` };
539
+ }
389
540
  return { ok: true };
390
541
  }
391
542
  // release returns a doing/blocked task to todo for re-execution. Only the claiming actor may
@@ -408,8 +559,8 @@ export function canReleaseTask(schedule, snapshot, taskId, actor, override) {
408
559
  if (state !== "doing" && state !== "blocked") {
409
560
  return { ok: false, reason: `task is not doing or blocked: ${taskId}` };
410
561
  }
411
- if (cur?.last_by !== actor && !canOverrideCrossActor(override)) {
412
- return { ok: false, reason: crossActorReason(cur?.last_by) };
562
+ if (claimOwnerOf(cur) !== actor && !canOverrideCrossActor(override)) {
563
+ return { ok: false, reason: crossActorReason(claimOwnerOf(cur)) };
413
564
  }
414
565
  return { ok: true };
415
566
  }
@@ -1,9 +1,11 @@
1
1
  import { readFileSync, renameSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join, relative, sep } from "node:path";
3
+ import { runLogPath, runnerRecordPrefixes, taskEvidencePaths, taskRecordPaths, } from "./run-records.js";
3
4
  import { ensureDir, redactSensitiveText, safeSlug } from "./shared.js";
4
5
  import { gitOutput } from "./worktree.js";
6
+ import { isCondenseRecords } from "../shared/condense-records.js";
5
7
  const MAX_LOG_BYTES = 64 * 1024;
6
- const MAX_CHANGE_FILES = 1_000;
8
+ export const MAX_CHANGE_FILES = 1_000;
7
9
  const MAX_FINAL_MESSAGE_LENGTH = 4_000;
8
10
  const MAX_HANDOFF_ITEMS = 100;
9
11
  const MAX_HANDOFF_LENGTH = 4_000;
@@ -108,6 +110,22 @@ export function parseExecutorReport(stdout) {
108
110
  });
109
111
  }
110
112
  }
113
+ const invalidCondense = report.condense_records !== undefined && !isCondenseRecords(report.condense_records);
114
+ if (invalidCondense) {
115
+ report.completion_status = "incomplete";
116
+ report.final_message =
117
+ "Invalid condense_records; supply records matching condense-records.schema.yaml";
118
+ }
119
+ const condenseRecords = isCondenseRecords(report.condense_records)
120
+ ? report.condense_records.map((record) => ({
121
+ ...record,
122
+ location: boundedText(record.location, 4000),
123
+ reason: boundedText(record.reason, 4000),
124
+ cause: record.cause.type === "kata"
125
+ ? { ...record.cause, location: boundedText(record.cause.location, 4000) }
126
+ : record.cause,
127
+ }))
128
+ : undefined;
111
129
  const fallback = stdout.replace(REPORT_PATTERN, "").trim();
112
130
  const handoff = Array.isArray(report.handoff)
113
131
  ? report.handoff
@@ -127,6 +145,7 @@ export function parseExecutorReport(stdout) {
127
145
  handoff,
128
146
  validations,
129
147
  targetCoverage,
148
+ ...(condenseRecords ? { condenseRecords } : {}),
130
149
  };
131
150
  }
132
151
  /** A successful process or validation batch cannot override an explicit incomplete report. */
@@ -136,6 +155,39 @@ export function executorCompletionFailure(evidence) {
136
155
  const detail = boundedText(evidence.final_message, MAX_VALIDATION_SUMMARY_LENGTH);
137
156
  return boundedText(detail ? `executor reported incomplete: ${detail}` : "executor reported incomplete", MAX_VALIDATION_SUMMARY_LENGTH);
138
157
  }
158
+ /**
159
+ * Returns why the executor envelope lacks a field the approach requires, or undefined when the
160
+ * contract holds. Only `condense` currently requires an extra field (`condense_records`).
161
+ */
162
+ export function executorReportContractFailure(evidence, contract) {
163
+ if (contract.approach !== "condense" || (contract.mode ?? "edit") !== "edit")
164
+ return undefined;
165
+ if (isCondenseRecords(evidence.condense_records))
166
+ return undefined;
167
+ return "executor evidence lacks valid condense_records required by approach condense (report [] when there are no candidates)";
168
+ }
169
+ /** Recovery command for a task whose executor stage must be redone in the kept worktree. */
170
+ export function executorStageResumeHint(target) {
171
+ const command = target.kind === "schedule"
172
+ ? `specdojo exec resume --task ${target.taskId} --resume-from executor`
173
+ : `specdojo exec run --register ${target.itemId} --worktree --resume --resume-from executor`;
174
+ return `${command} (add --executor-by <nickname> to switch the executor agent)`;
175
+ }
176
+ /**
177
+ * Checks the approach contract before the reporter stage. On failure the evidence is marked as an
178
+ * incomplete executor report and persisted, so resume selects the executor stage instead of
179
+ * re-running only the reporter on the same evidence.
180
+ */
181
+ export function enforceExecutorReportContract(input) {
182
+ const failure = executorReportContractFailure(input.evidence, input.contract);
183
+ if (!failure)
184
+ return undefined;
185
+ const reason = boundedText(`${failure}; next: ${input.resumeHint}`, MAX_VALIDATION_SUMMARY_LENGTH);
186
+ input.evidence.completion_status = "incomplete";
187
+ input.evidence.block_reason = reason;
188
+ writeExecutorEvidence(input.evidencePath, input.evidence);
189
+ return reason;
190
+ }
139
191
  function normalizedEvidencePath(value) {
140
192
  const normalized = value.replaceAll("\\", "/").replace(/^\.\//u, "");
141
193
  if (!normalized ||
@@ -333,6 +385,7 @@ export function buildExecutorEvidence(input) {
333
385
  summary: truncate(redactSensitiveText(input.diffStat.trim()), MAX_DIFF_SUMMARY_LENGTH),
334
386
  },
335
387
  validations,
388
+ ...(report.condenseRecords ? { condense_records: report.condenseRecords } : {}),
336
389
  ...(report.targetCoverage.length > 0 ? { target_coverage: report.targetCoverage } : {}),
337
390
  ...(input.rateLimitEvents?.length ? { rate_limit_events: input.rateLimitEvents } : {}),
338
391
  final_message: report.finalMessage,
@@ -362,10 +415,8 @@ export function buildExecutorEvidence(input) {
362
415
  export function recordExecutorEvidence(input) {
363
416
  const executionRel = repoRelative(input.repoRoot, input.executionPath);
364
417
  const runnerManagedPrefixes = [
365
- `${executionRel}/exec/plans/`,
366
- `${executionRel}/exec/results/`,
418
+ ...runnerRecordPrefixes(executionRel),
367
419
  `${executionRel}/exec/events/`,
368
- `${executionRel}/exec/evidence/`,
369
420
  `${executionRel}/generated/`,
370
421
  ];
371
422
  const productWorktrees = input.productWorktrees ?? [];
@@ -387,10 +438,9 @@ export function recordExecutorEvidence(input) {
387
438
  .filter(Boolean)
388
439
  .join("\n");
389
440
  const executionInWorktree = join(input.worktreePath, executionRel);
390
- const evidenceDir = join(executionInWorktree, "exec", "evidence", safeSlug(input.taskId), safeSlug(input.runId));
441
+ const { directory: evidenceDir, evidence: evidencePath } = taskEvidencePaths(executionInWorktree, input.taskId, input.runId);
391
442
  ensureDir(evidenceDir);
392
- const logPath = join(evidenceDir, "executor.log");
393
- const evidencePath = join(evidenceDir, "evidence.json");
443
+ const logPath = runLogPath(evidencePath, "executor.log");
394
444
  const { evidence, logExcerpt } = buildExecutorEvidence({
395
445
  taskId: input.taskId,
396
446
  runId: input.runId,
@@ -417,10 +467,8 @@ export function recordExecutorEvidence(input) {
417
467
  export function recordCommandEvidence(input) {
418
468
  const executionRel = repoRelative(input.repoRoot, input.executionPath);
419
469
  const runnerManagedPrefixes = [
420
- `${executionRel}/exec/plans/`,
421
- `${executionRel}/exec/results/`,
470
+ ...runnerRecordPrefixes(executionRel),
422
471
  `${executionRel}/exec/events/`,
423
- `${executionRel}/exec/evidence/`,
424
472
  `${executionRel}/generated/`,
425
473
  ];
426
474
  const changes = parseStatusPaths(input.worktreePath)
@@ -431,11 +479,11 @@ export function recordCommandEvidence(input) {
431
479
  status: boundedText(change.status, 40),
432
480
  }));
433
481
  const diffStat = gitOutput(input.worktreePath, ["diff", "--stat", "HEAD", "--"]);
434
- const evidenceDir = join(input.worktreePath, executionRel, "exec", "evidence", safeSlug(input.taskId), safeSlug(input.runId));
482
+ const evidenceDir = taskRecordPaths(join(input.worktreePath, executionRel), input.taskId, input.runId).directory;
435
483
  ensureDir(evidenceDir);
436
- const stdoutPath = join(evidenceDir, "command.stdout.log");
437
- const stderrPath = join(evidenceDir, "command.stderr.log");
438
- const evidencePath = join(evidenceDir, "evidence.json");
484
+ const evidencePath = taskRecordPaths(join(input.worktreePath, executionRel), input.taskId, input.runId).evidence;
485
+ const stdoutPath = runLogPath(evidencePath, "command.stdout.log");
486
+ const stderrPath = runLogPath(evidencePath, "command.stderr.log");
439
487
  const boundedStdout = boundedLog(input.stdout);
440
488
  const boundedStderr = boundedLog(input.stderr);
441
489
  writeFileSync(stdoutPath, boundedStdout.content, "utf8");
@@ -537,7 +585,7 @@ export function recordParentValidationFailureOutput(input) {
537
585
  const attempt = Math.max(0, ...priorAttempts) + 1;
538
586
  const refs = [];
539
587
  for (const output of input.failureOutputs) {
540
- const logPath = join(evidenceDir, `parent-validation-attempt-${attempt}-${safeSlug(output.label)}.log`);
588
+ const logPath = runLogPath(input.evidencePath, `parent-validation-attempt-${attempt}-${safeSlug(output.label)}.log`);
541
589
  const content = redactSensitiveText([
542
590
  `parent validation: ${output.label}`,
543
591
  `exit code: ${output.exitCode ?? "unknown"}`,
@@ -577,7 +625,7 @@ export function recordReporterFailureOutput(input) {
577
625
  input.invocationOutputs.forEach((output, index) => {
578
626
  const attempt = index + 1;
579
627
  for (const stream of ["stdout", "stderr"]) {
580
- const logPath = join(evidenceDir, `reporter-attempt-${attempt}.${stream}.log`);
628
+ const logPath = runLogPath(input.evidencePath, `reporter-attempt-${attempt}.${stream}.log`);
581
629
  const boundedOutput = boundedLog(output[stream]);
582
630
  writeFileSync(logPath, boundedOutput.content, "utf8");
583
631
  reporterRefs.push({
@@ -1,18 +1,19 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { existsSync, lstatSync, mkdtempSync, readFileSync, readdirSync, rmSync, unlinkSync, writeFileSync, } from "node:fs";
2
+ import { lstatSync, mkdtempSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
- import { createInterface } from "node:readline/promises";
5
4
  import { join, posix, resolve } from "node:path";
5
+ import { createInterface } from "node:readline/promises";
6
+ import { parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
7
+ import { specdojoRootDir } from "../shared/specdojo-config.js";
6
8
  import { isAgentProtectedConfigPath } from "./agent-protected-config.js";
7
9
  import { PROTECTION_HANDOFF_MARKER } from "./protection-handoff.js";
8
10
  import { normalizePjrId, resolveRegisterRunTarget } from "./register.js";
9
11
  import { refsTrailer, withCommitTrailers } from "./repo-trace.js";
10
- import { configuredProductReposForProject } from "./task-repos.js";
11
- import { parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
12
+ import { listRunRecords } from "./run-records.js";
12
13
  import { qualifyTaskId } from "./shared.js";
13
- import { specdojoRootDir } from "../shared/specdojo-config.js";
14
+ import { configuredProductReposForProject } from "./task-repos.js";
15
+ import { stabilizeCommitTargets, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "./worktree-ops.js";
14
16
  import { findExecWorktree, formatGitResultFailure, gitEnvironment, gitOutput, gitResult, } from "./worktree.js";
15
- import { stageCommitTargets, stabilizeCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "./worktree-ops.js";
16
17
  const HANDOFF_MECHANISM = "agent-config-write";
17
18
  const TRUNCATED_EVIDENCE_RE = /^\.\.\. \((?:\d+ 行を省略|文字数上限で切り詰め)\)$/m;
18
19
  function sectionAfterMarker(content) {
@@ -56,13 +57,8 @@ export function extractProtectedConfigHandoff(content) {
56
57
  return { subjects, patch: `${patch}\n` };
57
58
  }
58
59
  function latestResultForTask(executionPath, taskId) {
59
- const resultsDir = join(executionPath, "exec", "results");
60
- if (!existsSync(resultsDir))
61
- throw new Error(`Result directory not found: ${resultsDir}`);
62
- const candidates = readdirSync(resultsDir)
63
- .filter((name) => name.endsWith("-result.md"))
64
- .flatMap((name) => {
65
- const path = join(resultsDir, name);
60
+ const candidates = listRunRecords(executionPath, "result")
61
+ .flatMap((path) => {
66
62
  const data = parseSpecdojoDocument(readFileSync(path, "utf8")).data;
67
63
  if (data.task_id !== taskId)
68
64
  return [];
@@ -247,7 +247,7 @@ function deferredTask(taskId, state, now) {
247
247
  const attempts = attemptsText && /^\d+$/.test(attemptsText) ? Number.parseInt(attemptsText, 10) : 0;
248
248
  return {
249
249
  taskId,
250
- actor: state.last_by ?? "",
250
+ actor: state.claimed_by ?? state.last_by ?? "",
251
251
  kind,
252
252
  resumeAt: resumeAt.toISOString(),
253
253
  attempts,
@@ -0,0 +1,45 @@
1
+ import { MAX_TEXT_LENGTH } from "./reporter-output.js";
2
+ import { deriveReporterFacts } from "./reporter.js";
3
+ const MAX_SUMMARY_ITEMS = 100;
4
+ export const MECHANICAL_RESULT_APPROACH = "reporter を使わず、runner が executor の報告(`final_message`・`handoff`)と証跡から機械的に作成した(`pipeline.mechanical_result`)。";
5
+ function bounded(text) {
6
+ return text.length <= MAX_TEXT_LENGTH ? text : `${text.slice(0, MAX_TEXT_LENGTH - 1)}…`;
7
+ }
8
+ // executor の `final_message` は箇条書きや複数行の要約になることがある。行頭の箇条書きの記号を
9
+ // 外し、1 行を実施内容の 1 項目にする。
10
+ function summaryItems(finalMessage) {
11
+ return finalMessage
12
+ .split(/\r?\n/)
13
+ .map((line) => line.replace(/^\s*(?:[-*+]|\d+\.)\s+/, "").trim())
14
+ .filter(Boolean)
15
+ .slice(0, MAX_SUMMARY_ITEMS)
16
+ .map(bounded);
17
+ }
18
+ /**
19
+ * PJR-T01P: the edit result fields the runner can fill without the reporter agent. Returns
20
+ * `undefined` when a field needs summarising or judgement, so the caller runs the reporter:
21
+ * review mode (verdict), a blocked outcome (the reporter explains partial work), or an executor
22
+ * report without `final_message`.
23
+ *
24
+ * - `summary`: the lines of the executor's `final_message`.
25
+ * - `changed_files`: empty; the renderer lists the evidence changes with git line counts.
26
+ * - `handoff`: empty; the renderer keeps the executor `handoff` and the runner-derived notes.
27
+ * - `approach`: a fixed sentence stating that the runner wrote the result.
28
+ */
29
+ export function mechanicalEditReporterOutput(evidence, mode = "edit") {
30
+ if (mode !== "edit")
31
+ return undefined;
32
+ const summary = summaryItems(evidence.final_message ?? "");
33
+ if (summary.length === 0)
34
+ return undefined;
35
+ if (deriveReporterFacts(evidence, { mode }).outcome !== "complete")
36
+ return undefined;
37
+ return {
38
+ schema_version: 1,
39
+ mode: "edit",
40
+ summary,
41
+ changed_files: [],
42
+ handoff: [],
43
+ approach: MECHANICAL_RESULT_APPROACH,
44
+ };
45
+ }