specdojo 0.3.1 → 0.4.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 (260) hide show
  1. package/.github/agents/specdojo-orchestrator.md +61 -2
  2. package/CHANGELOG.md +90 -0
  3. package/README.md +85 -25
  4. package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
  5. package/dist/catalog/build-render.js +32 -0
  6. package/dist/{catalog-build.js → catalog/build.js} +9 -9
  7. package/dist/{catalog.js → catalog/catalog.js} +10 -10
  8. package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
  9. package/dist/catalog/paths.js +1 -0
  10. package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
  11. package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
  12. package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
  13. package/dist/{agent.js → commands/agent.js} +11 -11
  14. package/dist/{build-command.js → commands/build.js} +2 -2
  15. package/dist/{init-command.js → commands/init.js} +168 -45
  16. package/dist/commands/night-orchestrator.js +287 -0
  17. package/dist/{orchestrator.js → commands/orchestrator.js} +12 -5
  18. package/dist/{watch.js → commands/watch.js} +3 -3
  19. package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
  20. package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
  21. package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
  22. package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
  23. package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
  24. package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
  25. package/dist/{timeline.js → dashboard/timeline.js} +1 -1
  26. package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
  27. package/dist/{deliverable-trash.js → deliverable/trash.js} +5 -5
  28. package/dist/{devcontainer-command.js → devcontainer/command.js} +8 -4
  29. package/dist/devcontainer/scaffold.js +418 -0
  30. package/dist/{doc-index.js → docs/doc-index.js} +1 -1
  31. package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
  32. package/dist/{index-command.js → docs/index-command.js} +1 -1
  33. package/dist/docs/template-resolution.js +1 -0
  34. package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +1 -1
  35. package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
  36. package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
  37. package/dist/{exec-agent-config.js → exec/agent-config.js} +92 -5
  38. package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
  39. package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
  40. package/dist/{exec-commands.js → exec/commands.js} +22 -18
  41. package/dist/{exec-core.js → exec/core.js} +11 -11
  42. package/dist/{exec-events.js → exec/events.js} +2 -2
  43. package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
  44. package/dist/exec/exec.js +2 -0
  45. package/dist/exec/format.js +1 -0
  46. package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
  47. package/dist/{exec-limit.js → exec/limit.js} +93 -12
  48. package/dist/{exec-parent-validation.js → exec/parent-validation.js} +18 -4
  49. package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +29 -2
  50. package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
  51. package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
  52. package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
  53. package/dist/{exec-plans.js → exec/plans.js} +3 -3
  54. package/dist/{exec-project.js → exec/project.js} +1 -1
  55. package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
  56. package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
  57. package/dist/{exec-register.js → exec/register.js} +114 -9
  58. package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
  59. package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
  60. package/dist/{exec-repo-integration.js → exec/repo-integration.js} +14 -11
  61. package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
  62. package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
  63. package/dist/{exec-reporter.js → exec/reporter.js} +142 -25
  64. package/dist/{exec-results.js → exec/results.js} +287 -31
  65. package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +35 -12
  66. package/dist/{exec-run-agent.js → exec/run/agent.js} +115 -28
  67. package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
  68. package/dist/{exec-run-job.js → exec/run/job.js} +65 -36
  69. package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
  70. package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
  71. package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
  72. package/dist/{exec-run-register-command.js → exec/run/register-command.js} +38 -11
  73. package/dist/{exec-run-register-core.js → exec/run/register-core.js} +63 -21
  74. package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +58 -31
  75. package/dist/exec/run/register-post-review.js +420 -0
  76. package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +48 -27
  77. package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
  78. package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +119 -24
  79. package/dist/{exec-run.js → exec/run/run.js} +11 -11
  80. package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
  81. package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
  82. package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
  83. package/dist/{exec-run-shared.js → exec/run/shared.js} +78 -30
  84. package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
  85. package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
  86. package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
  87. package/dist/exec/schedule/gantt-chart.js +2 -0
  88. package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
  89. package/dist/exec/schedule/index.js +1 -0
  90. package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
  91. package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
  92. package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
  93. package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
  94. package/dist/exec/shared.js +63 -0
  95. package/dist/exec/slot-lock.js +1 -0
  96. package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
  97. package/dist/{exec-task-repos.js → exec/task-repos.js} +104 -17
  98. package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
  99. package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
  100. package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
  101. package/dist/{exec-trial.js → exec/trial.js} +2 -2
  102. package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
  103. package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
  104. package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
  105. package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
  106. package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
  107. package/dist/exec/worktree.js +305 -0
  108. package/dist/{grade-apply.js → grade/apply.js} +9 -9
  109. package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
  110. package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
  111. package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
  112. package/dist/{grade-core.js → grade/core.js} +3 -3
  113. package/dist/grade/grade.js +19 -0
  114. package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
  115. package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
  116. package/dist/{grade-plan.js → grade/plan.js} +5 -5
  117. package/dist/{grade-result.js → grade/result.js} +5 -94
  118. package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
  119. package/dist/{grade-targets.js → grade/targets.js} +11 -8
  120. package/dist/{job-definition.js → job/definition.js} +25 -6
  121. package/dist/{job.js → job/job.js} +12 -11
  122. package/dist/{kata-command.js → kata/command.js} +3 -3
  123. package/dist/{kata.js → kata/kata.js} +5 -5
  124. package/dist/register/approach.js +134 -0
  125. package/dist/{register-core.js → register/core.js} +26 -8
  126. package/dist/{register-create-commands.js → register/create-commands.js} +171 -8
  127. package/dist/{register-date.js → register/date.js} +1 -1
  128. package/dist/register/derivation.js +163 -0
  129. package/dist/{register-event-merge.js → register/event-merge.js} +44 -3
  130. package/dist/{register-events.js → register/events.js} +13 -3
  131. package/dist/{register-history.js → register/history.js} +7 -6
  132. package/dist/{register-item.js → register/item.js} +32 -5
  133. package/dist/register/lifecycle-lock.js +5 -0
  134. package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
  135. package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
  136. package/dist/{register-migration.js → register/migration.js} +5 -4
  137. package/dist/{register.js → register/register.js} +32 -27
  138. package/dist/{register-renumber.js → register/renumber.js} +38 -11
  139. package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
  140. package/dist/{register-update.js → register/update.js} +5 -5
  141. package/dist/{register-views.js → register/views.js} +47 -7
  142. package/dist/{review-grade.js → review/grade.js} +2 -2
  143. package/dist/{review-plan.js → review/plan.js} +3 -3
  144. package/dist/{routine-definition.js → routine/definition.js} +2 -2
  145. package/dist/{routine.js → routine/routine.js} +49 -22
  146. package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
  147. package/dist/{schedule-build.js → schedule/build.js} +7 -4
  148. package/dist/{schedule.js → schedule/schedule.js} +6 -6
  149. package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
  150. package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
  151. package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
  152. package/dist/shared/agent-types.js +23 -0
  153. package/dist/shared/artifact-path.js +9 -0
  154. package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
  155. package/dist/{catalog-build-render.js → shared/catalog-render.js} +3 -32
  156. package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
  157. package/dist/shared/fs.js +30 -0
  158. package/dist/shared/git.js +346 -0
  159. package/dist/shared/grade-result.js +94 -0
  160. package/dist/{package-paths.js → shared/package-paths.js} +3 -3
  161. package/dist/shared/plan-templates.js +114 -0
  162. package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +6 -3
  163. package/dist/shared/random.js +4 -0
  164. package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
  165. package/dist/shared/schedule-paths.js +9 -0
  166. package/dist/{specdojo-config.js → shared/specdojo-config.js} +162 -21
  167. package/dist/{exec-shared.js → shared/text.js} +4 -135
  168. package/dist/shared/time.js +28 -0
  169. package/dist/shared/workspace-scaffold.js +69 -0
  170. package/dist/specdojo.js +22 -22
  171. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +31 -18
  172. package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
  173. package/docs/ja/specdojo/exec-templates/xep-register-template.md +3 -2
  174. package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
  175. package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
  176. package/docs/ja/specdojo/exec-templates/xrp-register-post-run-template.md +46 -0
  177. package/docs/ja/specdojo/guides/branch-workflow-guide.md +34 -1
  178. package/docs/ja/specdojo/guides/docs-structure-guide.md +2 -0
  179. package/docs/ja/specdojo/guides/exec-config-guide.md +169 -26
  180. package/docs/ja/specdojo/guides/exec-operation-guide.md +184 -13
  181. package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
  182. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +40 -3
  183. package/docs/ja/specdojo/guides/quick-start-guide.md +89 -21
  184. package/docs/ja/specdojo/guides/register-operation-guide.md +44 -1
  185. package/docs/ja/specdojo/guides/remote-host-development-guide.md +61 -6
  186. package/docs/ja/specdojo/guides/review-guide.md +1 -1
  187. package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
  188. package/docs/ja/specdojo/guides/specdojo-overview-guide.md +1 -1
  189. package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
  190. package/docs/ja/specdojo/guides/waza-guide.md +1 -1
  191. package/docs/ja/specdojo/references/command-reference.md +124 -55
  192. package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
  193. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +22 -13
  194. package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
  195. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
  196. package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
  197. package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
  198. package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
  199. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +111 -17
  200. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +28 -0
  201. package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
  202. package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
  203. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +38 -0
  204. package/docs/specdojo/schemas/v1/register-events.schema.yaml +5 -0
  205. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +91 -7
  206. package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
  207. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +36 -1
  208. package/package.json +17 -17
  209. package/templates/antigravity/README.md +6 -2
  210. package/templates/antigravity/agent-members-snippet.yaml +108 -12
  211. package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
  212. package/templates/antigravity/orchestrator.md +61 -2
  213. package/templates/claude/README.md +27 -3
  214. package/templates/claude/agents/claude-executor.md +0 -1
  215. package/templates/claude/agents/claude-reporter.md +2 -1
  216. package/templates/claude/agents/claude-review-executor.md +0 -1
  217. package/templates/claude/agents/specdojo-orchestrator.md +61 -2
  218. package/templates/codex/README.md +40 -4
  219. package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
  220. package/templates/codex/orchestrator.md +61 -2
  221. package/templates/devcontainer/devcontainer.json +5 -2
  222. package/templates/devcontainer/post-create.sh +15 -7
  223. package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +102 -0
  224. package/templates/devcontainer/remote-host/ssh-config.sample +19 -0
  225. package/templates/devcontainer/vim/vimrc +37 -0
  226. package/templates/init-agent-members.yaml +75 -25
  227. package/templates/init-exec-defaults.yaml +44 -9
  228. package/templates/opencode/README.md +17 -3
  229. package/templates/opencode/agents/opencode-executor.md +0 -1
  230. package/templates/opencode/agents/opencode-reporter.md +2 -1
  231. package/templates/opencode/agents/opencode-review-executor.md +0 -1
  232. package/templates/opencode/agents/specdojo-orchestrator.md +61 -2
  233. package/dist/devcontainer-scaffold.js +0 -165
  234. package/dist/exec-schedule-gantt-chart.js +0 -2
  235. package/dist/exec-worktree.js +0 -474
  236. package/dist/exec.js +0 -2
  237. package/dist/grade.js +0 -19
  238. package/templates/claude/agents/claude-expert-review-executor.md +0 -14
  239. /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
  240. /package/dist/{catalog-types.js → catalog/types.js} +0 -0
  241. /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
  242. /package/dist/{role-types.js → exec/role-types.js} +0 -0
  243. /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
  244. /package/dist/{exec-types.js → exec/types.js} +0 -0
  245. /package/dist/{grade-command-shared.js → grade/command-shared.js} +0 -0
  246. /package/dist/{register-command-types.js → register/command-types.js} +0 -0
  247. /package/dist/{review-types.js → review/types.js} +0 -0
  248. /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
  249. /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
  250. /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
  251. /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
  252. /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
  253. /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
  254. /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
  255. /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
  256. /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
  257. /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
  258. /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
  259. /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
  260. /package/dist/{yaml.js → shared/yaml.js} +0 -0
@@ -1,14 +1,66 @@
1
1
  import { basename, resolve } from "node:path";
2
- import { defaultExecDefaultsPath, hasMemberCommandSource, loadExecDefaultsConfig, resolveMaxConcurrentRuns, resolveMemberCommand, resolveRegisterExecution, } from "./exec-agent-config.js";
3
- import { resolveProjectPaths } from "./exec-project.js";
4
- import { buildInitialStateFromStrategy } from "./exec-schedule-initial.js";
5
- import { buildScheduleIndex } from "./exec-schedule.js";
6
- import { listFilesRecursive, readYaml } from "./exec-shared.js";
7
- import { getProjectSchedulePath, loadConfig, specdojoRootDir, } from "./specdojo-config.js";
8
- import { acquireExecRunLock, EXEC_RUN_LOCK_TOKEN_ENV, execLocksDir, inheritsExecRunLock, releaseExecRunLock, ROUTINE_BUSY_SKIP_EXIT_CODE, ROUTINE_EXEC_ENV, } from "./exec-run-lock.js";
9
- import { getActiveExecLocksDir, setActiveExecLocksDir } from "./exec-slot-lock.js";
10
- import { readAllEventFiles, foldEventsToState } from "./exec-events.js";
11
- import { extractPhaseSuffix, normalizePhaseSetSelection, phaseSetNames, } from "./schedule-phase-sets.js";
2
+ import { defaultExecDefaultsPath, hasMemberCommandSource, loadExecDefaultsConfig, resolveMaxConcurrentRuns, resolveMemberCommand, resolveRegisterExecution, resolvePinnedRateLimitPolicy, } from "../agent-config.js";
3
+ import { resolveProjectPaths } from "../project.js";
4
+ import { buildInitialStateFromStrategy } from "../schedule/initial.js";
5
+ import { buildScheduleIndex } from "../schedule/schedule.js";
6
+ import { listFilesRecursive, readYaml } from "../shared.js";
7
+ import { getProjectSchedulePath, loadConfig, resolveAgentMember, specdojoRootDir, } from "../../shared/specdojo-config.js";
8
+ import { acquireExecRunLock, EXEC_RUN_LOCK_TOKEN_ENV, execLocksDir, inheritsExecRunLock, releaseExecRunLock, ROUTINE_BUSY_SKIP_EXIT_CODE, ROUTINE_EXEC_ENV, } from "./lock.js";
9
+ import { getActiveExecLocksDir, setActiveExecLocksDir } from "../slot-lock.js";
10
+ import { readAllEventFiles, foldEventsToState } from "../events.js";
11
+ import { extractPhaseSuffix, normalizePhaseSetSelection, phaseSetNames, } from "../../schedule/phase-sets.js";
12
+ export function rateLimitRecoveryReason(events) {
13
+ return events
14
+ .map((event) => event.action === "wait"
15
+ ? `rate limit wait: ${event.to_actor} resumed at ${event.resumed_at}`
16
+ : event.trigger === "connection_error"
17
+ ? `connection error fallback: ${event.from_actor} -> ${event.to_actor} at ${event.resumed_at}`
18
+ : `rate limit fallback: ${event.from_actor} -> ${event.to_actor} at ${event.resumed_at}`)
19
+ .join("; ");
20
+ }
21
+ export function isPinnedRateLimitAction(value) {
22
+ return value === "stop" || value === "wait" || value === "fallback";
23
+ }
24
+ /**
25
+ * Resolve CLI-over-config recovery for one pinned pipeline stage. A fallback nickname is resolved
26
+ * independently of --on-rate-limit because the same candidate also handles configured connection
27
+ * failures. A rate-limit fallback action without a nickname still degrades to stop.
28
+ */
29
+ export function resolvePinnedRateLimitRunOptions(opts, execDefaults, roster, stageRole, primary) {
30
+ const configured = resolvePinnedRateLimitPolicy(execDefaults, primary.provider);
31
+ const requested = opts.onRateLimit;
32
+ if (requested !== undefined && !isPinnedRateLimitAction(requested)) {
33
+ throw new Error(`--on-rate-limit must be "stop", "wait", or "fallback": ${requested}`);
34
+ }
35
+ const action = requested ?? configured.action;
36
+ const nickname = stageRole === "executor"
37
+ ? (opts.fallbackExecutorBy ?? configured.fallbackExecutorBy)
38
+ : (opts.fallbackReporterBy ?? configured.fallbackReporterBy);
39
+ if (!nickname) {
40
+ return {
41
+ action: action === "fallback" ? "stop" : action,
42
+ maxWaitSeconds: configured.maxWaitSeconds,
43
+ };
44
+ }
45
+ const resolution = resolveAgentOverride("edit", nickname, {}, roster, execDefaults, stageRole);
46
+ if (resolution.kind !== "command") {
47
+ const flag = stageRole === "executor" ? "--fallback-executor-by" : "--fallback-reporter-by";
48
+ const detail = resolution.kind === "error" ? resolution.message : `agent not found: ${nickname}`;
49
+ throw new Error(`${flag}: ${detail.replace(/^--by/, flag)}`);
50
+ }
51
+ if (resolution.actor === primary.actor) {
52
+ throw new Error(`Fallback ${stageRole} must differ from the pinned agent: ${nickname}`);
53
+ }
54
+ return {
55
+ action,
56
+ maxWaitSeconds: configured.maxWaitSeconds,
57
+ fallbackCandidate: {
58
+ command: resolution.command,
59
+ actor: resolution.actor ?? nickname,
60
+ provider: resolution.provider,
61
+ },
62
+ };
63
+ }
12
64
  export function pinnedExecutor(task) {
13
65
  return typeof task?.agent === "string" ? task.agent : task?.agent?.executor;
14
66
  }
@@ -24,7 +76,7 @@ export function resolveAgentOverride(mode, agentNicknameOverride, modeAgentOverr
24
76
  if (!nickname)
25
77
  return { kind: "none" };
26
78
  const flag = agentNicknameOverride ? "--by" : mode === "review" ? "--review-by" : "--edit-by";
27
- const member = roster?.members.find((m) => m.type === "agent" && m.nickname === nickname);
79
+ const member = resolveAgentMember(roster, nickname);
28
80
  if (member && stageRole !== undefined && member.stage_role !== stageRole) {
29
81
  return {
30
82
  kind: "error",
@@ -252,30 +304,26 @@ export function collectBusyActors(schedulePath) {
252
304
  return busy;
253
305
  }
254
306
  export function isRateLimitError(exitCode, output, detection) {
307
+ // `output` is combined stdout+stderr because some CLIs print failures to stdout. Successful
308
+ // output is ignored by default so quoted configuration/examples do not become false positives.
309
+ return isConfiguredAgentError(exitCode, output, detection);
310
+ }
311
+ export function isConnectionError(exitCode, output, detection) {
312
+ return isConfiguredAgentError(exitCode, output, detection);
313
+ }
314
+ function isConfiguredAgentError(exitCode, output, detection) {
255
315
  if (!detection)
256
316
  return false;
257
- // exit_codes is a standalone signal: an exact configured code identifies a rate limit
258
- // on its own. Keep this list minimal (see exec-defaults.yaml) since generic codes like 1
259
- // also mean ordinary failure.
260
317
  if (detection.exit_codes && exitCode !== null && detection.exit_codes.includes(exitCode)) {
261
318
  return true;
262
319
  }
263
- if (detection.stderr_patterns) {
264
- // `output` is the agent's combined stdout+stderr: some CLIs print the limit notice to
265
- // stdout, not stderr (e.g. claude's "You've hit your session limit"), so scanning stderr
266
- // alone misses it. By default a pattern only counts when the process also failed (non-zero
267
- // or null exit). A successful run (exit 0) that merely echoes the phrase — e.g. an agent
268
- // editing a file containing the literal text "rate limit" — is not a rate limit.
269
- const requireNonzeroExit = detection.stderr_requires_nonzero_exit ?? true;
270
- if (!requireNonzeroExit || exitCode !== 0) {
271
- const lower = output.toLowerCase();
272
- for (const pattern of detection.stderr_patterns) {
273
- if (lower.includes(pattern.toLowerCase()))
274
- return true;
275
- }
276
- }
277
- }
278
- return false;
320
+ if (!detection.stderr_patterns)
321
+ return false;
322
+ const requireNonzeroExit = detection.stderr_requires_nonzero_exit ?? true;
323
+ if (requireNonzeroExit && exitCode === 0)
324
+ return false;
325
+ const lower = output.toLowerCase();
326
+ return detection.stderr_patterns.some((pattern) => lower.includes(pattern.toLowerCase()));
279
327
  }
280
328
  export function resolveExecDefaultsPath(opts, schedulePath) {
281
329
  if (opts.execDefaults)
@@ -1,4 +1,4 @@
1
- import { formatDateOnlyUtc } from "./exec-shared.js";
1
+ import { formatDateOnlyUtc } from "../shared.js";
2
2
  function scheduleAnchorDateUtc() {
3
3
  return Date.UTC(2000, 0, 1, 0, 0, 0, 0);
4
4
  }
@@ -1,5 +1,5 @@
1
- import { toArtifactPath, toScheduleFilePath } from "./exec-shared.js";
2
- import { workingDayOffsetForDate } from "./exec-schedule-calendar.js";
1
+ import { toArtifactPath, toScheduleFilePath } from "../shared.js";
2
+ import { workingDayOffsetForDate } from "./calendar.js";
3
3
  export function topoSort(schedule) {
4
4
  const indeg = new Map();
5
5
  const out = new Map();
@@ -1,5 +1,5 @@
1
- import { formatDateOnlyUtc, formatDays } from "./exec-shared.js";
2
- import { buildWorkingTaskSegments, dateForWorkingOffset, ganttChartStartDate, isWorkingDateUtc, workingMinutesPerDay, } from "./exec-schedule-calendar.js";
1
+ import { formatDateOnlyUtc, formatDays } from "../shared.js";
2
+ import { buildWorkingTaskSegments, dateForWorkingOffset, ganttChartStartDate, isWorkingDateUtc, workingMinutesPerDay, } from "./calendar.js";
3
3
  function xmlEscape(text) {
4
4
  return text
5
5
  .replace(/&/g, "&")
@@ -0,0 +1,2 @@
1
+ export { buildGanttChartMarkdown, buildGanttChartSvg } from "./gantt-chart-render.js";
2
+ export { buildProgressSummaryLines } from "./progress.js";
@@ -1,8 +1,8 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { existsSync, writeFileSync } from "node:fs";
3
3
  import { basename, join } from "node:path";
4
- import { ensureDir, isRecord, isStringArray, readJson, toArtifactPath, toScheduleFilePath, writeJson, } from "./exec-shared.js";
5
- import { generatedDirForProject } from "./exec-project.js";
4
+ import { ensureDir, isRecord, isStringArray, readJson, toArtifactPath, toScheduleFilePath, writeJson, } from "../shared.js";
5
+ import { generatedDirForProject } from "../project.js";
6
6
  function isScheduleHash(value) {
7
7
  return (isRecord(value) &&
8
8
  value.schema_version === 1 &&
@@ -0,0 +1 @@
1
+ export * from "../../shared/schedule-index.js";
@@ -1,5 +1,5 @@
1
- import { listFilesRecursive, normalizeDateOnly, readYaml } from "./exec-shared.js";
2
- import { expandPhaseSetSelection, normalizePhaseSetSelection, } from "./schedule-phase-sets.js";
1
+ import { listFilesRecursive, normalizeDateOnly, readYaml } from "../shared.js";
2
+ import { expandPhaseSetSelection, normalizePhaseSetSelection, } from "../../schedule/phase-sets.js";
3
3
  export function buildInitialStateFromStrategy(schedulePath, schedule) {
4
4
  const initial = {};
5
5
  const strategyFiles = listFilesRecursive(schedulePath).filter((f) => /sch-strategy-.*\.(yaml|yml)$/.test(f));
@@ -1,5 +1,5 @@
1
- import { formatDateOnlyUtc } from "./exec-shared.js";
2
- import { dateForWorkingOffset, isWorkingDateUtc } from "./exec-schedule-calendar.js";
1
+ import { formatDateOnlyUtc } from "../shared.js";
2
+ import { dateForWorkingOffset, isWorkingDateUtc } from "./calendar.js";
3
3
  function parseDateOnlyUtc(value) {
4
4
  const [year, month, day] = value.split("-").map(Number);
5
5
  return new Date(Date.UTC(year, month - 1, day, 0, 0, 0, 0));
@@ -1,7 +1,7 @@
1
1
  import { writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { executionRootForProject, generatedDirForProject } from "./exec-project.js";
4
- import { ensureDir, formatDays, isRecord, isStringArray, readJson, toArtifactPath, toScheduleFilePath, writeJson, } from "./exec-shared.js";
3
+ import { executionRootForProject, generatedDirForProject } from "../project.js";
4
+ import { ensureDir, formatDays, isRecord, isStringArray, readJson, toArtifactPath, toScheduleFilePath, writeJson, } from "../shared.js";
5
5
  function isStrategyOrder(value) {
6
6
  return (isRecord(value) &&
7
7
  (typeof value.next_task_id === "string" || value.next_task_id === null) &&
@@ -1,16 +1,16 @@
1
1
  import { existsSync, statSync, writeFileSync } from "node:fs";
2
2
  import { basename, extname, join } from "node:path";
3
- import { computeReadyIds, foldEventsToState, isExecEventV1, validateEventShape, } from "./exec-events.js";
4
- import { ensureDir, formatDays, listFilesRecursive, readJson, toArtifactPath, toScheduleFilePath, writeJson, } from "./exec-shared.js";
5
- import { eventsDirForProject, executionRootForProject, generatedDirForProject, } from "./exec-project.js";
6
- import { buildGanttChartMarkdown, buildGanttChartSvg, buildProgressSummaryLines, } from "./exec-schedule-gantt-chart.js";
7
- import { buildScheduleIndex } from "./exec-schedule-index.js";
8
- import { buildGanttChartScopeSpecs, filterCpmNodes, scheduleTrackNames, } from "./exec-schedule-gantt-chart-scope.js";
9
- import { computeCpm, topoSort } from "./exec-schedule-cpm.js";
10
- import { buildReadySnapshot, orderReadyIds, writeReadyFiles, selectNextTask, } from "./exec-schedule-ready.js";
11
- import { writeScheduleHashAndDiff } from "./exec-schedule-hash.js";
12
- import { buildInitialStateFromStrategy } from "./exec-schedule-initial.js";
13
- import { buildPhaseModeIndex, resolveAgentAssignment, resolveAgentPipeline, resolveApproach, resolveTaskCapabilities, resolveTaskExecution, resolveTaskMode, resolveTaskProficiency, } from "./exec-strategy.js";
3
+ import { computeReadyIds, foldEventsToState, isExecEventV1, validateEventShape, } from "../events.js";
4
+ import { ensureDir, formatDays, listFilesRecursive, readJson, toArtifactPath, toScheduleFilePath, writeJson, } from "../shared.js";
5
+ import { eventsDirForProject, executionRootForProject, generatedDirForProject, } from "../project.js";
6
+ import { buildGanttChartMarkdown, buildGanttChartSvg, buildProgressSummaryLines, } from "./gantt-chart.js";
7
+ import { buildScheduleIndex } from "./index.js";
8
+ import { buildGanttChartScopeSpecs, filterCpmNodes, scheduleTrackNames, } from "./gantt-chart-scope.js";
9
+ import { computeCpm, topoSort } from "./cpm.js";
10
+ import { buildReadySnapshot, orderReadyIds, writeReadyFiles, selectNextTask } from "./ready.js";
11
+ import { writeScheduleHashAndDiff } from "./hash.js";
12
+ import { buildInitialStateFromStrategy } from "./initial.js";
13
+ import { buildPhaseModeIndex, resolveAgentAssignment, resolveAgentPipeline, resolveApproach, resolveTaskCapabilities, resolveTaskExecution, resolveTaskMode, resolveTaskProficiency, } from "../strategy.js";
14
14
  export function findStaleGeneratedTracks(projectPath) {
15
15
  const files = listFilesRecursive(projectPath);
16
16
  const trackFiles = new Map();
@@ -0,0 +1,63 @@
1
+ export { toArtifactPath, toPortablePath } from "../shared/artifact-path.js";
2
+ export { ensureDir, listFilesRecursive, readJson, readYaml, writeJson } from "../shared/fs.js";
3
+ export { displayWidth, escapeMarkdownInline, expandTemplate, inlineCodeAnglePlaceholders, padEndDisplay, redactSensitiveText, stripTerminalControlSequences, } from "../shared/text.js";
4
+ export { formatDateOnlyUtc, isUtcIsoSeconds, normalizeDateOnly, nowUtcIsoSeconds, } from "../shared/time.js";
5
+ export { randomHex } from "../shared/random.js";
6
+ export { isSchYamlFilename, toScheduleFilePath } from "../shared/schedule-paths.js";
7
+ export function tsForFilenameUtc(ts) {
8
+ return ts.replace(/[-:]/g, "").replace("T", "T");
9
+ }
10
+ // worktree/branch 生成専用。project 修飾した task ID(`<projectId>:<taskId>`)を返す。
11
+ // projectId が未解決(env path override 等)の場合は bare のままにして後方互換を保つ。
12
+ // schedule 検索・plan/result ファイル名・claim には使わない(bare の task ID を使う)。
13
+ export function qualifyTaskId(projectId, taskId) {
14
+ return projectId ? `${projectId}:${taskId}` : taskId;
15
+ }
16
+ export function safeSlug(s) {
17
+ return s
18
+ .trim()
19
+ .replace(/\s+/g, "-")
20
+ .replace(/[^A-Za-z0-9._-]/g, "_")
21
+ .slice(0, 80);
22
+ }
23
+ export function requireNonEmpty(name, v) {
24
+ if (typeof v !== "string" || v.trim().length === 0)
25
+ throw new Error(`${name} is required`);
26
+ return v.trim();
27
+ }
28
+ export function collectRepeatable(value, previous) {
29
+ return previous.concat([value]);
30
+ }
31
+ // CPM 由来の日数値(ES / EF / slack / duration 等)の表示用フォーマット。
32
+ // 浮動小数点誤差(例: 6.2509999999999994)を吸収し、小数点以下を最大2桁に丸める。
33
+ // JSON 等のデータ出力には使わず、Markdown 表示にのみ使う。
34
+ export function formatDays(value) {
35
+ return String(Math.round(value * 100) / 100);
36
+ }
37
+ export function parseKeyValuePairs(pairs) {
38
+ if (!pairs || pairs.length === 0)
39
+ return undefined;
40
+ const out = {};
41
+ for (const p of pairs) {
42
+ const idx = p.indexOf("=");
43
+ if (idx <= 0)
44
+ throw new Error(`Invalid key=value: ${p}`);
45
+ const k = p.slice(0, idx).trim();
46
+ const v = p.slice(idx + 1).trim();
47
+ if (!k)
48
+ throw new Error(`Empty key in: ${p}`);
49
+ out[k] = v;
50
+ }
51
+ return Object.keys(out).length ? out : undefined;
52
+ }
53
+ export function isRecord(value) {
54
+ return typeof value === "object" && value !== null && !Array.isArray(value);
55
+ }
56
+ export function isStringArray(value) {
57
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
58
+ }
59
+ export function sleepMs(ms) {
60
+ const sab = new SharedArrayBuffer(4);
61
+ const int32 = new Int32Array(sab);
62
+ Atomics.wait(int32, 0, 0, ms);
63
+ }
@@ -0,0 +1 @@
1
+ export * from "../shared/cross-process-lock.js";
@@ -1,5 +1,5 @@
1
- import { listFilesRecursive, readYaml } from "./exec-shared.js";
2
- import { extractPhaseSuffix, normalizePhaseSetSelection, phaseSetNames, } from "./schedule-phase-sets.js";
1
+ import { listFilesRecursive, readYaml } from "./shared.js";
2
+ import { extractPhaseSuffix, normalizePhaseSetSelection, phaseSetNames, } from "../schedule/phase-sets.js";
3
3
  function isTaskMode(value) {
4
4
  return value === "edit" || value === "review";
5
5
  }
@@ -1,35 +1,122 @@
1
1
  import { existsSync, readdirSync, rmdirSync } from "node:fs";
2
2
  import { dirname, resolve } from "node:path";
3
- import { getProjectRepos, getProjectSchedulePath, loadConfig, PROJECT_REPO_WORKTREE_DIRNAME, resolveRepoRoot, specdojoRootDir, } from "./specdojo-config.js";
4
- import { ensureExecWorktree, execBranchExists, execWorktreePath, findExecWorktree, generateWorktreeArtifacts, gitOutput, gitResult, installWorktreeDependencies, listRegisteredWorktrees, worktreeNameFromTaskId, } from "./exec-worktree.js";
3
+ import { getProjectRepos, getProjectSchedulePath, loadConfig, PROJECT_REPO_WORKTREE_DIRNAME, resolveRepoRoot, specdojoRootDir, } from "../shared/specdojo-config.js";
4
+ import { ensureExecWorktree, execBranchExists, execWorktreePath, findExecWorktree, generateWorktreeArtifacts, gitOutput, gitResult, installWorktreeDependencies, listRegisteredWorktrees, worktreeNameFromTaskId, } from "./worktree.js";
5
5
  // PJR-98G4: 1 つのタスクがプロジェクトリポジトリと宣言済みのプロダクトリポジトリ(`repos`)を
6
6
  // 変更する場合の worktree を扱う。`repos` を持たない project では、ここの関数はどれも空の結果を
7
7
  // 返し、既存の 1 リポジトリ・`<worktree_base>/<task-id>/` 直下の配置を変えない。
8
8
  export { PROJECT_REPO_WORKTREE_DIRNAME };
9
- export function resolveProductRepos(rootDir, project) {
10
- return getProjectRepos(project).map((repo) => ({
11
- name: repo.name,
12
- repoRoot: resolveRepoRoot(rootDir, repo),
13
- ...(repo.integration_branch?.trim()
14
- ? { integrationBranch: repo.integration_branch.trim() }
15
- : {}),
16
- install: repo.setup?.install ?? true,
17
- build: repo.setup?.build ?? true,
18
- }));
9
+ /** Parse repeatable `<repo>=<branch>` values used by `exec run --integration-branch`. */
10
+ export function parseIntegrationBranchOverrides(values) {
11
+ const entries = values === undefined ? [] : typeof values === "string" ? [values] : values;
12
+ const overrides = new Map();
13
+ for (const entry of entries) {
14
+ const separator = entry.indexOf("=");
15
+ const repo = separator > 0 ? entry.slice(0, separator).trim() : "";
16
+ const branch = separator > 0 ? entry.slice(separator + 1).trim() : "";
17
+ if (!repo || !branch) {
18
+ throw new Error(`--integration-branch must use <repo>=<branch> with non-empty values: ${entry}`);
19
+ }
20
+ if (overrides.has(repo)) {
21
+ throw new Error(`--integration-branch specifies repository "${repo}" more than once`);
22
+ }
23
+ overrides.set(repo, branch);
24
+ }
25
+ return overrides;
26
+ }
27
+ function isIntegrationBranchOverrides(value) {
28
+ return value instanceof Map;
29
+ }
30
+ function toIntegrationBranchOverrides(value) {
31
+ return isIntegrationBranchOverrides(value) ? value : parseIntegrationBranchOverrides(value);
32
+ }
33
+ function assertLocalIntegrationBranch(product, branch) {
34
+ if (!existsSync(product.repoRoot)) {
35
+ throw new Error(`Product repository "${product.name}" does not exist: ${product.repoRoot} (check repos[].path)`);
36
+ }
37
+ const validName = gitResult(product.repoRoot, ["check-ref-format", "--branch", branch]);
38
+ if (validName.status !== 0) {
39
+ throw new Error(`--integration-branch for repository "${product.name}" is not a valid branch name: ${branch}`);
40
+ }
41
+ const exists = gitResult(product.repoRoot, [
42
+ "show-ref",
43
+ "--verify",
44
+ "--quiet",
45
+ `refs/heads/${branch}`,
46
+ ]);
47
+ if (exists.status !== 0) {
48
+ throw new Error(`--integration-branch for repository "${product.name}" is not a local branch: ${branch}`);
49
+ }
50
+ }
51
+ /** Resolve the configured target; undefined deliberately means "use the current branch". */
52
+ export function resolveProductIntegrationBranch(repo, overrides) {
53
+ const configuredBranch = repo.integration_branch?.trim();
54
+ return overrides.get(repo.name) ?? (configuredBranch || undefined);
55
+ }
56
+ export function resolveProductRepos(rootDir, project, integrationBranches) {
57
+ const overrides = toIntegrationBranchOverrides(integrationBranches);
58
+ // Priority: run-scoped override → repos[].integration_branch → current branch (at use time).
59
+ const configured = getProjectRepos(project);
60
+ const configuredNames = new Set(configured.map((repo) => repo.name));
61
+ const unknown = [...overrides.keys()].filter((name) => !configuredNames.has(name));
62
+ if (unknown.length > 0) {
63
+ throw new Error(`--integration-branch references undeclared product repositories: ${unknown.join(", ")}`);
64
+ }
65
+ return configured.map((repo) => {
66
+ const override = overrides.get(repo.name);
67
+ const integrationBranch = resolveProductIntegrationBranch(repo, overrides);
68
+ const product = {
69
+ name: repo.name,
70
+ repoRoot: resolveRepoRoot(rootDir, repo),
71
+ ...(integrationBranch ? { integrationBranch } : {}),
72
+ install: repo.setup?.install ?? true,
73
+ build: repo.setup?.build ?? true,
74
+ };
75
+ if (override)
76
+ assertLocalIntegrationBranch(product, override);
77
+ return product;
78
+ });
19
79
  }
20
80
  /** Product repositories of the project whose schedule path is `schedulePath` ([] when none). */
21
- export function configuredProductRepos(schedulePath) {
81
+ export function configuredProductRepos(schedulePath, integrationBranches) {
82
+ const overrides = toIntegrationBranchOverrides(integrationBranches);
22
83
  const { config } = loadConfig();
23
- if (!config)
24
- return [];
25
84
  const rootDir = specdojoRootDir();
26
- for (const project of Object.values(config.projects)) {
85
+ for (const project of Object.values(config?.projects ?? {})) {
27
86
  if (resolve(rootDir, getProjectSchedulePath(project)) === resolve(schedulePath)) {
28
- return resolveProductRepos(rootDir, project);
87
+ return resolveProductRepos(rootDir, project, overrides);
29
88
  }
30
89
  }
90
+ if (overrides.size > 0) {
91
+ throw new Error(`--integration-branch references undeclared product repositories: ${[...overrides.keys()].join(", ")}`);
92
+ }
31
93
  return [];
32
94
  }
95
+ /**
96
+ * Run-scoped `--integration-branch` values recorded in the run checkpoint (`integration_branches`).
97
+ * Only explicit overrides are recorded, so a run without the option keeps resolving its targets
98
+ * from `repos[].integration_branch` or the current branch exactly as before.
99
+ */
100
+ export function integrationBranchOverrideRecord(values) {
101
+ const overrides = parseIntegrationBranchOverrides(values);
102
+ return overrides.size > 0 ? Object.fromEntries(overrides) : undefined;
103
+ }
104
+ /**
105
+ * Integration branch overrides for a resumed run. The checkpoint's overrides are reused so the
106
+ * option does not have to be repeated; an explicit value must match the checkpoint, because a
107
+ * run cannot change or add its integration target midway through execution.
108
+ */
109
+ export function resumeIntegrationBranches(persisted, requested) {
110
+ const requestedOverrides = parseIntegrationBranchOverrides(requested);
111
+ for (const [repo, branch] of requestedOverrides) {
112
+ const original = persisted?.[repo];
113
+ if (original !== branch) {
114
+ throw new Error(`--integration-branch cannot change the resumed run target for "${repo}" ` +
115
+ `(checkpoint: ${original ?? "not specified"}, requested: ${branch})`);
116
+ }
117
+ }
118
+ return new Map(Object.entries(persisted ?? {}));
119
+ }
33
120
  /** Product repositories of the project `projectId` ([] when none or unknown). */
34
121
  export function configuredProductReposForProject(projectId) {
35
122
  if (!projectId)
@@ -1,9 +1,9 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { buildScheduleIndex } from "./exec-schedule.js";
4
- import { readReadySnapshot } from "./exec-schedule-ready.js";
5
- import { buildPhaseModeIndex, resolveAgentAssignment, resolveAgentPipeline, resolveApproach, resolveTaskCapabilities, resolveTaskExecution, resolveTaskMode, resolveTaskProficiency, } from "./exec-strategy.js";
6
- import { extractLocalId, extractPhaseSuffix } from "./schedule-phase-sets.js";
3
+ import { buildScheduleIndex } from "./schedule/schedule.js";
4
+ import { readReadySnapshot } from "./schedule/ready.js";
5
+ import { buildPhaseModeIndex, resolveAgentAssignment, resolveAgentPipeline, resolveApproach, resolveTaskCapabilities, resolveTaskExecution, resolveTaskMode, resolveTaskProficiency, } from "./strategy.js";
6
+ import { extractLocalId, extractPhaseSuffix } from "../schedule/phase-sets.js";
7
7
  // Reconstruct a full ReadyTaskView for a task from the schedule (+ ready.json when
8
8
  // present), filling mode/execution/approach/capabilities/proficiency/pipeline from strategy
9
9
  // metadata. Works for any scheduled task regardless of its current state.
@@ -1,18 +1,18 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { copyFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { basename, dirname, join, resolve } from "node:path";
4
- import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, } from "./exec-agent-config.js";
5
- import { agentProtectedConfigViolation, isAgentProtectedConfigPath, } from "./exec-agent-protected-config.js";
6
- import { recordExecutorEvidence, recordParentValidationFailureOutput, } from "./exec-evidence.js";
7
- import { parentValidationLabels, } from "./exec-parent-validation.js";
8
- import { activateResolvedProjectPaths, resolveProjectPaths } from "./exec-project.js";
9
- import { buildExecutorPrompt, isRateLimitError, loadRosterForExecutionPath, runConfiguredParentValidationBatch, } from "./exec-run.js";
10
- import { parsePlanTaskIdentity } from "./exec-plans.js";
11
- import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "./exec-reporter.js";
12
- import { ensureDir, safeSlug } from "./exec-shared.js";
13
- import { ensureExecWorktree, execBranchExists, findExecWorktree, gitOutput, gitResult, resolveWorktreeBase, } from "./exec-worktree.js";
14
- import { specdojoRootDir } from "./specdojo-config.js";
15
- import { TRIAL_PROMPT_SUFFIX, buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, comparisonDir, comparisonPath, configuredWorktreeBase, hasValidExecutorEnvelope, parsePositiveInteger, parseRating, readComparison, repoRelative, resolveMember, spawnAgent, updateObjectiveMetrics, worktreeEnvironment, writeComparison, } from "./exec-trial-core.js";
4
+ import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, } from "./agent-config.js";
5
+ import { agentProtectedConfigViolation, isAgentProtectedConfigPath, } from "./agent-protected-config.js";
6
+ import { recordExecutorEvidence, recordParentValidationFailureOutput, } from "./evidence.js";
7
+ import { parentValidationLabels } from "./parent-validation.js";
8
+ import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js";
9
+ import { buildExecutorPrompt, isRateLimitError, loadRosterForExecutionPath, runConfiguredParentValidationBatch, } from "./run/run.js";
10
+ import { parsePlanTaskIdentity } from "./plans.js";
11
+ import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "./reporter.js";
12
+ import { ensureDir, safeSlug } from "./shared.js";
13
+ import { ensureExecWorktree, execBranchExists, findExecWorktree, formatGitResultFailure, gitOutput, gitResult, resolveWorktreeBase, } from "./worktree.js";
14
+ import { specdojoRootDir } from "../shared/specdojo-config.js";
15
+ import { TRIAL_PROMPT_SUFFIX, buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, comparisonDir, comparisonPath, configuredWorktreeBase, hasValidExecutorEnvelope, parsePositiveInteger, parseRating, readComparison, repoRelative, resolveMember, spawnAgent, updateObjectiveMetrics, worktreeEnvironment, writeComparison, } from "./trial-core.js";
16
16
  async function runOneTrial(params) {
17
17
  const { trial, worktree } = params;
18
18
  const startedAt = new Date();
@@ -186,14 +186,11 @@ function resolveTrialDefinitions(opts) {
186
186
  return { agents };
187
187
  }
188
188
  function resolveBaseCommit(repoRoot, revision) {
189
- const result = gitResult(repoRoot, [
190
- "rev-parse",
191
- "--verify",
192
- "--end-of-options",
193
- `${revision}^{commit}`,
194
- ]);
195
- if (result.status !== 0)
196
- throw new Error(`Trial base is not a commit: ${revision}`);
189
+ const args = ["rev-parse", "--verify", "--end-of-options", `${revision}^{commit}`];
190
+ const result = gitResult(repoRoot, args);
191
+ if (result.status !== 0) {
192
+ throw new Error(`Trial base is not a commit: ${revision}; ${formatGitResultFailure(args, result)}`);
193
+ }
197
194
  return String(result.stdout).trim();
198
195
  }
199
196
  async function runTrials(opts) {
@@ -408,7 +405,8 @@ function commitSelectedTrial(repoRoot, record, trial) {
408
405
  if (protectedPaths.length > 0)
409
406
  throw new Error(agentProtectedConfigViolation(protectedPaths));
410
407
  gitOutput(trial.worktree, ["add", "-A"]);
411
- const staged = gitResult(trial.worktree, ["diff", "--cached", "--quiet"]);
408
+ const stagedArgs = ["diff", "--cached", "--quiet"];
409
+ const staged = gitResult(trial.worktree, stagedArgs);
412
410
  if (staged.status === 1) {
413
411
  const commit = gitResult(trial.worktree, [
414
412
  "commit",
@@ -421,7 +419,7 @@ function commitSelectedTrial(repoRoot, record, trial) {
421
419
  }
422
420
  }
423
421
  else if (staged.status !== 0) {
424
- throw new Error("Failed to inspect selected trial changes.");
422
+ throw new Error(`Failed to inspect selected trial changes: ${formatGitResultFailure(stagedArgs, staged)}`);
425
423
  }
426
424
  const ahead = Number(gitOutput(trial.worktree, ["rev-list", "--count", `${record.base_commit}..HEAD`]).trim());
427
425
  if (!Number.isFinite(ahead) || ahead < 1)
@@ -2,11 +2,11 @@ import { spawn } from "node:child_process";
2
2
  import { createHash, randomUUID } from "node:crypto";
3
3
  import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
4
4
  import { dirname, join, relative, resolve, sep } from "node:path";
5
- import { agentProtectedConfigViolation, captureAgentProtectedConfigSnapshot, changedAgentProtectedConfigPaths, } from "./exec-agent-protected-config.js";
6
- import { agentGitStateViolation, captureAgentGitStateSnapshot, changedAgentGitStateFields, } from "./exec-agent-git-state.js";
7
- import { ensureDir, safeSlug } from "./exec-shared.js";
8
- import { gitEnvironment, gitResult, worktreeNameFromTaskId } from "./exec-worktree.js";
9
- import { getProjectSchedulePath, loadConfig, specdojoRootDir, } from "./specdojo-config.js";
5
+ import { agentProtectedConfigViolation, captureAgentProtectedConfigSnapshot, changedAgentProtectedConfigPaths, } from "./agent-protected-config.js";
6
+ import { agentGitStateViolation, captureAgentGitStateSnapshot, changedAgentGitStateFields, } from "./agent-git-state.js";
7
+ import { ensureDir, safeSlug } from "./shared.js";
8
+ import { gitEnvironment, gitResult, worktreeNameFromTaskId } from "./worktree.js";
9
+ import { getProjectSchedulePath, loadConfig, resolveAgentMember, specdojoRootDir, } from "../shared/specdojo-config.js";
10
10
  export const TRIAL_PROMPT_SUFFIX = `
11
11
 
12
12
  ---
@@ -168,7 +168,7 @@ export function parseRating(value, flag) {
168
168
  return Number(value);
169
169
  }
170
170
  export function resolveMember(roster, nickname, stageRole) {
171
- const member = roster?.members.find((candidate) => candidate.type === "agent" && candidate.nickname === nickname);
171
+ const member = resolveAgentMember(roster, nickname);
172
172
  if (!member)
173
173
  throw new Error(`Agent nickname not found in agent-members.yaml: ${nickname}`);
174
174
  if (member.disabled)
@@ -1,2 +1,2 @@
1
- export { buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, extractPlanRepoPaths, updateObjectiveMetrics, } from "./exec-trial-core.js";
2
- export { registerExecTrialCommands } from "./exec-trial-commands.js";
1
+ export { buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, extractPlanRepoPaths, updateObjectiveMetrics, } from "./trial-core.js";
2
+ export { registerExecTrialCommands } from "./trial-commands.js";