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