specdojo 0.3.1 → 0.4.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 (241) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +77 -18
  3. package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
  4. package/dist/catalog/build-render.js +32 -0
  5. package/dist/{catalog-build.js → catalog/build.js} +9 -9
  6. package/dist/{catalog.js → catalog/catalog.js} +10 -10
  7. package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
  8. package/dist/catalog/paths.js +1 -0
  9. package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
  10. package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
  11. package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
  12. package/dist/{agent.js → commands/agent.js} +11 -11
  13. package/dist/{build-command.js → commands/build.js} +2 -2
  14. package/dist/{init-command.js → commands/init.js} +98 -32
  15. package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
  16. package/dist/{watch.js → commands/watch.js} +3 -3
  17. package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
  18. package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
  19. package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
  20. package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
  21. package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
  22. package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
  23. package/dist/{timeline.js → dashboard/timeline.js} +1 -1
  24. package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
  25. package/dist/{deliverable-trash.js → deliverable/trash.js} +5 -5
  26. package/dist/{devcontainer-command.js → devcontainer/command.js} +5 -3
  27. package/dist/{devcontainer-scaffold.js → devcontainer/scaffold.js} +94 -2
  28. package/dist/{doc-index.js → docs/doc-index.js} +1 -1
  29. package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
  30. package/dist/{index-command.js → docs/index-command.js} +1 -1
  31. package/dist/docs/template-resolution.js +1 -0
  32. package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +1 -1
  33. package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
  34. package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
  35. package/dist/{exec-agent-config.js → exec/agent-config.js} +33 -4
  36. package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
  37. package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
  38. package/dist/{exec-commands.js → exec/commands.js} +22 -18
  39. package/dist/{exec-core.js → exec/core.js} +11 -11
  40. package/dist/{exec-events.js → exec/events.js} +2 -2
  41. package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
  42. package/dist/exec/exec.js +2 -0
  43. package/dist/exec/format.js +1 -0
  44. package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
  45. package/dist/{exec-limit.js → exec/limit.js} +93 -12
  46. package/dist/{exec-parent-validation.js → exec/parent-validation.js} +4 -4
  47. package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +16 -2
  48. package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
  49. package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
  50. package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
  51. package/dist/{exec-plans.js → exec/plans.js} +3 -3
  52. package/dist/{exec-project.js → exec/project.js} +1 -1
  53. package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
  54. package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
  55. package/dist/{exec-register.js → exec/register.js} +92 -9
  56. package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
  57. package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
  58. package/dist/{exec-repo-integration.js → exec/repo-integration.js} +13 -10
  59. package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
  60. package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
  61. package/dist/{exec-reporter.js → exec/reporter.js} +29 -12
  62. package/dist/{exec-results.js → exec/results.js} +256 -22
  63. package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +32 -12
  64. package/dist/{exec-run-agent.js → exec/run/agent.js} +79 -27
  65. package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
  66. package/dist/{exec-run-job.js → exec/run/job.js} +64 -35
  67. package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
  68. package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
  69. package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
  70. package/dist/{exec-run-register-command.js → exec/run/register-command.js} +18 -10
  71. package/dist/{exec-run-register-core.js → exec/run/register-core.js} +46 -21
  72. package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +20 -16
  73. package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +22 -17
  74. package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
  75. package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +54 -23
  76. package/dist/{exec-run.js → exec/run/run.js} +11 -11
  77. package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
  78. package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
  79. package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
  80. package/dist/{exec-run-shared.js → exec/run/shared.js} +61 -11
  81. package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
  82. package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
  83. package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
  84. package/dist/exec/schedule/gantt-chart.js +2 -0
  85. package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
  86. package/dist/exec/schedule/index.js +1 -0
  87. package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
  88. package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
  89. package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
  90. package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
  91. package/dist/exec/shared.js +63 -0
  92. package/dist/exec/slot-lock.js +1 -0
  93. package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
  94. package/dist/{exec-task-repos.js → exec/task-repos.js} +2 -2
  95. package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
  96. package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
  97. package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
  98. package/dist/{exec-trial.js → exec/trial.js} +2 -2
  99. package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
  100. package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
  101. package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
  102. package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
  103. package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
  104. package/dist/exec/worktree.js +305 -0
  105. package/dist/{grade-apply.js → grade/apply.js} +9 -9
  106. package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
  107. package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
  108. package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
  109. package/dist/{grade-core.js → grade/core.js} +3 -3
  110. package/dist/grade/grade.js +19 -0
  111. package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
  112. package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
  113. package/dist/{grade-plan.js → grade/plan.js} +5 -5
  114. package/dist/{grade-result.js → grade/result.js} +5 -94
  115. package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
  116. package/dist/{grade-targets.js → grade/targets.js} +11 -8
  117. package/dist/{job-definition.js → job/definition.js} +25 -6
  118. package/dist/{job.js → job/job.js} +12 -11
  119. package/dist/{kata-command.js → kata/command.js} +3 -3
  120. package/dist/{kata.js → kata/kata.js} +5 -5
  121. package/dist/register/approach.js +134 -0
  122. package/dist/{register-core.js → register/core.js} +13 -7
  123. package/dist/{register-create-commands.js → register/create-commands.js} +115 -8
  124. package/dist/{register-date.js → register/date.js} +1 -1
  125. package/dist/register/derivation.js +163 -0
  126. package/dist/{register-event-merge.js → register/event-merge.js} +32 -3
  127. package/dist/{register-events.js → register/events.js} +9 -3
  128. package/dist/{register-history.js → register/history.js} +7 -6
  129. package/dist/{register-item.js → register/item.js} +23 -5
  130. package/dist/register/lifecycle-lock.js +5 -0
  131. package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
  132. package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
  133. package/dist/{register-migration.js → register/migration.js} +4 -4
  134. package/dist/{register.js → register/register.js} +32 -27
  135. package/dist/{register-renumber.js → register/renumber.js} +38 -11
  136. package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
  137. package/dist/{register-update.js → register/update.js} +5 -5
  138. package/dist/{register-views.js → register/views.js} +47 -7
  139. package/dist/{review-grade.js → review/grade.js} +2 -2
  140. package/dist/{review-plan.js → review/plan.js} +3 -3
  141. package/dist/{routine-definition.js → routine/definition.js} +2 -2
  142. package/dist/{routine.js → routine/routine.js} +49 -22
  143. package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
  144. package/dist/{schedule-build.js → schedule/build.js} +7 -4
  145. package/dist/{schedule.js → schedule/schedule.js} +6 -6
  146. package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
  147. package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
  148. package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
  149. package/dist/shared/agent-types.js +23 -0
  150. package/dist/shared/artifact-path.js +9 -0
  151. package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
  152. package/dist/{catalog-build-render.js → shared/catalog-render.js} +3 -32
  153. package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
  154. package/dist/shared/fs.js +30 -0
  155. package/dist/{exec-worktree.js → shared/git.js} +83 -241
  156. package/dist/shared/grade-result.js +94 -0
  157. package/dist/{package-paths.js → shared/package-paths.js} +3 -3
  158. package/dist/shared/plan-templates.js +114 -0
  159. package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +3 -1
  160. package/dist/shared/random.js +4 -0
  161. package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
  162. package/dist/shared/schedule-paths.js +9 -0
  163. package/dist/{specdojo-config.js → shared/specdojo-config.js} +93 -5
  164. package/dist/{exec-shared.js → shared/text.js} +0 -134
  165. package/dist/shared/time.js +28 -0
  166. package/dist/specdojo.js +22 -22
  167. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +29 -17
  168. package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
  169. package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -2
  170. package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
  171. package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
  172. package/docs/ja/specdojo/guides/exec-config-guide.md +91 -16
  173. package/docs/ja/specdojo/guides/exec-operation-guide.md +145 -12
  174. package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
  175. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +31 -0
  176. package/docs/ja/specdojo/guides/quick-start-guide.md +81 -16
  177. package/docs/ja/specdojo/guides/register-operation-guide.md +2 -1
  178. package/docs/ja/specdojo/guides/remote-host-development-guide.md +10 -1
  179. package/docs/ja/specdojo/guides/review-guide.md +1 -1
  180. package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
  181. package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
  182. package/docs/ja/specdojo/references/command-reference.md +52 -28
  183. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +17 -11
  184. package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
  185. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
  186. package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
  187. package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
  188. package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
  189. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +20 -0
  190. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +23 -0
  191. package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
  192. package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
  193. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +26 -0
  194. package/docs/specdojo/schemas/v1/register-events.schema.yaml +3 -0
  195. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +70 -7
  196. package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
  197. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +1 -1
  198. package/package.json +1 -1
  199. package/templates/antigravity/README.md +5 -1
  200. package/templates/antigravity/agent-members-snippet.yaml +108 -12
  201. package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
  202. package/templates/claude/README.md +27 -3
  203. package/templates/claude/agents/claude-executor.md +0 -1
  204. package/templates/claude/agents/claude-reporter.md +2 -1
  205. package/templates/claude/agents/claude-review-executor.md +0 -1
  206. package/templates/codex/README.md +23 -4
  207. package/templates/devcontainer/devcontainer.json +2 -2
  208. package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +69 -0
  209. package/templates/devcontainer/remote-host/ssh-config.sample +16 -0
  210. package/templates/init-agent-members.yaml +75 -25
  211. package/templates/init-exec-defaults.yaml +24 -8
  212. package/templates/opencode/README.md +17 -3
  213. package/templates/opencode/agents/opencode-executor.md +0 -1
  214. package/templates/opencode/agents/opencode-reporter.md +2 -1
  215. package/templates/opencode/agents/opencode-review-executor.md +0 -1
  216. package/dist/exec-schedule-gantt-chart.js +0 -2
  217. package/dist/exec.js +0 -2
  218. package/dist/grade.js +0 -19
  219. package/templates/claude/agents/claude-expert-review-executor.md +0 -14
  220. /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
  221. /package/dist/{catalog-types.js → catalog/types.js} +0 -0
  222. /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
  223. /package/dist/{role-types.js → exec/role-types.js} +0 -0
  224. /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
  225. /package/dist/{exec-types.js → exec/types.js} +0 -0
  226. /package/dist/{grade-command-shared.js → grade/command-shared.js} +0 -0
  227. /package/dist/{register-command-types.js → register/command-types.js} +0 -0
  228. /package/dist/{review-types.js → review/types.js} +0 -0
  229. /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
  230. /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
  231. /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
  232. /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
  233. /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
  234. /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
  235. /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
  236. /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
  237. /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
  238. /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
  239. /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
  240. /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
  241. /package/dist/{yaml.js → shared/yaml.js} +0 -0
@@ -1,7 +1,7 @@
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>/` 直下の配置を変えない。
@@ -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";
@@ -1,23 +1,24 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { existsSync } from "node:fs";
3
3
  import { join, resolve } from "node:path";
4
- import { acquireSchedulerLock, foldEventsToState, readAllEventFiles, releaseSchedulerLock, } from "./exec-events.js";
5
- import { hasMemberCommandSource, loadExecDefaultsConfig, resolveMemberCommand, } from "./exec-agent-config.js";
6
- import { activateResolvedProjectPaths, resolveProjectPaths } from "./exec-project.js";
7
- import { agentGitStateViolation, captureAgentGitStateAcrossRepos, changedAgentGitStateAcrossRepos, qualifiedGitStateFields, } from "./exec-agent-git-state.js";
8
- import { agentProtectedConfigViolation, captureAgentProtectedConfigAcrossRepos, changedAgentProtectedConfigAcrossRepos, qualifiedRepoPaths, } from "./exec-agent-protected-config.js";
9
- import { recordGitStateBlockAcrossRepos, recordProtectedConfigBlockAcrossRepos, } from "./exec-protection-handoff.js";
10
- import { configuredProductRepos, missingProductWorktrees, plannedProjectWorktreePath, pruneOrphanedProductExecBranches, productRepoEnvironment, withAgentExtraRoots, withoutInheritedRepoEnvironment, withProductRepoPrompt, withProductWorktrees, } from "./exec-task-repos.js";
11
- import { buildTaskPhaseMap, loadPrompt, loadRosterForExecutionPath, resolveTaskPhaseContext, selectCandidates, } from "./exec-run.js";
12
- import { buildScheduleIndex } from "./exec-schedule.js";
13
- import { buildInitialStateFromStrategy } from "./exec-schedule-initial.js";
14
- import { generateSinglePlan } from "./exec-plans.js";
15
- import { qualifyTaskId } from "./exec-shared.js";
16
- import { buildTaskView } from "./exec-task-view.js";
17
- import { findExecWorktree, gitEnvironment, gitOutput, gitResult, resolveWorktreeBase, worktreeNameFromTaskId, } from "./exec-worktree.js";
18
- import { checkpointAndEnsureWorktree, commitWorktreeChanges, mergeWorktreeIntoCurrent, pruneOrphanedExecBranches, removeWorktree, taskPaths, worktreeStatusPaths, } from "./exec-worktree-ops.js";
19
- import { getProjectSchedulePath, loadConfig, specdojoRootDir } from "./specdojo-config.js";
20
- export { isCommitTargetPath, stabilizeCommitTargets } from "./exec-worktree-ops.js";
4
+ import { acquireSchedulerLock, foldEventsToState, readAllEventFiles, releaseSchedulerLock, } from "./events.js";
5
+ import { hasMemberCommandSource, loadExecDefaultsConfig, resolveMemberCommand, } from "./agent-config.js";
6
+ import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js";
7
+ import { agentGitStateViolation, captureAgentGitStateAcrossRepos, changedAgentGitStateAcrossRepos, qualifiedGitStateFields, } from "./agent-git-state.js";
8
+ import { agentProtectedConfigViolation, captureAgentProtectedConfigAcrossRepos, changedAgentProtectedConfigAcrossRepos, qualifiedRepoPaths, } from "./agent-protected-config.js";
9
+ import { recordGitStateBlockAcrossRepos, recordProtectedConfigBlockAcrossRepos, } from "./protection-handoff.js";
10
+ import { configuredProductRepos, missingProductWorktrees, plannedProjectWorktreePath, pruneOrphanedProductExecBranches, productRepoEnvironment, withAgentExtraRoots, withoutInheritedRepoEnvironment, withProductRepoPrompt, withProductWorktrees, } from "./task-repos.js";
11
+ import { resolveAgentMember } from "../shared/specdojo-config.js";
12
+ import { buildTaskPhaseMap, loadPrompt, loadRosterForExecutionPath, resolveTaskPhaseContext, selectCandidates, } from "./run/run.js";
13
+ import { buildScheduleIndex } from "./schedule/schedule.js";
14
+ import { buildInitialStateFromStrategy } from "./schedule/initial.js";
15
+ import { generateSinglePlan } from "./plans.js";
16
+ import { qualifyTaskId } from "./shared.js";
17
+ import { buildTaskView } from "./task-view.js";
18
+ import { findExecWorktree, gitEnvironment, gitOutput, gitResult, resolveWorktreeBase, worktreeNameFromTaskId, } from "./worktree.js";
19
+ import { checkpointAndEnsureWorktree, commitWorktreeChanges, mergeWorktreeIntoCurrent, pruneOrphanedExecBranches, removeWorktree, taskPaths, worktreeStatusPaths, } from "./worktree-ops.js";
20
+ import { getProjectSchedulePath, loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
21
+ export { isCommitTargetPath, stabilizeCommitTargets } from "./worktree-ops.js";
21
22
  const DEFAULT_LOCK_TIMEOUT_MS = 10_000;
22
23
  const DEFAULT_LOCK_STALE_MS = 300_000;
23
24
  function commandError(error) {
@@ -97,11 +98,12 @@ function resolveAgent(context, taskId, opts) {
97
98
  if ((task.execution ?? "agent") === "human" && !opts.by) {
98
99
  throw new Error(`Task requires human execution. Use --by <nickname> to override: ${taskId}`);
99
100
  }
100
- const member = roster?.members.find((item) => item.nickname === nickname &&
101
- item.type === "agent" &&
102
- hasMemberCommandSource(execDefaults, item));
101
+ const resolvedMember = resolveAgentMember(roster, nickname);
102
+ const member = resolvedMember && hasMemberCommandSource(execDefaults, resolvedMember)
103
+ ? resolvedMember
104
+ : undefined;
103
105
  const command = member ? resolveMemberCommand(execDefaults, member) : undefined;
104
- if (!command) {
106
+ if (!member || !command) {
105
107
  throw new Error(`Agent command not found for actor: ${nickname}`);
106
108
  }
107
109
  if (!opts.by) {
@@ -110,14 +112,14 @@ function resolveAgent(context, taskId, opts) {
110
112
  throw new Error(`Cannot resolve phase context for task: ${taskId}`);
111
113
  }
112
114
  const candidates = selectCandidates({ capabilities: task.capabilities ?? [], proficiency: task.proficiency }, roster, task.mode ?? "edit", undefined, execDefaults);
113
- if (!candidates.some((candidate) => candidate.nickname === nickname)) {
115
+ if (!candidates.some((candidate) => candidate.nickname === member.nickname)) {
114
116
  throw new Error(`Claim actor does not satisfy task agent requirements: ${nickname}`);
115
117
  }
116
118
  }
117
119
  const prompt = loadPrompt(context.executionPath, taskId);
118
120
  if (!prompt)
119
121
  throw new Error(`Plan not found for task: ${taskId}`);
120
- return { actor: nickname, command, provider: member?.provider, prompt };
122
+ return { actor: member.nickname, command, provider: member.provider, prompt };
121
123
  }
122
124
  function printWorktree(worktree) {
123
125
  process.stdout.write(`worktree: ${worktree.path}\nbranch: ${worktree.branch}\n`);
@@ -1,48 +1,24 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, writeFileSync, } from "node:fs";
3
- import { join, relative, resolve, sep } from "node:path";
4
- import { load } from "./yaml.js";
5
- import { deliverableDocPath, parsePlanTaskIdentity, targetReferenceDirsForApproach, } from "./exec-plans.js";
6
- import { parseResultTaskIdentity } from "./exec-results.js";
7
- import { stripTerminalControlSequences } from "./exec-shared.js";
8
- import { agentProtectedConfigPaths, agentProtectedConfigViolation, qualifiedRepoPaths, } from "./exec-agent-protected-config.js";
9
- import { recordProtectedConfigBlockAcrossRepos } from "./exec-protection-handoff.js";
10
- import { assertNoPendingProductChanges, productIntegrationTarget } from "./exec-task-repos.js";
11
- import { specdojoPackageRootDir } from "./package-paths.js";
12
- import { appendGitFailureLog, gitEnvironment, gitOutput, gitResult, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./exec-worktree.js";
2
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { join, resolve } from "node:path";
4
+ import { load } from "../shared/yaml.js";
5
+ import { deliverableDocPath, parsePlanTaskIdentity, targetReferenceDirsForApproach, } from "./plans.js";
6
+ import { parseResultTaskIdentity } from "./results.js";
7
+ import { stripTerminalControlSequences } from "./shared.js";
8
+ import { agentProtectedConfigPaths, agentProtectedConfigViolation, qualifiedRepoPaths, } from "./agent-protected-config.js";
9
+ import { recordProtectedConfigBlockAcrossRepos } from "./protection-handoff.js";
10
+ import { assertNoPendingProductChanges, productIntegrationTarget } from "./task-repos.js";
11
+ import { specdojoPackageRootDir } from "../shared/package-paths.js";
12
+ import { repoRelative, stageCommitTargets, worktreeStatusPaths as statusPaths, } from "../shared/git.js";
13
+ export { repoRelative, selectStageablePaths, stageCommitTargets, worktreeStatusPaths, } from "../shared/git.js";
14
+ import { appendGitFailureLog, appendGitResultFailureLog, formatGitResultFailure, gitEnvironment, gitOutput, gitResult, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./worktree.js";
13
15
  const MAX_COMMIT_STABILIZATION_ATTEMPTS = 3;
14
- export function repoRelative(repoRoot, path) {
15
- const value = relative(repoRoot, path);
16
- if (!value || value === ".." || value.startsWith(`..${sep}`)) {
17
- throw new Error(`Path is outside repository root: ${path}`);
18
- }
19
- return value.split(sep).join("/");
20
- }
21
16
  export function currentBranch(repoRoot) {
22
17
  const branch = gitOutput(repoRoot, ["branch", "--show-current"]).trim();
23
18
  if (!branch)
24
19
  throw new Error("Detached HEAD is not supported for exec worktree commands.");
25
20
  return branch;
26
21
  }
27
- function statusPaths(repoRoot) {
28
- const output = gitOutput(repoRoot, ["status", "--porcelain=v1", "-z", "--untracked-files=all"]);
29
- const records = output.split("\0").filter(Boolean);
30
- const paths = [];
31
- for (let index = 0; index < records.length; index++) {
32
- const record = records[index];
33
- if (record.length < 4)
34
- continue;
35
- const status = record.slice(0, 2);
36
- paths.push(record.slice(3));
37
- if ((status.includes("R") || status.includes("C")) && records[index + 1]) {
38
- paths.push(records[++index]);
39
- }
40
- }
41
- return paths;
42
- }
43
- export function worktreeStatusPaths(repoRoot) {
44
- return statusPaths(repoRoot);
45
- }
46
22
  export function taskPaths(context, taskId) {
47
23
  const executionRel = repoRelative(context.repoRoot, context.executionPath);
48
24
  return {
@@ -419,23 +395,6 @@ export function commitTargetPaths(context, worktree, taskId) {
419
395
  // パスはそのどちらにも存在しないため、`-A` を付けても「pathspec did not match any files」で
420
396
  // fatal になる。このようなパスは追加で stage する内容が無いので、add の対象から除外する。
421
397
  // commit / commit --amend の pathspec は HEAD も照合するため、対象から外さずに削除を記録できる。
422
- export function selectStageablePaths(repoRoot, paths) {
423
- if (paths.length === 0)
424
- return [];
425
- const indexed = new Set(zeroSeparatedPaths(repoRoot, ["ls-files", "--full-name", "-z", "--", ...paths]));
426
- // 作業ツリー側の存在確認は lstat で行う。git は symlink 自体を追跡するため、リンク先が
427
- // 無い symlink も add の対象になる(existsSync はリンク先を辿るため false になる)。
428
- const existsInWorktree = (path) => lstatSync(resolve(repoRoot, path), { throwIfNoEntry: false }) !== undefined;
429
- return paths.filter((path) => indexed.has(path) || existsInWorktree(path));
430
- }
431
- // commit 対象を stage する。stage できる対象が無い場合(staged 済みの削除だけが残る場合)は
432
- // git add を実行しない。commit 対象の限定は呼び出し側の paths が担うため、範囲は変わらない。
433
- export function stageCommitTargets(repoRoot, paths) {
434
- const stageable = selectStageablePaths(repoRoot, paths);
435
- if (stageable.length === 0)
436
- return;
437
- gitOutput(repoRoot, ["add", "-A", "--", ...stageable]);
438
- }
439
398
  // runner が stage した対象だけを index から戻す。利用者や別処理が stage 済みの無関係な
440
399
  // パスは保持し、commit / hook の失敗を後続の exec run へ持ち越さない。
441
400
  export function unstageCommitTargets(repoRoot, paths) {
@@ -506,7 +465,8 @@ export function stabilizeCommitTargets(repoRoot, listRemainingPaths, maxAttempts
506
465
  if (paths.length === 0)
507
466
  return;
508
467
  stageCommitTargets(repoRoot, paths);
509
- const staged = gitResult(repoRoot, ["diff", "--cached", "--quiet", "--", ...paths]);
468
+ const stagedArgs = ["diff", "--cached", "--quiet", "--", ...paths];
469
+ const staged = gitResult(repoRoot, stagedArgs);
510
470
  if (staged.status === 0) {
511
471
  // pathspec commit は hook が再stageした内容を commit した後、元の index を復元して
512
472
  // HEAD と逆向きの差分を残す場合がある。この場合は add が index を HEAD へ揃えて
@@ -516,8 +476,10 @@ export function stabilizeCommitTargets(repoRoot, listRemainingPaths, maxAttempts
516
476
  return;
517
477
  throw new Error(`Failed to stage post-hook commit-target changes: ${remaining.join(", ")}`);
518
478
  }
519
- if (staged.status !== 1)
520
- throw new Error("Failed to inspect post-hook worktree changes.");
479
+ if (staged.status !== 1) {
480
+ appendGitResultFailureLog(failureLogPath, "git diff post-hook worktree inspection", staged);
481
+ throw new Error(`Failed to inspect post-hook worktree changes: ${formatGitResultFailure(stagedArgs, staged)}`);
482
+ }
521
483
  const commitArgs = ["commit", "--amend", "--no-edit", "--", ...paths];
522
484
  const commit = gitResult(repoRoot, commitArgs);
523
485
  if (commit.status !== 0) {
@@ -672,13 +634,16 @@ export function commitWorktreeChanges(params) {
672
634
  return { targets: paths, committed: false };
673
635
  assertResultMarkdownlint(context, worktree, taskId);
674
636
  stageCommitTargets(worktree.path, paths);
675
- const staged = gitResult(worktree.path, ["diff", "--cached", "--quiet", "--", ...paths]);
637
+ const stagedArgs = ["diff", "--cached", "--quiet", "--", ...paths];
638
+ const staged = gitResult(worktree.path, stagedArgs);
676
639
  if (staged.status === 0) {
677
640
  process.stdout.write("No staged commit-target changes.\n");
678
641
  return { targets: paths, committed: false };
679
642
  }
680
- if (staged.status !== 1)
681
- throw new Error("Failed to inspect staged worktree changes.");
643
+ if (staged.status !== 1) {
644
+ appendGitResultFailureLog(params.failureLogPath, "git diff staged worktree inspection", staged);
645
+ throw new Error(`Failed to inspect staged worktree changes: ${formatGitResultFailure(stagedArgs, staged)}`);
646
+ }
682
647
  const commitArgs = [
683
648
  "commit",
684
649
  "-m",
@@ -1,9 +1,9 @@
1
1
  import { copyFileSync, existsSync, lstatSync, mkdirSync, rmSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
- import { stripTerminalControlSequences } from "./exec-shared.js";
4
- import { discardStaleProductWorktrees, ensureProductWorktrees, projectRepoDirName, productWorktreeRemovalBlockers, removeEmptyTaskDirectory, removeProductWorktrees, } from "./exec-task-repos.js";
5
- import { appendGitFailureLog, ensureExecWorktree, execBranchExists, findExecWorktree, generateWorktreeArtifacts, gitOutput, gitResult, listRegisteredWorktrees, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./exec-worktree.js";
6
- import { commitTargetPaths, currentBranch, repoRelative, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, zeroSeparatedPaths, } from "./exec-worktree-ops-commit.js";
3
+ import { stripTerminalControlSequences } from "./shared.js";
4
+ import { discardStaleProductWorktrees, ensureProductWorktrees, projectRepoDirName, productWorktreeRemovalBlockers, removeEmptyTaskDirectory, removeProductWorktrees, } from "./task-repos.js";
5
+ import { appendGitFailureLog, appendGitResultFailureLog, ensureExecWorktree, execBranchExists, findExecWorktree, formatGitResultFailure, generateWorktreeArtifacts, gitOutput, gitResult, listRegisteredWorktrees, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./worktree.js";
6
+ import { commitTargetPaths, currentBranch, repoRelative, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, zeroSeparatedPaths, } from "./worktree-ops-commit.js";
7
7
  // Remove a task worktree once its commit-target changes are committed and merged.
8
8
  export function removeWorktree(params) {
9
9
  const { context, worktree, taskId } = params;
@@ -167,6 +167,12 @@ function copyCheckpointPath(sourceRoot, targetRoot, relPath) {
167
167
  mkdirSync(resolve(target, ".."), { recursive: true });
168
168
  copyFileSync(source, target);
169
169
  }
170
+ export function assertCheckpointInspection(args, result, failureLogPath) {
171
+ if (result.status === 0 || result.status === 1)
172
+ return;
173
+ appendGitResultFailureLog(failureLogPath, "git diff checkpoint inspection", result);
174
+ throw new Error(`Failed to inspect execution checkpoint changes: ${formatGitResultFailure(args, result)}`);
175
+ }
170
176
  // Create the task worktree from the current integration HEAD, then commit the execution
171
177
  // checkpoint (plan / result / claim or register-start bookkeeping) on the exec branch only. The
172
178
  // root keeps its uncommitted copies so the task state stays visible there while the agent runs;
@@ -249,7 +255,9 @@ function checkpointAndEnsureProjectWorktree(params, repoDirName, ensureSiblingWo
249
255
  for (const path of paths)
250
256
  copyCheckpointPath(context.repoRoot, worktree.path, path);
251
257
  stageCommitTargets(worktree.path, paths);
252
- const checkpoint = gitResult(worktree.path, ["diff", "--cached", "--quiet", "--", ...paths]);
258
+ const checkpointArgs = ["diff", "--cached", "--quiet", "--", ...paths];
259
+ const checkpoint = gitResult(worktree.path, checkpointArgs);
260
+ assertCheckpointInspection(checkpointArgs, checkpoint, params.failureLogPath);
253
261
  if (checkpoint.status === 1) {
254
262
  const committed = gitResult(worktree.path, [
255
263
  "commit",
@@ -283,9 +291,6 @@ function checkpointAndEnsureProjectWorktree(params, repoDirName, ensureSiblingWo
283
291
  `(likely a failing git hook): ${summarizeGitHookFailure(output)}`);
284
292
  }
285
293
  }
286
- else if (checkpoint.status !== 0) {
287
- throw new Error("Failed to inspect execution checkpoint changes.");
288
- }
289
294
  return worktree;
290
295
  }
291
296
  return ensureProjectWorktree();
@@ -1,13 +1,52 @@
1
- import { lstatSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync, lstatSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
3
  import { basename, dirname, resolve } from "node:path";
3
- import { acquireSchedulerLock, releaseSchedulerLock } from "./exec-events.js";
4
- import { rebuildRegisterTicketFromEvents, unionRegisterEventLogs } from "./register-event-merge.js";
5
- import { displayIdFromRegisterEventFilename, REGISTER_EVENTS_DIRNAME } from "./register-events.js";
6
- import { displayIdFromTicketFilename } from "./register-item.js";
7
- import { appendGitFailureLog, gitOutput, gitResult, summarizeGitHookFailure, } from "./exec-worktree.js";
8
- import { commitTargetPaths, currentBranch, repoRelative, rootDirtyPaths, zeroSeparatedPaths, } from "./exec-worktree-ops-commit.js";
4
+ import { acquireSchedulerLock, releaseSchedulerLock } from "./events.js";
5
+ import { rebuildRegisterTicketFromEvents, unionRegisterEventLogs, } from "../register/event-merge.js";
6
+ import { displayIdFromRegisterEventFilename, REGISTER_EVENTS_DIRNAME } from "../register/events.js";
7
+ import { displayIdFromTicketFilename } from "../register/item.js";
8
+ import { appendGitFailureLog, gitOutput, gitResult, summarizeGitHookFailure, } from "./worktree.js";
9
+ import { commitTargetPaths, currentBranch, repoRelative, rootDirtyPaths, zeroSeparatedPaths, } from "./worktree-ops-commit.js";
9
10
  const DEFAULT_LOCK_TIMEOUT_MS = 10_000;
10
11
  const DEFAULT_LOCK_STALE_MS = 300_000;
12
+ // A successful `git merge` runs post-merge, but a merge completed by the bookkeeping-conflict
13
+ // resolver below uses `git commit --no-verify` and therefore skips that hook. Invoke the same
14
+ // repository-local entry point explicitly after either path. Only a SpecDojo development checkout
15
+ // whose local bin points at dist is eligible; repositories consuming SpecDojo from node_modules
16
+ // remain unaffected. The script and this launcher are both best-effort so a dist rebuild failure
17
+ // never turns a completed merge into an integration failure.
18
+ function usesLocalSpecdojoDistBin(repoRoot) {
19
+ try {
20
+ const packageJson = JSON.parse(readFileSync(resolve(repoRoot, "package.json"), "utf8"));
21
+ if (packageJson.name !== "specdojo" || typeof packageJson.bin !== "object")
22
+ return false;
23
+ return packageJson.bin?.specdojo === "dist/specdojo.js";
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ }
29
+ function runBuildIfStaleAfterMerge(repoRoot) {
30
+ try {
31
+ const scriptPath = resolve(repoRoot, "tools", "build-if-stale.mjs");
32
+ if (!existsSync(scriptPath) || !usesLocalSpecdojoDistBin(repoRoot))
33
+ return;
34
+ const result = spawnSync(process.execPath, [scriptPath], {
35
+ cwd: repoRoot,
36
+ stdio: "inherit",
37
+ shell: false,
38
+ });
39
+ if (result.error) {
40
+ process.stderr.write(` [integrate] warning: build-if-stale could not start: ${result.error.message}\n`);
41
+ }
42
+ else if (result.status !== 0) {
43
+ process.stderr.write(` [integrate] warning: build-if-stale failed with exit code ${result.status ?? "unknown"}\n`);
44
+ }
45
+ }
46
+ catch (error) {
47
+ process.stderr.write(` [integrate] warning: build-if-stale failed: ${error instanceof Error ? error.message : String(error)}\n`);
48
+ }
49
+ }
11
50
  // The checkpoint commit lives on the exec branch only, so the root keeps its own uncommitted copy
12
51
  // of the bookkeeping files while the task runs (the schedule/register state must stay visible at
13
52
  // root). Before the exec branch is merged those copies must yield to the committed versions,
@@ -261,6 +300,8 @@ export function mergeWorktreeIntoCurrent(params) {
261
300
  }
262
301
  }
263
302
  finally {
303
+ if (merged)
304
+ runBuildIfStaleAfterMerge(context.repoRoot);
264
305
  if (!merged && released.length > 0)
265
306
  restoreRootWorkingCopies(context.repoRoot, released);
266
307
  if (lockDir)
@@ -1,3 +1,3 @@
1
- export { REGISTER_NEW_FILE_DIR_PREFIXES, ROOT_NEW_FILES_HANDOFF_LABEL, applyRootNewFilesHandoff, assertResultMarkdownlint, commitTargetPaths, commitWorktreeChanges, currentBranch, deliverableStatus, isCommitTargetPath, normalizeResultWhitespace, partitionCommitTargets, recordRootNewFilesHandoff, repoRelative, resolveCommitScope, selectStageablePaths, stabilizeCommitTargets, stageCommitTargets, taskPaths, taskTargetsAtHead, unstageCommitTargets, worktreeStatusPaths, } from "./exec-worktree-ops-commit.js";
2
- export { abortMerge, isExecBranchMergedIntoCurrent, mergeWorktreeIntoCurrent, releaseRootWorkingCopies, restoreRootWorkingCopies, } from "./exec-worktree-ops-merge.js";
3
- export { WorktreeRemovedBranchDeletionError, checkpointAndEnsureWorktree, discardStaleExecWorktree, listOrphanedExecBranches, pruneOrphanedExecBranches, removeWorktree, } from "./exec-worktree-ops-lifecycle.js";
1
+ export { REGISTER_NEW_FILE_DIR_PREFIXES, ROOT_NEW_FILES_HANDOFF_LABEL, applyRootNewFilesHandoff, assertResultMarkdownlint, commitTargetPaths, commitWorktreeChanges, currentBranch, deliverableStatus, isCommitTargetPath, normalizeResultWhitespace, partitionCommitTargets, recordRootNewFilesHandoff, repoRelative, resolveCommitScope, selectStageablePaths, stabilizeCommitTargets, stageCommitTargets, taskPaths, taskTargetsAtHead, unstageCommitTargets, worktreeStatusPaths, } from "./worktree-ops-commit.js";
2
+ export { abortMerge, isExecBranchMergedIntoCurrent, mergeWorktreeIntoCurrent, releaseRootWorkingCopies, restoreRootWorkingCopies, } from "./worktree-ops-merge.js";
3
+ export { WorktreeRemovedBranchDeletionError, checkpointAndEnsureWorktree, discardStaleExecWorktree, listOrphanedExecBranches, pruneOrphanedExecBranches, removeWorktree, } from "./worktree-ops-lifecycle.js";