specdojo 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/.github/agents/specdojo-orchestrator.md +61 -2
  2. package/CHANGELOG.md +90 -0
  3. package/README.md +85 -25
  4. package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
  5. package/dist/catalog/build-render.js +32 -0
  6. package/dist/{catalog-build.js → catalog/build.js} +9 -9
  7. package/dist/{catalog.js → catalog/catalog.js} +10 -10
  8. package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
  9. package/dist/catalog/paths.js +1 -0
  10. package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
  11. package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
  12. package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
  13. package/dist/{agent.js → commands/agent.js} +11 -11
  14. package/dist/{build-command.js → commands/build.js} +2 -2
  15. package/dist/{init-command.js → commands/init.js} +168 -45
  16. package/dist/commands/night-orchestrator.js +287 -0
  17. package/dist/{orchestrator.js → commands/orchestrator.js} +12 -5
  18. package/dist/{watch.js → commands/watch.js} +3 -3
  19. package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
  20. package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
  21. package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
  22. package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
  23. package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
  24. package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
  25. package/dist/{timeline.js → dashboard/timeline.js} +1 -1
  26. package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
  27. package/dist/{deliverable-trash.js → deliverable/trash.js} +5 -5
  28. package/dist/{devcontainer-command.js → devcontainer/command.js} +8 -4
  29. package/dist/devcontainer/scaffold.js +418 -0
  30. package/dist/{doc-index.js → docs/doc-index.js} +1 -1
  31. package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
  32. package/dist/{index-command.js → docs/index-command.js} +1 -1
  33. package/dist/docs/template-resolution.js +1 -0
  34. package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +1 -1
  35. package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
  36. package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
  37. package/dist/{exec-agent-config.js → exec/agent-config.js} +92 -5
  38. package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
  39. package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
  40. package/dist/{exec-commands.js → exec/commands.js} +22 -18
  41. package/dist/{exec-core.js → exec/core.js} +11 -11
  42. package/dist/{exec-events.js → exec/events.js} +2 -2
  43. package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
  44. package/dist/exec/exec.js +2 -0
  45. package/dist/exec/format.js +1 -0
  46. package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
  47. package/dist/{exec-limit.js → exec/limit.js} +93 -12
  48. package/dist/{exec-parent-validation.js → exec/parent-validation.js} +18 -4
  49. package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +29 -2
  50. package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
  51. package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
  52. package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
  53. package/dist/{exec-plans.js → exec/plans.js} +3 -3
  54. package/dist/{exec-project.js → exec/project.js} +1 -1
  55. package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
  56. package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
  57. package/dist/{exec-register.js → exec/register.js} +114 -9
  58. package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
  59. package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
  60. package/dist/{exec-repo-integration.js → exec/repo-integration.js} +14 -11
  61. package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
  62. package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
  63. package/dist/{exec-reporter.js → exec/reporter.js} +142 -25
  64. package/dist/{exec-results.js → exec/results.js} +287 -31
  65. package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +35 -12
  66. package/dist/{exec-run-agent.js → exec/run/agent.js} +115 -28
  67. package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
  68. package/dist/{exec-run-job.js → exec/run/job.js} +65 -36
  69. package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
  70. package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
  71. package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
  72. package/dist/{exec-run-register-command.js → exec/run/register-command.js} +38 -11
  73. package/dist/{exec-run-register-core.js → exec/run/register-core.js} +63 -21
  74. package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +58 -31
  75. package/dist/exec/run/register-post-review.js +420 -0
  76. package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +48 -27
  77. package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
  78. package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +119 -24
  79. package/dist/{exec-run.js → exec/run/run.js} +11 -11
  80. package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
  81. package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
  82. package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
  83. package/dist/{exec-run-shared.js → exec/run/shared.js} +78 -30
  84. package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
  85. package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
  86. package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
  87. package/dist/exec/schedule/gantt-chart.js +2 -0
  88. package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
  89. package/dist/exec/schedule/index.js +1 -0
  90. package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
  91. package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
  92. package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
  93. package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
  94. package/dist/exec/shared.js +63 -0
  95. package/dist/exec/slot-lock.js +1 -0
  96. package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
  97. package/dist/{exec-task-repos.js → exec/task-repos.js} +104 -17
  98. package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
  99. package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
  100. package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
  101. package/dist/{exec-trial.js → exec/trial.js} +2 -2
  102. package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
  103. package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
  104. package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
  105. package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
  106. package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
  107. package/dist/exec/worktree.js +305 -0
  108. package/dist/{grade-apply.js → grade/apply.js} +9 -9
  109. package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
  110. package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
  111. package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
  112. package/dist/{grade-core.js → grade/core.js} +3 -3
  113. package/dist/grade/grade.js +19 -0
  114. package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
  115. package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
  116. package/dist/{grade-plan.js → grade/plan.js} +5 -5
  117. package/dist/{grade-result.js → grade/result.js} +5 -94
  118. package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
  119. package/dist/{grade-targets.js → grade/targets.js} +11 -8
  120. package/dist/{job-definition.js → job/definition.js} +25 -6
  121. package/dist/{job.js → job/job.js} +12 -11
  122. package/dist/{kata-command.js → kata/command.js} +3 -3
  123. package/dist/{kata.js → kata/kata.js} +5 -5
  124. package/dist/register/approach.js +134 -0
  125. package/dist/{register-core.js → register/core.js} +26 -8
  126. package/dist/{register-create-commands.js → register/create-commands.js} +171 -8
  127. package/dist/{register-date.js → register/date.js} +1 -1
  128. package/dist/register/derivation.js +163 -0
  129. package/dist/{register-event-merge.js → register/event-merge.js} +44 -3
  130. package/dist/{register-events.js → register/events.js} +13 -3
  131. package/dist/{register-history.js → register/history.js} +7 -6
  132. package/dist/{register-item.js → register/item.js} +32 -5
  133. package/dist/register/lifecycle-lock.js +5 -0
  134. package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
  135. package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
  136. package/dist/{register-migration.js → register/migration.js} +5 -4
  137. package/dist/{register.js → register/register.js} +32 -27
  138. package/dist/{register-renumber.js → register/renumber.js} +38 -11
  139. package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
  140. package/dist/{register-update.js → register/update.js} +5 -5
  141. package/dist/{register-views.js → register/views.js} +47 -7
  142. package/dist/{review-grade.js → review/grade.js} +2 -2
  143. package/dist/{review-plan.js → review/plan.js} +3 -3
  144. package/dist/{routine-definition.js → routine/definition.js} +2 -2
  145. package/dist/{routine.js → routine/routine.js} +49 -22
  146. package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
  147. package/dist/{schedule-build.js → schedule/build.js} +7 -4
  148. package/dist/{schedule.js → schedule/schedule.js} +6 -6
  149. package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
  150. package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
  151. package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
  152. package/dist/shared/agent-types.js +23 -0
  153. package/dist/shared/artifact-path.js +9 -0
  154. package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
  155. package/dist/{catalog-build-render.js → shared/catalog-render.js} +3 -32
  156. package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
  157. package/dist/shared/fs.js +30 -0
  158. package/dist/shared/git.js +346 -0
  159. package/dist/shared/grade-result.js +94 -0
  160. package/dist/{package-paths.js → shared/package-paths.js} +3 -3
  161. package/dist/shared/plan-templates.js +114 -0
  162. package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +6 -3
  163. package/dist/shared/random.js +4 -0
  164. package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
  165. package/dist/shared/schedule-paths.js +9 -0
  166. package/dist/{specdojo-config.js → shared/specdojo-config.js} +162 -21
  167. package/dist/{exec-shared.js → shared/text.js} +4 -135
  168. package/dist/shared/time.js +28 -0
  169. package/dist/shared/workspace-scaffold.js +69 -0
  170. package/dist/specdojo.js +22 -22
  171. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +31 -18
  172. package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
  173. package/docs/ja/specdojo/exec-templates/xep-register-template.md +3 -2
  174. package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
  175. package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
  176. package/docs/ja/specdojo/exec-templates/xrp-register-post-run-template.md +46 -0
  177. package/docs/ja/specdojo/guides/branch-workflow-guide.md +34 -1
  178. package/docs/ja/specdojo/guides/docs-structure-guide.md +2 -0
  179. package/docs/ja/specdojo/guides/exec-config-guide.md +169 -26
  180. package/docs/ja/specdojo/guides/exec-operation-guide.md +184 -13
  181. package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
  182. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +40 -3
  183. package/docs/ja/specdojo/guides/quick-start-guide.md +89 -21
  184. package/docs/ja/specdojo/guides/register-operation-guide.md +44 -1
  185. package/docs/ja/specdojo/guides/remote-host-development-guide.md +61 -6
  186. package/docs/ja/specdojo/guides/review-guide.md +1 -1
  187. package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
  188. package/docs/ja/specdojo/guides/specdojo-overview-guide.md +1 -1
  189. package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
  190. package/docs/ja/specdojo/guides/waza-guide.md +1 -1
  191. package/docs/ja/specdojo/references/command-reference.md +124 -55
  192. package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
  193. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +22 -13
  194. package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
  195. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
  196. package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
  197. package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
  198. package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
  199. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +111 -17
  200. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +28 -0
  201. package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
  202. package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
  203. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +38 -0
  204. package/docs/specdojo/schemas/v1/register-events.schema.yaml +5 -0
  205. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +91 -7
  206. package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
  207. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +36 -1
  208. package/package.json +17 -17
  209. package/templates/antigravity/README.md +6 -2
  210. package/templates/antigravity/agent-members-snippet.yaml +108 -12
  211. package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
  212. package/templates/antigravity/orchestrator.md +61 -2
  213. package/templates/claude/README.md +27 -3
  214. package/templates/claude/agents/claude-executor.md +0 -1
  215. package/templates/claude/agents/claude-reporter.md +2 -1
  216. package/templates/claude/agents/claude-review-executor.md +0 -1
  217. package/templates/claude/agents/specdojo-orchestrator.md +61 -2
  218. package/templates/codex/README.md +40 -4
  219. package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
  220. package/templates/codex/orchestrator.md +61 -2
  221. package/templates/devcontainer/devcontainer.json +5 -2
  222. package/templates/devcontainer/post-create.sh +15 -7
  223. package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +102 -0
  224. package/templates/devcontainer/remote-host/ssh-config.sample +19 -0
  225. package/templates/devcontainer/vim/vimrc +37 -0
  226. package/templates/init-agent-members.yaml +75 -25
  227. package/templates/init-exec-defaults.yaml +44 -9
  228. package/templates/opencode/README.md +17 -3
  229. package/templates/opencode/agents/opencode-executor.md +0 -1
  230. package/templates/opencode/agents/opencode-reporter.md +2 -1
  231. package/templates/opencode/agents/opencode-review-executor.md +0 -1
  232. package/templates/opencode/agents/specdojo-orchestrator.md +61 -2
  233. package/dist/devcontainer-scaffold.js +0 -165
  234. package/dist/exec-schedule-gantt-chart.js +0 -2
  235. package/dist/exec-worktree.js +0 -474
  236. package/dist/exec.js +0 -2
  237. package/dist/grade.js +0 -19
  238. package/templates/claude/agents/claude-expert-review-executor.md +0 -14
  239. /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
  240. /package/dist/{catalog-types.js → catalog/types.js} +0 -0
  241. /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
  242. /package/dist/{role-types.js → exec/role-types.js} +0 -0
  243. /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
  244. /package/dist/{exec-types.js → exec/types.js} +0 -0
  245. /package/dist/{grade-command-shared.js → grade/command-shared.js} +0 -0
  246. /package/dist/{register-command-types.js → register/command-types.js} +0 -0
  247. /package/dist/{review-types.js → review/types.js} +0 -0
  248. /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
  249. /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
  250. /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
  251. /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
  252. /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
  253. /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
  254. /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
  255. /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
  256. /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
  257. /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
  258. /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
  259. /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
  260. /package/dist/{yaml.js → shared/yaml.js} +0 -0
@@ -2,14 +2,16 @@ import { spawnSync } from "node:child_process";
2
2
  import { appendFileSync, existsSync, mkdirSync, readdirSync, rmSync, statSync } from "node:fs";
3
3
  import { join, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { ensureFreshDistBuildForEntry } from "./dist-freshness.js";
6
- import { ROUTINE_BUSY_SKIP_EXIT_CODE, ROUTINE_EXEC_ENV } from "./exec-run-lock.js";
7
- import { ensureDir, listFilesRecursive, nowUtcIsoSeconds, padEndDisplay, readJson, writeJson, } from "./exec-shared.js";
8
- import { jobDeclaresReview, jobRunUsesReviewedIntegration, loadJobDefinition, resolveJobPaths, resolveJobReviewAgentNominations, } from "./job.js";
9
- import { cronOccurrences, isRecord, isRoutineDue, isRoutineYamlFile, isoWeek, loadRoutines, resolveRoutinePaths, routineActionKindLabel, } from "./routine-definition.js";
10
- import { selfRunArgs } from "./spawn-self.js";
11
- import { specdojoRootDir } from "./specdojo-config.js";
12
- export { cronMatches, cronOccurrences, isRoutineDue, isoWeek, loadRoutines, parseCronExpression, parseIntervalMs, parseRoutineDoc, resolveRoutinePaths, routineActionKindLabel, } from "./routine-definition.js";
5
+ import { ensureFreshDistBuildForEntry } from "../shared/dist-freshness.js";
6
+ import { ROUTINE_BUSY_SKIP_EXIT_CODE, ROUTINE_EXEC_ENV } from "../exec/run/lock.js";
7
+ import { ensureDir, listFilesRecursive, readJson, writeJson } from "../shared/fs.js";
8
+ import { padEndDisplay } from "../shared/text.js";
9
+ import { nowUtcIsoSeconds } from "../shared/time.js";
10
+ import { jobDeclaresReview, jobRunUsesReviewedIntegration, loadJobDefinition, resolveJobPaths, resolveJobReviewAgentNominations, } from "../job/job.js";
11
+ import { cronOccurrences, isRecord, isRoutineDue, isRoutineYamlFile, isoWeek, loadRoutines, resolveRoutinePaths, routineActionKindLabel, } from "./definition.js";
12
+ import { selfRunArgs } from "../shared/spawn-self.js";
13
+ import { specdojoRootDir } from "../shared/specdojo-config.js";
14
+ export { cronMatches, cronOccurrences, isRoutineDue, isoWeek, loadRoutines, parseCronExpression, parseIntervalMs, parseRoutineDoc, resolveRoutinePaths, routineActionKindLabel, } from "./definition.js";
13
15
  // ================================
14
16
  // State
15
17
  // ================================
@@ -31,6 +33,31 @@ function writeRoutineState(paths, state) {
31
33
  ensureDir(paths.generatedPath);
32
34
  writeJson(paths.statePath, state);
33
35
  }
36
+ export function recordRoutineStart(current, startedAt, scheduledAt) {
37
+ const next = {
38
+ ...current,
39
+ last_run: startedAt,
40
+ last_result: "running",
41
+ ...(scheduledAt ? { last_scheduled_for: scheduledAt } : {}),
42
+ };
43
+ delete next.last_reason;
44
+ delete next.last_action_results;
45
+ return next;
46
+ }
47
+ export function recordRoutineCompletion(current, result, reason, actionResults) {
48
+ const next = {
49
+ ...current,
50
+ last_run: current?.last_run ?? nowUtcIsoSeconds(),
51
+ last_result: result,
52
+ ...(reason ? { last_reason: reason } : {}),
53
+ ...(actionResults ? { last_action_results: actionResults } : {}),
54
+ };
55
+ if (!reason)
56
+ delete next.last_reason;
57
+ if (!actionResults)
58
+ delete next.last_action_results;
59
+ return next;
60
+ }
34
61
  export function appendRoutineRunHistory(runsPath, entry) {
35
62
  ensureDir(resolve(runsPath, ".."));
36
63
  appendFileSync(runsPath, `${JSON.stringify(entry)}\n`, "utf8");
@@ -74,7 +101,7 @@ function releaseRoutineLock(lockDir) {
74
101
  * tsx で src を直接実行している場合と配布環境では no-op になる。
75
102
  */
76
103
  function ensureFreshDistForRoutineRun() {
77
- const result = ensureFreshDistBuildForEntry(fileURLToPath(import.meta.url));
104
+ const result = ensureFreshDistBuildForEntry(fileURLToPath(new URL("../specdojo.js", import.meta.url)));
78
105
  if (result.message) {
79
106
  const stream = result.outcome === "rebuild-failed" ? process.stderr : process.stdout;
80
107
  stream.write(`[routine] ${result.message}\n`);
@@ -113,6 +140,9 @@ function spawnSelf(args) {
113
140
  }
114
141
  if (result.status === ROUTINE_BUSY_SKIP_EXIT_CODE)
115
142
  return "skipped";
143
+ if (result.status === 0 && marker?.match(/\bstate=([^\s]+)/)?.[1] === "partial") {
144
+ return "partial";
145
+ }
116
146
  return result.status === 0 ? "success" : "failure";
117
147
  }
118
148
  function renderRoutineInput(value, scheduledAt, timezone) {
@@ -162,6 +192,8 @@ export function describeJobActionReview(action, definition) {
162
192
  export function aggregateRoutineActionResults(results) {
163
193
  if (results.includes("failure"))
164
194
  return "failure";
195
+ if (results.includes("partial"))
196
+ return "partial";
165
197
  if (results.includes("skipped"))
166
198
  return "skipped";
167
199
  return "success";
@@ -223,7 +255,7 @@ function findJobRunId(action, projectId, scheduledAt) {
223
255
  return undefined;
224
256
  }
225
257
  // action が配列なら、前段の結果にかかわらず先頭から全段を順次実行する。
226
- // 段別結果を返し、全体結果は failure > skipped > success の順に集約する。
258
+ // 段別結果を返し、全体結果は failure > partial > skipped > success の順に集約する。
227
259
  function executeRoutine(routine, projectId, dryRun, scheduledAt = new Date()) {
228
260
  const { doc } = routine;
229
261
  const actions = Array.isArray(doc.action) ? doc.action : [doc.action];
@@ -428,35 +460,30 @@ export function registerRoutineCommands(program) {
428
460
  lockDir = acquireRoutineLock(paths.routinesPath);
429
461
  }
430
462
  let failed = 0;
463
+ let partial = 0;
431
464
  let skipped = 0;
432
465
  for (const selectedRun of selected) {
433
466
  const { entry, scheduledAt } = selectedRun;
434
467
  const startedAt = nowUtcIsoSeconds();
435
468
  // 実行の試行自体を last_run として先に記録する。失敗した routine が次の
436
469
  // 発火まで再試行されない代わりに、失敗が高頻度で連続発火することを防ぐ。
470
+ // また、実行中は last_result を "running" とし、前回の結果や理由が表示されるのを防ぐ。
437
471
  if (!dryRun) {
438
- state.routines[entry.doc.id] = {
439
- ...state.routines[entry.doc.id],
440
- last_run: startedAt,
441
- ...(entry.doc.trigger ? { last_scheduled_for: scheduledAt.toISOString() } : {}),
442
- };
472
+ state.routines[entry.doc.id] = recordRoutineStart(state.routines[entry.doc.id], startedAt, entry.doc.trigger ? scheduledAt.toISOString() : undefined);
443
473
  writeRoutineState(paths, state);
444
474
  }
445
475
  const execution = executeRoutine(entry, paths.projectId, dryRun, scheduledAt);
446
476
  const { result } = execution;
447
477
  if (result === "failure")
448
478
  failed++;
479
+ if (result === "partial")
480
+ partial++;
449
481
  if (result === "skipped") {
450
482
  skipped++;
451
483
  process.stdout.write(`[routine] skipped ${entry.doc.id}: job action skipped\n`);
452
484
  }
453
485
  if (!dryRun) {
454
- state.routines[entry.doc.id] = {
455
- ...state.routines[entry.doc.id],
456
- last_result: result,
457
- ...(execution.reason ? { last_reason: execution.reason } : { last_reason: undefined }),
458
- last_action_results: execution.actionResults,
459
- };
486
+ state.routines[entry.doc.id] = recordRoutineCompletion(state.routines[entry.doc.id], result, execution.reason, execution.actionResults);
460
487
  writeRoutineState(paths, state);
461
488
  appendRoutineRunHistory(paths.runsPath, {
462
489
  version: 1,
@@ -470,7 +497,7 @@ export function registerRoutineCommands(program) {
470
497
  });
471
498
  }
472
499
  }
473
- process.stdout.write(`[routine] ${selected.length} routine(s) processed, ${skipped} skipped, ${failed} failed\n`);
500
+ process.stdout.write(`[routine] ${selected.length} routine(s) processed, ${partial} partial, ${skipped} skipped, ${failed} failed\n`);
474
501
  if (failed > 0)
475
502
  process.exitCode = 1;
476
503
  }
@@ -2,14 +2,14 @@
2
2
  // sch-strategy-<track>.yaml; deliverable/Kata facts and stored grades are read on every run.
3
3
  import { existsSync, readFileSync } from "node:fs";
4
4
  import { join, resolve } from "node:path";
5
- import { load } from "./yaml.js";
6
- import { collectResolvedDeliverables } from "./catalog-build.js";
7
- import { resolveBasePath } from "./catalog-paths.js";
8
- import { readYaml } from "./exec-shared.js";
9
- import { readSpecdojoNamespace } from "./frontmatter-namespace.js";
10
- import { validateGradedMarkdown } from "./grade.js";
11
- import { readGradeResultForDocument, validateGradeResult } from "./grade-result.js";
12
- import { KATA_MISSING, loadRulebookRefs, resolveKataRefs } from "./kata.js";
5
+ import { load } from "../shared/yaml.js";
6
+ import { collectResolvedDeliverables } from "../catalog/build.js";
7
+ import { resolveBasePath } from "../catalog/paths.js";
8
+ import { readYaml } from "../shared/fs.js";
9
+ import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
10
+ import { validateGradedMarkdown } from "../grade/grade.js";
11
+ import { readGradeResultForDocument, validateGradeResult } from "../grade/result.js";
12
+ import { KATA_MISSING, loadRulebookRefs, resolveKataRefs } from "../kata/kata.js";
13
13
  export const KATA_KINDS = ["rulebook", "recipe", "sample", "template"];
14
14
  function isRecord(value) {
15
15
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1,7 +1,8 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
- import { readYaml } from "./exec-shared.js";
4
- import { expandPhaseSetSelection, normalizePhaseSetSelection, taskIterationSuffix, } from "./schedule-phase-sets.js";
3
+ import { readYaml } from "../shared/fs.js";
4
+ import { resolveAgentMember } from "../shared/specdojo-config.js";
5
+ import { expandPhaseSetSelection, normalizePhaseSetSelection, taskIterationSuffix, } from "./phase-sets.js";
5
6
  // --- Helpers ---
6
7
  function collectDeliverables(sections, includeKinds, catalogId, selectedLocalIds, catalogLocalIds, topLevelGroup, out) {
7
8
  for (const section of sections) {
@@ -134,11 +135,13 @@ function validateAgentAssignment(label, assignment, roster, errors) {
134
135
  if (!nickname)
135
136
  continue;
136
137
  const members = roster.members.filter((member) => member.type === "agent" && member.nickname === nickname);
137
- if (members.length !== 1) {
138
+ // A backward-compatible alias resolves to its concrete member; validate that member's role.
139
+ const resolved = members.length === 0 ? resolveAgentMember(roster, nickname) : undefined;
140
+ if (members.length > 1 || (members.length === 0 && !resolved)) {
138
141
  errors.push(`${label}.agent.${stageRole}: nickname '${nickname}' was not found uniquely in agent-members.yaml`);
139
142
  continue;
140
143
  }
141
- if (members[0].stage_role !== stageRole) {
144
+ if ((members[0] ?? resolved)?.stage_role !== stageRole) {
142
145
  errors.push(`${label}.agent.${stageRole}: nickname '${nickname}' must have stage_role: ${stageRole}`);
143
146
  }
144
147
  }
@@ -1,11 +1,11 @@
1
1
  import { dirname, join, relative, resolve, sep } from "node:path";
2
2
  import { existsSync, readdirSync, writeFileSync } from "node:fs";
3
- import { dump } from "./yaml.js";
4
- import { getProjectCatalogPath, getProjectRolesPath, getProjectSchedulePath, getProjectTimelinePath, loadConfig, loadEnv, loadMemberRoster, specdojoRootDir, } from "./specdojo-config.js";
5
- import { buildScheduleTrack, } from "./schedule-build.js";
6
- import { readYaml } from "./exec-shared.js";
7
- import { resolveSpecdojoPath } from "./template-resolution.js";
8
- import { generateStrategy, writeStrategyFile } from "./schedule-strategy-generate.js";
3
+ import { dump } from "../shared/yaml.js";
4
+ import { getProjectCatalogPath, getProjectRolesPath, getProjectSchedulePath, getProjectTimelinePath, loadConfig, loadEnv, loadMemberRoster, specdojoRootDir, } from "../shared/specdojo-config.js";
5
+ import { buildScheduleTrack, } from "./build.js";
6
+ import { readYaml } from "../shared/fs.js";
7
+ import { resolveSpecdojoPath } from "../docs/template-resolution.js";
8
+ import { generateStrategy, writeStrategyFile } from "./strategy-generate.js";
9
9
  function resolveSchedulePath(opts) {
10
10
  loadEnv();
11
11
  const { config, configPath } = loadConfig();
@@ -1,5 +1,5 @@
1
- import { AUTHOR_PHASE_SETS, PHASE_SET_ORDER, profileFor, renderPhase, STRATEGY_PHASE_SETS, } from "./schedule-strategy-profiles.js";
2
- import { artifactNameFromCatalogTitle, } from "./schedule-strategy-generate-scope.js";
1
+ import { AUTHOR_PHASE_SETS, PHASE_SET_ORDER, profileFor, renderPhase, STRATEGY_PHASE_SETS, } from "./strategy-profiles.js";
2
+ import { artifactNameFromCatalogTitle, } from "./strategy-generate-scope.js";
3
3
  function phaseSetsOf(approach) {
4
4
  return profileFor(approach).phase_sets;
5
5
  }
@@ -1,9 +1,9 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { basename, join, relative, resolve } from "node:path";
3
- import { collectResolvedDeliverables } from "./catalog-build.js";
4
- import { resolveBasePath } from "./catalog-paths.js";
5
- import { readYaml } from "./exec-shared.js";
6
- import { collectCatalogFilesByDomain, loadTimelineIndex } from "./timeline-build.js";
3
+ import { collectResolvedDeliverables } from "../catalog/build.js";
4
+ import { resolveBasePath } from "../catalog/paths.js";
5
+ import { readYaml } from "../shared/fs.js";
6
+ import { collectCatalogFilesByDomain, loadTimelineIndex } from "../dashboard/timeline-build.js";
7
7
  export function isRecord(value) {
8
8
  return typeof value === "object" && value !== null && !Array.isArray(value);
9
9
  }
@@ -5,18 +5,18 @@
5
5
  import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync, } from "node:fs";
6
6
  import { tmpdir } from "node:os";
7
7
  import { basename, join, resolve } from "node:path";
8
- import { dump, load as loadYaml } from "./yaml.js";
9
- import { resolveSpecdojoPath } from "./template-resolution.js";
8
+ import { dump, load as loadYaml } from "../shared/yaml.js";
9
+ import { resolveSpecdojoPath } from "../docs/template-resolution.js";
10
10
  import Ajv2020Module from "ajv/dist/2020.js";
11
- import { diffPlanText } from "./catalog-plan.js";
12
- import { readYaml } from "./exec-shared.js";
13
- import { buildScheduleTrack } from "./schedule-build.js";
14
- import { collectApproachFacts, deriveApproaches, } from "./schedule-approach.js";
15
- import { buildStrategyDocument, } from "./schedule-strategy-generate-document.js";
16
- import { collectScopeDeliverables, isRecord, loadKnownRoles, resolveDeliverableOwners, resolveTrackScopeCatalogs, } from "./schedule-strategy-generate-scope.js";
11
+ import { diffPlanText } from "../catalog/plan.js";
12
+ import { readYaml } from "../shared/fs.js";
13
+ import { buildScheduleTrack } from "./build.js";
14
+ import { collectApproachFacts, deriveApproaches, } from "./approach.js";
15
+ import { buildStrategyDocument, } from "./strategy-generate-document.js";
16
+ import { collectScopeDeliverables, isRecord, loadKnownRoles, resolveDeliverableOwners, resolveTrackScopeCatalogs, } from "./strategy-generate-scope.js";
17
17
  export const SCH_STRATEGY_SCHEMA_PATH = "docs/specdojo/schemas/v1/sch-strategy.schema.yaml";
18
- export { artifactNameFromCatalogTitle, collectScopeDeliverables, loadKnownRoles, resolveDeliverableOwners, resolveTrackScopeCatalogs, } from "./schedule-strategy-generate-scope.js";
19
- export { buildStrategyDocument } from "./schedule-strategy-generate-document.js";
18
+ export { artifactNameFromCatalogTitle, collectScopeDeliverables, loadKnownRoles, resolveDeliverableOwners, resolveTrackScopeCatalogs, } from "./strategy-generate-scope.js";
19
+ export { buildStrategyDocument } from "./strategy-generate-document.js";
20
20
  // ---- serialization & validation ------------------------------------------------
21
21
  export function dumpStrategy(doc) {
22
22
  return dump(doc, {
@@ -0,0 +1,23 @@
1
+ // タスクの進め方プロファイル。前3者は成果物作業で参考資料をどの程度参照するかを表し、
2
+ // <kind>-maintenance は成果物や finding が指す規範を根拠に対象の参考資料を見直す進め方
3
+ // (参照の向きが逆転する)。
4
+ // bootstrap は成果物とその参考資料一式(rulebook/recipe/sample/template)を一貫した一組として
5
+ // 同一タスクで作成・整備する進め方(初期立ち上げ専用)。
6
+ // retrofit は宣言済みの実装エビデンスを現在動作の根拠として読み、成果物へ反映・新設する。
7
+ // cross-deliverable-dedup は明示した成果物群を横断して正本を選び、重複を要約と参照へ置換する。
8
+ // finalize は human が成果物のみを最終確認して status を ready へ確定する進め方、
9
+ // bootstrap-finalize は bootstrap と対になり、成果物と参考資料一式をまとめて確定する進め方。
10
+ export const APPROACHES = [
11
+ "fully-guided",
12
+ "recipe-guided",
13
+ "freeform",
14
+ "bootstrap",
15
+ "retrofit",
16
+ "cross-deliverable-dedup",
17
+ "rulebook-maintenance",
18
+ "recipe-maintenance",
19
+ "sample-maintenance",
20
+ "template-maintenance",
21
+ "finalize",
22
+ "bootstrap-finalize",
23
+ ];
@@ -0,0 +1,9 @@
1
+ import { relative } from "node:path";
2
+ import { specdojoRootDir } from "./specdojo-config.js";
3
+ export function toPortablePath(path) {
4
+ return path.replace(/\\/g, "/");
5
+ }
6
+ export function toArtifactPath(path) {
7
+ const rel = relative(specdojoRootDir(), path);
8
+ return toPortablePath(rel || ".");
9
+ }
@@ -18,7 +18,7 @@ function isPrimaryWorktree(repoRoot) {
18
18
  return existsSync(gitEntry) && lstatSync(gitEntry).isDirectory();
19
19
  }
20
20
  function main() {
21
- const repoRoot = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
21
+ const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
22
22
  if (!isPrimaryWorktree(repoRoot)) {
23
23
  // linked worktree は dist を持たず、agent は tsx で src を直接実行するため対象外。
24
24
  return;
@@ -1,11 +1,10 @@
1
1
  import { resolveBasePath } from "./catalog-paths.js";
2
- import { buildSpecdojoFrontmatter } from "./frontmatter-namespace.js";
3
2
  function formatDependsOn(deps) {
4
3
  if (!deps || deps.length === 0)
5
4
  return "-";
6
5
  return deps.map((d) => `\`${d}\``).join(", ");
7
6
  }
8
- function renderTable(deliverables) {
7
+ export function renderTable(deliverables) {
9
8
  const lines = ["<!-- prettier-ignore -->"];
10
9
  const hasInstanceIdPattern = deliverables.some((item) => item.instance_id_pattern);
11
10
  if (hasInstanceIdPattern) {
@@ -29,7 +28,7 @@ function renderTable(deliverables) {
29
28
  }
30
29
  return lines;
31
30
  }
32
- function renderDoneCriteria(deliverables) {
31
+ export function renderDoneCriteria(deliverables) {
33
32
  const lines = [];
34
33
  for (const item of deliverables) {
35
34
  if (item.kind !== "work" || !item.done_criteria || item.done_criteria.length === 0)
@@ -43,7 +42,7 @@ function renderDoneCriteria(deliverables) {
43
42
  }
44
43
  return lines;
45
44
  }
46
- function renderSections(sections, parentBase, depth, prefix) {
45
+ export function renderSections(sections, parentBase, depth, prefix) {
47
46
  const lines = [];
48
47
  const hashes = "#".repeat(depth + 1);
49
48
  let counter = 0;
@@ -93,21 +92,6 @@ function renderSections(sections, parentBase, depth, prefix) {
93
92
  }
94
93
  return lines;
95
94
  }
96
- function buildFrontmatter(doc) {
97
- const inner = [];
98
- inner.push(`id: ${doc.id}`);
99
- inner.push(`type: ${doc.type}`);
100
- inner.push(`status: ${doc.status}`);
101
- if (doc.part_of && doc.part_of.length > 0) {
102
- inner.push("part_of:");
103
- for (const p of doc.part_of) {
104
- const val = p.includes(":") ? `'${p}'` : p;
105
- inner.push(` - ${val}`);
106
- }
107
- }
108
- inner.push("rulebook: specdojo:dct-rulebook");
109
- return buildSpecdojoFrontmatter(inner).split("\n");
110
- }
111
95
  export function isRecord(value) {
112
96
  return typeof value === "object" && value !== null && !Array.isArray(value);
113
97
  }
@@ -129,16 +113,3 @@ export function renderCatalogTemplateBody(doc) {
129
113
  const topBase = resolveBasePath("", doc.base_path);
130
114
  return renderSections(doc.groups, topBase, 1, []).join("\n").trim();
131
115
  }
132
- export function buildMarkdown(doc) {
133
- const lines = [];
134
- lines.push(...buildFrontmatter(doc));
135
- lines.push("");
136
- lines.push(`# 成果物カタログ: ${doc.domain}`);
137
- lines.push("");
138
- lines.push(`- project-id: \`${doc.project_id}\``);
139
- lines.push(`- ドメイン: \`${doc.domain}\``);
140
- const topBase = resolveBasePath("", doc.base_path);
141
- lines.push(...renderSections(doc.groups, topBase, 1, []));
142
- lines.push("");
143
- return lines.join("\n");
144
- }
@@ -1,7 +1,9 @@
1
1
  import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, utimesSync, } from "node:fs";
2
2
  import { spawn } from "node:child_process";
3
3
  import { join } from "node:path";
4
- import { ensureDir, nowUtcIsoSeconds, randomHex, writeJson } from "./exec-shared.js";
4
+ import { ensureDir, writeJson } from "./fs.js";
5
+ import { randomHex } from "./random.js";
6
+ import { nowUtcIsoSeconds } from "./time.js";
5
7
  // Cross-process locks and counting semaphores built on atomic `mkdir`. Every held lock is a
6
8
  // directory with an `owner.json` and a detached heartbeat process that keeps its mtime fresh.
7
9
  // A lock whose heartbeat stopped (the owner crashed) becomes stale after `staleMs` and may be
@@ -0,0 +1,30 @@
1
+ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { load } from "./yaml.js";
4
+ export function ensureDir(path) {
5
+ if (!existsSync(path))
6
+ mkdirSync(path, { recursive: true });
7
+ }
8
+ export function listFilesRecursive(dir) {
9
+ const out = [];
10
+ if (!existsSync(dir))
11
+ return out;
12
+ for (const name of readdirSync(dir)) {
13
+ const full = join(dir, name);
14
+ const st = statSync(full);
15
+ if (st.isDirectory())
16
+ out.push(...listFilesRecursive(full));
17
+ else if (st.isFile())
18
+ out.push(full);
19
+ }
20
+ return out;
21
+ }
22
+ export function readJson(path) {
23
+ return JSON.parse(readFileSync(path, "utf8"));
24
+ }
25
+ export function writeJson(path, data) {
26
+ writeFileSync(path, JSON.stringify(data, null, 2) + "\n", "utf8");
27
+ }
28
+ export function readYaml(path) {
29
+ return load(readFileSync(path, "utf8"));
30
+ }