specdojo 0.1.0 → 0.2.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 (540) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +142 -35
  3. package/dist/agent-response.js +27 -0
  4. package/dist/agent.js +124 -0
  5. package/dist/build-command.js +149 -0
  6. package/dist/build-if-stale.js +35 -0
  7. package/dist/catalog-build.js +1079 -0
  8. package/dist/catalog-generate.js +226 -0
  9. package/dist/catalog-paths.js +31 -0
  10. package/dist/catalog-plan-generate.js +301 -0
  11. package/dist/catalog-plan-prompt.js +73 -0
  12. package/dist/catalog-plan.js +471 -0
  13. package/dist/catalog-scaffold.js +255 -0
  14. package/dist/catalog-types.js +4 -0
  15. package/dist/catalog.js +606 -0
  16. package/dist/dashboard.js +990 -0
  17. package/dist/deliverable-trash.js +148 -0
  18. package/dist/deliverable.js +97 -0
  19. package/dist/dist-freshness.js +150 -0
  20. package/dist/doc-index.js +424 -0
  21. package/dist/exec-agent-config.js +172 -0
  22. package/dist/exec-agent-git-state.js +136 -0
  23. package/dist/exec-agent-protected-config.js +276 -0
  24. package/dist/exec-events.js +250 -112
  25. package/dist/exec-evidence.js +317 -0
  26. package/dist/exec-format.js +54 -0
  27. package/dist/exec-limit.js +202 -0
  28. package/dist/exec-parent-validation.js +169 -0
  29. package/dist/exec-pipeline-state.js +160 -0
  30. package/dist/exec-plans.js +1016 -0
  31. package/dist/exec-project.js +25 -11
  32. package/dist/exec-protection-handoff.js +169 -0
  33. package/dist/exec-provider-scaffold.js +99 -0
  34. package/dist/exec-register-resume.js +196 -0
  35. package/dist/exec-register.js +281 -0
  36. package/dist/exec-reporter.js +329 -0
  37. package/dist/exec-results.js +510 -0
  38. package/dist/exec-run-lock.js +149 -0
  39. package/dist/exec-run.js +4953 -0
  40. package/dist/exec-schedule-calendar.js +86 -9
  41. package/dist/exec-schedule-cpm.js +30 -12
  42. package/dist/exec-schedule-gantt-chart-render.js +428 -0
  43. package/dist/exec-schedule-gantt-chart-scope.js +111 -0
  44. package/dist/exec-schedule-gantt-chart.js +2 -0
  45. package/dist/exec-schedule-hash.js +34 -25
  46. package/dist/exec-schedule-index.js +200 -67
  47. package/dist/exec-schedule-initial.js +100 -0
  48. package/dist/exec-schedule-progress.js +51 -26
  49. package/dist/exec-schedule-ready.js +71 -27
  50. package/dist/exec-schedule.js +171 -93
  51. package/dist/exec-shared.js +146 -25
  52. package/dist/exec-strategy.js +547 -0
  53. package/dist/exec-task-view.js +64 -0
  54. package/dist/exec-trial.js +895 -0
  55. package/dist/exec-worktree-command.js +426 -0
  56. package/dist/exec-worktree-ops.js +847 -0
  57. package/dist/exec-worktree.js +359 -0
  58. package/dist/exec.js +744 -192
  59. package/dist/frontmatter-namespace.js +48 -0
  60. package/dist/git-environment.js +23 -0
  61. package/dist/grade-result.js +137 -0
  62. package/dist/grade.js +2456 -0
  63. package/dist/index-command.js +103 -0
  64. package/dist/job.js +1081 -0
  65. package/dist/kata-command.js +303 -0
  66. package/dist/kata.js +187 -0
  67. package/dist/package-paths.js +33 -0
  68. package/dist/practice-id.js +24 -0
  69. package/dist/register-date.js +122 -0
  70. package/dist/register-events.js +363 -0
  71. package/dist/register-history.js +323 -0
  72. package/dist/register-item.js +455 -0
  73. package/dist/register-migrate-timestamps.js +176 -0
  74. package/dist/register.js +2199 -0
  75. package/dist/review-plan.js +199 -0
  76. package/dist/review-types.js +1 -0
  77. package/dist/role-types.js +1 -0
  78. package/dist/routine.js +814 -0
  79. package/dist/schedule-approach.js +252 -0
  80. package/dist/schedule-build.js +552 -0
  81. package/dist/schedule-phase-sets.js +73 -0
  82. package/dist/schedule-strategy-generate.js +812 -0
  83. package/dist/schedule-strategy-profiles.js +276 -0
  84. package/dist/schedule.js +420 -0
  85. package/dist/spawn-self.js +28 -0
  86. package/dist/specdojo-config.js +133 -39
  87. package/dist/specdojo.js +56 -7
  88. package/dist/template-frontmatter.js +89 -0
  89. package/dist/template-resolution.js +92 -0
  90. package/dist/timeline-build.js +334 -0
  91. package/dist/timeline.js +107 -0
  92. package/dist/watch.js +313 -0
  93. package/dist/yaml-pages-command.js +28 -0
  94. package/dist/yaml-pages.js +180 -0
  95. package/dist/yaml-schema-modeline.js +49 -0
  96. package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +600 -0
  97. package/docs/ja/specdojo/exec-templates/xep-bootstrap-template.md +120 -0
  98. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +37 -0
  99. package/docs/ja/specdojo/exec-templates/xep-cross-deliverable-dedup-template.md +51 -0
  100. package/docs/ja/specdojo/exec-templates/xep-freeform-template.md +74 -0
  101. package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +109 -0
  102. package/docs/ja/specdojo/exec-templates/xep-job-template.md +43 -0
  103. package/docs/ja/specdojo/exec-templates/xep-recipe-guided-template.md +82 -0
  104. package/docs/ja/specdojo/exec-templates/xep-recipe-maintenance-template.md +86 -0
  105. package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +42 -0
  106. package/docs/ja/specdojo/exec-templates/xep-register-template.md +49 -0
  107. package/docs/ja/specdojo/exec-templates/xep-retrofit-template.md +98 -0
  108. package/docs/ja/specdojo/exec-templates/xep-rulebook-maintenance-template.md +86 -0
  109. package/docs/ja/specdojo/exec-templates/xep-sample-maintenance-template.md +86 -0
  110. package/docs/ja/specdojo/exec-templates/xep-template-maintenance-template.md +86 -0
  111. package/docs/ja/specdojo/exec-templates/xep-template.md +66 -0
  112. package/docs/ja/specdojo/exec-templates/xer-cross-deliverable-dedup-template.md +31 -0
  113. package/docs/ja/specdojo/exec-templates/xer-human-bootstrap-finalize-template.md +40 -0
  114. package/docs/ja/specdojo/exec-templates/xer-human-finalize-template.md +30 -0
  115. package/docs/ja/specdojo/exec-templates/xer-template.md +19 -0
  116. package/docs/ja/specdojo/exec-templates/xrp-freeform-template.md +70 -0
  117. package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +97 -0
  118. package/docs/ja/specdojo/exec-templates/xrp-recipe-guided-template.md +76 -0
  119. package/docs/ja/specdojo/exec-templates/xrp-recipe-maintenance-template.md +73 -0
  120. package/docs/ja/specdojo/exec-templates/xrp-retrofit-template.md +74 -0
  121. package/docs/ja/specdojo/exec-templates/xrp-rulebook-maintenance-template.md +74 -0
  122. package/docs/ja/specdojo/exec-templates/xrp-sample-maintenance-template.md +73 -0
  123. package/docs/ja/specdojo/exec-templates/xrp-template-maintenance-template.md +73 -0
  124. package/docs/ja/specdojo/exec-templates/xrp-template.md +67 -0
  125. package/docs/ja/specdojo/exec-templates/xrp-viewpoint-detail-template.md +7 -0
  126. package/docs/ja/specdojo/exec-templates/xrr-template.md +21 -0
  127. package/docs/ja/specdojo/exec-templates/xrr-viewpoint-detail-template.md +7 -0
  128. package/docs/ja/specdojo/guides/branch-workflow-guide.md +354 -0
  129. package/docs/ja/specdojo/guides/docs-editing-guide.md +327 -0
  130. package/docs/ja/specdojo/guides/docs-structure-guide.md +519 -0
  131. package/docs/ja/specdojo/guides/exec-config-guide.md +589 -0
  132. package/docs/ja/specdojo/guides/exec-operation-guide.md +440 -0
  133. package/docs/ja/specdojo/guides/exec-worktree-guide.md +318 -0
  134. package/docs/ja/specdojo/guides/kata-guide.md +89 -0
  135. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +127 -0
  136. package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +228 -0
  137. package/docs/ja/specdojo/guides/practice-system-composition-guide.md +111 -0
  138. package/docs/ja/specdojo/guides/quick-start-guide.md +472 -0
  139. package/docs/ja/specdojo/guides/register-operation-guide.md +418 -0
  140. package/docs/ja/specdojo/guides/remote-host-development-guide.md +163 -0
  141. package/docs/ja/specdojo/guides/review-guide.md +428 -0
  142. package/docs/ja/specdojo/guides/routine-operation-guide.md +282 -0
  143. package/docs/ja/specdojo/guides/ryu-guide.md +230 -0
  144. package/docs/ja/specdojo/guides/schedule-design-guide.md +429 -0
  145. package/docs/ja/specdojo/guides/schedule-operation-guide.md +151 -0
  146. package/docs/ja/specdojo/guides/specdojo-overview-guide.md +257 -0
  147. package/docs/ja/specdojo/guides/timeline-design-guide.md +160 -0
  148. package/docs/ja/specdojo/guides/track-design-guide.md +215 -0
  149. package/docs/ja/specdojo/guides/use-case-guide.md +133 -0
  150. package/docs/ja/specdojo/guides/waza-guide.md +224 -0
  151. package/docs/ja/specdojo/index.md +33 -0
  152. package/docs/ja/specdojo/philosophy/needs-to-implementation-philosophy.md +212 -0
  153. package/docs/ja/specdojo/philosophy/specdojo-philosophy.md +242 -0
  154. package/docs/ja/specdojo/recipes/cdfd-overview-recipe.md +198 -0
  155. package/docs/ja/specdojo/recipes/cdfd-recipe.md +218 -0
  156. package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +198 -0
  157. package/docs/ja/specdojo/recipes/exec-human-finalize-recipe.md +100 -0
  158. package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +148 -0
  159. package/docs/ja/specdojo/recipes/pm-communication-plan-recipe.md +97 -0
  160. package/docs/ja/specdojo/recipes/pm-members-recipe.md +149 -0
  161. package/docs/ja/specdojo/recipes/pm-organization-recipe.md +96 -0
  162. package/docs/ja/specdojo/recipes/pm-plan-recipe.md +98 -0
  163. package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +97 -0
  164. package/docs/ja/specdojo/recipes/pm-raci-recipe.md +96 -0
  165. package/docs/ja/specdojo/recipes/pm-roles-recipe.md +136 -0
  166. package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +162 -0
  167. package/docs/ja/specdojo/recipes/prj-charter-recipe.md +187 -0
  168. package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +235 -0
  169. package/docs/ja/specdojo/recipes/prj-issues-and-approach-recipe.md +205 -0
  170. package/docs/ja/specdojo/recipes/prj-overview-recipe.md +289 -0
  171. package/docs/ja/specdojo/recipes/prj-scope-recipe.md +201 -0
  172. package/docs/ja/specdojo/recipes/prj-stakeholder-register-recipe.md +168 -0
  173. package/docs/ja/specdojo/recipes/prj-success-criteria-and-acceptance-criteria-recipe.md +179 -0
  174. package/docs/ja/specdojo/recipes/stsd-recipe.md +138 -0
  175. package/docs/ja/specdojo/references/command-reference.md +718 -0
  176. package/docs/ja/specdojo/references/deliverables-reference.md +407 -0
  177. package/docs/ja/specdojo/references/directory-layout-reference.md +280 -0
  178. package/docs/ja/specdojo/references/specdojo-config-reference.md +133 -0
  179. package/docs/ja/specdojo/rulebooks/atc-index-rulebook.md +372 -0
  180. package/docs/ja/specdojo/rulebooks/atc-rulebook.md +302 -0
  181. package/docs/ja/specdojo/rulebooks/bac-rulebook.md +331 -0
  182. package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +134 -0
  183. package/docs/ja/specdojo/rulebooks/bds-rulebook.md +207 -0
  184. package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +102 -0
  185. package/docs/ja/specdojo/rulebooks/bes-rulebook.md +131 -0
  186. package/docs/ja/specdojo/rulebooks/bps-rulebook.md +269 -0
  187. package/docs/ja/specdojo/rulebooks/br-rulebook.md +187 -0
  188. package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +279 -0
  189. package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +219 -0
  190. package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +233 -0
  191. package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +182 -0
  192. package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +171 -0
  193. package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +105 -0
  194. package/docs/ja/specdojo/rulebooks/cld-rulebook.md +195 -0
  195. package/docs/ja/specdojo/rulebooks/cnd-mermaid-rulebook.md +285 -0
  196. package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +292 -0
  197. package/docs/ja/specdojo/rulebooks/cop-index-rulebook.md +171 -0
  198. package/docs/ja/specdojo/rulebooks/cop-rulebook.md +325 -0
  199. package/docs/ja/specdojo/rulebooks/cpd-mermaid-rulebook.md +266 -0
  200. package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +294 -0
  201. package/docs/ja/specdojo/rulebooks/cstd-rulebook.md +21 -0
  202. package/docs/ja/specdojo/rulebooks/cxd-mermaid-rulebook.md +401 -0
  203. package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +311 -0
  204. package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +158 -0
  205. package/docs/ja/specdojo/rulebooks/dct-rulebook.md +287 -0
  206. package/docs/ja/specdojo/rulebooks/dec-rulebook.md +62 -0
  207. package/docs/ja/specdojo/rulebooks/dmd-index-rulebook.md +100 -0
  208. package/docs/ja/specdojo/rulebooks/dmd-rulebook.md +298 -0
  209. package/docs/ja/specdojo/rulebooks/etc-index-rulebook.md +379 -0
  210. package/docs/ja/specdojo/rulebooks/etc-rulebook.md +310 -0
  211. package/docs/ja/specdojo/rulebooks/gl-rulebook.md +86 -0
  212. package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +297 -0
  213. package/docs/ja/specdojo/rulebooks/ifx-api-rulebook.md +79 -0
  214. package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +213 -0
  215. package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +311 -0
  216. package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +94 -0
  217. package/docs/ja/specdojo/rulebooks/ifx-msg-rulebook.md +81 -0
  218. package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +117 -0
  219. package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +118 -0
  220. package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +116 -0
  221. package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +116 -0
  222. package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +116 -0
  223. package/docs/ja/specdojo/rulebooks/itc-index-rulebook.md +421 -0
  224. package/docs/ja/specdojo/rulebooks/itc-rulebook.md +307 -0
  225. package/docs/ja/specdojo/rulebooks/mip-index-rulebook.md +312 -0
  226. package/docs/ja/specdojo/rulebooks/mm-rulebook.md +63 -0
  227. package/docs/ja/specdojo/rulebooks/mtp-rulebook.md +353 -0
  228. package/docs/ja/specdojo/rulebooks/nfr-availability-rulebook.md +184 -0
  229. package/docs/ja/specdojo/rulebooks/nfr-index-rulebook.md +179 -0
  230. package/docs/ja/specdojo/rulebooks/nfr-integrity-rulebook.md +184 -0
  231. package/docs/ja/specdojo/rulebooks/nfr-maintainability-rulebook.md +183 -0
  232. package/docs/ja/specdojo/rulebooks/nfr-operations-rulebook.md +185 -0
  233. package/docs/ja/specdojo/rulebooks/nfr-performance-rulebook.md +185 -0
  234. package/docs/ja/specdojo/rulebooks/nfr-reliability-rulebook.md +186 -0
  235. package/docs/ja/specdojo/rulebooks/nfr-security-safety-rulebook.md +186 -0
  236. package/docs/ja/specdojo/rulebooks/nfr-usability-rulebook.md +184 -0
  237. package/docs/ja/specdojo/rulebooks/ntp-rulebook.md +61 -0
  238. package/docs/ja/specdojo/rulebooks/opd-index-rulebook.md +84 -0
  239. package/docs/ja/specdojo/rulebooks/opd-rulebook.md +357 -0
  240. package/docs/ja/specdojo/rulebooks/opr-index-rulebook.md +80 -0
  241. package/docs/ja/specdojo/rulebooks/opr-rulebook.md +484 -0
  242. package/docs/ja/specdojo/rulebooks/otp-index-rulebook.md +120 -0
  243. package/docs/ja/specdojo/rulebooks/otp-rulebook.md +293 -0
  244. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +211 -0
  245. package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +94 -0
  246. package/docs/ja/specdojo/rulebooks/pm-communication-plan-rulebook.md +116 -0
  247. package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +93 -0
  248. package/docs/ja/specdojo/rulebooks/pm-members-rulebook.md +190 -0
  249. package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +108 -0
  250. package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +122 -0
  251. package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +117 -0
  252. package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +116 -0
  253. package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +93 -0
  254. package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +146 -0
  255. package/docs/ja/specdojo/rulebooks/pr-rulebook.md +65 -0
  256. package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +178 -0
  257. package/docs/ja/specdojo/rulebooks/prj-charter-rulebook.md +232 -0
  258. package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +235 -0
  259. package/docs/ja/specdojo/rulebooks/prj-issues-and-approach-rulebook.md +242 -0
  260. package/docs/ja/specdojo/rulebooks/prj-overview-rulebook.md +187 -0
  261. package/docs/ja/specdojo/rulebooks/prj-scope-rulebook.md +201 -0
  262. package/docs/ja/specdojo/rulebooks/prj-stakeholder-register-rulebook.md +165 -0
  263. package/docs/ja/specdojo/rulebooks/prj-success-criteria-and-acceptance-criteria-rulebook.md +165 -0
  264. package/docs/ja/specdojo/rulebooks/sac-rulebook.md +202 -0
  265. package/docs/ja/specdojo/rulebooks/sch-rulebook.md +139 -0
  266. package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +63 -0
  267. package/docs/ja/specdojo/rulebooks/sf-rulebook.md +93 -0
  268. package/docs/ja/specdojo/rulebooks/sld-rulebook.md +93 -0
  269. package/docs/ja/specdojo/rulebooks/stc-index-rulebook.md +329 -0
  270. package/docs/ja/specdojo/rulebooks/stc-rulebook.md +297 -0
  271. package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +132 -0
  272. package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +215 -0
  273. package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +376 -0
  274. package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +313 -0
  275. package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +246 -0
  276. package/docs/ja/specdojo/rulebooks/sysd-rulebook.md +119 -0
  277. package/docs/ja/specdojo/rulebooks/tml-rulebook.md +188 -0
  278. package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +114 -0
  279. package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +117 -0
  280. package/docs/ja/specdojo/rulebooks/tsd-index-rulebook.md +101 -0
  281. package/docs/ja/specdojo/rulebooks/tsd-rulebook.md +103 -0
  282. package/docs/ja/specdojo/rulebooks/tsp-index-rulebook.md +396 -0
  283. package/docs/ja/specdojo/rulebooks/uis-rulebook.md +207 -0
  284. package/docs/ja/specdojo/rulebooks/utc-index-rulebook.md +387 -0
  285. package/docs/ja/specdojo/rulebooks/utc-rulebook.md +303 -0
  286. package/docs/ja/specdojo/samples/atc-index-sample.md +38 -0
  287. package/docs/ja/specdojo/samples/atc-sample.md +41 -0
  288. package/docs/ja/specdojo/samples/bac-sample.md +38 -0
  289. package/docs/ja/specdojo/samples/bdd-sample.yaml +71 -0
  290. package/docs/ja/specdojo/samples/bds-sample.md +38 -0
  291. package/docs/ja/specdojo/samples/bes-index-sample.md +38 -0
  292. package/docs/ja/specdojo/samples/bes-sample.md +38 -0
  293. package/docs/ja/specdojo/samples/bps-sample.md +38 -0
  294. package/docs/ja/specdojo/samples/br-sample.md +40 -0
  295. package/docs/ja/specdojo/samples/ccd-sample.md +38 -0
  296. package/docs/ja/specdojo/samples/cdfd-overview-sample.md +284 -0
  297. package/docs/ja/specdojo/samples/cdfd-sample.md +229 -0
  298. package/docs/ja/specdojo/samples/cdfd-uc-sample.md +146 -0
  299. package/docs/ja/specdojo/samples/cdsd-sample.md +38 -0
  300. package/docs/ja/specdojo/samples/cld-sample.md +38 -0
  301. package/docs/ja/specdojo/samples/cnd-sample.md +38 -0
  302. package/docs/ja/specdojo/samples/cop-index-sample.md +38 -0
  303. package/docs/ja/specdojo/samples/cop-sample.md +38 -0
  304. package/docs/ja/specdojo/samples/cpd-sample.md +38 -0
  305. package/docs/ja/specdojo/samples/cstd-sample.md +11 -0
  306. package/docs/ja/specdojo/samples/cxd-sample.md +38 -0
  307. package/docs/ja/specdojo/samples/dct-index-sample.yaml +39 -0
  308. package/docs/ja/specdojo/samples/dct-sample.yaml +91 -0
  309. package/docs/ja/specdojo/samples/dec-sample.md +39 -0
  310. package/docs/ja/specdojo/samples/dmd-index-sample.md +50 -0
  311. package/docs/ja/specdojo/samples/dmd-sample.md +74 -0
  312. package/docs/ja/specdojo/samples/etc-index-sample.md +38 -0
  313. package/docs/ja/specdojo/samples/etc-sample.md +38 -0
  314. package/docs/ja/specdojo/samples/gl-sample.yaml +37 -0
  315. package/docs/ja/specdojo/samples/ifd-sample.md +38 -0
  316. package/docs/ja/specdojo/samples/ifx-api-sample.yaml +102 -0
  317. package/docs/ja/specdojo/samples/ifx-cmd-sample.yaml +107 -0
  318. package/docs/ja/specdojo/samples/ifx-file-sample.md +38 -0
  319. package/docs/ja/specdojo/samples/ifx-msg-sample.yaml +89 -0
  320. package/docs/ja/specdojo/samples/imp-business-sample.md +66 -0
  321. package/docs/ja/specdojo/samples/imp-data-sample.md +60 -0
  322. package/docs/ja/specdojo/samples/imp-interface-sample.md +60 -0
  323. package/docs/ja/specdojo/samples/imp-operations-sample.md +60 -0
  324. package/docs/ja/specdojo/samples/imp-test-sample.md +60 -0
  325. package/docs/ja/specdojo/samples/itc-index-sample.md +38 -0
  326. package/docs/ja/specdojo/samples/itc-sample.md +38 -0
  327. package/docs/ja/specdojo/samples/mip-index-sample.md +38 -0
  328. package/docs/ja/specdojo/samples/mm-sample.md +35 -0
  329. package/docs/ja/specdojo/samples/mtp-sample.md +38 -0
  330. package/docs/ja/specdojo/samples/nfr-availability-sample.md +38 -0
  331. package/docs/ja/specdojo/samples/nfr-index-sample.md +38 -0
  332. package/docs/ja/specdojo/samples/nfr-integrity-sample.md +38 -0
  333. package/docs/ja/specdojo/samples/nfr-maintainability-sample.md +38 -0
  334. package/docs/ja/specdojo/samples/nfr-operations-sample.md +38 -0
  335. package/docs/ja/specdojo/samples/nfr-performance-sample.md +38 -0
  336. package/docs/ja/specdojo/samples/nfr-reliability-sample.md +38 -0
  337. package/docs/ja/specdojo/samples/nfr-security-safety-sample.md +38 -0
  338. package/docs/ja/specdojo/samples/nfr-usability-sample.md +38 -0
  339. package/docs/ja/specdojo/samples/ntp-sample.md +38 -0
  340. package/docs/ja/specdojo/samples/opd-access-control-sample.md +29 -0
  341. package/docs/ja/specdojo/samples/opd-incident-management-sample.md +31 -0
  342. package/docs/ja/specdojo/samples/opd-index-sample.md +41 -0
  343. package/docs/ja/specdojo/samples/opd-monitoring-sample.md +32 -0
  344. package/docs/ja/specdojo/samples/opd-sample.md +38 -0
  345. package/docs/ja/specdojo/samples/opr-access-control-sample.md +24 -0
  346. package/docs/ja/specdojo/samples/opr-backup-restore-sample.md +27 -0
  347. package/docs/ja/specdojo/samples/opr-batch-sample.md +23 -0
  348. package/docs/ja/specdojo/samples/opr-change-sample.md +24 -0
  349. package/docs/ja/specdojo/samples/opr-incident-sample.md +38 -0
  350. package/docs/ja/specdojo/samples/opr-index-sample.md +43 -0
  351. package/docs/ja/specdojo/samples/opr-monitoring-sample.md +27 -0
  352. package/docs/ja/specdojo/samples/opr-sample.md +38 -0
  353. package/docs/ja/specdojo/samples/opr-support-sample.md +23 -0
  354. package/docs/ja/specdojo/samples/otp-index-sample.md +66 -0
  355. package/docs/ja/specdojo/samples/otp-sample.md +68 -0
  356. package/docs/ja/specdojo/samples/pm-change-request-log-sample.md +47 -0
  357. package/docs/ja/specdojo/samples/pm-communication-plan-sample.md +46 -0
  358. package/docs/ja/specdojo/samples/pm-issue-log-sample.md +45 -0
  359. package/docs/ja/specdojo/samples/pm-members-sample.yaml +103 -0
  360. package/docs/ja/specdojo/samples/pm-organization-sample.md +46 -0
  361. package/docs/ja/specdojo/samples/pm-plan-sample.md +57 -0
  362. package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +52 -0
  363. package/docs/ja/specdojo/samples/pm-raci-sample.md +57 -0
  364. package/docs/ja/specdojo/samples/pm-risk-register-sample.md +43 -0
  365. package/docs/ja/specdojo/samples/pm-roles-sample.yaml +41 -0
  366. package/docs/ja/specdojo/samples/pr-sample.md +39 -0
  367. package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +57 -0
  368. package/docs/ja/specdojo/samples/prj-charter-sample.md +121 -0
  369. package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +105 -0
  370. package/docs/ja/specdojo/samples/prj-issues-and-approach-sample.md +78 -0
  371. package/docs/ja/specdojo/samples/prj-overview-sample.md +95 -0
  372. package/docs/ja/specdojo/samples/prj-scope-sample.md +71 -0
  373. package/docs/ja/specdojo/samples/prj-stakeholder-register-sample.md +60 -0
  374. package/docs/ja/specdojo/samples/prj-success-criteria-and-acceptance-criteria-sample.md +62 -0
  375. package/docs/ja/specdojo/samples/sac-sample.md +38 -0
  376. package/docs/ja/specdojo/samples/sf-index-sample.md +38 -0
  377. package/docs/ja/specdojo/samples/sf-sample.md +38 -0
  378. package/docs/ja/specdojo/samples/sld-sample.md +38 -0
  379. package/docs/ja/specdojo/samples/stc-index-sample.md +38 -0
  380. package/docs/ja/specdojo/samples/stc-sample.md +38 -0
  381. package/docs/ja/specdojo/samples/stsd-sample.md +58 -0
  382. package/docs/ja/specdojo/samples/sysd-critical-flows-sample.md +38 -0
  383. package/docs/ja/specdojo/samples/sysd-cross-cutting-policy-sample.md +38 -0
  384. package/docs/ja/specdojo/samples/sysd-index-sample.md +38 -0
  385. package/docs/ja/specdojo/samples/trc-requirements-to-specs-sample.md +56 -0
  386. package/docs/ja/specdojo/samples/trc-requirements-to-tests-sample.md +56 -0
  387. package/docs/ja/specdojo/samples/tsd-index-sample.md +29 -0
  388. package/docs/ja/specdojo/samples/tsd-sample.md +38 -0
  389. package/docs/ja/specdojo/samples/tsp-index-sample.md +38 -0
  390. package/docs/ja/specdojo/samples/uis-sample.md +38 -0
  391. package/docs/ja/specdojo/samples/utc-index-sample.md +38 -0
  392. package/docs/ja/specdojo/samples/utc-sample.md +38 -0
  393. package/docs/ja/specdojo/schemas/v1/guide-content.schema.yaml +20 -0
  394. package/docs/ja/specdojo/schemas/v1/philosophy-content.schema.yaml +21 -0
  395. package/docs/ja/specdojo/schemas/v1/reference-content.schema.yaml +21 -0
  396. package/docs/ja/specdojo/standards/document-metadata-standard.md +323 -0
  397. package/docs/ja/specdojo/standards/exec-human-finalize-standard.md +75 -0
  398. package/docs/ja/specdojo/standards/git-branching-standard.md +227 -0
  399. package/docs/ja/specdojo/standards/guide-authoring-standard.md +124 -0
  400. package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +929 -0
  401. package/docs/ja/specdojo/standards/job-definition-standard.md +148 -0
  402. package/docs/ja/specdojo/standards/people-and-organization-definition-standard.md +431 -0
  403. package/docs/ja/specdojo/standards/philosophy-authoring-standard.md +113 -0
  404. package/docs/ja/specdojo/standards/recipe-authoring-standard.md +143 -0
  405. package/docs/ja/specdojo/standards/reference-authoring-standard.md +99 -0
  406. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +140 -0
  407. package/docs/ja/specdojo/standards/sample-authoring-standard.md +151 -0
  408. package/docs/ja/specdojo/standards/standard-authoring-standard.md +108 -0
  409. package/docs/ja/specdojo/standards/template-authoring-standard.md +101 -0
  410. package/docs/ja/specdojo/standards/test-document-scope-standard.md +176 -0
  411. package/docs/ja/specdojo/templates/cdfd-overview-template.md +199 -0
  412. package/docs/ja/specdojo/templates/cdfd-template.md +173 -0
  413. package/docs/ja/specdojo/templates/cdfd-uc-template.md +148 -0
  414. package/docs/ja/specdojo/templates/dct-architecture-template.yaml +136 -0
  415. package/docs/ja/specdojo/templates/dct-business-acceptance-criteria-template.yaml +34 -0
  416. package/docs/ja/specdojo/templates/dct-business-model-bes-template.yaml +75 -0
  417. package/docs/ja/specdojo/templates/dct-business-model-bps-template.yaml +49 -0
  418. package/docs/ja/specdojo/templates/dct-business-model-br-template.yaml +50 -0
  419. package/docs/ja/specdojo/templates/dct-data-flow-template.yaml +40 -0
  420. package/docs/ja/specdojo/templates/dct-data-model-bdd-template.yaml +46 -0
  421. package/docs/ja/specdojo/templates/dct-data-model-ccd-template.yaml +46 -0
  422. package/docs/ja/specdojo/templates/dct-data-model-cdsd-template.yaml +41 -0
  423. package/docs/ja/specdojo/templates/dct-data-model-cld-template.yaml +38 -0
  424. package/docs/ja/specdojo/templates/dct-data-model-sld-template.yaml +38 -0
  425. package/docs/ja/specdojo/templates/dct-data-model-stsd-template.yaml +46 -0
  426. package/docs/ja/specdojo/templates/dct-external-interface-specs-template.yaml +114 -0
  427. package/docs/ja/specdojo/templates/dct-glossary-template.yaml +35 -0
  428. package/docs/ja/specdojo/templates/dct-impact-analysis-template.yaml +138 -0
  429. package/docs/ja/specdojo/templates/dct-index-template.md +40 -0
  430. package/docs/ja/specdojo/templates/dct-migration-planning-template.yaml +148 -0
  431. package/docs/ja/specdojo/templates/dct-non-functional-requirements-template.yaml +222 -0
  432. package/docs/ja/specdojo/templates/dct-operations-template.yaml +108 -0
  433. package/docs/ja/specdojo/templates/dct-project-definition-template.yaml +210 -0
  434. package/docs/ja/specdojo/templates/dct-project-management-template.yaml +423 -0
  435. package/docs/ja/specdojo/templates/dct-system-acceptance-criteria-template.yaml +37 -0
  436. package/docs/ja/specdojo/templates/dct-system-design-template.yaml +82 -0
  437. package/docs/ja/specdojo/templates/dct-system-functions-template.yaml +58 -0
  438. package/docs/ja/specdojo/templates/dct-test-specs-template.yaml +261 -0
  439. package/docs/ja/specdojo/templates/dct-user-interface-model-template.yaml +60 -0
  440. package/docs/ja/specdojo/templates/ifx-cmd-template.yaml +88 -0
  441. package/docs/ja/specdojo/templates/opr-template.md +85 -0
  442. package/docs/ja/specdojo/templates/pjr-change-request-template.md +60 -0
  443. package/docs/ja/specdojo/templates/pjr-decision-template.md +61 -0
  444. package/docs/ja/specdojo/templates/pjr-index-template.md +49 -0
  445. package/docs/ja/specdojo/templates/pjr-issue-template.md +50 -0
  446. package/docs/ja/specdojo/templates/pjr-note-template.md +35 -0
  447. package/docs/ja/specdojo/templates/pjr-question-template.md +53 -0
  448. package/docs/ja/specdojo/templates/pjr-risk-template.md +49 -0
  449. package/docs/ja/specdojo/templates/pjr-todo-template.md +41 -0
  450. package/docs/ja/specdojo/templates/pjr-views-by-owner-template.md +22 -0
  451. package/docs/ja/specdojo/templates/pjr-views-by-priority-template.md +22 -0
  452. package/docs/ja/specdojo/templates/pjr-views-by-status-template.md +22 -0
  453. package/docs/ja/specdojo/templates/pm-change-request-log-template.md +20 -0
  454. package/docs/ja/specdojo/templates/pm-communication-plan-template.md +46 -0
  455. package/docs/ja/specdojo/templates/pm-decision-log-template.md +20 -0
  456. package/docs/ja/specdojo/templates/pm-issue-log-template.md +20 -0
  457. package/docs/ja/specdojo/templates/pm-members-template.yaml +105 -0
  458. package/docs/ja/specdojo/templates/pm-organization-template.md +44 -0
  459. package/docs/ja/specdojo/templates/pm-plan-template.md +52 -0
  460. package/docs/ja/specdojo/templates/pm-quality-management-plan-template.md +46 -0
  461. package/docs/ja/specdojo/templates/pm-raci-template.md +51 -0
  462. package/docs/ja/specdojo/templates/pm-risk-register-template.md +20 -0
  463. package/docs/ja/specdojo/templates/pm-roles-template.yaml +53 -0
  464. package/docs/ja/specdojo/templates/prj-assumptions-constraints-dependencies-template.md +59 -0
  465. package/docs/ja/specdojo/templates/prj-charter-template.md +116 -0
  466. package/docs/ja/specdojo/templates/prj-comparison-of-alternatives-template.md +116 -0
  467. package/docs/ja/specdojo/templates/prj-issues-and-approach-template.md +89 -0
  468. package/docs/ja/specdojo/templates/prj-overview-template.md +85 -0
  469. package/docs/ja/specdojo/templates/prj-scope-template.md +75 -0
  470. package/docs/ja/specdojo/templates/prj-stakeholder-register-template.md +64 -0
  471. package/docs/ja/specdojo/templates/prj-success-criteria-and-acceptance-criteria-template.md +60 -0
  472. package/docs/ja/specdojo/templates/stsd-template.md +57 -0
  473. package/docs/specdojo/schemas/v1/bdd.schema.yaml +230 -0
  474. package/docs/specdojo/schemas/v1/common-frontmatter.schema.yaml +77 -0
  475. package/docs/specdojo/schemas/v1/dct-index.schema.yaml +85 -0
  476. package/docs/specdojo/schemas/v1/dct-plan.schema.yaml +324 -0
  477. package/docs/specdojo/schemas/v1/dct.schema.yaml +368 -0
  478. package/docs/specdojo/schemas/v1/deliverable-frontmatter.schema.yaml +91 -0
  479. package/docs/specdojo/schemas/v1/esil.schema.yaml +142 -0
  480. package/docs/specdojo/schemas/v1/exec-common.schema.yaml +101 -0
  481. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +272 -0
  482. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +162 -0
  483. package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +126 -0
  484. package/docs/specdojo/schemas/v1/exec-reporter-output.schema.yaml +151 -0
  485. package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +144 -0
  486. package/docs/specdojo/schemas/v1/grade-done-criteria.schema.yaml +79 -0
  487. package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +60 -0
  488. package/docs/specdojo/schemas/v1/grade-result.schema.yaml +118 -0
  489. package/docs/specdojo/schemas/v1/guide-frontmatter.schema.yaml +19 -0
  490. package/docs/specdojo/schemas/v1/ifx-cmd.schema.yaml +293 -0
  491. package/docs/specdojo/schemas/v1/job-run.schema.yaml +90 -0
  492. package/docs/specdojo/schemas/v1/job.schema.yaml +198 -0
  493. package/docs/specdojo/schemas/v1/philosophy-frontmatter.schema.yaml +19 -0
  494. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +56 -0
  495. package/docs/specdojo/schemas/v1/pm-members.schema.yaml +252 -0
  496. package/docs/specdojo/schemas/v1/pm-review-viewpoints.schema.yaml +387 -0
  497. package/docs/specdojo/schemas/v1/pm-roles.schema.yaml +106 -0
  498. package/docs/specdojo/schemas/v1/recipe-frontmatter.schema.yaml +27 -0
  499. package/docs/specdojo/schemas/v1/reference-frontmatter.schema.yaml +18 -0
  500. package/docs/specdojo/schemas/v1/register-events.schema.yaml +106 -0
  501. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +204 -0
  502. package/docs/specdojo/schemas/v1/routine-run.schema.yaml +36 -0
  503. package/docs/specdojo/schemas/v1/routine.schema.yaml +87 -0
  504. package/docs/specdojo/schemas/v1/rulebook-frontmatter.schema.yaml +61 -0
  505. package/docs/specdojo/schemas/v1/sch-common.schema.yaml +258 -0
  506. package/docs/specdojo/schemas/v1/sch-defaults.schema.yaml +48 -0
  507. package/docs/specdojo/schemas/v1/sch-milestones.schema.yaml +64 -0
  508. package/docs/specdojo/schemas/v1/sch-strategy.schema.yaml +772 -0
  509. package/docs/specdojo/schemas/v1/sch-track.schema.yaml +66 -0
  510. package/docs/specdojo/schemas/v1/standard-frontmatter.schema.yaml +18 -0
  511. package/docs/specdojo/schemas/v1/tml-index.schema.yaml +103 -0
  512. package/package.json +121 -24
  513. package/templates/antigravity/README.md +35 -0
  514. package/templates/antigravity/exec-defaults-snippet.yaml +38 -0
  515. package/templates/antigravity/orchestrator.md +146 -0
  516. package/templates/antigravity/pm-members-snippet.yaml +55 -0
  517. package/templates/claude/README.md +46 -0
  518. package/templates/claude/agents/claude-expert-review-executor.md +14 -0
  519. package/templates/claude/agents/claude-review-executor.md +14 -0
  520. package/templates/claude/agents/specdojo-orchestrator.md +153 -0
  521. package/templates/claude/settings.edit.json +6 -0
  522. package/templates/claude/settings.report.json +6 -0
  523. package/templates/claude/settings.review.json +7 -0
  524. package/templates/codex/README.md +61 -0
  525. package/templates/codex/agents/codex-executor.toml +12 -0
  526. package/templates/codex/agents/codex-expert-executor.toml +12 -0
  527. package/templates/codex/agents/codex-expert-review-executor.toml +10 -0
  528. package/templates/codex/agents/codex-review-executor.toml +10 -0
  529. package/templates/codex/agents/specdojo-orchestrator.toml +154 -0
  530. package/templates/codex/orchestrator.md +146 -0
  531. package/templates/copilot/README.md +41 -0
  532. package/templates/copilot/exec-defaults-snippet.yaml +28 -0
  533. package/templates/copilot/pm-members-snippet.yaml +44 -0
  534. package/templates/opencode/README.md +41 -0
  535. package/templates/opencode/agents/opencode-executor.md +59 -0
  536. package/templates/opencode/agents/opencode-reporter.md +26 -0
  537. package/templates/opencode/agents/opencode-review-executor.md +48 -0
  538. package/templates/opencode/agents/specdojo-orchestrator.md +193 -0
  539. package/dist/exec-schedule-timeline-render.js +0 -201
  540. package/dist/exec-schedule-timeline.js +0 -2
@@ -0,0 +1,1079 @@
1
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
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";
11
+ const CATALOG_RULEBOOK_ID_PATTERN = /^(?:[a-z][a-z0-9-]*:)?[a-z0-9][a-z0-9-]*-rulebook$/;
12
+ const CATALOG_KATA_DIRS = {
13
+ rulebook: "rulebooks",
14
+ recipe: "recipes",
15
+ sample: "samples",
16
+ template: "templates",
17
+ };
18
+ function declaredKataCandidates(repoRoot, kind, id) {
19
+ const localId = id.includes(":") ? id.split(":").slice(1).join(":") : id;
20
+ const extensions = kind === "rulebook" || kind === "recipe" ? ["md"] : ["md", "yaml", "json"];
21
+ return extensions.map((extension) => {
22
+ const relativePath = `docs/ja/specdojo/${CATALOG_KATA_DIRS[kind]}/${localId}.${extension}`;
23
+ return (resolveSpecdojoPathIfExists(relativePath, { repositoryRoot: repoRoot }) ??
24
+ specdojoResourceCandidates(relativePath, { repositoryRoot: repoRoot }).repositoryPath);
25
+ });
26
+ }
27
+ function readPracticeDocumentId(filePath) {
28
+ const content = readFileSync(filePath, "utf8");
29
+ if (filePath.endsWith(".md")) {
30
+ const id = readSpecdojoNamespace(content).id;
31
+ return typeof id === "string" ? id : undefined;
32
+ }
33
+ const parsed = yaml.load(content);
34
+ if (!isRecord(parsed))
35
+ return undefined;
36
+ const nested = isRecord(parsed.specdojo) ? parsed.specdojo.id : undefined;
37
+ const extensionMetadata = isRecord(parsed["x-spec-meta"]) ? parsed["x-spec-meta"].id : undefined;
38
+ const id = typeof parsed.id === "string"
39
+ ? parsed.id
40
+ : typeof nested === "string"
41
+ ? nested
42
+ : extensionMetadata;
43
+ return typeof id === "string" ? id : undefined;
44
+ }
45
+ const DCT_INDEX_FILE = "dct-index.yaml";
46
+ 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
+ }
189
+ // Collects every local_id across all dct-*.yaml in a catalog directory.
190
+ // Used to resolve cross-file depends_on references (same project, other file).
191
+ export function collectCatalogLocalIds(catalogPath) {
192
+ const ids = new Set();
193
+ const files = readdirSync(catalogPath).filter(isDctCatalogFileName).sort();
194
+ for (const f of files) {
195
+ let doc;
196
+ try {
197
+ doc = yaml.load(readFileSync(join(catalogPath, f), "utf8"));
198
+ }
199
+ catch {
200
+ continue;
201
+ }
202
+ if (!doc || !Array.isArray(doc.groups))
203
+ continue;
204
+ const walk = (sections) => {
205
+ for (const section of sections) {
206
+ for (const item of section.deliverables ?? [])
207
+ ids.add(item.local_id);
208
+ if (section.groups)
209
+ walk(section.groups);
210
+ }
211
+ };
212
+ walk(doc.groups);
213
+ }
214
+ return ids;
215
+ }
216
+ // Reads and parses every dct-*.yaml in a catalog directory in sorted file order.
217
+ // Files that fail to parse or have no groups are skipped (structural validation
218
+ // and parse-error reporting are handled by the caller / validateDctDoc).
219
+ export function loadCatalogDocs(catalogPath) {
220
+ const loaded = [];
221
+ const files = readdirSync(catalogPath).filter(isDctCatalogFileName).sort();
222
+ for (const f of files) {
223
+ const filePath = join(catalogPath, f);
224
+ let doc;
225
+ try {
226
+ doc = yaml.load(readFileSync(filePath, "utf8"));
227
+ }
228
+ catch {
229
+ continue;
230
+ }
231
+ if (!doc || !Array.isArray(doc.groups))
232
+ continue;
233
+ loaded.push({ file: f, filePath, doc });
234
+ }
235
+ return loaded;
236
+ }
237
+ // Collect (local_id -> first-seen file) across a section tree, appending an error
238
+ // for any local_id that first appears in a different file (cross-file duplicate).
239
+ function collectMergedLocalIds(sections, filePath, domain, seen, reported, errors) {
240
+ for (const section of sections) {
241
+ for (const item of section.deliverables ?? []) {
242
+ const prev = seen.get(item.local_id);
243
+ if (prev === undefined) {
244
+ seen.set(item.local_id, filePath);
245
+ }
246
+ else if (prev !== filePath && !reported.has(item.local_id)) {
247
+ reported.add(item.local_id);
248
+ errors.push(`domain '${domain}': duplicate local_id '${item.local_id}' across merged files: ${prev}, ${filePath}`);
249
+ }
250
+ }
251
+ if (section.groups) {
252
+ collectMergedLocalIds(section.groups, filePath, domain, seen, reported, errors);
253
+ }
254
+ }
255
+ }
256
+ function cloneSection(section) {
257
+ return {
258
+ ...section,
259
+ ...(section.deliverables ? { deliverables: [...section.deliverables] } : {}),
260
+ ...(section.groups ? { groups: section.groups.map(cloneSection) } : {}),
261
+ };
262
+ }
263
+ // Merge groups contributed by one physical file into groups accumulated from
264
+ // earlier files. Only a named group that already existed before this file is a
265
+ // merge target, so duplicate headings inside a single file keep their legacy
266
+ // shape. Unnamed groups are never keyed and remain heading-less concatenations.
267
+ //
268
+ // The first occurrence owns scalar metadata (base_path, note, min_size). Later
269
+ // matching groups contribute deliverables in definition order and child groups,
270
+ // which are merged recursively by the same sibling-level name rule.
271
+ function mergeSectionGroups(accumulated, incoming) {
272
+ const result = accumulated.map(cloneSection);
273
+ const namedTargets = new Map();
274
+ for (const [index, section] of result.entries()) {
275
+ if (section.name && !namedTargets.has(section.name)) {
276
+ namedTargets.set(section.name, index);
277
+ }
278
+ }
279
+ for (const section of incoming) {
280
+ const targetIndex = section.name ? namedTargets.get(section.name) : undefined;
281
+ if (targetIndex === undefined) {
282
+ result.push(cloneSection(section));
283
+ continue;
284
+ }
285
+ const target = result[targetIndex];
286
+ result[targetIndex] = {
287
+ ...target,
288
+ ...(section.deliverables
289
+ ? { deliverables: [...(target.deliverables ?? []), ...section.deliverables] }
290
+ : {}),
291
+ ...(section.groups
292
+ ? { groups: mergeSectionGroups(target.groups ?? [], section.groups) }
293
+ : {}),
294
+ };
295
+ }
296
+ return result;
297
+ }
298
+ // Groups loaded dct docs by their logical `domain` and merges each group's parts
299
+ // into a single domain catalog. Merge order is the sorted file order captured by
300
+ // loadCatalogDocs, so the result is deterministic and file-listing-order agnostic.
301
+ //
302
+ // Parts of one domain must agree on `project_id` and `base_path` (both anchor how
303
+ // the merged groups resolve), and their `local_id`s must stay unique across parts;
304
+ // violations are reported as per-domain errors instead of silently merging.
305
+ export function mergeDomainCatalogs(loaded) {
306
+ const order = [];
307
+ const groups = new Map();
308
+ const sorted = [...loaded].sort((a, b) => (a.file < b.file ? -1 : a.file > b.file ? 1 : 0));
309
+ for (const entry of sorted) {
310
+ const domain = entry.doc.domain;
311
+ if (!domain)
312
+ continue;
313
+ const existing = groups.get(domain);
314
+ if (existing) {
315
+ existing.push(entry);
316
+ }
317
+ else {
318
+ groups.set(domain, [entry]);
319
+ order.push(domain);
320
+ }
321
+ }
322
+ const merged = [];
323
+ for (const domain of order) {
324
+ const parts = groups.get(domain);
325
+ if (!parts || parts.length === 0)
326
+ continue;
327
+ const primary = parts[0];
328
+ const errors = [];
329
+ for (const part of parts.slice(1)) {
330
+ if (part.doc.project_id !== primary.doc.project_id) {
331
+ errors.push(`domain '${domain}': project_id mismatch between ${primary.filePath} (${primary.doc.project_id}) and ${part.filePath} (${part.doc.project_id})`);
332
+ }
333
+ const primaryBase = primary.doc.base_path ?? "";
334
+ const partBase = part.doc.base_path ?? "";
335
+ if (partBase !== primaryBase) {
336
+ errors.push(`domain '${domain}': base_path mismatch between ${primary.filePath} (${primaryBase || "-"}) and ${part.filePath} (${partBase || "-"}); parts of one domain must share base_path`);
337
+ }
338
+ }
339
+ let mergedGroups = [];
340
+ const seen = new Map();
341
+ const reported = new Set();
342
+ for (const part of parts) {
343
+ mergedGroups = mergeSectionGroups(mergedGroups, part.doc.groups);
344
+ collectMergedLocalIds(part.doc.groups, part.filePath, domain, seen, reported, errors);
345
+ }
346
+ merged.push({
347
+ domain,
348
+ doc: { ...primary.doc, groups: mergedGroups },
349
+ files: parts.map((p) => p.file),
350
+ errors,
351
+ });
352
+ }
353
+ return merged;
354
+ }
355
+ // Cross-file check: multiple dct-*.yaml may share a `domain` (physical split of one
356
+ // logical domain); build merges them into a single domain catalog. This validates
357
+ // that same-domain parts are mergeable — consistent project_id / base_path and
358
+ // project-wide-unique local_ids — rather than forbidding the shared domain outright.
359
+ export function validateCatalogDomains(catalogPath) {
360
+ const errors = mergeDomainCatalogs(loadCatalogDocs(catalogPath)).flatMap((m) => m.errors);
361
+ return { ok: errors.length === 0, errors, warnings: [] };
362
+ }
363
+ // Cross-file check: each `local_id` must be unique across the project's catalogs,
364
+ // so that a bare `local_id` (in `--deliverable` or a scheduled task) resolves to a
365
+ // single deliverable. Returns warnings (not errors); per-file duplicates are caught
366
+ // as errors by validateDctDoc.
367
+ export function validateCatalogLocalIds(catalogPath) {
368
+ const warnings = [];
369
+ const seen = new Map();
370
+ const reported = new Set();
371
+ const files = readdirSync(catalogPath).filter(isDctCatalogFileName).sort();
372
+ for (const f of files) {
373
+ const filePath = join(catalogPath, f);
374
+ let doc;
375
+ try {
376
+ doc = yaml.load(readFileSync(filePath, "utf8"));
377
+ }
378
+ catch {
379
+ continue;
380
+ }
381
+ if (!doc || !Array.isArray(doc.groups))
382
+ continue;
383
+ const walk = (sections) => {
384
+ for (const section of sections) {
385
+ for (const item of section.deliverables ?? []) {
386
+ const prev = seen.get(item.local_id);
387
+ if (prev === undefined) {
388
+ seen.set(item.local_id, filePath);
389
+ }
390
+ else if (prev !== filePath && !reported.has(item.local_id)) {
391
+ reported.add(item.local_id);
392
+ warnings.push(`local_id '${item.local_id}' is defined in multiple catalogs: ${prev}, ${filePath}`);
393
+ }
394
+ }
395
+ if (section.groups)
396
+ walk(section.groups);
397
+ }
398
+ };
399
+ walk(doc.groups);
400
+ }
401
+ return { ok: true, errors: [], warnings };
402
+ }
403
+ // Reads the specdojo `type` from a rulebook file. Returns undefined when the file
404
+ // has no frontmatter or the field is absent.
405
+ function readRulebookType(fsPath) {
406
+ if (!existsSync(fsPath))
407
+ return undefined;
408
+ const fm = readSpecdojoNamespace(readFileSync(fsPath, "utf8"));
409
+ return typeof fm.type === "string" ? fm.type : undefined;
410
+ }
411
+ // Cross-file check: rulebook frontmatter declarations and practice files must agree.
412
+ // Declared-but-missing references and existing-but-undeclared counterparts are warnings,
413
+ // because the mismatch is an authoring signal rather than a catalog schema failure.
414
+ export function validateRulebookKata(catalogPath) {
415
+ const warnings = [];
416
+ const rulebookIds = new Set();
417
+ const files = readdirSync(catalogPath).filter(isDctCatalogFileName).sort();
418
+ for (const f of files) {
419
+ let doc;
420
+ try {
421
+ doc = yaml.load(readFileSync(join(catalogPath, f), "utf8"));
422
+ }
423
+ catch {
424
+ continue;
425
+ }
426
+ if (!doc || !Array.isArray(doc.groups))
427
+ continue;
428
+ const walk = (sections) => {
429
+ for (const section of sections) {
430
+ for (const item of section.deliverables ?? []) {
431
+ const rulebookId = item.rulebook;
432
+ if (!rulebookId ||
433
+ rulebookId === "none" ||
434
+ rulebookId === "undecided" ||
435
+ rulebookId === "not-needed") {
436
+ continue;
437
+ }
438
+ rulebookIds.add(rulebookId);
439
+ }
440
+ if (section.groups)
441
+ walk(section.groups);
442
+ }
443
+ };
444
+ walk(doc.groups);
445
+ }
446
+ const repoRoot = specdojoRootDir();
447
+ const rulebooksDirs = specdojoDirectoryPaths("docs/ja/specdojo/rulebooks", {
448
+ repositoryRoot: repoRoot,
449
+ });
450
+ // 実践の型のディレクトリを持たないリポジトリ(テスト用の最小構成など)では、
451
+ // 突き合わせる対象がないため検証を行わない。
452
+ if (rulebooksDirs.length === 0)
453
+ return { ok: true, errors: [], warnings };
454
+ const seenRulebookFiles = new Set();
455
+ for (const rulebooksDir of rulebooksDirs) {
456
+ for (const file of readdirSync(rulebooksDir).filter((name) => name.endsWith("-rulebook.md"))) {
457
+ if (seenRulebookFiles.has(file))
458
+ continue;
459
+ seenRulebookFiles.add(file);
460
+ const fsPath = join(rulebooksDir, file);
461
+ const id = readSpecdojoNamespace(readFileSync(fsPath, "utf8")).id;
462
+ rulebookIds.add(typeof id === "string" ? id : file.replace(/\.md$/, ""));
463
+ }
464
+ }
465
+ const declaredSampleLocalIds = new Set();
466
+ for (const rulebookId of [...rulebookIds].sort()) {
467
+ const refs = declaredKata(rulebookId);
468
+ const declaredPaths = new Set(refs.map((ref) => ref.fsPath));
469
+ for (const ref of refs) {
470
+ if (ref.kind === "sample") {
471
+ declaredSampleLocalIds.add(ref.id.includes(":") ? ref.id.split(":").slice(1).join(":") : ref.id);
472
+ }
473
+ if (!existsSync(ref.fsPath)) {
474
+ warnings.push(`rulebook '${rulebookId}' declares ${ref.kind} '${ref.id}' but the file is missing: ${ref.fsPath}`);
475
+ }
476
+ }
477
+ const localRulebookId = rulebookId.includes(":")
478
+ ? rulebookId.split(":").slice(1).join(":")
479
+ : rulebookId;
480
+ const prefix = localRulebookId.replace(/-rulebook$/, "");
481
+ for (const kind of ["recipe", "template"]) {
482
+ const extensions = kind === "recipe" ? ["md"] : ["md", "yaml", "json"];
483
+ for (const extension of extensions) {
484
+ const fsPath = resolveSpecdojoPathIfExists(`docs/ja/specdojo/${CATALOG_KATA_DIRS[kind]}/${prefix}-${kind}.${extension}`, { repositoryRoot: repoRoot });
485
+ if (fsPath && !declaredPaths.has(fsPath)) {
486
+ warnings.push(`rulebook '${rulebookId}' does not declare existing ${kind}: ${fsPath}`);
487
+ }
488
+ }
489
+ }
490
+ for (const inc of declaredIncludes(rulebookId)) {
491
+ if (inc.selfReference) {
492
+ warnings.push(`rulebook '${rulebookId}' includes itself; remove the self-reference`);
493
+ continue;
494
+ }
495
+ if (!existsSync(inc.fsPath)) {
496
+ warnings.push(`rulebook '${rulebookId}' includes '${inc.id}' but the file is missing: ${inc.fsPath}`);
497
+ continue;
498
+ }
499
+ const type = readRulebookType(inc.fsPath);
500
+ if (type !== "rulebook") {
501
+ warnings.push(`rulebook '${rulebookId}' includes '${inc.id}' but it is not a rulebook (type: ${type ?? "unknown"})`);
502
+ }
503
+ }
504
+ }
505
+ const samplesDirs = specdojoDirectoryPaths("docs/ja/specdojo/samples", {
506
+ repositoryRoot: repoRoot,
507
+ });
508
+ const seenSampleFiles = new Set();
509
+ for (const samplesDir of samplesDirs) {
510
+ const sampleFiles = readdirSync(samplesDir).filter((name) => /-sample\.(?:md|yaml|json)$/.test(name));
511
+ for (const file of sampleFiles) {
512
+ if (seenSampleFiles.has(file))
513
+ continue;
514
+ seenSampleFiles.add(file);
515
+ const fsPath = join(samplesDir, file);
516
+ const declaredId = readPracticeDocumentId(fsPath);
517
+ const localId = declaredId
518
+ ? declaredId.includes(":")
519
+ ? declaredId.split(":").slice(1).join(":")
520
+ : declaredId
521
+ : file.replace(/\.(?:md|yaml|json)$/, "");
522
+ if (!declaredSampleLocalIds.has(localId)) {
523
+ warnings.push(`sample '${localId}' exists but no rulebook declares it: ${fsPath}`);
524
+ }
525
+ }
526
+ }
527
+ return { ok: true, errors: [], warnings };
528
+ }
529
+ // When knownLocalIds is provided, depends_on references are resolved against the
530
+ // whole catalog (all dct-*.yaml of the project), so cross-file dependencies do
531
+ // not warn. When omitted, resolution falls back to same-file local_ids only.
532
+ export function validateDctDoc(doc, filePath, knownLocalIds, repoRoot) {
533
+ const errors = [];
534
+ const warnings = [];
535
+ const localIdPattern = /^[a-z0-9][a-z0-9-]*$/;
536
+ const instanceIdPattern = /^(?=.*\{[a-z][a-z0-9-]*\})[a-z0-9]+(?:-(?:[a-z0-9]+|\{[a-z][a-z0-9-]*\}))*$/;
537
+ const overlyBroadEvidencePaths = new Set([
538
+ "src",
539
+ "tools",
540
+ "docs",
541
+ "tests",
542
+ "templates",
543
+ "public",
544
+ ".github",
545
+ ".agents",
546
+ ".codex",
547
+ ".specdojo",
548
+ ]);
549
+ if (!doc.id)
550
+ errors.push(`${filePath}: missing required field: id`);
551
+ if (doc.type !== "project")
552
+ errors.push(`${filePath}: type must be 'project', got: ${doc.type}`);
553
+ if (!["draft", "ready", "deprecated"].includes(doc.status)) {
554
+ errors.push(`${filePath}: invalid status: ${doc.status}`);
555
+ }
556
+ if (!doc.project_id)
557
+ errors.push(`${filePath}: missing required field: project_id`);
558
+ if (!doc.domain)
559
+ errors.push(`${filePath}: missing required field: domain`);
560
+ if (!doc.groups || !Array.isArray(doc.groups) || doc.groups.length === 0) {
561
+ errors.push(`${filePath}: groups must be a non-empty array`);
562
+ }
563
+ const localIds = new Set();
564
+ function collectIds(sections) {
565
+ for (const section of sections) {
566
+ if (section.deliverables) {
567
+ for (const item of section.deliverables) {
568
+ if (!localIdPattern.test(item.local_id)) {
569
+ errors.push(`${filePath}: invalid local_id: ${item.local_id}`);
570
+ }
571
+ if (item.instance_id_pattern !== undefined &&
572
+ !instanceIdPattern.test(item.instance_id_pattern)) {
573
+ errors.push(`${filePath}: ${item.local_id}: invalid instance_id_pattern: ${item.instance_id_pattern}`);
574
+ }
575
+ const declaration = item.rulebook;
576
+ if (declaration !== undefined &&
577
+ declaration !== "undecided" &&
578
+ declaration !== "not-needed") {
579
+ if (!CATALOG_RULEBOOK_ID_PATTERN.test(declaration)) {
580
+ errors.push(`${filePath}: ${item.local_id}: rulebook must be a rulebook document id, 'undecided', or 'not-needed': ${declaration}`);
581
+ }
582
+ else if (repoRoot) {
583
+ const existing = declaredKataCandidates(repoRoot, "rulebook", declaration).find((candidate) => existsSync(candidate));
584
+ if (!existing) {
585
+ errors.push(`${filePath}: ${item.local_id}: declared rulebook document id does not exist: ${declaration}`);
586
+ }
587
+ else {
588
+ const actualId = readPracticeDocumentId(existing);
589
+ if (actualId !== undefined && actualId !== declaration) {
590
+ errors.push(`${filePath}: ${item.local_id}: declared rulebook document id '${declaration}' does not match '${actualId ?? "<missing>"}' in ${existing}`);
591
+ }
592
+ }
593
+ }
594
+ }
595
+ if (localIds.has(item.local_id)) {
596
+ errors.push(`${filePath}: duplicate local_id: ${item.local_id}`);
597
+ }
598
+ else {
599
+ localIds.add(item.local_id);
600
+ }
601
+ if (item.kind === "work") {
602
+ if (!item.path)
603
+ errors.push(`${filePath}: ${item.local_id}: kind:work requires path`);
604
+ if (!item.done_criteria || item.done_criteria.length === 0) {
605
+ errors.push(`${filePath}: ${item.local_id}: kind:work requires done_criteria`);
606
+ }
607
+ }
608
+ if (item.evidence_refs !== undefined) {
609
+ if (!Array.isArray(item.evidence_refs) || item.evidence_refs.length === 0) {
610
+ errors.push(`${filePath}: ${item.local_id}: evidence_refs must be a non-empty array`);
611
+ }
612
+ else {
613
+ const evidencePaths = new Set();
614
+ for (const rawRef of item.evidence_refs) {
615
+ if (!isRecord(rawRef)) {
616
+ errors.push(`${filePath}: ${item.local_id}: evidence_refs entries must be objects`);
617
+ continue;
618
+ }
619
+ if (rawRef.kind !== "implementation") {
620
+ errors.push(`${filePath}: ${item.local_id}: evidence_refs kind must be 'implementation'`);
621
+ }
622
+ const evidencePath = typeof rawRef.path === "string" ? rawRef.path : "";
623
+ const segments = evidencePath.split("/");
624
+ const canonical = evidencePath.length > 0 &&
625
+ !evidencePath.startsWith("/") &&
626
+ !evidencePath.includes("\\") &&
627
+ !evidencePath.includes("//") &&
628
+ !/\s/.test(evidencePath) &&
629
+ segments.every((segment) => segment !== "" && segment !== "." && segment !== "..");
630
+ if (!canonical) {
631
+ errors.push(`${filePath}: ${item.local_id}: evidence_refs path must be canonical repo-relative: ${evidencePath || "<missing>"}`);
632
+ continue;
633
+ }
634
+ if (evidencePaths.has(evidencePath)) {
635
+ errors.push(`${filePath}: ${item.local_id}: duplicate evidence_refs path: ${evidencePath}`);
636
+ }
637
+ else {
638
+ evidencePaths.add(evidencePath);
639
+ }
640
+ if (overlyBroadEvidencePaths.has(evidencePath)) {
641
+ errors.push(`${filePath}: ${item.local_id}: evidence_refs path is overly broad: ${evidencePath}`);
642
+ }
643
+ if (repoRoot && !existsSync(join(repoRoot, evidencePath))) {
644
+ errors.push(`${filePath}: ${item.local_id}: evidence_refs path does not exist: ${evidencePath}`);
645
+ }
646
+ if (typeof rawRef.purpose !== "string" || rawRef.purpose.trim().length === 0) {
647
+ errors.push(`${filePath}: ${item.local_id}: evidence_refs purpose must be a non-empty string`);
648
+ }
649
+ }
650
+ }
651
+ }
652
+ }
653
+ }
654
+ if (section.groups)
655
+ collectIds(section.groups);
656
+ }
657
+ }
658
+ if (doc.groups)
659
+ collectIds(doc.groups);
660
+ const depLookup = knownLocalIds ?? localIds;
661
+ const depScope = knownLocalIds ? "catalog" : "this file";
662
+ function checkDeps(sections) {
663
+ for (const section of sections) {
664
+ if (section.deliverables) {
665
+ for (const item of section.deliverables) {
666
+ if (item.depends_on) {
667
+ for (const dep of item.depends_on) {
668
+ if (!depLookup.has(dep)) {
669
+ warnings.push(`${filePath}: ${item.local_id}: depends_on '${dep}' not found in ${depScope}`);
670
+ }
671
+ }
672
+ }
673
+ }
674
+ }
675
+ if (section.groups)
676
+ checkDeps(section.groups);
677
+ }
678
+ }
679
+ if (doc.groups)
680
+ checkDeps(doc.groups);
681
+ return { ok: errors.length === 0, errors, warnings };
682
+ }
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
+ }
821
+ function validateDctIndexStructure(doc, filePath) {
822
+ const errors = [];
823
+ if (!doc || typeof doc !== "object") {
824
+ return { ok: false, errors: [`${filePath}: document must be an object`], warnings: [] };
825
+ }
826
+ if (!doc.id)
827
+ errors.push(`${filePath}: missing required field: id`);
828
+ if (doc.type !== "project")
829
+ errors.push(`${filePath}: type must be 'project', got: ${doc.type}`);
830
+ if (!["draft", "ready", "deprecated"].includes(doc.status)) {
831
+ errors.push(`${filePath}: invalid status: ${doc.status}`);
832
+ }
833
+ if (!doc.title)
834
+ errors.push(`${filePath}: missing required field: title`);
835
+ if (doc.rulebook !== "specdojo:dct-index-rulebook") {
836
+ errors.push(`${filePath}: rulebook must be 'specdojo:dct-index-rulebook'`);
837
+ }
838
+ if (!/^prj-[0-9]{4,}$/.test(doc.project_id ?? "")) {
839
+ errors.push(`${filePath}: invalid project_id: ${doc.project_id}`);
840
+ }
841
+ else if (doc.id !== `${doc.project_id}:dct-index`) {
842
+ errors.push(`${filePath}: id must be '${doc.project_id}:dct-index', got: ${doc.id}`);
843
+ }
844
+ if (!["small", "medium", "large"].includes(doc.size)) {
845
+ errors.push(`${filePath}: size must be one of: small|medium|large`);
846
+ }
847
+ if (!Array.isArray(doc.groups) || doc.groups.length === 0) {
848
+ errors.push(`${filePath}: groups must be a non-empty array`);
849
+ }
850
+ else {
851
+ const domains = new Set();
852
+ const validateGroups = (groups, path, depth) => {
853
+ const groupNames = new Set();
854
+ for (const [groupIndex, value] of groups.entries()) {
855
+ const groupAt = `${path}[${groupIndex}]`;
856
+ if (!isRecord(value)) {
857
+ errors.push(`${groupAt}: group must be an object`);
858
+ continue;
859
+ }
860
+ const name = value.name;
861
+ if (typeof name !== "string" || name.trim().length === 0) {
862
+ errors.push(`${groupAt}: name must be a non-empty string`);
863
+ }
864
+ else if (/[|\r\n]/.test(name)) {
865
+ errors.push(`${groupAt}: name must not contain a table delimiter or newline`);
866
+ }
867
+ else if (groupNames.has(name)) {
868
+ errors.push(`${groupAt}: duplicate group name: ${name}`);
869
+ }
870
+ else {
871
+ groupNames.add(name);
872
+ }
873
+ const hasDomains = Object.hasOwn(value, "domains");
874
+ const hasGroups = Object.hasOwn(value, "groups");
875
+ if (hasDomains === hasGroups) {
876
+ errors.push(`${groupAt}: exactly one of domains or groups must be specified`);
877
+ continue;
878
+ }
879
+ if (hasGroups) {
880
+ if (depth >= 1) {
881
+ errors.push(`${groupAt}: groups may only be nested one level`);
882
+ continue;
883
+ }
884
+ if (!Array.isArray(value.groups) || value.groups.length === 0) {
885
+ errors.push(`${groupAt}: groups must be a non-empty array`);
886
+ continue;
887
+ }
888
+ validateGroups(value.groups, `${groupAt}.groups`, depth + 1);
889
+ continue;
890
+ }
891
+ if (!Array.isArray(value.domains) || value.domains.length === 0) {
892
+ errors.push(`${groupAt}: domains must be a non-empty array`);
893
+ continue;
894
+ }
895
+ for (const [domainIndex, domainValue] of value.domains.entries()) {
896
+ const at = `${groupAt}.domains[${domainIndex}]`;
897
+ if (!isRecord(domainValue)) {
898
+ errors.push(`${at}: domain declaration must be an object`);
899
+ continue;
900
+ }
901
+ const domain = domainValue.domain;
902
+ if (typeof domain !== "string" || !/^[a-z0-9][a-z0-9-]{0,62}$/.test(domain)) {
903
+ errors.push(`${at}: invalid domain: ${String(domain)}`);
904
+ }
905
+ else if (domains.has(domain)) {
906
+ errors.push(`${at}: duplicate domain declaration: ${domain}`);
907
+ }
908
+ else {
909
+ domains.add(domain);
910
+ }
911
+ for (const field of ["name", "overview"]) {
912
+ const fieldValue = domainValue[field];
913
+ if (typeof fieldValue !== "string" || fieldValue.trim().length === 0) {
914
+ errors.push(`${at}: ${field} must be a non-empty string`);
915
+ }
916
+ else if (/[|\r\n]/.test(fieldValue)) {
917
+ errors.push(`${at}: ${field} must not contain a table delimiter or newline`);
918
+ }
919
+ }
920
+ }
921
+ }
922
+ };
923
+ validateGroups(doc.groups, `${filePath}: groups`, 0);
924
+ }
925
+ return { ok: errors.length === 0, errors, warnings: [] };
926
+ }
927
+ function flattenDctIndexDomains(groups) {
928
+ return groups.flatMap((group) => "domains" in group ? group.domains : group.groups.flatMap((child) => child.domains));
929
+ }
930
+ export function loadDctIndex(catalogPath) {
931
+ const filePath = join(catalogPath, DCT_INDEX_FILE);
932
+ if (!existsSync(filePath))
933
+ return null;
934
+ return yaml.load(readFileSync(filePath, "utf8"));
935
+ }
936
+ // The index declaration and physical domain files must describe exactly the same domain set.
937
+ // Multiple physical files for one domain intentionally collapse to one declaration.
938
+ export function validateCatalogIndex(catalogPath) {
939
+ const filePath = join(catalogPath, DCT_INDEX_FILE);
940
+ if (!existsSync(filePath)) {
941
+ return {
942
+ ok: false,
943
+ errors: [`${filePath}: missing dct-index.yaml; declare every catalog domain in this file`],
944
+ warnings: [],
945
+ };
946
+ }
947
+ let doc;
948
+ try {
949
+ doc = loadDctIndex(catalogPath);
950
+ }
951
+ catch (error) {
952
+ return {
953
+ ok: false,
954
+ errors: [`${filePath}: ${error instanceof Error ? error.message : String(error)}`],
955
+ warnings: [],
956
+ };
957
+ }
958
+ const structural = validateDctIndexStructure(doc, filePath);
959
+ if (!structural.ok)
960
+ return structural;
961
+ const declared = new Set(flattenDctIndexDomains(doc.groups).map((item) => item.domain));
962
+ const actual = new Set(loadCatalogDocs(catalogPath).map((entry) => entry.doc.domain));
963
+ const errors = [];
964
+ for (const domain of [...declared].sort()) {
965
+ if (!actual.has(domain)) {
966
+ errors.push(`${filePath}: declared domain '${domain}' has no dct-*.yaml source`);
967
+ }
968
+ }
969
+ for (const domain of [...actual].sort()) {
970
+ if (!declared.has(domain)) {
971
+ errors.push(`${filePath}: domain '${domain}' from dct-*.yaml is not declared`);
972
+ }
973
+ }
974
+ return { ok: errors.length === 0, errors, warnings: [] };
975
+ }
976
+ function injectDctIndexSlot(content, tables) {
977
+ const marker = "<!-- specdojo:view-slot=domain-tables -->";
978
+ if (!content.includes(marker)) {
979
+ throw new Error(`View-slot not found in template: domain-tables`);
980
+ }
981
+ return content.replace(marker, tables);
982
+ }
983
+ export function buildDctIndexMarkdown(doc, templateRaw) {
984
+ const template = flattenTemplateFrontmatter(templateRaw)
985
+ .replaceAll("_PROJECT_ID_", doc.project_id)
986
+ .replaceAll("_STATUS_", doc.status);
987
+ const renderGroups = (groups, prefix, level) => groups.flatMap((group, groupIndex) => {
988
+ const numbers = [...prefix, groupIndex + 1];
989
+ const heading = `${"#".repeat(level)} ${numbers.join(".")}. ${group.name}`;
990
+ if ("groups" in group) {
991
+ return [heading, "", ...renderGroups(group.groups, numbers, level + 1)];
992
+ }
993
+ const rows = group.domains.map((entry) => `| \`${entry.domain}\` | ${entry.name} | [dct-${entry.domain}](./dct-${entry.domain}.md) | ${entry.overview} |`);
994
+ return [
995
+ heading,
996
+ "",
997
+ "<!-- prettier-ignore -->",
998
+ "| ドメイン | 名称 | 成果物カタログ | 概要 |",
999
+ "| --- | --- | --- | --- |",
1000
+ ...rows,
1001
+ "",
1002
+ ];
1003
+ });
1004
+ const tables = renderGroups(doc.groups, [2], 3).join("\n").trimEnd();
1005
+ return `${injectDctIndexSlot(template, tables).trimEnd()}\n`;
1006
+ }
1007
+ export function buildCatalog(catalogPath) {
1008
+ const outputDir = join(catalogPath, "generated");
1009
+ mkdirSync(outputDir, { recursive: true });
1010
+ const generated = [];
1011
+ const errors = [];
1012
+ const files = readdirSync(catalogPath).filter(isDctCatalogFileName).sort();
1013
+ const knownLocalIds = collectCatalogLocalIds(catalogPath);
1014
+ // Per-file structural validation first. Files that pass become merge inputs;
1015
+ // a domain with any invalid part is skipped so we never emit a partial catalog.
1016
+ const loaded = [];
1017
+ const invalidDomains = new Set();
1018
+ for (const f of files) {
1019
+ const filePath = join(catalogPath, f);
1020
+ let doc;
1021
+ try {
1022
+ doc = yaml.load(readFileSync(filePath, "utf8"));
1023
+ }
1024
+ catch (err) {
1025
+ errors.push(`${filePath}: ${err instanceof Error ? err.message : String(err)}`);
1026
+ continue;
1027
+ }
1028
+ const validation = validateDctDoc(doc, filePath, knownLocalIds);
1029
+ if (!validation.ok) {
1030
+ errors.push(...validation.errors);
1031
+ if (doc?.domain)
1032
+ invalidDomains.add(doc.domain);
1033
+ continue;
1034
+ }
1035
+ loaded.push({ file: f, filePath, doc });
1036
+ }
1037
+ // Merge same-domain parts into one domain catalog, keyed and named by `domain`
1038
+ // so a single file (dct-<domain>.yaml) keeps its previous dct-<domain>.md output.
1039
+ for (const catalog of mergeDomainCatalogs(loaded)) {
1040
+ if (invalidDomains.has(catalog.domain))
1041
+ continue;
1042
+ if (catalog.errors.length > 0) {
1043
+ errors.push(...catalog.errors);
1044
+ continue;
1045
+ }
1046
+ try {
1047
+ const md = buildMarkdown(catalog.doc);
1048
+ const outPath = join(outputDir, `dct-${catalog.domain}.md`);
1049
+ writeFileSync(outPath, md, "utf8");
1050
+ generated.push(outPath);
1051
+ }
1052
+ catch (err) {
1053
+ errors.push(`dct-${catalog.domain}: ${err instanceof Error ? err.message : String(err)}`);
1054
+ }
1055
+ }
1056
+ const indexPath = join(catalogPath, DCT_INDEX_FILE);
1057
+ if (existsSync(indexPath)) {
1058
+ const indexValidation = validateCatalogIndex(catalogPath);
1059
+ if (!indexValidation.ok) {
1060
+ errors.push(...indexValidation.errors);
1061
+ }
1062
+ else {
1063
+ try {
1064
+ const index = loadDctIndex(catalogPath);
1065
+ const templatePath = resolveSpecdojoPath(`docs/ja/specdojo/templates/${DCT_INDEX_TEMPLATE}`);
1066
+ if (!existsSync(templatePath))
1067
+ throw new Error(`Template not found: ${templatePath}`);
1068
+ const outputPath = join(outputDir, "dct-index.md");
1069
+ const markdown = buildDctIndexMarkdown(index, readFileSync(templatePath, "utf8"));
1070
+ writeFileSync(outputPath, markdown, "utf8");
1071
+ generated.push(outputPath);
1072
+ }
1073
+ catch (error) {
1074
+ errors.push(`dct-index: ${error instanceof Error ? error.message : String(error)}`);
1075
+ }
1076
+ }
1077
+ }
1078
+ return { generated, errors };
1079
+ }