specdojo 0.8.0 → 0.9.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 (284) hide show
  1. package/.github/agents/specdojo-orchestrator.md +4 -1
  2. package/CHANGELOG.md +64 -0
  3. package/dist/catalog/catalog.js +16 -14
  4. package/dist/commands/agent.js +5 -3
  5. package/dist/commands/build.js +69 -10
  6. package/dist/commands/git.js +206 -0
  7. package/dist/commands/init.js +4 -2
  8. package/dist/commands/where.js +25 -0
  9. package/dist/dashboard/dashboard.js +5 -3
  10. package/dist/dashboard/routines.js +4 -7
  11. package/dist/dashboard/timeline.js +14 -14
  12. package/dist/docs/index-command.js +2 -2
  13. package/dist/docs/yaml-business-tables.js +243 -0
  14. package/dist/docs/yaml-interface-tables.js +106 -0
  15. package/dist/docs/yaml-pages-command.js +5 -3
  16. package/dist/docs/yaml-pages.js +146 -3
  17. package/dist/docs/yaml-table-shared.js +70 -0
  18. package/dist/docs/yaml-tables.js +39 -0
  19. package/dist/exec/agent-config.js +9 -0
  20. package/dist/exec/agent-protected-config.js +2 -0
  21. package/dist/exec/commands.js +31 -18
  22. package/dist/exec/events.js +34 -14
  23. package/dist/exec/evidence.js +13 -3
  24. package/dist/exec/parent-validation.js +56 -3
  25. package/dist/exec/plans-core.js +21 -2
  26. package/dist/exec/plans-generation.js +6 -7
  27. package/dist/exec/post-integration.js +162 -0
  28. package/dist/exec/queue-command.js +166 -0
  29. package/dist/exec/queue.js +285 -0
  30. package/dist/exec/register-foreign-wait.js +84 -0
  31. package/dist/exec/repo-integration-sync.js +17 -5
  32. package/dist/exec/reporter.js +2 -2
  33. package/dist/exec/results.js +24 -4
  34. package/dist/exec/review-kata.js +4 -1
  35. package/dist/exec/run/agent-pipeline.js +3 -2
  36. package/dist/exec/run/agent.js +12 -6
  37. package/dist/exec/run/change-scope.js +365 -0
  38. package/dist/exec/run/deferred-cleanup.js +31 -0
  39. package/dist/exec/run/in-place.js +4 -1
  40. package/dist/exec/run/job-lock.js +66 -0
  41. package/dist/exec/run/job-sequence.js +137 -0
  42. package/dist/exec/run/job.js +56 -19
  43. package/dist/exec/run/lifecycle-commands.js +1 -1
  44. package/dist/exec/run/lock.js +22 -1
  45. package/dist/exec/run/register-command.js +8 -5
  46. package/dist/exec/run/register-mode.js +68 -8
  47. package/dist/exec/run/register-resume.js +68 -14
  48. package/dist/exec/run/register-state.js +13 -8
  49. package/dist/exec/run/register-worktree.js +140 -125
  50. package/dist/exec/run/schedule-mode.js +75 -14
  51. package/dist/exec/run/schedule-prepare.js +3 -0
  52. package/dist/exec/run/schedule-task.js +88 -38
  53. package/dist/exec/run/shared.js +5 -0
  54. package/dist/exec/schedule/schedule.js +116 -4
  55. package/dist/exec/shared.js +1 -1
  56. package/dist/exec/smoke.js +190 -0
  57. package/dist/exec/strategy.js +13 -3
  58. package/dist/exec/task-view.js +6 -4
  59. package/dist/exec/trial-commands.js +5 -2
  60. package/dist/exec/trial-core.js +6 -1
  61. package/dist/exec/validation-metrics.js +181 -0
  62. package/dist/exec/worktree-cleanup-lock.js +26 -0
  63. package/dist/exec/worktree-command.js +9 -1
  64. package/dist/exec/worktree-ops-commit.js +2 -2
  65. package/dist/exec/worktree.js +13 -2
  66. package/dist/grade/command-apply.js +3 -3
  67. package/dist/grade/command-inspect.js +5 -3
  68. package/dist/grade/command-plan.js +1 -1
  69. package/dist/grade/command-run.js +5 -1
  70. package/dist/grade/run.js +64 -8
  71. package/dist/job/definition.js +84 -8
  72. package/dist/job/job.js +79 -23
  73. package/dist/register/authoring-sources.js +22 -16
  74. package/dist/register/maintenance-commands.js +2 -2
  75. package/dist/register/register.js +31 -7
  76. package/dist/routine/definition.js +9 -0
  77. package/dist/routine/routine.js +137 -43
  78. package/dist/routine/status.js +62 -0
  79. package/dist/schedule/schedule.js +38 -39
  80. package/dist/shared/agent-types.js +5 -0
  81. package/dist/shared/cross-process-lock.js +9 -1
  82. package/dist/shared/dist-freshness.js +8 -2
  83. package/dist/shared/git-environment.js +2 -1
  84. package/dist/shared/git.js +44 -1
  85. package/dist/shared/lefthook-scaffold.js +3 -0
  86. package/dist/shared/local-config.js +244 -0
  87. package/dist/shared/specdojo-config.js +34 -20
  88. package/dist/shared/specdojo-gitignore.js +1 -0
  89. package/dist/shared/text.js +9 -1
  90. package/dist/shared/where-alias.js +13 -0
  91. package/dist/specdojo.js +4 -0
  92. package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +2 -0
  93. package/docs/ja/specdojo/guides/exec-config-guide.md +23 -4
  94. package/docs/ja/specdojo/guides/exec-operation-guide.md +44 -1
  95. package/docs/ja/specdojo/guides/job-sequence-guide.md +77 -0
  96. package/docs/ja/specdojo/guides/quick-start-guide.md +3 -3
  97. package/docs/ja/specdojo/guides/register-operation-guide.md +1 -1
  98. package/docs/ja/specdojo/guides/routine-operation-guide.md +11 -6
  99. package/docs/ja/specdojo/guides/schedule-design-guide.md +20 -17
  100. package/docs/ja/specdojo/guides/waza-guide.md +12 -8
  101. package/docs/ja/specdojo/recipes/bac-recipe.md +66 -49
  102. package/docs/ja/specdojo/recipes/bes-recipe.md +90 -54
  103. package/docs/ja/specdojo/recipes/bps-recipe.md +88 -139
  104. package/docs/ja/specdojo/recipes/br-recipe.md +40 -47
  105. package/docs/ja/specdojo/recipes/cdfd-overview-recipe.md +97 -109
  106. package/docs/ja/specdojo/recipes/cdfd-recipe.md +85 -146
  107. package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +91 -110
  108. package/docs/ja/specdojo/recipes/cnd-recipe.md +79 -69
  109. package/docs/ja/specdojo/recipes/cpd-recipe.md +78 -64
  110. package/docs/ja/specdojo/recipes/cxd-recipe.md +92 -75
  111. package/docs/ja/specdojo/recipes/ifd-recipe.md +79 -68
  112. package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +78 -105
  113. package/docs/ja/specdojo/recipes/ifx-index-recipe.md +105 -71
  114. package/docs/ja/specdojo/recipes/pm-communication-plan-recipe.md +60 -49
  115. package/docs/ja/specdojo/recipes/pm-members-recipe.md +50 -51
  116. package/docs/ja/specdojo/recipes/pm-organization-recipe.md +59 -51
  117. package/docs/ja/specdojo/recipes/pm-plan-recipe.md +69 -56
  118. package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +37 -56
  119. package/docs/ja/specdojo/recipes/pm-raci-recipe.md +39 -53
  120. package/docs/ja/specdojo/recipes/pm-roles-recipe.md +52 -79
  121. package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +64 -93
  122. package/docs/ja/specdojo/recipes/prj-charter-recipe.md +71 -106
  123. package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +78 -157
  124. package/docs/ja/specdojo/recipes/prj-issues-and-approach-recipe.md +62 -111
  125. package/docs/ja/specdojo/recipes/prj-scope-recipe.md +67 -123
  126. package/docs/ja/specdojo/recipes/prj-stakeholder-register-recipe.md +60 -96
  127. package/docs/ja/specdojo/recipes/prj-success-criteria-and-acceptance-criteria-recipe.md +61 -105
  128. package/docs/ja/specdojo/recipes/stsd-recipe.md +79 -109
  129. package/docs/ja/specdojo/recipes/sysd-critical-flows-recipe.md +78 -55
  130. package/docs/ja/specdojo/recipes/sysd-cross-cutting-policy-recipe.md +82 -73
  131. package/docs/ja/specdojo/recipes/sysd-index-recipe.md +78 -59
  132. package/docs/ja/specdojo/recipes/tsd-recipe.md +149 -129
  133. package/docs/ja/specdojo/references/command-reference.md +257 -117
  134. package/docs/ja/specdojo/references/deliverables-reference.md +21 -12
  135. package/docs/ja/specdojo/references/specdojo-config-reference.md +37 -2
  136. package/docs/ja/specdojo/rulebooks/atc-index-rulebook.md +101 -257
  137. package/docs/ja/specdojo/rulebooks/atc-rulebook.md +102 -228
  138. package/docs/ja/specdojo/rulebooks/bac-rulebook.md +19 -28
  139. package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +16 -67
  140. package/docs/ja/specdojo/rulebooks/bds-rulebook.md +30 -51
  141. package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +41 -61
  142. package/docs/ja/specdojo/rulebooks/bes-rulebook.md +22 -50
  143. package/docs/ja/specdojo/rulebooks/bps-rulebook.md +24 -56
  144. package/docs/ja/specdojo/rulebooks/br-rulebook.md +13 -38
  145. package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +41 -76
  146. package/docs/ja/specdojo/rulebooks/cdfd-d2-rulebook.md +18 -93
  147. package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +18 -52
  148. package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +109 -147
  149. package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +80 -108
  150. package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +21 -46
  151. package/docs/ja/specdojo/rulebooks/cdr-rulebook.md +144 -0
  152. package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +27 -48
  153. package/docs/ja/specdojo/rulebooks/cdt-rulebook.md +37 -50
  154. package/docs/ja/specdojo/rulebooks/clis-rulebook.md +52 -69
  155. package/docs/ja/specdojo/rulebooks/cnd-mermaid-rulebook.md +33 -86
  156. package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +16 -32
  157. package/docs/ja/specdojo/rulebooks/cop-index-rulebook.md +45 -131
  158. package/docs/ja/specdojo/rulebooks/cop-rulebook.md +69 -275
  159. package/docs/ja/specdojo/rulebooks/cpd-mermaid-rulebook.md +20 -112
  160. package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +23 -56
  161. package/docs/ja/specdojo/rulebooks/cxd-mermaid-rulebook.md +12 -145
  162. package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +39 -47
  163. package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +37 -56
  164. package/docs/ja/specdojo/rulebooks/dct-rulebook.md +118 -175
  165. package/docs/ja/specdojo/rulebooks/dec-rulebook.md +5 -14
  166. package/docs/ja/specdojo/rulebooks/dmd-index-rulebook.md +22 -66
  167. package/docs/ja/specdojo/rulebooks/dmd-rulebook.md +36 -94
  168. package/docs/ja/specdojo/rulebooks/dss-rulebook.md +59 -81
  169. package/docs/ja/specdojo/rulebooks/etc-index-rulebook.md +31 -131
  170. package/docs/ja/specdojo/rulebooks/etc-rulebook.md +50 -104
  171. package/docs/ja/specdojo/rulebooks/gl-rulebook.md +51 -61
  172. package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +38 -45
  173. package/docs/ja/specdojo/rulebooks/ifx-api-rulebook.md +14 -20
  174. package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +26 -38
  175. package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +26 -107
  176. package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +42 -49
  177. package/docs/ja/specdojo/rulebooks/ifx-msg-rulebook.md +14 -22
  178. package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +21 -44
  179. package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +41 -64
  180. package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +14 -38
  181. package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +34 -61
  182. package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +27 -50
  183. package/docs/ja/specdojo/rulebooks/itc-index-rulebook.md +70 -199
  184. package/docs/ja/specdojo/rulebooks/itc-rulebook.md +65 -153
  185. package/docs/ja/specdojo/rulebooks/mip-index-rulebook.md +74 -150
  186. package/docs/ja/specdojo/rulebooks/mm-rulebook.md +11 -23
  187. package/docs/ja/specdojo/rulebooks/mtp-rulebook.md +99 -176
  188. package/docs/ja/specdojo/rulebooks/nfr-availability-rulebook.md +35 -61
  189. package/docs/ja/specdojo/rulebooks/nfr-index-rulebook.md +75 -117
  190. package/docs/ja/specdojo/rulebooks/nfr-integrity-rulebook.md +31 -60
  191. package/docs/ja/specdojo/rulebooks/nfr-maintainability-rulebook.md +26 -81
  192. package/docs/ja/specdojo/rulebooks/nfr-operations-rulebook.md +32 -70
  193. package/docs/ja/specdojo/rulebooks/nfr-performance-rulebook.md +45 -87
  194. package/docs/ja/specdojo/rulebooks/nfr-reliability-rulebook.md +48 -101
  195. package/docs/ja/specdojo/rulebooks/nfr-security-safety-rulebook.md +44 -80
  196. package/docs/ja/specdojo/rulebooks/nfr-usability-rulebook.md +59 -127
  197. package/docs/ja/specdojo/rulebooks/opd-index-rulebook.md +31 -50
  198. package/docs/ja/specdojo/rulebooks/opd-rulebook.md +42 -109
  199. package/docs/ja/specdojo/rulebooks/opr-index-rulebook.md +29 -42
  200. package/docs/ja/specdojo/rulebooks/opr-rulebook.md +29 -87
  201. package/docs/ja/specdojo/rulebooks/otp-index-rulebook.md +62 -84
  202. package/docs/ja/specdojo/rulebooks/otp-rulebook.md +11 -61
  203. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +91 -106
  204. package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +25 -34
  205. package/docs/ja/specdojo/rulebooks/pm-communication-plan-rulebook.md +30 -53
  206. package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +23 -35
  207. package/docs/ja/specdojo/rulebooks/pm-members-rulebook.md +27 -45
  208. package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +37 -45
  209. package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +45 -46
  210. package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +37 -48
  211. package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +25 -29
  212. package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +28 -35
  213. package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +36 -41
  214. package/docs/ja/specdojo/rulebooks/pr-rulebook.md +5 -18
  215. package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +16 -37
  216. package/docs/ja/specdojo/rulebooks/prj-charter-rulebook.md +23 -97
  217. package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +39 -57
  218. package/docs/ja/specdojo/rulebooks/prj-issues-and-approach-rulebook.md +43 -116
  219. package/docs/ja/specdojo/rulebooks/prj-scope-rulebook.md +16 -51
  220. package/docs/ja/specdojo/rulebooks/prj-stakeholder-register-rulebook.md +47 -92
  221. package/docs/ja/specdojo/rulebooks/prj-success-criteria-and-acceptance-criteria-rulebook.md +25 -84
  222. package/docs/ja/specdojo/rulebooks/sac-rulebook.md +44 -107
  223. package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +39 -49
  224. package/docs/ja/specdojo/rulebooks/sf-rulebook.md +42 -49
  225. package/docs/ja/specdojo/rulebooks/sld-rulebook.md +64 -89
  226. package/docs/ja/specdojo/rulebooks/stc-index-rulebook.md +90 -189
  227. package/docs/ja/specdojo/rulebooks/stc-rulebook.md +45 -105
  228. package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +6 -12
  229. package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +49 -68
  230. package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +51 -60
  231. package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +46 -50
  232. package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +39 -64
  233. package/docs/ja/specdojo/rulebooks/sysd-rulebook.md +47 -60
  234. package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +69 -70
  235. package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +65 -72
  236. package/docs/ja/specdojo/rulebooks/tsd-index-rulebook.md +35 -46
  237. package/docs/ja/specdojo/rulebooks/tsd-rulebook.md +49 -66
  238. package/docs/ja/specdojo/rulebooks/tsp-index-rulebook.md +64 -139
  239. package/docs/ja/specdojo/rulebooks/uis-rulebook.md +41 -108
  240. package/docs/ja/specdojo/rulebooks/utc-index-rulebook.md +49 -144
  241. package/docs/ja/specdojo/rulebooks/utc-rulebook.md +67 -155
  242. package/docs/ja/specdojo/samples/bds-sample.md +58 -71
  243. package/docs/ja/specdojo/samples/bes-index-sample.md +20 -37
  244. package/docs/ja/specdojo/samples/bes-sample.md +43 -53
  245. package/docs/ja/specdojo/samples/bps-sample.md +42 -54
  246. package/docs/ja/specdojo/samples/br-sample.md +40 -52
  247. package/docs/ja/specdojo/samples/ccd-sample.md +0 -1
  248. package/docs/ja/specdojo/samples/cdr-sample.md +78 -0
  249. package/docs/ja/specdojo/samples/cdsd-sample.md +47 -63
  250. package/docs/ja/specdojo/samples/clis-sample.md +70 -77
  251. package/docs/ja/specdojo/samples/dec-sample.md +2 -3
  252. package/docs/ja/specdojo/samples/ifx-api-sample.yaml +0 -2
  253. package/docs/ja/specdojo/samples/ifx-msg-sample.yaml +0 -2
  254. package/docs/ja/specdojo/samples/job-sequence.yaml +67 -0
  255. package/docs/ja/specdojo/samples/mip-index-sample.md +98 -20
  256. package/docs/ja/specdojo/samples/pm-communication-plan-sample.md +26 -19
  257. package/docs/ja/specdojo/samples/pm-organization-sample.md +39 -50
  258. package/docs/ja/specdojo/samples/pm-plan-sample.md +61 -67
  259. package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +31 -45
  260. package/docs/ja/specdojo/samples/pm-raci-sample.md +31 -37
  261. package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +32 -48
  262. package/docs/ja/specdojo/samples/prj-charter-sample.md +42 -59
  263. package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +55 -61
  264. package/docs/ja/specdojo/samples/prj-success-criteria-and-acceptance-criteria-sample.md +30 -33
  265. package/docs/ja/specdojo/samples/sf-index-sample.md +13 -55
  266. package/docs/ja/specdojo/samples/sf-sample.md +73 -85
  267. package/docs/ja/specdojo/samples/sld-sample.md +60 -79
  268. package/docs/ja/specdojo/samples/uis-sample.md +98 -121
  269. package/docs/ja/specdojo/standards/job-definition-standard.md +24 -9
  270. package/docs/ja/specdojo/templates/cdr-template.md +58 -0
  271. package/docs/specdojo/schemas/v1/exec-common.schema.yaml +2 -1
  272. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +42 -5
  273. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +35 -0
  274. package/docs/specdojo/schemas/v1/job-run.schema.yaml +23 -0
  275. package/docs/specdojo/schemas/v1/job.schema.yaml +63 -2
  276. package/docs/specdojo/schemas/v1/sch-strategy.schema.yaml +2 -2
  277. package/package.json +9 -6
  278. package/templates/antigravity/orchestrator.md +4 -1
  279. package/templates/claude/agents/specdojo-orchestrator.md +4 -1
  280. package/templates/codex/agents/specdojo-orchestrator.toml +4 -1
  281. package/templates/codex/orchestrator.md +4 -1
  282. package/templates/init-exec-defaults.yaml +13 -0
  283. package/templates/lefthook/tools/specdojo-pre-commit.mjs +8 -0
  284. package/templates/opencode/agents/specdojo-orchestrator.md +5 -2
@@ -3,6 +3,7 @@ import { basename, join, resolve } from "node:path";
3
3
  import { load } from "../shared/yaml.js";
4
4
  import { listFilesRecursive, readJson } from "../shared/fs.js";
5
5
  import { getProjectExecutionPath, getProjectJobsPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
6
+ import { isProficiency, PROFICIENCIES, } from "../shared/agent-types.js";
6
7
  function isRecord(value) {
7
8
  return typeof value === "object" && value !== null && !Array.isArray(value);
8
9
  }
@@ -17,6 +18,65 @@ function validStringList(value) {
17
18
  value.length > 0 &&
18
19
  value.every((item) => typeof item === "string" && item.trim()));
19
20
  }
21
+ export function parseJobSteps(value) {
22
+ const errors = [];
23
+ if (!Array.isArray(value) || value.length === 0)
24
+ return { errors: ["task.steps must be a non-empty list"] };
25
+ const steps = [];
26
+ const ids = new Set();
27
+ for (const [index, raw] of value.entries()) {
28
+ const prefix = `task.steps[${index}]`;
29
+ if (!isRecord(raw)) {
30
+ errors.push(`${prefix} must be a mapping`);
31
+ continue;
32
+ }
33
+ if (Object.keys(raw).some((key) => !["id", "command", "on_failure", "timeout_seconds", "completion"].includes(key)))
34
+ errors.push(`${prefix} has unknown keys`);
35
+ if (typeof raw.id !== "string" || !/^[a-z][a-z0-9-]*$/.test(raw.id) || ids.has(raw.id))
36
+ errors.push(`${prefix}.id must be a unique lowercase slug`);
37
+ else
38
+ ids.add(raw.id);
39
+ if (typeof raw.command !== "string" || !raw.command.trim())
40
+ errors.push(`${prefix}.command must be non-empty`);
41
+ if (raw.on_failure !== undefined && raw.on_failure !== "stop" && raw.on_failure !== "continue")
42
+ errors.push(`${prefix}.on_failure must be stop|continue`);
43
+ if (raw.timeout_seconds !== undefined &&
44
+ (!Number.isSafeInteger(raw.timeout_seconds) ||
45
+ Number(raw.timeout_seconds) < 1 ||
46
+ Number(raw.timeout_seconds) > 2147483))
47
+ errors.push(`${prefix}.timeout_seconds must be an integer from 1 to 2147483`);
48
+ let completion;
49
+ if (raw.completion !== undefined) {
50
+ const state = raw.completion;
51
+ if (!isRecord(state) ||
52
+ Object.keys(state).some((key) => !["path", "field", "succeeded", "deferred"].includes(key)) ||
53
+ typeof state.path !== "string" ||
54
+ !state.path.trim() ||
55
+ typeof state.field !== "string" ||
56
+ !state.field.trim() ||
57
+ !validStringList(state.succeeded) ||
58
+ (state.deferred !== undefined && !validStringList(state.deferred)) ||
59
+ (Array.isArray(state.deferred) &&
60
+ state.deferred.some((item) => state.succeeded.includes(item))))
61
+ errors.push(`${prefix}.completion requires path, field and disjoint succeeded/deferred state lists`);
62
+ else
63
+ completion = state;
64
+ }
65
+ steps.push({
66
+ id: String(raw.id),
67
+ command: String(raw.command),
68
+ ...(raw.on_failure ? { on_failure: raw.on_failure } : {}),
69
+ ...(raw.timeout_seconds !== undefined
70
+ ? { timeout_seconds: Number(raw.timeout_seconds) }
71
+ : {}),
72
+ ...(completion ? { completion } : {}),
73
+ });
74
+ }
75
+ return { ...(errors.length === 0 ? { steps } : {}), errors };
76
+ }
77
+ export function jobCommandText(task) {
78
+ return (task.steps?.map((step) => `# ${step.id}\n${step.command}`).join("\n") ?? task.command ?? "");
79
+ }
20
80
  // Same nickname shape as agent-members.schema.yaml. The roster is not loaded here, so a
21
81
  // definition only guarantees the format; an unknown nickname fails when the Run resolves
22
82
  // the agent command.
@@ -133,7 +193,8 @@ function isJobTaskDefinition(value) {
133
193
  if (value.review !== undefined && !isJobReviewDefinition(value.review))
134
194
  return false;
135
195
  if (value.mode === "command") {
136
- return (typeof value.command === "string" &&
196
+ return (((typeof value.command === "string" && value.steps === undefined) ||
197
+ (value.command === undefined && parseJobSteps(value.steps).errors.length === 0)) &&
137
198
  (value.partial_exit_code === undefined ||
138
199
  (Number.isSafeInteger(value.partial_exit_code) &&
139
200
  Number(value.partial_exit_code) >= 1 &&
@@ -377,8 +438,19 @@ export function parseJobDefinition(value, fileName) {
377
438
  };
378
439
  if (mode === "command") {
379
440
  const command = typeof value.task.command === "string" ? value.task.command.trim() : "";
380
- if (!command)
381
- errors.push("task.command is required for command mode");
441
+ const parsedSteps = value.task.steps === undefined ? undefined : parseJobSteps(value.task.steps);
442
+ if (parsedSteps)
443
+ errors.push(...parsedSteps.errors);
444
+ if ((value.task.command !== undefined) === (value.task.steps !== undefined) ||
445
+ (value.task.command !== undefined && !command))
446
+ errors.push("command mode requires exactly one of task.command or task.steps");
447
+ if (value.task.lock_wait_seconds !== undefined &&
448
+ (!parsedSteps ||
449
+ !Number.isSafeInteger(value.task.lock_wait_seconds) ||
450
+ Number(value.task.lock_wait_seconds) < 0))
451
+ errors.push("task.lock_wait_seconds must be a non-negative integer for task.steps");
452
+ if (parsedSteps && value.task.partial_exit_code !== undefined)
453
+ errors.push("task.partial_exit_code cannot be combined with task.steps");
382
454
  const partialExitCode = value.task.partial_exit_code;
383
455
  if (partialExitCode !== undefined &&
384
456
  (!Number.isSafeInteger(partialExitCode) ||
@@ -448,11 +520,14 @@ export function parseJobDefinition(value, fileName) {
448
520
  if (value.task.capabilities !== undefined || value.task.proficiency !== undefined) {
449
521
  errors.push("task.capabilities and task.proficiency are not allowed in command mode");
450
522
  }
451
- if (command)
523
+ if (command || parsedSteps?.steps)
452
524
  task = {
453
525
  mode: "command",
454
526
  ...(precondition ? { precondition } : {}),
455
- command,
527
+ ...(parsedSteps?.steps ? { steps: parsedSteps.steps } : { command }),
528
+ ...(value.task.lock_wait_seconds !== undefined
529
+ ? { lock_wait_seconds: Number(value.task.lock_wait_seconds) }
530
+ : {}),
456
531
  ...(Number.isSafeInteger(partialExitCode)
457
532
  ? { partial_exit_code: Number(partialExitCode) }
458
533
  : {}),
@@ -478,6 +553,8 @@ export function parseJobDefinition(value, fileName) {
478
553
  }
479
554
  if (value.task.analysis !== undefined ||
480
555
  value.task.command !== undefined ||
556
+ value.task.steps !== undefined ||
557
+ value.task.lock_wait_seconds !== undefined ||
481
558
  value.task.precondition !== undefined ||
482
559
  value.task.partial_exit_code !== undefined) {
483
560
  errors.push("task.command, task.precondition, task.partial_exit_code, and task.analysis are only allowed in command mode");
@@ -486,9 +563,8 @@ export function parseJobDefinition(value, fileName) {
486
563
  errors.push("task.capabilities must be a non-empty string list");
487
564
  }
488
565
  const proficiency = value.task.proficiency;
489
- if (proficiency !== undefined &&
490
- !["low", "normal", "high", "expert"].includes(String(proficiency))) {
491
- errors.push("task.proficiency must be low|normal|high|expert");
566
+ if (proficiency !== undefined && !isProficiency(proficiency)) {
567
+ errors.push(`task.proficiency must be ${PROFICIENCIES.join("|")}`);
492
568
  }
493
569
  if ((mode === "edit" || mode === "review") && description && (targets || paths)) {
494
570
  task = {
package/dist/job/job.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { registerDeprecatedWhereAlias } from "../shared/where-alias.js";
1
2
  import { spawn, spawnSync } from "node:child_process";
2
3
  import { createHash } from "node:crypto";
3
4
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@ -11,9 +12,9 @@ import { execTemplatePath, injectCommonConventions, MISSING } from "../shared/pl
11
12
  import { selfRunCommand } from "../shared/spawn-self.js";
12
13
  import { specdojoRootDir } from "../shared/specdojo-config.js";
13
14
  import { expandTemplate } from "../shared/text.js";
14
- import { getPath, isJobAgentTask, isJobCommandTask, loadAllJobs, loadJobDefinition, loadJobRunRecord, parseInputValue, parseJobInputs, renderJobTemplate, resolveJobPaths, validateJobInputValue, } from "./definition.js";
15
+ import { getPath, isJobAgentTask, isJobCommandTask, jobCommandText, loadAllJobs, loadJobDefinition, loadJobRunRecord, parseInputValue, parseJobInputs, renderJobTemplate, resolveJobPaths, validateJobInputValue, } from "./definition.js";
15
16
  import { jobNoopDirectory, localJobNoopPath } from "./noop.js";
16
- export { isJobAgentTask, isJobCommandTask, jobDeclaresReview, jobRunUsesReviewedIntegration, loadAllJobs, loadJobDefinition, loadJobRunRecord, parseJobDefinition, parseJobInputs, renderJobTemplate, resolveJobPaths, resolveJobReviewAgentNominations, } from "./definition.js";
17
+ export { jobCommandText, isJobAgentTask, isJobCommandTask, jobDeclaresReview, jobRunUsesReviewedIntegration, loadAllJobs, loadJobDefinition, loadJobRunRecord, parseJobDefinition, parseJobInputs, renderJobTemplate, resolveJobPaths, resolveJobReviewAgentNominations, } from "./definition.js";
17
18
  export function jobCheckpoint(paths, jobId) {
18
19
  return deriveJobState(paths).jobs[jobId]?.checkpoint ?? {};
19
20
  }
@@ -121,7 +122,7 @@ function commandOutputText(chunks, truncated) {
121
122
  return truncated ? text.replace(/\uFFFD$/u, "") : text;
122
123
  }
123
124
  /** Executes a materialized Job command directly in the runner process, never through an agent. */
124
- export async function executeJobCommand(command, cwd) {
125
+ export async function executeJobCommand(command, cwd, options = {}) {
125
126
  const startedAt = new Date().toISOString();
126
127
  return await new Promise((resolveResult) => {
127
128
  const stdoutChunks = [];
@@ -131,6 +132,9 @@ export async function executeJobCommand(command, cwd) {
131
132
  let stdoutTruncated = false;
132
133
  let stderrTruncated = false;
133
134
  let settled = false;
135
+ let timedOut = false;
136
+ let timeout;
137
+ let killTimeout;
134
138
  const executable = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "/bin/sh";
135
139
  const args = process.platform === "win32" ? ["/d", "/s", "/c", command] : ["-eu", "-c", command];
136
140
  const child = spawn(executable, args, {
@@ -139,7 +143,27 @@ export async function executeJobCommand(command, cwd) {
139
143
  shell: false,
140
144
  stdio: ["ignore", "pipe", "pipe"],
141
145
  windowsHide: true,
146
+ detached: options.timeoutMs !== undefined && process.platform !== "win32",
142
147
  });
148
+ const kill = (signal) => {
149
+ try {
150
+ if (process.platform !== "win32" && child.pid)
151
+ process.kill(-child.pid, signal);
152
+ else
153
+ child.kill(signal);
154
+ }
155
+ catch (error) {
156
+ if (error.code !== "ESRCH")
157
+ child.kill(signal);
158
+ }
159
+ };
160
+ if (options.timeoutMs !== undefined) {
161
+ timeout = setTimeout(() => {
162
+ timedOut = true;
163
+ kill("SIGTERM");
164
+ killTimeout = setTimeout(() => kill("SIGKILL"), 1000);
165
+ }, options.timeoutMs);
166
+ }
143
167
  child.stdout.on("data", (chunk) => {
144
168
  process.stdout.write(chunk);
145
169
  const appended = appendCommandOutput(stdoutChunks, chunk, stdoutBytes);
@@ -156,6 +180,10 @@ export async function executeJobCommand(command, cwd) {
156
180
  if (settled)
157
181
  return;
158
182
  settled = true;
183
+ clearTimeout(timeout);
184
+ clearTimeout(killTimeout);
185
+ if (timedOut)
186
+ kill("SIGKILL");
159
187
  resolveResult({
160
188
  command,
161
189
  startedAt,
@@ -166,6 +194,7 @@ export async function executeJobCommand(command, cwd) {
166
194
  stdoutTruncated,
167
195
  stderrTruncated,
168
196
  ...(error ? { error } : {}),
197
+ ...(timedOut ? { timedOut: true, error: "command timed out" } : {}),
169
198
  });
170
199
  };
171
200
  child.once("error", (error) => finish(null, error.message));
@@ -255,7 +284,7 @@ export async function generateJobPlan(paths, definition, record) {
255
284
  "runner が次の解決済みコマンドを agent の sandbox 外で直接実行する。",
256
285
  "",
257
286
  "```sh",
258
- commandTask.command,
287
+ jobCommandText(commandTask),
259
288
  "```",
260
289
  "",
261
290
  commandTask.analysis
@@ -370,7 +399,23 @@ export async function materializeJobRun(opts) {
370
399
  command: renderJobTemplate(task.precondition.command, context),
371
400
  };
372
401
  }
373
- task.command = renderJobTemplate(task.command, context);
402
+ if (task.command !== undefined)
403
+ task.command = renderJobTemplate(task.command, context);
404
+ if (task.steps) {
405
+ task.steps = task.steps.map((step) => ({
406
+ ...step,
407
+ command: renderJobTemplate(step.command, context),
408
+ ...(step.completion
409
+ ? {
410
+ completion: {
411
+ ...step.completion,
412
+ path: renderJobTemplate(step.completion.path, context),
413
+ field: renderJobTemplate(step.completion.field, context),
414
+ },
415
+ }
416
+ : {}),
417
+ }));
418
+ }
374
419
  if (task.analysis) {
375
420
  task.analysis = {
376
421
  ...task.analysis,
@@ -425,7 +470,11 @@ export async function materializeJobRun(opts) {
425
470
  plan_ref: recordRef(paths.executionPath, taskRecordPaths(paths.executionPath, runId, runId, "job").plan),
426
471
  result_ref: recordRef(paths.executionPath, taskRecordPaths(paths.executionPath, runId, runId, "job").result),
427
472
  };
428
- if (!existingRun && !opts.dryRun && isJobCommandTask(task) && task.precondition) {
473
+ if (!existingRun &&
474
+ !opts.dryRun &&
475
+ !opts.skipPrecondition &&
476
+ isJobCommandTask(task) &&
477
+ task.precondition) {
429
478
  const precondition = await executeJobPrecondition(task.precondition, specdojoRootDir());
430
479
  if (precondition.skipped) {
431
480
  return {
@@ -515,28 +564,35 @@ export function completeJobRun(opts) {
515
564
  }
516
565
  return updated;
517
566
  }
567
+ /** Persist each step immediately so a stopped runner retains its last known progress. */
568
+ export function recordJobSteps(runPath, steps) {
569
+ const record = loadJobRunRecord(runPath);
570
+ const attempt = record.attempts.at(-1);
571
+ if (!attempt)
572
+ throw new Error(`Job Run has no attempt: ${record.run_id}`);
573
+ attempt.steps = steps;
574
+ record.updated_at = new Date().toISOString();
575
+ writeJson(runPath, record);
576
+ }
518
577
  export function jobRunRelativePath(runPath) {
519
578
  return repoRelative(runPath);
520
579
  }
580
+ export function printJobPaths(opts) {
581
+ try {
582
+ const paths = resolveJobPaths(opts.project);
583
+ process.stdout.write(`project: ${paths.projectId}\n`);
584
+ process.stdout.write(`jobs: ${paths.jobsPath}\n`);
585
+ process.stdout.write(`runs: ${paths.runsPath}\n`);
586
+ process.stdout.write(`state: ${paths.statePath}\n`);
587
+ }
588
+ catch (error) {
589
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
590
+ process.exitCode = 1;
591
+ }
592
+ }
521
593
  export function registerJobCommands(program) {
522
594
  const command = program.command("job").description("Reusable Job Definition and Run helpers");
523
- command
524
- .command("where")
525
- .description("Print resolved Job paths")
526
- .option("--project <projectId>", "Project id")
527
- .action((opts) => {
528
- try {
529
- const paths = resolveJobPaths(opts.project);
530
- process.stdout.write(`project: ${paths.projectId}\n`);
531
- process.stdout.write(`jobs: ${paths.jobsPath}\n`);
532
- process.stdout.write(`runs: ${paths.runsPath}\n`);
533
- process.stdout.write(`state: ${paths.statePath}\n`);
534
- }
535
- catch (error) {
536
- process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
537
- process.exitCode = 1;
538
- }
539
- });
595
+ registerDeprecatedWhereAlias(command, printJobPaths);
540
596
  command
541
597
  .command("validate")
542
598
  .description("Validate job-*.yaml definitions")
@@ -1,6 +1,5 @@
1
- import { existsSync, realpathSync, statSync } from "node:fs";
1
+ import { existsSync, globSync, realpathSync, statSync } from "node:fs";
2
2
  import { extname, isAbsolute, posix, relative, resolve, sep } from "node:path";
3
- import { globSync } from "tinyglobby";
4
3
  import { collectDocIndexEntries } from "../docs/doc-index.js";
5
4
  import { getProjectRepos, resolveRepoQualifiedRef, resolveRepoRoot, } from "../shared/specdojo-config.js";
6
5
  // A bounded source set keeps generated plans reviewable and prevents a broad glob from handing an
@@ -28,6 +27,23 @@ function assertInsideRoot(root, path, ref) {
28
27
  throw new Error(`Authoring source resolves outside its repository: ${ref}`);
29
28
  }
30
29
  }
30
+ const IGNORED_SOURCE_DIRECTORIES = new Set([".git", "node_modules"]);
31
+ function isExcludedSourceEntry(entry) {
32
+ if (entry.isSymbolicLink())
33
+ return true;
34
+ return entry.isDirectory() && IGNORED_SOURCE_DIRECTORIES.has(entry.name);
35
+ }
36
+ /**
37
+ * Lists regular files matching the patterns as slash-separated paths relative to `cwd`.
38
+ * node:fs globSync skips dot entries unless a pattern names them; symbolic links found while
39
+ * walking, `.git`, and `node_modules` are excluded.
40
+ */
41
+ function globSourceFiles(patterns, cwd) {
42
+ const root = resolve(cwd);
43
+ return globSync(patterns, { cwd: root, withFileTypes: true, exclude: isExcludedSourceEntry })
44
+ .filter((entry) => entry.isFile())
45
+ .map((entry) => relative(root, resolve(entry.parentPath, entry.name)).replaceAll("\\", "/"));
46
+ }
31
47
  function expandPath(root, rawPath, ref) {
32
48
  if (!existsSync(root) || !statSync(root).isDirectory()) {
33
49
  throw new Error(`Repository root for authoring source does not exist: ${ref}`);
@@ -38,26 +54,16 @@ function expandPath(root, rawPath, ref) {
38
54
  if (existsSync(exact)) {
39
55
  assertInsideRoot(root, exact, ref);
40
56
  if (statSync(exact).isDirectory()) {
41
- paths = globSync("**/*", {
42
- cwd: exact,
43
- onlyFiles: true,
44
- dot: false,
45
- followSymbolicLinks: false,
46
- ignore: ["**/.git/**", "**/node_modules/**"],
47
- }).map((entry) => posix.join(normalized, entry.replaceAll("\\", "/")));
57
+ paths = globSourceFiles(["**/*"], exact).map((entry) => posix.join(normalized, entry));
48
58
  }
49
59
  else {
50
60
  paths = [normalized];
51
61
  }
52
62
  }
53
63
  else {
54
- paths = globSync(normalized, {
55
- cwd: root,
56
- onlyFiles: true,
57
- dot: false,
58
- followSymbolicLinks: false,
59
- ignore: ["**/.git/**", "**/node_modules/**"],
60
- }).map((entry) => entry.replaceAll("\\", "/"));
64
+ // A pattern that does not end with "*" also matches the files below a matching directory.
65
+ const patterns = normalized.endsWith("*") ? [normalized] : [normalized, `${normalized}/**`];
66
+ paths = globSourceFiles(patterns, root);
61
67
  }
62
68
  const sorted = [...new Set(paths)].sort();
63
69
  if (sorted.length === 0) {
@@ -72,8 +72,8 @@ export function registerMaintenanceCommands(reg, dependencies) {
72
72
  });
73
73
  // --- build ---
74
74
  const buildCmd = reg
75
- .command("build")
76
- .description("Generate the register list and derived views from register item files");
75
+ .command("build", { hidden: true })
76
+ .description("Internal compatibility entry for build --only register");
77
77
  addProjectOption(buildCmd);
78
78
  buildCmd.option("--scope <scope>", "Generation scope: register | controls | all", "all");
79
79
  buildCmd.option("--dry-run", "Print generated content without writing", false);
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
2
2
  import { relative, sep } from "node:path";
3
3
  import { setImmediate } from "node:timers/promises";
4
4
  import { CrossProcessMutex } from "../shared/cross-process-lock.js";
5
- import { gitOutput, gitResult, repoRelative, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "../shared/git.js";
5
+ import { gitOutput, gitResult, repoRelative, restoreIndexAfterPathspecCommit, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "../shared/git.js";
6
6
  import { inlineCodeAnglePlaceholders } from "../shared/text.js";
7
7
  import { atomicWriteFile, buildRegisterItemContent, derivedTopicNeedsWarning, generatePjrId, printDerivedTopicWarning, registerEventActor, REGISTER_TOPIC_RE, resolveRegisterPaths, slugify, validateFields, } from "./core.js";
8
8
  import { registerCreateCommands, registerUpdateCommand } from "./create-commands.js";
@@ -72,7 +72,20 @@ function assertRegisterItemCommitTargetsClean(context, view) {
72
72
  function addRegisterCommitOptions(cmd) {
73
73
  return cmd
74
74
  .option("--commit", "Take the register lifecycle lock, rebuild views, and commit only this command's changes", false)
75
- .option("-m, --message <message>", "Override the register commit message");
75
+ .option("-m, --message <message>", "Override the register commit message (repeatable; each value becomes a paragraph, as in git commit -m)", collectRegisterCommitMessage);
76
+ }
77
+ // commander は値付きオプションの繰り返しを最後の値で上書きする。`-m <subject> -m <body>` の
78
+ // subject が失われて body だけが commit message になり、commitlint に拒否されていた(PJR-Y3XS)。
79
+ function collectRegisterCommitMessage(value, previous) {
80
+ return [...(previous ?? []), value];
81
+ }
82
+ // git commit -m と同じく、空でない各値を段落として空行でつなぐ。
83
+ export function registerCommitMessageFromParagraphs(paragraphs) {
84
+ const text = (paragraphs ?? [])
85
+ .map((paragraph) => paragraph.trim())
86
+ .filter((paragraph) => paragraph !== "")
87
+ .join("\n\n");
88
+ return text === "" ? undefined : text;
76
89
  }
77
90
  const REGISTER_COMMIT_SUBJECT_MAX_LENGTH = 100;
78
91
  const REGISTER_COMMIT_STABILIZATION_ATTEMPTS = 3;
@@ -130,6 +143,7 @@ async function commitRegisterMutation(repoRoot, paths, command, result, preexist
130
143
  if (interrupted)
131
144
  throw new Error(`Register commit interrupted by ${interrupted}; staged changes rolled back.`);
132
145
  };
146
+ let committed = false;
133
147
  try {
134
148
  stageCommitTargets(repoRoot, changed);
135
149
  await checkInterruption();
@@ -140,11 +154,13 @@ async function commitRegisterMutation(repoRoot, paths, command, result, preexist
140
154
  }
141
155
  if (staged.status !== 1)
142
156
  throw new Error("Failed to inspect staged register changes.");
143
- const commitMessage = message?.trim() || defaultRegisterCommitMessage(command, result);
144
- if (commitMessage === "")
145
- throw new Error("Register commit message must not be empty");
157
+ const commitMessage = registerCommitMessageFromParagraphs(message) ?? defaultRegisterCommitMessage(command, result);
146
158
  // --only は初回・amend とも指定し、開始前からある staged 変更を混ぜない。
147
159
  gitOutput(repoRoot, ["commit", "--only", "-m", commitMessage, "--", ...changed]);
160
+ committed = true;
161
+ // hook の整形は一時 index にだけ入る。HEAD と一致した対象を index でも HEAD へ戻し、
162
+ // 整形前の内容を staged のまま残さない(PJR-Y3XS)。
163
+ restoreIndexAfterPathspecCommit(repoRoot, changed);
148
164
  await checkInterruption();
149
165
  for (let attempt = 0; attempt < REGISTER_COMMIT_STABILIZATION_ATTEMPTS; attempt++) {
150
166
  const remaining = worktreeStatusPaths(repoRoot).filter((path) => changed.includes(path));
@@ -156,6 +172,7 @@ async function commitRegisterMutation(repoRoot, paths, command, result, preexist
156
172
  stageCommitTargets(repoRoot, remaining);
157
173
  await checkInterruption();
158
174
  gitOutput(repoRoot, ["commit", "--only", "--amend", "--no-edit", "--", ...remaining]);
175
+ restoreIndexAfterPathspecCommit(repoRoot, remaining);
159
176
  await checkInterruption();
160
177
  }
161
178
  const remaining = worktreeStatusPaths(repoRoot).filter((path) => changed.includes(path));
@@ -171,13 +188,20 @@ async function commitRegisterMutation(repoRoot, paths, command, result, preexist
171
188
  // changed は開始前に clean だった対象だけ。本文を残して、自分の stage だけを戻す。
172
189
  unstageCommitTargets(repoRoot, changed);
173
190
  await setImmediate();
174
- throw error;
191
+ if (committed)
192
+ throw error;
193
+ // 記帳は作業ツリーに残り commit だけが無い。最後の行に結果が出るよう、原因の後に状態を書く。
194
+ const cause = error instanceof Error ? error.message : String(error);
195
+ throw new Error(`Register commit failed for ${result.id}: ${cause}\n` +
196
+ `The register changes were written but not committed:\n` +
197
+ changed.map((path) => ` ${path}`).join("\n"), { cause: error });
175
198
  }
176
199
  finally {
177
200
  signals.forEach((signal, index) => process.removeListener(signal, handlers[index]));
178
201
  }
179
202
  }
180
- async function runRegisterMutationInCurrentWorktree(command, opts, mutate, requireCleanRegister) {
203
+ // Throws on failure so composite commands can stop before the next lifecycle step.
204
+ export async function runRegisterMutationInCurrentWorktree(command, opts, mutate, requireCleanRegister = false) {
181
205
  const paths = resolveRegisterPaths(opts);
182
206
  if (!opts.commit || opts.dryRun) {
183
207
  mutate({ paths, assertCommitTargetsClean: () => undefined });
@@ -34,6 +34,15 @@ export function isRoutineDue(doc, lastRun, now) {
34
34
  return true;
35
35
  return now.getTime() - last.getTime() >= parseIntervalMs(doc.interval);
36
36
  }
37
+ // state 込みの due 判定。busy skip の流し直し待ち(busy_skip_count が正)の interval routine は
38
+ // interval の経過を待たずに due とする。cron は last_scheduled_for を進めないことで流し直す。
39
+ export function isRoutineEntryDue(doc, entry, now) {
40
+ if (doc.trigger)
41
+ return cronOccurrences(doc, entry?.last_scheduled_for, now).length > 0;
42
+ if ((entry?.busy_skip_count ?? 0) > 0)
43
+ return true;
44
+ return isRoutineDue(doc, entry?.last_run, now);
45
+ }
37
46
  function parseCronField(text, min, max, label) {
38
47
  const result = new Set();
39
48
  for (const token of text.split(",")) {