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
@@ -1,13 +1,14 @@
1
1
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import yaml from "js-yaml";
4
- import { isDctCatalogFileName } from "./catalog-types.js";
5
- import { declaredIncludes, declaredKata } from "./kata.js";
6
- import { resolveBasePath, resolveDeliverablePath } from "./catalog-paths.js";
7
- import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "./frontmatter-namespace.js";
8
- import { flattenTemplateFrontmatter } from "./template-frontmatter.js";
9
- import { specdojoRootDir } from "./specdojo-config.js";
10
- import { resolveSpecdojoPath, resolveSpecdojoPathIfExists, specdojoDirectoryPaths, specdojoResourceCandidates, } from "./template-resolution.js";
3
+ import { load } from "../shared/yaml.js";
4
+ import { isDctCatalogFileName } from "./types.js";
5
+ import { declaredIncludes, declaredKata } from "../kata/kata.js";
6
+ import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
7
+ import { flattenTemplateFrontmatter } from "../docs/template-frontmatter.js";
8
+ import { specdojoRootDir } from "../shared/specdojo-config.js";
9
+ import { buildMarkdown, isRecord, isDctTemplateCatalog, renderCatalogTemplateBody, } from "./build-render.js";
10
+ import { collectResolvedDeliverables, validateBasedOn } from "./build-references.js";
11
+ import { resolveSpecdojoPath, resolveSpecdojoPathIfExists, specdojoDirectoryPaths, specdojoResourceCandidates, } from "../docs/template-resolution.js";
11
12
  const CATALOG_RULEBOOK_ID_PATTERN = /^(?:[a-z][a-z0-9-]*:)?[a-z0-9][a-z0-9-]*-rulebook$/;
12
13
  const CATALOG_KATA_DIRS = {
13
14
  rulebook: "rulebooks",
@@ -30,7 +31,7 @@ function readPracticeDocumentId(filePath) {
30
31
  const id = readSpecdojoNamespace(content).id;
31
32
  return typeof id === "string" ? id : undefined;
32
33
  }
33
- const parsed = yaml.load(content);
34
+ const parsed = load(content);
34
35
  if (!isRecord(parsed))
35
36
  return undefined;
36
37
  const nested = isRecord(parsed.specdojo) ? parsed.specdojo.id : undefined;
@@ -44,148 +45,7 @@ function readPracticeDocumentId(filePath) {
44
45
  }
45
46
  const DCT_INDEX_FILE = "dct-index.yaml";
46
47
  const DCT_INDEX_TEMPLATE = "dct-index-template.md";
47
- function formatDependsOn(deps) {
48
- if (!deps || deps.length === 0)
49
- return "-";
50
- return deps.map((d) => `\`${d}\``).join(", ");
51
- }
52
- function renderTable(deliverables) {
53
- const lines = ["<!-- prettier-ignore -->"];
54
- const hasInstanceIdPattern = deliverables.some((item) => item.instance_id_pattern);
55
- if (hasInstanceIdPattern) {
56
- lines.push("| local-id | 実体IDパターン | 成果物名 | 種別 | 根拠 | 概要 |");
57
- lines.push("| --- | --- | --- | --- | --- | --- |");
58
- }
59
- else {
60
- lines.push("| local-id | 成果物名 | 種別 | 根拠 | 概要 |");
61
- lines.push("| --- | --- | --- | --- | --- |");
62
- }
63
- for (const item of deliverables) {
64
- const localId = `\`${item.local_id}\``;
65
- const deps = formatDependsOn(item.depends_on);
66
- if (hasInstanceIdPattern) {
67
- const instanceIdPattern = item.instance_id_pattern ? `\`${item.instance_id_pattern}\`` : "-";
68
- lines.push(`| ${localId} | ${instanceIdPattern} | ${item.name} | ${item.kind} | ${deps} | ${item.overview} |`);
69
- }
70
- else {
71
- lines.push(`| ${localId} | ${item.name} | ${item.kind} | ${deps} | ${item.overview} |`);
72
- }
73
- }
74
- return lines;
75
- }
76
- function renderDoneCriteria(deliverables) {
77
- const lines = [];
78
- for (const item of deliverables) {
79
- if (item.kind !== "work" || !item.done_criteria || item.done_criteria.length === 0)
80
- continue;
81
- lines.push("");
82
- lines.push(`**\`${item.local_id}\`** の完了条件:`);
83
- lines.push("");
84
- for (const criterion of item.done_criteria) {
85
- lines.push(`- ${criterion.text}`);
86
- }
87
- }
88
- return lines;
89
- }
90
- function renderSections(sections, parentBase, depth, prefix) {
91
- const lines = [];
92
- const hashes = "#".repeat(depth + 1);
93
- let counter = 0;
94
- for (const section of sections) {
95
- const sectionBase = resolveBasePath(parentBase, section.base_path);
96
- if (!section.name) {
97
- // Unnamed section: output content without heading
98
- if (section.base_path) {
99
- lines.push("");
100
- lines.push(`- 配置先: \`${sectionBase}\``);
101
- }
102
- if (section.note) {
103
- lines.push("");
104
- lines.push(section.note);
105
- }
106
- if (section.deliverables && section.deliverables.length > 0) {
107
- lines.push("");
108
- lines.push(...renderTable(section.deliverables));
109
- lines.push(...renderDoneCriteria(section.deliverables));
110
- }
111
- if (section.groups && section.groups.length > 0) {
112
- lines.push(...renderSections(section.groups, sectionBase, depth, prefix));
113
- }
114
- continue;
115
- }
116
- counter++;
117
- const nums = [...prefix, counter];
118
- const numStr = nums.join(".");
119
- lines.push("");
120
- lines.push(`${hashes} ${numStr}. ${section.name}`);
121
- if (section.base_path) {
122
- lines.push("");
123
- lines.push(`- 配置先: \`${sectionBase}\``);
124
- }
125
- if (section.note) {
126
- lines.push("");
127
- lines.push(section.note);
128
- }
129
- if (section.deliverables && section.deliverables.length > 0) {
130
- lines.push("");
131
- lines.push(...renderTable(section.deliverables));
132
- lines.push(...renderDoneCriteria(section.deliverables));
133
- }
134
- if (section.groups && section.groups.length > 0) {
135
- lines.push(...renderSections(section.groups, sectionBase, depth + 1, nums));
136
- }
137
- }
138
- return lines;
139
- }
140
- function buildFrontmatter(doc) {
141
- const inner = [];
142
- inner.push(`id: ${doc.id}`);
143
- inner.push(`type: ${doc.type}`);
144
- inner.push(`status: ${doc.status}`);
145
- if (doc.part_of && doc.part_of.length > 0) {
146
- inner.push("part_of:");
147
- for (const p of doc.part_of) {
148
- const val = p.includes(":") ? `'${p}'` : p;
149
- inner.push(` - ${val}`);
150
- }
151
- }
152
- inner.push("rulebook: specdojo:dct-rulebook");
153
- return buildSpecdojoFrontmatter(inner).split("\n");
154
- }
155
- function isRecord(value) {
156
- return typeof value === "object" && value !== null && !Array.isArray(value);
157
- }
158
- // dct 成果物カタログのテンプレート(type: template)YAML かを判定する。
159
- // テンプレートはインスタンス(type: project)と違い project_id を持たず local_id に
160
- // プレースホルダを含むため、validateDctDoc/buildMarkdown は適用できない。yaml-pages の
161
- // 表示ページで、YAML 丸写しのコードブロックではなく可読な表形式で描画するために使う。
162
- export function isDctTemplateCatalog(yamlRelPath, parsed) {
163
- if (!/\/templates\/dct-.+-template\.ya?ml$/.test(yamlRelPath))
164
- return false;
165
- if (!isRecord(parsed))
166
- return false;
167
- return (parsed.type === "template" && typeof parsed.domain === "string" && Array.isArray(parsed.groups));
168
- }
169
- // dct テンプレートの本文(成果物表+完了条件)を描画する。frontmatter・H1・注記は
170
- // 呼び出し側(yaml-pages 表示ページ)が付与するため、ここでは本文セクションのみ返す。
171
- // インスタンス(buildMarkdown)と同じ renderSections を共用し、表現を一致させる。
172
- export function renderCatalogTemplateBody(doc) {
173
- const topBase = resolveBasePath("", doc.base_path);
174
- return renderSections(doc.groups, topBase, 1, []).join("\n").trim();
175
- }
176
- export function buildMarkdown(doc) {
177
- const lines = [];
178
- lines.push(...buildFrontmatter(doc));
179
- lines.push("");
180
- lines.push(`# 成果物カタログ: ${doc.domain}`);
181
- lines.push("");
182
- lines.push(`- project-id: \`${doc.project_id}\``);
183
- lines.push(`- ドメイン: \`${doc.domain}\``);
184
- const topBase = resolveBasePath("", doc.base_path);
185
- lines.push(...renderSections(doc.groups, topBase, 1, []));
186
- lines.push("");
187
- return lines.join("\n");
188
- }
48
+ export { buildMarkdown, isDctTemplateCatalog, renderCatalogTemplateBody };
189
49
  // Collects every local_id across all dct-*.yaml in a catalog directory.
190
50
  // Used to resolve cross-file depends_on references (same project, other file).
191
51
  export function collectCatalogLocalIds(catalogPath) {
@@ -194,7 +54,7 @@ export function collectCatalogLocalIds(catalogPath) {
194
54
  for (const f of files) {
195
55
  let doc;
196
56
  try {
197
- doc = yaml.load(readFileSync(join(catalogPath, f), "utf8"));
57
+ doc = load(readFileSync(join(catalogPath, f), "utf8"));
198
58
  }
199
59
  catch {
200
60
  continue;
@@ -223,7 +83,7 @@ export function loadCatalogDocs(catalogPath) {
223
83
  const filePath = join(catalogPath, f);
224
84
  let doc;
225
85
  try {
226
- doc = yaml.load(readFileSync(filePath, "utf8"));
86
+ doc = load(readFileSync(filePath, "utf8"));
227
87
  }
228
88
  catch {
229
89
  continue;
@@ -373,7 +233,7 @@ export function validateCatalogLocalIds(catalogPath) {
373
233
  const filePath = join(catalogPath, f);
374
234
  let doc;
375
235
  try {
376
- doc = yaml.load(readFileSync(filePath, "utf8"));
236
+ doc = load(readFileSync(filePath, "utf8"));
377
237
  }
378
238
  catch {
379
239
  continue;
@@ -418,7 +278,7 @@ export function validateRulebookKata(catalogPath) {
418
278
  for (const f of files) {
419
279
  let doc;
420
280
  try {
421
- doc = yaml.load(readFileSync(join(catalogPath, f), "utf8"));
281
+ doc = load(readFileSync(join(catalogPath, f), "utf8"));
422
282
  }
423
283
  catch {
424
284
  continue;
@@ -680,144 +540,7 @@ export function validateDctDoc(doc, filePath, knownLocalIds, repoRoot) {
680
540
  checkDeps(doc.groups);
681
541
  return { ok: errors.length === 0, errors, warnings };
682
542
  }
683
- // Walk all deliverables, resolving each one's document path using the
684
- // leading-slash base_path convention (same rules as renderSections / dct build).
685
- export function collectResolvedDeliverables(sections, parentBase, out) {
686
- for (const section of sections) {
687
- const sectionBase = resolveBasePath(parentBase, section.base_path);
688
- for (const item of section.deliverables ?? []) {
689
- out.push({ item, resolvedPath: resolveDeliverablePath(sectionBase, item.path) });
690
- }
691
- if (section.groups)
692
- collectResolvedDeliverables(section.groups, sectionBase, out);
693
- }
694
- }
695
- // Builds the project-global graph across all dct-*.yaml in the catalog directory.
696
- // depends_on references are same-project local_ids, so they resolve to
697
- // `<project_id>:<dep>`; this lets the graph span multiple catalog files.
698
- function buildCatalogGraph(catalogPath) {
699
- const nodes = new Map();
700
- const files = readdirSync(catalogPath).filter(isDctCatalogFileName).sort();
701
- for (const f of files) {
702
- const filePath = join(catalogPath, f);
703
- let doc;
704
- try {
705
- doc = yaml.load(readFileSync(filePath, "utf8"));
706
- }
707
- catch {
708
- continue;
709
- }
710
- if (!doc || !Array.isArray(doc.groups) || !doc.project_id)
711
- continue;
712
- const projectId = doc.project_id;
713
- const deliverables = [];
714
- collectResolvedDeliverables(doc.groups, resolveBasePath("", doc.base_path), deliverables);
715
- for (const { item, resolvedPath } of deliverables) {
716
- const fullId = `${projectId}:${item.local_id}`;
717
- nodes.set(fullId, {
718
- fullId,
719
- projectId,
720
- localId: item.local_id,
721
- kind: item.kind,
722
- dependsOn: (item.depends_on ?? []).map((dep) => `${projectId}:${dep}`),
723
- filePath,
724
- resolvedDocPath: item.path ? resolvedPath : undefined,
725
- });
726
- }
727
- }
728
- return nodes;
729
- }
730
- // Transitive closure of a node's depends_on edges over the project-global graph.
731
- function transitiveDependsOn(startId, nodes) {
732
- const seen = new Set();
733
- const stack = [...(nodes.get(startId)?.dependsOn ?? [])];
734
- while (stack.length > 0) {
735
- const current = stack.pop();
736
- if (current === undefined || seen.has(current))
737
- continue;
738
- seen.add(current);
739
- for (const dep of nodes.get(current)?.dependsOn ?? []) {
740
- if (!seen.has(dep))
741
- stack.push(dep);
742
- }
743
- }
744
- return seen;
745
- }
746
- // Resolves a based_on reference per specdojo:id-and-file-naming-standard §5.2.
747
- // Bare references resolve to the same project first, then to a global/product id.
748
- function resolveReference(ref, projectId, nodes, knownIds) {
749
- if (ref.includes(":")) {
750
- if (nodes.has(ref)) {
751
- return ref.startsWith(`${projectId}:`)
752
- ? { kind: "catalog", fullId: ref }
753
- : { kind: "external" };
754
- }
755
- return knownIds.has(ref) ? { kind: "external" } : { kind: "unresolved" };
756
- }
757
- const sameProjectId = `${projectId}:${ref}`;
758
- if (nodes.has(sameProjectId))
759
- return { kind: "catalog", fullId: sameProjectId };
760
- if (knownIds.has(sameProjectId))
761
- return { kind: "external" }; // same project, not a catalog deliverable
762
- if (knownIds.has(ref))
763
- return { kind: "external" }; // global / product doc
764
- return { kind: "unresolved" };
765
- }
766
- // Reads the based_on list from a deliverable document's frontmatter.
767
- // Returns null when the document file does not exist.
768
- function readBasedOn(docFsPath) {
769
- if (!existsSync(docFsPath))
770
- return null;
771
- const content = readFileSync(docFsPath, "utf8");
772
- // based_on は Markdown frontmatter の `specdojo:` 名前空間配下にある。
773
- const based = readSpecdojoNamespace(content).based_on;
774
- if (!Array.isArray(based))
775
- return [];
776
- return based.filter((value) => typeof value === "string");
777
- }
778
- // Validates the invariant: every same-project catalog deliverable referenced in
779
- // a document's based_on must lie within that deliverable's transitive depends_on
780
- // closure (project-global). A basis document must be produced before the document
781
- // based on it, so it has to be a (transitive) prerequisite in the WBS.
782
- //
783
- // References are resolved per specdojo:id-and-file-naming-standard §5.2:
784
- // - bare refs resolve to the same project first, then to a global/product id;
785
- // - `<project_id>:<local_id>` and other-project refs use the explicit id.
786
- // `knownIds` is the universe of valid document ids (from the doc index); a
787
- // reference that resolves to neither a catalog deliverable nor a known id is
788
- // reported as an error (typo detection / resolve-or-error).
789
- export function validateBasedOn(catalogPath, rootDir, knownIds) {
790
- const errors = [];
791
- const warnings = [];
792
- const nodes = buildCatalogGraph(catalogPath);
793
- for (const node of nodes.values()) {
794
- if (node.kind !== "work" || !node.resolvedDocPath)
795
- continue;
796
- const basedOn = readBasedOn(join(rootDir, node.resolvedDocPath));
797
- if (basedOn === null) {
798
- warnings.push(`${node.filePath}: ${node.localId}: based_on を検証する文書が見つかりません (${node.resolvedDocPath})`);
799
- continue;
800
- }
801
- const closure = transitiveDependsOn(node.fullId, nodes);
802
- for (const ref of basedOn) {
803
- const resolution = resolveReference(ref, node.projectId, nodes, knownIds);
804
- if (resolution.kind === "unresolved") {
805
- errors.push(`${node.filePath}: ${node.localId}: based_on '${ref}' を解決できません(プロジェクト内 deliverable にもグローバル ID にも一致しません)`);
806
- continue;
807
- }
808
- if (resolution.kind === "external")
809
- continue; // 他プロジェクト/グローバル参照は閉包検査の対象外
810
- if (resolution.fullId === node.fullId) {
811
- errors.push(`${node.filePath}: ${node.localId}: based_on が自分自身を参照しています`);
812
- continue;
813
- }
814
- if (!closure.has(resolution.fullId)) {
815
- errors.push(`${node.filePath}: ${node.localId}: based_on '${ref}' (${resolution.fullId}) が depends_on の推移閉包に含まれていません(根拠ドキュメントは先行成果物である必要があります)`);
816
- }
817
- }
818
- }
819
- return { ok: errors.length === 0, errors, warnings };
820
- }
543
+ export { collectResolvedDeliverables, validateBasedOn };
821
544
  function validateDctIndexStructure(doc, filePath) {
822
545
  const errors = [];
823
546
  if (!doc || typeof doc !== "object") {
@@ -931,7 +654,7 @@ export function loadDctIndex(catalogPath) {
931
654
  const filePath = join(catalogPath, DCT_INDEX_FILE);
932
655
  if (!existsSync(filePath))
933
656
  return null;
934
- return yaml.load(readFileSync(filePath, "utf8"));
657
+ return load(readFileSync(filePath, "utf8"));
935
658
  }
936
659
  // The index declaration and physical domain files must describe exactly the same domain set.
937
660
  // Multiple physical files for one domain intentionally collapse to one declaration.
@@ -1019,7 +742,7 @@ export function buildCatalog(catalogPath) {
1019
742
  const filePath = join(catalogPath, f);
1020
743
  let doc;
1021
744
  try {
1022
- doc = yaml.load(readFileSync(filePath, "utf8"));
745
+ doc = load(readFileSync(filePath, "utf8"));
1023
746
  }
1024
747
  catch (err) {
1025
748
  errors.push(`${filePath}: ${err instanceof Error ? err.message : String(err)}`);
@@ -1,16 +1,16 @@
1
1
  import { join, relative, resolve } from "node:path";
2
2
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { dirname } from "node:path";
4
- import yaml from "js-yaml";
5
- import { getProjectCatalogPath, loadConfig, loadEnv, SPECDOJO_CONFIG_REFERENCE_URL, specdojoRootDir, } from "./specdojo-config.js";
6
- import { buildCatalog, collectCatalogLocalIds, loadDctIndex, validateBasedOn, validateCatalogDomains, validateCatalogIndex, validateCatalogLocalIds, validateDctDoc, validateRulebookKata, } from "./catalog-build.js";
7
- import { collectDocIndexEntries } from "./doc-index.js";
8
- import { deriveProjectId, runScaffold } from "./catalog-scaffold.js";
9
- import { isDctCatalogFileName } from "./catalog-types.js";
10
- import { buildPlanSkeleton, DCT_PLAN_SCHEMA_PATH, domainFromPlanFileName, listPlanFiles, loadPlan, loadTemplateForDomain, planFileName, resolvePlanInputs, resolvePlanPath, resolvePlansDir, validateDctPlan, validatePlanSchema, writePlan, } from "./catalog-plan.js";
11
- import { renderPlanPrompt } from "./catalog-plan-prompt.js";
12
- import { generateCatalogsFromPlan, writeGeneratedCatalogs } from "./catalog-plan-generate.js";
13
- import { resolveSpecdojoReferencePathIfExists, resolveSpecdojoTemplatesDir, } from "./template-resolution.js";
4
+ import { load } from "../shared/yaml.js";
5
+ import { getProjectCatalogPath, loadConfig, loadEnv, SPECDOJO_CONFIG_REFERENCE_URL, specdojoRootDir, } from "../shared/specdojo-config.js";
6
+ import { buildCatalog, collectCatalogLocalIds, loadDctIndex, validateBasedOn, validateCatalogDomains, validateCatalogIndex, validateCatalogLocalIds, validateDctDoc, validateRulebookKata, } from "./build.js";
7
+ import { collectDocIndexEntries } from "../docs/doc-index.js";
8
+ import { deriveProjectId, runScaffold } from "./scaffold.js";
9
+ import { isDctCatalogFileName } from "./types.js";
10
+ import { buildPlanSkeleton, DCT_PLAN_SCHEMA_PATH, domainFromPlanFileName, listPlanFiles, loadPlan, loadTemplateForDomain, planFileName, resolvePlanInputs, resolvePlanPath, resolvePlansDir, validateDctPlan, validatePlanSchema, writePlan, } from "./plan.js";
11
+ import { renderPlanPrompt } from "./plan-prompt.js";
12
+ import { generateCatalogsFromPlan, writeGeneratedCatalogs } from "./plan-generate.js";
13
+ import { resolveSpecdojoReferencePathIfExists, resolveSpecdojoTemplatesDir, } from "../docs/template-resolution.js";
14
14
  function readSizeFromDeclaration(catalogPath) {
15
15
  const size = loadDctIndex(catalogPath)?.size;
16
16
  return size === "small" || size === "medium" || size === "large" ? size : null;
@@ -247,7 +247,7 @@ export function registerCatalogCommands(program) {
247
247
  const filePath = `${catalogPath}/${f}`;
248
248
  try {
249
249
  const raw = readFileSync(filePath, "utf8");
250
- const doc = yaml.load(raw);
250
+ const doc = load(raw);
251
251
  const result = validateDctDoc(doc, filePath, knownLocalIds, repoRoot);
252
252
  for (const err of result.errors) {
253
253
  process.stdout.write(`ERROR: ${err}\n`);
@@ -1,13 +1,13 @@
1
1
  import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
- import yaml from "js-yaml";
4
- import { collectResolvedDeliverables } from "./catalog-build.js";
5
- import { resolveBasePath } from "./catalog-paths.js";
6
- import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "./frontmatter-namespace.js";
7
- import { practiceLocalId } from "./practice-id.js";
8
- import { flattenTemplateFrontmatter } from "./template-frontmatter.js";
9
- import { isDctCatalogFileName } from "./catalog-types.js";
10
- import { resolveSpecdojoPathIfExists, } from "./template-resolution.js";
3
+ import { dump, load } from "../shared/yaml.js";
4
+ import { collectResolvedDeliverables } from "./build.js";
5
+ import { resolveBasePath } from "./paths.js";
6
+ import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
7
+ import { practiceLocalId } from "../shared/practice-id.js";
8
+ import { flattenTemplateFrontmatter } from "../docs/template-frontmatter.js";
9
+ import { isDctCatalogFileName } from "./types.js";
10
+ import { resolveSpecdojoPathIfExists, } from "../docs/template-resolution.js";
11
11
  const PROJECT_ID_PLACEHOLDER = "_PROJECT_ID_";
12
12
  const LOCAL_ID_PLACEHOLDER = "_LOCAL_ID_";
13
13
  const DELIVERABLE_NAME_PLACEHOLDER = "_DELIVERABLE_NAME_";
@@ -109,10 +109,7 @@ function fallbackMarkdown(item, projectId) {
109
109
  const basedOn = (item.depends_on ?? []).map((dep) => `${projectId}:${dep}`);
110
110
  if (basedOn.length > 0)
111
111
  inner.based_on = basedOn;
112
- const innerLines = yaml
113
- .dump(inner, { lineWidth: 120, noRefs: true })
114
- .replace(/\n+$/, "")
115
- .split("\n");
112
+ const innerLines = dump(inner, { lineWidth: 120, noRefs: true }).replace(/\n+$/, "").split("\n");
116
113
  const frontmatter = buildSpecdojoFrontmatter(innerLines);
117
114
  return `${frontmatter}\n\n# ${item.name}\n\n${item.overview}\n\n_TODO_: 本文を記述する\n`;
118
115
  }
@@ -126,12 +123,12 @@ function fallbackYaml(item, projectId) {
126
123
  if (item.rulebook && item.rulebook !== "undecided") {
127
124
  doc.rulebook = item.rulebook === "not-needed" ? "none" : item.rulebook;
128
125
  }
129
- return yaml.dump(doc, { lineWidth: 120, noRefs: true });
126
+ return dump(doc, { lineWidth: 120, noRefs: true });
130
127
  }
131
128
  // Flatten a YAML deliverable template (`metadata_template` + body, minus own-meta)
132
129
  // into its generated form, replacing catalog-derived generation placeholders.
133
130
  function expandYamlTemplate(templatePath, item, projectId) {
134
- const loaded = yaml.load(readFileSync(templatePath, "utf8"));
131
+ const loaded = load(readFileSync(templatePath, "utf8"));
135
132
  if (!isRecord(loaded)) {
136
133
  throw new Error(`Template is not a YAML mapping: ${templatePath}`);
137
134
  }
@@ -139,7 +136,7 @@ function expandYamlTemplate(templatePath, item, projectId) {
139
136
  const body = Object.fromEntries(Object.entries(loaded).filter(([key]) => !TEMPLATE_OWN_META_KEYS.has(key)));
140
137
  const merged = isRecord(metadataTemplate) ? { ...metadataTemplate, ...body } : body;
141
138
  const doc = replaceGeneratedPlaceholders(merged, item, projectId);
142
- return yaml.dump(doc, { lineWidth: 120, noRefs: true });
139
+ return dump(doc, { lineWidth: 120, noRefs: true });
143
140
  }
144
141
  function generateContent(item, resolvedPath, projectId, templatesPath, rulebooksPath, resourceRoots) {
145
142
  if (isYamlPath(resolvedPath)) {
@@ -186,7 +183,7 @@ export function runGenerate(opts) {
186
183
  const filePath = join(catalogPath, f);
187
184
  let doc;
188
185
  try {
189
- doc = yaml.load(readFileSync(filePath, "utf8"));
186
+ doc = load(readFileSync(filePath, "utf8"));
190
187
  }
191
188
  catch (err) {
192
189
  errors.push(`${filePath}: ${err instanceof Error ? err.message : String(err)}`);
@@ -0,0 +1 @@
1
+ export { resolveBasePath, resolveDeliverablePath, isTrashedPath } from "../shared/catalog-paths.js";
@@ -6,10 +6,10 @@
6
6
  // implementation exists.
7
7
  import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync, } from "node:fs";
8
8
  import { join } from "node:path";
9
- import yaml from "js-yaml";
10
- import { collectCatalogLocalIds, validateDctDoc } from "./catalog-build.js";
11
- import { collectTemplateEntries, diffPlanText, loadTemplatesForDomain, validateDctPlan, } from "./catalog-plan.js";
12
- import { catalogFileNameFromTemplate, dumpDctDoc, scaffoldDoc, } from "./catalog-scaffold.js";
9
+ import { load } from "../shared/yaml.js";
10
+ import { collectCatalogLocalIds, validateDctDoc } from "./build.js";
11
+ import { collectTemplateEntries, diffPlanText, loadTemplatesForDomain, validateDctPlan, } from "./plan.js";
12
+ import { catalogFileNameFromTemplate, dumpDctDoc, scaffoldDoc, } from "./scaffold.js";
13
13
  function newOverlay() {
14
14
  return {
15
15
  instances: new Map(),
@@ -222,7 +222,7 @@ function collectCatalogLocalIdsExcept(catalogPath, skip) {
222
222
  function collectDocLocalIdsFromFile(filePath) {
223
223
  let doc = null;
224
224
  try {
225
- doc = yaml.load(readFileSync(filePath, "utf8"));
225
+ doc = load(readFileSync(filePath, "utf8"));
226
226
  }
227
227
  catch {
228
228
  return [];
@@ -6,11 +6,11 @@
6
6
  // base_path, done_criteria) stays in the DCT template and is never copied into a plan.
7
7
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
8
8
  import { basename, join, resolve } from "node:path";
9
- import yaml from "js-yaml";
10
- import { resolveSpecdojoPath, specdojoDirectoryPaths } from "./template-resolution.js";
9
+ import { dump, load } from "../shared/yaml.js";
10
+ import { resolveSpecdojoPath, specdojoDirectoryPaths } from "../docs/template-resolution.js";
11
11
  import Ajv2020Module from "ajv/dist/2020.js";
12
- import { collectResolvedDeliverables, loadCatalogDocs } from "./catalog-build.js";
13
- import { isTrashedPath, resolveBasePath } from "./catalog-paths.js";
12
+ import { collectResolvedDeliverables, loadCatalogDocs } from "./build.js";
13
+ import { isTrashedPath, resolveBasePath } from "./paths.js";
14
14
  export const DCT_PLAN_SCHEMA_VERSION = 1;
15
15
  export const DCT_PLAN_SCHEMA_PATH = "docs/specdojo/schemas/v1/dct-plan.schema.yaml";
16
16
  const PLACEHOLDER_RE = /_([A-Z][A-Z0-9_]*)_/g;
@@ -48,7 +48,7 @@ function compilePlanSchema(repoRoot) {
48
48
  }
49
49
  let schema;
50
50
  try {
51
- schema = yaml.load(readFileSync(schemaPath, "utf8"));
51
+ schema = load(readFileSync(schemaPath, "utf8"));
52
52
  }
53
53
  catch (error) {
54
54
  throw new Error(`Failed to read DCT plan schema: ${schemaPath} (${error instanceof Error ? error.message : String(error)})`);
@@ -100,7 +100,7 @@ export function loadTemplatesForDomain(templatesPath, domain, repoRoot) {
100
100
  for (const [file, filePath] of [...files].sort(([a], [b]) => a.localeCompare(b))) {
101
101
  let template;
102
102
  try {
103
- template = yaml.load(readFileSync(filePath, "utf8"));
103
+ template = load(readFileSync(filePath, "utf8"));
104
104
  }
105
105
  catch {
106
106
  continue;
@@ -373,17 +373,17 @@ export function normalizePlan(plan) {
373
373
  return normalized;
374
374
  }
375
375
  export function dumpPlan(plan) {
376
- return yaml.dump(normalizePlan(plan), {
376
+ return dump(normalizePlan(plan), {
377
377
  lineWidth: 120,
378
378
  noRefs: true,
379
- quotingType: "'",
379
+ quoteStyle: "single",
380
380
  forceQuotes: false,
381
381
  });
382
382
  }
383
383
  export function parsePlan(content, filePath) {
384
384
  let parsed;
385
385
  try {
386
- parsed = yaml.load(content);
386
+ parsed = load(content);
387
387
  }
388
388
  catch (error) {
389
389
  throw new Error(`${filePath}: failed to parse YAML (${error instanceof Error ? error.message : String(error)})`);
@@ -1,8 +1,8 @@
1
1
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import yaml from "js-yaml";
4
- import { practiceLocalId } from "./practice-id.js";
5
- import { specdojoDirectoryPaths } from "./template-resolution.js";
3
+ import { dump, load } from "../shared/yaml.js";
4
+ import { practiceLocalId } from "../shared/practice-id.js";
5
+ import { specdojoDirectoryPaths, } from "../docs/template-resolution.js";
6
6
  const PLACEHOLDER_RE = /_([A-Z][A-Z0-9_]*)_/g;
7
7
  // js-yaml serializes all non-empty arrays in block style.
8
8
  // Restore flow style for the `roles` field to match template formatting.
@@ -15,10 +15,10 @@ function applyFlowStyleRoles(yamlStr) {
15
15
  // Single serialization used by every catalog writer so plan-driven generation and template
16
16
  // scaffolding produce byte-identical formatting for the same document.
17
17
  export function dumpDctDoc(doc) {
18
- const out = yaml.dump(doc, {
18
+ const out = dump(doc, {
19
19
  lineWidth: 120,
20
20
  noRefs: true,
21
- quotingType: "'",
21
+ quoteStyle: "single",
22
22
  forceQuotes: false,
23
23
  });
24
24
  return applyFlowStyleRoles(out);
@@ -210,7 +210,7 @@ export function runScaffold(opts) {
210
210
  for (const [f, templatePath] of [...templateFiles].sort(([a], [b]) => a.localeCompare(b))) {
211
211
  try {
212
212
  const raw = readFileSync(templatePath, "utf8");
213
- loaded.push({ filename: f, path: templatePath, template: yaml.load(raw) });
213
+ loaded.push({ filename: f, path: templatePath, template: load(raw) });
214
214
  }
215
215
  catch (err) {
216
216
  errors.push(`${templatePath}: ${err instanceof Error ? err.message : String(err)}`);
@@ -1,24 +1,24 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { dirname, resolve } from "node:path";
3
- import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, resolveRateLimitPolicy, } from "./exec-agent-config.js";
4
- import { resolveProjectPaths } from "./exec-project.js";
5
- import { executeAgent, loadRosterForExecutionPath } from "./exec-run.js";
6
- import { gitEnvironment } from "./git-environment.js";
7
- import { specdojoRootDir } from "./specdojo-config.js";
3
+ import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, resolveRateLimitPolicy, } from "../exec/agent-config.js";
4
+ import { resolveProjectPaths } from "../exec/project.js";
5
+ import { executeAgent, loadRosterForExecutionPath } from "../exec/run/run.js";
6
+ import { gitEnvironment } from "../shared/git-environment.js";
7
+ import { resolveAgentMember as resolveRosterAgentMember, specdojoRootDir, } from "../shared/specdojo-config.js";
8
8
  // Rate limit は通常失敗と異なり、呼び出し側が処理済みにせず中断・再開する必要がある。
9
9
  // shell script が出力文字列を解析せず分岐できるよう、一時失敗を表す専用コードにする。
10
10
  export const AGENT_RUN_RATE_LIMIT_EXIT_CODE = 75;
11
11
  export function resolveAgentMember(roster, nickname) {
12
- const members = roster?.members.filter((candidate) => {
12
+ const directMembers = roster?.members.filter((candidate) => {
13
13
  return candidate.type === "agent" && candidate.nickname === nickname;
14
14
  });
15
- if (!members || members.length === 0) {
16
- return { error: `--by agent nickname not found in agent-members.yaml: ${nickname}` };
17
- }
18
- if (members.length !== 1) {
15
+ if (directMembers && directMembers.length > 1) {
19
16
  return { error: `--by agent nickname is not unique in agent-members.yaml: ${nickname}` };
20
17
  }
21
- const [member] = members;
18
+ const member = resolveRosterAgentMember(roster, nickname);
19
+ if (!member) {
20
+ return { error: `--by agent nickname not found in agent-members.yaml: ${nickname}` };
21
+ }
22
22
  if (member.disabled) {
23
23
  return { error: `--by agent is disabled in agent-members.yaml: ${nickname}` };
24
24
  }
@@ -1,6 +1,6 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { loadConfig, loadEnv, specdojoRootDir } from "./specdojo-config.js";
3
- import { selfRunArgs } from "./spawn-self.js";
2
+ import { loadConfig, loadEnv, specdojoRootDir } from "../shared/specdojo-config.js";
3
+ import { selfRunArgs } from "../shared/spawn-self.js";
4
4
  const VALID_SCOPES = [
5
5
  "exec",
6
6
  "catalog",