specdojo 0.4.7 → 0.5.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 (267) hide show
  1. package/.github/agents/specdojo-orchestrator.md +14 -9
  2. package/CHANGELOG.md +46 -0
  3. package/dist/commands/init.js +3 -0
  4. package/dist/commands/night-orchestrator.js +33 -4
  5. package/dist/dashboard/dashboard.js +5 -6
  6. package/dist/dashboard/timeline-build.js +5 -1
  7. package/dist/dashboard/timeline.js +6 -3
  8. package/dist/docs/yaml-pages.js +17 -17
  9. package/dist/exec/core.js +2 -0
  10. package/dist/exec/pipeline-state.js +5 -2
  11. package/dist/exec/plans-core.js +3 -2
  12. package/dist/exec/plans-generation.js +9 -5
  13. package/dist/exec/plans-grade-findings.js +16 -0
  14. package/dist/exec/plans-planning.js +43 -0
  15. package/dist/exec/plans-storage.js +5 -2
  16. package/dist/exec/register.js +16 -1
  17. package/dist/exec/repo-integration-sync.js +9 -0
  18. package/dist/exec/repo-integration.js +17 -2
  19. package/dist/exec/repo-trace.js +17 -4
  20. package/dist/exec/results.js +2 -0
  21. package/dist/exec/run/register-core.js +11 -0
  22. package/dist/exec/run/register-mode.js +19 -1
  23. package/dist/exec/run/register-resume.js +22 -0
  24. package/dist/exec/run/register-worktree.js +23 -0
  25. package/dist/exec/strategy.js +2 -0
  26. package/dist/exec/task-repos.js +18 -4
  27. package/dist/exec/worktree-ops-commit.js +7 -1
  28. package/dist/grade/apply.js +6 -2
  29. package/dist/grade/markdown.js +7 -2
  30. package/dist/grade/plan.js +6 -4
  31. package/dist/register/approach.js +19 -0
  32. package/dist/register/catalog-status.js +49 -0
  33. package/dist/register/core.js +3 -0
  34. package/dist/register/create-commands.js +34 -4
  35. package/dist/register/dependency.js +123 -0
  36. package/dist/register/derivation.js +2 -2
  37. package/dist/register/epic.js +42 -0
  38. package/dist/register/event-merge.js +5 -2
  39. package/dist/register/events.js +4 -0
  40. package/dist/register/external-project.js +4 -0
  41. package/dist/register/item.js +10 -0
  42. package/dist/register/maintenance-commands.js +7 -1
  43. package/dist/register/planning.js +37 -0
  44. package/dist/register/register.js +5 -1
  45. package/dist/register/renumber.js +12 -4
  46. package/dist/register/views.js +55 -4
  47. package/dist/schedule/schedule.js +3 -1
  48. package/dist/schedule/strategy-generate-scope.js +5 -1
  49. package/dist/schedule/strategy-generate.js +1 -0
  50. package/dist/schedule/strategy-profiles.js +1 -1
  51. package/dist/shared/agent-types.js +3 -0
  52. package/dist/shared/grade-result.js +23 -5
  53. package/dist/shared/markdownlint-config.js +38 -0
  54. package/dist/shared/markdownlint-scaffold.js +2 -9
  55. package/dist/shared/specdojo-config.js +10 -3
  56. package/dist/shared/specdojo-gitignore.js +4 -0
  57. package/docs/ja/specdojo/exec-templates/xep-catalog-planning-template.md +24 -0
  58. package/docs/ja/specdojo/exec-templates/xep-strategy-planning-template.md +24 -0
  59. package/docs/ja/specdojo/guides/docs-editing-guide.md +14 -1
  60. package/docs/ja/specdojo/guides/docs-structure-guide.md +10 -8
  61. package/docs/ja/specdojo/guides/exec-operation-guide.md +16 -15
  62. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +19 -1
  63. package/docs/ja/specdojo/guides/practice-system-composition-guide.md +2 -0
  64. package/docs/ja/specdojo/guides/quick-start-guide.md +37 -14
  65. package/docs/ja/specdojo/guides/register-operation-guide.md +44 -15
  66. package/docs/ja/specdojo/guides/specdojo-overview-guide.md +16 -16
  67. package/docs/ja/specdojo/guides/timeline-design-guide.md +37 -33
  68. package/docs/ja/specdojo/recipes/tsd-recipe.md +198 -0
  69. package/docs/ja/specdojo/references/command-reference.md +42 -4
  70. package/docs/ja/specdojo/references/specdojo-config-reference.md +20 -8
  71. package/docs/ja/specdojo/rulebooks/atc-index-rulebook.md +1 -0
  72. package/docs/ja/specdojo/rulebooks/atc-rulebook.md +1 -0
  73. package/docs/ja/specdojo/rulebooks/bac-rulebook.md +5 -4
  74. package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +3 -2
  75. package/docs/ja/specdojo/rulebooks/bds-rulebook.md +4 -3
  76. package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +8 -7
  77. package/docs/ja/specdojo/rulebooks/bes-rulebook.md +4 -3
  78. package/docs/ja/specdojo/rulebooks/bps-rulebook.md +1 -0
  79. package/docs/ja/specdojo/rulebooks/br-rulebook.md +1 -0
  80. package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +1 -0
  81. package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +1 -0
  82. package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +1 -0
  83. package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +1 -0
  84. package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +1 -0
  85. package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +3 -2
  86. package/docs/ja/specdojo/rulebooks/cld-rulebook.md +2 -1
  87. package/docs/ja/specdojo/rulebooks/cnd-mermaid-rulebook.md +1 -0
  88. package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +1 -0
  89. package/docs/ja/specdojo/rulebooks/cop-index-rulebook.md +2 -1
  90. package/docs/ja/specdojo/rulebooks/cop-rulebook.md +3 -2
  91. package/docs/ja/specdojo/rulebooks/cpd-mermaid-rulebook.md +1 -0
  92. package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +1 -0
  93. package/docs/ja/specdojo/rulebooks/cstd-rulebook.md +1 -0
  94. package/docs/ja/specdojo/rulebooks/cxd-mermaid-rulebook.md +1 -0
  95. package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +1 -0
  96. package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +1 -0
  97. package/docs/ja/specdojo/rulebooks/dct-rulebook.md +1 -0
  98. package/docs/ja/specdojo/rulebooks/dec-rulebook.md +1 -0
  99. package/docs/ja/specdojo/rulebooks/dmd-index-rulebook.md +2 -1
  100. package/docs/ja/specdojo/rulebooks/dmd-rulebook.md +2 -1
  101. package/docs/ja/specdojo/rulebooks/etc-index-rulebook.md +1 -0
  102. package/docs/ja/specdojo/rulebooks/etc-rulebook.md +1 -0
  103. package/docs/ja/specdojo/rulebooks/gl-rulebook.md +9 -6
  104. package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +1 -0
  105. package/docs/ja/specdojo/rulebooks/ifx-api-rulebook.md +3 -1
  106. package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +2 -1
  107. package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +2 -1
  108. package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +2 -0
  109. package/docs/ja/specdojo/rulebooks/ifx-msg-rulebook.md +4 -2
  110. package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +1 -0
  111. package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +1 -0
  112. package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +1 -0
  113. package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +1 -0
  114. package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +1 -0
  115. package/docs/ja/specdojo/rulebooks/itc-index-rulebook.md +1 -0
  116. package/docs/ja/specdojo/rulebooks/itc-rulebook.md +1 -0
  117. package/docs/ja/specdojo/rulebooks/mip-index-rulebook.md +2 -1
  118. package/docs/ja/specdojo/rulebooks/mm-rulebook.md +1 -0
  119. package/docs/ja/specdojo/rulebooks/mtp-rulebook.md +4 -3
  120. package/docs/ja/specdojo/rulebooks/nfr-availability-rulebook.md +9 -8
  121. package/docs/ja/specdojo/rulebooks/nfr-index-rulebook.md +10 -9
  122. package/docs/ja/specdojo/rulebooks/nfr-integrity-rulebook.md +9 -8
  123. package/docs/ja/specdojo/rulebooks/nfr-maintainability-rulebook.md +9 -8
  124. package/docs/ja/specdojo/rulebooks/nfr-operations-rulebook.md +9 -8
  125. package/docs/ja/specdojo/rulebooks/nfr-performance-rulebook.md +9 -8
  126. package/docs/ja/specdojo/rulebooks/nfr-reliability-rulebook.md +10 -9
  127. package/docs/ja/specdojo/rulebooks/nfr-security-safety-rulebook.md +9 -8
  128. package/docs/ja/specdojo/rulebooks/nfr-usability-rulebook.md +9 -8
  129. package/docs/ja/specdojo/rulebooks/ntp-rulebook.md +7 -6
  130. package/docs/ja/specdojo/rulebooks/opd-index-rulebook.md +1 -0
  131. package/docs/ja/specdojo/rulebooks/opd-rulebook.md +1 -0
  132. package/docs/ja/specdojo/rulebooks/opr-index-rulebook.md +1 -0
  133. package/docs/ja/specdojo/rulebooks/opr-rulebook.md +1 -0
  134. package/docs/ja/specdojo/rulebooks/otp-index-rulebook.md +2 -1
  135. package/docs/ja/specdojo/rulebooks/otp-rulebook.md +2 -1
  136. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +50 -36
  137. package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +1 -0
  138. package/docs/ja/specdojo/rulebooks/pm-communication-plan-rulebook.md +1 -0
  139. package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +1 -0
  140. package/docs/ja/specdojo/rulebooks/pm-members-rulebook.md +1 -0
  141. package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +1 -0
  142. package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +1 -0
  143. package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +1 -0
  144. package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +1 -0
  145. package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +1 -0
  146. package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +1 -0
  147. package/docs/ja/specdojo/rulebooks/pr-rulebook.md +1 -0
  148. package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +1 -0
  149. package/docs/ja/specdojo/rulebooks/prj-charter-rulebook.md +1 -0
  150. package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +1 -0
  151. package/docs/ja/specdojo/rulebooks/prj-issues-and-approach-rulebook.md +1 -0
  152. package/docs/ja/specdojo/rulebooks/prj-overview-rulebook.md +1 -0
  153. package/docs/ja/specdojo/rulebooks/prj-scope-rulebook.md +1 -0
  154. package/docs/ja/specdojo/rulebooks/prj-stakeholder-register-rulebook.md +1 -0
  155. package/docs/ja/specdojo/rulebooks/prj-success-criteria-and-acceptance-criteria-rulebook.md +1 -0
  156. package/docs/ja/specdojo/rulebooks/sac-rulebook.md +3 -2
  157. package/docs/ja/specdojo/rulebooks/sch-rulebook.md +1 -0
  158. package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +7 -6
  159. package/docs/ja/specdojo/rulebooks/sf-rulebook.md +4 -3
  160. package/docs/ja/specdojo/rulebooks/sld-rulebook.md +2 -1
  161. package/docs/ja/specdojo/rulebooks/stc-index-rulebook.md +1 -0
  162. package/docs/ja/specdojo/rulebooks/stc-rulebook.md +1 -0
  163. package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +1 -0
  164. package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +1 -0
  165. package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +2 -1
  166. package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +9 -8
  167. package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +2 -1
  168. package/docs/ja/specdojo/rulebooks/sysd-rulebook.md +1 -0
  169. package/docs/ja/specdojo/rulebooks/tml-rulebook.md +1 -0
  170. package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +1 -0
  171. package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +1 -0
  172. package/docs/ja/specdojo/rulebooks/tsd-index-rulebook.md +80 -61
  173. package/docs/ja/specdojo/rulebooks/tsd-rulebook.md +111 -63
  174. package/docs/ja/specdojo/rulebooks/tsp-index-rulebook.md +1 -0
  175. package/docs/ja/specdojo/rulebooks/uis-rulebook.md +3 -2
  176. package/docs/ja/specdojo/rulebooks/utc-index-rulebook.md +1 -0
  177. package/docs/ja/specdojo/rulebooks/utc-rulebook.md +1 -0
  178. package/docs/ja/specdojo/samples/atc-index-sample.md +1 -1
  179. package/docs/ja/specdojo/samples/atc-sample.md +1 -1
  180. package/docs/ja/specdojo/samples/bac-sample.md +1 -1
  181. package/docs/ja/specdojo/samples/bdd-sample.yaml +1 -1
  182. package/docs/ja/specdojo/samples/bds-sample.md +1 -1
  183. package/docs/ja/specdojo/samples/bes-index-sample.md +1 -1
  184. package/docs/ja/specdojo/samples/bes-sample.md +1 -1
  185. package/docs/ja/specdojo/samples/ccd-sample.md +1 -1
  186. package/docs/ja/specdojo/samples/cdfd-sample.md +1 -1
  187. package/docs/ja/specdojo/samples/cdfd-uc-sample.md +1 -1
  188. package/docs/ja/specdojo/samples/cdsd-sample.md +1 -1
  189. package/docs/ja/specdojo/samples/cld-sample.md +1 -1
  190. package/docs/ja/specdojo/samples/cnd-sample.md +1 -1
  191. package/docs/ja/specdojo/samples/cop-index-sample.md +1 -1
  192. package/docs/ja/specdojo/samples/cop-sample.md +1 -1
  193. package/docs/ja/specdojo/samples/cpd-sample.md +1 -1
  194. package/docs/ja/specdojo/samples/cstd-sample.md +1 -1
  195. package/docs/ja/specdojo/samples/cxd-sample.md +1 -1
  196. package/docs/ja/specdojo/samples/dmd-index-sample.md +1 -1
  197. package/docs/ja/specdojo/samples/dmd-sample.md +1 -1
  198. package/docs/ja/specdojo/samples/etc-index-sample.md +1 -1
  199. package/docs/ja/specdojo/samples/etc-sample.md +1 -1
  200. package/docs/ja/specdojo/samples/gl-sample.yaml +2 -0
  201. package/docs/ja/specdojo/samples/ifd-sample.md +1 -1
  202. package/docs/ja/specdojo/samples/ifx-api-sample.yaml +1 -0
  203. package/docs/ja/specdojo/samples/ifx-cmd-sample.yaml +1 -1
  204. package/docs/ja/specdojo/samples/ifx-file-sample.md +1 -1
  205. package/docs/ja/specdojo/samples/ifx-index-sample.yaml +1 -0
  206. package/docs/ja/specdojo/samples/ifx-msg-sample.yaml +2 -1
  207. package/docs/ja/specdojo/samples/itc-index-sample.md +1 -1
  208. package/docs/ja/specdojo/samples/itc-sample.md +1 -1
  209. package/docs/ja/specdojo/samples/mtp-sample.md +1 -1
  210. package/docs/ja/specdojo/samples/nfr-availability-sample.md +1 -1
  211. package/docs/ja/specdojo/samples/nfr-index-sample.md +1 -1
  212. package/docs/ja/specdojo/samples/nfr-integrity-sample.md +1 -1
  213. package/docs/ja/specdojo/samples/nfr-maintainability-sample.md +1 -1
  214. package/docs/ja/specdojo/samples/nfr-operations-sample.md +1 -1
  215. package/docs/ja/specdojo/samples/nfr-performance-sample.md +1 -1
  216. package/docs/ja/specdojo/samples/nfr-reliability-sample.md +1 -1
  217. package/docs/ja/specdojo/samples/nfr-security-safety-sample.md +1 -1
  218. package/docs/ja/specdojo/samples/nfr-usability-sample.md +1 -1
  219. package/docs/ja/specdojo/samples/ntp-sample.md +1 -1
  220. package/docs/ja/specdojo/samples/opd-sample.md +1 -1
  221. package/docs/ja/specdojo/samples/opr-sample.md +1 -1
  222. package/docs/ja/specdojo/samples/otp-index-sample.md +1 -1
  223. package/docs/ja/specdojo/samples/otp-sample.md +1 -1
  224. package/docs/ja/specdojo/samples/prj-stakeholder-register-sample.md +1 -1
  225. package/docs/ja/specdojo/samples/sac-sample.md +1 -1
  226. package/docs/ja/specdojo/samples/sf-index-sample.md +1 -1
  227. package/docs/ja/specdojo/samples/sf-sample.md +1 -1
  228. package/docs/ja/specdojo/samples/sld-sample.md +1 -1
  229. package/docs/ja/specdojo/samples/stc-index-sample.md +1 -1
  230. package/docs/ja/specdojo/samples/stc-sample.md +1 -1
  231. package/docs/ja/specdojo/samples/stsd-sample.md +1 -1
  232. package/docs/ja/specdojo/samples/sysd-critical-flows-sample.md +1 -1
  233. package/docs/ja/specdojo/samples/sysd-cross-cutting-policy-sample.md +1 -1
  234. package/docs/ja/specdojo/samples/sysd-index-sample.md +1 -1
  235. package/docs/ja/specdojo/samples/tsd-index-sample.md +22 -16
  236. package/docs/ja/specdojo/samples/tsd-sample.md +241 -21
  237. package/docs/ja/specdojo/samples/tsp-index-sample.md +1 -1
  238. package/docs/ja/specdojo/samples/uis-sample.md +1 -1
  239. package/docs/ja/specdojo/samples/utc-index-sample.md +1 -1
  240. package/docs/ja/specdojo/samples/utc-sample.md +1 -1
  241. package/docs/ja/specdojo/standards/document-metadata-standard.md +28 -3
  242. package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +2 -0
  243. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +16 -11
  244. package/docs/ja/specdojo/standards/sample-authoring-standard.md +1 -0
  245. package/docs/ja/specdojo/templates/ifx-cmd-template.yaml +1 -1
  246. package/docs/ja/specdojo/templates/pjr-dependent-items-template.md +22 -0
  247. package/docs/ja/specdojo/templates/pjr-epic-items-template.md +22 -0
  248. package/docs/ja/specdojo/templates/pjr-epic-template.md +44 -0
  249. package/docs/ja/specdojo/templates/pjr-index-template.md +4 -2
  250. package/docs/specdojo/schemas/v1/bdd.schema.yaml +1 -1
  251. package/docs/specdojo/schemas/v1/deliverable-frontmatter.schema.yaml +24 -16
  252. package/docs/specdojo/schemas/v1/exec-common.schema.yaml +4 -1
  253. package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +1 -1
  254. package/docs/specdojo/schemas/v1/gl.schema.yaml +8 -0
  255. package/docs/specdojo/schemas/v1/ifx-cmd.schema.yaml +5 -1
  256. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +2 -1
  257. package/docs/specdojo/schemas/v1/register-events.schema.yaml +18 -0
  258. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +40 -3
  259. package/docs/specdojo/schemas/v1/rulebook-frontmatter.schema.yaml +5 -0
  260. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +5 -0
  261. package/package.json +2 -2
  262. package/templates/antigravity/orchestrator.md +14 -9
  263. package/templates/claude/agents/specdojo-orchestrator.md +14 -9
  264. package/templates/codex/agents/specdojo-orchestrator.toml +14 -9
  265. package/templates/codex/orchestrator.md +14 -9
  266. package/templates/copilot/README.md +2 -1
  267. package/templates/opencode/agents/specdojo-orchestrator.md +14 -9
@@ -4,11 +4,13 @@ import { inlineCodeAnglePlaceholders } from "../shared/text.js";
4
4
  import { APPROACHES } from "../shared/agent-types.js";
5
5
  import { appendRegisterEvent, buildRegisterEvent, registerEventFilePath } from "./events.js";
6
6
  import { nowUtcTimestamp } from "./date.js";
7
- import { CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
7
+ import { readRegisterItemContent, CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
8
8
  import { resolveSpecdojoTemplatePath } from "../docs/template-resolution.js";
9
9
  import { validateRegisterApproachTargetsForProject } from "./approach.js";
10
+ import { normalizeDependsOn, validateRegisterDependencies } from "./dependency.js";
10
11
  import { normalizeDerivedFrom, validateDerivedFrom } from "./derivation.js";
11
12
  import { delegateExternalRegisterAdd } from "./external-project.js";
13
+ import { validateRegisterTrack } from "./epic.js";
12
14
  import { isAuthoringApproach } from "../kata/authoring.js";
13
15
  function collectTarget(value, previous = []) {
14
16
  return [...previous, value];
@@ -72,6 +74,7 @@ export function registerCreateCommands(reg, dependencies) {
72
74
  const addCmd = reg.command("add").description("Add a new item to pjr-index.md");
73
75
  addProjectOption(addCmd);
74
76
  addCmd.requiredOption("--type <type>", `Item type: ${VALID_TYPES.join(" | ")}`);
77
+ addCmd.option("--track <track>", "Track governed by an epic (required for epic)");
75
78
  addCmd.requiredOption("--title <title>", "Short title for the item");
76
79
  addCmd.option("--description <text>", "Description shown in the list", "_TODO_");
77
80
  addCmd.option("--priority <priority>", `Priority: ${VALID_PRIORITIES.join(" | ")}`, "medium");
@@ -85,9 +88,10 @@ export function registerCreateCommands(reg, dependencies) {
85
88
  addCmd.option("--target-path <path>", "Repository-relative deliverable file path");
86
89
  addCmd.option("--target-rulebook <doc-id>", "Deliverable rulebook id (new id for bootstrap)");
87
90
  addCmd.option("--approach <approach>", `Execution approach: ${APPROACHES.join(" | ")}`);
88
- addCmd.option("--target <doc-id>", "Target document id (repeatable; authoring accepts legacy exemplar targets after the first)", collectTarget);
91
+ addCmd.option("--target <target>", "Document id, domain:<id> for catalog-planning, or track:<id> for strategy-planning (repeatable)", collectTarget);
89
92
  addCmd.option("--source <ref>", "Read-only exemplar for *-authoring (repeatable: doc id, path, or <repo>:<path>)", collectTarget);
90
93
  addCmd.option("--from <item-id>", "Register item this item derives from (repeatable)", collectTarget);
94
+ addCmd.option("--depends-on <item-id>", "Predecessor item ID (repeatable; use - to remove)", collectTarget);
91
95
  addCmd.option("--id <id>", "Display ID (e.g., PJR-0061); auto-incremented if omitted");
92
96
  addCmd.option("--topic <topic>", "Topic slug for ticket filename; derived from --title if omitted");
93
97
  addCmd.option("--by <actor>", "Actor recorded in the append-only register event");
@@ -139,7 +143,10 @@ export function registerCreateCommands(reg, dependencies) {
139
143
  ...(explicitSources !== undefined ? { sources: explicitSources } : {}),
140
144
  validateTargetsWithoutApproach: opts.target !== undefined || opts.source !== undefined,
141
145
  });
146
+ const track = opts.track?.trim();
147
+ validateRegisterTrack(paths.projectId, opts.type, track);
142
148
  const fields = {
149
+ ...(track !== undefined ? { track } : {}),
143
150
  type: opts.type,
144
151
  title: opts.title,
145
152
  description: opts.description,
@@ -174,6 +181,7 @@ export function registerCreateCommands(reg, dependencies) {
174
181
  });
175
182
  if (derivedFrom !== undefined)
176
183
  fields.derivedFrom = derivedFrom;
184
+ fields.dependsOn = normalizeDependsOn(opts.dependsOn);
177
185
  const ticketPath = join(paths.projectRegisterPath, ticketFilename);
178
186
  const content = buildRegisterItemContent({
179
187
  projectId: paths.projectId,
@@ -182,6 +190,10 @@ export function registerCreateCommands(reg, dependencies) {
182
190
  fields,
183
191
  templatePath,
184
192
  });
193
+ const dependencyItem = readRegisterItemContent(content, ticketFilename)?.item;
194
+ if (!dependencyItem)
195
+ throw new Error(`Failed to read item ${displayId}`);
196
+ validateRegisterDependencies(paths, dependencyItem);
185
197
  const addEvent = buildRegisterEvent({
186
198
  afterContent: content,
187
199
  filename: ticketFilename,
@@ -230,6 +242,7 @@ export function registerUpdateCommand(reg, dependencies) {
230
242
  const updateCmd = reg.command("update").description("Update fields of a register item");
231
243
  addProjectOption(updateCmd);
232
244
  updateCmd.requiredOption("--id <id>", "Item ID (PJR-XXXX)");
245
+ updateCmd.option("--track <track>", "Replace the track governed by an epic");
233
246
  updateCmd.option("--title <title>", "Update title");
234
247
  updateCmd.option("--description <text>", "Update description");
235
248
  updateCmd.option("--priority <priority>", `Update priority: ${VALID_PRIORITIES.join(" | ")}`);
@@ -242,9 +255,10 @@ export function registerUpdateCommand(reg, dependencies) {
242
255
  updateCmd.option("--target-path <path>", "Replace deliverable path; use - to remove");
243
256
  updateCmd.option("--target-rulebook <doc-id>", "Replace deliverable rulebook id; use - to remove");
244
257
  updateCmd.option("--approach <approach>", `Update execution approach (${APPROACHES.join(" | ")}; use - to remove)`);
245
- updateCmd.option("--target <doc-id>", "Replace target document ids (repeatable; legacy authoring exemplars may follow; use - to remove)", collectTarget);
258
+ updateCmd.option("--target <target>", "Replace target document ids (repeatable; legacy authoring exemplars may follow; use - to remove)", collectTarget);
246
259
  updateCmd.option("--source <ref>", "Replace read-only *-authoring exemplars (repeatable; use - to remove)", collectTarget);
247
260
  updateCmd.option("--from <item-id>", "Replace source register item IDs (repeatable; use - to remove)", collectTarget);
261
+ updateCmd.option("--depends-on <item-id>", "Replace predecessor IDs (repeatable; use - to remove)", collectTarget);
248
262
  updateCmd.option("--topic <topic>", "Update the topic slug in the ticket filename and document ID");
249
263
  updateCmd.option("--by <actor>", "Actor recorded in the append-only register event");
250
264
  updateCmd.option("--reason <text>", "Reason recorded in the append-only register event");
@@ -256,6 +270,7 @@ export function registerUpdateCommand(reg, dependencies) {
256
270
  const view = loadItemForUpdate(paths, opts.id);
257
271
  const item = view.item;
258
272
  const hasUpdates = [
273
+ "track",
259
274
  "title",
260
275
  "description",
261
276
  "priority",
@@ -271,10 +286,11 @@ export function registerUpdateCommand(reg, dependencies) {
271
286
  "targetPath",
272
287
  "targetRulebook",
273
288
  "from",
289
+ "dependsOn",
274
290
  "topic",
275
291
  ].some((key) => opts[key] !== undefined);
276
292
  if (!hasUpdates) {
277
- throw new Error("At least one field option must be specified (--title, --description, --priority, --difficulty, --owner, --due, --conclusion, --block-reason, --autopilot, --approach, --target, --source, --from, --topic)");
293
+ throw new Error("At least one field option must be specified (--track, --title, --description, --priority, --difficulty, --owner, --due, --conclusion, --block-reason, --autopilot, --approach, --target, --source, --from, --depends-on, --topic)");
278
294
  }
279
295
  if (opts.priority !== undefined &&
280
296
  !VALID_PRIORITIES.includes(opts.priority)) {
@@ -357,6 +373,8 @@ export function registerUpdateCommand(reg, dependencies) {
357
373
  ? explicitSources
358
374
  : item.sources;
359
375
  const normalizedNextSources = nextSources && nextSources.length > 0 ? nextSources : undefined;
376
+ const nextDependsOn = opts.dependsOn === undefined ? item.dependsOn : normalizeDependsOn(opts.dependsOn);
377
+ validateRegisterDependencies(paths, { ...item, dependsOn: nextDependsOn });
360
378
  const nextDerivedFrom = opts.from === undefined
361
379
  ? item.derivedFrom
362
380
  : normalizeDerivedFrom(opts.from, { allowRemove: true });
@@ -384,6 +402,9 @@ export function registerUpdateCommand(reg, dependencies) {
384
402
  (authoring && opts.source !== undefined && (item.targets?.length ?? 0) > 1);
385
403
  const shouldUpdateSources = opts.source !== undefined || (authoring && providedLegacySources.length > 0);
386
404
  const approachTargetUpdates = {
405
+ ...(opts.dependsOn !== undefined
406
+ ? { depends_on: nextDependsOn ?? REMOVE_REGISTER_ITEM_FIELD }
407
+ : {}),
387
408
  ...(opts.targetPath !== undefined
388
409
  ? { target_path: nextTargetPath ?? REMOVE_REGISTER_ITEM_FIELD }
389
410
  : {}),
@@ -416,8 +437,11 @@ export function registerUpdateCommand(reg, dependencies) {
416
437
  }
417
438
  : {}),
418
439
  };
440
+ const track = opts.track === undefined ? item.track : opts.track.trim();
441
+ validateRegisterTrack(paths.projectId, item.type, track);
419
442
  const updated = {
420
443
  ...item,
444
+ ...(track !== undefined ? { track } : {}),
421
445
  ...(opts.title !== undefined ? { title: opts.title } : {}),
422
446
  ...(opts.description !== undefined ? { description: opts.description } : {}),
423
447
  ...(opts.priority !== undefined ? { priority: opts.priority } : {}),
@@ -472,6 +496,12 @@ export function registerUpdateCommand(reg, dependencies) {
472
496
  else
473
497
  updated.derivedFrom = nextDerivedFrom;
474
498
  }
499
+ if (opts.dependsOn !== undefined) {
500
+ if (nextDependsOn === undefined)
501
+ delete updated.dependsOn;
502
+ else
503
+ updated.dependsOn = nextDependsOn;
504
+ }
475
505
  const currentTopic = view.ticketFilename
476
506
  ? ticketTopicFromFilename(opts.id, view.ticketFilename)
477
507
  : undefined;
@@ -0,0 +1,123 @@
1
+ import { basename } from "node:path";
2
+ import { gitOutput, gitResult } from "../shared/git.js";
3
+ import { getProjectRegisterPath, loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
4
+ import { resolveProjectIntegrationBranch } from "./cross-project.js";
5
+ import { parseRegisterItemRef } from "./derivation.js";
6
+ import { loadRegisterItemDocs, readRegisterItemContent } from "./item.js";
7
+ export function normalizeDependsOn(values) {
8
+ if (values === undefined)
9
+ return undefined;
10
+ const refs = [...new Set(values.map((value) => value.trim()).filter(Boolean))];
11
+ if (refs.includes("-")) {
12
+ if (refs.length !== 1)
13
+ throw new Error("--depends-on - cannot be combined with other item IDs");
14
+ return undefined;
15
+ }
16
+ if (refs.length === 0)
17
+ throw new Error("--depends-on must contain a register item ID");
18
+ return refs;
19
+ }
20
+ // Each operation gets a fresh snapshot. Other projects are read from the same local
21
+ // integration branches used to verify derived_from, never from unrelated worktrees.
22
+ function dependencyGraph(paths, replacement) {
23
+ const projects = new Map();
24
+ const local = new Map(loadRegisterItemDocs(paths.projectRegisterPath).map((doc) => [doc.id, doc.item]));
25
+ if (replacement)
26
+ local.set(replacement.id, replacement);
27
+ projects.set(paths.projectId, local);
28
+ const projectItems = (projectId) => {
29
+ const cached = projects.get(projectId);
30
+ if (cached)
31
+ return cached;
32
+ const { config } = loadConfig();
33
+ const project = config?.projects[projectId];
34
+ if (!project)
35
+ throw new Error(`depends_on: unknown project ${projectId}`);
36
+ const registerPath = getProjectRegisterPath(project);
37
+ if (!registerPath)
38
+ throw new Error(`depends_on: project_register_path is not set for ${projectId}`);
39
+ const root = specdojoRootDir();
40
+ const branch = resolveProjectIntegrationBranch(projectId, project);
41
+ if (gitResult(root, ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`]).status !== 0) {
42
+ throw new Error(`depends_on: integration branch does not exist locally: ${branch}`);
43
+ }
44
+ const files = gitOutput(root, [
45
+ "ls-tree",
46
+ "-r",
47
+ "--name-only",
48
+ branch,
49
+ "--",
50
+ registerPath.replaceAll("\\", "/"),
51
+ ]);
52
+ const items = new Map();
53
+ for (const file of files.split(/\r?\n/).filter(Boolean)) {
54
+ if (!/^pjr-[0-9a-z]{4}-.+\.md$/.test(basename(file)))
55
+ continue;
56
+ const parsed = readRegisterItemContent(gitOutput(root, ["show", `${branch}:${file}`]), basename(file));
57
+ if (parsed)
58
+ items.set(parsed.id, parsed.item);
59
+ }
60
+ projects.set(projectId, items);
61
+ return items;
62
+ };
63
+ const lookup = (ref, projectId) => {
64
+ const parsed = parseRegisterItemRef(ref, projectId);
65
+ if (!parsed)
66
+ throw new Error(`Invalid depends_on item ID: "${ref}". Use PJR-XXXX or <project-id>:PJR-XXXX`);
67
+ const item = projectItems(parsed.projectId).get(parsed.itemId);
68
+ if (!item)
69
+ throw new Error(`Depends-on item not found: ${ref} (searched configured project ${parsed.projectId})`);
70
+ return { ...parsed, key: `${parsed.projectId}:${parsed.itemId}`, item };
71
+ };
72
+ const visited = new Set();
73
+ const visiting = [];
74
+ const visit = (item, projectId) => {
75
+ const key = `${projectId}:${item.id}`;
76
+ if (visiting.includes(key))
77
+ throw new Error(`depends_on cycle: ${[...visiting, key].join(" -> ")}`);
78
+ if (visited.has(key))
79
+ return;
80
+ visiting.push(key);
81
+ for (const ref of item.dependsOn ?? []) {
82
+ const target = lookup(ref, projectId);
83
+ if (target.key === key)
84
+ throw new Error(`Item ${key} cannot depend on itself`);
85
+ visit(target.item, target.projectId);
86
+ }
87
+ visiting.pop();
88
+ visited.add(key);
89
+ };
90
+ return { local, lookup, visit };
91
+ }
92
+ export function validateRegisterDependencies(paths, replacement) {
93
+ const graph = dependencyGraph(paths, replacement);
94
+ for (const item of graph.local.values())
95
+ graph.visit(item, paths.projectId);
96
+ }
97
+ export function validateRegisterDependencyDocs(paths) {
98
+ try {
99
+ validateRegisterDependencies(paths);
100
+ return [];
101
+ }
102
+ catch (error) {
103
+ return [error instanceof Error ? error.message : String(error)];
104
+ }
105
+ }
106
+ export function registerDependencyBlockReason(paths, item) {
107
+ if (!item.dependsOn?.length)
108
+ return undefined;
109
+ try {
110
+ const graph = dependencyGraph(paths, item);
111
+ graph.visit(item, paths.projectId);
112
+ const pending = item.dependsOn.flatMap((ref) => {
113
+ const target = graph.lookup(ref, paths.projectId);
114
+ return ["done", "decided"].includes(target.item.status)
115
+ ? []
116
+ : [`${ref} (${target.item.status})`];
117
+ });
118
+ return pending.length ? `Unfinished depends_on: ${pending.join(", ")}` : undefined;
119
+ }
120
+ catch (error) {
121
+ return error instanceof Error ? error.message : String(error);
122
+ }
123
+ }
@@ -147,11 +147,11 @@ function configuredExternalRegisterDirectories(paths) {
147
147
  return existsSync(absolutePath) ? [{ projectId, registerPath: absolutePath }] : [];
148
148
  });
149
149
  }
150
- export function collectDerivedRegisterRelations(paths, currentItems) {
150
+ export function collectDerivedRegisterRelations(paths, currentItems, relationField = "derivedFrom") {
151
151
  const relations = [];
152
152
  const collect = (projectId, items) => {
153
153
  for (const item of items) {
154
- for (const ref of item.item.derivedFrom ?? []) {
154
+ for (const ref of item.item[relationField] ?? []) {
155
155
  const source = parseRegisterItemRef(ref, projectId);
156
156
  if (!source || source.projectId !== paths.projectId)
157
157
  continue;
@@ -0,0 +1,42 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ import { getProjectTimelinePath, loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
4
+ import { loadTimelineIndex } from "../shared/timeline-index.js";
5
+ import { loadRegisterItemDocs } from "./item.js";
6
+ // track は epic の担当単位。timeline がない project でも同じ形式の識別子を保持する。
7
+ export function validateRegisterTrack(projectId, itemType, track) {
8
+ if (itemType !== "epic") {
9
+ if (track !== undefined)
10
+ throw new Error("--track is only valid for epic items");
11
+ return;
12
+ }
13
+ if (!track || !/^[a-z0-9][a-z0-9-]*$/.test(track)) {
14
+ throw new Error("An epic requires --track with a lowercase track identifier");
15
+ }
16
+ const { config } = loadConfig();
17
+ const project = config?.projects[projectId];
18
+ if (!project)
19
+ throw new Error(`Cannot validate epic track: unknown project ${projectId}`);
20
+ const indexPath = resolve(specdojoRootDir(), getProjectTimelinePath(project), "tml-index.yaml");
21
+ if (!existsSync(indexPath))
22
+ return;
23
+ const { index, errors } = loadTimelineIndex(indexPath);
24
+ if (errors.length > 0)
25
+ throw new Error(`${indexPath}: ${errors.join("; ")}`);
26
+ if (!index.tracks.some((entry) => entry.track === track)) {
27
+ throw new Error(`Undefined epic track "${track}" in ${indexPath}`);
28
+ }
29
+ }
30
+ export function validateRegisterEpicDocs(paths) {
31
+ return loadRegisterItemDocs(paths.projectRegisterPath).flatMap((doc) => {
32
+ try {
33
+ validateRegisterTrack(paths.projectId, doc.item.type, doc.item.track);
34
+ return [];
35
+ }
36
+ catch (error) {
37
+ return [
38
+ `${join(paths.projectRegisterPath, doc.filename)}: ${error instanceof Error ? error.message : String(error)}`,
39
+ ];
40
+ }
41
+ });
42
+ }
@@ -125,6 +125,8 @@ function fieldUpdateFromChange(change) {
125
125
  switch (change.field) {
126
126
  case "type":
127
127
  return isUnset ? undefined : { item_type: value };
128
+ case "track":
129
+ return { track: isUnset ? REMOVE_REGISTER_ITEM_FIELD : value };
128
130
  case "priority":
129
131
  return isUnset ? undefined : { priority: value };
130
132
  case "difficulty":
@@ -158,13 +160,14 @@ function fieldUpdateFromChange(change) {
158
160
  return undefined;
159
161
  }
160
162
  }
163
+ case "depends_on":
161
164
  case "derived_from": {
162
165
  if (isUnset)
163
- return { derived_from: REMOVE_REGISTER_ITEM_FIELD };
166
+ return { [change.field]: REMOVE_REGISTER_ITEM_FIELD };
164
167
  try {
165
168
  const parsed = JSON.parse(value);
166
169
  return Array.isArray(parsed) && parsed.every((ref) => typeof ref === "string")
167
- ? { derived_from: parsed }
170
+ ? { [change.field]: parsed }
168
171
  : undefined;
169
172
  }
170
173
  catch {
@@ -13,6 +13,7 @@ export const REGISTER_EVENT_FIELDS = [
13
13
  "title",
14
14
  "description",
15
15
  "type",
16
+ "track",
16
17
  "priority",
17
18
  "difficulty",
18
19
  "owner",
@@ -27,6 +28,7 @@ export const REGISTER_EVENT_FIELDS = [
27
28
  "target_path",
28
29
  "target_rulebook",
29
30
  "derived_from",
31
+ "depends_on",
30
32
  "autopilot",
31
33
  ];
32
34
  export const REGISTER_EVENT_ACTIONS = [
@@ -69,6 +71,7 @@ export function registerEventFieldValues(content, filename, timeZone) {
69
71
  title: item.title,
70
72
  description: item.description,
71
73
  type: item.type,
74
+ track: item.track ?? CELL_NONE,
72
75
  priority: item.priority,
73
76
  difficulty: item.difficulty ?? CELL_NONE,
74
77
  owner: item.owner,
@@ -83,6 +86,7 @@ export function registerEventFieldValues(content, filename, timeZone) {
83
86
  target_rulebook: item.targetRulebook ?? CELL_NONE,
84
87
  sources: item.sources ? JSON.stringify(item.sources) : CELL_NONE,
85
88
  derived_from: item.derivedFrom ? JSON.stringify(item.derivedFrom) : CELL_NONE,
89
+ depends_on: item.dependsOn ? JSON.stringify(item.dependsOn) : CELL_NONE,
86
90
  autopilot: item.autopilot ?? CELL_NONE,
87
91
  };
88
92
  }
@@ -40,6 +40,7 @@ export function buildExternalRegisterAddArgs(alias, externalProject, opts) {
40
40
  "--conclusion",
41
41
  opts.conclusion,
42
42
  ];
43
+ addValue(args, "--track", opts.track);
43
44
  addValue(args, "--difficulty", opts.difficulty);
44
45
  addValue(args, "--registered", opts.registered);
45
46
  addValue(args, "--approach", opts.approach);
@@ -50,6 +51,9 @@ export function buildExternalRegisterAddArgs(alias, externalProject, opts) {
50
51
  for (const source of opts.from ?? []) {
51
52
  addValue(args, "--from", rewriteExternalDerivedFrom(source, alias, externalProject.project_id));
52
53
  }
54
+ for (const predecessor of opts.dependsOn ?? []) {
55
+ addValue(args, "--depends-on", rewriteExternalDerivedFrom(predecessor, alias, externalProject.project_id));
56
+ }
53
57
  addValue(args, "--id", opts.id);
54
58
  addValue(args, "--topic", opts.topic);
55
59
  addValue(args, "--by", opts.by);
@@ -20,6 +20,7 @@ export const VALID_STATUSES = [
20
20
  ];
21
21
  export const VALID_TYPES = [
22
22
  "todo",
23
+ "epic",
23
24
  "question",
24
25
  "risk",
25
26
  "issue",
@@ -57,6 +58,7 @@ const SPECDOJO_KEY_ORDER = [
57
58
  "part_of",
58
59
  "based_on",
59
60
  "item_type",
61
+ "track",
60
62
  "item_status",
61
63
  "priority",
62
64
  "difficulty",
@@ -67,6 +69,7 @@ const SPECDOJO_KEY_ORDER = [
67
69
  "block_reason",
68
70
  "conclusion",
69
71
  "derived_from",
72
+ "depends_on",
70
73
  "autopilot",
71
74
  "approach",
72
75
  "targets",
@@ -228,6 +231,9 @@ export function readRegisterItemContent(content, filename) {
228
231
  const derivedFrom = Array.isArray(fields.derived_from)
229
232
  ? fields.derived_from.filter((entry) => typeof entry === "string" && entry.trim() !== "")
230
233
  : undefined;
234
+ const dependsOn = Array.isArray(fields.depends_on)
235
+ ? fields.depends_on.filter((value) => typeof value === "string" && value.trim() !== "")
236
+ : undefined;
231
237
  const autopilot = fields.autopilot === "approved" ? "approved" : undefined;
232
238
  const difficulty = asString(fields.difficulty);
233
239
  const item = {
@@ -236,6 +242,7 @@ export function readRegisterItemContent(content, filename) {
236
242
  title: titleFromBody(body, id),
237
243
  description: descriptionFromBody(body),
238
244
  type: asString(fields.item_type) ?? CELL_TODO,
245
+ ...(asString(fields.track) ? { track: asString(fields.track) } : {}),
239
246
  priority: asString(fields.priority) ?? "medium",
240
247
  ...(difficulty ? { difficulty } : {}),
241
248
  owner: asString(fields.owner) ?? CELL_TODO,
@@ -255,6 +262,7 @@ export function readRegisterItemContent(content, filename) {
255
262
  ...(targets && targets.length > 0 ? { targets } : {}),
256
263
  ...(sources && sources.length > 0 ? { sources } : {}),
257
264
  ...(derivedFrom && derivedFrom.length > 0 ? { derivedFrom } : {}),
265
+ ...(dependsOn && dependsOn.length > 0 ? { dependsOn } : {}),
258
266
  ...(autopilot ? { autopilot } : {}),
259
267
  };
260
268
  return {
@@ -376,12 +384,14 @@ export function registerItemFieldsFromItem(item) {
376
384
  conclusion: isPlaceholderCell(item.conclusion)
377
385
  ? null
378
386
  : inlineCodeAnglePlaceholders(item.conclusion.trim()),
387
+ ...(item.track ? { track: item.track } : {}),
379
388
  ...(item.approach ? { approach: item.approach } : {}),
380
389
  ...(item.targetPath ? { target_path: item.targetPath } : {}),
381
390
  ...(item.targetRulebook ? { target_rulebook: item.targetRulebook } : {}),
382
391
  ...(item.targets && item.targets.length > 0 ? { targets: item.targets } : {}),
383
392
  ...(item.sources && item.sources.length > 0 ? { sources: item.sources } : {}),
384
393
  ...(item.derivedFrom && item.derivedFrom.length > 0 ? { derived_from: item.derivedFrom } : {}),
394
+ ...(item.dependsOn && item.dependsOn.length > 0 ? { depends_on: item.dependsOn } : {}),
385
395
  ...(item.autopilot ? { autopilot: item.autopilot } : {}),
386
396
  };
387
397
  }
@@ -4,6 +4,8 @@ import { createGitTimestampResolver, planRegisterTimestampMigration, summarizeTi
4
4
  import { registerEventFilePath, validateRegisterEventDocs } from "./events.js";
5
5
  import { validateRegisterItemDocs } from "./item.js";
6
6
  import { specdojoRootDir } from "../shared/specdojo-config.js";
7
+ import { validateRegisterDependencyDocs } from "./dependency.js";
8
+ import { validateRegisterEpicDocs } from "./epic.js";
7
9
  import { validateDerivedFromDocs } from "./derivation.js";
8
10
  export function registerMaintenanceCommands(reg, dependencies) {
9
11
  const { addProjectOption, addRegisterCommitOptions, applyRegisterMigrationPlan, generateDerivedViewFiles, loadItemForUpdate, migrateEmbeddedRegisterEvents, migrateRegisterEventsFromGit, parseHistoryIds, planRegisterMigration, planRenumber, printCommandError, registerEventActor, renumberPjrItem, repoRelativePathspec, resolveRegisterPaths, runRegisterMutation, validBuildScopes, writeDerivedViews, } = dependencies;
@@ -87,7 +89,11 @@ export function registerMaintenanceCommands(reg, dependencies) {
87
89
  throw new Error(`Invalid scope: "${opts.scope}". Must be one of: ${validBuildScopes.join(", ")}`);
88
90
  }
89
91
  const validation = validateRegisterItemDocs(paths.projectRegisterPath);
90
- const derivationErrors = validateDerivedFromDocs(paths);
92
+ const derivationErrors = [
93
+ ...validateDerivedFromDocs(paths),
94
+ ...validateRegisterEpicDocs(paths),
95
+ ...validateRegisterDependencyDocs(paths),
96
+ ];
91
97
  const eventErrors = validateRegisterEventDocs(paths.projectRegisterPath, paths.registerDateTimeZone);
92
98
  if (validation.errors.length > 0 || derivationErrors.length > 0 || eventErrors.length > 0) {
93
99
  throw new Error(`Invalid register item files:\n${[
@@ -0,0 +1,37 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ import { getProjectCatalogPath, getProjectTimelinePath, } from "../shared/specdojo-config.js";
4
+ import { loadTimelineIndex } from "../shared/timeline-index.js";
5
+ export function isPlanningApproach(approach) {
6
+ return approach === "catalog-planning" || approach === "strategy-planning";
7
+ }
8
+ // These targets identify work units, including units whose documents do not exist yet.
9
+ export function planningTarget(approach, target) {
10
+ const prefix = approach === "catalog-planning" ? "domain" : "track";
11
+ const match = target.match(new RegExp(`^${prefix}:([a-z0-9][a-z0-9-]{0,62})$`));
12
+ if (!match)
13
+ throw new Error(`Approach "${approach}" requires --target ${prefix}:<id>`);
14
+ return match[1];
15
+ }
16
+ export function validatePlanningTarget(opts) {
17
+ const unit = planningTarget(opts.approach, opts.target);
18
+ if (!getProjectCatalogPath(opts.project)) {
19
+ throw new Error(`Approach "${opts.approach}" requires catalog_path`);
20
+ }
21
+ if (opts.approach !== "strategy-planning")
22
+ return;
23
+ if (!opts.project.schedule_path?.trim()) {
24
+ throw new Error('Approach "strategy-planning" requires schedule_path');
25
+ }
26
+ const file = resolve(opts.repoRoot, getProjectTimelinePath(opts.project), "tml-index.yaml");
27
+ if (!existsSync(file)) {
28
+ // A declared strategy scope also supports projects without a timeline.
29
+ return;
30
+ }
31
+ const { index, errors } = loadTimelineIndex(file);
32
+ if (errors.length > 0)
33
+ throw new Error(`${file}: ${errors.join("; ")}`);
34
+ if (!index.tracks.some((track) => track.track === unit)) {
35
+ throw new Error(`Undefined strategy track "${unit}" in ${join(getProjectTimelinePath(opts.project), "tml-index.yaml")}`);
36
+ }
37
+ }
@@ -6,6 +6,7 @@ import { inlineCodeAnglePlaceholders } from "../shared/text.js";
6
6
  import { atomicWriteFile, buildRegisterItemContent, derivedTopicNeedsWarning, generatePjrId, printDerivedTopicWarning, registerEventActor, REGISTER_TOPIC_RE, resolveRegisterPaths, slugify, validateFields, } from "./core.js";
7
7
  import { registerCreateCommands, registerUpdateCommand } from "./create-commands.js";
8
8
  import { normalizeRegisterTimestamp } from "./date.js";
9
+ import { validateRegisterDependencyDocs } from "./dependency.js";
9
10
  import { validateDerivedFromDocs } from "./derivation.js";
10
11
  import { appendRegisterEvent, deterministicRegisterEventId, readEmbeddedRegisterEvents, readRegisterEventsFromContent, registerEventFilePath, removeEmbeddedRegisterEvents, serializeRegisterEvents, validateRegisterEventDocs, } from "./events.js";
11
12
  import { collectRegisterHistoryEvents } from "./history.js";
@@ -82,7 +83,10 @@ function defaultRegisterCommitMessage(command, result) {
82
83
  }
83
84
  function rebuildRegisterViews(paths) {
84
85
  const validation = validateRegisterItemDocs(paths.projectRegisterPath);
85
- const derivationErrors = validateDerivedFromDocs(paths);
86
+ const derivationErrors = [
87
+ ...validateDerivedFromDocs(paths),
88
+ ...validateRegisterDependencyDocs(paths),
89
+ ];
86
90
  const eventErrors = validateRegisterEventDocs(paths.projectRegisterPath, paths.registerDateTimeZone);
87
91
  if (validation.errors.length > 0 || derivationErrors.length > 0 || eventErrors.length > 0) {
88
92
  throw new Error(`Invalid register item files:\n${[
@@ -71,12 +71,12 @@ export function renumberReferences(content, fromDocId, toDocId) {
71
71
  // から参照する project 修飾形の両方を対象にする。
72
72
  function renumberDerivedFromReferences(content, filename, sourceProjectId, fromId, toId) {
73
73
  const parsed = readRegisterItemContent(content, filename);
74
- if (!parsed?.item.derivedFrom)
74
+ if (!parsed)
75
75
  return { content, changed: false };
76
76
  const docId = readSpecdojoFields(content).id;
77
77
  const referencingProjectId = typeof docId === "string" && docId.includes(":") ? docId.split(":", 1)[0] : undefined;
78
78
  let changed = false;
79
- const derivedFrom = parsed.item.derivedFrom.map((ref) => {
79
+ const rewrite = (ref) => {
80
80
  if (referencingProjectId === sourceProjectId && ref === fromId) {
81
81
  changed = true;
82
82
  return toId;
@@ -86,9 +86,17 @@ function renumberDerivedFromReferences(content, filename, sourceProjectId, fromI
86
86
  return `${sourceProjectId}:${toId}`;
87
87
  }
88
88
  return ref;
89
- });
89
+ };
90
+ const derivedFrom = parsed.item.derivedFrom?.map(rewrite);
91
+ const dependsOn = parsed.item.dependsOn?.map(rewrite);
90
92
  return changed
91
- ? { content: applyRegisterItemFields(content, { derived_from: derivedFrom }), changed }
93
+ ? {
94
+ content: applyRegisterItemFields(content, {
95
+ ...(derivedFrom ? { derived_from: derivedFrom } : {}),
96
+ ...(dependsOn ? { depends_on: dependsOn } : {}),
97
+ }),
98
+ changed,
99
+ }
92
100
  : { content, changed };
93
101
  }
94
102
  // topic 変更で書き換える全ファイルを事前に算出する。参照の更新範囲は renumber と