specdojo 0.2.1 → 0.3.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 (242) hide show
  1. package/.github/agents/specdojo-orchestrator.md +165 -0
  2. package/CHANGELOG.md +298 -0
  3. package/README.md +92 -42
  4. package/dist/agent-response.js +20 -0
  5. package/dist/agent.js +4 -4
  6. package/dist/build-command.js +28 -8
  7. package/dist/catalog-build-references.js +144 -0
  8. package/dist/catalog-build-render.js +144 -0
  9. package/dist/catalog-build.js +13 -290
  10. package/dist/catalog-generate.js +6 -9
  11. package/dist/catalog-plan-generate.js +2 -2
  12. package/dist/catalog-plan.js +6 -6
  13. package/dist/catalog-scaffold.js +4 -4
  14. package/dist/catalog.js +2 -2
  15. package/dist/dashboard-exec-records.js +105 -0
  16. package/dist/dashboard-routines.js +255 -0
  17. package/dist/dashboard-shared.js +14 -0
  18. package/dist/dashboard-timeline.js +175 -0
  19. package/dist/dashboard.js +31 -444
  20. package/dist/deliverable-trash.js +3 -3
  21. package/dist/devcontainer-command.js +43 -0
  22. package/dist/devcontainer-scaffold.js +165 -0
  23. package/dist/doc-index.js +3 -3
  24. package/dist/exec-agent-config.js +107 -9
  25. package/dist/exec-agent-git-state.js +18 -0
  26. package/dist/exec-agent-protected-config.js +46 -8
  27. package/dist/exec-commands.js +557 -0
  28. package/dist/exec-core.js +457 -0
  29. package/dist/exec-evidence.js +254 -11
  30. package/dist/exec-handoff.js +336 -0
  31. package/dist/exec-parent-validation.js +317 -43
  32. package/dist/exec-pipeline-state.js +74 -9
  33. package/dist/exec-plans-core.js +693 -0
  34. package/dist/exec-plans-generation.js +206 -0
  35. package/dist/exec-plans-storage.js +131 -0
  36. package/dist/exec-plans.js +3 -1016
  37. package/dist/exec-protection-handoff.js +43 -2
  38. package/dist/exec-provider-scaffold.js +247 -15
  39. package/dist/exec-register-resume.js +65 -19
  40. package/dist/exec-register.js +9 -3
  41. package/dist/exec-repo-integration-git.js +23 -0
  42. package/dist/exec-repo-integration-sync.js +264 -0
  43. package/dist/exec-repo-integration.js +534 -0
  44. package/dist/exec-repo-trace.js +182 -0
  45. package/dist/exec-reporter-output.js +206 -0
  46. package/dist/exec-reporter.js +525 -248
  47. package/dist/exec-results.js +103 -71
  48. package/dist/exec-run-agent-pipeline.js +256 -0
  49. package/dist/exec-run-agent.js +531 -0
  50. package/dist/exec-run-in-place.js +541 -0
  51. package/dist/exec-run-job.js +717 -0
  52. package/dist/exec-run-lifecycle-commands.js +522 -0
  53. package/dist/exec-run-lock.js +110 -107
  54. package/dist/exec-run-mode-shared.js +140 -0
  55. package/dist/exec-run-register-command.js +244 -0
  56. package/dist/exec-run-register-core.js +386 -0
  57. package/dist/exec-run-register-mode.js +206 -0
  58. package/dist/exec-run-register-resume.js +393 -0
  59. package/dist/exec-run-register-state.js +322 -0
  60. package/dist/exec-run-register-worktree.js +509 -0
  61. package/dist/exec-run-schedule-mode.js +294 -0
  62. package/dist/exec-run-schedule-prepare.js +353 -0
  63. package/dist/exec-run-schedule-task.js +572 -0
  64. package/dist/exec-run-shared.js +399 -0
  65. package/dist/exec-run.js +11 -4953
  66. package/dist/exec-shared.js +9 -2
  67. package/dist/exec-slot-lock.js +242 -0
  68. package/dist/exec-task-repos.js +415 -0
  69. package/dist/exec-trial-commands.js +558 -0
  70. package/dist/exec-trial-core.js +371 -0
  71. package/dist/exec-trial.js +2 -895
  72. package/dist/exec-worktree-command.js +87 -43
  73. package/dist/exec-worktree-ops-commit.js +707 -0
  74. package/dist/exec-worktree-ops-lifecycle.js +292 -0
  75. package/dist/exec-worktree-ops-merge.js +303 -0
  76. package/dist/exec-worktree-ops.js +3 -847
  77. package/dist/exec-worktree.js +146 -31
  78. package/dist/exec.js +2 -999
  79. package/dist/frontmatter-namespace.js +2 -2
  80. package/dist/grade-apply.js +734 -0
  81. package/dist/grade-command-apply.js +250 -0
  82. package/dist/grade-command-inspect.js +138 -0
  83. package/dist/grade-command-plan.js +101 -0
  84. package/dist/grade-command-shared.js +68 -0
  85. package/dist/grade-core.js +307 -0
  86. package/dist/grade-markdown.js +274 -0
  87. package/dist/grade-pipeline-state.js +184 -0
  88. package/dist/grade-plan.js +507 -0
  89. package/dist/grade-result.js +133 -5
  90. package/dist/grade-target-discovery.js +265 -0
  91. package/dist/grade-targets.js +432 -0
  92. package/dist/grade.js +14 -2451
  93. package/dist/init-command.js +443 -0
  94. package/dist/job-definition.js +670 -0
  95. package/dist/job.js +64 -578
  96. package/dist/kata-command.js +2 -2
  97. package/dist/orchestrator.js +213 -0
  98. package/dist/register-command-types.js +1 -0
  99. package/dist/register-core.js +363 -0
  100. package/dist/register-create-commands.js +245 -0
  101. package/dist/register-event-merge.js +169 -0
  102. package/dist/register-events.js +4 -4
  103. package/dist/register-item.js +13 -7
  104. package/dist/register-maintenance-commands.js +187 -0
  105. package/dist/register-migration.js +268 -0
  106. package/dist/register-renumber.js +314 -0
  107. package/dist/register-transition-commands.js +248 -0
  108. package/dist/register-update.js +230 -0
  109. package/dist/register-views.js +256 -0
  110. package/dist/register.js +175 -1975
  111. package/dist/review-grade.js +252 -0
  112. package/dist/review-plan.js +114 -4
  113. package/dist/review-types.js +40 -1
  114. package/dist/routine-definition.js +401 -0
  115. package/dist/routine.js +73 -402
  116. package/dist/schedule-approach.js +2 -2
  117. package/dist/schedule-build.js +2 -2
  118. package/dist/schedule-strategy-generate-document.js +273 -0
  119. package/dist/schedule-strategy-generate-scope.js +199 -0
  120. package/dist/schedule-strategy-generate.js +9 -473
  121. package/dist/schedule.js +19 -6
  122. package/dist/specdojo-config.js +465 -20
  123. package/dist/specdojo-gitignore.js +135 -0
  124. package/dist/specdojo.js +6 -0
  125. package/dist/viewpoint-document-kinds-check.js +128 -0
  126. package/dist/yaml-pages.js +4 -4
  127. package/dist/yaml.js +28 -0
  128. package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +348 -90
  129. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +51 -17
  130. package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +7 -5
  131. package/docs/ja/specdojo/exec-templates/xrp-freeform-template.md +29 -31
  132. package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +34 -55
  133. package/docs/ja/specdojo/exec-templates/xrp-job-template.md +54 -0
  134. package/docs/ja/specdojo/exec-templates/xrp-recipe-guided-template.md +28 -37
  135. package/docs/ja/specdojo/exec-templates/xrp-recipe-maintenance-template.md +29 -34
  136. package/docs/ja/specdojo/exec-templates/xrp-retrofit-template.md +30 -30
  137. package/docs/ja/specdojo/exec-templates/xrp-rulebook-maintenance-template.md +29 -34
  138. package/docs/ja/specdojo/exec-templates/xrp-sample-maintenance-template.md +29 -34
  139. package/docs/ja/specdojo/exec-templates/xrp-template-maintenance-template.md +29 -34
  140. package/docs/ja/specdojo/exec-templates/xrp-template.md +29 -28
  141. package/docs/ja/specdojo/exec-templates/xrr-template.md +11 -9
  142. package/docs/ja/specdojo/guides/docs-editing-guide.md +20 -0
  143. package/docs/ja/specdojo/guides/docs-structure-guide.md +103 -70
  144. package/docs/ja/specdojo/guides/exec-config-guide.md +93 -49
  145. package/docs/ja/specdojo/guides/exec-operation-guide.md +124 -27
  146. package/docs/ja/specdojo/guides/exec-worktree-guide.md +40 -11
  147. package/docs/ja/specdojo/guides/kata-guide.md +4 -4
  148. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +45 -22
  149. package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +1 -1
  150. package/docs/ja/specdojo/guides/practice-system-composition-guide.md +13 -13
  151. package/docs/ja/specdojo/guides/quick-start-guide.md +260 -30
  152. package/docs/ja/specdojo/guides/register-operation-guide.md +31 -14
  153. package/docs/ja/specdojo/guides/release-v0-3-0-migration-guide.md +264 -0
  154. package/docs/ja/specdojo/guides/remote-host-development-guide.md +22 -1
  155. package/docs/ja/specdojo/guides/review-guide.md +195 -158
  156. package/docs/ja/specdojo/guides/routine-operation-guide.md +75 -10
  157. package/docs/ja/specdojo/guides/ryu-guide.md +32 -30
  158. package/docs/ja/specdojo/guides/schedule-design-guide.md +10 -10
  159. package/docs/ja/specdojo/guides/schedule-operation-guide.md +1 -1
  160. package/docs/ja/specdojo/guides/specdojo-overview-guide.md +58 -33
  161. package/docs/ja/specdojo/guides/use-case-guide.md +3 -3
  162. package/docs/ja/specdojo/guides/waza-guide.md +15 -2
  163. package/docs/ja/specdojo/index.md +2 -2
  164. package/docs/ja/specdojo/philosophy/specdojo-philosophy.md +5 -5
  165. package/docs/ja/specdojo/recipes/bps-recipe.md +213 -0
  166. package/docs/ja/specdojo/recipes/pm-members-recipe.md +52 -117
  167. package/docs/ja/specdojo/references/command-reference.md +335 -92
  168. package/docs/ja/specdojo/references/deliverables-reference.md +1 -1
  169. package/docs/ja/specdojo/references/directory-layout-reference.md +13 -9
  170. package/docs/ja/specdojo/references/specdojo-config-reference.md +107 -24
  171. package/docs/ja/specdojo/rulebooks/bps-rulebook.md +132 -220
  172. package/docs/ja/specdojo/rulebooks/br-rulebook.md +6 -44
  173. package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +2 -0
  174. package/docs/ja/specdojo/rulebooks/dmd-rulebook.md +0 -87
  175. package/docs/ja/specdojo/rulebooks/gl-rulebook.md +61 -39
  176. package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +0 -87
  177. package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +1 -33
  178. package/docs/ja/specdojo/rulebooks/opd-rulebook.md +0 -137
  179. package/docs/ja/specdojo/rulebooks/opr-rulebook.md +0 -247
  180. package/docs/ja/specdojo/rulebooks/otp-rulebook.md +0 -83
  181. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +4 -2
  182. package/docs/ja/specdojo/rulebooks/pm-members-rulebook.md +78 -150
  183. package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +5 -4
  184. package/docs/ja/specdojo/rulebooks/sch-rulebook.md +1 -1
  185. package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +0 -11
  186. package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +0 -61
  187. package/docs/ja/specdojo/rulebooks/tml-rulebook.md +2 -47
  188. package/docs/ja/specdojo/samples/bps-sample.md +74 -21
  189. package/docs/ja/specdojo/samples/gl-sample.yaml +17 -1
  190. package/docs/ja/specdojo/samples/ifx-index-sample.yaml +28 -0
  191. package/docs/ja/specdojo/samples/pm-members-sample.yaml +2 -67
  192. package/docs/ja/specdojo/samples/pm-organization-sample.md +8 -7
  193. package/docs/ja/specdojo/samples/pm-raci-sample.md +1 -1
  194. package/docs/ja/specdojo/samples/tml-sample.yaml +40 -0
  195. package/docs/ja/specdojo/standards/document-metadata-standard.md +21 -16
  196. package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +14 -14
  197. package/docs/ja/specdojo/standards/job-definition-standard.md +37 -17
  198. package/docs/ja/specdojo/standards/people-and-organization-definition-standard.md +37 -32
  199. package/docs/ja/specdojo/standards/philosophy-authoring-standard.md +1 -1
  200. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +21 -11
  201. package/docs/ja/specdojo/templates/agent-members-template.yaml +25 -0
  202. package/docs/ja/specdojo/templates/bps-template.md +91 -0
  203. package/docs/ja/specdojo/templates/pm-members-template.yaml +2 -59
  204. package/docs/specdojo/schemas/v1/agent-members.schema.yaml +76 -0
  205. package/docs/specdojo/schemas/v1/exec-common.schema.yaml +4 -2
  206. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +55 -2
  207. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +93 -6
  208. package/docs/specdojo/schemas/v1/exec-reporter-output.schema.yaml +27 -78
  209. package/docs/specdojo/schemas/v1/gl.schema.yaml +87 -0
  210. package/docs/specdojo/schemas/v1/grade-result.schema.yaml +33 -0
  211. package/docs/specdojo/schemas/v1/job-run.schema.yaml +27 -0
  212. package/docs/specdojo/schemas/v1/job.schema.yaml +25 -0
  213. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +49 -1
  214. package/docs/specdojo/schemas/v1/pm-members.schema.yaml +9 -169
  215. package/docs/specdojo/schemas/v1/pm-review-viewpoints.schema.yaml +100 -10
  216. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +13 -0
  217. package/docs/specdojo/schemas/v1/routine-run.schema.yaml +3 -0
  218. package/docs/specdojo/schemas/v1/routine.schema.yaml +7 -0
  219. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +110 -0
  220. package/package.json +17 -12
  221. package/templates/antigravity/README.md +29 -4
  222. package/templates/antigravity/{pm-members-snippet.yaml → agent-members-snippet.yaml} +8 -2
  223. package/templates/antigravity/exec-defaults-snippet.yaml +10 -7
  224. package/templates/antigravity/orchestrator.md +18 -7
  225. package/templates/antigravity/settings.global.json +55 -0
  226. package/templates/claude/agents/claude-executor.md +14 -0
  227. package/templates/claude/agents/claude-reporter.md +16 -0
  228. package/templates/claude/agents/specdojo-orchestrator.md +18 -7
  229. package/templates/claude/settings.edit.json +27 -1
  230. package/templates/codex/README.md +5 -4
  231. package/templates/codex/agents/specdojo-orchestrator.toml +18 -7
  232. package/templates/codex/orchestrator.md +18 -7
  233. package/templates/copilot/README.md +7 -5
  234. package/templates/copilot/{pm-members-snippet.yaml → agent-members-snippet.yaml} +4 -2
  235. package/templates/devcontainer/devcontainer.json +27 -0
  236. package/templates/devcontainer/emacs/init.el +88 -0
  237. package/templates/devcontainer/post-create.sh +62 -0
  238. package/templates/init-agent-members.yaml +200 -0
  239. package/templates/init-exec-defaults.yaml +74 -0
  240. package/templates/opencode/agents/specdojo-orchestrator.md +18 -7
  241. package/docs/ja/specdojo/exec-templates/xrp-viewpoint-detail-template.md +0 -7
  242. package/docs/ja/specdojo/exec-templates/xrr-viewpoint-detail-template.md +0 -7
@@ -0,0 +1,135 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { isAbsolute, join, posix } from "node:path";
3
+ export const GITIGNORE_HEADER = "# 依存と specdojo の生成物(specdojo config init が追記)";
4
+ export const NODE_MODULES_PATTERN = "node_modules/";
5
+ // このリポジトリの .gitignore と同じ既定の除外。docs/ 配下の配置はすべてこれで覆える。
6
+ // README の導入手順は npm install の直後に config init を実行するため、依存の node_modules/ も含める。
7
+ export const DEFAULT_GITIGNORE_PATTERNS = [
8
+ NODE_MODULES_PATTERN,
9
+ ".specdojo/doc-index.json",
10
+ "docs/**/generated/*",
11
+ "!docs/**/generated/.gitkeep",
12
+ "docs/**/execution/exec/.locks/",
13
+ ];
14
+ // repo-root 相対の posix パスへ正規化する。リポジトリ外(絶対パス・`..`)や root 自身は
15
+ // 除外対象にできないため undefined を返す。
16
+ function normalizeRepoPath(value) {
17
+ const trimmed = value?.trim();
18
+ if (!trimmed || isAbsolute(trimmed))
19
+ return undefined;
20
+ const normalized = posix.normalize(trimmed.replace(/\\/g, "/")).replace(/\/+$/, "");
21
+ if (normalized === "" || normalized === "." || normalized.startsWith(".."))
22
+ return undefined;
23
+ return normalized;
24
+ }
25
+ function isUnderDocs(path) {
26
+ return path === "docs" || path.startsWith("docs/");
27
+ }
28
+ function generatedPatternsFor(root) {
29
+ return [`${root}/**/generated/*`, `!${root}/**/generated/.gitkeep`];
30
+ }
31
+ /**
32
+ * Derive the .gitignore lines that keep specdojo build outputs untracked for the given layouts.
33
+ * Layouts under docs/ are covered by the defaults; other layouts add patterns derived from
34
+ * base_path, or from each configured path when base_path is absent.
35
+ */
36
+ export function gitignorePatternsForLayouts(layouts) {
37
+ const patterns = [...DEFAULT_GITIGNORE_PATTERNS];
38
+ const push = (line) => {
39
+ if (!patterns.includes(line))
40
+ patterns.push(line);
41
+ };
42
+ for (const layout of layouts) {
43
+ const base = normalizeRepoPath(layout.basePath);
44
+ const roots = base
45
+ ? [base]
46
+ : layout.projectPaths.flatMap((path) => normalizeRepoPath(path) ?? []);
47
+ for (const root of roots) {
48
+ if (isUnderDocs(root))
49
+ continue;
50
+ generatedPatternsFor(root).forEach(push);
51
+ }
52
+ const executionPath = normalizeRepoPath(layout.executionPath);
53
+ if (!executionPath)
54
+ continue;
55
+ const coveredByDefault = isUnderDocs(executionPath) && posix.basename(executionPath) === "execution";
56
+ if (!coveredByDefault)
57
+ push(`${executionPath}/exec/.locks/`);
58
+ }
59
+ return patterns;
60
+ }
61
+ // 既存の .gitignore で node_modules/ と同じ意味(root の node_modules を除外する)になる行。
62
+ const NODE_MODULES_EQUIVALENTS = [
63
+ "node_modules",
64
+ "node_modules/",
65
+ "/node_modules",
66
+ "/node_modules/",
67
+ "**/node_modules",
68
+ "**/node_modules/",
69
+ ];
70
+ function isAlreadyPresent(present, pattern) {
71
+ if (present.has(pattern))
72
+ return true;
73
+ if (pattern !== NODE_MODULES_PATTERN)
74
+ return false;
75
+ return NODE_MODULES_EQUIVALENTS.some((line) => present.has(line));
76
+ }
77
+ /**
78
+ * Append the missing patterns to existing .gitignore content. Existing lines are never removed
79
+ * or reordered, and the file's line ending (LF / CRLF) is preserved.
80
+ */
81
+ export function mergeGitignore(existing, patterns) {
82
+ const present = new Set(existing.split(/\r?\n/).map((line) => line.trim()));
83
+ const added = [];
84
+ const skipped = [];
85
+ for (const pattern of patterns) {
86
+ if (isAlreadyPresent(present, pattern) || added.includes(pattern)) {
87
+ if (!skipped.includes(pattern))
88
+ skipped.push(pattern);
89
+ continue;
90
+ }
91
+ added.push(pattern);
92
+ }
93
+ if (added.length === 0)
94
+ return { content: existing, added, skipped };
95
+ const eol = existing.includes("\r\n") ? "\r\n" : "\n";
96
+ let content = existing;
97
+ if (content.length > 0 && !content.endsWith("\n"))
98
+ content += eol;
99
+ if (content.length > 0)
100
+ content += eol;
101
+ content += [GITIGNORE_HEADER, ...added].join(eol) + eol;
102
+ return { content, added, skipped };
103
+ }
104
+ /** Read `<repoRoot>/.gitignore`, append the missing patterns and write it back unless dryRun. */
105
+ export function ensureGitignore(repoRoot, patterns, options) {
106
+ const gitignorePath = join(repoRoot, ".gitignore");
107
+ const created = !existsSync(gitignorePath);
108
+ const existing = created ? "" : readFileSync(gitignorePath, "utf8");
109
+ const merged = mergeGitignore(existing, patterns);
110
+ const shouldWrite = !options.dryRun && merged.added.length > 0;
111
+ if (shouldWrite)
112
+ writeFileSync(gitignorePath, merged.content, "utf8");
113
+ return { ...merged, gitignorePath, created, written: shouldWrite };
114
+ }
115
+ export const UNTRACK_IGNORED_COMMAND = "git ls-files -ci --exclude-standard -z | xargs -0 -r git rm -r --cached --quiet";
116
+ /** Human-readable report of an ensureGitignore run, including the untrack guidance. */
117
+ export function formatGitignoreReport(result, dryRun) {
118
+ const lines = [];
119
+ const addVerb = dryRun ? "Would add" : "Added";
120
+ if (result.added.length === 0) {
121
+ lines.push(`.gitignore already excludes node_modules/ and specdojo outputs:${result.gitignorePath}`);
122
+ }
123
+ else {
124
+ const action = result.created ? (dryRun ? "Would create" : "Created") : "Updated";
125
+ lines.push(`${dryRun ? `${action} (dry-run)` : action}: ${result.gitignorePath}`);
126
+ for (const line of result.added)
127
+ lines.push(` ${addVerb}: ${line}`);
128
+ }
129
+ for (const line of result.skipped)
130
+ lines.push(` Skipped (already present): ${line}`);
131
+ if (result.added.length > 0) {
132
+ lines.push("If node_modules/ or specdojo outputs are already tracked by git, untrack them once and commit:", ` ${UNTRACK_IGNORED_COMMAND}`);
133
+ }
134
+ return lines.join("\n") + "\n";
135
+ }
package/dist/specdojo.js CHANGED
@@ -20,6 +20,9 @@ import { registerDashboardCommands } from "./dashboard.js";
20
20
  import { registerGradeCommand } from "./grade.js";
21
21
  import { registerAgentCommands } from "./agent.js";
22
22
  import { registerKataCommands } from "./kata-command.js";
23
+ import { registerDevcontainerCommands } from "./devcontainer-command.js";
24
+ import { registerInitCommand } from "./init-command.js";
25
+ import { registerOrchestratorCommands } from "./orchestrator.js";
23
26
  /**
24
27
  * bin は dist/specdojo.js を指すため、開発チェックアウトで `npm run build` を忘れると
25
28
  * 古い挙動のまま実行される。src が dist より新しい場合は警告し、exec 系は中断する。
@@ -39,6 +42,7 @@ async function main() {
39
42
  }
40
43
  const program = new Command();
41
44
  program.name("specdojo").description("SpecDojo helper CLI").version(specdojoPackageVersion());
45
+ registerInitCommand(program);
42
46
  registerConfigCommands(program);
43
47
  registerProjectCommands(program);
44
48
  registerExecCommands(program);
@@ -57,6 +61,8 @@ async function main() {
57
61
  registerGradeCommand(program);
58
62
  registerAgentCommands(program);
59
63
  registerKataCommands(program);
64
+ registerDevcontainerCommands(program);
65
+ registerOrchestratorCommands(program);
60
66
  await program.parseAsync(process.argv);
61
67
  }
62
68
  void main();
@@ -0,0 +1,128 @@
1
+ import { readdirSync, readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { load } from "./yaml.js";
5
+ // PJR-H220 / PJR-VJP8: 観点の document_kinds は rulebook ID の列挙で宣言する。rulebook を
6
+ // 追加したときに観点ごとの扱いの判断が漏れないよう、include / exclude / confirmed_default の
7
+ // どれにも載っていない rulebook を一覧にする。confirmed_default は判断の記録であり、適用判定
8
+ // (review-plan.ts の viewpointAppliesToDocument)には影響しない。
9
+ export const DEFAULT_VIEWPOINTS_PATH = "docs/ja/specdojo/defaults/pm-review-viewpoints.yaml";
10
+ export const DEFAULT_RULEBOOK_DIR = "docs/ja/specdojo/rulebooks";
11
+ const DECISION_FIELDS = ["include", "exclude", "confirmed_default"];
12
+ function isRecord(value) {
13
+ return typeof value === "object" && value !== null && !Array.isArray(value);
14
+ }
15
+ function stringList(value) {
16
+ return Array.isArray(value)
17
+ ? value.filter((item) => typeof item === "string")
18
+ : [];
19
+ }
20
+ function rulebookIdFromMarkdown(markdown, filePath) {
21
+ const match = markdown.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
22
+ if (!match)
23
+ return undefined;
24
+ let parsed;
25
+ try {
26
+ parsed = load(match[1]);
27
+ }
28
+ catch (error) {
29
+ throw new Error(`Invalid rulebook frontmatter: ${filePath}`, { cause: error });
30
+ }
31
+ const specdojo = isRecord(parsed) && isRecord(parsed["specdojo"]) ? parsed["specdojo"] : {};
32
+ const id = specdojo["id"];
33
+ if (specdojo["type"] !== "rulebook" || typeof id !== "string" || !id.trim())
34
+ return undefined;
35
+ return id;
36
+ }
37
+ /** Collect rulebook IDs from `*-rulebook.md` frontmatter, sorted for stable output. */
38
+ export function collectRulebookIds(rulebookDir = DEFAULT_RULEBOOK_DIR) {
39
+ const ids = readdirSync(rulebookDir)
40
+ .filter((name) => name.endsWith("-rulebook.md"))
41
+ .flatMap((name) => {
42
+ const filePath = path.join(rulebookDir, name);
43
+ const id = rulebookIdFromMarkdown(readFileSync(filePath, "utf8"), filePath);
44
+ return id ? [id] : [];
45
+ });
46
+ return [...new Set(ids)].sort((left, right) => left.localeCompare(right));
47
+ }
48
+ /**
49
+ * A viewpoint that enumerates rulebook IDs in `document_kinds` must decide every rulebook:
50
+ * list it in include / exclude, or record in confirmed_default that the unlisted outcome
51
+ * was reviewed. Viewpoints without any of those lists apply to every kind and are skipped.
52
+ */
53
+ export function lintViewpointDocumentKinds(viewpointsDoc, rulebookIds) {
54
+ const viewpoints = isRecord(viewpointsDoc) && Array.isArray(viewpointsDoc["viewpoints"])
55
+ ? viewpointsDoc["viewpoints"]
56
+ : [];
57
+ const known = new Set(rulebookIds);
58
+ const findings = [];
59
+ for (const viewpoint of viewpoints) {
60
+ if (!isRecord(viewpoint) || typeof viewpoint["id"] !== "string")
61
+ continue;
62
+ const declaration = viewpoint["document_kinds"];
63
+ if (!isRecord(declaration))
64
+ continue;
65
+ if (!DECISION_FIELDS.some((field) => declaration[field] !== undefined))
66
+ continue;
67
+ const viewpointId = viewpoint["id"];
68
+ const decided = new Map();
69
+ for (const field of DECISION_FIELDS) {
70
+ for (const rulebookId of stringList(declaration[field])) {
71
+ decided.set(rulebookId, [...(decided.get(rulebookId) ?? []), field]);
72
+ if (!known.has(rulebookId)) {
73
+ findings.push({ kind: "unknown-rulebook", viewpointId, field, rulebookId });
74
+ }
75
+ }
76
+ }
77
+ for (const [rulebookId, fields] of decided) {
78
+ if (fields.length > 1)
79
+ findings.push({ kind: "duplicate", viewpointId, rulebookId, fields });
80
+ }
81
+ for (const rulebookId of rulebookIds) {
82
+ if (!decided.has(rulebookId))
83
+ findings.push({ kind: "undecided", viewpointId, rulebookId });
84
+ }
85
+ }
86
+ return findings;
87
+ }
88
+ export function formatViewpointDocumentKindsFinding(finding) {
89
+ switch (finding.kind) {
90
+ case "undecided":
91
+ return `${finding.viewpointId}: ${finding.rulebookId} is not decided (add it to document_kinds.include / exclude, or to confirmed_default to keep the default)`;
92
+ case "unknown-rulebook":
93
+ return `${finding.viewpointId}: document_kinds.${finding.field} lists unknown rulebook ${finding.rulebookId}`;
94
+ case "duplicate":
95
+ return `${finding.viewpointId}: ${finding.rulebookId} is listed in more than one of document_kinds.${finding.fields.join(" / ")}`;
96
+ }
97
+ }
98
+ /** Returns error lines; an empty array means every enumerating viewpoint is fully decided. */
99
+ export function checkViewpointDocumentKinds(viewpointsPath = DEFAULT_VIEWPOINTS_PATH, rulebookDir = DEFAULT_RULEBOOK_DIR) {
100
+ const rulebookIds = collectRulebookIds(rulebookDir);
101
+ if (rulebookIds.length === 0) {
102
+ return { rulebookCount: 0, errors: [`No rulebooks found: ${rulebookDir}`] };
103
+ }
104
+ const doc = load(readFileSync(viewpointsPath, "utf8"));
105
+ const errors = lintViewpointDocumentKinds(doc, rulebookIds).map(formatViewpointDocumentKindsFinding);
106
+ return { rulebookCount: rulebookIds.length, errors };
107
+ }
108
+ function main() {
109
+ const { rulebookCount, errors } = checkViewpointDocumentKinds();
110
+ if (errors.length === 0) {
111
+ process.stdout.write(`${DEFAULT_VIEWPOINTS_PATH}: document_kinds decisions cover all ${rulebookCount} rulebooks\n`);
112
+ return;
113
+ }
114
+ process.stderr.write(`${DEFAULT_VIEWPOINTS_PATH}: document_kinds decisions are incomplete\n`);
115
+ for (const line of errors)
116
+ process.stderr.write(` - ${line}\n`);
117
+ process.exitCode = 1;
118
+ }
119
+ const invokedPath = process.argv[1];
120
+ if (invokedPath && path.resolve(invokedPath) === fileURLToPath(import.meta.url)) {
121
+ try {
122
+ main();
123
+ }
124
+ catch (error) {
125
+ process.stderr.write(`viewpoint document_kinds check failed: ${error instanceof Error ? error.message : String(error)}\n`);
126
+ process.exitCode = 1;
127
+ }
128
+ }
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join, posix } from "node:path";
3
- import yaml from "js-yaml";
3
+ import { dump, load } from "./yaml.js";
4
4
  import { collectDocIndexEntries } from "./doc-index.js";
5
5
  import { isDctTemplateCatalog, renderCatalogTemplateBody } from "./catalog-build.js";
6
6
  // YAML は VitePress のページにならないため、doc-index に載っている YAML ごとに
@@ -50,7 +50,7 @@ export function yamlPageRelPath(yamlRelPath) {
50
50
  function deriveMeta(yamlRelPath, content) {
51
51
  let parsed;
52
52
  try {
53
- parsed = yaml.load(content);
53
+ parsed = load(content);
54
54
  }
55
55
  catch {
56
56
  parsed = undefined;
@@ -89,7 +89,7 @@ function deriveMeta(yamlRelPath, content) {
89
89
  // 本文中のバッククォート連続より長いフェンスを使って壊れないようにする。
90
90
  export function renderYamlPage(yamlRelPath, content) {
91
91
  const { title, ...meta } = deriveMeta(yamlRelPath, content);
92
- const frontmatter = yaml.dump({ specdojo: meta }, { lineWidth: -1 }).trimEnd();
92
+ const frontmatter = dump({ specdojo: meta }, { lineWidth: -1 }).trimEnd();
93
93
  const fileName = posix.basename(yamlRelPath);
94
94
  const heading = title ?? fileName;
95
95
  const note = `> このページは \`${yamlRelPath}\` から生成された表示用ページです。正本は YAML ファイルであり、このページは再生成できます。`;
@@ -97,7 +97,7 @@ export function renderYamlPage(yamlRelPath, content) {
97
97
  // インスタンス(catalog build)と同じ表形式で本文を描画する。
98
98
  let parsed;
99
99
  try {
100
- parsed = yaml.load(content);
100
+ parsed = load(content);
101
101
  }
102
102
  catch {
103
103
  parsed = undefined;
package/dist/yaml.js ADDED
@@ -0,0 +1,28 @@
1
+ import { createRequire } from "node:module";
2
+ import { dump as dumpWithJsYaml, load as loadWithJsYaml, } from "js-yaml";
3
+ const require = createRequire(import.meta.url);
4
+ const jsYamlSchemas = require("js-yaml");
5
+ const legacyLoadSchema = (jsYamlSchemas.YAML11_SCHEMA ??
6
+ jsYamlSchemas.DEFAULT_SCHEMA);
7
+ const usesV5Api = jsYamlSchemas.YAML11_SCHEMA !== undefined;
8
+ if (legacyLoadSchema === undefined) {
9
+ throw new Error("js-yaml does not expose a YAML 1.1-compatible schema");
10
+ }
11
+ /** Load YAML with the scalar and merge-key behavior used by js-yaml 4. */
12
+ export function load(source, options = {}) {
13
+ return loadWithJsYaml(source, { ...options, schema: options.schema ?? legacyLoadSchema });
14
+ }
15
+ /** Dump YAML using the v5 option name while remaining runnable before the dependency handoff. */
16
+ export function dump(input, options = {}) {
17
+ const normalized = { ...options };
18
+ const quoteStyle = normalized.quoteStyle;
19
+ delete normalized.quoteStyle;
20
+ if (quoteStyle !== undefined) {
21
+ normalized[usesV5Api ? "quoteStyle" : "quotingType"] = usesV5Api
22
+ ? quoteStyle
23
+ : quoteStyle === "single"
24
+ ? "'"
25
+ : '"';
26
+ }
27
+ return dumpWithJsYaml(input, normalized);
28
+ }