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.
- package/CHANGELOG.md +18 -0
- package/dist/catalog-build-references.js +144 -0
- package/dist/catalog-build-render.js +144 -0
- package/dist/catalog-build.js +13 -290
- package/dist/catalog-generate.js +6 -9
- package/dist/catalog-plan-generate.js +2 -2
- package/dist/catalog-plan.js +6 -6
- package/dist/catalog-scaffold.js +4 -4
- package/dist/catalog.js +2 -2
- package/dist/dashboard-exec-records.js +105 -0
- package/dist/dashboard-routines.js +255 -0
- package/dist/dashboard-shared.js +14 -0
- package/dist/dashboard-timeline.js +175 -0
- package/dist/dashboard.js +10 -544
- package/dist/deliverable-trash.js +3 -3
- package/dist/doc-index.js +3 -3
- package/dist/exec-commands.js +557 -0
- package/dist/exec-core.js +457 -0
- package/dist/exec-plans-core.js +693 -0
- package/dist/exec-plans-generation.js +206 -0
- package/dist/exec-plans-storage.js +131 -0
- package/dist/exec-plans.js +3 -1018
- package/dist/exec-repo-integration-git.js +23 -0
- package/dist/exec-repo-integration-sync.js +264 -0
- package/dist/exec-repo-integration.js +4 -281
- package/dist/exec-reporter-output.js +206 -0
- package/dist/exec-reporter.js +2 -206
- package/dist/exec-results.js +22 -15
- package/dist/exec-run-agent-pipeline.js +256 -0
- package/dist/exec-run-agent.js +531 -0
- package/dist/exec-run-in-place.js +541 -0
- package/dist/exec-run-job.js +717 -0
- package/dist/exec-run-lifecycle-commands.js +522 -0
- package/dist/exec-run-mode-shared.js +140 -0
- package/dist/exec-run-register-command.js +244 -0
- package/dist/exec-run-register-core.js +386 -0
- package/dist/exec-run-register-mode.js +206 -0
- package/dist/exec-run-register-resume.js +393 -0
- package/dist/exec-run-register-state.js +322 -0
- package/dist/exec-run-register-worktree.js +509 -0
- package/dist/exec-run-schedule-mode.js +294 -0
- package/dist/exec-run-schedule-prepare.js +353 -0
- package/dist/exec-run-schedule-task.js +572 -0
- package/dist/exec-run-shared.js +399 -0
- package/dist/exec-run.js +11 -6182
- package/dist/exec-shared.js +2 -2
- package/dist/exec-trial-commands.js +558 -0
- package/dist/exec-trial-core.js +371 -0
- package/dist/exec-trial.js +2 -921
- package/dist/exec-worktree-ops-commit.js +707 -0
- package/dist/exec-worktree-ops-lifecycle.js +292 -0
- package/dist/exec-worktree-ops-merge.js +303 -0
- package/dist/exec-worktree-ops.js +3 -1292
- package/dist/exec-worktree.js +32 -4
- package/dist/exec.js +2 -1006
- package/dist/frontmatter-namespace.js +2 -2
- 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-markdown.js +274 -0
- package/dist/grade-pipeline-state.js +184 -0
- package/dist/grade-plan.js +507 -0
- package/dist/grade-result.js +5 -5
- package/dist/grade-target-discovery.js +265 -0
- package/dist/grade-targets.js +432 -0
- package/dist/grade.js +14 -3188
- package/dist/init-command.js +7 -7
- package/dist/job-definition.js +670 -0
- package/dist/job.js +9 -673
- package/dist/kata-command.js +2 -2
- package/dist/register-command-types.js +1 -0
- package/dist/register-core.js +363 -0
- package/dist/register-create-commands.js +245 -0
- package/dist/register-events.js +4 -4
- package/dist/register-item.js +6 -6
- package/dist/register-maintenance-commands.js +187 -0
- package/dist/register-migration.js +268 -0
- package/dist/register-renumber.js +314 -0
- package/dist/register-transition-commands.js +248 -0
- package/dist/register-update.js +230 -0
- package/dist/register-views.js +256 -0
- package/dist/register.js +61 -2069
- package/dist/review-plan.js +3 -3
- package/dist/routine-definition.js +401 -0
- package/dist/routine.js +6 -402
- package/dist/schedule-approach.js +2 -2
- package/dist/schedule-strategy-generate-document.js +273 -0
- package/dist/schedule-strategy-generate-scope.js +199 -0
- package/dist/schedule-strategy-generate.js +9 -473
- package/dist/schedule.js +4 -4
- package/dist/specdojo-config.js +3 -4
- package/dist/viewpoint-document-kinds-check.js +3 -3
- package/dist/yaml-pages.js +4 -4
- package/dist/yaml.js +28 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +6 -6
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +20 -18
- package/docs/ja/specdojo/guides/routine-operation-guide.md +1 -1
- package/package.json +4 -5
- package/templates/antigravity/README.md +3 -3
- package/templates/antigravity/exec-defaults-snippet.yaml +6 -4
- package/templates/init-exec-defaults.yaml +3 -1
package/dist/exec-plans.js
CHANGED
|
@@ -1,1018 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { DEFAULT_PROJECT_CONTEXT, specdojoRootDir } from "./specdojo-config.js";
|
|
5
|
-
import { kataDirsForKinds, resolveDeliverableSchemaRef, resolveIncludedRulebooks, resolveKataRefs, } from "./kata.js";
|
|
6
|
-
import { resolveBasePath, resolveDeliverablePath } from "./catalog-paths.js";
|
|
7
|
-
import { isDctPlanFileName } from "./catalog-plan.js";
|
|
8
|
-
import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "./frontmatter-namespace.js";
|
|
9
|
-
import { formatMarkdownFile } from "./exec-format.js";
|
|
10
|
-
import { qualifyPracticeId, SPECDOJO_PRACTICE_AUTHORITY } from "./practice-id.js";
|
|
11
|
-
import { resolveViewpointsDoc, viewpointAppliesToDocument } from "./review-plan.js";
|
|
12
|
-
import { expandTemplate, listFilesRecursive, nowUtcIsoSeconds, randomHex, tsForFilenameUtc, } from "./exec-shared.js";
|
|
13
|
-
import { gradeFindingDisplayMessage, gradeResultPathForDocument, readGradeResultForDocument, } from "./grade-result.js";
|
|
14
|
-
import { lookupDocIndex } from "./doc-index.js";
|
|
15
|
-
import { resolveSpecdojoPath, resolveSpecdojoPathIfExists } from "./template-resolution.js";
|
|
16
|
-
import { renderReviewGradeSummary, reviewGradeFreshness } from "./review-grade.js";
|
|
17
|
-
export const MISSING = "_MISSING_";
|
|
18
|
-
function execDocId(projectId, prefix, localBase) {
|
|
19
|
-
const localId = `${prefix}-${localBase.toLowerCase()}`;
|
|
20
|
-
return projectId ? `${projectId}:${localId}` : localId;
|
|
21
|
-
}
|
|
22
|
-
// In-place plan/result share one unique stem (`<slug>-<UTC>-<rand>`) so each run keeps a
|
|
23
|
-
// distinct file and id (no doc-index collision) and the result name is derivable from the
|
|
24
|
-
// plan. Mirrors the done/ archive naming convention (tsForFilenameUtc + randomHex).
|
|
25
|
-
export function buildInPlaceStem(slug) {
|
|
26
|
-
return `${slug}-${tsForFilenameUtc(nowUtcIsoSeconds())}-${randomHex(2)}`;
|
|
27
|
-
}
|
|
28
|
-
// Recover the shared stem from a plan path: `.../exec/plans/<stem>-plan.md` → `<stem>`.
|
|
29
|
-
// Used when re-running `--plan <path>` so the tied result is overwritten in place.
|
|
30
|
-
export function stemFromPlanPath(planPath) {
|
|
31
|
-
return basename(planPath).replace(/-plan\.md$/, "");
|
|
32
|
-
}
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
|
-
// Catalog helpers
|
|
35
|
-
// ---------------------------------------------------------------------------
|
|
36
|
-
function searchSections(sections, parentBase, localId) {
|
|
37
|
-
for (const section of sections) {
|
|
38
|
-
const sectionBase = resolveBasePath(parentBase, section.base_path);
|
|
39
|
-
for (const d of section.deliverables ?? []) {
|
|
40
|
-
if (d.local_id === localId) {
|
|
41
|
-
return {
|
|
42
|
-
deliverable: d,
|
|
43
|
-
resolvedPath: resolveDeliverablePath(sectionBase, d.path),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const found = searchSections(section.groups ?? [], sectionBase, localId);
|
|
48
|
-
if (found)
|
|
49
|
-
return found;
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
function findDeliverableInfo(catalogPath, localId) {
|
|
54
|
-
if (!catalogPath || !existsSync(catalogPath))
|
|
55
|
-
return null;
|
|
56
|
-
// Catalog scans walk subdirectories, so agent judgment plans (plans/dct-plan-*.yaml)
|
|
57
|
-
// must be excluded; they share the dct- prefix but carry no catalog structure.
|
|
58
|
-
const files = listFilesRecursive(catalogPath)
|
|
59
|
-
.filter((f) => {
|
|
60
|
-
const name = f.split("/").pop() ?? "";
|
|
61
|
-
return /^dct-.+\.ya?ml$/i.test(name) && !isDctPlanFileName(name);
|
|
62
|
-
})
|
|
63
|
-
.sort();
|
|
64
|
-
for (const filePath of files) {
|
|
65
|
-
let doc;
|
|
66
|
-
try {
|
|
67
|
-
doc = load(readFileSync(filePath, "utf8"));
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
const found = searchSections(doc.groups, resolveBasePath("", doc.base_path), localId);
|
|
73
|
-
if (found)
|
|
74
|
-
return found;
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
function loadCatalogDocs(catalogPath) {
|
|
79
|
-
if (!catalogPath || !existsSync(catalogPath))
|
|
80
|
-
return [];
|
|
81
|
-
// Catalog scans walk subdirectories, so agent judgment plans (plans/dct-plan-*.yaml)
|
|
82
|
-
// must be excluded; they share the dct- prefix but carry no catalog structure.
|
|
83
|
-
const files = listFilesRecursive(catalogPath)
|
|
84
|
-
.filter((f) => {
|
|
85
|
-
const name = f.split("/").pop() ?? "";
|
|
86
|
-
return /^dct-.+\.ya?ml$/i.test(name) && !isDctPlanFileName(name);
|
|
87
|
-
})
|
|
88
|
-
.sort();
|
|
89
|
-
const docs = [];
|
|
90
|
-
for (const filePath of files) {
|
|
91
|
-
try {
|
|
92
|
-
docs.push(load(readFileSync(filePath, "utf8")));
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return docs;
|
|
99
|
-
}
|
|
100
|
-
// Resolve a `--deliverable` identifier (a bare `local_id`) to a catalog deliverable.
|
|
101
|
-
// `local_id` is unique project-wide (catalog validate warns otherwise); an ambiguous
|
|
102
|
-
// match is an error rather than a silent first match.
|
|
103
|
-
export function resolveDeliverableTarget(catalogPath, value) {
|
|
104
|
-
const localId = value.trim();
|
|
105
|
-
if (!localId)
|
|
106
|
-
throw new Error("deliverable identifier is empty");
|
|
107
|
-
const docs = loadCatalogDocs(catalogPath);
|
|
108
|
-
const matches = [];
|
|
109
|
-
for (const doc of docs) {
|
|
110
|
-
const info = searchSections(doc.groups, resolveBasePath("", doc.base_path), localId);
|
|
111
|
-
if (info)
|
|
112
|
-
matches.push({ domain: doc.domain, localId, slug: localId, info });
|
|
113
|
-
}
|
|
114
|
-
if (matches.length === 0)
|
|
115
|
-
throw new Error(`deliverable not found: ${localId}`);
|
|
116
|
-
if (matches.length > 1) {
|
|
117
|
-
const domains = matches.map((m) => m.domain).join(", ");
|
|
118
|
-
throw new Error(`ambiguous deliverable: ${localId} (defined in domains: ${domains}). ` +
|
|
119
|
-
`local_id must be unique project-wide; run catalog validate.`);
|
|
120
|
-
}
|
|
121
|
-
return matches[0];
|
|
122
|
-
}
|
|
123
|
-
function loadViewpoints(viewpointsPath) {
|
|
124
|
-
if (!viewpointsPath || !existsSync(viewpointsPath))
|
|
125
|
-
return new Map();
|
|
126
|
-
const doc = resolveViewpointsDoc(viewpointsPath);
|
|
127
|
-
return new Map((doc.viewpoints ?? []).map((vp) => [vp.id, vp]));
|
|
128
|
-
}
|
|
129
|
-
function loadRoles(rolesPath) {
|
|
130
|
-
if (!rolesPath || !existsSync(rolesPath))
|
|
131
|
-
return new Map();
|
|
132
|
-
try {
|
|
133
|
-
const doc = load(readFileSync(rolesPath, "utf8"));
|
|
134
|
-
return new Map((doc.roles ?? []).map((role) => [role.code, role]));
|
|
135
|
-
}
|
|
136
|
-
catch {
|
|
137
|
-
return new Map();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// Canonical repo-root-relative path: POSIX separators, no leading slash. Agents and
|
|
141
|
-
// tools resolve it from the run CWD (repo root for in-place, worktree root otherwise),
|
|
142
|
-
// so a leading slash (filesystem-absolute) must not be emitted.
|
|
143
|
-
function repoRelativePath(absPath) {
|
|
144
|
-
return relative(specdojoRootDir(), absPath).replace(/\\/g, "/");
|
|
145
|
-
}
|
|
146
|
-
// ---------------------------------------------------------------------------
|
|
147
|
-
// Markdown builders
|
|
148
|
-
// ---------------------------------------------------------------------------
|
|
149
|
-
function frontmatter(meta) {
|
|
150
|
-
const inner = [
|
|
151
|
-
`id: ${meta.id}`,
|
|
152
|
-
`type: ${meta.type}`,
|
|
153
|
-
`rulebook: ${meta.rulebook}`,
|
|
154
|
-
`task_id: ${meta.task_id}`,
|
|
155
|
-
...(meta.name ? [`name: ${JSON.stringify(meta.name)}`] : []),
|
|
156
|
-
`mode: ${meta.mode}`,
|
|
157
|
-
`status: ${meta.status}`,
|
|
158
|
-
`project_id: ${meta.project_id}`,
|
|
159
|
-
];
|
|
160
|
-
if (meta.origin)
|
|
161
|
-
inner.push(`origin: ${meta.origin}`);
|
|
162
|
-
if (meta.owner)
|
|
163
|
-
inner.push(`owner: ${meta.owner}`);
|
|
164
|
-
if (meta.on_critical_path)
|
|
165
|
-
inner.push(`on_critical_path: true`);
|
|
166
|
-
if (meta.approach)
|
|
167
|
-
inner.push(`approach: ${meta.approach}`);
|
|
168
|
-
if (meta.targets && meta.targets.length > 0) {
|
|
169
|
-
inner.push("targets:");
|
|
170
|
-
for (const target of meta.targets)
|
|
171
|
-
inner.push(` - ${target}`);
|
|
172
|
-
}
|
|
173
|
-
return buildSpecdojoFrontmatter(inner);
|
|
174
|
-
}
|
|
175
|
-
// ---------------------------------------------------------------------------
|
|
176
|
-
// Template-based generation (edit-plan / review-plan テンプレートの展開)
|
|
177
|
-
// ---------------------------------------------------------------------------
|
|
178
|
-
// Shared conventions (link notation など) appended to every generated plan. The plan is the
|
|
179
|
-
// only context guaranteed to reach the executing agent regardless of tool (it is piped via
|
|
180
|
-
// stdin), so cross-tool rules must travel with the plan rather than tool-specific instruction
|
|
181
|
-
// files. Kept as a single fragment to avoid duplicating the rule across every plan template.
|
|
182
|
-
const COMMON_CONVENTIONS_TEMPLATE = "xep-common-conventions-template.md";
|
|
183
|
-
export function execTemplatesDir() {
|
|
184
|
-
return resolveSpecdojoPath("docs/ja/specdojo/exec-templates");
|
|
185
|
-
}
|
|
186
|
-
export function execTemplatePath(fileName) {
|
|
187
|
-
return resolveSpecdojoPath(`docs/ja/specdojo/exec-templates/${fileName}`);
|
|
188
|
-
}
|
|
189
|
-
function templatePrefix(mode) {
|
|
190
|
-
return mode === "review" ? "xrp" : "xep";
|
|
191
|
-
}
|
|
192
|
-
function standardTemplateFileName(mode) {
|
|
193
|
-
return `${templatePrefix(mode)}-template.md`;
|
|
194
|
-
}
|
|
195
|
-
function approachTemplateFileName(mode, approach) {
|
|
196
|
-
return `${templatePrefix(mode)}-${approach}-template.md`;
|
|
197
|
-
}
|
|
198
|
-
// Selects <prefix>-<approach>-template.md when it exists, falling back
|
|
199
|
-
// to the standard <prefix>-template.md. Any missing variant falls through to the
|
|
200
|
-
// next candidate so a plan is always produced.
|
|
201
|
-
function resolvePlanTemplatePath(mode, approach) {
|
|
202
|
-
if (approach) {
|
|
203
|
-
const candidatePath = resolveSpecdojoPathIfExists(`docs/ja/specdojo/exec-templates/${approachTemplateFileName(mode, approach)}`);
|
|
204
|
-
if (candidatePath)
|
|
205
|
-
return candidatePath;
|
|
206
|
-
}
|
|
207
|
-
return execTemplatePath(standardTemplateFileName(mode));
|
|
208
|
-
}
|
|
209
|
-
function readTemplate(templatePath, cache) {
|
|
210
|
-
const cached = cache.get(templatePath);
|
|
211
|
-
if (cached !== undefined)
|
|
212
|
-
return cached;
|
|
213
|
-
if (!existsSync(templatePath)) {
|
|
214
|
-
throw new Error(`Template not found: ${templatePath}`);
|
|
215
|
-
}
|
|
216
|
-
const content = readFileSync(templatePath, "utf8");
|
|
217
|
-
cache.set(templatePath, content);
|
|
218
|
-
return content;
|
|
219
|
-
}
|
|
220
|
-
function loadPlanTemplate(mode, approach, cache) {
|
|
221
|
-
return readTemplate(resolvePlanTemplatePath(mode, approach), cache);
|
|
222
|
-
}
|
|
223
|
-
// Marker a plan template places to control where the shared conventions fragment lands.
|
|
224
|
-
const COMMON_CONVENTIONS_PLACEHOLDER = "_COMMON_CONVENTIONS_";
|
|
225
|
-
// Lines delimiting the review-only block of the conventions fragment (review の判断手順). The
|
|
226
|
-
// block is kept, without the marker lines, in review plans and dropped from every other plan.
|
|
227
|
-
const REVIEW_ONLY_START = "<!-- review-only:start -->";
|
|
228
|
-
const REVIEW_ONLY_END = "<!-- review-only:end -->";
|
|
229
|
-
function selectReviewOnlyBlock(conventions, isReview) {
|
|
230
|
-
const kept = [];
|
|
231
|
-
let inside = false;
|
|
232
|
-
for (const line of conventions.split("\n")) {
|
|
233
|
-
const marker = line.trim();
|
|
234
|
-
if (marker === REVIEW_ONLY_START) {
|
|
235
|
-
inside = true;
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
if (marker === REVIEW_ONLY_END) {
|
|
239
|
-
inside = false;
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
if (!inside || isReview)
|
|
243
|
-
kept.push(line);
|
|
244
|
-
}
|
|
245
|
-
return kept
|
|
246
|
-
.join("\n")
|
|
247
|
-
.replace(/\n{3,}/g, "\n\n")
|
|
248
|
-
.trimEnd();
|
|
249
|
-
}
|
|
250
|
-
// Placeholder in the conventions fragment for the resolved schema path. The agent cannot derive
|
|
251
|
-
// the schema path on its own (it would have to hunt for it and risks burning its turn before
|
|
252
|
-
// filling the result), so the generator resolves it deterministically and bakes it in here.
|
|
253
|
-
const SCHEMA_REF_PLACEHOLDER = "_SCHEMA_REF_";
|
|
254
|
-
// Injects the shared conventions fragment into a built plan body so every generated plan carries
|
|
255
|
-
// the same rules (e.g. link notation) in its own text, independent of the executing tool. A
|
|
256
|
-
// template controls placement via the COMMON_CONVENTIONS_PLACEHOLDER marker; templates without the
|
|
257
|
-
// marker get the block appended so the rules are never silently dropped.
|
|
258
|
-
// schemaRef is the resolved schema path: when MISSING (non-yaml deliverable or no schema), the
|
|
259
|
-
// schema-validation bullet is dropped so the plan never asks for a check it cannot specify.
|
|
260
|
-
// mode selects whether the review-only block (review の判断手順) is kept; it defaults to edit so
|
|
261
|
-
// register / job plans never carry review instructions.
|
|
262
|
-
export function injectCommonConventions(body, schemaRef, cache, mode = "edit") {
|
|
263
|
-
let conventions = selectReviewOnlyBlock(readTemplate(execTemplatePath(COMMON_CONVENTIONS_TEMPLATE), cache), mode === "review");
|
|
264
|
-
conventions =
|
|
265
|
-
schemaRef === MISSING
|
|
266
|
-
? conventions
|
|
267
|
-
.split("\n")
|
|
268
|
-
.filter((line) => !line.includes(SCHEMA_REF_PLACEHOLDER))
|
|
269
|
-
.join("\n")
|
|
270
|
-
: conventions.split(SCHEMA_REF_PLACEHOLDER).join(schemaRef);
|
|
271
|
-
if (body.includes(COMMON_CONVENTIONS_PLACEHOLDER)) {
|
|
272
|
-
return body.split(COMMON_CONVENTIONS_PLACEHOLDER).join(conventions);
|
|
273
|
-
}
|
|
274
|
-
return `${body.trimEnd()}\n\n${conventions}\n`;
|
|
275
|
-
}
|
|
276
|
-
function phaseDescriptionText(task) {
|
|
277
|
-
if (task.description)
|
|
278
|
-
return task.description.trimEnd();
|
|
279
|
-
return task.name ?? task.id;
|
|
280
|
-
}
|
|
281
|
-
function deliverablePath(deliverable) {
|
|
282
|
-
return deliverable?.resolvedPath ?? MISSING;
|
|
283
|
-
}
|
|
284
|
-
function deliverableName(deliverable) {
|
|
285
|
-
return deliverable?.deliverable.name ?? MISSING;
|
|
286
|
-
}
|
|
287
|
-
function gradeFindingsText(projectId, targetPath) {
|
|
288
|
-
if (!targetPath || targetPath === MISSING || !existsSync(join(specdojoRootDir(), targetPath))) {
|
|
289
|
-
return "- なし";
|
|
290
|
-
}
|
|
291
|
-
try {
|
|
292
|
-
const result = readGradeResultForDocument({ documentPath: targetPath, project: projectId });
|
|
293
|
-
if (!result || result.findings.length === 0)
|
|
294
|
-
return "- なし";
|
|
295
|
-
return result.findings
|
|
296
|
-
.map((finding) => `- ${finding.id} [${finding.severity}/${finding.rule}; line=${finding.line}; anchor=${JSON.stringify(finding.anchor)}]: ${gradeFindingDisplayMessage(finding)}`)
|
|
297
|
-
.join("\n");
|
|
298
|
-
}
|
|
299
|
-
catch {
|
|
300
|
-
return "- なし";
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
function gradeFindingTargetPath(approach, deliverable, refs) {
|
|
304
|
-
if (approach === "rulebook-maintenance")
|
|
305
|
-
return refs.rulebook;
|
|
306
|
-
if (approach === "recipe-maintenance")
|
|
307
|
-
return refs.recipe;
|
|
308
|
-
if (approach === "sample-maintenance")
|
|
309
|
-
return refs.sample;
|
|
310
|
-
if (approach === "template-maintenance")
|
|
311
|
-
return refs.template;
|
|
312
|
-
return deliverablePath(deliverable);
|
|
313
|
-
}
|
|
314
|
-
// grade の --target。実践の型メンテナンス系は実践の型そのものを評価対象にする。
|
|
315
|
-
function gradeTargetKind(approach) {
|
|
316
|
-
return approach === "rulebook-maintenance" ||
|
|
317
|
-
approach === "recipe-maintenance" ||
|
|
318
|
-
approach === "sample-maintenance" ||
|
|
319
|
-
approach === "template-maintenance"
|
|
320
|
-
? "kata"
|
|
321
|
-
: "deliverable";
|
|
322
|
-
}
|
|
323
|
-
// review の前段で runner が grade を実行する評価対象(PJR-KCMH)。review plan の「評価結果」章と
|
|
324
|
-
// 同じ規則で決めるため、plan 生成と runner の実行対象が食い違わない。
|
|
325
|
-
export function reviewGradeSubject(catalogPath, task) {
|
|
326
|
-
const deliverable = task.local_id && catalogPath ? findDeliverableInfo(catalogPath, task.local_id) : null;
|
|
327
|
-
const refs = resolveKataRefs(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind);
|
|
328
|
-
const path = gradeFindingTargetPath(task.approach, deliverable, refs);
|
|
329
|
-
if (!path || path === MISSING)
|
|
330
|
-
return undefined;
|
|
331
|
-
return { path, target: gradeTargetKind(task.approach) };
|
|
332
|
-
}
|
|
333
|
-
// review plan に提示する評価結果。runner の grade 実行結果があれば併記する。
|
|
334
|
-
function reviewGradeSummaryText(projectId, subjectPath, outcome) {
|
|
335
|
-
return renderReviewGradeSummary(reviewGradeFreshness({
|
|
336
|
-
subjectPath: subjectPath === MISSING ? "" : subjectPath,
|
|
337
|
-
projectId,
|
|
338
|
-
rootDir: specdojoRootDir(),
|
|
339
|
-
}), outcome);
|
|
340
|
-
}
|
|
341
|
-
// 評価対象に対応する評価結果サイドカーのリポジトリ相対パス。評価対象が未作成、または
|
|
342
|
-
// frontmatter の id を解決できない場合は MISSING を返す(サイドカーの有無は問わない)。
|
|
343
|
-
function gradeResultRef(projectId, subjectPath) {
|
|
344
|
-
if (!subjectPath || subjectPath === MISSING)
|
|
345
|
-
return MISSING;
|
|
346
|
-
if (!existsSync(join(specdojoRootDir(), subjectPath)))
|
|
347
|
-
return MISSING;
|
|
348
|
-
try {
|
|
349
|
-
return repoRelativePath(gradeResultPathForDocument({ documentPath: subjectPath, project: projectId }));
|
|
350
|
-
}
|
|
351
|
-
catch {
|
|
352
|
-
return MISSING;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
// plan に表示する実践の型の状態。宣言からパスを解決できたがファイルが無い場合と、
|
|
356
|
-
// 宣言不足・対象外などでパス自体を解決できない場合を分ける。これにより executor は
|
|
357
|
-
// 既存文書の編集、宣言済みパスへの新規作成、前提確認が必要な状態を推測せず判別できる。
|
|
358
|
-
function kataRefState(refPath) {
|
|
359
|
-
if (refPath === MISSING)
|
|
360
|
-
return "unresolved";
|
|
361
|
-
return existsSync(join(specdojoRootDir(), refPath)) ? "existing" : "missing";
|
|
362
|
-
}
|
|
363
|
-
// 対象成果物の depends_on を、依存先 doc の [[id]] 参照の入れ子リストで提示する。
|
|
364
|
-
// id は依存先の frontmatter、未作成なら配置規約から解決する。agent へ plan を渡すときに
|
|
365
|
-
// expandPromptRefs(src/exec-run.ts, format:'path')が
|
|
366
|
-
// この [[id]] を doc-index 経由でリポジトリ相対パスへ展開し、agent が先行成果物を直接開ける。
|
|
367
|
-
// テンプレート側はラベル直後にこの値を差し込むため、件数 0・成果物未解決時は先頭スペース付きの
|
|
368
|
-
// インライン値、依存ありの場合は改行始まりの入れ子リストを返す。
|
|
369
|
-
function deliverableDependsOn(deliverable, projectId, catalogPath) {
|
|
370
|
-
if (!deliverable)
|
|
371
|
-
return ` ${MISSING}`;
|
|
372
|
-
const deps = deliverable.deliverable.depends_on ?? [];
|
|
373
|
-
if (deps.length === 0)
|
|
374
|
-
return " -";
|
|
375
|
-
const lines = deps.map((dep) => {
|
|
376
|
-
const info = findDeliverableInfo(catalogPath, dep);
|
|
377
|
-
return ` - [[${deliverableDocId(projectId, dep, info?.resolvedPath)}]]`;
|
|
378
|
-
});
|
|
379
|
-
return `\n${lines.join("\n")}`;
|
|
380
|
-
}
|
|
381
|
-
const PROJECT_CONTEXT_EXCLUDED_APPROACHES = new Set([
|
|
382
|
-
"cross-deliverable-dedup",
|
|
383
|
-
"rulebook-maintenance",
|
|
384
|
-
"recipe-maintenance",
|
|
385
|
-
"sample-maintenance",
|
|
386
|
-
"template-maintenance",
|
|
387
|
-
"finalize",
|
|
388
|
-
"bootstrap-finalize",
|
|
389
|
-
]);
|
|
390
|
-
// Project context is project-level guidance, not an ordering/evidence edge. It is rendered only
|
|
391
|
-
// for deliverable edit/review work, separately from depends_on, and is deliberately omitted for
|
|
392
|
-
// maintenance/finalize work and when the target itself is the configured context document.
|
|
393
|
-
function projectContextSection(refs, deliverable, approach, projectId) {
|
|
394
|
-
if (!deliverable || (approach && PROJECT_CONTEXT_EXCLUDED_APPROACHES.has(approach)))
|
|
395
|
-
return "";
|
|
396
|
-
const targetId = deliverableDocId(projectId, deliverable.deliverable.local_id, deliverable.resolvedPath);
|
|
397
|
-
const qualifiedRefs = [
|
|
398
|
-
...new Set(refs
|
|
399
|
-
.map((ref) => ref.trim())
|
|
400
|
-
.filter(Boolean)
|
|
401
|
-
.map((ref) => (ref.includes(":") ? ref : qualifiedDocId(projectId, ref)))
|
|
402
|
-
.filter((ref) => ref !== targetId)),
|
|
403
|
-
];
|
|
404
|
-
if (qualifiedRefs.length === 0)
|
|
405
|
-
return "";
|
|
406
|
-
return [
|
|
407
|
-
"### プロジェクトコンテキスト",
|
|
408
|
-
"",
|
|
409
|
-
"以下は `depends_on` とは独立したプロジェクト共通の文脈であり、実行順序・成果物間の根拠関係を表さない。作業開始前に実際に読み、プロジェクトレベルの Why、用語、判断原則と成果物の内容を整合させる。",
|
|
410
|
-
"",
|
|
411
|
-
...qualifiedRefs.map((ref) => `- [[${ref}]]`),
|
|
412
|
-
"",
|
|
413
|
-
"プロジェクトレベルの Why は判断軸として参照し、全文を成果物へ再掲しない。対象成果物の責務に必要な結論・影響だけを反映する。",
|
|
414
|
-
].join("\n");
|
|
415
|
-
}
|
|
416
|
-
function deliverableOverview(deliverable) {
|
|
417
|
-
return deliverable?.deliverable.overview ?? MISSING;
|
|
418
|
-
}
|
|
419
|
-
function implementationEvidence(deliverable) {
|
|
420
|
-
const refs = deliverable?.deliverable.evidence_refs ?? [];
|
|
421
|
-
if (refs.length === 0)
|
|
422
|
-
return MISSING;
|
|
423
|
-
return refs.map((ref) => `- \`${ref.path}\`(${ref.kind}): ${ref.purpose}`).join("\n");
|
|
424
|
-
}
|
|
425
|
-
// edit plan の「完了の狙い」用。一文書一責務のため、done_criteria を owner ロールの狙いと
|
|
426
|
-
// 下流ロールの入力適合に分けて提示する。owner の狙いを作成目標とし、下流は入力として最低限
|
|
427
|
-
// 成立させる範囲にとどめる(各ロールの内容を作り込まない)。下流の適合性検証や観点別の自己
|
|
428
|
-
// レビューは edit plan では行わず、多観点検証は独立した review plan に委ねる。
|
|
429
|
-
// owner が done_criteria に現れない場合は分割せず全件を素の箇条書きにフォールバックする。
|
|
430
|
-
function doneCriteriaGoals(criteria, owner) {
|
|
431
|
-
if (criteria.length === 0)
|
|
432
|
-
return MISSING;
|
|
433
|
-
const ownerCriteria = owner ? criteria.filter((c) => c.roles.includes(owner)) : [];
|
|
434
|
-
if (ownerCriteria.length === 0) {
|
|
435
|
-
return criteria.map((c) => `- ${c.text}`).join("\n");
|
|
436
|
-
}
|
|
437
|
-
const downstream = criteria.filter((c) => !c.roles.includes(owner));
|
|
438
|
-
const lines = ["owner として達成する狙い:", ""];
|
|
439
|
-
for (const c of ownerCriteria)
|
|
440
|
-
lines.push(`- ${c.text}`);
|
|
441
|
-
if (downstream.length > 0) {
|
|
442
|
-
lines.push("");
|
|
443
|
-
lines.push("下流ロールの入力適合(最低ライン。各ロールの内容は作り込まず、入力として成立させる):");
|
|
444
|
-
lines.push("");
|
|
445
|
-
for (const c of downstream)
|
|
446
|
-
lines.push(`- [${c.roles.join(", ")}] ${c.text}`);
|
|
447
|
-
}
|
|
448
|
-
return lines.join("\n");
|
|
449
|
-
}
|
|
450
|
-
// done_criteria を人間の最終確認用チェックリストに整形する。owner/下流の分割はせず、
|
|
451
|
-
// 各項目を `- [ ] <text>` の素のチェック項目にする(human finalize は多観点の作り込みでは
|
|
452
|
-
// なく、完成版が done_criteria を満たすかの確認が目的のため)。criteria が空なら MISSING。
|
|
453
|
-
function doneCriteriaChecklist(criteria) {
|
|
454
|
-
if (criteria.length === 0)
|
|
455
|
-
return MISSING;
|
|
456
|
-
return criteria.map((c) => `- [ ] ${c.text}`).join("\n");
|
|
457
|
-
}
|
|
458
|
-
// done_criteria を plan 提示用の素の箇条書きに整形する。チェックの記録は result 側の
|
|
459
|
-
// チェックリストで行うため、plan では「何を確認するか」の列挙にとどめる。
|
|
460
|
-
function doneCriteriaItems(criteria) {
|
|
461
|
-
if (criteria.length === 0)
|
|
462
|
-
return MISSING;
|
|
463
|
-
return criteria.map((c) => `- ${c.text}`).join("\n");
|
|
464
|
-
}
|
|
465
|
-
// 主 rulebook が include する rulebook を plan へ注入する表記に整形する。
|
|
466
|
-
// 併せて適用する rulebook(記法など)を backtick 付きパスのカンマ区切りで示す。
|
|
467
|
-
// include が無い場合は他の参照と同様に MISSING を返す。
|
|
468
|
-
function rulebookIncludesText(rulebookId, targetKind) {
|
|
469
|
-
if (targetKind === "generated")
|
|
470
|
-
return MISSING;
|
|
471
|
-
const paths = resolveIncludedRulebooks(rulebookId);
|
|
472
|
-
if (paths.length === 0)
|
|
473
|
-
return MISSING;
|
|
474
|
-
return paths.map((p) => `\`${p}\``).join(", ");
|
|
475
|
-
}
|
|
476
|
-
// 実践の型の doc id を正準パス(docs/ja/specdojo/<kind>s/<id>.<ext>)の basename から導出する。
|
|
477
|
-
// 実践の型の frontmatter id はファイル名と一致する規約(specdojo:docs-structure-guide)を前提にする。
|
|
478
|
-
function refDocIdFromPath(refPath) {
|
|
479
|
-
const localId = basename(refPath).replace(/\.(md|yaml|json)$/, "");
|
|
480
|
-
const parts = refPath.split("/");
|
|
481
|
-
const authority = parts[0] === "docs" && /^[a-z]{2}$/.test(parts[1] ?? "")
|
|
482
|
-
? parts[2]
|
|
483
|
-
: SPECDOJO_PRACTICE_AUTHORITY;
|
|
484
|
-
return qualifyPracticeId(authority ?? SPECDOJO_PRACTICE_AUTHORITY, localId);
|
|
485
|
-
}
|
|
486
|
-
// approach ごとに、成果物に加えて変更・確定の対象になる実践の型の種別。
|
|
487
|
-
const TARGET_REF_KINDS = {
|
|
488
|
-
bootstrap: ["rulebook", "recipe", "sample", "template"],
|
|
489
|
-
"bootstrap-finalize": ["rulebook", "recipe", "sample", "template"],
|
|
490
|
-
"rulebook-maintenance": ["rulebook"],
|
|
491
|
-
"recipe-maintenance": ["recipe"],
|
|
492
|
-
"sample-maintenance": ["sample"],
|
|
493
|
-
"template-maintenance": ["template"],
|
|
494
|
-
};
|
|
495
|
-
function qualifiedDocId(projectId, localId) {
|
|
496
|
-
return projectId ? `${projectId}:${localId}` : localId;
|
|
497
|
-
}
|
|
498
|
-
// 成果物の doc id は、既存文書では frontmatter を正本とする。author 前など文書が
|
|
499
|
-
// 未作成の場合は配置規約に従い、product 配下だけをローカル ID、projects 配下を含む
|
|
500
|
-
// その他の配置を従来どおり project 修飾 ID とする。
|
|
501
|
-
export function deliverableDocId(projectId, localId, resolvedPath) {
|
|
502
|
-
if (resolvedPath) {
|
|
503
|
-
const absolutePath = resolve(specdojoRootDir(), resolvedPath);
|
|
504
|
-
if (existsSync(absolutePath)) {
|
|
505
|
-
try {
|
|
506
|
-
const id = readSpecdojoNamespace(readFileSync(absolutePath, "utf8")).id;
|
|
507
|
-
if (typeof id === "string" && id.trim())
|
|
508
|
-
return id.trim();
|
|
509
|
-
}
|
|
510
|
-
catch {
|
|
511
|
-
// 読み取り不能・不正 frontmatter は配置によるフォールバックへ進む。
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
const normalizedPath = resolvedPath.replaceAll("\\", "/").replace(/^\/+/, "");
|
|
515
|
-
if (/^docs\/[a-z]{2}\/product(?:\/|$)/.test(normalizedPath))
|
|
516
|
-
return localId;
|
|
517
|
-
}
|
|
518
|
-
return qualifiedDocId(projectId, localId);
|
|
519
|
-
}
|
|
520
|
-
// タスクが対象とする文書の doc id リスト。先頭は対象成果物(配置に対応する doc id)、
|
|
521
|
-
// 以降は approach に応じて変更・確定しうる実践の型の doc id。いずれも doc-index で
|
|
522
|
-
// パスへ解決できる id にし、schedule やファイル名の命名規約に依存せず対象を機械的に
|
|
523
|
-
// 取得できるようにする。解決できない実践の型(_MISSING_)は含めない。
|
|
524
|
-
// targets は frontmatter の必須項目のため、catalog で成果物を解決できない場合も
|
|
525
|
-
// fallbackLocalId から成果物の doc id だけは組み立てる。
|
|
526
|
-
function targetDocIds(projectId, deliverable, approach, fallbackLocalId) {
|
|
527
|
-
if (!deliverable) {
|
|
528
|
-
return fallbackLocalId ? [qualifiedDocId(projectId, fallbackLocalId)] : [];
|
|
529
|
-
}
|
|
530
|
-
const ids = [
|
|
531
|
-
deliverableDocId(projectId, deliverable.deliverable.local_id, deliverable.resolvedPath),
|
|
532
|
-
];
|
|
533
|
-
const kinds = approach ? (TARGET_REF_KINDS[approach] ?? []) : [];
|
|
534
|
-
if (kinds.length === 0)
|
|
535
|
-
return ids;
|
|
536
|
-
const refs = resolveKataRefs(deliverable.deliverable.rulebook, deliverable.deliverable.kind);
|
|
537
|
-
for (const kind of kinds) {
|
|
538
|
-
const refPath = refs[kind];
|
|
539
|
-
if (refPath !== MISSING)
|
|
540
|
-
ids.push(refDocIdFromPath(refPath));
|
|
541
|
-
}
|
|
542
|
-
return ids;
|
|
543
|
-
}
|
|
544
|
-
function targetDocIdsForTask(projectId, task, deliverable, crossDeliverables) {
|
|
545
|
-
if (task.target_local_ids && task.target_local_ids.length > 0) {
|
|
546
|
-
return [...new Set(task.target_local_ids)].map((localId) => {
|
|
547
|
-
const info = crossDeliverables.get(localId);
|
|
548
|
-
return deliverableDocId(projectId, localId, info?.resolvedPath);
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
return targetDocIds(projectId, deliverable, task.approach, task.local_id);
|
|
552
|
-
}
|
|
553
|
-
// approach が実践の型の変更を伴う場合に、変更を許可するディレクトリ(repo ルート相対)。
|
|
554
|
-
// commit 許可リスト(exec-worktree-ops)から使う。
|
|
555
|
-
export function targetReferenceDirsForApproach(approach) {
|
|
556
|
-
const kinds = approach ? (TARGET_REF_KINDS[approach] ?? []) : [];
|
|
557
|
-
return kataDirsForKinds(kinds);
|
|
558
|
-
}
|
|
559
|
-
// catalog から成果物 local_id の文書パス(repo ルート相対)を解決する。
|
|
560
|
-
// 未作成の成果物でも catalog が宣言するパスを返せるため、doc-index に載る前の
|
|
561
|
-
// 新規成果物の commit 許可判定に使う。
|
|
562
|
-
export function deliverableDocPath(catalogPath, localId) {
|
|
563
|
-
return findDeliverableInfo(catalogPath, localId)?.resolvedPath;
|
|
564
|
-
}
|
|
565
|
-
// Resolve the target doc ids for a deliverable by local_id (result scaffold 用)。
|
|
566
|
-
// localId が不明な場合のみ undefined を返す。catalog で成果物を解決できない場合は
|
|
567
|
-
// 成果物の doc id 1 件へフォールバックする(targets は必須項目のため)。
|
|
568
|
-
export function targetDocIdsForDeliverable(catalogPath, localId, projectId, approach) {
|
|
569
|
-
if (!localId)
|
|
570
|
-
return undefined;
|
|
571
|
-
const info = catalogPath ? findDeliverableInfo(catalogPath, localId) : null;
|
|
572
|
-
const ids = targetDocIds(projectId, info, approach, localId);
|
|
573
|
-
return ids.length > 0 ? ids : undefined;
|
|
574
|
-
}
|
|
575
|
-
// Resolve every target of a scheduled task. Cross-deliverable tasks carry an explicit
|
|
576
|
-
// target_local_ids list; ordinary tasks keep the single-deliverable/reference-material behavior.
|
|
577
|
-
export function targetDocIdsForScheduledTask(catalogPath, task, projectId) {
|
|
578
|
-
if (task.target_local_ids && task.target_local_ids.length > 0) {
|
|
579
|
-
const ids = [...new Set(task.target_local_ids)].map((localId) => {
|
|
580
|
-
const info = findDeliverableInfo(catalogPath, localId);
|
|
581
|
-
return deliverableDocId(projectId, localId, info?.resolvedPath);
|
|
582
|
-
});
|
|
583
|
-
return ids.length > 0 ? ids : undefined;
|
|
584
|
-
}
|
|
585
|
-
return targetDocIdsForDeliverable(catalogPath, task.local_id, projectId, task.approach);
|
|
586
|
-
}
|
|
587
|
-
function crossDeliverableTargetDetails(projectId, localIds, deliverables, catalogPath) {
|
|
588
|
-
const lines = [];
|
|
589
|
-
for (const localId of localIds) {
|
|
590
|
-
const info = deliverables.get(localId);
|
|
591
|
-
const docId = deliverableDocId(projectId, localId, info?.resolvedPath);
|
|
592
|
-
lines.push(`### ${docId}`);
|
|
593
|
-
lines.push("");
|
|
594
|
-
lines.push(`- document: [[${docId}]]`);
|
|
595
|
-
lines.push(`- name: ${deliverableName(info ?? null)}`);
|
|
596
|
-
lines.push(`- path: \`${deliverablePath(info ?? null)}\``);
|
|
597
|
-
lines.push(`- overview: ${deliverableOverview(info ?? null)}`);
|
|
598
|
-
lines.push(`- depends_on:${deliverableDependsOn(info ?? null, projectId, catalogPath)}`);
|
|
599
|
-
lines.push("- done_criteria:");
|
|
600
|
-
const criteria = info?.deliverable.done_criteria ?? [];
|
|
601
|
-
if (criteria.length === 0)
|
|
602
|
-
lines.push(` - ${MISSING}`);
|
|
603
|
-
else {
|
|
604
|
-
for (const criterion of criteria) {
|
|
605
|
-
lines.push(` - [${criterion.roles.join(", ")} / ${criterion.viewpoint}] ${criterion.text}`);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
lines.push("");
|
|
609
|
-
}
|
|
610
|
-
return lines.join("\n").trimEnd();
|
|
611
|
-
}
|
|
612
|
-
// review plan の完了条件表の行。review は観点ごとに評価せず、done_criteria をタスクの
|
|
613
|
-
// 完了条件として照合するため、ID は DC-NNN とする。
|
|
614
|
-
function reviewDoneCriteriaRows(criteria) {
|
|
615
|
-
if (criteria.length === 0)
|
|
616
|
-
return MISSING;
|
|
617
|
-
const lines = [];
|
|
618
|
-
criteria.forEach((c, i) => {
|
|
619
|
-
const criterionId = `DC-${String(i + 1).padStart(3, "0")}`;
|
|
620
|
-
lines.push(`| ${criterionId} | ${c.roles.join(", ")} | ${c.viewpoint} | ${c.text} |`);
|
|
621
|
-
});
|
|
622
|
-
return lines.join("\n");
|
|
623
|
-
}
|
|
624
|
-
export function applicableReviewCriteria(criteria, vpMap, rulebook) {
|
|
625
|
-
const metadata = rulebook ? { rulebook } : {};
|
|
626
|
-
return criteria.filter((criterion) => {
|
|
627
|
-
const viewpoint = vpMap.get(criterion.viewpoint);
|
|
628
|
-
return viewpoint === undefined || viewpointAppliesToDocument(viewpoint, metadata);
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
// done_criteria を確認記録用チェックボックスに整形する。各項目に roles / viewpoint
|
|
632
|
-
// (review-viewpoints の観点 ID)を注記し、どの観点で確認したかが result に残るようにする。
|
|
633
|
-
function doneCriteriaResultChecklist(criteria) {
|
|
634
|
-
return criteria
|
|
635
|
-
.map((c) => {
|
|
636
|
-
const annotation = [c.roles.join(", "), c.viewpoint].filter(Boolean).join(" / ");
|
|
637
|
-
return annotation ? `- [ ] ${c.text}(${annotation})` : `- [ ] ${c.text}`;
|
|
638
|
-
})
|
|
639
|
-
.join("\n");
|
|
640
|
-
}
|
|
641
|
-
// 確定対象(status を ready へ昇格する対象)のチェックリスト。成果物を先頭に、
|
|
642
|
-
// bootstrap-finalize では解決できた実践の型(_MISSING_ 以外)を続ける。
|
|
643
|
-
function finalizeTargetsChecklist(deliverable, approach) {
|
|
644
|
-
const lines = [`- [ ] 成果物: \`${deliverablePath(deliverable)}\``];
|
|
645
|
-
if (approach === "bootstrap-finalize") {
|
|
646
|
-
const refs = resolveKataRefs(deliverable.deliverable.rulebook, deliverable.deliverable.kind);
|
|
647
|
-
const entries = [
|
|
648
|
-
["rulebook", refs.rulebook],
|
|
649
|
-
["recipe", refs.recipe],
|
|
650
|
-
["sample", refs.sample],
|
|
651
|
-
["template", refs.template],
|
|
652
|
-
];
|
|
653
|
-
for (const [kind, ref] of entries) {
|
|
654
|
-
if (ref !== MISSING)
|
|
655
|
-
lines.push(`- [ ] ${kind}: \`${ref}\``);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
return lines.join("\n");
|
|
659
|
-
}
|
|
660
|
-
// Resolve the finalize result sections for a deliverable by local_id. Returns undefined when
|
|
661
|
-
// the catalog, deliverable, or its done_criteria cannot be resolved; the caller then falls
|
|
662
|
-
// back to a generic result body (placeholders stay _TODO_).
|
|
663
|
-
export function finalizeResultSectionsForDeliverable(catalogPath, localId, approach) {
|
|
664
|
-
if (!catalogPath || !localId)
|
|
665
|
-
return undefined;
|
|
666
|
-
const info = findDeliverableInfo(catalogPath, localId);
|
|
667
|
-
if (!info)
|
|
668
|
-
return undefined;
|
|
669
|
-
const criteria = info.deliverable.done_criteria ?? [];
|
|
670
|
-
if (criteria.length === 0)
|
|
671
|
-
return undefined;
|
|
672
|
-
return {
|
|
673
|
-
doneCriteriaChecklist: doneCriteriaResultChecklist(criteria),
|
|
674
|
-
targetsChecklist: finalizeTargetsChecklist(info, approach),
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
// owner の Role code から、pm-roles.yaml の責務(project_note)と
|
|
678
|
-
// pm-review-viewpoints.yaml の該当 role 観点を取り出す。owner 未設定や情報欠落時は
|
|
679
|
-
// 他のプレースホルダと同様に MISSING を返し、表示構造はテンプレート側に委ねる。
|
|
680
|
-
export function ownerRoleFields(owner, roleMap, vpMap, rulebook) {
|
|
681
|
-
if (!owner) {
|
|
682
|
-
return { label: MISSING, note: MISSING, viewpoints: MISSING };
|
|
683
|
-
}
|
|
684
|
-
const role = roleMap.get(owner);
|
|
685
|
-
const label = role?.name ? `${owner}(${role.name})` : owner;
|
|
686
|
-
const note = role?.project_note ?? MISSING;
|
|
687
|
-
const metadata = rulebook ? { rulebook } : {};
|
|
688
|
-
const roleViewpoints = [...vpMap.values()].filter((vp) => vp.role === owner && viewpointAppliesToDocument(vp, metadata));
|
|
689
|
-
const viewpoints = roleViewpoints.length > 0
|
|
690
|
-
? roleViewpoints.map((vp) => `- ${vp.title}: ${vp.check}`).join("\n")
|
|
691
|
-
: MISSING;
|
|
692
|
-
return { label, note, viewpoints };
|
|
693
|
-
}
|
|
694
|
-
// edit plan は観点別の自己レビューを行わない。done_criteria は §3 の owner 視点とは別に
|
|
695
|
-
// 「完了の狙い」として素の箇条書きで提示し、多観点検証は独立した review plan に委ねる。
|
|
696
|
-
function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, projectId, catalogPath, projectContext, resultRef, stem, crossDeliverables = new Map()) {
|
|
697
|
-
const cpm = task.cpm;
|
|
698
|
-
const onCriticalPath = cpm !== undefined && cpm.slack === 0;
|
|
699
|
-
const targets = targetDocIdsForTask(projectId, task, deliverable, crossDeliverables);
|
|
700
|
-
const meta = {
|
|
701
|
-
id: execDocId(projectId, "xep", stem),
|
|
702
|
-
type: "exec-plan",
|
|
703
|
-
rulebook: "none",
|
|
704
|
-
task_id: task.id,
|
|
705
|
-
...(task.name ? { name: task.name } : {}),
|
|
706
|
-
mode: "edit",
|
|
707
|
-
status: "ready",
|
|
708
|
-
project_id: projectId,
|
|
709
|
-
...(task.owner ? { owner: task.owner } : {}),
|
|
710
|
-
...(onCriticalPath ? { on_critical_path: true } : {}),
|
|
711
|
-
...(task.approach ? { approach: task.approach } : {}),
|
|
712
|
-
...(targets.length > 0 ? { targets } : {}),
|
|
713
|
-
};
|
|
714
|
-
const criteria = deliverable?.deliverable.done_criteria ?? [];
|
|
715
|
-
const ownerRole = ownerRoleFields(task.owner, roleMap, vpMap, deliverable?.deliverable.rulebook);
|
|
716
|
-
const refs = resolveKataRefs(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind);
|
|
717
|
-
const values = {
|
|
718
|
-
_FRONTMATTER_: frontmatter(meta),
|
|
719
|
-
_TASK_ID_: task.id,
|
|
720
|
-
_PHASE_DESCRIPTION_: phaseDescriptionText(task),
|
|
721
|
-
_DELIVERABLE_NAME_: deliverableName(deliverable),
|
|
722
|
-
_DELIVERABLE_DEPENDS_ON_: deliverableDependsOn(deliverable, projectId, catalogPath),
|
|
723
|
-
_PROJECT_CONTEXT_: projectContextSection(projectContext, deliverable, task.approach, projectId),
|
|
724
|
-
_DELIVERABLE_OVERVIEW_: deliverableOverview(deliverable),
|
|
725
|
-
_IMPLEMENTATION_EVIDENCE_: implementationEvidence(deliverable),
|
|
726
|
-
_DELIVERABLE_PATH_: deliverablePath(deliverable),
|
|
727
|
-
_RESULT_REF_: resultRef,
|
|
728
|
-
_RULEBOOK_REF_: refs.rulebook,
|
|
729
|
-
_RULEBOOK_STATE_: kataRefState(refs.rulebook),
|
|
730
|
-
_RULEBOOK_INCLUDES_: rulebookIncludesText(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind),
|
|
731
|
-
_RECIPE_REF_: refs.recipe,
|
|
732
|
-
_RECIPE_STATE_: kataRefState(refs.recipe),
|
|
733
|
-
_SAMPLE_REF_: refs.sample,
|
|
734
|
-
_SAMPLE_STATE_: kataRefState(refs.sample),
|
|
735
|
-
_TEMPLATE_REF_: refs.template,
|
|
736
|
-
_TEMPLATE_STATE_: kataRefState(refs.template),
|
|
737
|
-
_OWNER_ROLE_LABEL_: ownerRole.label,
|
|
738
|
-
_OWNER_ROLE_NOTE_: ownerRole.note,
|
|
739
|
-
_OWNER_ROLE_VIEWPOINTS_: ownerRole.viewpoints,
|
|
740
|
-
_DONE_CRITERIA_GOALS_: doneCriteriaGoals(criteria, task.owner),
|
|
741
|
-
_DONE_CRITERIA_CHECKLIST_: doneCriteriaChecklist(criteria),
|
|
742
|
-
_DONE_CRITERIA_ITEMS_: doneCriteriaItems(criteria),
|
|
743
|
-
_GRADE_FINDINGS_: gradeFindingsText(projectId, gradeFindingTargetPath(task.approach, deliverable, refs)),
|
|
744
|
-
_TARGET_DELIVERABLES_: crossDeliverableTargetDetails(projectId, task.target_local_ids ?? [], crossDeliverables, catalogPath),
|
|
745
|
-
};
|
|
746
|
-
return expandTemplate(template, values);
|
|
747
|
-
}
|
|
748
|
-
// review plan は成果物を再評価しない。grade の評価結果(サイドカー)の位置と完了条件を示し、
|
|
749
|
-
// 評価結果を事実として受け取ってタスクの完了可否を判断させる(bps-task-completion)。
|
|
750
|
-
function buildReviewPlanMarkdown(template, task, deliverable, criteria, vpMap, projectId, catalogPath, projectContext, resultRef, stem, reviewGradeOutcome) {
|
|
751
|
-
const cpm = task.cpm;
|
|
752
|
-
const onCriticalPath = cpm !== undefined && cpm.slack === 0;
|
|
753
|
-
const targets = targetDocIds(projectId, deliverable, task.approach, task.local_id);
|
|
754
|
-
const meta = {
|
|
755
|
-
id: execDocId(projectId, "xrp", stem),
|
|
756
|
-
type: "exec-plan",
|
|
757
|
-
rulebook: "none",
|
|
758
|
-
task_id: task.id,
|
|
759
|
-
...(task.name ? { name: task.name } : {}),
|
|
760
|
-
mode: "review",
|
|
761
|
-
status: "ready",
|
|
762
|
-
project_id: projectId,
|
|
763
|
-
...(task.owner ? { owner: task.owner } : {}),
|
|
764
|
-
...(onCriticalPath ? { on_critical_path: true } : {}),
|
|
765
|
-
...(task.approach ? { approach: task.approach } : {}),
|
|
766
|
-
...(targets.length > 0 ? { targets } : {}),
|
|
767
|
-
};
|
|
768
|
-
const refs = resolveKataRefs(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind);
|
|
769
|
-
const applicableCriteria = applicableReviewCriteria(criteria, vpMap, deliverable?.deliverable.rulebook);
|
|
770
|
-
const gradeSubjectPath = gradeFindingTargetPath(task.approach, deliverable, refs);
|
|
771
|
-
const values = {
|
|
772
|
-
_FRONTMATTER_: frontmatter(meta),
|
|
773
|
-
_TASK_ID_: task.id,
|
|
774
|
-
_PHASE_DESCRIPTION_: phaseDescriptionText(task),
|
|
775
|
-
_DELIVERABLE_NAME_: deliverableName(deliverable),
|
|
776
|
-
_DELIVERABLE_DEPENDS_ON_: deliverableDependsOn(deliverable, projectId, catalogPath),
|
|
777
|
-
_PROJECT_CONTEXT_: projectContextSection(projectContext, deliverable, task.approach, projectId),
|
|
778
|
-
_DELIVERABLE_OVERVIEW_: deliverableOverview(deliverable),
|
|
779
|
-
_IMPLEMENTATION_EVIDENCE_: implementationEvidence(deliverable),
|
|
780
|
-
_DELIVERABLE_PATH_: deliverablePath(deliverable),
|
|
781
|
-
_RESULT_REF_: resultRef,
|
|
782
|
-
_RULEBOOK_REF_: refs.rulebook,
|
|
783
|
-
_RULEBOOK_INCLUDES_: rulebookIncludesText(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind),
|
|
784
|
-
_RECIPE_REF_: refs.recipe,
|
|
785
|
-
_SAMPLE_REF_: refs.sample,
|
|
786
|
-
_TEMPLATE_REF_: refs.template,
|
|
787
|
-
_GRADE_SUBJECT_PATH_: gradeSubjectPath,
|
|
788
|
-
_GRADE_TARGET_: gradeTargetKind(task.approach),
|
|
789
|
-
_GRADE_RESULT_PATH_: gradeResultRef(projectId, gradeSubjectPath),
|
|
790
|
-
_GRADE_SUMMARY_: reviewGradeSummaryText(projectId, gradeSubjectPath, reviewGradeOutcome),
|
|
791
|
-
_DONE_CRITERIA_ROWS_: reviewDoneCriteriaRows(applicableCriteria),
|
|
792
|
-
};
|
|
793
|
-
return expandTemplate(template, values);
|
|
794
|
-
}
|
|
795
|
-
async function writeTaskPlan(ctx, task, override) {
|
|
796
|
-
const mode = task.mode ?? "edit";
|
|
797
|
-
const localId = task.local_id;
|
|
798
|
-
const targetLocalIds = [...new Set(task.target_local_ids ?? [])];
|
|
799
|
-
const crossDeliverables = new Map();
|
|
800
|
-
for (const targetLocalId of targetLocalIds) {
|
|
801
|
-
const info = ctx.catalogPath ? findDeliverableInfo(ctx.catalogPath, targetLocalId) : null;
|
|
802
|
-
if (info)
|
|
803
|
-
crossDeliverables.set(targetLocalId, info);
|
|
804
|
-
}
|
|
805
|
-
const deliverable = override?.deliverable !== undefined
|
|
806
|
-
? override.deliverable
|
|
807
|
-
: localId && ctx.catalogPath
|
|
808
|
-
? findDeliverableInfo(ctx.catalogPath, localId)
|
|
809
|
-
: null;
|
|
810
|
-
// The stem links a plan to its result (both share `<stem>-{plan,result}.md` and the doc id).
|
|
811
|
-
// Defaults to the task id (fixed-name worktree/claim flow); in-place callers pass a unique stem.
|
|
812
|
-
const stem = override?.stem ?? task.id;
|
|
813
|
-
const resultRef = `${repoRelativePath(ctx.executionPath)}/exec/results/${stem}-result.md`;
|
|
814
|
-
const outPath = override?.outPath ?? join(ctx.plansDir, `${stem}-plan.md`);
|
|
815
|
-
const criteria = deliverable?.deliverable.done_criteria ?? [];
|
|
816
|
-
if ((task.execution ?? "agent") === "human") {
|
|
817
|
-
throw new Error(`Task ${task.id} has execution: human; claim it to create and use its result instead of a plan.`);
|
|
818
|
-
}
|
|
819
|
-
const planTask = { ...task, mode };
|
|
820
|
-
if (task.approach === "retrofit" && implementationEvidence(deliverable) === MISSING) {
|
|
821
|
-
throw new Error(`Task ${task.id} uses approach: retrofit but the target deliverable has no evidence_refs.`);
|
|
822
|
-
}
|
|
823
|
-
const template = loadPlanTemplate(mode, task.approach, ctx.templateCache);
|
|
824
|
-
const body = mode === "review"
|
|
825
|
-
? buildReviewPlanMarkdown(template, planTask, deliverable, criteria, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, ctx.reviewGradeOutcome)
|
|
826
|
-
: buildEditPlanMarkdown(template, planTask, deliverable, ctx.roleMap, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, crossDeliverables);
|
|
827
|
-
const schemaRef = resolveDeliverableSchemaRef(deliverable?.resolvedPath);
|
|
828
|
-
const content = injectCommonConventions(body, schemaRef, ctx.templateCache, mode);
|
|
829
|
-
writeFileSync(outPath, content, "utf8");
|
|
830
|
-
await formatMarkdownFile(outPath);
|
|
831
|
-
return outPath;
|
|
832
|
-
}
|
|
833
|
-
// Generate the plan for a single agent task without touching other plan files,
|
|
834
|
-
// the index, or task state. Human tasks are result-only and are rejected here.
|
|
835
|
-
export async function generateSinglePlan(opts) {
|
|
836
|
-
if ((opts.task.execution ?? "agent") === "human") {
|
|
837
|
-
throw new Error(`Task ${opts.task.id} has execution: human; claim it to create and use its result instead of a plan.`);
|
|
838
|
-
}
|
|
839
|
-
const ctx = newPlanGenContext(opts);
|
|
840
|
-
if (opts.reviewGradeOutcome)
|
|
841
|
-
ctx.reviewGradeOutcome = opts.reviewGradeOutcome;
|
|
842
|
-
const override = opts.outPath || opts.stem
|
|
843
|
-
? {
|
|
844
|
-
...(opts.outPath ? { outPath: opts.outPath } : {}),
|
|
845
|
-
...(opts.stem ? { stem: opts.stem } : {}),
|
|
846
|
-
}
|
|
847
|
-
: undefined;
|
|
848
|
-
return await writeTaskPlan(ctx, { ...opts.task, mode: opts.task.mode ?? "edit" }, override);
|
|
849
|
-
}
|
|
850
|
-
// Generate a plan directly from a catalog deliverable, independent of the
|
|
851
|
-
// schedule. The slug (`<domain>-<local_id>`) names the plan unless `outPath`
|
|
852
|
-
// overrides it. CPM is absent for ad-hoc targets; owner is absent unless the
|
|
853
|
-
// caller resolves it (e.g. from sch-strategy owner_rules via a track).
|
|
854
|
-
export async function generateDeliverablePlan(opts) {
|
|
855
|
-
const ctx = newPlanGenContext(opts);
|
|
856
|
-
const task = {
|
|
857
|
-
id: opts.target.slug,
|
|
858
|
-
local_id: opts.target.localId,
|
|
859
|
-
name: opts.target.info.deliverable.name,
|
|
860
|
-
mode: opts.mode ?? "edit",
|
|
861
|
-
...(opts.approach ? { approach: opts.approach } : {}),
|
|
862
|
-
...(opts.owner ? { owner: opts.owner } : {}),
|
|
863
|
-
schedule_file: "",
|
|
864
|
-
fifo_rank: 0,
|
|
865
|
-
critical_first_rank: 0,
|
|
866
|
-
};
|
|
867
|
-
return await writeTaskPlan(ctx, task, {
|
|
868
|
-
deliverable: opts.target.info,
|
|
869
|
-
...(opts.outPath ? { outPath: opts.outPath } : {}),
|
|
870
|
-
...(opts.stem ? { stem: opts.stem } : {}),
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
function newPlanGenContext(opts) {
|
|
874
|
-
const plansDir = join(opts.executionPath, "exec", "plans");
|
|
875
|
-
mkdirSync(plansDir, { recursive: true });
|
|
876
|
-
return {
|
|
877
|
-
plansDir,
|
|
878
|
-
executionPath: opts.executionPath,
|
|
879
|
-
projectId: opts.projectId,
|
|
880
|
-
catalogPath: opts.catalogPath,
|
|
881
|
-
vpMap: opts.viewpointsPath
|
|
882
|
-
? loadViewpoints(opts.viewpointsPath)
|
|
883
|
-
: new Map(),
|
|
884
|
-
roleMap: loadRoles(opts.rolesPath),
|
|
885
|
-
projectContext: [
|
|
886
|
-
...(opts.projectContext ??
|
|
887
|
-
(opts.projectId ? DEFAULT_PROJECT_CONTEXT : [])),
|
|
888
|
-
],
|
|
889
|
-
templateCache: new Map(),
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
// Move a completed plan to exec/plans/done/ with a unique UTC + random suffix
|
|
893
|
-
// (same convention as event filenames), or delete it. The plan is regenerable
|
|
894
|
-
// from the catalog, so deletion is safe; the result remains as the record.
|
|
895
|
-
export function archivePlan(opts) {
|
|
896
|
-
const plansDir = join(opts.executionPath, "exec", "plans");
|
|
897
|
-
const from = join(plansDir, `${opts.slug}-plan.md`);
|
|
898
|
-
if (!existsSync(from))
|
|
899
|
-
throw new Error(`plan not found: ${from}`);
|
|
900
|
-
if (opts.delete) {
|
|
901
|
-
rmSync(from, { force: true });
|
|
902
|
-
return { from, deleted: true };
|
|
903
|
-
}
|
|
904
|
-
const doneDir = join(plansDir, "done");
|
|
905
|
-
mkdirSync(doneDir, { recursive: true });
|
|
906
|
-
const stamp = tsForFilenameUtc(nowUtcIsoSeconds());
|
|
907
|
-
const to = join(doneDir, `${opts.slug}-${stamp}-${randomHex(2)}-plan.md`);
|
|
908
|
-
renameSync(from, to);
|
|
909
|
-
return { from, to, deleted: false };
|
|
910
|
-
}
|
|
911
|
-
export function planPathForTask(executionPath, taskId) {
|
|
912
|
-
return join(executionPath, "exec", "plans", `${taskId}-plan.md`);
|
|
913
|
-
}
|
|
914
|
-
export function loadPlan(executionPath, taskId) {
|
|
915
|
-
const planPath = planPathForTask(executionPath, taskId);
|
|
916
|
-
if (existsSync(planPath))
|
|
917
|
-
return readFileSync(planPath, "utf8");
|
|
918
|
-
return null;
|
|
919
|
-
}
|
|
920
|
-
const PLAN_APPROACHES = [
|
|
921
|
-
"fully-guided",
|
|
922
|
-
"recipe-guided",
|
|
923
|
-
"freeform",
|
|
924
|
-
"bootstrap",
|
|
925
|
-
"retrofit",
|
|
926
|
-
"cross-deliverable-dedup",
|
|
927
|
-
"rulebook-maintenance",
|
|
928
|
-
"recipe-maintenance",
|
|
929
|
-
"sample-maintenance",
|
|
930
|
-
"template-maintenance",
|
|
931
|
-
"finalize",
|
|
932
|
-
"bootstrap-finalize",
|
|
933
|
-
];
|
|
934
|
-
// Parse an exec-plan file's frontmatter to recover the task identity. Returns
|
|
935
|
-
// null when the frontmatter is missing or has no usable task_id, in which case
|
|
936
|
-
// the caller treats the plan as an ad-hoc plan with no managed identity.
|
|
937
|
-
export function parsePlanTaskIdentity(planContent) {
|
|
938
|
-
// exec-plan frontmatter は `specdojo:` 名前空間配下にある。
|
|
939
|
-
const parsed = readSpecdojoNamespace(planContent);
|
|
940
|
-
const taskId = typeof parsed.task_id === "string" ? parsed.task_id.trim() : "";
|
|
941
|
-
if (!taskId)
|
|
942
|
-
return null;
|
|
943
|
-
const mode = parsed.mode === "review" ? "review" : "edit";
|
|
944
|
-
const projectId = typeof parsed.project_id === "string" ? parsed.project_id.trim() : "";
|
|
945
|
-
const approach = typeof parsed.approach === "string" &&
|
|
946
|
-
PLAN_APPROACHES.includes(parsed.approach)
|
|
947
|
-
? parsed.approach
|
|
948
|
-
: undefined;
|
|
949
|
-
const targets = Array.isArray(parsed.targets)
|
|
950
|
-
? parsed.targets.filter((entry) => typeof entry === "string")
|
|
951
|
-
: [];
|
|
952
|
-
// 未知の値は採用せず undefined(= schedule)として扱う。
|
|
953
|
-
const origin = parsed.origin === "register" || parsed.origin === "schedule"
|
|
954
|
-
? parsed.origin
|
|
955
|
-
: undefined;
|
|
956
|
-
return {
|
|
957
|
-
taskId,
|
|
958
|
-
mode,
|
|
959
|
-
projectId,
|
|
960
|
-
approach,
|
|
961
|
-
...(origin ? { origin } : {}),
|
|
962
|
-
...(targets.length > 0 ? { targets } : {}),
|
|
963
|
-
};
|
|
964
|
-
}
|
|
965
|
-
export function registerGradeFindingsText(projectId, ticketPath) {
|
|
966
|
-
if (!existsSync(ticketPath))
|
|
967
|
-
return "- なし";
|
|
968
|
-
const content = readFileSync(ticketPath, "utf8");
|
|
969
|
-
const metadata = readSpecdojoNamespace(content);
|
|
970
|
-
const targets = Array.isArray(metadata.targets)
|
|
971
|
-
? metadata.targets
|
|
972
|
-
.filter((target) => typeof target === "string")
|
|
973
|
-
.map((target) => target.trim())
|
|
974
|
-
.filter((target) => target.length > 0)
|
|
975
|
-
: [];
|
|
976
|
-
if (targets.length === 0)
|
|
977
|
-
return "- なし";
|
|
978
|
-
const docIndexPath = join(specdojoRootDir(), ".specdojo", "doc-index.json");
|
|
979
|
-
const MAX_DOCS = 10;
|
|
980
|
-
const MAX_FINDINGS = 20;
|
|
981
|
-
const lines = [];
|
|
982
|
-
let docCount = 0;
|
|
983
|
-
for (const id of targets) {
|
|
984
|
-
if (docCount >= MAX_DOCS) {
|
|
985
|
-
lines.push(`- その他 ${targets.length - MAX_DOCS} 件の文書は省略されました`);
|
|
986
|
-
break;
|
|
987
|
-
}
|
|
988
|
-
const targetPath = lookupDocIndex(id, docIndexPath);
|
|
989
|
-
if (!targetPath)
|
|
990
|
-
continue;
|
|
991
|
-
const result = readGradeResultForDocument({ documentPath: targetPath, project: projectId });
|
|
992
|
-
if (!result || result.findings.length === 0) {
|
|
993
|
-
lines.push(`- [[${id}]]: finding なし`);
|
|
994
|
-
docCount++;
|
|
995
|
-
continue;
|
|
996
|
-
}
|
|
997
|
-
const sidecarPath = gradeResultPathForDocument({
|
|
998
|
-
documentPath: targetPath,
|
|
999
|
-
project: projectId,
|
|
1000
|
-
});
|
|
1001
|
-
// Use posix separators
|
|
1002
|
-
const sidecarRel = relative(specdojoRootDir(), sidecarPath).replace(/\\/g, "/");
|
|
1003
|
-
lines.push(`- [[${id}]] (サイドカー: \`${sidecarRel}\`):`);
|
|
1004
|
-
let findingCount = 0;
|
|
1005
|
-
for (const finding of result.findings) {
|
|
1006
|
-
if (findingCount >= MAX_FINDINGS) {
|
|
1007
|
-
lines.push(` - 他 ${result.findings.length - MAX_FINDINGS} 件の finding があります。詳細はサイドカーを参照してください。`);
|
|
1008
|
-
break;
|
|
1009
|
-
}
|
|
1010
|
-
lines.push(` - [${finding.severity}/${finding.rule}; line=${finding.line}; anchor=${JSON.stringify(finding.anchor)}]: ${gradeFindingDisplayMessage(finding)}`);
|
|
1011
|
-
findingCount++;
|
|
1012
|
-
}
|
|
1013
|
-
docCount++;
|
|
1014
|
-
}
|
|
1015
|
-
if (lines.length === 0)
|
|
1016
|
-
return "- なし";
|
|
1017
|
-
return lines.join("\n");
|
|
1018
|
-
}
|
|
1
|
+
export { MISSING, applicableReviewCriteria, buildInPlaceStem, deliverableDocId, deliverableDocPath, execTemplatePath, execTemplatesDir, finalizeResultSectionsForDeliverable, injectCommonConventions, ownerRoleFields, resolveDeliverableTarget, reviewGradeSubject, stemFromPlanPath, targetDocIdsForDeliverable, targetDocIdsForScheduledTask, targetReferenceDirsForApproach, } from "./exec-plans-core.js";
|
|
2
|
+
export { generateDeliverablePlan, generateSinglePlan } from "./exec-plans-generation.js";
|
|
3
|
+
export { archivePlan, loadPlan, parsePlanTaskIdentity, planPathForTask, registerGradeFindingsText, } from "./exec-plans-storage.js";
|