specdojo 0.3.0 → 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 (245) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +77 -18
  3. package/dist/catalog/build-references.js +144 -0
  4. package/dist/catalog/build-render.js +32 -0
  5. package/dist/{catalog-build.js → catalog/build.js} +18 -295
  6. package/dist/{catalog.js → catalog/catalog.js} +11 -11
  7. package/dist/{catalog-generate.js → catalog/generate.js} +13 -16
  8. package/dist/catalog/paths.js +1 -0
  9. package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +5 -5
  10. package/dist/{catalog-plan.js → catalog/plan.js} +9 -9
  11. package/dist/{catalog-scaffold.js → catalog/scaffold.js} +6 -6
  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} +103 -37
  15. package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
  16. package/dist/{watch.js → commands/watch.js} +3 -3
  17. package/dist/dashboard/dashboard-timeline.js +175 -0
  18. package/dist/{dashboard.js → dashboard/dashboard.js} +16 -549
  19. package/dist/dashboard/exec-records.js +105 -0
  20. package/dist/dashboard/routines.js +256 -0
  21. package/dist/dashboard/shared.js +14 -0
  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} +7 -7
  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} +3 -3
  29. package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +2 -2
  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} +3 -3
  33. package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
  34. package/dist/{yaml-pages.js → docs/yaml-pages.js} +5 -5
  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.js → exec/commands.js} +22 -467
  39. package/dist/exec/core.js +457 -0
  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.js → exec/plans-core.js} +97 -468
  49. package/dist/exec/plans-generation.js +249 -0
  50. package/dist/exec/plans-storage.js +131 -0
  51. package/dist/exec/plans.js +3 -0
  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 +23 -0
  57. package/dist/exec/repo-integration-sync.js +264 -0
  58. package/dist/{exec-repo-integration.js → exec/repo-integration.js} +13 -287
  59. package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
  60. package/dist/exec/reporter-output.js +206 -0
  61. package/dist/{exec-reporter.js → exec/reporter.js} +29 -216
  62. package/dist/{exec-results.js → exec/results.js} +277 -36
  63. package/dist/exec/run/agent-pipeline.js +276 -0
  64. package/dist/exec/run/agent.js +583 -0
  65. package/dist/exec/run/in-place.js +570 -0
  66. package/dist/exec/run/job.js +746 -0
  67. package/dist/exec/run/lifecycle-commands.js +530 -0
  68. package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
  69. package/dist/exec/run/mode-shared.js +140 -0
  70. package/dist/exec/run/register-command.js +252 -0
  71. package/dist/exec/run/register-core.js +411 -0
  72. package/dist/exec/run/register-mode.js +210 -0
  73. package/dist/exec/run/register-resume.js +398 -0
  74. package/dist/exec/run/register-state.js +325 -0
  75. package/dist/exec/run/register-worktree.js +540 -0
  76. package/dist/exec/run/run.js +11 -0
  77. package/dist/exec/run/schedule-mode.js +294 -0
  78. package/dist/exec/run/schedule-prepare.js +366 -0
  79. package/dist/exec/run/schedule-task.js +599 -0
  80. package/dist/exec/run/shared.js +449 -0
  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.js → exec/trial-commands.js} +23 -388
  97. package/dist/exec/trial-core.js +371 -0
  98. package/dist/exec/trial.js +2 -0
  99. package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
  100. package/dist/exec/worktree-ops-commit.js +672 -0
  101. package/dist/exec/worktree-ops-lifecycle.js +297 -0
  102. package/dist/exec/worktree-ops-merge.js +344 -0
  103. package/dist/exec/worktree-ops.js +3 -0
  104. package/dist/exec/worktree.js +305 -0
  105. package/dist/grade/apply.js +734 -0
  106. package/dist/grade/command-apply.js +250 -0
  107. package/dist/grade/command-inspect.js +138 -0
  108. package/dist/grade/command-plan.js +101 -0
  109. package/dist/grade/command-shared.js +68 -0
  110. package/dist/grade/core.js +307 -0
  111. package/dist/grade/grade.js +19 -0
  112. package/dist/grade/markdown.js +274 -0
  113. package/dist/grade/pipeline-state.js +184 -0
  114. package/dist/grade/plan.js +507 -0
  115. package/dist/{grade-result.js → grade/result.js} +7 -96
  116. package/dist/grade/target-discovery.js +265 -0
  117. package/dist/grade/targets.js +435 -0
  118. package/dist/{job.js → job/definition.js} +32 -574
  119. package/dist/job/job.js +568 -0
  120. package/dist/{kata-command.js → kata/command.js} +4 -4
  121. package/dist/{kata.js → kata/kata.js} +5 -5
  122. package/dist/register/approach.js +134 -0
  123. package/dist/register/command-types.js +1 -0
  124. package/dist/register/core.js +369 -0
  125. package/dist/register/create-commands.js +352 -0
  126. package/dist/{register-date.js → register/date.js} +1 -1
  127. package/dist/register/derivation.js +163 -0
  128. package/dist/{register-event-merge.js → register/event-merge.js} +32 -3
  129. package/dist/{register-events.js → register/events.js} +12 -6
  130. package/dist/{register-history.js → register/history.js} +7 -6
  131. package/dist/{register-item.js → register/item.js} +28 -10
  132. package/dist/register/lifecycle-lock.js +5 -0
  133. package/dist/register/maintenance-commands.js +193 -0
  134. package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
  135. package/dist/register/migration.js +268 -0
  136. package/dist/register/register.js +404 -0
  137. package/dist/register/renumber.js +341 -0
  138. package/dist/register/transition-commands.js +248 -0
  139. package/dist/register/update.js +230 -0
  140. package/dist/register/views.js +296 -0
  141. package/dist/{review-grade.js → review/grade.js} +2 -2
  142. package/dist/{review-plan.js → review/plan.js} +5 -5
  143. package/dist/routine/definition.js +401 -0
  144. package/dist/{routine.js → routine/routine.js} +50 -419
  145. package/dist/{schedule-approach.js → schedule/approach.js} +9 -9
  146. package/dist/{schedule-build.js → schedule/build.js} +7 -4
  147. package/dist/{schedule.js → schedule/schedule.js} +9 -9
  148. package/dist/schedule/strategy-generate-document.js +273 -0
  149. package/dist/schedule/strategy-generate-scope.js +199 -0
  150. package/dist/schedule/strategy-generate.js +348 -0
  151. package/dist/shared/agent-types.js +23 -0
  152. package/dist/shared/artifact-path.js +9 -0
  153. package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
  154. package/dist/shared/catalog-render.js +115 -0
  155. package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
  156. package/dist/shared/fs.js +30 -0
  157. package/dist/shared/git.js +316 -0
  158. package/dist/shared/grade-result.js +94 -0
  159. package/dist/{package-paths.js → shared/package-paths.js} +3 -3
  160. package/dist/shared/plan-templates.js +114 -0
  161. package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +3 -1
  162. package/dist/shared/random.js +4 -0
  163. package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
  164. package/dist/shared/schedule-paths.js +9 -0
  165. package/dist/{specdojo-config.js → shared/specdojo-config.js} +96 -9
  166. package/dist/{exec-shared.js → shared/text.js} +0 -134
  167. package/dist/shared/time.js +28 -0
  168. package/dist/shared/yaml.js +28 -0
  169. package/dist/specdojo.js +22 -22
  170. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +29 -17
  171. package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
  172. package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -2
  173. package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
  174. package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
  175. package/docs/ja/specdojo/guides/exec-config-guide.md +97 -22
  176. package/docs/ja/specdojo/guides/exec-operation-guide.md +145 -12
  177. package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
  178. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +51 -18
  179. package/docs/ja/specdojo/guides/quick-start-guide.md +81 -16
  180. package/docs/ja/specdojo/guides/register-operation-guide.md +2 -1
  181. package/docs/ja/specdojo/guides/remote-host-development-guide.md +10 -1
  182. package/docs/ja/specdojo/guides/review-guide.md +1 -1
  183. package/docs/ja/specdojo/guides/routine-operation-guide.md +6 -6
  184. package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
  185. package/docs/ja/specdojo/references/command-reference.md +52 -28
  186. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +17 -11
  187. package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
  188. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
  189. package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
  190. package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
  191. package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
  192. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +20 -0
  193. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +23 -0
  194. package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
  195. package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
  196. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +26 -0
  197. package/docs/specdojo/schemas/v1/register-events.schema.yaml +3 -0
  198. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +70 -7
  199. package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
  200. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +1 -1
  201. package/package.json +4 -5
  202. package/templates/antigravity/README.md +7 -3
  203. package/templates/antigravity/agent-members-snippet.yaml +108 -12
  204. package/templates/antigravity/exec-defaults-snippet.yaml +10 -13
  205. package/templates/claude/README.md +27 -3
  206. package/templates/claude/agents/claude-executor.md +0 -1
  207. package/templates/claude/agents/claude-reporter.md +2 -1
  208. package/templates/claude/agents/claude-review-executor.md +0 -1
  209. package/templates/codex/README.md +23 -4
  210. package/templates/devcontainer/devcontainer.json +2 -2
  211. package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +69 -0
  212. package/templates/devcontainer/remote-host/ssh-config.sample +16 -0
  213. package/templates/init-agent-members.yaml +75 -25
  214. package/templates/init-exec-defaults.yaml +26 -8
  215. package/templates/opencode/README.md +17 -3
  216. package/templates/opencode/agents/opencode-executor.md +0 -1
  217. package/templates/opencode/agents/opencode-reporter.md +2 -1
  218. package/templates/opencode/agents/opencode-review-executor.md +0 -1
  219. package/dist/exec-run.js +0 -6182
  220. package/dist/exec-schedule-gantt-chart.js +0 -2
  221. package/dist/exec-worktree-ops.js +0 -1292
  222. package/dist/exec-worktree.js +0 -446
  223. package/dist/grade.js +0 -3193
  224. package/dist/register.js +0 -2407
  225. package/dist/schedule-strategy-generate.js +0 -812
  226. package/templates/claude/agents/claude-expert-review-executor.md +0 -14
  227. /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
  228. /package/dist/{catalog-types.js → catalog/types.js} +0 -0
  229. /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
  230. /package/dist/{role-types.js → exec/role-types.js} +0 -0
  231. /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
  232. /package/dist/{exec-types.js → exec/types.js} +0 -0
  233. /package/dist/{review-types.js → review/types.js} +0 -0
  234. /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
  235. /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
  236. /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
  237. /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
  238. /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
  239. /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
  240. /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
  241. /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
  242. /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
  243. /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
  244. /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
  245. /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
@@ -0,0 +1 @@
1
+ export * from "../shared/template-resolution.js";
@@ -1,7 +1,7 @@
1
1
  import { readdirSync, readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- import yaml from "js-yaml";
4
+ import { load } from "../shared/yaml.js";
5
5
  // PJR-H220 / PJR-VJP8: 観点の document_kinds は rulebook ID の列挙で宣言する。rulebook を
6
6
  // 追加したときに観点ごとの扱いの判断が漏れないよう、include / exclude / confirmed_default の
7
7
  // どれにも載っていない rulebook を一覧にする。confirmed_default は判断の記録であり、適用判定
@@ -23,7 +23,7 @@ function rulebookIdFromMarkdown(markdown, filePath) {
23
23
  return undefined;
24
24
  let parsed;
25
25
  try {
26
- parsed = yaml.load(match[1]);
26
+ parsed = load(match[1]);
27
27
  }
28
28
  catch (error) {
29
29
  throw new Error(`Invalid rulebook frontmatter: ${filePath}`, { cause: error });
@@ -101,7 +101,7 @@ export function checkViewpointDocumentKinds(viewpointsPath = DEFAULT_VIEWPOINTS_
101
101
  if (rulebookIds.length === 0) {
102
102
  return { rulebookCount: 0, errors: [`No rulebooks found: ${rulebookDir}`] };
103
103
  }
104
- const doc = yaml.load(readFileSync(viewpointsPath, "utf8"));
104
+ const doc = load(readFileSync(viewpointsPath, "utf8"));
105
105
  const errors = lintViewpointDocumentKinds(doc, rulebookIds).map(formatViewpointDocumentKindsFinding);
106
106
  return { rulebookCount: rulebookIds.length, errors };
107
107
  }
@@ -1,5 +1,5 @@
1
1
  import { resolve } from "node:path";
2
- import { loadEnv, specdojoRootDir } from "./specdojo-config.js";
2
+ import { loadEnv, specdojoRootDir } from "../shared/specdojo-config.js";
3
3
  import { buildYamlPages } from "./yaml-pages.js";
4
4
  function printCommandError(error) {
5
5
  const message = error instanceof Error ? error.message : String(error);
@@ -1,8 +1,8 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join, posix } from "node:path";
3
- import yaml from "js-yaml";
3
+ import { dump, load } from "../shared/yaml.js";
4
4
  import { collectDocIndexEntries } from "./doc-index.js";
5
- import { isDctTemplateCatalog, renderCatalogTemplateBody } from "./catalog-build.js";
5
+ import { isDctTemplateCatalog, renderCatalogTemplateBody } from "../shared/catalog-render.js";
6
6
  // YAML は VitePress のページにならないため、doc-index に載っている YAML ごとに
7
7
  // 同階層の generated/<name>.md へ表示用ページ(本文を yaml コードブロックで埋め込んだ
8
8
  // Markdown)を生成する。wikilink・frontmatter リンクはこのページへ解決される。
@@ -50,7 +50,7 @@ export function yamlPageRelPath(yamlRelPath) {
50
50
  function deriveMeta(yamlRelPath, content) {
51
51
  let parsed;
52
52
  try {
53
- parsed = yaml.load(content);
53
+ parsed = load(content);
54
54
  }
55
55
  catch {
56
56
  parsed = undefined;
@@ -89,7 +89,7 @@ function deriveMeta(yamlRelPath, content) {
89
89
  // 本文中のバッククォート連続より長いフェンスを使って壊れないようにする。
90
90
  export function renderYamlPage(yamlRelPath, content) {
91
91
  const { title, ...meta } = deriveMeta(yamlRelPath, content);
92
- const frontmatter = yaml.dump({ specdojo: meta }, { lineWidth: -1 }).trimEnd();
92
+ const frontmatter = dump({ specdojo: meta }, { lineWidth: -1 }).trimEnd();
93
93
  const fileName = posix.basename(yamlRelPath);
94
94
  const heading = title ?? fileName;
95
95
  const note = `> このページは \`${yamlRelPath}\` から生成された表示用ページです。正本は YAML ファイルであり、このページは再生成できます。`;
@@ -97,7 +97,7 @@ export function renderYamlPage(yamlRelPath, content) {
97
97
  // インスタンス(catalog build)と同じ表形式で本文を描画する。
98
98
  let parsed;
99
99
  try {
100
- parsed = yaml.load(content);
100
+ parsed = load(content);
101
101
  }
102
102
  catch {
103
103
  parsed = undefined;
@@ -1,9 +1,9 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { listFilesRecursive, readYaml } from "./exec-shared.js";
4
- import { acquirePoolSlot, releaseLock } from "./exec-slot-lock.js";
5
- import { specdojoRootDir, } from "./specdojo-config.js";
6
- import { resolveParentValidationConcurrency, resolveParentValidationDefinitions, } from "./exec-parent-validation.js";
3
+ import { listFilesRecursive, readYaml } from "./shared.js";
4
+ import { acquirePoolSlot, releaseLock } from "./slot-lock.js";
5
+ import { specdojoRootDir, } from "../shared/specdojo-config.js";
6
+ import { resolveParentValidationConcurrency, resolveParentValidationDefinitions, } from "./parent-validation.js";
7
7
  const PLACEHOLDER_PATTERN = /\{([a-z][a-z0-9_]*)\}/g;
8
8
  const BUILTIN_VARIABLE_NAMES = new Set(["nickname", "mode", "proficiency"]);
9
9
  // Mirror of the nickname pattern in docs/specdojo/schemas/v1/agent-members.schema.yaml.
@@ -53,6 +53,10 @@ function buildCommandVariables(provider, member, params) {
53
53
  variables.set(key, value);
54
54
  for (const [key, value] of Object.entries(byNickname ?? {}))
55
55
  variables.set(key, value);
56
+ // A concrete member's model is the source of truth. Legacy members without model keep using
57
+ // command_params, so existing one-level rosters and templates remain compatible.
58
+ if (member.model)
59
+ variables.set("model", member.model);
56
60
  return variables;
57
61
  }
58
62
  // Resolve the shell command that launches a member's agent. Returns undefined when the
@@ -88,6 +92,25 @@ export function resolveRateLimitPolicy(config, provider) {
88
92
  const override = provider ? config.providers?.[provider]?.rate_limit_policy : undefined;
89
93
  return override ?? config.rate_limit_policy;
90
94
  }
95
+ export const DEFAULT_PINNED_RATE_LIMIT_MAX_WAIT_SECONDS = 8 * 60 * 60;
96
+ /** Resolve and validate the policy used only for agents selected by nickname. */
97
+ export function resolvePinnedRateLimitPolicy(config, provider) {
98
+ const pinned = resolveRateLimitPolicy(config, provider)?.pinned;
99
+ const action = pinned?.action ?? "stop";
100
+ if (action !== "stop" && action !== "wait" && action !== "fallback") {
101
+ throw new Error(`rate_limit_policy.pinned.action in exec-defaults must be "stop", "wait", or "fallback": ${String(action)}`);
102
+ }
103
+ const maxWaitSeconds = pinned?.max_wait_seconds ?? DEFAULT_PINNED_RATE_LIMIT_MAX_WAIT_SECONDS;
104
+ if (!Number.isFinite(maxWaitSeconds) || maxWaitSeconds < 0) {
105
+ throw new Error(`rate_limit_policy.pinned.max_wait_seconds in exec-defaults must be a non-negative number: ${String(maxWaitSeconds)}`);
106
+ }
107
+ return {
108
+ action,
109
+ maxWaitSeconds,
110
+ ...(pinned?.fallback_executor_by ? { fallbackExecutorBy: pinned.fallback_executor_by } : {}),
111
+ ...(pinned?.fallback_reporter_by ? { fallbackReporterBy: pinned.fallback_reporter_by } : {}),
112
+ };
113
+ }
91
114
  // Resolve a provider's concurrency cap, validating the YAML-sourced value. A missing,
92
115
  // non-integer, or non-positive value means "no limit" (returns undefined).
93
116
  export function resolveMaxConcurrency(config, provider) {
@@ -266,5 +289,11 @@ export function loadExecDefaultsConfig(configPath, executionPath) {
266
289
  resolveParentValidationDefinitions(defaults.pipeline?.parent_validations);
267
290
  resolveParentValidationConcurrency(defaults.pipeline?.parent_validation_concurrency);
268
291
  resolveRegisterExecution(defaults);
292
+ resolvePinnedRateLimitPolicy(defaults);
293
+ for (const provider of Object.keys(defaults.providers ?? {})) {
294
+ if (defaults.providers?.[provider]?.rate_limit_policy) {
295
+ resolvePinnedRateLimitPolicy(defaults, provider);
296
+ }
297
+ }
269
298
  return defaults;
270
299
  }
@@ -1,4 +1,4 @@
1
- import { gitResult } from "./exec-worktree.js";
1
+ import { gitResult } from "./worktree.js";
2
2
  function commandSnapshot(repoRoot, args) {
3
3
  const result = gitResult(repoRoot, args);
4
4
  const stdout = typeof result.stdout === "string" ? result.stdout : "";
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
2
2
  import { createHash } from "node:crypto";
3
3
  import { existsSync, lstatSync, readdirSync, readFileSync, readlinkSync } from "node:fs";
4
4
  import { join, relative, sep } from "node:path";
5
- import { gitEnvironment, gitResult } from "./exec-worktree.js";
5
+ import { gitEnvironment, gitResult } from "./worktree.js";
6
6
  // PJR-3S8Q で agent の書き込み対象外とした、親 runner / hook / CI の実行内容を
7
7
  // 変えられる設定パス。provider 設定から注入できない固定定義として CLI 側に持つ。
8
8
  export const PROTECTED_DIRECTORY_PREFIXES = [
@@ -1,472 +1,23 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join, resolve as pathResolve } from "node:path";
3
- import { validateCatalogLocalIds, validateRulebookKata } from "./catalog-build.js";
4
- import { acquireSchedulerLock, buildEvent, canBlockTask, canCancelTask, canClaimTask, canCompleteTask, canReopenTask, canReleaseTask, canUnblockTask, collectRepeatable, computeReadyIds, findDoingTasksForActor, foldEventsToState, readAllEventFiles, releaseSchedulerLock, schedulerLockPath, writeEventFile, } from "./exec-events.js";
5
- import { activateResolvedProjectPaths, eventsDirForProject, generatedDirForProject, resolveProjectPaths, } from "./exec-project.js";
6
- import { assertValidActor, getProjectViewpointsPath, loadConfig, loadMemberRoster, specdojoRootDir, } from "./specdojo-config.js";
7
- import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, selectNextTask, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./exec-schedule.js";
8
- import { readReadySnapshot } from "./exec-schedule-ready.js";
9
- import { displayWidth, nowUtcIsoSeconds, padEndDisplay, qualifyTaskId, requireNonEmpty, } from "./exec-shared.js";
10
- import { archivePlan, buildInPlaceStem, generateDeliverablePlan, generateSinglePlan, resolveDeliverableTarget, finalizeResultSectionsForDeliverable, targetDocIdsForScheduledTask, stemFromPlanPath, } from "./exec-plans.js";
11
- import { resetResultForClaim, scaffoldResult } from "./exec-results.js";
12
- import { runProviderScaffold, specdojoPackageRootDir } from "./exec-provider-scaffold.js";
13
- import { generateRegisterPlan, normalizePjrId, resolveRegisterRunTarget } from "./exec-register.js";
14
- import { scaffoldViewpoints } from "./review-plan.js";
15
- import { registerCycleCommand, registerResumeCommand, registerRunCommand, registerSlotsCommand, } from "./exec-run.js";
16
- import { buildTaskView } from "./exec-task-view.js";
17
- import { registerExecWorktreeCommands } from "./exec-worktree-command.js";
18
- import { registerExecTrialCommands } from "./exec-trial.js";
19
- import { registerExecHandoffCommands } from "./exec-handoff.js";
20
- import { discardStaleExecWorktree } from "./exec-worktree-ops.js";
21
- import { configuredProductRepos } from "./exec-task-repos.js";
22
- import { buildInitialStateFromStrategy } from "./exec-schedule-initial.js";
23
- import { buildPhaseModeIndex, resolveApproach, resolveOwnerForLocalId, resolveTaskExecution, resolveTaskMode, } from "./exec-strategy.js";
24
- const KNOWN_OWNER_LABELS = ["PO", "PM", "BA", "ARC", "DEV", "QE", "UX", "OPS"];
25
- const KNOWN_OWNER_LABELS_TEXT = KNOWN_OWNER_LABELS.join("|");
26
- const KNOWN_APPROACHES = [
27
- "fully-guided",
28
- "recipe-guided",
29
- "freeform",
30
- "bootstrap",
31
- "retrofit",
32
- "cross-deliverable-dedup",
33
- "rulebook-maintenance",
34
- "recipe-maintenance",
35
- "sample-maintenance",
36
- "template-maintenance",
37
- "finalize",
38
- "bootstrap-finalize",
39
- ];
40
- function parseTaskMode(value) {
41
- const mode = typeof value === "string" ? value.trim().toLowerCase() : "edit";
42
- if (mode !== "edit" && mode !== "review") {
43
- throw new Error(`Invalid --mode value: ${mode}. Use one of: edit|review.`);
44
- }
45
- return mode;
46
- }
47
- function parseApproach(value) {
48
- const approach = typeof value === "string" ? value.trim().toLowerCase() : "";
49
- if (!KNOWN_APPROACHES.includes(approach)) {
50
- throw new Error(`Invalid --approach value: ${approach}. Use one of: ${KNOWN_APPROACHES.join("|")}.`);
51
- }
52
- return approach;
53
- }
54
- function addProjectOptions(cmd) {
55
- return cmd.option("--project <projectId>", "Project id in specdojo.config.json (e.g. shj-0001)");
56
- }
57
- function addLockOptions(cmd) {
58
- return cmd
59
- .option("--allow-multiple-doing", "Allow this actor to hold multiple doing tasks", false)
60
- .option("--lock-timeout-ms <ms>", "Lock acquisition timeout in ms", "10000")
61
- .option("--lock-stale-ms <ms>", "Lock stale threshold in ms", "300000");
62
- }
63
- function addForceOption(cmd) {
64
- return cmd.option("--force", "Human actor only: override the guard on a task held by another actor", false);
65
- }
66
- function addOwnerOptions(cmd) {
67
- return cmd
68
- .option("--owner <owner>", `Planned owner label for assignment checks (${KNOWN_OWNER_LABELS_TEXT}; defaults to SPECDOJO_OWNER, roster owner, or actor)`)
69
- .option("--allow-owner-mismatch", "Allow claiming a task assigned to a different owner", false);
70
- }
71
- // Fixed default messages for routine state transitions. Events whose message carries the
72
- // reason itself (note / block / unblock / reopen / cancel) have no default and keep --msg required.
73
- const DEFAULT_EVENT_MESSAGES = {
74
- claim: "claim task",
75
- complete: "complete task",
76
- release: "release task",
77
- link: "link refs",
78
- estimate: "update estimate",
79
- };
80
- function addCommonAddOptions(cmd, options) {
81
- addProjectOptions(cmd);
82
- // `release --all-blocked` operates on every blocked task instead of a single --task, so the task
83
- // option must be optional for that command. The single-task path still validates it via
84
- // requireNonEmpty before building the event.
85
- if (options?.requireTask === false) {
86
- cmd.option("--task <taskId>", "Task/Milestone ID");
87
- }
88
- else {
89
- cmd.requiredOption("--task <taskId>", "Task/Milestone ID");
90
- }
91
- cmd.requiredOption("--by <actor>", "Actor (human/agent)");
92
- if (options?.msgDefault !== undefined) {
93
- cmd.option("--msg <message>", "Short message", options.msgDefault);
94
- }
95
- else {
96
- cmd.requiredOption("--msg <message>", "Short message");
97
- }
98
- return cmd
99
- .option("--run-id <id>", "Correlation id")
100
- .option("--ref <k=v...>", "refs key=value (repeatable)", collectRepeatable, [])
101
- .option("--meta <k=v...>", "meta key=value (repeatable)", collectRepeatable, [])
102
- .option("--dry-run", "Print event JSON without writing to disk", false);
103
- }
104
- function resolveProjectContext(opts) {
105
- const resolvedPaths = resolveProjectPaths({ project: opts.project });
106
- activateResolvedProjectPaths(resolvedPaths);
107
- return resolvedPaths;
108
- }
109
- function loadRosterForOpts(opts) {
110
- const { config } = loadConfig();
111
- if (!config)
112
- return null;
113
- const projectId = resolveProjectId(opts);
114
- const project = config.projects[projectId];
115
- if (!project)
116
- return null;
117
- return loadMemberRoster(specdojoRootDir(), project);
118
- }
119
- function resolveProjectId(opts) {
120
- const { config } = loadConfig();
121
- return (opts.project?.trim() ||
122
- process.env.SPECDOJO_PROJECT?.trim() ||
123
- config?.current_project?.trim() ||
124
- Object.keys(config?.projects ?? {})[0] ||
125
- "");
126
- }
127
- function findRosterMember(roster, actor) {
128
- return roster?.members.find((member) => member.nickname === actor) ?? null;
129
- }
130
- // The --force override is honored only for actors registered as humans in the
131
- // roster, so agents cannot steal a task another actor is working on.
132
- function resolveForceOverride(opts, actor) {
133
- const isHuman = findRosterMember(loadRosterForOpts(opts), actor)?.type === "human";
134
- return { isHuman, force: !!opts.force };
135
- }
136
- export function resolveClaimOwner(opts, actor, roster = null, taskOwner) {
137
- const cliOwner = typeof opts.owner === "string" ? opts.owner.trim().toUpperCase() : "";
138
- const envOwner = typeof process.env.SPECDOJO_OWNER === "string"
139
- ? process.env.SPECDOJO_OWNER.trim().toUpperCase()
140
- : "";
141
- const rosterMemberRoles = findRosterMember(roster, actor)?.roles ?? [];
142
- // For multi-role actors, prefer the role matching the task's planned owner.
143
- const matchedRole = taskOwner && rosterMemberRoles.length > 1
144
- ? (rosterMemberRoles
145
- .find((r) => r.trim().toUpperCase() === taskOwner.toUpperCase() &&
146
- KNOWN_OWNER_LABELS.includes(r.trim().toUpperCase()))
147
- ?.trim()
148
- .toUpperCase() ?? "")
149
- : "";
150
- const rosterOwner = Array.isArray(rosterMemberRoles) && rosterMemberRoles.length > 0
151
- ? rosterMemberRoles[0].trim().toUpperCase()
152
- : "";
153
- if (cliOwner && !KNOWN_OWNER_LABELS.includes(cliOwner)) {
154
- throw new Error(`Invalid --owner value: ${cliOwner}. Use one of: ${KNOWN_OWNER_LABELS_TEXT}.`);
155
- }
156
- if (envOwner && !KNOWN_OWNER_LABELS.includes(envOwner)) {
157
- throw new Error(`Invalid SPECDOJO_OWNER value: ${envOwner}. Use one of: ${KNOWN_OWNER_LABELS_TEXT}.`);
158
- }
159
- if (rosterOwner &&
160
- !KNOWN_OWNER_LABELS.includes(rosterOwner)) {
161
- throw new Error(`Invalid roster owner for actor ${actor}: ${rosterOwner}. Use one of: ${KNOWN_OWNER_LABELS_TEXT}.`);
162
- }
163
- return cliOwner || envOwner || matchedRole || rosterOwner || "";
164
- }
165
- function resolveSchedulerStrategy(opts, actor, roster = null) {
166
- const cliStrategy = typeof opts.strategy === "string" ? opts.strategy.trim().toLowerCase() : "";
167
- const rosterStrategy = findRosterMember(roster, actor)?.scheduler_strategy ?? "";
168
- const strategy = (cliStrategy || rosterStrategy || "critical-first");
169
- if (strategy !== "critical-first" && strategy !== "fifo") {
170
- throw new Error(`Invalid --strategy value: ${strategy}. Use one of: critical-first|fifo.`);
171
- }
172
- return strategy;
173
- }
174
- function printCommandError(error, fail = true) {
175
- const message = error instanceof Error ? error.message : String(error);
176
- process.stdout.write(message + "\n");
177
- if (fail)
178
- exitWithCode(false);
179
- else
180
- process.exitCode = 1;
181
- }
182
- function loadValidatedExecState(projectPath) {
183
- const res = validateAll(projectPath);
184
- if (!res.ok) {
185
- printValidateResult(res);
186
- exitWithCode(false);
187
- return null;
188
- }
189
- const schedule = buildScheduleIndex(projectPath);
190
- const events = readAllEventFiles(projectPath);
191
- const initialTasks = buildInitialStateFromStrategy(projectPath, schedule);
192
- const snapshot = foldEventsToState(events, schedule, projectPath, initialTasks);
193
- return { schedule, events, snapshot };
194
- }
195
- function ensureActorCanClaimNext(snapshot, actor, allowMultipleDoing) {
196
- const doingTasks = findDoingTasksForActor(snapshot, actor);
197
- if (allowMultipleDoing || doingTasks.length === 0)
198
- return true;
199
- process.stdout.write(`Actor ${actor} already has doing task(s): ${doingTasks.join(", ")}\n` +
200
- `Use --allow-multiple-doing to override.\n`);
201
- exitWithCode(false);
202
- return false;
203
- }
204
- async function scaffoldClaimResult(opts) {
205
- const scheduleNode = opts.state.schedule.nodes.get(opts.taskId);
206
- const localId = scheduleNode?.local_id;
207
- const phaseModeIndex = buildPhaseModeIndex(opts.schedulePath);
208
- const mode = resolveTaskMode(localId, opts.taskId, phaseModeIndex, scheduleNode?.phase_suffix, scheduleNode?.phase_set);
209
- const approach = resolveApproach(localId, opts.taskId, phaseModeIndex, scheduleNode?.phase_suffix, scheduleNode?.phase_set);
210
- const execution = resolveTaskExecution(localId, opts.taskId, phaseModeIndex, scheduleNode?.phase_suffix, scheduleNode?.phase_set);
211
- const finalizeSections = approach === "finalize" || approach === "bootstrap-finalize"
212
- ? finalizeResultSectionsForDeliverable(opts.catalogPath ?? "", localId, approach)
213
- : undefined;
214
- const targets = targetDocIdsForScheduledTask(opts.catalogPath ?? "", {
215
- local_id: localId,
216
- target_local_ids: scheduleNode?.target_local_ids,
217
- approach,
218
- }, opts.projectId);
219
- const result = await scaffoldResult({
220
- executionPath: opts.executionPath,
221
- taskId: opts.taskId,
222
- mode,
223
- projectId: opts.projectId,
224
- ...(execution === "agent" ? { planRef: `exec/plans/${opts.taskId}-plan.md` } : {}),
225
- agent: opts.actor,
226
- startedAt: opts.startedAt,
227
- execution,
228
- ...(approach ? { approach } : {}),
229
- ...(targets ? { targets } : {}),
230
- ...(finalizeSections ? { finalizeSections } : {}),
231
- });
232
- if (!result.created) {
233
- await resetResultForClaim(result.resultPath, opts.actor, opts.startedAt, execution);
234
- }
235
- }
236
- function runSimpleEventCommand(opts, type) {
237
- try {
238
- const { schedulePath } = resolveProjectContext(opts);
239
- const actor = requireNonEmpty("by", opts.by);
240
- const roster = loadRosterForOpts(opts);
241
- assertValidActor(actor, roster);
242
- const event = buildEvent(type, opts);
243
- if (opts.dryRun) {
244
- process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
245
- exitWithCode(true);
246
- return;
247
- }
248
- const out = writeEventFile(schedulePath, event);
249
- process.stdout.write(out + "\n");
250
- exitWithCode(true);
251
- }
252
- catch (error) {
253
- printCommandError(error, false);
254
- }
255
- }
256
- async function runLockedEventCommand(opts, action) {
257
- let lockDir = "";
258
- try {
259
- const { schedulePath, executionPath, catalogPath } = resolveProjectContext(opts);
260
- const actor = requireNonEmpty("by", opts.by);
261
- const roster = loadRosterForOpts(opts);
262
- assertValidActor(actor, roster);
263
- let taskId = typeof opts.task === "string" ? opts.task.trim() : "";
264
- const allowMultipleDoing = !!opts.allowMultipleDoing;
265
- const lockTimeoutMs = Number(opts.lockTimeoutMs);
266
- const lockStaleMs = Number(opts.lockStaleMs);
267
- lockDir = acquireSchedulerLock(schedulePath, { actor, lockTimeoutMs, lockStaleMs });
268
- const state = loadValidatedExecState(schedulePath);
269
- if (!state)
270
- return;
271
- if (!taskId && action.type === "complete") {
272
- const doingTasks = findDoingTasksForActor(state.snapshot, actor);
273
- if (doingTasks.length === 0) {
274
- throw new Error(`Actor ${actor} has no doing task to complete.`);
275
- }
276
- if (doingTasks.length > 1) {
277
- throw new Error(`Actor ${actor} has multiple doing tasks: ${doingTasks.join(", ")}. Specify --task.`);
278
- }
279
- taskId = doingTasks[0];
280
- }
281
- if (!taskId)
282
- taskId = requireNonEmpty("task", opts.task);
283
- const resolvedOpts = { ...opts, task: taskId };
284
- if (action.requireSingleDoing &&
285
- !ensureActorCanClaimNext(state.snapshot, actor, allowMultipleDoing)) {
286
- return;
287
- }
288
- const check = action.check(state, taskId, actor, resolvedOpts);
289
- if (!check.ok) {
290
- process.stdout.write(`Cannot ${action.type} ${taskId}: ${check.reason}\n`);
291
- exitWithCode(false);
292
- return;
293
- }
294
- const event = buildEvent(action.type, resolvedOpts);
295
- if (action.type === "claim") {
296
- const plannedOwner = state.schedule.nodes.get(taskId)?.owner;
297
- const claimOwner = resolveClaimOwner(resolvedOpts, actor, roster, plannedOwner);
298
- const cpm = computeCpm(state.schedule, schedulePath);
299
- writeGeneratedCore(schedulePath, state.events, state.schedule, cpm);
300
- writeScheduleHashAndDiff(schedulePath, state.schedule);
301
- writeCpmFiles(schedulePath, cpm, state.snapshot);
302
- event.meta = {
303
- ...(event.meta ?? {}),
304
- claim_owner: claimOwner,
305
- };
306
- if (plannedOwner)
307
- event.meta.planned_owner = plannedOwner;
308
- if (plannedOwner && claimOwner !== plannedOwner && resolvedOpts.allowOwnerMismatch) {
309
- event.meta.owner_override = true;
310
- }
311
- }
312
- if (opts.dryRun) {
313
- process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
314
- if (action.type === "release" && opts.resetWorktree) {
315
- resetExecWorktreeForTask({
316
- projectId: resolveProjectId(opts),
317
- taskId,
318
- schedulePath,
319
- executionPath,
320
- dryRun: true,
321
- });
322
- }
323
- exitWithCode(true);
324
- return;
325
- }
326
- const out = writeEventFile(schedulePath, event);
327
- if (action.type === "claim") {
328
- await scaffoldClaimResult({
329
- schedulePath,
330
- executionPath,
331
- catalogPath,
332
- taskId,
333
- state,
334
- projectId: resolveProjectId(opts),
335
- actor,
336
- startedAt: new Date().toISOString(),
337
- });
338
- }
339
- // The release event has been persisted (the task is now todo), so a retained exec worktree is
340
- // stale residue. --reset-worktree discards it eagerly instead of waiting for the next claim to
341
- // clean it up via discardStaleExecWorktree.
342
- if (action.type === "release" && opts.resetWorktree) {
343
- resetExecWorktreeForTask({
344
- projectId: resolveProjectId(opts),
345
- taskId,
346
- schedulePath,
347
- executionPath,
348
- dryRun: false,
349
- });
350
- }
351
- process.stdout.write(out + "\n");
352
- exitWithCode(true);
353
- }
354
- catch (error) {
355
- printCommandError(error);
356
- }
357
- finally {
358
- if (lockDir) {
359
- try {
360
- releaseSchedulerLock(lockDir);
361
- }
362
- catch { }
363
- }
364
- }
365
- }
366
- // Discards the exec worktree and branch left behind by a now-released task. A released task is back
367
- // in todo, so any retained worktree is stale residue. `dryRun` only prints what would be discarded.
368
- function resetExecWorktreeForTask(args) {
369
- const worktreeTaskId = qualifyTaskId(args.projectId, args.taskId);
370
- if (args.dryRun) {
371
- process.stdout.write(`[dry-run] reset worktree: discard exec/${worktreeTaskId}\n`);
372
- return;
373
- }
374
- const discarded = discardStaleExecWorktree({
375
- context: {
376
- repoRoot: specdojoRootDir(),
377
- schedulePath: args.schedulePath,
378
- executionPath: args.executionPath,
379
- },
380
- worktreeTaskId,
381
- // PJR-98G4: repos を宣言した project では、プロダクト側の worktree と exec branch も破棄する。
382
- products: configuredProductRepos(args.schedulePath),
383
- });
384
- process.stdout.write(discarded
385
- ? `reset worktree: discarded ${discarded}\n`
386
- : `reset worktree: no worktree or branch for ${worktreeTaskId}\n`);
387
- }
388
- // `release --all-blocked`: return every blocked task in the project to todo under a single scheduler
389
- // lock. Tasks blocked by a different actor are skipped unless --force is given (humans only); each
390
- // skip is reported with its reason. --reset-worktree discards each released task's stale worktree.
391
- async function runReleaseAllBlocked(opts) {
392
- let lockDir = "";
393
- try {
394
- const { schedulePath, executionPath } = resolveProjectContext(opts);
395
- const actor = requireNonEmpty("by", opts.by);
396
- const roster = loadRosterForOpts(opts);
397
- assertValidActor(actor, roster);
398
- requireNonEmpty("msg", opts.msg);
399
- if (opts.task) {
400
- process.stdout.write("Note: --all-blocked ignores --task.\n");
401
- }
402
- const lockTimeoutMs = Number(opts.lockTimeoutMs);
403
- const lockStaleMs = Number(opts.lockStaleMs);
404
- lockDir = acquireSchedulerLock(schedulePath, { actor, lockTimeoutMs, lockStaleMs });
405
- const state = loadValidatedExecState(schedulePath);
406
- if (!state)
407
- return;
408
- const projectId = resolveProjectId(opts);
409
- const blockedTaskIds = Object.entries(state.snapshot.tasks)
410
- .filter(([, cs]) => cs.state === "blocked")
411
- .map(([taskId]) => taskId)
412
- .sort((a, b) => a.localeCompare(b));
413
- if (blockedTaskIds.length === 0) {
414
- process.stdout.write("No blocked tasks to release.\n");
415
- exitWithCode(true);
416
- return;
417
- }
418
- const released = [];
419
- const skipped = [];
420
- const override = resolveForceOverride(opts, actor);
421
- // Releasing one task does not change another task's releasability, so a single snapshot read is
422
- // sufficient even though the in-memory snapshot is not re-folded after each write.
423
- for (const taskId of blockedTaskIds) {
424
- const check = canReleaseTask(state.schedule, state.snapshot, taskId, actor, override);
425
- if (!check.ok) {
426
- skipped.push({ taskId, reason: check.reason ?? "not releasable" });
427
- continue;
428
- }
429
- const event = buildEvent("release", { ...opts, task: taskId });
430
- if (opts.dryRun) {
431
- process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
432
- if (opts.resetWorktree) {
433
- resetExecWorktreeForTask({
434
- projectId,
435
- taskId,
436
- schedulePath,
437
- executionPath,
438
- dryRun: true,
439
- });
440
- }
441
- released.push(taskId);
442
- continue;
443
- }
444
- const out = writeEventFile(schedulePath, event);
445
- if (opts.resetWorktree) {
446
- resetExecWorktreeForTask({ projectId, taskId, schedulePath, executionPath, dryRun: false });
447
- }
448
- process.stdout.write(out + "\n");
449
- released.push(taskId);
450
- }
451
- const dryRunSuffix = opts.dryRun ? " (dry-run)" : "";
452
- process.stdout.write(`\nReleased ${released.length} blocked task(s)${dryRunSuffix}; skipped ${skipped.length}.\n`);
453
- for (const s of skipped) {
454
- process.stdout.write(` skip ${s.taskId}: ${s.reason}\n`);
455
- }
456
- exitWithCode(true);
457
- }
458
- catch (error) {
459
- printCommandError(error);
460
- }
461
- finally {
462
- if (lockDir) {
463
- try {
464
- releaseSchedulerLock(lockDir);
465
- }
466
- catch { }
467
- }
468
- }
469
- }
3
+ import { validateCatalogLocalIds, validateRulebookKata } from "../catalog/build.js";
4
+ import { acquireSchedulerLock, canBlockTask, canCancelTask, canClaimTask, canCompleteTask, canReleaseTask, canReopenTask, canUnblockTask, computeReadyIds, readAllEventFiles, releaseSchedulerLock, schedulerLockPath, writeEventFile, } from "./events.js";
5
+ import { eventsDirForProject, generatedDirForProject } from "./project.js";
6
+ import { assertValidActor, getProjectViewpointsPath, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
7
+ import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, selectNextTask, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./schedule/schedule.js";
8
+ import { readReadySnapshot } from "./schedule/ready.js";
9
+ import { displayWidth, nowUtcIsoSeconds, padEndDisplay, requireNonEmpty } from "./shared.js";
10
+ import { archivePlan, buildInPlaceStem, generateDeliverablePlan, generateSinglePlan, resolveDeliverableTarget, stemFromPlanPath, } from "./plans.js";
11
+ import { runProviderScaffold, specdojoPackageRootDir } from "../shared/provider-scaffold.js";
12
+ import { generateRegisterPlan, normalizePjrId, resolveRegisterRunTarget } from "./register.js";
13
+ import { scaffoldViewpoints } from "../review/plan.js";
14
+ import { registerCycleCommand, registerResumeCommand, registerRunCommand, registerSlotsCommand, } from "./run/run.js";
15
+ import { buildTaskView } from "./task-view.js";
16
+ import { registerExecWorktreeCommands } from "./worktree-command.js";
17
+ import { registerExecTrialCommands } from "./trial.js";
18
+ import { registerExecHandoffCommands } from "./handoff.js";
19
+ import { resolveOwnerForLocalId } from "./strategy.js";
20
+ import { DEFAULT_EVENT_MESSAGES, KNOWN_OWNER_LABELS, KNOWN_OWNER_LABELS_TEXT, addCommonAddOptions, addForceOption, addLockOptions, addOwnerOptions, addProjectOptions, ensureActorCanClaimNext, findRosterMember, loadRosterForOpts, loadValidatedExecState, parseApproach, parseTaskMode, printCommandError, resolveClaimOwner, resolveForceOverride, resolveProjectContext, resolveProjectId, resolveSchedulerStrategy, runLockedEventCommand, runReleaseAllBlocked, runSimpleEventCommand, scaffoldClaimResult, } from "./core.js";
470
21
  export function registerExecCommands(program) {
471
22
  const exec = program.command("exec").description("Execution helpers");
472
23
  registerExecHandoffCommands(exec);
@@ -633,6 +184,10 @@ export function registerExecCommands(program) {
633
184
  const generated = await generateRegisterPlan({
634
185
  executionPath,
635
186
  projectId,
187
+ ...(catalogPath ? { catalogPath } : {}),
188
+ ...(rolesPath ? { rolesPath } : {}),
189
+ ...(viewpointsPath ? { viewpointsPath } : {}),
190
+ ...(projectContext ? { projectContext } : {}),
636
191
  registerPaths,
637
192
  item,
638
193
  stem,