specdojo 0.3.0 → 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 (104) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/catalog-build-references.js +144 -0
  3. package/dist/catalog-build-render.js +144 -0
  4. package/dist/catalog-build.js +13 -290
  5. package/dist/catalog-generate.js +6 -9
  6. package/dist/catalog-plan-generate.js +2 -2
  7. package/dist/catalog-plan.js +6 -6
  8. package/dist/catalog-scaffold.js +4 -4
  9. package/dist/catalog.js +2 -2
  10. package/dist/dashboard-exec-records.js +105 -0
  11. package/dist/dashboard-routines.js +255 -0
  12. package/dist/dashboard-shared.js +14 -0
  13. package/dist/dashboard-timeline.js +175 -0
  14. package/dist/dashboard.js +10 -544
  15. package/dist/deliverable-trash.js +3 -3
  16. package/dist/doc-index.js +3 -3
  17. package/dist/exec-commands.js +557 -0
  18. package/dist/exec-core.js +457 -0
  19. package/dist/exec-plans-core.js +693 -0
  20. package/dist/exec-plans-generation.js +206 -0
  21. package/dist/exec-plans-storage.js +131 -0
  22. package/dist/exec-plans.js +3 -1018
  23. package/dist/exec-repo-integration-git.js +23 -0
  24. package/dist/exec-repo-integration-sync.js +264 -0
  25. package/dist/exec-repo-integration.js +4 -281
  26. package/dist/exec-reporter-output.js +206 -0
  27. package/dist/exec-reporter.js +2 -206
  28. package/dist/exec-results.js +22 -15
  29. package/dist/exec-run-agent-pipeline.js +256 -0
  30. package/dist/exec-run-agent.js +531 -0
  31. package/dist/exec-run-in-place.js +541 -0
  32. package/dist/exec-run-job.js +717 -0
  33. package/dist/exec-run-lifecycle-commands.js +522 -0
  34. package/dist/exec-run-mode-shared.js +140 -0
  35. package/dist/exec-run-register-command.js +244 -0
  36. package/dist/exec-run-register-core.js +386 -0
  37. package/dist/exec-run-register-mode.js +206 -0
  38. package/dist/exec-run-register-resume.js +393 -0
  39. package/dist/exec-run-register-state.js +322 -0
  40. package/dist/exec-run-register-worktree.js +509 -0
  41. package/dist/exec-run-schedule-mode.js +294 -0
  42. package/dist/exec-run-schedule-prepare.js +353 -0
  43. package/dist/exec-run-schedule-task.js +572 -0
  44. package/dist/exec-run-shared.js +399 -0
  45. package/dist/exec-run.js +11 -6182
  46. package/dist/exec-shared.js +2 -2
  47. package/dist/exec-trial-commands.js +558 -0
  48. package/dist/exec-trial-core.js +371 -0
  49. package/dist/exec-trial.js +2 -921
  50. package/dist/exec-worktree-ops-commit.js +707 -0
  51. package/dist/exec-worktree-ops-lifecycle.js +292 -0
  52. package/dist/exec-worktree-ops-merge.js +303 -0
  53. package/dist/exec-worktree-ops.js +3 -1292
  54. package/dist/exec-worktree.js +32 -4
  55. package/dist/exec.js +2 -1006
  56. package/dist/frontmatter-namespace.js +2 -2
  57. package/dist/grade-apply.js +734 -0
  58. package/dist/grade-command-apply.js +250 -0
  59. package/dist/grade-command-inspect.js +138 -0
  60. package/dist/grade-command-plan.js +101 -0
  61. package/dist/grade-command-shared.js +68 -0
  62. package/dist/grade-core.js +307 -0
  63. package/dist/grade-markdown.js +274 -0
  64. package/dist/grade-pipeline-state.js +184 -0
  65. package/dist/grade-plan.js +507 -0
  66. package/dist/grade-result.js +5 -5
  67. package/dist/grade-target-discovery.js +265 -0
  68. package/dist/grade-targets.js +432 -0
  69. package/dist/grade.js +14 -3188
  70. package/dist/init-command.js +7 -7
  71. package/dist/job-definition.js +670 -0
  72. package/dist/job.js +9 -673
  73. package/dist/kata-command.js +2 -2
  74. package/dist/register-command-types.js +1 -0
  75. package/dist/register-core.js +363 -0
  76. package/dist/register-create-commands.js +245 -0
  77. package/dist/register-events.js +4 -4
  78. package/dist/register-item.js +6 -6
  79. package/dist/register-maintenance-commands.js +187 -0
  80. package/dist/register-migration.js +268 -0
  81. package/dist/register-renumber.js +314 -0
  82. package/dist/register-transition-commands.js +248 -0
  83. package/dist/register-update.js +230 -0
  84. package/dist/register-views.js +256 -0
  85. package/dist/register.js +61 -2069
  86. package/dist/review-plan.js +3 -3
  87. package/dist/routine-definition.js +401 -0
  88. package/dist/routine.js +6 -402
  89. package/dist/schedule-approach.js +2 -2
  90. package/dist/schedule-strategy-generate-document.js +273 -0
  91. package/dist/schedule-strategy-generate-scope.js +199 -0
  92. package/dist/schedule-strategy-generate.js +9 -473
  93. package/dist/schedule.js +4 -4
  94. package/dist/specdojo-config.js +3 -4
  95. package/dist/viewpoint-document-kinds-check.js +3 -3
  96. package/dist/yaml-pages.js +4 -4
  97. package/dist/yaml.js +28 -0
  98. package/docs/ja/specdojo/guides/exec-config-guide.md +6 -6
  99. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +20 -18
  100. package/docs/ja/specdojo/guides/routine-operation-guide.md +1 -1
  101. package/package.json +4 -5
  102. package/templates/antigravity/README.md +3 -3
  103. package/templates/antigravity/exec-defaults-snippet.yaml +6 -4
  104. package/templates/init-exec-defaults.yaml +3 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  SpecDojo の利用者に影響する変更を記録します。
4
4
 
5
+ ## [0.3.1] - 2026-10-16
6
+
7
+ 同梱パッケージの `@specdojo/docs-lint` と `@specdojo/docs-site` は、この版では公開しません(docs-lint の js-yaml の更新は次の docs-lint の版で公開します)。
8
+
9
+ ### 不具合修正
10
+
11
+ - `specdojo init` と Antigravity 向け配布雛形・ガイドが、agy 1.3.5 で提供されないモデル ID を指定し、expert agent が `invalid model selection` で起動できない問題を修正しました。利用可能な ID は `agy models` で確認できます(PJR-X60A)。
12
+ - exec の result の frontmatter で、改行を含む `block_reason` が字下げされずに書かれ、YAML として不正になる問題を修正しました。値は YAML として正しく引用して書きます(PJR-TMAW)。
13
+ - 未追跡のファイルが多い作業場所で、`register --commit` などが原因の分からない `git status failed` で止まる問題を修正しました。git の出力を 1 MiB を超えても受け取り、出力の上限超過や signal による失敗はエラーのメッセージに原因を含めます(PJR-RY4C)。
14
+
15
+ ### 依存関係
16
+
17
+ - SpecDojo 本体の js-yaml を 5.4.3 へ更新しました。既存文書との互換性のため、引用符なしの日付と merge key は 4 系と同じ規則で読み込みます(PJR-RCVS)。
18
+
19
+ ### 内部の変更
20
+
21
+ - 大きくなったソースファイル(`exec-run.ts`・`grade.ts`・`register.ts` など)を責務ごとのモジュールへ分けました。CLI の動作と出力は変わりません(PJR-QCMP・PJR-K6KB・PJR-3W2N・PJR-2JFM・PJR-GBPX・PJR-Y8P9)。
22
+
5
23
  ## [0.3.0] - 2026-10-14
6
24
 
7
25
  同梱パッケージは `@specdojo/docs-lint` 0.2.0 と `@specdojo/docs-site` 0.2.1 を同時に公開します。docs-lint は 0.1.0 以降の変更(下記の lint の追加、依存の更新、脆弱性の修正)を含みます。docs-site 0.2.1 は、先に公開した 0.2.0 の導入時の不具合 2 件(下記の不具合修正の PJR-EA20・PJR-CA0S)を直した版です。
@@ -0,0 +1,144 @@
1
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { load } from "./yaml.js";
4
+ import { resolveBasePath, resolveDeliverablePath } from "./catalog-paths.js";
5
+ import { isDctCatalogFileName } from "./catalog-types.js";
6
+ import { readSpecdojoNamespace } from "./frontmatter-namespace.js";
7
+ // Walk all deliverables, resolving each one's document path using the
8
+ // leading-slash base_path convention (same rules as renderSections / dct build).
9
+ export function collectResolvedDeliverables(sections, parentBase, out) {
10
+ for (const section of sections) {
11
+ const sectionBase = resolveBasePath(parentBase, section.base_path);
12
+ for (const item of section.deliverables ?? []) {
13
+ out.push({ item, resolvedPath: resolveDeliverablePath(sectionBase, item.path) });
14
+ }
15
+ if (section.groups)
16
+ collectResolvedDeliverables(section.groups, sectionBase, out);
17
+ }
18
+ }
19
+ // Builds the project-global graph across all dct-*.yaml in the catalog directory.
20
+ // depends_on references are same-project local_ids, so they resolve to
21
+ // `<project_id>:<dep>`; this lets the graph span multiple catalog files.
22
+ function buildCatalogGraph(catalogPath) {
23
+ const nodes = new Map();
24
+ const files = readdirSync(catalogPath).filter(isDctCatalogFileName).sort();
25
+ for (const f of files) {
26
+ const filePath = join(catalogPath, f);
27
+ let doc;
28
+ try {
29
+ doc = load(readFileSync(filePath, "utf8"));
30
+ }
31
+ catch {
32
+ continue;
33
+ }
34
+ if (!doc || !Array.isArray(doc.groups) || !doc.project_id)
35
+ continue;
36
+ const projectId = doc.project_id;
37
+ const deliverables = [];
38
+ collectResolvedDeliverables(doc.groups, resolveBasePath("", doc.base_path), deliverables);
39
+ for (const { item, resolvedPath } of deliverables) {
40
+ const fullId = `${projectId}:${item.local_id}`;
41
+ nodes.set(fullId, {
42
+ fullId,
43
+ projectId,
44
+ localId: item.local_id,
45
+ kind: item.kind,
46
+ dependsOn: (item.depends_on ?? []).map((dep) => `${projectId}:${dep}`),
47
+ filePath,
48
+ resolvedDocPath: item.path ? resolvedPath : undefined,
49
+ });
50
+ }
51
+ }
52
+ return nodes;
53
+ }
54
+ // Transitive closure of a node's depends_on edges over the project-global graph.
55
+ function transitiveDependsOn(startId, nodes) {
56
+ const seen = new Set();
57
+ const stack = [...(nodes.get(startId)?.dependsOn ?? [])];
58
+ while (stack.length > 0) {
59
+ const current = stack.pop();
60
+ if (current === undefined || seen.has(current))
61
+ continue;
62
+ seen.add(current);
63
+ for (const dep of nodes.get(current)?.dependsOn ?? []) {
64
+ if (!seen.has(dep))
65
+ stack.push(dep);
66
+ }
67
+ }
68
+ return seen;
69
+ }
70
+ // Resolves a based_on reference per specdojo:id-and-file-naming-standard §5.2.
71
+ // Bare references resolve to the same project first, then to a global/product id.
72
+ function resolveReference(ref, projectId, nodes, knownIds) {
73
+ if (ref.includes(":")) {
74
+ if (nodes.has(ref)) {
75
+ return ref.startsWith(`${projectId}:`)
76
+ ? { kind: "catalog", fullId: ref }
77
+ : { kind: "external" };
78
+ }
79
+ return knownIds.has(ref) ? { kind: "external" } : { kind: "unresolved" };
80
+ }
81
+ const sameProjectId = `${projectId}:${ref}`;
82
+ if (nodes.has(sameProjectId))
83
+ return { kind: "catalog", fullId: sameProjectId };
84
+ if (knownIds.has(sameProjectId))
85
+ return { kind: "external" }; // same project, not a catalog deliverable
86
+ if (knownIds.has(ref))
87
+ return { kind: "external" }; // global / product doc
88
+ return { kind: "unresolved" };
89
+ }
90
+ // Reads the based_on list from a deliverable document's frontmatter.
91
+ // Returns null when the document file does not exist.
92
+ function readBasedOn(docFsPath) {
93
+ if (!existsSync(docFsPath))
94
+ return null;
95
+ const content = readFileSync(docFsPath, "utf8");
96
+ // based_on は Markdown frontmatter の `specdojo:` 名前空間配下にある。
97
+ const based = readSpecdojoNamespace(content).based_on;
98
+ if (!Array.isArray(based))
99
+ return [];
100
+ return based.filter((value) => typeof value === "string");
101
+ }
102
+ // Validates the invariant: every same-project catalog deliverable referenced in
103
+ // a document's based_on must lie within that deliverable's transitive depends_on
104
+ // closure (project-global). A basis document must be produced before the document
105
+ // based on it, so it has to be a (transitive) prerequisite in the WBS.
106
+ //
107
+ // References are resolved per specdojo:id-and-file-naming-standard §5.2:
108
+ // - bare refs resolve to the same project first, then to a global/product id;
109
+ // - `<project_id>:<local_id>` and other-project refs use the explicit id.
110
+ // `knownIds` is the universe of valid document ids (from the doc index); a
111
+ // reference that resolves to neither a catalog deliverable nor a known id is
112
+ // reported as an error (typo detection / resolve-or-error).
113
+ export function validateBasedOn(catalogPath, rootDir, knownIds) {
114
+ const errors = [];
115
+ const warnings = [];
116
+ const nodes = buildCatalogGraph(catalogPath);
117
+ for (const node of nodes.values()) {
118
+ if (node.kind !== "work" || !node.resolvedDocPath)
119
+ continue;
120
+ const basedOn = readBasedOn(join(rootDir, node.resolvedDocPath));
121
+ if (basedOn === null) {
122
+ warnings.push(`${node.filePath}: ${node.localId}: based_on を検証する文書が見つかりません (${node.resolvedDocPath})`);
123
+ continue;
124
+ }
125
+ const closure = transitiveDependsOn(node.fullId, nodes);
126
+ for (const ref of basedOn) {
127
+ const resolution = resolveReference(ref, node.projectId, nodes, knownIds);
128
+ if (resolution.kind === "unresolved") {
129
+ errors.push(`${node.filePath}: ${node.localId}: based_on '${ref}' を解決できません(プロジェクト内 deliverable にもグローバル ID にも一致しません)`);
130
+ continue;
131
+ }
132
+ if (resolution.kind === "external")
133
+ continue; // 他プロジェクト/グローバル参照は閉包検査の対象外
134
+ if (resolution.fullId === node.fullId) {
135
+ errors.push(`${node.filePath}: ${node.localId}: based_on が自分自身を参照しています`);
136
+ continue;
137
+ }
138
+ if (!closure.has(resolution.fullId)) {
139
+ errors.push(`${node.filePath}: ${node.localId}: based_on '${ref}' (${resolution.fullId}) が depends_on の推移閉包に含まれていません(根拠ドキュメントは先行成果物である必要があります)`);
140
+ }
141
+ }
142
+ }
143
+ return { ok: errors.length === 0, errors, warnings };
144
+ }
@@ -0,0 +1,144 @@
1
+ import { resolveBasePath } from "./catalog-paths.js";
2
+ import { buildSpecdojoFrontmatter } from "./frontmatter-namespace.js";
3
+ function formatDependsOn(deps) {
4
+ if (!deps || deps.length === 0)
5
+ return "-";
6
+ return deps.map((d) => `\`${d}\``).join(", ");
7
+ }
8
+ function renderTable(deliverables) {
9
+ const lines = ["<!-- prettier-ignore -->"];
10
+ const hasInstanceIdPattern = deliverables.some((item) => item.instance_id_pattern);
11
+ if (hasInstanceIdPattern) {
12
+ lines.push("| local-id | 実体IDパターン | 成果物名 | 種別 | 根拠 | 概要 |");
13
+ lines.push("| --- | --- | --- | --- | --- | --- |");
14
+ }
15
+ else {
16
+ lines.push("| local-id | 成果物名 | 種別 | 根拠 | 概要 |");
17
+ lines.push("| --- | --- | --- | --- | --- |");
18
+ }
19
+ for (const item of deliverables) {
20
+ const localId = `\`${item.local_id}\``;
21
+ const deps = formatDependsOn(item.depends_on);
22
+ if (hasInstanceIdPattern) {
23
+ const instanceIdPattern = item.instance_id_pattern ? `\`${item.instance_id_pattern}\`` : "-";
24
+ lines.push(`| ${localId} | ${instanceIdPattern} | ${item.name} | ${item.kind} | ${deps} | ${item.overview} |`);
25
+ }
26
+ else {
27
+ lines.push(`| ${localId} | ${item.name} | ${item.kind} | ${deps} | ${item.overview} |`);
28
+ }
29
+ }
30
+ return lines;
31
+ }
32
+ function renderDoneCriteria(deliverables) {
33
+ const lines = [];
34
+ for (const item of deliverables) {
35
+ if (item.kind !== "work" || !item.done_criteria || item.done_criteria.length === 0)
36
+ continue;
37
+ lines.push("");
38
+ lines.push(`**\`${item.local_id}\`** の完了条件:`);
39
+ lines.push("");
40
+ for (const criterion of item.done_criteria) {
41
+ lines.push(`- ${criterion.text}`);
42
+ }
43
+ }
44
+ return lines;
45
+ }
46
+ function renderSections(sections, parentBase, depth, prefix) {
47
+ const lines = [];
48
+ const hashes = "#".repeat(depth + 1);
49
+ let counter = 0;
50
+ for (const section of sections) {
51
+ const sectionBase = resolveBasePath(parentBase, section.base_path);
52
+ if (!section.name) {
53
+ // Unnamed section: output content without heading
54
+ if (section.base_path) {
55
+ lines.push("");
56
+ lines.push(`- 配置先: \`${sectionBase}\``);
57
+ }
58
+ if (section.note) {
59
+ lines.push("");
60
+ lines.push(section.note);
61
+ }
62
+ if (section.deliverables && section.deliverables.length > 0) {
63
+ lines.push("");
64
+ lines.push(...renderTable(section.deliverables));
65
+ lines.push(...renderDoneCriteria(section.deliverables));
66
+ }
67
+ if (section.groups && section.groups.length > 0) {
68
+ lines.push(...renderSections(section.groups, sectionBase, depth, prefix));
69
+ }
70
+ continue;
71
+ }
72
+ counter++;
73
+ const nums = [...prefix, counter];
74
+ const numStr = nums.join(".");
75
+ lines.push("");
76
+ lines.push(`${hashes} ${numStr}. ${section.name}`);
77
+ if (section.base_path) {
78
+ lines.push("");
79
+ lines.push(`- 配置先: \`${sectionBase}\``);
80
+ }
81
+ if (section.note) {
82
+ lines.push("");
83
+ lines.push(section.note);
84
+ }
85
+ if (section.deliverables && section.deliverables.length > 0) {
86
+ lines.push("");
87
+ lines.push(...renderTable(section.deliverables));
88
+ lines.push(...renderDoneCriteria(section.deliverables));
89
+ }
90
+ if (section.groups && section.groups.length > 0) {
91
+ lines.push(...renderSections(section.groups, sectionBase, depth + 1, nums));
92
+ }
93
+ }
94
+ return lines;
95
+ }
96
+ function buildFrontmatter(doc) {
97
+ const inner = [];
98
+ inner.push(`id: ${doc.id}`);
99
+ inner.push(`type: ${doc.type}`);
100
+ inner.push(`status: ${doc.status}`);
101
+ if (doc.part_of && doc.part_of.length > 0) {
102
+ inner.push("part_of:");
103
+ for (const p of doc.part_of) {
104
+ const val = p.includes(":") ? `'${p}'` : p;
105
+ inner.push(` - ${val}`);
106
+ }
107
+ }
108
+ inner.push("rulebook: specdojo:dct-rulebook");
109
+ return buildSpecdojoFrontmatter(inner).split("\n");
110
+ }
111
+ export function isRecord(value) {
112
+ return typeof value === "object" && value !== null && !Array.isArray(value);
113
+ }
114
+ // dct 成果物カタログのテンプレート(type: template)YAML かを判定する。
115
+ // テンプレートはインスタンス(type: project)と違い project_id を持たず local_id に
116
+ // プレースホルダを含むため、validateDctDoc/buildMarkdown は適用できない。yaml-pages の
117
+ // 表示ページで、YAML 丸写しのコードブロックではなく可読な表形式で描画するために使う。
118
+ export function isDctTemplateCatalog(yamlRelPath, parsed) {
119
+ if (!/\/templates\/dct-.+-template\.ya?ml$/.test(yamlRelPath))
120
+ return false;
121
+ if (!isRecord(parsed))
122
+ return false;
123
+ return (parsed.type === "template" && typeof parsed.domain === "string" && Array.isArray(parsed.groups));
124
+ }
125
+ // dct テンプレートの本文(成果物表+完了条件)を描画する。frontmatter・H1・注記は
126
+ // 呼び出し側(yaml-pages 表示ページ)が付与するため、ここでは本文セクションのみ返す。
127
+ // インスタンス(buildMarkdown)と同じ renderSections を共用し、表現を一致させる。
128
+ export function renderCatalogTemplateBody(doc) {
129
+ const topBase = resolveBasePath("", doc.base_path);
130
+ return renderSections(doc.groups, topBase, 1, []).join("\n").trim();
131
+ }
132
+ export function buildMarkdown(doc) {
133
+ const lines = [];
134
+ lines.push(...buildFrontmatter(doc));
135
+ lines.push("");
136
+ lines.push(`# 成果物カタログ: ${doc.domain}`);
137
+ lines.push("");
138
+ lines.push(`- project-id: \`${doc.project_id}\``);
139
+ lines.push(`- ドメイン: \`${doc.domain}\``);
140
+ const topBase = resolveBasePath("", doc.base_path);
141
+ lines.push(...renderSections(doc.groups, topBase, 1, []));
142
+ lines.push("");
143
+ return lines.join("\n");
144
+ }