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
@@ -0,0 +1,64 @@
1
+ // 個票の「作業内容」の表が実績に合っているかを検査する。close の前に、未着手のまま
2
+ // 理由のない行や `_TODO_` の残った行を見つけ、完了を止める理由として返す。
3
+ const WORK_TABLE_HEADING_RE = /^##\s+(?:\d+\.\s*)?作業内容\s*$/;
4
+ const PLACEHOLDER_CELLS = new Set(["", "-", "_TODO_"]);
5
+ const DONE_STATE = "done";
6
+ function splitTableRow(line) {
7
+ const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
8
+ // `\|` はセル内の文字であり、列の区切りではない。
9
+ return trimmed.split(/(?<!\\)\|/).map((cell) => cell.trim());
10
+ }
11
+ // インラインコードの `_TODO_` は記法の説明であり、未記入の目印ではない。
12
+ function hasTodoMarker(cell) {
13
+ return cell.replace(/`[^`]*`/g, "").includes("_TODO_");
14
+ }
15
+ function isSeparatorRow(cells) {
16
+ return cells.length > 0 && cells.every((cell) => /^:?-{3,}:?$/.test(cell));
17
+ }
18
+ function workTableLines(content) {
19
+ const body = content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "");
20
+ const lines = body.split(/\r?\n/);
21
+ const heading = lines.findIndex((line) => WORK_TABLE_HEADING_RE.test(line));
22
+ if (heading < 0)
23
+ return [];
24
+ const section = [];
25
+ for (const line of lines.slice(heading + 1)) {
26
+ if (/^##\s+/.test(line))
27
+ break;
28
+ section.push(line);
29
+ }
30
+ const start = section.findIndex((line) => line.trim().startsWith("|"));
31
+ if (start < 0)
32
+ return [];
33
+ const endOffset = section.slice(start).findIndex((line) => !line.trim().startsWith("|"));
34
+ return section.slice(start, endOffset < 0 ? undefined : start + endOffset);
35
+ }
36
+ // 状態が done でない行は、メモに残した理由があれば通す。理由のない行と、どの列であれ
37
+ // `_TODO_` の目印が残る行を問題として返す。表や状態の列がない個票は検査の対象外とする。
38
+ export function registerWorkTableIssues(content) {
39
+ const [header, separator, ...rows] = workTableLines(content).map(splitTableRow);
40
+ if (!header || !separator || !isSeparatorRow(separator))
41
+ return [];
42
+ const stateIndex = header.indexOf("状態");
43
+ if (stateIndex < 0)
44
+ return [];
45
+ const noteIndex = header.indexOf("メモ");
46
+ const numberIndex = header.indexOf("No");
47
+ return rows.flatMap((cells, index) => {
48
+ const label = `row ${numberIndex >= 0 && cells[numberIndex] ? cells[numberIndex] : index + 1}`;
49
+ if (cells.some(hasTodoMarker)) {
50
+ return [`${label} still contains _TODO_`];
51
+ }
52
+ const state = cells[stateIndex] ?? "";
53
+ if (state === DONE_STATE)
54
+ return [];
55
+ const note = noteIndex >= 0 ? (cells[noteIndex] ?? "") : "";
56
+ if (!PLACEHOLDER_CELLS.has(note))
57
+ return [];
58
+ return [`${label} is "${state || "-"}" without a reason in メモ`];
59
+ });
60
+ }
61
+ export function registerWorkTableIssueMessage(id, issues) {
62
+ return (`the 作業内容 table of ${id} does not match the work done: ${issues.join("; ")}. ` +
63
+ `Set each row to done, or write why it remains in メモ.`);
64
+ }
@@ -1,4 +1,5 @@
1
1
  import { spawn } from "node:child_process";
2
+ import { createHash } from "node:crypto";
2
3
  import { existsSync, readFileSync } from "node:fs";
3
4
  import { join } from "node:path";
4
5
  import { gitEnvironment } from "../shared/git-environment.js";
@@ -84,6 +85,9 @@ export function reviewGradeArgs(opts) {
84
85
  const args = [
85
86
  "grade",
86
87
  "run",
88
+ "--isolate-pipeline-state",
89
+ "--if-busy",
90
+ "wait",
87
91
  "--run-id",
88
92
  opts.runId,
89
93
  "--project",
@@ -123,10 +127,16 @@ function lastLine(text) {
123
127
  .filter(Boolean);
124
128
  return lines.at(-1) ?? "";
125
129
  }
130
+ // grade の出力の形式の誤りなど一過性の失敗に備え、review の前の grade は合計この回数まで試す
131
+ // (PJR-M18B)。各試行は別の run id を使い、失敗した試行の状態を引き継がない。
132
+ export const REVIEW_GRADE_MAX_ATTEMPTS = 3;
133
+ export function reviewGradeAttemptRunId(runId, attempt) {
134
+ return attempt <= 1 ? runId : `${runId}-a${attempt}`;
135
+ }
126
136
  /**
127
137
  * Runner-side grade before a review plan is generated. The executor never grades (PJR-2ZVS 3.6).
128
- * Failures are reported in the outcome instead of thrown so the review can still record
129
- * grade-stale / grade-unavailable as its verdict.
138
+ * A failed grade is retried up to maxAttempts times. Failures are reported in the outcome instead
139
+ * of thrown; the runner then blocks the review task instead of completing it (PJR-M18B).
130
140
  */
131
141
  export async function ensureReviewGrade(opts) {
132
142
  const freshness = reviewGradeFreshness({
@@ -135,12 +145,29 @@ export async function ensureReviewGrade(opts) {
135
145
  rootDir: opts.repoRoot,
136
146
  });
137
147
  const decision = decideReviewGradeAction({
138
- freshness,
148
+ freshness: freshness.state === "fresh" && freshness.result.target !== opts.target
149
+ ? { ...freshness, state: "stale" }
150
+ : freshness,
139
151
  dryRun: opts.dryRun,
140
152
  });
141
153
  if (!decision.run)
142
154
  return decision.outcome;
143
- const runId = reviewGradeRunId(opts.taskId, opts.now ?? new Date());
155
+ const subjectKey = createHash("sha256").update(opts.subjectPath).digest("hex").slice(0, 10);
156
+ const baseRunId = reviewGradeRunId(`${opts.taskId}-${subjectKey}`, opts.now ?? new Date());
157
+ const invoke = opts.invoke ?? defaultInvoke;
158
+ const maxAttempts = Math.max(1, Math.floor(opts.maxAttempts ?? REVIEW_GRADE_MAX_ATTEMPTS));
159
+ for (let attempt = 1;; attempt += 1) {
160
+ const runId = reviewGradeAttemptRunId(baseRunId, attempt);
161
+ const detail = await invokeReviewGrade(opts, runId, invoke);
162
+ if (detail === undefined)
163
+ return { action: "executed", runId };
164
+ if (attempt >= maxAttempts)
165
+ return { action: "failed", runId, detail, attempts: attempt };
166
+ process.stderr.write(`[grade] attempt ${attempt}/${maxAttempts} failed; retrying: ${detail}\n`);
167
+ }
168
+ }
169
+ /** Run one grade attempt. Returns undefined on success, or the failure detail. */
170
+ async function invokeReviewGrade(opts, runId, invoke) {
144
171
  const args = reviewGradeArgs({
145
172
  runId,
146
173
  projectId: opts.projectId,
@@ -149,7 +176,6 @@ export async function ensureReviewGrade(opts) {
149
176
  by: opts.by,
150
177
  execDefaultsPath: opts.execDefaultsPath,
151
178
  });
152
- const invoke = opts.invoke ?? defaultInvoke;
153
179
  try {
154
180
  // Resolve the entrypoint from this package, never from the consumer repository.
155
181
  const javascript = fileURLToPath(new URL("../specdojo.js", import.meta.url));
@@ -158,16 +184,12 @@ export async function ensureReviewGrade(opts) {
158
184
  : ["--import", "tsx", fileURLToPath(new URL("../specdojo.ts", import.meta.url))];
159
185
  const { exitCode, stderr } = await invoke(process.execPath, [...entryArgs, ...args], opts.repoRoot);
160
186
  if (exitCode === 0)
161
- return { action: "executed", runId };
187
+ return undefined;
162
188
  const reason = lastLine(stderr);
163
- return {
164
- action: "failed",
165
- runId,
166
- detail: `${opts.subjectPath}: exit ${exitCode}${reason ? `: ${reason}` : ""}`,
167
- };
189
+ return `${opts.subjectPath}: exit ${exitCode}${reason ? `: ${reason}` : ""}`;
168
190
  }
169
191
  catch (error) {
170
- return { action: "failed", runId, detail: `${opts.subjectPath}: ${errorMessage(error)}` };
192
+ return `${opts.subjectPath}: ${errorMessage(error)}`;
171
193
  }
172
194
  }
173
195
  function outcomeLine(outcome) {
@@ -179,7 +201,7 @@ function outcomeLine(outcome) {
179
201
  case "executed":
180
202
  return `- runner の grade 実行: 実行した(run id: \`${outcome.runId}\`)`;
181
203
  case "failed":
182
- return `- runner の grade 実行: 失敗した(run id: \`${outcome.runId}\`; ${outcome.detail})`;
204
+ return `- runner の grade 実行: ${outcome.attempts} 回試して失敗した(最後の run id: \`${outcome.runId}\`; ${outcome.detail})。runner はこの review タスクを完了にせず blocked にする`;
183
205
  case "not-run":
184
206
  return `- runner の grade 実行: 実行していない(${outcome.detail})`;
185
207
  }
@@ -1,6 +1,7 @@
1
1
  import { basename, join, resolve } from "node:path";
2
- import { getProjectRoutinesPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
2
+ import { getProjectRoutinesPath, getProjectExecutionPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
3
3
  import { listFilesRecursive, readYaml } from "../shared/fs.js";
4
+ import { routineStoragePaths } from "./storage.js";
4
5
  export function routineActionKindLabel(action) {
5
6
  const actions = Array.isArray(action) ? action : [action];
6
7
  return actions.length > 0 ? actions.map((item) => item.kind).join(" -> ") : "-";
@@ -359,8 +360,8 @@ export function resolveRoutinePaths(opts) {
359
360
  projectId,
360
361
  routinesPath: absRoutinesPath,
361
362
  generatedPath,
362
- statePath: join(generatedPath, "routine-state.json"),
363
- runsPath: join(generatedPath, "routine-runs.jsonl"),
363
+ ...routineStoragePaths(absRoutinesPath, baseDir),
364
+ failuresPath: resolve(baseDir, getProjectExecutionPath(project), "routines", "failures"),
364
365
  };
365
366
  }
366
367
  export function isRoutineYamlFile(filePath) {
@@ -0,0 +1,30 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { join, relative } from "node:path";
3
+ import { ensureDir, writeJson } from "../shared/fs.js";
4
+ import { gitOutput } from "../shared/git.js";
5
+ import { redactSensitiveText } from "../shared/text.js";
6
+ /** Durable diagnostics only when no Job Run exists to explain a failed routine. */
7
+ export function recordRoutineFailure(repoRoot, failuresPath, entry) {
8
+ if (entry.result !== "failure" || entry.job_run_ids.length > 0)
9
+ return undefined;
10
+ const runId = randomUUID();
11
+ const directory = join(failuresPath, entry.routine_id);
12
+ ensureDir(directory);
13
+ const file = join(directory, `${runId}.json`);
14
+ writeJson(file, {
15
+ ...entry,
16
+ run_id: runId,
17
+ ...(entry.reason ? { reason: redactSensitiveText(entry.reason) } : {}),
18
+ });
19
+ const target = relative(repoRoot, file);
20
+ gitOutput(repoRoot, ["add", "--", target]);
21
+ gitOutput(repoRoot, [
22
+ "commit",
23
+ "--only",
24
+ "-m",
25
+ `chore(routine): record failure ${entry.routine_id}`,
26
+ "--",
27
+ target,
28
+ ]);
29
+ return file;
30
+ }
@@ -11,6 +11,8 @@ import { jobDeclaresReview, jobRunUsesReviewedIntegration, loadJobDefinition, re
11
11
  import { cronOccurrences, isRecord, isRoutineDue, isRoutineYamlFile, isoWeek, loadRoutines, resolveRoutinePaths, routineActionKindLabel, } from "./definition.js";
12
12
  import { selfRunArgs } from "../shared/spawn-self.js";
13
13
  import { specdojoRootDir } from "../shared/specdojo-config.js";
14
+ import { migrateRoutineStorage } from "./storage.js";
15
+ import { recordRoutineFailure } from "./failure.js";
14
16
  export { cronMatches, cronOccurrences, isRoutineDue, isoWeek, loadRoutines, parseCronExpression, parseIntervalMs, parseRoutineDoc, resolveRoutinePaths, routineActionKindLabel, } from "./definition.js";
15
17
  // ================================
16
18
  // State
@@ -30,7 +32,7 @@ function readRoutineState(statePath) {
30
32
  return { routines: {} };
31
33
  }
32
34
  function writeRoutineState(paths, state) {
33
- ensureDir(paths.generatedPath);
35
+ ensureDir(paths.stateDirectory);
34
36
  writeJson(paths.statePath, state);
35
37
  }
36
38
  export function recordRoutineStart(current, startedAt, scheduledAt) {
@@ -68,8 +70,7 @@ export function appendRoutineRunHistory(runsPath, entry) {
68
70
  const ROUTINE_LOCK_STALE_MS = 60 * 60 * 1000;
69
71
  // routine run の多重起動(外部スケジューラの重複発火)を防ぐ簡易 lock。
70
72
  // 生存中の lock があれば即座に失敗し、stale(1 時間超)な lock は奪う。
71
- function acquireRoutineLock(routinesPath) {
72
- const lockDir = join(routinesPath, ".locks", "routine-run.lock");
73
+ function acquireRoutineLock(lockDir) {
73
74
  ensureDir(resolve(lockDir, ".."));
74
75
  try {
75
76
  mkdirSync(lockDir);
@@ -110,9 +111,11 @@ function ensureFreshDistForRoutineRun() {
110
111
  }
111
112
  let lastRoutineSpawnReason;
112
113
  let lastRoutineSpawnRunId;
114
+ let lastRoutineSpawnNoop = false;
113
115
  function spawnSelf(args) {
114
116
  lastRoutineSpawnReason = undefined;
115
117
  lastRoutineSpawnRunId = undefined;
118
+ lastRoutineSpawnNoop = false;
116
119
  const [exe, fullArgs] = selfRunArgs(args);
117
120
  const result = spawnSync(exe, fullArgs, {
118
121
  encoding: "utf8",
@@ -128,6 +131,7 @@ function spawnSelf(args) {
128
131
  const output = `${result.stdout ?? ""}\n${result.stderr ?? ""}`;
129
132
  const marker = [...output.matchAll(/^\[routine-job\]\s+([^\n]+)$/gm)].at(-1)?.[1];
130
133
  if (marker) {
134
+ lastRoutineSpawnNoop = /\bstate=noop\b/.test(marker);
131
135
  lastRoutineSpawnRunId = marker.match(/\brun_id=([^\s]+)/)?.[1];
132
136
  lastRoutineSpawnReason = marker.match(/\breason=(.+)$/)?.[1]?.trim();
133
137
  }
@@ -212,6 +216,7 @@ function executeRoutineAction(doc, action, projectId, dryRun, scheduledAt = new
212
216
  if (dryRun) {
213
217
  lastRoutineSpawnReason = undefined;
214
218
  lastRoutineSpawnRunId = undefined;
219
+ lastRoutineSpawnNoop = false;
215
220
  process.stdout.write(` [dry-run] specdojo ${args.join(" ")}\n`);
216
221
  if (action.kind === "job") {
217
222
  try {
@@ -231,7 +236,7 @@ export function buildSpecdojoActionArgs(action, projectId) {
231
236
  return [...action.args, "--project", projectId];
232
237
  }
233
238
  function findJobRunId(action, projectId, scheduledAt) {
234
- if (action.kind !== "job")
239
+ if (action.kind !== "job" || lastRoutineSpawnNoop)
235
240
  return undefined;
236
241
  const runsPath = resolveJobPaths(projectId).runsPath;
237
242
  if (!existsSync(runsPath))
@@ -261,36 +266,40 @@ function executeRoutine(routine, projectId, dryRun, scheduledAt = new Date()) {
261
266
  const actions = Array.isArray(doc.action) ? doc.action : [doc.action];
262
267
  const label = doc.name ?? (actions.length === 1 ? actions[0].kind : `${actions.length} actions`);
263
268
  process.stdout.write(`[routine] ${doc.id}: ${label}\n`);
264
- if (!Array.isArray(doc.action)) {
265
- const result = executeRoutineAction(doc, doc.action, projectId, dryRun, scheduledAt);
266
- const jobRunId = dryRun ? undefined : findJobRunId(doc.action, projectId, scheduledAt);
267
- return {
268
- result,
269
- jobRunIds: lastRoutineSpawnRunId ? [lastRoutineSpawnRunId] : jobRunId ? [jobRunId] : [],
270
- ...(lastRoutineSpawnReason ? { reason: lastRoutineSpawnReason } : {}),
271
- };
272
- }
269
+ const multiple = Array.isArray(doc.action);
270
+ const jobRunIds = [];
271
+ const reasons = [];
273
272
  const actionResults = executeRoutineActions(actions, (action, index) => {
274
- process.stdout.write(` action ${index}/${actions.length}: ${action.kind}\n`);
275
- const result = executeRoutineAction(doc, action, projectId, dryRun, scheduledAt);
276
- process.stdout.write(` action ${index}/${actions.length}: ${result}\n`);
273
+ if (multiple)
274
+ process.stdout.write(` action ${index}/${actions.length}: ${action.kind}\n`);
275
+ lastRoutineSpawnReason = undefined;
276
+ lastRoutineSpawnRunId = undefined;
277
+ lastRoutineSpawnNoop = false;
278
+ let result;
279
+ try {
280
+ result = executeRoutineAction(doc, action, projectId, dryRun, scheduledAt);
281
+ }
282
+ catch (error) {
283
+ result = "failure";
284
+ lastRoutineSpawnReason = error instanceof Error ? error.message : String(error);
285
+ }
286
+ const runId = lastRoutineSpawnRunId ?? (dryRun ? undefined : findJobRunId(action, projectId, scheduledAt));
287
+ if (runId)
288
+ jobRunIds.push(runId);
289
+ if (lastRoutineSpawnReason)
290
+ reasons.push(lastRoutineSpawnReason);
291
+ if (multiple)
292
+ process.stdout.write(` action ${index}/${actions.length}: ${result}\n`);
277
293
  return result;
278
294
  });
279
295
  const result = aggregateRoutineActionResults(actionResults.map((item) => item.result));
280
- process.stdout.write(` action summary: ${actionResults.map((item) => `${item.index}:${item.result}`).join(", ")} => ${result}\n`);
281
- const jobRunIds = dryRun
282
- ? []
283
- : doc.action.flatMap((action) => {
284
- const runId = findJobRunId(action, projectId, scheduledAt);
285
- return runId ? [runId] : [];
286
- });
296
+ if (multiple)
297
+ process.stdout.write(` action summary: ${actionResults.map((item) => `${item.index}:${item.result}`).join(", ")} => ${result}\n`);
287
298
  return {
288
299
  result,
289
- actionResults,
290
- jobRunIds: [
291
- ...new Set([...(lastRoutineSpawnRunId ? [lastRoutineSpawnRunId] : []), ...jobRunIds]),
292
- ],
293
- ...(lastRoutineSpawnReason ? { reason: lastRoutineSpawnReason } : {}),
300
+ ...(multiple ? { actionResults } : {}),
301
+ jobRunIds: [...new Set(jobRunIds)],
302
+ ...(reasons.length ? { reason: reasons.join("; ") } : {}),
294
303
  };
295
304
  }
296
305
  // ================================
@@ -368,6 +377,7 @@ export function registerRoutineCommands(program) {
368
377
  process.exitCode = 1;
369
378
  return;
370
379
  }
380
+ migrateRoutineStorage(paths.routinesPath);
371
381
  const state = readRoutineState(paths.statePath);
372
382
  const now = new Date();
373
383
  const rows = routines.map(({ doc }) => ({
@@ -423,6 +433,8 @@ export function registerRoutineCommands(program) {
423
433
  }
424
434
  if (errors.length > 0)
425
435
  process.exitCode = 1;
436
+ if (!opts.dryRun)
437
+ migrateRoutineStorage(paths.routinesPath);
426
438
  const state = readRoutineState(paths.statePath);
427
439
  const now = new Date();
428
440
  let selected;
@@ -457,7 +469,7 @@ export function registerRoutineCommands(program) {
457
469
  process.exitCode = 1;
458
470
  return;
459
471
  }
460
- lockDir = acquireRoutineLock(paths.routinesPath);
472
+ lockDir = acquireRoutineLock(paths.lockPath);
461
473
  }
462
474
  let failed = 0;
463
475
  let partial = 0;
@@ -472,7 +484,17 @@ export function registerRoutineCommands(program) {
472
484
  state.routines[entry.doc.id] = recordRoutineStart(state.routines[entry.doc.id], startedAt, entry.doc.trigger ? scheduledAt.toISOString() : undefined);
473
485
  writeRoutineState(paths, state);
474
486
  }
475
- const execution = executeRoutine(entry, paths.projectId, dryRun, scheduledAt);
487
+ let execution;
488
+ try {
489
+ execution = executeRoutine(entry, paths.projectId, dryRun, scheduledAt);
490
+ }
491
+ catch (error) {
492
+ execution = {
493
+ result: "failure",
494
+ jobRunIds: [],
495
+ reason: error instanceof Error ? error.message : String(error),
496
+ };
497
+ }
476
498
  const { result } = execution;
477
499
  if (result === "failure")
478
500
  failed++;
@@ -485,7 +507,7 @@ export function registerRoutineCommands(program) {
485
507
  if (!dryRun) {
486
508
  state.routines[entry.doc.id] = recordRoutineCompletion(state.routines[entry.doc.id], result, execution.reason, execution.actionResults);
487
509
  writeRoutineState(paths, state);
488
- appendRoutineRunHistory(paths.runsPath, {
510
+ const history = {
489
511
  version: 1,
490
512
  routine_id: entry.doc.id,
491
513
  scheduled_for: scheduledAt.toISOString(),
@@ -494,7 +516,9 @@ export function registerRoutineCommands(program) {
494
516
  result,
495
517
  job_run_ids: execution.jobRunIds,
496
518
  ...(execution.reason ? { reason: execution.reason } : {}),
497
- });
519
+ };
520
+ appendRoutineRunHistory(paths.runsPath, history);
521
+ recordRoutineFailure(specdojoRootDir(), paths.failuresPath, history);
498
522
  }
499
523
  }
500
524
  process.stdout.write(`[routine] ${selected.length} routine(s) processed, ${partial} partial, ${skipped} skipped, ${failed} failed\n`);
@@ -0,0 +1,33 @@
1
+ import { constants, copyFileSync, existsSync, mkdirSync } from "node:fs";
2
+ import { createHash } from "node:crypto";
3
+ import { join, relative, resolve } from "node:path";
4
+ import { localStateDirectory } from "../shared/local-state.js";
5
+ import { specdojoRootDir } from "../shared/specdojo-config.js";
6
+ export function routineStoragePaths(routinesPath, repoRoot = specdojoRootDir()) {
7
+ const key = createHash("sha256").update(relative(repoRoot, routinesPath)).digest("hex");
8
+ const stateDirectory = join(localStateDirectory(repoRoot), "routines", key);
9
+ return {
10
+ stateDirectory,
11
+ statePath: join(stateDirectory, "routine-state.json"),
12
+ runsPath: join(stateDirectory, "routine-runs.jsonl"),
13
+ lockPath: join(stateDirectory, ".locks", "routine-run.lock"),
14
+ };
15
+ }
16
+ /** Copy once, preserving the old files for rollback and never overwriting newer state. */
17
+ export function migrateRoutineStorage(routinesPath, repoRoot = specdojoRootDir()) {
18
+ const paths = routineStoragePaths(routinesPath, repoRoot);
19
+ for (const destination of [paths.statePath, paths.runsPath]) {
20
+ const source = join(routinesPath, "generated", destination === paths.statePath ? "routine-state.json" : "routine-runs.jsonl");
21
+ if (!existsSync(source) || existsSync(destination))
22
+ continue;
23
+ mkdirSync(resolve(destination, ".."), { recursive: true });
24
+ try {
25
+ copyFileSync(source, destination, constants.COPYFILE_EXCL);
26
+ }
27
+ catch (error) {
28
+ if (error.code !== "EEXIST")
29
+ throw error;
30
+ }
31
+ }
32
+ return paths;
33
+ }
@@ -289,6 +289,7 @@ function registerScheduleStrategyCommands(sch) {
289
289
  schedulePath: context.schedulePath,
290
290
  track,
291
291
  content: result.content,
292
+ repoRoot: context.baseDir,
292
293
  force: !!opts.force,
293
294
  dryRun: !!opts.dryRun,
294
295
  });
@@ -1,7 +1,7 @@
1
1
  import { AUTHOR_PHASE_SETS, PHASE_SET_ORDER, profileFor, renderPhase, STRATEGY_PHASE_SETS, } from "./strategy-profiles.js";
2
2
  import { artifactNameFromCatalogTitle, } from "./strategy-generate-scope.js";
3
- function phaseSetsOf(approach) {
4
- return profileFor(approach).phase_sets;
3
+ function phaseSetsOf(deliverable) {
4
+ return profileFor(deliverable.approach).phase_sets.filter((name) => !deliverable.not_needed_kata?.some((kind) => name === `${kind}-maintenance-pass`));
5
5
  }
6
6
  function orderPhaseSets(names) {
7
7
  const unique = [...new Set(names)];
@@ -38,7 +38,7 @@ export function buildStrategyDocument(input) {
38
38
  return false;
39
39
  });
40
40
  const sorted = [...eligibleDeliverables].sort((left, right) => left.local_id.localeCompare(right.local_id));
41
- // --- owner_rules: one rule per (owner, approach) pair -------------------------
41
+ // Group by the effective sequence too: the same approach can omit different not-needed Kata.
42
42
  const groups = new Map();
43
43
  for (const deliverable of sorted) {
44
44
  const owner = input.owners.get(deliverable.local_id);
@@ -46,22 +46,34 @@ export function buildStrategyDocument(input) {
46
46
  errors.push(`${deliverable.local_id}: owner が解決できていない。`);
47
47
  continue;
48
48
  }
49
- const key = JSON.stringify([owner, deliverable.approach]);
50
- const group = groups.get(key) ?? { owner, approach: deliverable.approach, localIds: [] };
49
+ const sequence = phaseSetsOf(deliverable);
50
+ const key = JSON.stringify([owner, deliverable.approach, sequence]);
51
+ const group = groups.get(key) ?? {
52
+ owner,
53
+ approach: deliverable.approach,
54
+ sequence,
55
+ localIds: [],
56
+ };
51
57
  group.localIds.push(deliverable.local_id);
52
58
  groups.set(key, group);
53
59
  }
54
60
  const orderedGroups = [...groups.values()].sort((left, right) => left.owner === right.owner
55
- ? left.approach.localeCompare(right.approach)
61
+ ? left.approach.localeCompare(right.approach) ||
62
+ left.sequence.join(",").localeCompare(right.sequence.join(","))
56
63
  : left.owner.localeCompare(right.owner));
57
64
  // The most common profile becomes default_phase_sets so rules that follow it stay compact.
58
- const byApproach = new Map();
65
+ const bySequence = new Map();
59
66
  for (const deliverable of sorted) {
60
- byApproach.set(deliverable.approach, (byApproach.get(deliverable.approach) ?? 0) + 1);
67
+ const sequence = phaseSetsOf(deliverable);
68
+ const key = JSON.stringify(sequence);
69
+ const entry = bySequence.get(key) ?? { sequence, count: 0 };
70
+ entry.count++;
71
+ bySequence.set(key, entry);
61
72
  }
62
- const defaultApproach = [...byApproach.entries()].sort((left, right) => right[1] === left[1] ? left[0].localeCompare(right[0]) : right[1] - left[1])[0]?.[0];
63
- const defaultSequence = defaultApproach ? phaseSetsOf(defaultApproach) : [];
64
- const usedPhaseSets = orderPhaseSets(sorted.flatMap((d) => phaseSetsOf(d.approach)));
73
+ const defaultSequence = [...bySequence.entries()].sort((left, right) => right[1].count === left[1].count
74
+ ? left[0].localeCompare(right[0])
75
+ : right[1].count - left[1].count)[0]?.[1].sequence ?? [];
76
+ const usedPhaseSets = orderPhaseSets(sorted.flatMap(phaseSetsOf));
65
77
  const phaseSets = {};
66
78
  for (const name of usedPhaseSets) {
67
79
  const definition = STRATEGY_PHASE_SETS[name];
@@ -72,7 +84,7 @@ export function buildStrategyDocument(input) {
72
84
  phaseSets[name] = definition.map(renderPhase);
73
85
  }
74
86
  const ownerRules = orderedGroups.map((group) => {
75
- const sequence = phaseSetsOf(group.approach);
87
+ const sequence = group.sequence;
76
88
  const sameAsDefault = sequence.length === defaultSequence.length &&
77
89
  sequence.every((name, index) => name === defaultSequence[index]);
78
90
  const finalizeApproach = profileFor(group.approach).finalize_approach;
@@ -86,7 +98,7 @@ export function buildStrategyDocument(input) {
86
98
  };
87
99
  });
88
100
  // --- phase gates -------------------------------------------------------------
89
- const countUsing = (phaseSetName) => sorted.filter((d) => phaseSetsOf(d.approach).includes(phaseSetName)).length;
101
+ const countUsing = (phaseSetName) => sorted.filter((d) => phaseSetsOf(d).includes(phaseSetName)).length;
90
102
  const authorPhaseSets = orderPhaseSets(usedPhaseSets.filter((name) => AUTHOR_PHASE_SETS.includes(name)));
91
103
  const catalogScope = { catalogs: input.catalogs.map((catalog) => catalog.id) };
92
104
  const artifactName = input.catalogs.length === 1 ? artifactNameFromCatalogTitle(input.catalogs[0].title) : undefined;
@@ -94,7 +106,7 @@ export function buildStrategyDocument(input) {
94
106
  const dedupLocalIds = sorted
95
107
  .filter((d) => d.approach === "cross-deliverable-dedup")
96
108
  .map((d) => d.local_id);
97
- const authorPassDeliverables = sorted.filter((d) => phaseSetsOf(d.approach).some((name) => AUTHOR_PHASE_SETS.includes(name))).length;
109
+ const authorPassDeliverables = sorted.filter((d) => phaseSetsOf(d).some((name) => AUTHOR_PHASE_SETS.includes(name))).length;
98
110
  const firstPassGateId = `G-${trackUpper}-first-pass`;
99
111
  const gates = [];
100
112
  const needsFirstPassGate = authorPhaseSets.length > 0 && (authorPassDeliverables >= 2 || dedupLocalIds.length >= 2);
@@ -1,11 +1,10 @@
1
1
  import { existsSync } from "node:fs";
2
- import { basename, join, relative, resolve } from "node:path";
2
+ import { relative, resolve } from "node:path";
3
3
  import { collectResolvedDeliverables } from "../catalog/build.js";
4
4
  import { resolveBasePath } from "../catalog/paths.js";
5
5
  import { collectCatalogFilesByDomain } from "../shared/catalog-files.js";
6
6
  import { readYaml } from "../shared/fs.js";
7
- import { loadTimelineIndex } from "../shared/timeline-index.js";
8
- import { resolveTimelineCatalogStatus } from "../register/catalog-status.js";
7
+ import { resolveTrackDomains } from "../register/track-domains.js";
9
8
  export function isRecord(value) {
10
9
  return typeof value === "object" && value !== null && !Array.isArray(value);
11
10
  }
@@ -20,10 +19,10 @@ export function artifactNameFromCatalogTitle(title) {
20
19
  return match ? match[1] : undefined;
21
20
  }
22
21
  // Resolves the catalogs a track covers. An existing strategy is authoritative (a human may have
23
- // narrowed the scope on purpose); otherwise the Timeline track plan decides which domains belong
22
+ // narrowed the scope on purpose); otherwise epic domains, then the legacy track plan decide what belongs
24
23
  // to the track, and every catalog file of those domains (including physical splits) is included.
25
24
  export function resolveTrackScopeCatalogs(opts) {
26
- const { repoRoot, catalogPath, timelinePath, track } = opts;
25
+ const { repoRoot, catalogPath, track } = opts;
27
26
  const warnings = [];
28
27
  const errors = [];
29
28
  const byDomain = collectCatalogFilesByDomain(catalogPath);
@@ -41,44 +40,24 @@ export function resolveTrackScopeCatalogs(opts) {
41
40
  ...(doc.title ? { title: doc.title } : {}),
42
41
  };
43
42
  };
43
+ const resolved = resolveTrackDomains(opts);
44
+ errors.push(...resolved.errors);
44
45
  const timelineCatalogs = [];
45
- const indexFile = join(timelinePath, "tml-index.yaml");
46
- if (existsSync(indexFile)) {
47
- const { index, errors: loadErrors } = loadTimelineIndex(indexFile);
48
- const derived = resolveTimelineCatalogStatus(index.tracks, opts.registerPath);
49
- index.tracks = derived.tracks;
50
- warnings.push(...derived.warnings);
51
- if (loadErrors.length > 0) {
52
- warnings.push(`${basename(indexFile)}: ${loadErrors.join(" / ")}`);
53
- }
54
- const plan = index.tracks.find((entry) => entry.track === track);
55
- if (plan) {
56
- for (const domain of plan.domains) {
57
- const files = byDomain.get(domain) ?? [];
58
- if (files.length === 0) {
59
- warnings.push(`timeline: track '${track}' の domain '${domain}' に対応する dct-*.yaml が無い(scope から除外)。`);
60
- continue;
61
- }
62
- for (const filePath of files) {
63
- const ref = refFor(filePath);
64
- if (ref)
65
- timelineCatalogs.push(ref);
66
- }
67
- }
68
- if (plan.catalog_status !== "primary") {
69
- warnings.push(`timeline: track '${track}' の catalog_status は '${plan.catalog_status}'。` +
70
- `カタログ作成 todo の完了を確認して timeline build を実行する。todo がない domain は手書きの計画値を使う。`);
71
- }
72
- }
73
- else {
74
- warnings.push(`timeline: track '${track}' が tml-index.yaml に無い。`);
46
+ for (const domain of resolved.source === "strategy" ? [] : resolved.domains) {
47
+ const files = byDomain.get(domain) ?? [];
48
+ if (files.length === 0)
49
+ warnings.push(`${resolved.source}: track '${track}' の domain '${domain}' に対応する dct-*.yaml が無い(scope から除外)。`);
50
+ for (const filePath of files) {
51
+ const ref = refFor(filePath);
52
+ if (ref)
53
+ timelineCatalogs.push(ref);
75
54
  }
76
55
  }
77
56
  const existingScope = isRecord(opts.existingStrategy?.scope)
78
57
  ? opts.existingStrategy.scope
79
58
  : undefined;
80
59
  const existingCatalogs = Array.isArray(existingScope?.catalogs) ? existingScope.catalogs : [];
81
- if (existingCatalogs.length > 0) {
60
+ if (Array.isArray(existingScope?.catalogs)) {
82
61
  const catalogs = [];
83
62
  for (const entry of existingCatalogs) {
84
63
  if (!isRecord(entry) || typeof entry.path !== "string")
@@ -103,20 +82,13 @@ export function resolveTrackScopeCatalogs(opts) {
103
82
  if (ref)
104
83
  catalogs.push(ref);
105
84
  }
106
- const known = new Set(catalogs.map((catalog) => catalog.id));
107
- for (const catalog of timelineCatalogs) {
108
- if (known.has(catalog.id))
109
- continue;
110
- warnings.push(`timeline の domain から解決した ${catalog.id} が既存 scope に無い。scope を広げる場合は ` +
111
- `sch-strategy-${track}.yaml の scope.catalogs を先に更新する。`);
112
- }
113
85
  return { catalogs, source: "strategy", warnings, errors };
114
86
  }
115
87
  if (timelineCatalogs.length === 0) {
116
- errors.push(`track '${track}' の scope を解決できない。tml-index.yaml の domains と ` +
88
+ errors.push(`track '${track}' の scope を解決できない。epic の domains と ` +
117
89
  `dct-<domain>.yaml を用意するか、既存 strategy の scope.catalogs を先に定義する。`);
118
90
  }
119
- return { catalogs: timelineCatalogs, source: "timeline", warnings, errors };
91
+ return { catalogs: timelineCatalogs, source: resolved.source, warnings, errors };
120
92
  }
121
93
  // Deliverables of the scoped catalogs, in catalog order. `include_kinds` mirrors the strategy
122
94
  // scope (work by default).