specdojo 0.1.0 → 0.2.1

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 (540) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +142 -35
  3. package/dist/agent-response.js +27 -0
  4. package/dist/agent.js +124 -0
  5. package/dist/build-command.js +149 -0
  6. package/dist/build-if-stale.js +35 -0
  7. package/dist/catalog-build.js +1079 -0
  8. package/dist/catalog-generate.js +226 -0
  9. package/dist/catalog-paths.js +31 -0
  10. package/dist/catalog-plan-generate.js +301 -0
  11. package/dist/catalog-plan-prompt.js +73 -0
  12. package/dist/catalog-plan.js +471 -0
  13. package/dist/catalog-scaffold.js +255 -0
  14. package/dist/catalog-types.js +4 -0
  15. package/dist/catalog.js +606 -0
  16. package/dist/dashboard.js +990 -0
  17. package/dist/deliverable-trash.js +148 -0
  18. package/dist/deliverable.js +97 -0
  19. package/dist/dist-freshness.js +150 -0
  20. package/dist/doc-index.js +424 -0
  21. package/dist/exec-agent-config.js +172 -0
  22. package/dist/exec-agent-git-state.js +136 -0
  23. package/dist/exec-agent-protected-config.js +276 -0
  24. package/dist/exec-events.js +250 -112
  25. package/dist/exec-evidence.js +317 -0
  26. package/dist/exec-format.js +54 -0
  27. package/dist/exec-limit.js +202 -0
  28. package/dist/exec-parent-validation.js +169 -0
  29. package/dist/exec-pipeline-state.js +160 -0
  30. package/dist/exec-plans.js +1016 -0
  31. package/dist/exec-project.js +25 -11
  32. package/dist/exec-protection-handoff.js +169 -0
  33. package/dist/exec-provider-scaffold.js +99 -0
  34. package/dist/exec-register-resume.js +196 -0
  35. package/dist/exec-register.js +281 -0
  36. package/dist/exec-reporter.js +329 -0
  37. package/dist/exec-results.js +510 -0
  38. package/dist/exec-run-lock.js +149 -0
  39. package/dist/exec-run.js +4953 -0
  40. package/dist/exec-schedule-calendar.js +86 -9
  41. package/dist/exec-schedule-cpm.js +30 -12
  42. package/dist/exec-schedule-gantt-chart-render.js +428 -0
  43. package/dist/exec-schedule-gantt-chart-scope.js +111 -0
  44. package/dist/exec-schedule-gantt-chart.js +2 -0
  45. package/dist/exec-schedule-hash.js +34 -25
  46. package/dist/exec-schedule-index.js +200 -67
  47. package/dist/exec-schedule-initial.js +100 -0
  48. package/dist/exec-schedule-progress.js +51 -26
  49. package/dist/exec-schedule-ready.js +71 -27
  50. package/dist/exec-schedule.js +171 -93
  51. package/dist/exec-shared.js +146 -25
  52. package/dist/exec-strategy.js +547 -0
  53. package/dist/exec-task-view.js +64 -0
  54. package/dist/exec-trial.js +895 -0
  55. package/dist/exec-worktree-command.js +426 -0
  56. package/dist/exec-worktree-ops.js +847 -0
  57. package/dist/exec-worktree.js +359 -0
  58. package/dist/exec.js +744 -192
  59. package/dist/frontmatter-namespace.js +48 -0
  60. package/dist/git-environment.js +23 -0
  61. package/dist/grade-result.js +137 -0
  62. package/dist/grade.js +2456 -0
  63. package/dist/index-command.js +103 -0
  64. package/dist/job.js +1081 -0
  65. package/dist/kata-command.js +303 -0
  66. package/dist/kata.js +187 -0
  67. package/dist/package-paths.js +33 -0
  68. package/dist/practice-id.js +24 -0
  69. package/dist/register-date.js +122 -0
  70. package/dist/register-events.js +363 -0
  71. package/dist/register-history.js +323 -0
  72. package/dist/register-item.js +455 -0
  73. package/dist/register-migrate-timestamps.js +176 -0
  74. package/dist/register.js +2199 -0
  75. package/dist/review-plan.js +199 -0
  76. package/dist/review-types.js +1 -0
  77. package/dist/role-types.js +1 -0
  78. package/dist/routine.js +814 -0
  79. package/dist/schedule-approach.js +252 -0
  80. package/dist/schedule-build.js +552 -0
  81. package/dist/schedule-phase-sets.js +73 -0
  82. package/dist/schedule-strategy-generate.js +812 -0
  83. package/dist/schedule-strategy-profiles.js +276 -0
  84. package/dist/schedule.js +420 -0
  85. package/dist/spawn-self.js +28 -0
  86. package/dist/specdojo-config.js +133 -39
  87. package/dist/specdojo.js +56 -7
  88. package/dist/template-frontmatter.js +89 -0
  89. package/dist/template-resolution.js +92 -0
  90. package/dist/timeline-build.js +334 -0
  91. package/dist/timeline.js +107 -0
  92. package/dist/watch.js +313 -0
  93. package/dist/yaml-pages-command.js +28 -0
  94. package/dist/yaml-pages.js +180 -0
  95. package/dist/yaml-schema-modeline.js +49 -0
  96. package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +600 -0
  97. package/docs/ja/specdojo/exec-templates/xep-bootstrap-template.md +120 -0
  98. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +37 -0
  99. package/docs/ja/specdojo/exec-templates/xep-cross-deliverable-dedup-template.md +51 -0
  100. package/docs/ja/specdojo/exec-templates/xep-freeform-template.md +74 -0
  101. package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +109 -0
  102. package/docs/ja/specdojo/exec-templates/xep-job-template.md +43 -0
  103. package/docs/ja/specdojo/exec-templates/xep-recipe-guided-template.md +82 -0
  104. package/docs/ja/specdojo/exec-templates/xep-recipe-maintenance-template.md +86 -0
  105. package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +42 -0
  106. package/docs/ja/specdojo/exec-templates/xep-register-template.md +49 -0
  107. package/docs/ja/specdojo/exec-templates/xep-retrofit-template.md +98 -0
  108. package/docs/ja/specdojo/exec-templates/xep-rulebook-maintenance-template.md +86 -0
  109. package/docs/ja/specdojo/exec-templates/xep-sample-maintenance-template.md +86 -0
  110. package/docs/ja/specdojo/exec-templates/xep-template-maintenance-template.md +86 -0
  111. package/docs/ja/specdojo/exec-templates/xep-template.md +66 -0
  112. package/docs/ja/specdojo/exec-templates/xer-cross-deliverable-dedup-template.md +31 -0
  113. package/docs/ja/specdojo/exec-templates/xer-human-bootstrap-finalize-template.md +40 -0
  114. package/docs/ja/specdojo/exec-templates/xer-human-finalize-template.md +30 -0
  115. package/docs/ja/specdojo/exec-templates/xer-template.md +19 -0
  116. package/docs/ja/specdojo/exec-templates/xrp-freeform-template.md +70 -0
  117. package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +97 -0
  118. package/docs/ja/specdojo/exec-templates/xrp-recipe-guided-template.md +76 -0
  119. package/docs/ja/specdojo/exec-templates/xrp-recipe-maintenance-template.md +73 -0
  120. package/docs/ja/specdojo/exec-templates/xrp-retrofit-template.md +74 -0
  121. package/docs/ja/specdojo/exec-templates/xrp-rulebook-maintenance-template.md +74 -0
  122. package/docs/ja/specdojo/exec-templates/xrp-sample-maintenance-template.md +73 -0
  123. package/docs/ja/specdojo/exec-templates/xrp-template-maintenance-template.md +73 -0
  124. package/docs/ja/specdojo/exec-templates/xrp-template.md +67 -0
  125. package/docs/ja/specdojo/exec-templates/xrp-viewpoint-detail-template.md +7 -0
  126. package/docs/ja/specdojo/exec-templates/xrr-template.md +21 -0
  127. package/docs/ja/specdojo/exec-templates/xrr-viewpoint-detail-template.md +7 -0
  128. package/docs/ja/specdojo/guides/branch-workflow-guide.md +354 -0
  129. package/docs/ja/specdojo/guides/docs-editing-guide.md +327 -0
  130. package/docs/ja/specdojo/guides/docs-structure-guide.md +519 -0
  131. package/docs/ja/specdojo/guides/exec-config-guide.md +589 -0
  132. package/docs/ja/specdojo/guides/exec-operation-guide.md +440 -0
  133. package/docs/ja/specdojo/guides/exec-worktree-guide.md +318 -0
  134. package/docs/ja/specdojo/guides/kata-guide.md +89 -0
  135. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +127 -0
  136. package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +228 -0
  137. package/docs/ja/specdojo/guides/practice-system-composition-guide.md +111 -0
  138. package/docs/ja/specdojo/guides/quick-start-guide.md +472 -0
  139. package/docs/ja/specdojo/guides/register-operation-guide.md +418 -0
  140. package/docs/ja/specdojo/guides/remote-host-development-guide.md +163 -0
  141. package/docs/ja/specdojo/guides/review-guide.md +428 -0
  142. package/docs/ja/specdojo/guides/routine-operation-guide.md +282 -0
  143. package/docs/ja/specdojo/guides/ryu-guide.md +230 -0
  144. package/docs/ja/specdojo/guides/schedule-design-guide.md +429 -0
  145. package/docs/ja/specdojo/guides/schedule-operation-guide.md +151 -0
  146. package/docs/ja/specdojo/guides/specdojo-overview-guide.md +257 -0
  147. package/docs/ja/specdojo/guides/timeline-design-guide.md +160 -0
  148. package/docs/ja/specdojo/guides/track-design-guide.md +215 -0
  149. package/docs/ja/specdojo/guides/use-case-guide.md +133 -0
  150. package/docs/ja/specdojo/guides/waza-guide.md +224 -0
  151. package/docs/ja/specdojo/index.md +33 -0
  152. package/docs/ja/specdojo/philosophy/needs-to-implementation-philosophy.md +212 -0
  153. package/docs/ja/specdojo/philosophy/specdojo-philosophy.md +242 -0
  154. package/docs/ja/specdojo/recipes/cdfd-overview-recipe.md +198 -0
  155. package/docs/ja/specdojo/recipes/cdfd-recipe.md +218 -0
  156. package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +198 -0
  157. package/docs/ja/specdojo/recipes/exec-human-finalize-recipe.md +100 -0
  158. package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +148 -0
  159. package/docs/ja/specdojo/recipes/pm-communication-plan-recipe.md +97 -0
  160. package/docs/ja/specdojo/recipes/pm-members-recipe.md +149 -0
  161. package/docs/ja/specdojo/recipes/pm-organization-recipe.md +96 -0
  162. package/docs/ja/specdojo/recipes/pm-plan-recipe.md +98 -0
  163. package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +97 -0
  164. package/docs/ja/specdojo/recipes/pm-raci-recipe.md +96 -0
  165. package/docs/ja/specdojo/recipes/pm-roles-recipe.md +136 -0
  166. package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +162 -0
  167. package/docs/ja/specdojo/recipes/prj-charter-recipe.md +187 -0
  168. package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +235 -0
  169. package/docs/ja/specdojo/recipes/prj-issues-and-approach-recipe.md +205 -0
  170. package/docs/ja/specdojo/recipes/prj-overview-recipe.md +289 -0
  171. package/docs/ja/specdojo/recipes/prj-scope-recipe.md +201 -0
  172. package/docs/ja/specdojo/recipes/prj-stakeholder-register-recipe.md +168 -0
  173. package/docs/ja/specdojo/recipes/prj-success-criteria-and-acceptance-criteria-recipe.md +179 -0
  174. package/docs/ja/specdojo/recipes/stsd-recipe.md +138 -0
  175. package/docs/ja/specdojo/references/command-reference.md +718 -0
  176. package/docs/ja/specdojo/references/deliverables-reference.md +407 -0
  177. package/docs/ja/specdojo/references/directory-layout-reference.md +280 -0
  178. package/docs/ja/specdojo/references/specdojo-config-reference.md +133 -0
  179. package/docs/ja/specdojo/rulebooks/atc-index-rulebook.md +372 -0
  180. package/docs/ja/specdojo/rulebooks/atc-rulebook.md +302 -0
  181. package/docs/ja/specdojo/rulebooks/bac-rulebook.md +331 -0
  182. package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +134 -0
  183. package/docs/ja/specdojo/rulebooks/bds-rulebook.md +207 -0
  184. package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +102 -0
  185. package/docs/ja/specdojo/rulebooks/bes-rulebook.md +131 -0
  186. package/docs/ja/specdojo/rulebooks/bps-rulebook.md +269 -0
  187. package/docs/ja/specdojo/rulebooks/br-rulebook.md +187 -0
  188. package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +279 -0
  189. package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +219 -0
  190. package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +233 -0
  191. package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +182 -0
  192. package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +171 -0
  193. package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +105 -0
  194. package/docs/ja/specdojo/rulebooks/cld-rulebook.md +195 -0
  195. package/docs/ja/specdojo/rulebooks/cnd-mermaid-rulebook.md +285 -0
  196. package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +292 -0
  197. package/docs/ja/specdojo/rulebooks/cop-index-rulebook.md +171 -0
  198. package/docs/ja/specdojo/rulebooks/cop-rulebook.md +325 -0
  199. package/docs/ja/specdojo/rulebooks/cpd-mermaid-rulebook.md +266 -0
  200. package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +294 -0
  201. package/docs/ja/specdojo/rulebooks/cstd-rulebook.md +21 -0
  202. package/docs/ja/specdojo/rulebooks/cxd-mermaid-rulebook.md +401 -0
  203. package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +311 -0
  204. package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +158 -0
  205. package/docs/ja/specdojo/rulebooks/dct-rulebook.md +287 -0
  206. package/docs/ja/specdojo/rulebooks/dec-rulebook.md +62 -0
  207. package/docs/ja/specdojo/rulebooks/dmd-index-rulebook.md +100 -0
  208. package/docs/ja/specdojo/rulebooks/dmd-rulebook.md +298 -0
  209. package/docs/ja/specdojo/rulebooks/etc-index-rulebook.md +379 -0
  210. package/docs/ja/specdojo/rulebooks/etc-rulebook.md +310 -0
  211. package/docs/ja/specdojo/rulebooks/gl-rulebook.md +86 -0
  212. package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +297 -0
  213. package/docs/ja/specdojo/rulebooks/ifx-api-rulebook.md +79 -0
  214. package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +213 -0
  215. package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +311 -0
  216. package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +94 -0
  217. package/docs/ja/specdojo/rulebooks/ifx-msg-rulebook.md +81 -0
  218. package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +117 -0
  219. package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +118 -0
  220. package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +116 -0
  221. package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +116 -0
  222. package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +116 -0
  223. package/docs/ja/specdojo/rulebooks/itc-index-rulebook.md +421 -0
  224. package/docs/ja/specdojo/rulebooks/itc-rulebook.md +307 -0
  225. package/docs/ja/specdojo/rulebooks/mip-index-rulebook.md +312 -0
  226. package/docs/ja/specdojo/rulebooks/mm-rulebook.md +63 -0
  227. package/docs/ja/specdojo/rulebooks/mtp-rulebook.md +353 -0
  228. package/docs/ja/specdojo/rulebooks/nfr-availability-rulebook.md +184 -0
  229. package/docs/ja/specdojo/rulebooks/nfr-index-rulebook.md +179 -0
  230. package/docs/ja/specdojo/rulebooks/nfr-integrity-rulebook.md +184 -0
  231. package/docs/ja/specdojo/rulebooks/nfr-maintainability-rulebook.md +183 -0
  232. package/docs/ja/specdojo/rulebooks/nfr-operations-rulebook.md +185 -0
  233. package/docs/ja/specdojo/rulebooks/nfr-performance-rulebook.md +185 -0
  234. package/docs/ja/specdojo/rulebooks/nfr-reliability-rulebook.md +186 -0
  235. package/docs/ja/specdojo/rulebooks/nfr-security-safety-rulebook.md +186 -0
  236. package/docs/ja/specdojo/rulebooks/nfr-usability-rulebook.md +184 -0
  237. package/docs/ja/specdojo/rulebooks/ntp-rulebook.md +61 -0
  238. package/docs/ja/specdojo/rulebooks/opd-index-rulebook.md +84 -0
  239. package/docs/ja/specdojo/rulebooks/opd-rulebook.md +357 -0
  240. package/docs/ja/specdojo/rulebooks/opr-index-rulebook.md +80 -0
  241. package/docs/ja/specdojo/rulebooks/opr-rulebook.md +484 -0
  242. package/docs/ja/specdojo/rulebooks/otp-index-rulebook.md +120 -0
  243. package/docs/ja/specdojo/rulebooks/otp-rulebook.md +293 -0
  244. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +211 -0
  245. package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +94 -0
  246. package/docs/ja/specdojo/rulebooks/pm-communication-plan-rulebook.md +116 -0
  247. package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +93 -0
  248. package/docs/ja/specdojo/rulebooks/pm-members-rulebook.md +190 -0
  249. package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +108 -0
  250. package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +122 -0
  251. package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +117 -0
  252. package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +116 -0
  253. package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +93 -0
  254. package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +146 -0
  255. package/docs/ja/specdojo/rulebooks/pr-rulebook.md +65 -0
  256. package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +178 -0
  257. package/docs/ja/specdojo/rulebooks/prj-charter-rulebook.md +232 -0
  258. package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +235 -0
  259. package/docs/ja/specdojo/rulebooks/prj-issues-and-approach-rulebook.md +242 -0
  260. package/docs/ja/specdojo/rulebooks/prj-overview-rulebook.md +187 -0
  261. package/docs/ja/specdojo/rulebooks/prj-scope-rulebook.md +201 -0
  262. package/docs/ja/specdojo/rulebooks/prj-stakeholder-register-rulebook.md +165 -0
  263. package/docs/ja/specdojo/rulebooks/prj-success-criteria-and-acceptance-criteria-rulebook.md +165 -0
  264. package/docs/ja/specdojo/rulebooks/sac-rulebook.md +202 -0
  265. package/docs/ja/specdojo/rulebooks/sch-rulebook.md +139 -0
  266. package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +63 -0
  267. package/docs/ja/specdojo/rulebooks/sf-rulebook.md +93 -0
  268. package/docs/ja/specdojo/rulebooks/sld-rulebook.md +93 -0
  269. package/docs/ja/specdojo/rulebooks/stc-index-rulebook.md +329 -0
  270. package/docs/ja/specdojo/rulebooks/stc-rulebook.md +297 -0
  271. package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +132 -0
  272. package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +215 -0
  273. package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +376 -0
  274. package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +313 -0
  275. package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +246 -0
  276. package/docs/ja/specdojo/rulebooks/sysd-rulebook.md +119 -0
  277. package/docs/ja/specdojo/rulebooks/tml-rulebook.md +188 -0
  278. package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +114 -0
  279. package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +117 -0
  280. package/docs/ja/specdojo/rulebooks/tsd-index-rulebook.md +101 -0
  281. package/docs/ja/specdojo/rulebooks/tsd-rulebook.md +103 -0
  282. package/docs/ja/specdojo/rulebooks/tsp-index-rulebook.md +396 -0
  283. package/docs/ja/specdojo/rulebooks/uis-rulebook.md +207 -0
  284. package/docs/ja/specdojo/rulebooks/utc-index-rulebook.md +387 -0
  285. package/docs/ja/specdojo/rulebooks/utc-rulebook.md +303 -0
  286. package/docs/ja/specdojo/samples/atc-index-sample.md +38 -0
  287. package/docs/ja/specdojo/samples/atc-sample.md +41 -0
  288. package/docs/ja/specdojo/samples/bac-sample.md +38 -0
  289. package/docs/ja/specdojo/samples/bdd-sample.yaml +71 -0
  290. package/docs/ja/specdojo/samples/bds-sample.md +38 -0
  291. package/docs/ja/specdojo/samples/bes-index-sample.md +38 -0
  292. package/docs/ja/specdojo/samples/bes-sample.md +38 -0
  293. package/docs/ja/specdojo/samples/bps-sample.md +38 -0
  294. package/docs/ja/specdojo/samples/br-sample.md +40 -0
  295. package/docs/ja/specdojo/samples/ccd-sample.md +38 -0
  296. package/docs/ja/specdojo/samples/cdfd-overview-sample.md +284 -0
  297. package/docs/ja/specdojo/samples/cdfd-sample.md +229 -0
  298. package/docs/ja/specdojo/samples/cdfd-uc-sample.md +146 -0
  299. package/docs/ja/specdojo/samples/cdsd-sample.md +38 -0
  300. package/docs/ja/specdojo/samples/cld-sample.md +38 -0
  301. package/docs/ja/specdojo/samples/cnd-sample.md +38 -0
  302. package/docs/ja/specdojo/samples/cop-index-sample.md +38 -0
  303. package/docs/ja/specdojo/samples/cop-sample.md +38 -0
  304. package/docs/ja/specdojo/samples/cpd-sample.md +38 -0
  305. package/docs/ja/specdojo/samples/cstd-sample.md +11 -0
  306. package/docs/ja/specdojo/samples/cxd-sample.md +38 -0
  307. package/docs/ja/specdojo/samples/dct-index-sample.yaml +39 -0
  308. package/docs/ja/specdojo/samples/dct-sample.yaml +91 -0
  309. package/docs/ja/specdojo/samples/dec-sample.md +39 -0
  310. package/docs/ja/specdojo/samples/dmd-index-sample.md +50 -0
  311. package/docs/ja/specdojo/samples/dmd-sample.md +74 -0
  312. package/docs/ja/specdojo/samples/etc-index-sample.md +38 -0
  313. package/docs/ja/specdojo/samples/etc-sample.md +38 -0
  314. package/docs/ja/specdojo/samples/gl-sample.yaml +37 -0
  315. package/docs/ja/specdojo/samples/ifd-sample.md +38 -0
  316. package/docs/ja/specdojo/samples/ifx-api-sample.yaml +102 -0
  317. package/docs/ja/specdojo/samples/ifx-cmd-sample.yaml +107 -0
  318. package/docs/ja/specdojo/samples/ifx-file-sample.md +38 -0
  319. package/docs/ja/specdojo/samples/ifx-msg-sample.yaml +89 -0
  320. package/docs/ja/specdojo/samples/imp-business-sample.md +66 -0
  321. package/docs/ja/specdojo/samples/imp-data-sample.md +60 -0
  322. package/docs/ja/specdojo/samples/imp-interface-sample.md +60 -0
  323. package/docs/ja/specdojo/samples/imp-operations-sample.md +60 -0
  324. package/docs/ja/specdojo/samples/imp-test-sample.md +60 -0
  325. package/docs/ja/specdojo/samples/itc-index-sample.md +38 -0
  326. package/docs/ja/specdojo/samples/itc-sample.md +38 -0
  327. package/docs/ja/specdojo/samples/mip-index-sample.md +38 -0
  328. package/docs/ja/specdojo/samples/mm-sample.md +35 -0
  329. package/docs/ja/specdojo/samples/mtp-sample.md +38 -0
  330. package/docs/ja/specdojo/samples/nfr-availability-sample.md +38 -0
  331. package/docs/ja/specdojo/samples/nfr-index-sample.md +38 -0
  332. package/docs/ja/specdojo/samples/nfr-integrity-sample.md +38 -0
  333. package/docs/ja/specdojo/samples/nfr-maintainability-sample.md +38 -0
  334. package/docs/ja/specdojo/samples/nfr-operations-sample.md +38 -0
  335. package/docs/ja/specdojo/samples/nfr-performance-sample.md +38 -0
  336. package/docs/ja/specdojo/samples/nfr-reliability-sample.md +38 -0
  337. package/docs/ja/specdojo/samples/nfr-security-safety-sample.md +38 -0
  338. package/docs/ja/specdojo/samples/nfr-usability-sample.md +38 -0
  339. package/docs/ja/specdojo/samples/ntp-sample.md +38 -0
  340. package/docs/ja/specdojo/samples/opd-access-control-sample.md +29 -0
  341. package/docs/ja/specdojo/samples/opd-incident-management-sample.md +31 -0
  342. package/docs/ja/specdojo/samples/opd-index-sample.md +41 -0
  343. package/docs/ja/specdojo/samples/opd-monitoring-sample.md +32 -0
  344. package/docs/ja/specdojo/samples/opd-sample.md +38 -0
  345. package/docs/ja/specdojo/samples/opr-access-control-sample.md +24 -0
  346. package/docs/ja/specdojo/samples/opr-backup-restore-sample.md +27 -0
  347. package/docs/ja/specdojo/samples/opr-batch-sample.md +23 -0
  348. package/docs/ja/specdojo/samples/opr-change-sample.md +24 -0
  349. package/docs/ja/specdojo/samples/opr-incident-sample.md +38 -0
  350. package/docs/ja/specdojo/samples/opr-index-sample.md +43 -0
  351. package/docs/ja/specdojo/samples/opr-monitoring-sample.md +27 -0
  352. package/docs/ja/specdojo/samples/opr-sample.md +38 -0
  353. package/docs/ja/specdojo/samples/opr-support-sample.md +23 -0
  354. package/docs/ja/specdojo/samples/otp-index-sample.md +66 -0
  355. package/docs/ja/specdojo/samples/otp-sample.md +68 -0
  356. package/docs/ja/specdojo/samples/pm-change-request-log-sample.md +47 -0
  357. package/docs/ja/specdojo/samples/pm-communication-plan-sample.md +46 -0
  358. package/docs/ja/specdojo/samples/pm-issue-log-sample.md +45 -0
  359. package/docs/ja/specdojo/samples/pm-members-sample.yaml +103 -0
  360. package/docs/ja/specdojo/samples/pm-organization-sample.md +46 -0
  361. package/docs/ja/specdojo/samples/pm-plan-sample.md +57 -0
  362. package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +52 -0
  363. package/docs/ja/specdojo/samples/pm-raci-sample.md +57 -0
  364. package/docs/ja/specdojo/samples/pm-risk-register-sample.md +43 -0
  365. package/docs/ja/specdojo/samples/pm-roles-sample.yaml +41 -0
  366. package/docs/ja/specdojo/samples/pr-sample.md +39 -0
  367. package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +57 -0
  368. package/docs/ja/specdojo/samples/prj-charter-sample.md +121 -0
  369. package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +105 -0
  370. package/docs/ja/specdojo/samples/prj-issues-and-approach-sample.md +78 -0
  371. package/docs/ja/specdojo/samples/prj-overview-sample.md +95 -0
  372. package/docs/ja/specdojo/samples/prj-scope-sample.md +71 -0
  373. package/docs/ja/specdojo/samples/prj-stakeholder-register-sample.md +60 -0
  374. package/docs/ja/specdojo/samples/prj-success-criteria-and-acceptance-criteria-sample.md +62 -0
  375. package/docs/ja/specdojo/samples/sac-sample.md +38 -0
  376. package/docs/ja/specdojo/samples/sf-index-sample.md +38 -0
  377. package/docs/ja/specdojo/samples/sf-sample.md +38 -0
  378. package/docs/ja/specdojo/samples/sld-sample.md +38 -0
  379. package/docs/ja/specdojo/samples/stc-index-sample.md +38 -0
  380. package/docs/ja/specdojo/samples/stc-sample.md +38 -0
  381. package/docs/ja/specdojo/samples/stsd-sample.md +58 -0
  382. package/docs/ja/specdojo/samples/sysd-critical-flows-sample.md +38 -0
  383. package/docs/ja/specdojo/samples/sysd-cross-cutting-policy-sample.md +38 -0
  384. package/docs/ja/specdojo/samples/sysd-index-sample.md +38 -0
  385. package/docs/ja/specdojo/samples/trc-requirements-to-specs-sample.md +56 -0
  386. package/docs/ja/specdojo/samples/trc-requirements-to-tests-sample.md +56 -0
  387. package/docs/ja/specdojo/samples/tsd-index-sample.md +29 -0
  388. package/docs/ja/specdojo/samples/tsd-sample.md +38 -0
  389. package/docs/ja/specdojo/samples/tsp-index-sample.md +38 -0
  390. package/docs/ja/specdojo/samples/uis-sample.md +38 -0
  391. package/docs/ja/specdojo/samples/utc-index-sample.md +38 -0
  392. package/docs/ja/specdojo/samples/utc-sample.md +38 -0
  393. package/docs/ja/specdojo/schemas/v1/guide-content.schema.yaml +20 -0
  394. package/docs/ja/specdojo/schemas/v1/philosophy-content.schema.yaml +21 -0
  395. package/docs/ja/specdojo/schemas/v1/reference-content.schema.yaml +21 -0
  396. package/docs/ja/specdojo/standards/document-metadata-standard.md +323 -0
  397. package/docs/ja/specdojo/standards/exec-human-finalize-standard.md +75 -0
  398. package/docs/ja/specdojo/standards/git-branching-standard.md +227 -0
  399. package/docs/ja/specdojo/standards/guide-authoring-standard.md +124 -0
  400. package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +929 -0
  401. package/docs/ja/specdojo/standards/job-definition-standard.md +148 -0
  402. package/docs/ja/specdojo/standards/people-and-organization-definition-standard.md +431 -0
  403. package/docs/ja/specdojo/standards/philosophy-authoring-standard.md +113 -0
  404. package/docs/ja/specdojo/standards/recipe-authoring-standard.md +143 -0
  405. package/docs/ja/specdojo/standards/reference-authoring-standard.md +99 -0
  406. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +140 -0
  407. package/docs/ja/specdojo/standards/sample-authoring-standard.md +151 -0
  408. package/docs/ja/specdojo/standards/standard-authoring-standard.md +108 -0
  409. package/docs/ja/specdojo/standards/template-authoring-standard.md +101 -0
  410. package/docs/ja/specdojo/standards/test-document-scope-standard.md +176 -0
  411. package/docs/ja/specdojo/templates/cdfd-overview-template.md +199 -0
  412. package/docs/ja/specdojo/templates/cdfd-template.md +173 -0
  413. package/docs/ja/specdojo/templates/cdfd-uc-template.md +148 -0
  414. package/docs/ja/specdojo/templates/dct-architecture-template.yaml +136 -0
  415. package/docs/ja/specdojo/templates/dct-business-acceptance-criteria-template.yaml +34 -0
  416. package/docs/ja/specdojo/templates/dct-business-model-bes-template.yaml +75 -0
  417. package/docs/ja/specdojo/templates/dct-business-model-bps-template.yaml +49 -0
  418. package/docs/ja/specdojo/templates/dct-business-model-br-template.yaml +50 -0
  419. package/docs/ja/specdojo/templates/dct-data-flow-template.yaml +40 -0
  420. package/docs/ja/specdojo/templates/dct-data-model-bdd-template.yaml +46 -0
  421. package/docs/ja/specdojo/templates/dct-data-model-ccd-template.yaml +46 -0
  422. package/docs/ja/specdojo/templates/dct-data-model-cdsd-template.yaml +41 -0
  423. package/docs/ja/specdojo/templates/dct-data-model-cld-template.yaml +38 -0
  424. package/docs/ja/specdojo/templates/dct-data-model-sld-template.yaml +38 -0
  425. package/docs/ja/specdojo/templates/dct-data-model-stsd-template.yaml +46 -0
  426. package/docs/ja/specdojo/templates/dct-external-interface-specs-template.yaml +114 -0
  427. package/docs/ja/specdojo/templates/dct-glossary-template.yaml +35 -0
  428. package/docs/ja/specdojo/templates/dct-impact-analysis-template.yaml +138 -0
  429. package/docs/ja/specdojo/templates/dct-index-template.md +40 -0
  430. package/docs/ja/specdojo/templates/dct-migration-planning-template.yaml +148 -0
  431. package/docs/ja/specdojo/templates/dct-non-functional-requirements-template.yaml +222 -0
  432. package/docs/ja/specdojo/templates/dct-operations-template.yaml +108 -0
  433. package/docs/ja/specdojo/templates/dct-project-definition-template.yaml +210 -0
  434. package/docs/ja/specdojo/templates/dct-project-management-template.yaml +423 -0
  435. package/docs/ja/specdojo/templates/dct-system-acceptance-criteria-template.yaml +37 -0
  436. package/docs/ja/specdojo/templates/dct-system-design-template.yaml +82 -0
  437. package/docs/ja/specdojo/templates/dct-system-functions-template.yaml +58 -0
  438. package/docs/ja/specdojo/templates/dct-test-specs-template.yaml +261 -0
  439. package/docs/ja/specdojo/templates/dct-user-interface-model-template.yaml +60 -0
  440. package/docs/ja/specdojo/templates/ifx-cmd-template.yaml +88 -0
  441. package/docs/ja/specdojo/templates/opr-template.md +85 -0
  442. package/docs/ja/specdojo/templates/pjr-change-request-template.md +60 -0
  443. package/docs/ja/specdojo/templates/pjr-decision-template.md +61 -0
  444. package/docs/ja/specdojo/templates/pjr-index-template.md +49 -0
  445. package/docs/ja/specdojo/templates/pjr-issue-template.md +50 -0
  446. package/docs/ja/specdojo/templates/pjr-note-template.md +35 -0
  447. package/docs/ja/specdojo/templates/pjr-question-template.md +53 -0
  448. package/docs/ja/specdojo/templates/pjr-risk-template.md +49 -0
  449. package/docs/ja/specdojo/templates/pjr-todo-template.md +41 -0
  450. package/docs/ja/specdojo/templates/pjr-views-by-owner-template.md +22 -0
  451. package/docs/ja/specdojo/templates/pjr-views-by-priority-template.md +22 -0
  452. package/docs/ja/specdojo/templates/pjr-views-by-status-template.md +22 -0
  453. package/docs/ja/specdojo/templates/pm-change-request-log-template.md +20 -0
  454. package/docs/ja/specdojo/templates/pm-communication-plan-template.md +46 -0
  455. package/docs/ja/specdojo/templates/pm-decision-log-template.md +20 -0
  456. package/docs/ja/specdojo/templates/pm-issue-log-template.md +20 -0
  457. package/docs/ja/specdojo/templates/pm-members-template.yaml +105 -0
  458. package/docs/ja/specdojo/templates/pm-organization-template.md +44 -0
  459. package/docs/ja/specdojo/templates/pm-plan-template.md +52 -0
  460. package/docs/ja/specdojo/templates/pm-quality-management-plan-template.md +46 -0
  461. package/docs/ja/specdojo/templates/pm-raci-template.md +51 -0
  462. package/docs/ja/specdojo/templates/pm-risk-register-template.md +20 -0
  463. package/docs/ja/specdojo/templates/pm-roles-template.yaml +53 -0
  464. package/docs/ja/specdojo/templates/prj-assumptions-constraints-dependencies-template.md +59 -0
  465. package/docs/ja/specdojo/templates/prj-charter-template.md +116 -0
  466. package/docs/ja/specdojo/templates/prj-comparison-of-alternatives-template.md +116 -0
  467. package/docs/ja/specdojo/templates/prj-issues-and-approach-template.md +89 -0
  468. package/docs/ja/specdojo/templates/prj-overview-template.md +85 -0
  469. package/docs/ja/specdojo/templates/prj-scope-template.md +75 -0
  470. package/docs/ja/specdojo/templates/prj-stakeholder-register-template.md +64 -0
  471. package/docs/ja/specdojo/templates/prj-success-criteria-and-acceptance-criteria-template.md +60 -0
  472. package/docs/ja/specdojo/templates/stsd-template.md +57 -0
  473. package/docs/specdojo/schemas/v1/bdd.schema.yaml +230 -0
  474. package/docs/specdojo/schemas/v1/common-frontmatter.schema.yaml +77 -0
  475. package/docs/specdojo/schemas/v1/dct-index.schema.yaml +85 -0
  476. package/docs/specdojo/schemas/v1/dct-plan.schema.yaml +324 -0
  477. package/docs/specdojo/schemas/v1/dct.schema.yaml +368 -0
  478. package/docs/specdojo/schemas/v1/deliverable-frontmatter.schema.yaml +91 -0
  479. package/docs/specdojo/schemas/v1/esil.schema.yaml +142 -0
  480. package/docs/specdojo/schemas/v1/exec-common.schema.yaml +101 -0
  481. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +272 -0
  482. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +162 -0
  483. package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +126 -0
  484. package/docs/specdojo/schemas/v1/exec-reporter-output.schema.yaml +151 -0
  485. package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +144 -0
  486. package/docs/specdojo/schemas/v1/grade-done-criteria.schema.yaml +79 -0
  487. package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +60 -0
  488. package/docs/specdojo/schemas/v1/grade-result.schema.yaml +118 -0
  489. package/docs/specdojo/schemas/v1/guide-frontmatter.schema.yaml +19 -0
  490. package/docs/specdojo/schemas/v1/ifx-cmd.schema.yaml +293 -0
  491. package/docs/specdojo/schemas/v1/job-run.schema.yaml +90 -0
  492. package/docs/specdojo/schemas/v1/job.schema.yaml +198 -0
  493. package/docs/specdojo/schemas/v1/philosophy-frontmatter.schema.yaml +19 -0
  494. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +56 -0
  495. package/docs/specdojo/schemas/v1/pm-members.schema.yaml +252 -0
  496. package/docs/specdojo/schemas/v1/pm-review-viewpoints.schema.yaml +387 -0
  497. package/docs/specdojo/schemas/v1/pm-roles.schema.yaml +106 -0
  498. package/docs/specdojo/schemas/v1/recipe-frontmatter.schema.yaml +27 -0
  499. package/docs/specdojo/schemas/v1/reference-frontmatter.schema.yaml +18 -0
  500. package/docs/specdojo/schemas/v1/register-events.schema.yaml +106 -0
  501. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +204 -0
  502. package/docs/specdojo/schemas/v1/routine-run.schema.yaml +36 -0
  503. package/docs/specdojo/schemas/v1/routine.schema.yaml +87 -0
  504. package/docs/specdojo/schemas/v1/rulebook-frontmatter.schema.yaml +61 -0
  505. package/docs/specdojo/schemas/v1/sch-common.schema.yaml +258 -0
  506. package/docs/specdojo/schemas/v1/sch-defaults.schema.yaml +48 -0
  507. package/docs/specdojo/schemas/v1/sch-milestones.schema.yaml +64 -0
  508. package/docs/specdojo/schemas/v1/sch-strategy.schema.yaml +772 -0
  509. package/docs/specdojo/schemas/v1/sch-track.schema.yaml +66 -0
  510. package/docs/specdojo/schemas/v1/standard-frontmatter.schema.yaml +18 -0
  511. package/docs/specdojo/schemas/v1/tml-index.schema.yaml +103 -0
  512. package/package.json +121 -24
  513. package/templates/antigravity/README.md +35 -0
  514. package/templates/antigravity/exec-defaults-snippet.yaml +38 -0
  515. package/templates/antigravity/orchestrator.md +146 -0
  516. package/templates/antigravity/pm-members-snippet.yaml +55 -0
  517. package/templates/claude/README.md +46 -0
  518. package/templates/claude/agents/claude-expert-review-executor.md +14 -0
  519. package/templates/claude/agents/claude-review-executor.md +14 -0
  520. package/templates/claude/agents/specdojo-orchestrator.md +153 -0
  521. package/templates/claude/settings.edit.json +6 -0
  522. package/templates/claude/settings.report.json +6 -0
  523. package/templates/claude/settings.review.json +7 -0
  524. package/templates/codex/README.md +61 -0
  525. package/templates/codex/agents/codex-executor.toml +12 -0
  526. package/templates/codex/agents/codex-expert-executor.toml +12 -0
  527. package/templates/codex/agents/codex-expert-review-executor.toml +10 -0
  528. package/templates/codex/agents/codex-review-executor.toml +10 -0
  529. package/templates/codex/agents/specdojo-orchestrator.toml +154 -0
  530. package/templates/codex/orchestrator.md +146 -0
  531. package/templates/copilot/README.md +41 -0
  532. package/templates/copilot/exec-defaults-snippet.yaml +28 -0
  533. package/templates/copilot/pm-members-snippet.yaml +44 -0
  534. package/templates/opencode/README.md +41 -0
  535. package/templates/opencode/agents/opencode-executor.md +59 -0
  536. package/templates/opencode/agents/opencode-reporter.md +26 -0
  537. package/templates/opencode/agents/opencode-review-executor.md +48 -0
  538. package/templates/opencode/agents/specdojo-orchestrator.md +193 -0
  539. package/dist/exec-schedule-timeline-render.js +0 -201
  540. package/dist/exec-schedule-timeline.js +0 -2
package/dist/exec.js CHANGED
@@ -1,37 +1,103 @@
1
- import { spawnSync } from 'node:child_process';
2
- import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync, writeFileSync } from 'node:fs';
3
- import { dirname, join, resolve } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import { acquireSchedulerLock, buildEvent, canBlockTask, canCancelTask, canClaimTask, canCompleteTask, canUnblockTask, collectRepeatable, computeReadyIds, findDoingTasksForActor, foldEventsToState, readAllEventFiles, releaseSchedulerLock, schedulerLockPath, writeEventFile, } from './exec-events.js';
6
- import { activateResolvedProjectPaths, eventsDirForProject, generatedDirForProject, resolveProjectPaths, } from './exec-project.js';
7
- import { assertValidActor, loadConfig, loadMemberRoster, } from './specdojo-config.js';
8
- import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, selectNextTask, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from './exec-schedule.js';
9
- import { nowUtcIsoSeconds, requireNonEmpty, safeSlug, tsForFilenameUtc } from './exec-shared.js';
10
- const KNOWN_OWNER_LABELS = ['PO', 'BA', 'ARC', 'QE'];
11
- const KNOWN_OWNER_LABELS_TEXT = KNOWN_OWNER_LABELS.join('|');
1
+ import { existsSync } from "node:fs";
2
+ import { join, resolve as pathResolve } from "node:path";
3
+ import { validateCatalogLocalIds, validateRulebookKata } from "./catalog-build.js";
4
+ import { acquireSchedulerLock, buildEvent, canBlockTask, canCancelTask, canClaimTask, canCompleteTask, canReopenTask, canReleaseTask, canUnblockTask, collectRepeatable, computeReadyIds, findDoingTasksForActor, foldEventsToState, readAllEventFiles, releaseSchedulerLock, schedulerLockPath, writeEventFile, } from "./exec-events.js";
5
+ import { activateResolvedProjectPaths, eventsDirForProject, generatedDirForProject, resolveProjectPaths, } from "./exec-project.js";
6
+ import { assertValidActor, getProjectViewpointsPath, loadConfig, loadMemberRoster, specdojoRootDir, } from "./specdojo-config.js";
7
+ import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, selectNextTask, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./exec-schedule.js";
8
+ import { readReadySnapshot } from "./exec-schedule-ready.js";
9
+ import { displayWidth, nowUtcIsoSeconds, padEndDisplay, qualifyTaskId, requireNonEmpty, } from "./exec-shared.js";
10
+ import { archivePlan, buildInPlaceStem, generateDeliverablePlan, generateSinglePlan, resolveDeliverableTarget, finalizeResultSectionsForDeliverable, reviewResultSectionsForDeliverable, targetDocIdsForScheduledTask, stemFromPlanPath, } from "./exec-plans.js";
11
+ import { resetResultForClaim, scaffoldResult } from "./exec-results.js";
12
+ import { runProviderScaffold, specdojoPackageRootDir } from "./exec-provider-scaffold.js";
13
+ import { generateRegisterPlan, normalizePjrId, resolveRegisterRunTarget } from "./exec-register.js";
14
+ import { scaffoldViewpoints } from "./review-plan.js";
15
+ import { registerCycleCommand, registerResumeCommand, registerRunCommand } from "./exec-run.js";
16
+ import { buildTaskView } from "./exec-task-view.js";
17
+ import { registerExecWorktreeCommands } from "./exec-worktree-command.js";
18
+ import { registerExecTrialCommands } from "./exec-trial.js";
19
+ import { discardStaleExecWorktree } from "./exec-worktree-ops.js";
20
+ import { buildInitialStateFromStrategy } from "./exec-schedule-initial.js";
21
+ import { buildPhaseModeIndex, resolveApproach, resolveOwnerForLocalId, resolveTaskExecution, resolveTaskMode, } from "./exec-strategy.js";
22
+ const KNOWN_OWNER_LABELS = ["PO", "PM", "BA", "ARC", "DEV", "QE", "UX", "OPS"];
23
+ const KNOWN_OWNER_LABELS_TEXT = KNOWN_OWNER_LABELS.join("|");
24
+ const KNOWN_APPROACHES = [
25
+ "fully-guided",
26
+ "recipe-guided",
27
+ "freeform",
28
+ "bootstrap",
29
+ "retrofit",
30
+ "cross-deliverable-dedup",
31
+ "rulebook-maintenance",
32
+ "recipe-maintenance",
33
+ "sample-maintenance",
34
+ "template-maintenance",
35
+ "finalize",
36
+ "bootstrap-finalize",
37
+ ];
38
+ function parseTaskMode(value) {
39
+ const mode = typeof value === "string" ? value.trim().toLowerCase() : "edit";
40
+ if (mode !== "edit" && mode !== "review") {
41
+ throw new Error(`Invalid --mode value: ${mode}. Use one of: edit|review.`);
42
+ }
43
+ return mode;
44
+ }
45
+ function parseApproach(value) {
46
+ const approach = typeof value === "string" ? value.trim().toLowerCase() : "";
47
+ if (!KNOWN_APPROACHES.includes(approach)) {
48
+ throw new Error(`Invalid --approach value: ${approach}. Use one of: ${KNOWN_APPROACHES.join("|")}.`);
49
+ }
50
+ return approach;
51
+ }
12
52
  function addProjectOptions(cmd) {
13
- return cmd.option('--project <projectId>', 'Project id in specdojo.config.json (e.g. shj-0001)');
53
+ return cmd.option("--project <projectId>", "Project id in specdojo.config.json (e.g. shj-0001)");
14
54
  }
15
55
  function addLockOptions(cmd) {
16
56
  return cmd
17
- .option('--allow-multiple-doing', 'Allow this actor to hold multiple doing tasks', false)
18
- .option('--lock-timeout-ms <ms>', 'Lock acquisition timeout in ms', '10000')
19
- .option('--lock-stale-ms <ms>', 'Lock stale threshold in ms', '300000');
57
+ .option("--allow-multiple-doing", "Allow this actor to hold multiple doing tasks", false)
58
+ .option("--lock-timeout-ms <ms>", "Lock acquisition timeout in ms", "10000")
59
+ .option("--lock-stale-ms <ms>", "Lock stale threshold in ms", "300000");
60
+ }
61
+ function addForceOption(cmd) {
62
+ return cmd.option("--force", "Human actor only: override the guard on a task held by another actor", false);
20
63
  }
21
64
  function addOwnerOptions(cmd) {
22
65
  return cmd
23
- .option('--owner <owner>', `Planned owner label for assignment checks (${KNOWN_OWNER_LABELS_TEXT}; defaults to SPECDOJO_OWNER or actor)`)
24
- .option('--allow-owner-mismatch', 'Allow claiming a task assigned to a different owner', false);
66
+ .option("--owner <owner>", `Planned owner label for assignment checks (${KNOWN_OWNER_LABELS_TEXT}; defaults to SPECDOJO_OWNER, roster owner, or actor)`)
67
+ .option("--allow-owner-mismatch", "Allow claiming a task assigned to a different owner", false);
25
68
  }
26
- function addCommonAddOptions(cmd) {
69
+ // Fixed default messages for routine state transitions. Events whose message carries the
70
+ // reason itself (note / block / unblock / reopen / cancel) have no default and keep --msg required.
71
+ const DEFAULT_EVENT_MESSAGES = {
72
+ claim: "claim task",
73
+ complete: "complete task",
74
+ release: "release task",
75
+ link: "link refs",
76
+ estimate: "update estimate",
77
+ };
78
+ function addCommonAddOptions(cmd, options) {
27
79
  addProjectOptions(cmd);
80
+ // `release --all-blocked` operates on every blocked task instead of a single --task, so the task
81
+ // option must be optional for that command. The single-task path still validates it via
82
+ // requireNonEmpty before building the event.
83
+ if (options?.requireTask === false) {
84
+ cmd.option("--task <taskId>", "Task/Milestone ID");
85
+ }
86
+ else {
87
+ cmd.requiredOption("--task <taskId>", "Task/Milestone ID");
88
+ }
89
+ cmd.requiredOption("--by <actor>", "Actor (human/agent)");
90
+ if (options?.msgDefault !== undefined) {
91
+ cmd.option("--msg <message>", "Short message", options.msgDefault);
92
+ }
93
+ else {
94
+ cmd.requiredOption("--msg <message>", "Short message");
95
+ }
28
96
  return cmd
29
- .requiredOption('--task <taskId>', 'Task/Milestone ID')
30
- .requiredOption('--by <actor>', 'Actor (human/agent)')
31
- .requiredOption('--msg <message>', 'Short message')
32
- .option('--run-id <id>', 'Correlation id')
33
- .option('--ref <k=v...>', 'refs key=value (repeatable)', collectRepeatable, [])
34
- .option('--meta <k=v...>', 'meta key=value (repeatable)', collectRepeatable, []);
97
+ .option("--run-id <id>", "Correlation id")
98
+ .option("--ref <k=v...>", "refs key=value (repeatable)", collectRepeatable, [])
99
+ .option("--meta <k=v...>", "meta key=value (repeatable)", collectRepeatable, [])
100
+ .option("--dry-run", "Print event JSON without writing to disk", false);
35
101
  }
36
102
  function resolveProjectContext(opts) {
37
103
  const resolvedPaths = resolveProjectPaths({ project: opts.project });
@@ -39,116 +105,78 @@ function resolveProjectContext(opts) {
39
105
  return resolvedPaths;
40
106
  }
41
107
  function loadRosterForOpts(opts) {
42
- const { config, configPath } = loadConfig();
108
+ const { config } = loadConfig();
43
109
  if (!config)
44
110
  return null;
45
- const projectId = opts.project?.trim() ||
46
- process.env.SPECDOJO_PROJECT?.trim() ||
47
- Object.keys(config.projects)[0] ||
48
- '';
111
+ const projectId = resolveProjectId(opts);
49
112
  const project = config.projects[projectId];
50
113
  if (!project)
51
114
  return null;
52
- const baseDir = dirname(configPath);
53
- return loadMemberRoster(baseDir, project);
115
+ return loadMemberRoster(specdojoRootDir(), project);
54
116
  }
55
- function resolveClaimOwner(opts, actor) {
56
- const cliOwner = typeof opts.owner === 'string' ? opts.owner.trim().toUpperCase() : '';
57
- const envOwner = typeof process.env.SPECDOJO_OWNER === 'string'
117
+ function resolveProjectId(opts) {
118
+ const { config } = loadConfig();
119
+ return (opts.project?.trim() ||
120
+ process.env.SPECDOJO_PROJECT?.trim() ||
121
+ config?.current_project?.trim() ||
122
+ Object.keys(config?.projects ?? {})[0] ||
123
+ "");
124
+ }
125
+ function findRosterMember(roster, actor) {
126
+ return roster?.members.find((member) => member.nickname === actor) ?? null;
127
+ }
128
+ // The --force override is honored only for actors registered as humans in the
129
+ // roster, so agents cannot steal a task another actor is working on.
130
+ function resolveForceOverride(opts, actor) {
131
+ const isHuman = findRosterMember(loadRosterForOpts(opts), actor)?.type === "human";
132
+ return { isHuman, force: !!opts.force };
133
+ }
134
+ export function resolveClaimOwner(opts, actor, roster = null, taskOwner) {
135
+ const cliOwner = typeof opts.owner === "string" ? opts.owner.trim().toUpperCase() : "";
136
+ const envOwner = typeof process.env.SPECDOJO_OWNER === "string"
58
137
  ? process.env.SPECDOJO_OWNER.trim().toUpperCase()
59
- : '';
138
+ : "";
139
+ const rosterMemberRoles = findRosterMember(roster, actor)?.roles ?? [];
140
+ // For multi-role actors, prefer the role matching the task's planned owner.
141
+ const matchedRole = taskOwner && rosterMemberRoles.length > 1
142
+ ? (rosterMemberRoles
143
+ .find((r) => r.trim().toUpperCase() === taskOwner.toUpperCase() &&
144
+ KNOWN_OWNER_LABELS.includes(r.trim().toUpperCase()))
145
+ ?.trim()
146
+ .toUpperCase() ?? "")
147
+ : "";
148
+ const rosterOwner = Array.isArray(rosterMemberRoles) && rosterMemberRoles.length > 0
149
+ ? rosterMemberRoles[0].trim().toUpperCase()
150
+ : "";
60
151
  if (cliOwner && !KNOWN_OWNER_LABELS.includes(cliOwner)) {
61
152
  throw new Error(`Invalid --owner value: ${cliOwner}. Use one of: ${KNOWN_OWNER_LABELS_TEXT}.`);
62
153
  }
63
154
  if (envOwner && !KNOWN_OWNER_LABELS.includes(envOwner)) {
64
155
  throw new Error(`Invalid SPECDOJO_OWNER value: ${envOwner}. Use one of: ${KNOWN_OWNER_LABELS_TEXT}.`);
65
156
  }
66
- return cliOwner || envOwner || actor;
157
+ if (rosterOwner &&
158
+ !KNOWN_OWNER_LABELS.includes(rosterOwner)) {
159
+ throw new Error(`Invalid roster owner for actor ${actor}: ${rosterOwner}. Use one of: ${KNOWN_OWNER_LABELS_TEXT}.`);
160
+ }
161
+ return cliOwner || envOwner || matchedRole || rosterOwner || "";
162
+ }
163
+ function resolveSchedulerStrategy(opts, actor, roster = null) {
164
+ const cliStrategy = typeof opts.strategy === "string" ? opts.strategy.trim().toLowerCase() : "";
165
+ const rosterStrategy = findRosterMember(roster, actor)?.scheduler_strategy ?? "";
166
+ const strategy = (cliStrategy || rosterStrategy || "critical-first");
167
+ if (strategy !== "critical-first" && strategy !== "fifo") {
168
+ throw new Error(`Invalid --strategy value: ${strategy}. Use one of: critical-first|fifo.`);
169
+ }
170
+ return strategy;
67
171
  }
68
172
  function printCommandError(error, fail = true) {
69
173
  const message = error instanceof Error ? error.message : String(error);
70
- process.stdout.write(message + '\n');
174
+ process.stdout.write(message + "\n");
71
175
  if (fail)
72
176
  exitWithCode(false);
73
177
  else
74
178
  process.exitCode = 1;
75
179
  }
76
- function runTaskCatalogBuild(schedulePath, executionPath) {
77
- const currentFileDir = dirname(fileURLToPath(import.meta.url));
78
- const scriptPath = resolve(currentFileDir, '../../docs/src/gen-task-catalog.ts');
79
- const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
80
- const result = spawnSync(npxCmd, ['tsx', scriptPath, '--schedule-path', schedulePath, '--execution-path', executionPath], {
81
- encoding: 'utf8',
82
- env: process.env,
83
- });
84
- if (result.status !== 0) {
85
- const stderr = (result.stderr ?? '').trim();
86
- const stdout = (result.stdout ?? '').trim();
87
- const details = [stdout, stderr].filter(Boolean).join('\n');
88
- throw new Error(`task-catalog generation failed: ${scriptPath}` + (details ? `\n${details}` : ''));
89
- }
90
- }
91
- function runAgentBriefBuild(schedulePath, executionPath, cliProject = '') {
92
- const currentFileDir = dirname(fileURLToPath(import.meta.url));
93
- const scriptPath = resolve(currentFileDir, '../../docs/src/gen-agent-briefs.ts');
94
- const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
95
- const result = spawnSync(npxCmd, [
96
- 'tsx',
97
- scriptPath,
98
- '--schedule-path',
99
- schedulePath,
100
- '--execution-path',
101
- executionPath,
102
- '--cli-project',
103
- cliProject,
104
- ], {
105
- encoding: 'utf8',
106
- env: process.env,
107
- });
108
- if (result.status !== 0) {
109
- const stderr = (result.stderr ?? '').trim();
110
- const stdout = (result.stdout ?? '').trim();
111
- const details = [stdout, stderr].filter(Boolean).join('\n');
112
- throw new Error(`agent-brief generation failed: ${scriptPath}` + (details ? `\n${details}` : ''));
113
- }
114
- }
115
- function saveClaimBriefSnapshot(executionPath, taskId, actor, eventTs) {
116
- const sourcePath = join(executionPath, 'generated', 'agent-briefs', `${taskId}.md`);
117
- if (!existsSync(sourcePath)) {
118
- throw new Error(`agent brief source not found for snapshot: ${sourcePath}`);
119
- }
120
- const snapshotDir = join(executionPath, 'exec', 'agent-briefs', 'claims', taskId);
121
- mkdirSync(snapshotDir, { recursive: true });
122
- const fileName = `${tsForFilenameUtc(eventTs)}--${safeSlug(actor)}.md`;
123
- copyFileSync(sourcePath, join(snapshotDir, fileName));
124
- writeClaimBriefSnapshotIndex(executionPath);
125
- }
126
- function writeClaimBriefSnapshotIndex(executionPath) {
127
- const claimsDir = join(executionPath, 'exec', 'agent-briefs', 'claims');
128
- mkdirSync(claimsDir, { recursive: true });
129
- const taskDirs = readdirSync(claimsDir)
130
- .map(name => ({ name, path: join(claimsDir, name) }))
131
- .filter(entry => statSync(entry.path).isDirectory())
132
- .sort((a, b) => a.name.localeCompare(b.name));
133
- const lines = [];
134
- lines.push('# Claim Brief Snapshot Index');
135
- lines.push('');
136
- lines.push('claim 時点で固定保存した Agent ブリーフの一覧。');
137
- lines.push('');
138
- lines.push('| task_id | snapshots | latest | latest_file |');
139
- lines.push('|---|---:|---|---|');
140
- for (const taskDir of taskDirs) {
141
- const files = readdirSync(taskDir.path)
142
- .filter(name => name.endsWith('.md'))
143
- .sort((a, b) => a.localeCompare(b));
144
- const latest = files.at(-1);
145
- if (!latest)
146
- continue;
147
- lines.push(`| ${taskDir.name} | ${files.length} | ${latest.replace(/\.md$/, '')} | [${latest}](./${taskDir.name}/${latest}) |`);
148
- }
149
- lines.push('');
150
- writeFileSync(join(claimsDir, 'index.md'), `${lines.join('\n')}\n`, 'utf8');
151
- }
152
180
  function loadValidatedExecState(projectPath) {
153
181
  const res = validateAll(projectPath);
154
182
  if (!res.ok) {
@@ -158,39 +186,83 @@ function loadValidatedExecState(projectPath) {
158
186
  }
159
187
  const schedule = buildScheduleIndex(projectPath);
160
188
  const events = readAllEventFiles(projectPath);
161
- const snapshot = foldEventsToState(events, schedule, projectPath);
189
+ const initialTasks = buildInitialStateFromStrategy(projectPath, schedule);
190
+ const snapshot = foldEventsToState(events, schedule, projectPath, initialTasks);
162
191
  return { schedule, events, snapshot };
163
192
  }
164
193
  function ensureActorCanClaimNext(snapshot, actor, allowMultipleDoing) {
165
194
  const doingTasks = findDoingTasksForActor(snapshot, actor);
166
195
  if (allowMultipleDoing || doingTasks.length === 0)
167
196
  return true;
168
- process.stdout.write(`Actor ${actor} already has doing task(s): ${doingTasks.join(', ')}\n` +
197
+ process.stdout.write(`Actor ${actor} already has doing task(s): ${doingTasks.join(", ")}\n` +
169
198
  `Use --allow-multiple-doing to override.\n`);
170
199
  exitWithCode(false);
171
200
  return false;
172
201
  }
202
+ async function scaffoldClaimResult(opts) {
203
+ const scheduleNode = opts.state.schedule.nodes.get(opts.taskId);
204
+ const localId = scheduleNode?.local_id;
205
+ const phaseModeIndex = buildPhaseModeIndex(opts.schedulePath);
206
+ const mode = resolveTaskMode(localId, opts.taskId, phaseModeIndex, scheduleNode?.phase_suffix, scheduleNode?.phase_set);
207
+ const approach = resolveApproach(localId, opts.taskId, phaseModeIndex, scheduleNode?.phase_suffix, scheduleNode?.phase_set);
208
+ const execution = resolveTaskExecution(localId, opts.taskId, phaseModeIndex, scheduleNode?.phase_suffix, scheduleNode?.phase_set);
209
+ const reviewSections = mode === "review"
210
+ ? reviewResultSectionsForDeliverable(opts.catalogPath ?? "", localId)
211
+ : undefined;
212
+ const finalizeSections = approach === "finalize" || approach === "bootstrap-finalize"
213
+ ? finalizeResultSectionsForDeliverable(opts.catalogPath ?? "", localId, approach)
214
+ : undefined;
215
+ const targets = targetDocIdsForScheduledTask(opts.catalogPath ?? "", {
216
+ local_id: localId,
217
+ target_local_ids: scheduleNode?.target_local_ids,
218
+ approach,
219
+ }, opts.projectId);
220
+ const result = await scaffoldResult({
221
+ executionPath: opts.executionPath,
222
+ taskId: opts.taskId,
223
+ mode,
224
+ projectId: opts.projectId,
225
+ ...(execution === "agent" ? { planRef: `exec/plans/${opts.taskId}-plan.md` } : {}),
226
+ agent: opts.actor,
227
+ startedAt: opts.startedAt,
228
+ execution,
229
+ ...(approach ? { approach } : {}),
230
+ ...(targets ? { targets } : {}),
231
+ ...(reviewSections ? { reviewSections } : {}),
232
+ ...(finalizeSections ? { finalizeSections } : {}),
233
+ });
234
+ if (!result.created) {
235
+ await resetResultForClaim(result.resultPath, opts.actor, opts.startedAt, execution);
236
+ }
237
+ }
173
238
  function runSimpleEventCommand(opts, type) {
174
239
  try {
175
240
  const { schedulePath } = resolveProjectContext(opts);
176
- const actor = requireNonEmpty('by', opts.by);
177
- assertValidActor(actor, loadRosterForOpts(opts));
241
+ const actor = requireNonEmpty("by", opts.by);
242
+ const roster = loadRosterForOpts(opts);
243
+ assertValidActor(actor, roster);
178
244
  const event = buildEvent(type, opts);
245
+ if (opts.dryRun) {
246
+ process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
247
+ exitWithCode(true);
248
+ return;
249
+ }
179
250
  const out = writeEventFile(schedulePath, event);
180
- process.stdout.write(out + '\n');
251
+ process.stdout.write(out + "\n");
181
252
  exitWithCode(true);
182
253
  }
183
254
  catch (error) {
184
255
  printCommandError(error, false);
185
256
  }
186
257
  }
187
- function runLockedEventCommand(opts, action) {
188
- let lockDir = '';
258
+ async function runLockedEventCommand(opts, action) {
259
+ let lockDir = "";
189
260
  try {
190
- const { schedulePath, executionPath } = resolveProjectContext(opts);
191
- const actor = requireNonEmpty('by', opts.by);
192
- assertValidActor(actor, loadRosterForOpts(opts));
193
- const taskId = requireNonEmpty('task', opts.task);
261
+ const { schedulePath, executionPath, catalogPath } = resolveProjectContext(opts);
262
+ const actor = requireNonEmpty("by", opts.by);
263
+ const roster = loadRosterForOpts(opts);
264
+ assertValidActor(actor, roster);
265
+ let taskId = typeof opts.task === "string" ? opts.task.trim() : "";
194
266
  const allowMultipleDoing = !!opts.allowMultipleDoing;
195
267
  const lockTimeoutMs = Number(opts.lockTimeoutMs);
196
268
  const lockStaleMs = Number(opts.lockStaleMs);
@@ -198,39 +270,189 @@ function runLockedEventCommand(opts, action) {
198
270
  const state = loadValidatedExecState(schedulePath);
199
271
  if (!state)
200
272
  return;
273
+ if (!taskId && action.type === "complete") {
274
+ const doingTasks = findDoingTasksForActor(state.snapshot, actor);
275
+ if (doingTasks.length === 0) {
276
+ throw new Error(`Actor ${actor} has no doing task to complete.`);
277
+ }
278
+ if (doingTasks.length > 1) {
279
+ throw new Error(`Actor ${actor} has multiple doing tasks: ${doingTasks.join(", ")}. Specify --task.`);
280
+ }
281
+ taskId = doingTasks[0];
282
+ }
283
+ if (!taskId)
284
+ taskId = requireNonEmpty("task", opts.task);
285
+ const resolvedOpts = { ...opts, task: taskId };
201
286
  if (action.requireSingleDoing &&
202
287
  !ensureActorCanClaimNext(state.snapshot, actor, allowMultipleDoing)) {
203
288
  return;
204
289
  }
205
- const check = action.check(state, taskId, actor, opts);
290
+ const check = action.check(state, taskId, actor, resolvedOpts);
206
291
  if (!check.ok) {
207
292
  process.stdout.write(`Cannot ${action.type} ${taskId}: ${check.reason}\n`);
208
293
  exitWithCode(false);
209
294
  return;
210
295
  }
211
- const event = buildEvent(action.type, opts);
212
- if (action.type === 'claim') {
296
+ const event = buildEvent(action.type, resolvedOpts);
297
+ if (action.type === "claim") {
213
298
  const plannedOwner = state.schedule.nodes.get(taskId)?.owner;
214
- const claimOwner = resolveClaimOwner(opts, actor);
299
+ const claimOwner = resolveClaimOwner(resolvedOpts, actor, roster, plannedOwner);
215
300
  const cpm = computeCpm(state.schedule, schedulePath);
216
301
  writeGeneratedCore(schedulePath, state.events, state.schedule, cpm);
217
302
  writeScheduleHashAndDiff(schedulePath, state.schedule);
218
303
  writeCpmFiles(schedulePath, cpm, state.snapshot);
219
- runTaskCatalogBuild(schedulePath, executionPath);
220
- runAgentBriefBuild(schedulePath, executionPath, opts.project ?? process.env.SPECDOJO_PROJECT ?? '');
221
- saveClaimBriefSnapshot(executionPath, taskId, actor, event.ts);
222
304
  event.meta = {
223
305
  ...(event.meta ?? {}),
224
306
  claim_owner: claimOwner,
225
307
  };
226
308
  if (plannedOwner)
227
309
  event.meta.planned_owner = plannedOwner;
228
- if (plannedOwner && claimOwner !== plannedOwner && opts.allowOwnerMismatch) {
310
+ if (plannedOwner && claimOwner !== plannedOwner && resolvedOpts.allowOwnerMismatch) {
229
311
  event.meta.owner_override = true;
230
312
  }
231
313
  }
314
+ if (opts.dryRun) {
315
+ process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
316
+ if (action.type === "release" && opts.resetWorktree) {
317
+ resetExecWorktreeForTask({
318
+ projectId: resolveProjectId(opts),
319
+ taskId,
320
+ schedulePath,
321
+ executionPath,
322
+ dryRun: true,
323
+ });
324
+ }
325
+ exitWithCode(true);
326
+ return;
327
+ }
232
328
  const out = writeEventFile(schedulePath, event);
233
- process.stdout.write(out + '\n');
329
+ if (action.type === "claim") {
330
+ await scaffoldClaimResult({
331
+ schedulePath,
332
+ executionPath,
333
+ catalogPath,
334
+ taskId,
335
+ state,
336
+ projectId: resolveProjectId(opts),
337
+ actor,
338
+ startedAt: new Date().toISOString(),
339
+ });
340
+ }
341
+ // The release event has been persisted (the task is now todo), so a retained exec worktree is
342
+ // stale residue. --reset-worktree discards it eagerly instead of waiting for the next claim to
343
+ // clean it up via discardStaleExecWorktree.
344
+ if (action.type === "release" && opts.resetWorktree) {
345
+ resetExecWorktreeForTask({
346
+ projectId: resolveProjectId(opts),
347
+ taskId,
348
+ schedulePath,
349
+ executionPath,
350
+ dryRun: false,
351
+ });
352
+ }
353
+ process.stdout.write(out + "\n");
354
+ exitWithCode(true);
355
+ }
356
+ catch (error) {
357
+ printCommandError(error);
358
+ }
359
+ finally {
360
+ if (lockDir) {
361
+ try {
362
+ releaseSchedulerLock(lockDir);
363
+ }
364
+ catch { }
365
+ }
366
+ }
367
+ }
368
+ // Discards the exec worktree and branch left behind by a now-released task. A released task is back
369
+ // in todo, so any retained worktree is stale residue. `dryRun` only prints what would be discarded.
370
+ function resetExecWorktreeForTask(args) {
371
+ const worktreeTaskId = qualifyTaskId(args.projectId, args.taskId);
372
+ if (args.dryRun) {
373
+ process.stdout.write(`[dry-run] reset worktree: discard exec/${worktreeTaskId}\n`);
374
+ return;
375
+ }
376
+ const discarded = discardStaleExecWorktree({
377
+ context: {
378
+ repoRoot: specdojoRootDir(),
379
+ schedulePath: args.schedulePath,
380
+ executionPath: args.executionPath,
381
+ },
382
+ worktreeTaskId,
383
+ });
384
+ process.stdout.write(discarded
385
+ ? `reset worktree: discarded ${discarded}\n`
386
+ : `reset worktree: no worktree or branch for ${worktreeTaskId}\n`);
387
+ }
388
+ // `release --all-blocked`: return every blocked task in the project to todo under a single scheduler
389
+ // lock. Tasks blocked by a different actor are skipped unless --force is given (humans only); each
390
+ // skip is reported with its reason. --reset-worktree discards each released task's stale worktree.
391
+ async function runReleaseAllBlocked(opts) {
392
+ let lockDir = "";
393
+ try {
394
+ const { schedulePath, executionPath } = resolveProjectContext(opts);
395
+ const actor = requireNonEmpty("by", opts.by);
396
+ const roster = loadRosterForOpts(opts);
397
+ assertValidActor(actor, roster);
398
+ requireNonEmpty("msg", opts.msg);
399
+ if (opts.task) {
400
+ process.stdout.write("Note: --all-blocked ignores --task.\n");
401
+ }
402
+ const lockTimeoutMs = Number(opts.lockTimeoutMs);
403
+ const lockStaleMs = Number(opts.lockStaleMs);
404
+ lockDir = acquireSchedulerLock(schedulePath, { actor, lockTimeoutMs, lockStaleMs });
405
+ const state = loadValidatedExecState(schedulePath);
406
+ if (!state)
407
+ return;
408
+ const projectId = resolveProjectId(opts);
409
+ const blockedTaskIds = Object.entries(state.snapshot.tasks)
410
+ .filter(([, cs]) => cs.state === "blocked")
411
+ .map(([taskId]) => taskId)
412
+ .sort((a, b) => a.localeCompare(b));
413
+ if (blockedTaskIds.length === 0) {
414
+ process.stdout.write("No blocked tasks to release.\n");
415
+ exitWithCode(true);
416
+ return;
417
+ }
418
+ const released = [];
419
+ const skipped = [];
420
+ const override = resolveForceOverride(opts, actor);
421
+ // Releasing one task does not change another task's releasability, so a single snapshot read is
422
+ // sufficient even though the in-memory snapshot is not re-folded after each write.
423
+ for (const taskId of blockedTaskIds) {
424
+ const check = canReleaseTask(state.schedule, state.snapshot, taskId, actor, override);
425
+ if (!check.ok) {
426
+ skipped.push({ taskId, reason: check.reason ?? "not releasable" });
427
+ continue;
428
+ }
429
+ const event = buildEvent("release", { ...opts, task: taskId });
430
+ if (opts.dryRun) {
431
+ process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
432
+ if (opts.resetWorktree) {
433
+ resetExecWorktreeForTask({
434
+ projectId,
435
+ taskId,
436
+ schedulePath,
437
+ executionPath,
438
+ dryRun: true,
439
+ });
440
+ }
441
+ released.push(taskId);
442
+ continue;
443
+ }
444
+ const out = writeEventFile(schedulePath, event);
445
+ if (opts.resetWorktree) {
446
+ resetExecWorktreeForTask({ projectId, taskId, schedulePath, executionPath, dryRun: false });
447
+ }
448
+ process.stdout.write(out + "\n");
449
+ released.push(taskId);
450
+ }
451
+ const dryRunSuffix = opts.dryRun ? " (dry-run)" : "";
452
+ process.stdout.write(`\nReleased ${released.length} blocked task(s)${dryRunSuffix}; skipped ${skipped.length}.\n`);
453
+ for (const s of skipped) {
454
+ process.stdout.write(` skip ${s.taskId}: ${s.reason}\n`);
455
+ }
234
456
  exitWithCode(true);
235
457
  }
236
458
  catch (error) {
@@ -246,72 +468,115 @@ function runLockedEventCommand(opts, action) {
246
468
  }
247
469
  }
248
470
  export function registerExecCommands(program) {
249
- const exec = program.command('exec').description('Execution helpers');
471
+ const exec = program.command("exec").description("Execution helpers");
250
472
  const lockedActions = {
251
473
  claim: {
252
- type: 'claim',
474
+ type: "claim",
253
475
  requireSingleDoing: true,
254
- check: ({ schedule, snapshot }, taskId, actor, opts) => canClaimTask(schedule, snapshot, taskId, resolveClaimOwner(opts, actor), !!opts.allowOwnerMismatch),
476
+ check: ({ schedule, snapshot }, taskId, actor, opts) => {
477
+ const taskOwner = schedule.nodes.get(taskId)?.owner;
478
+ return canClaimTask(schedule, snapshot, taskId, resolveClaimOwner(opts, actor, loadRosterForOpts(opts), taskOwner), !!opts.allowOwnerMismatch);
479
+ },
255
480
  },
256
481
  complete: {
257
- type: 'complete',
258
- check: ({ schedule, snapshot }, taskId, actor) => canCompleteTask(schedule, snapshot, taskId, actor),
482
+ type: "complete",
483
+ check: ({ schedule, snapshot }, taskId, actor, opts) => canCompleteTask(schedule, snapshot, taskId, actor, resolveForceOverride(opts, actor)),
484
+ },
485
+ reopen: {
486
+ type: "reopen",
487
+ check: ({ schedule, snapshot }, taskId, actor, opts) => canReopenTask(schedule, snapshot, taskId, findRosterMember(loadRosterForOpts(opts), actor)?.type === "human"),
259
488
  },
260
489
  block: {
261
- type: 'block',
262
- check: ({ schedule, snapshot }, taskId, actor) => canBlockTask(schedule, snapshot, taskId, actor),
490
+ type: "block",
491
+ check: ({ schedule, snapshot }, taskId, actor, opts) => canBlockTask(schedule, snapshot, taskId, actor, resolveForceOverride(opts, actor)),
263
492
  },
264
493
  unblock: {
265
- type: 'unblock',
494
+ type: "unblock",
266
495
  check: ({ schedule, snapshot }, taskId) => canUnblockTask(schedule, snapshot, taskId),
267
496
  },
497
+ release: {
498
+ type: "release",
499
+ check: ({ schedule, snapshot }, taskId, actor, opts) => canReleaseTask(schedule, snapshot, taskId, actor, resolveForceOverride(opts, actor)),
500
+ },
268
501
  cancel: {
269
- type: 'cancel',
270
- check: ({ schedule, snapshot }, taskId, actor) => canCancelTask(schedule, snapshot, taskId, actor),
502
+ type: "cancel",
503
+ check: ({ schedule, snapshot }, taskId) => canCancelTask(schedule, snapshot, taskId),
271
504
  },
272
505
  };
273
506
  const types = [
274
- 'claim',
275
- 'note',
276
- 'block',
277
- 'unblock',
278
- 'complete',
279
- 'cancel',
280
- 'link',
281
- 'estimate',
507
+ "claim",
508
+ "note",
509
+ "block",
510
+ "unblock",
511
+ "complete",
512
+ "reopen",
513
+ "release",
514
+ "cancel",
515
+ "link",
516
+ "estimate",
282
517
  ];
283
518
  for (const t of types) {
284
519
  const cmd = exec.command(t).description(`Write ${t} event JSON into exec/events/ (UTC)`);
285
- addCommonAddOptions(cmd);
520
+ addCommonAddOptions(cmd, {
521
+ requireTask: t !== "release" && t !== "complete",
522
+ msgDefault: DEFAULT_EVENT_MESSAGES[t],
523
+ });
286
524
  if (t in lockedActions)
287
525
  addLockOptions(cmd);
288
- if (t === 'claim')
526
+ if (t === "claim")
289
527
  addOwnerOptions(cmd);
528
+ if (t === "complete" || t === "block" || t === "release")
529
+ addForceOption(cmd);
530
+ if (t === "release") {
531
+ cmd.option("--reset-worktree", "Discard the task's exec worktree and branch after releasing (force removal)", false);
532
+ cmd.option("--all-blocked", "Release every blocked task in the project back to todo (ignores --task)", false);
533
+ }
290
534
  if (t in lockedActions) {
291
- cmd.action(opts => runLockedEventCommand(opts, lockedActions[t]));
535
+ const action = lockedActions[t];
536
+ cmd.action(async (opts) => {
537
+ if (action.type === "release" && opts.allBlocked) {
538
+ await runReleaseAllBlocked(opts);
539
+ return;
540
+ }
541
+ await runLockedEventCommand(opts, action);
542
+ });
292
543
  }
293
544
  else {
294
- cmd.action(opts => runSimpleEventCommand(opts, t));
545
+ cmd.action((opts) => runSimpleEventCommand(opts, t));
295
546
  }
296
547
  }
297
- const vcmd = exec.command('validate').description('Validate schedule + events');
548
+ const vcmd = exec.command("validate").description("Validate schedule + events");
298
549
  addProjectOptions(vcmd);
299
- vcmd.action(opts => {
550
+ vcmd.action((opts) => {
300
551
  try {
301
- const { schedulePath } = resolveProjectContext(opts);
552
+ const { schedulePath, catalogPath } = resolveProjectContext(opts);
302
553
  const res = validateAll(schedulePath);
303
554
  printValidateResult(res);
555
+ // Scheduled tasks resolve their deliverable by bare local_id, so warn when a
556
+ // local_id is not unique project-wide across the catalogs.
557
+ if (catalogPath && existsSync(catalogPath)) {
558
+ for (const warn of validateCatalogLocalIds(catalogPath).warnings) {
559
+ process.stdout.write(`WARN: ${warn}\n`);
560
+ }
561
+ // Warn when a rulebook declares recipe/sample/template or includes rulebooks
562
+ // that do not exist (or self-reference / non-rulebook includes).
563
+ for (const warn of validateRulebookKata(catalogPath).warnings) {
564
+ process.stdout.write(`WARN: ${warn}\n`);
565
+ }
566
+ }
304
567
  exitWithCode(res.ok);
305
568
  }
306
569
  catch (error) {
307
570
  printCommandError(error, false);
308
571
  }
309
572
  });
310
- const bcmd = exec.command('build').description('Generate all files under generated/');
311
- addProjectOptions(bcmd);
312
- bcmd.action(opts => {
573
+ const refreshCmd = exec
574
+ .command("refresh")
575
+ .description("Refresh derived execution state under generated/");
576
+ addProjectOptions(refreshCmd);
577
+ refreshCmd.action(async (opts) => {
313
578
  try {
314
- const { schedulePath, executionPath } = resolveProjectContext(opts);
579
+ const { schedulePath } = resolveProjectContext(opts);
315
580
  const res = validateAll(schedulePath);
316
581
  printValidateResult(res);
317
582
  if (!res.ok) {
@@ -324,8 +589,6 @@ export function registerExecCommands(program) {
324
589
  const snapshot = writeGeneratedCore(schedulePath, events, schedule, cpm);
325
590
  writeScheduleHashAndDiff(schedulePath, schedule);
326
591
  writeCpmFiles(schedulePath, cpm, snapshot);
327
- runTaskCatalogBuild(schedulePath, executionPath);
328
- runAgentBriefBuild(schedulePath, executionPath, opts.project ?? process.env.SPECDOJO_PROJECT ?? '');
329
592
  process.stdout.write(`\nGenerated: ${generatedDirForProject(schedulePath)}\n`);
330
593
  exitWithCode(true);
331
594
  }
@@ -333,26 +596,144 @@ export function registerExecCommands(program) {
333
596
  printCommandError(error, false);
334
597
  }
335
598
  });
599
+ const planCmd = exec
600
+ .command("plan")
601
+ .description("Generate a plan for an agent task or catalog deliverable (schedule-independent; does not change state or events)");
602
+ addProjectOptions(planCmd);
603
+ planCmd.option("--task <taskId>", "Scheduled task ID to generate the plan for");
604
+ planCmd.option("--deliverable <localId>", "Catalog deliverable local_id (unique project-wide)");
605
+ planCmd.option("--register <pjrId>", "Project register item ID (PJR-XXXX)");
606
+ planCmd.option("--mode <mode>", "edit|review (deliverable target)", "edit");
607
+ planCmd.option("--approach <approach>", "Approach template (deliverable target)");
608
+ planCmd.option("--track <track>", "Track to resolve the owner role from sch-strategy owner_rules (deliverable target)");
609
+ planCmd.option("--out <path>", "Override output path");
610
+ planCmd.action(async (opts) => {
611
+ try {
612
+ const { schedulePath, executionPath, catalogPath, rolesPath, viewpointsPath, projectContext, } = resolveProjectContext(opts);
613
+ const hasTask = typeof opts.task === "string" && opts.task.trim() !== "";
614
+ const hasDeliverable = typeof opts.deliverable === "string" && opts.deliverable.trim() !== "";
615
+ const hasRegister = typeof opts.register === "string" && opts.register.trim() !== "";
616
+ if ([hasTask, hasDeliverable, hasRegister].filter(Boolean).length !== 1) {
617
+ throw new Error("Specify exactly one of --task, --deliverable, or --register.");
618
+ }
619
+ const projectId = resolveProjectId(opts);
620
+ const outOverride = typeof opts.out === "string" && opts.out.trim() ? opts.out.trim() : undefined;
621
+ // Stem priority: --out → derive from the given filename (overwrite it); else --task → the
622
+ // fixed task id, so the plan/result share one canonical name with claim / run --track-state
623
+ // and an in-place run can be adopted without renaming; else --deliverable / --register → a
624
+ // new unique stem per generation (no task identity; avoids doc-index id collisions).
625
+ let outPath;
626
+ if (hasRegister) {
627
+ const pjrId = normalizePjrId(opts.register);
628
+ const { registerPaths, item } = resolveRegisterRunTarget(projectId, pjrId);
629
+ const stem = outOverride
630
+ ? stemFromPlanPath(outOverride)
631
+ : buildInPlaceStem(pjrId.toLowerCase());
632
+ const generated = await generateRegisterPlan({
633
+ executionPath,
634
+ projectId,
635
+ registerPaths,
636
+ item,
637
+ stem,
638
+ ...(outOverride ? { outPath: outOverride } : {}),
639
+ });
640
+ outPath = generated.planPath;
641
+ }
642
+ else if (hasTask) {
643
+ const task = buildTaskView(schedulePath, executionPath, opts.task.trim());
644
+ const stem = outOverride ? stemFromPlanPath(outOverride) : opts.task.trim();
645
+ outPath = await generateSinglePlan({
646
+ executionPath,
647
+ projectId,
648
+ catalogPath: catalogPath ?? "",
649
+ rolesPath,
650
+ viewpointsPath,
651
+ projectContext,
652
+ task,
653
+ stem,
654
+ ...(outOverride ? { outPath: outOverride } : {}),
655
+ });
656
+ }
657
+ else {
658
+ const target = resolveDeliverableTarget(catalogPath ?? "", opts.deliverable.trim());
659
+ const track = typeof opts.track === "string" && opts.track.trim() ? opts.track.trim() : undefined;
660
+ const owner = resolveOwnerForLocalId(schedulePath, target.localId, track);
661
+ const stem = outOverride ? stemFromPlanPath(outOverride) : buildInPlaceStem(target.slug);
662
+ outPath = await generateDeliverablePlan({
663
+ executionPath,
664
+ projectId,
665
+ catalogPath: catalogPath ?? "",
666
+ rolesPath,
667
+ viewpointsPath,
668
+ projectContext,
669
+ target,
670
+ mode: parseTaskMode(opts.mode),
671
+ ...(opts.approach ? { approach: parseApproach(opts.approach) } : {}),
672
+ ...(owner ? { owner } : {}),
673
+ stem,
674
+ ...(outOverride ? { outPath: outOverride } : {}),
675
+ });
676
+ }
677
+ process.stdout.write(`Generated: ${outPath}\n`);
678
+ exitWithCode(true);
679
+ }
680
+ catch (error) {
681
+ printCommandError(error, false);
682
+ }
683
+ });
684
+ const archiveCmd = exec
685
+ .command("archive")
686
+ .description("Archive a completed plan to exec/plans/done/ (or delete it)");
687
+ addProjectOptions(archiveCmd);
688
+ archiveCmd.option("--task <taskId>", "Scheduled task ID whose plan to archive");
689
+ archiveCmd.option("--deliverable <localId>", "Catalog deliverable local_id (unique project-wide)");
690
+ archiveCmd.option("--plan <path>", "Plan file to archive (for unique-named in-place plans)");
691
+ archiveCmd.option("--delete", "Delete the plan instead of moving it to done/", false);
692
+ archiveCmd.action((opts) => {
693
+ try {
694
+ const { executionPath, catalogPath } = resolveProjectContext(opts);
695
+ const hasTask = typeof opts.task === "string" && opts.task.trim() !== "";
696
+ const hasDeliverable = typeof opts.deliverable === "string" && opts.deliverable.trim() !== "";
697
+ const hasPlan = typeof opts.plan === "string" && opts.plan.trim() !== "";
698
+ if ([hasTask, hasDeliverable, hasPlan].filter(Boolean).length !== 1) {
699
+ throw new Error("Specify exactly one of --task, --deliverable, or --plan.");
700
+ }
701
+ // `archivePlan` rebuilds `<slug>-plan.md`; for --plan the stem recovered from the filename
702
+ // is that slug, so a unique-named in-place plan archives to done/ like a fixed-name one.
703
+ const slug = hasPlan
704
+ ? stemFromPlanPath(opts.plan.trim())
705
+ : hasTask
706
+ ? opts.task.trim()
707
+ : resolveDeliverableTarget(catalogPath ?? "", opts.deliverable.trim()).slug;
708
+ const result = archivePlan({ executionPath, slug, delete: !!opts.delete });
709
+ process.stdout.write(result.deleted ? `Deleted: ${result.from}\n` : `Archived: ${result.from} -> ${result.to}\n`);
710
+ exitWithCode(true);
711
+ }
712
+ catch (error) {
713
+ printCommandError(error, false);
714
+ }
715
+ });
336
716
  const scmd = exec
337
- .command('scheduler')
338
- .description('Auto-claim next task safely (with project-level lock).');
717
+ .command("scheduler")
718
+ .description("Auto-claim next task safely (with project-level lock).");
339
719
  addProjectOptions(scmd);
340
- scmd.requiredOption('--by <actor>', 'Actor (agent name)');
720
+ scmd.requiredOption("--by <actor>", "Actor (agent name)");
341
721
  addOwnerOptions(scmd);
342
- scmd.option('--strategy <strategy>', 'critical-first|fifo', 'critical-first');
343
- scmd.option('--dry-run', 'Do not write; print selected task only', false);
344
- scmd.option('--msg <message>', 'Claim message', 'auto-claim');
722
+ scmd.option("--strategy <strategy>", "critical-first|fifo (defaults to member profile or critical-first)");
723
+ scmd.option("--dry-run", "Do not write; print selected task only", false);
724
+ scmd.option("--msg <message>", "Claim message", "auto-claim");
345
725
  addLockOptions(scmd);
346
- scmd.action(opts => {
347
- let lockDir = '';
726
+ scmd.action(async (opts) => {
727
+ let lockDir = "";
348
728
  try {
349
- const { schedulePath } = resolveProjectContext(opts);
350
- const actor = requireNonEmpty('by', opts.by);
351
- assertValidActor(actor, loadRosterForOpts(opts));
352
- const strategy = String(opts.strategy);
729
+ const { schedulePath, executionPath, catalogPath } = resolveProjectContext(opts);
730
+ const actor = requireNonEmpty("by", opts.by);
731
+ const roster = loadRosterForOpts(opts);
732
+ assertValidActor(actor, roster);
733
+ const strategy = resolveSchedulerStrategy(opts, actor, roster);
353
734
  const dryRun = !!opts.dryRun;
354
- const msg = String(opts.msg ?? 'auto-claim');
355
- const claimOwner = resolveClaimOwner(opts, actor);
735
+ const msg = String(opts.msg ?? "auto-claim");
736
+ const claimOwner = resolveClaimOwner(opts, actor, roster);
356
737
  const allowOwnerMismatch = !!opts.allowOwnerMismatch;
357
738
  const allowMultipleDoing = !!opts.allowMultipleDoing;
358
739
  const lockTimeoutMs = Number(opts.lockTimeoutMs);
@@ -371,38 +752,82 @@ export function registerExecCommands(program) {
371
752
  catch {
372
753
  cpm = null;
373
754
  }
374
- const readyForOwner = ready.filter(taskId => {
375
- const claimCheck = canClaimTask(state.schedule, state.snapshot, taskId, claimOwner, allowOwnerMismatch);
376
- return claimCheck.ok;
755
+ // Collect all valid owner labels for this actor.
756
+ // Single-role actors use claimOwner; multi-role actors (e.g. indie) check every role.
757
+ const actorAllRoles = findRosterMember(roster, actor)
758
+ ?.roles?.map((r) => r.trim().toUpperCase())
759
+ .filter((r) => KNOWN_OWNER_LABELS.includes(r)) ??
760
+ [];
761
+ const ownerCandidates = actorAllRoles.length > 1 ? actorAllRoles : claimOwner ? [claimOwner] : [];
762
+ const readyForOwner = ready.filter((taskId) => {
763
+ if (ownerCandidates.length === 0) {
764
+ return canClaimTask(state.schedule, state.snapshot, taskId, claimOwner, allowOwnerMismatch).ok;
765
+ }
766
+ // Pass if any of the actor's roles can claim the task
767
+ return ownerCandidates.some((role) => canClaimTask(state.schedule, state.snapshot, taskId, role, allowOwnerMismatch).ok);
377
768
  });
378
- const next = selectNextTask(readyForOwner, cpm, strategy);
769
+ // Filter by actor mode and execution type from ready.json.
770
+ // Agent actors (with mode set) skip tasks with wrong mode or execution: human.
771
+ const actorMember = findRosterMember(roster, actor);
772
+ const actorMode = actorMember?.mode;
773
+ const isAgent = actorMember?.type === "agent";
774
+ let readyForMode = readyForOwner;
775
+ if (actorMode || isAgent) {
776
+ const readyJsonPath = join(generatedDirForProject(schedulePath), "ready.json");
777
+ if (existsSync(readyJsonPath)) {
778
+ const readySnapshot = readReadySnapshot(readyJsonPath);
779
+ const taskInfoMap = new Map(readySnapshot.tasks.map((t) => [t.id, t]));
780
+ readyForMode = readyForOwner.filter((taskId) => {
781
+ const taskInfo = taskInfoMap.get(taskId);
782
+ if (!taskInfo)
783
+ return true;
784
+ // Agents skip manual tasks
785
+ if (isAgent && (taskInfo.execution ?? "agent") === "human")
786
+ return false;
787
+ // Mode filter: skip tasks with different mode
788
+ if (actorMode && (taskInfo.mode ?? "edit") !== actorMode)
789
+ return false;
790
+ return true;
791
+ });
792
+ }
793
+ }
794
+ const next = selectNextTask(readyForMode, cpm, strategy);
379
795
  if (!next) {
380
- if (ready.length > 0 && !allowOwnerMismatch) {
796
+ if (readyForOwner.length > 0 && (actorMode || isAgent)) {
797
+ process.stdout.write(`No ready ${actorMode ?? "agent"} task for ${actor}. ` +
798
+ `${readyForOwner.length} task(s) ready but require different mode or are human-only.\n`);
799
+ }
800
+ else if (ready.length > 0 && !allowOwnerMismatch) {
381
801
  process.stdout.write(`No ready task assigned to owner ${claimOwner}. Use --owner <${KNOWN_OWNER_LABELS_TEXT}>, SPECDOJO_OWNER, or --allow-owner-mismatch.\n`);
382
802
  }
383
803
  else {
384
- process.stdout.write('No ready task to claim.\n');
804
+ process.stdout.write("No ready task to claim.\n");
385
805
  }
386
806
  exitWithCode(true);
387
807
  return;
388
808
  }
389
809
  if (dryRun) {
390
- process.stdout.write(next + '\n');
810
+ process.stdout.write(next + "\n");
391
811
  exitWithCode(true);
392
812
  return;
393
813
  }
814
+ // For multi-role actors, use the role that matches the selected task's owner.
815
+ const plannedOwner = state.schedule.nodes.get(next)?.owner ?? "";
816
+ const effectiveClaimOwner = ownerCandidates.length > 1 && ownerCandidates.includes(plannedOwner)
817
+ ? plannedOwner
818
+ : claimOwner;
394
819
  const ev = {
395
820
  v: 1,
396
821
  ts: nowUtcIsoSeconds(),
397
- type: 'claim',
822
+ type: "claim",
398
823
  task_id: next,
399
824
  by: actor,
400
825
  msg,
401
826
  meta: {
402
- claim_owner: claimOwner,
403
- planned_owner: state.schedule.nodes.get(next)?.owner,
827
+ claim_owner: effectiveClaimOwner,
828
+ planned_owner: plannedOwner || undefined,
404
829
  scheduler_strategy: strategy,
405
- claimed_via: 'dojo-exec-scheduler',
830
+ claimed_via: "dojo-exec-scheduler",
406
831
  },
407
832
  };
408
833
  if (ev.meta?.planned_owner &&
@@ -411,7 +836,20 @@ export function registerExecCommands(program) {
411
836
  ev.meta.owner_override = true;
412
837
  }
413
838
  const out = writeEventFile(schedulePath, ev);
414
- process.stdout.write(out + '\n');
839
+ // Await the scaffold (it formats the result with Prettier asynchronously). Firing it without
840
+ // awaiting leaks a promise that can read/write the result after the caller tears down its
841
+ // working directory, surfacing as an ENOENT unhandled rejection.
842
+ await scaffoldClaimResult({
843
+ schedulePath,
844
+ executionPath,
845
+ catalogPath,
846
+ state,
847
+ taskId: next,
848
+ projectId: resolveProjectId(opts),
849
+ actor,
850
+ startedAt: ev.ts,
851
+ });
852
+ process.stdout.write(out + "\n");
415
853
  exitWithCode(true);
416
854
  }
417
855
  catch (error) {
@@ -428,9 +866,123 @@ export function registerExecCommands(program) {
428
866
  }
429
867
  }
430
868
  });
431
- const wcmd = exec.command('where').description('Print resolved paths');
869
+ registerRunCommand(exec);
870
+ registerResumeCommand(exec);
871
+ registerCycleCommand(exec);
872
+ registerExecWorktreeCommands(exec);
873
+ registerExecTrialCommands(exec);
874
+ // exec scaffold: creates project setup files (viewpoints etc.) or provider templates
875
+ const scaffoldCmd = exec
876
+ .command("scaffold")
877
+ .description("Scaffold project setup files (pm-review-viewpoints.yaml) or provider templates (--provider)");
878
+ addProjectOptions(scaffoldCmd);
879
+ scaffoldCmd.option("--force", "Overwrite existing files", false);
880
+ scaffoldCmd.option("--provider <name>", "Copy the provider's agent/settings templates (templates/<name>) into the repository");
881
+ scaffoldCmd.option("--dry-run", "Show planned files without writing", false);
882
+ scaffoldCmd.action(async (opts) => {
883
+ try {
884
+ if (opts.provider) {
885
+ await runProviderScaffold(String(opts.provider), {
886
+ packageRoot: specdojoPackageRootDir(),
887
+ repoRoot: specdojoRootDir(),
888
+ force: !!opts.force,
889
+ dryRun: !!opts.dryRun,
890
+ });
891
+ return;
892
+ }
893
+ const { config } = loadConfig();
894
+ if (!config)
895
+ throw new Error("specdojo.config.json not found. Run: specdojo config init");
896
+ const projectId = opts.project?.trim() ||
897
+ process.env.SPECDOJO_PROJECT?.trim() ||
898
+ config.current_project?.trim() ||
899
+ Object.keys(config.projects)[0] ||
900
+ "";
901
+ if (!projectId)
902
+ throw new Error("No project specified. Use --project <id>.");
903
+ const project = config.projects[projectId];
904
+ if (!project)
905
+ throw new Error(`Unknown project: ${projectId}`);
906
+ const baseDir = specdojoRootDir();
907
+ const commonPath = join(baseDir, "docs", "ja", "specdojo", "standards", "pm-review-viewpoints.yaml");
908
+ const viewpointsRel = getProjectViewpointsPath(project);
909
+ if (viewpointsRel) {
910
+ const outputPath = pathResolve(baseDir, viewpointsRel);
911
+ const result = scaffoldViewpoints({
912
+ commonPath,
913
+ projectId,
914
+ outputPath,
915
+ force: !!opts.force,
916
+ });
917
+ if (result.written) {
918
+ process.stdout.write(`Written: ${outputPath}\n`);
919
+ }
920
+ else {
921
+ process.stdout.write(`Skipped (already exists): ${outputPath}\n`);
922
+ }
923
+ }
924
+ else {
925
+ process.stdout.write(`viewpoints_path not set for project '${projectId}'. Add it to specdojo.config.json.\n`);
926
+ }
927
+ }
928
+ catch (error) {
929
+ printCommandError(error, false);
930
+ }
931
+ });
932
+ const statusCmd = exec.command("status").description("Show tasks filtered by state and actor");
933
+ addProjectOptions(statusCmd);
934
+ statusCmd.option("--by <actor>", "Filter by actor nickname");
935
+ statusCmd.option("--state <state>", "Filter by state: todo|doing|blocked|done|cancelled (default: doing)", "doing");
936
+ statusCmd.action((opts) => {
937
+ try {
938
+ const { schedulePath } = resolveProjectContext(opts);
939
+ // Compute state directly from events (not from cached state.json)
940
+ const state = loadValidatedExecState(schedulePath);
941
+ if (!state)
942
+ return;
943
+ const snapshot = state.snapshot;
944
+ const schedule = state.schedule;
945
+ const filterState = String(opts.state ?? "doing");
946
+ const filterBy = typeof opts.by === "string" ? opts.by.trim() : undefined;
947
+ const entries = Object.entries(snapshot.tasks)
948
+ .filter(([, cs]) => cs.state === filterState)
949
+ .filter(([, cs]) => !filterBy || cs.last_by === filterBy)
950
+ .sort(([a], [b]) => a.localeCompare(b));
951
+ if (entries.length === 0) {
952
+ const byMsg = filterBy ? ` for ${filterBy}` : "";
953
+ process.stdout.write(`No ${filterState} tasks${byMsg}.\n`);
954
+ exitWithCode(true);
955
+ return;
956
+ }
957
+ const byMsg = filterBy ? ` for ${filterBy}` : "";
958
+ process.stdout.write(`${filterState} tasks${byMsg}:\n\n`);
959
+ const rows = entries.map(([taskId, cs]) => ({
960
+ taskId,
961
+ name: schedule.nodes.get(taskId)?.name ?? "-",
962
+ by: cs.last_by ?? "-",
963
+ ts: cs.last_ts ?? "-",
964
+ }));
965
+ // Size every column to its longest value (including the header) so nothing is truncated.
966
+ // displayWidth counts full-width (CJK) characters as 2 columns so the table stays aligned.
967
+ const taskWidth = Math.max("task_id".length, ...rows.map((r) => displayWidth(r.taskId)));
968
+ const nameWidth = Math.max("name".length, ...rows.map((r) => displayWidth(r.name)));
969
+ const byWidth = Math.max("by".length, ...rows.map((r) => displayWidth(r.by)));
970
+ const tsWidth = Math.max("claimed_at".length, ...rows.map((r) => displayWidth(r.ts)));
971
+ process.stdout.write(` ${padEndDisplay("task_id", taskWidth)} ${padEndDisplay("name", nameWidth)} ${padEndDisplay("by", byWidth)} claimed_at\n`);
972
+ process.stdout.write(` ${"-".repeat(taskWidth)} ${"-".repeat(nameWidth)} ${"-".repeat(byWidth)} ${"-".repeat(tsWidth)}\n`);
973
+ for (const r of rows) {
974
+ // The trailing claimed_at column is left unpadded to avoid stray trailing whitespace.
975
+ process.stdout.write(` ${padEndDisplay(r.taskId, taskWidth)} ${padEndDisplay(r.name, nameWidth)} ${padEndDisplay(r.by, byWidth)} ${r.ts}\n`);
976
+ }
977
+ exitWithCode(true);
978
+ }
979
+ catch (error) {
980
+ printCommandError(error, false);
981
+ }
982
+ });
983
+ const wcmd = exec.command("where").description("Print resolved paths");
432
984
  addProjectOptions(wcmd);
433
- wcmd.action(opts => {
985
+ wcmd.action((opts) => {
434
986
  try {
435
987
  const resolvedPaths = resolveProjectContext(opts);
436
988
  process.stdout.write(`schedule-path: ${resolvedPaths.schedulePath}\n`);