specdojo 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/catalog-build-references.js +144 -0
  3. package/dist/catalog-build-render.js +144 -0
  4. package/dist/catalog-build.js +13 -290
  5. package/dist/catalog-generate.js +6 -9
  6. package/dist/catalog-plan-generate.js +2 -2
  7. package/dist/catalog-plan.js +6 -6
  8. package/dist/catalog-scaffold.js +4 -4
  9. package/dist/catalog.js +2 -2
  10. package/dist/dashboard-exec-records.js +105 -0
  11. package/dist/dashboard-routines.js +255 -0
  12. package/dist/dashboard-shared.js +14 -0
  13. package/dist/dashboard-timeline.js +175 -0
  14. package/dist/dashboard.js +10 -544
  15. package/dist/deliverable-trash.js +3 -3
  16. package/dist/doc-index.js +3 -3
  17. package/dist/exec-commands.js +557 -0
  18. package/dist/exec-core.js +457 -0
  19. package/dist/exec-plans-core.js +693 -0
  20. package/dist/exec-plans-generation.js +206 -0
  21. package/dist/exec-plans-storage.js +131 -0
  22. package/dist/exec-plans.js +3 -1018
  23. package/dist/exec-repo-integration-git.js +23 -0
  24. package/dist/exec-repo-integration-sync.js +264 -0
  25. package/dist/exec-repo-integration.js +4 -281
  26. package/dist/exec-reporter-output.js +206 -0
  27. package/dist/exec-reporter.js +2 -206
  28. package/dist/exec-results.js +22 -15
  29. package/dist/exec-run-agent-pipeline.js +256 -0
  30. package/dist/exec-run-agent.js +531 -0
  31. package/dist/exec-run-in-place.js +541 -0
  32. package/dist/exec-run-job.js +717 -0
  33. package/dist/exec-run-lifecycle-commands.js +522 -0
  34. package/dist/exec-run-mode-shared.js +140 -0
  35. package/dist/exec-run-register-command.js +244 -0
  36. package/dist/exec-run-register-core.js +386 -0
  37. package/dist/exec-run-register-mode.js +206 -0
  38. package/dist/exec-run-register-resume.js +393 -0
  39. package/dist/exec-run-register-state.js +322 -0
  40. package/dist/exec-run-register-worktree.js +509 -0
  41. package/dist/exec-run-schedule-mode.js +294 -0
  42. package/dist/exec-run-schedule-prepare.js +353 -0
  43. package/dist/exec-run-schedule-task.js +572 -0
  44. package/dist/exec-run-shared.js +399 -0
  45. package/dist/exec-run.js +11 -6182
  46. package/dist/exec-shared.js +2 -2
  47. package/dist/exec-trial-commands.js +558 -0
  48. package/dist/exec-trial-core.js +371 -0
  49. package/dist/exec-trial.js +2 -921
  50. package/dist/exec-worktree-ops-commit.js +707 -0
  51. package/dist/exec-worktree-ops-lifecycle.js +292 -0
  52. package/dist/exec-worktree-ops-merge.js +303 -0
  53. package/dist/exec-worktree-ops.js +3 -1292
  54. package/dist/exec-worktree.js +32 -4
  55. package/dist/exec.js +2 -1006
  56. package/dist/frontmatter-namespace.js +2 -2
  57. package/dist/grade-apply.js +734 -0
  58. package/dist/grade-command-apply.js +250 -0
  59. package/dist/grade-command-inspect.js +138 -0
  60. package/dist/grade-command-plan.js +101 -0
  61. package/dist/grade-command-shared.js +68 -0
  62. package/dist/grade-core.js +307 -0
  63. package/dist/grade-markdown.js +274 -0
  64. package/dist/grade-pipeline-state.js +184 -0
  65. package/dist/grade-plan.js +507 -0
  66. package/dist/grade-result.js +5 -5
  67. package/dist/grade-target-discovery.js +265 -0
  68. package/dist/grade-targets.js +432 -0
  69. package/dist/grade.js +14 -3188
  70. package/dist/init-command.js +7 -7
  71. package/dist/job-definition.js +670 -0
  72. package/dist/job.js +9 -673
  73. package/dist/kata-command.js +2 -2
  74. package/dist/register-command-types.js +1 -0
  75. package/dist/register-core.js +363 -0
  76. package/dist/register-create-commands.js +245 -0
  77. package/dist/register-events.js +4 -4
  78. package/dist/register-item.js +6 -6
  79. package/dist/register-maintenance-commands.js +187 -0
  80. package/dist/register-migration.js +268 -0
  81. package/dist/register-renumber.js +314 -0
  82. package/dist/register-transition-commands.js +248 -0
  83. package/dist/register-update.js +230 -0
  84. package/dist/register-views.js +256 -0
  85. package/dist/register.js +61 -2069
  86. package/dist/review-plan.js +3 -3
  87. package/dist/routine-definition.js +401 -0
  88. package/dist/routine.js +6 -402
  89. package/dist/schedule-approach.js +2 -2
  90. package/dist/schedule-strategy-generate-document.js +273 -0
  91. package/dist/schedule-strategy-generate-scope.js +199 -0
  92. package/dist/schedule-strategy-generate.js +9 -473
  93. package/dist/schedule.js +4 -4
  94. package/dist/specdojo-config.js +3 -4
  95. package/dist/viewpoint-document-kinds-check.js +3 -3
  96. package/dist/yaml-pages.js +4 -4
  97. package/dist/yaml.js +28 -0
  98. package/docs/ja/specdojo/guides/exec-config-guide.md +6 -6
  99. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +20 -18
  100. package/docs/ja/specdojo/guides/routine-operation-guide.md +1 -1
  101. package/package.json +4 -5
  102. package/templates/antigravity/README.md +3 -3
  103. package/templates/antigravity/exec-defaults-snippet.yaml +6 -4
  104. package/templates/init-exec-defaults.yaml +3 -1
@@ -0,0 +1,206 @@
1
+ import { mkdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { DEFAULT_PROJECT_CONTEXT } from "./specdojo-config.js";
4
+ import { resolveDeliverableSchemaRef, resolveKataRefs } from "./kata.js";
5
+ import { formatMarkdownFile } from "./exec-format.js";
6
+ import { expandTemplate } from "./exec-shared.js";
7
+ import { MISSING, applicableReviewCriteria, crossDeliverableTargetDetails, deliverableDependsOn, deliverableName, deliverableOverview, deliverablePath, doneCriteriaChecklist, doneCriteriaGoals, doneCriteriaItems, execDocId, findDeliverableInfo, frontmatter, gradeFindingsText, gradeFindingTargetPath, gradeResultRef, gradeTargetKind, implementationEvidence, injectCommonConventions, kataRefState, loadPlanTemplate, loadRoles, loadViewpoints, ownerRoleFields, phaseDescriptionText, projectContextSection, repoRelativePath, reviewDoneCriteriaRows, reviewGradeSummaryText, rulebookIncludesText, targetDocIds, targetDocIdsForTask, } from "./exec-plans-core.js";
8
+ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, projectId, catalogPath, projectContext, resultRef, stem, crossDeliverables = new Map()) {
9
+ const cpm = task.cpm;
10
+ const onCriticalPath = cpm !== undefined && cpm.slack === 0;
11
+ const targets = targetDocIdsForTask(projectId, task, deliverable, crossDeliverables);
12
+ const meta = {
13
+ id: execDocId(projectId, "xep", stem),
14
+ type: "exec-plan",
15
+ rulebook: "none",
16
+ task_id: task.id,
17
+ ...(task.name ? { name: task.name } : {}),
18
+ mode: "edit",
19
+ status: "ready",
20
+ project_id: projectId,
21
+ ...(task.owner ? { owner: task.owner } : {}),
22
+ ...(onCriticalPath ? { on_critical_path: true } : {}),
23
+ ...(task.approach ? { approach: task.approach } : {}),
24
+ ...(targets.length > 0 ? { targets } : {}),
25
+ };
26
+ const criteria = deliverable?.deliverable.done_criteria ?? [];
27
+ const ownerRole = ownerRoleFields(task.owner, roleMap, vpMap, deliverable?.deliverable.rulebook);
28
+ const refs = resolveKataRefs(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind);
29
+ const values = {
30
+ _FRONTMATTER_: frontmatter(meta),
31
+ _TASK_ID_: task.id,
32
+ _PHASE_DESCRIPTION_: phaseDescriptionText(task),
33
+ _DELIVERABLE_NAME_: deliverableName(deliverable),
34
+ _DELIVERABLE_DEPENDS_ON_: deliverableDependsOn(deliverable, projectId, catalogPath),
35
+ _PROJECT_CONTEXT_: projectContextSection(projectContext, deliverable, task.approach, projectId),
36
+ _DELIVERABLE_OVERVIEW_: deliverableOverview(deliverable),
37
+ _IMPLEMENTATION_EVIDENCE_: implementationEvidence(deliverable),
38
+ _DELIVERABLE_PATH_: deliverablePath(deliverable),
39
+ _RESULT_REF_: resultRef,
40
+ _RULEBOOK_REF_: refs.rulebook,
41
+ _RULEBOOK_STATE_: kataRefState(refs.rulebook),
42
+ _RULEBOOK_INCLUDES_: rulebookIncludesText(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind),
43
+ _RECIPE_REF_: refs.recipe,
44
+ _RECIPE_STATE_: kataRefState(refs.recipe),
45
+ _SAMPLE_REF_: refs.sample,
46
+ _SAMPLE_STATE_: kataRefState(refs.sample),
47
+ _TEMPLATE_REF_: refs.template,
48
+ _TEMPLATE_STATE_: kataRefState(refs.template),
49
+ _OWNER_ROLE_LABEL_: ownerRole.label,
50
+ _OWNER_ROLE_NOTE_: ownerRole.note,
51
+ _OWNER_ROLE_VIEWPOINTS_: ownerRole.viewpoints,
52
+ _DONE_CRITERIA_GOALS_: doneCriteriaGoals(criteria, task.owner),
53
+ _DONE_CRITERIA_CHECKLIST_: doneCriteriaChecklist(criteria),
54
+ _DONE_CRITERIA_ITEMS_: doneCriteriaItems(criteria),
55
+ _GRADE_FINDINGS_: gradeFindingsText(projectId, gradeFindingTargetPath(task.approach, deliverable, refs)),
56
+ _TARGET_DELIVERABLES_: crossDeliverableTargetDetails(projectId, task.target_local_ids ?? [], crossDeliverables, catalogPath),
57
+ };
58
+ return expandTemplate(template, values);
59
+ }
60
+ // review plan は成果物を再評価しない。grade の評価結果(サイドカー)の位置と完了条件を示し、
61
+ // 評価結果を事実として受け取ってタスクの完了可否を判断させる(bps-task-completion)。
62
+ function buildReviewPlanMarkdown(template, task, deliverable, criteria, vpMap, projectId, catalogPath, projectContext, resultRef, stem, reviewGradeOutcome) {
63
+ const cpm = task.cpm;
64
+ const onCriticalPath = cpm !== undefined && cpm.slack === 0;
65
+ const targets = targetDocIds(projectId, deliverable, task.approach, task.local_id);
66
+ const meta = {
67
+ id: execDocId(projectId, "xrp", stem),
68
+ type: "exec-plan",
69
+ rulebook: "none",
70
+ task_id: task.id,
71
+ ...(task.name ? { name: task.name } : {}),
72
+ mode: "review",
73
+ status: "ready",
74
+ project_id: projectId,
75
+ ...(task.owner ? { owner: task.owner } : {}),
76
+ ...(onCriticalPath ? { on_critical_path: true } : {}),
77
+ ...(task.approach ? { approach: task.approach } : {}),
78
+ ...(targets.length > 0 ? { targets } : {}),
79
+ };
80
+ const refs = resolveKataRefs(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind);
81
+ const applicableCriteria = applicableReviewCriteria(criteria, vpMap, deliverable?.deliverable.rulebook);
82
+ const gradeSubjectPath = gradeFindingTargetPath(task.approach, deliverable, refs);
83
+ const values = {
84
+ _FRONTMATTER_: frontmatter(meta),
85
+ _TASK_ID_: task.id,
86
+ _PHASE_DESCRIPTION_: phaseDescriptionText(task),
87
+ _DELIVERABLE_NAME_: deliverableName(deliverable),
88
+ _DELIVERABLE_DEPENDS_ON_: deliverableDependsOn(deliverable, projectId, catalogPath),
89
+ _PROJECT_CONTEXT_: projectContextSection(projectContext, deliverable, task.approach, projectId),
90
+ _DELIVERABLE_OVERVIEW_: deliverableOverview(deliverable),
91
+ _IMPLEMENTATION_EVIDENCE_: implementationEvidence(deliverable),
92
+ _DELIVERABLE_PATH_: deliverablePath(deliverable),
93
+ _RESULT_REF_: resultRef,
94
+ _RULEBOOK_REF_: refs.rulebook,
95
+ _RULEBOOK_INCLUDES_: rulebookIncludesText(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind),
96
+ _RECIPE_REF_: refs.recipe,
97
+ _SAMPLE_REF_: refs.sample,
98
+ _TEMPLATE_REF_: refs.template,
99
+ _GRADE_SUBJECT_PATH_: gradeSubjectPath,
100
+ _GRADE_TARGET_: gradeTargetKind(task.approach),
101
+ _GRADE_RESULT_PATH_: gradeResultRef(projectId, gradeSubjectPath),
102
+ _GRADE_SUMMARY_: reviewGradeSummaryText(projectId, gradeSubjectPath, reviewGradeOutcome),
103
+ _DONE_CRITERIA_ROWS_: reviewDoneCriteriaRows(applicableCriteria),
104
+ };
105
+ return expandTemplate(template, values);
106
+ }
107
+ async function writeTaskPlan(ctx, task, override) {
108
+ const mode = task.mode ?? "edit";
109
+ const localId = task.local_id;
110
+ const targetLocalIds = [...new Set(task.target_local_ids ?? [])];
111
+ const crossDeliverables = new Map();
112
+ for (const targetLocalId of targetLocalIds) {
113
+ const info = ctx.catalogPath ? findDeliverableInfo(ctx.catalogPath, targetLocalId) : null;
114
+ if (info)
115
+ crossDeliverables.set(targetLocalId, info);
116
+ }
117
+ const deliverable = override?.deliverable !== undefined
118
+ ? override.deliverable
119
+ : localId && ctx.catalogPath
120
+ ? findDeliverableInfo(ctx.catalogPath, localId)
121
+ : null;
122
+ // The stem links a plan to its result (both share `<stem>-{plan,result}.md` and the doc id).
123
+ // Defaults to the task id (fixed-name worktree/claim flow); in-place callers pass a unique stem.
124
+ const stem = override?.stem ?? task.id;
125
+ const resultRef = `${repoRelativePath(ctx.executionPath)}/exec/results/${stem}-result.md`;
126
+ const outPath = override?.outPath ?? join(ctx.plansDir, `${stem}-plan.md`);
127
+ const criteria = deliverable?.deliverable.done_criteria ?? [];
128
+ if ((task.execution ?? "agent") === "human") {
129
+ throw new Error(`Task ${task.id} has execution: human; claim it to create and use its result instead of a plan.`);
130
+ }
131
+ const planTask = { ...task, mode };
132
+ if (task.approach === "retrofit" && implementationEvidence(deliverable) === MISSING) {
133
+ throw new Error(`Task ${task.id} uses approach: retrofit but the target deliverable has no evidence_refs.`);
134
+ }
135
+ const template = loadPlanTemplate(mode, task.approach, ctx.templateCache);
136
+ const body = mode === "review"
137
+ ? buildReviewPlanMarkdown(template, planTask, deliverable, criteria, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, ctx.reviewGradeOutcome)
138
+ : buildEditPlanMarkdown(template, planTask, deliverable, ctx.roleMap, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, crossDeliverables);
139
+ const schemaRef = resolveDeliverableSchemaRef(deliverable?.resolvedPath);
140
+ const content = injectCommonConventions(body, schemaRef, ctx.templateCache, mode);
141
+ writeFileSync(outPath, content, "utf8");
142
+ await formatMarkdownFile(outPath);
143
+ return outPath;
144
+ }
145
+ // Generate the plan for a single agent task without touching other plan files,
146
+ // the index, or task state. Human tasks are result-only and are rejected here.
147
+ export async function generateSinglePlan(opts) {
148
+ if ((opts.task.execution ?? "agent") === "human") {
149
+ throw new Error(`Task ${opts.task.id} has execution: human; claim it to create and use its result instead of a plan.`);
150
+ }
151
+ const ctx = newPlanGenContext(opts);
152
+ if (opts.reviewGradeOutcome)
153
+ ctx.reviewGradeOutcome = opts.reviewGradeOutcome;
154
+ const override = opts.outPath || opts.stem
155
+ ? {
156
+ ...(opts.outPath ? { outPath: opts.outPath } : {}),
157
+ ...(opts.stem ? { stem: opts.stem } : {}),
158
+ }
159
+ : undefined;
160
+ return await writeTaskPlan(ctx, { ...opts.task, mode: opts.task.mode ?? "edit" }, override);
161
+ }
162
+ // Generate a plan directly from a catalog deliverable, independent of the
163
+ // schedule. The slug (`<domain>-<local_id>`) names the plan unless `outPath`
164
+ // overrides it. CPM is absent for ad-hoc targets; owner is absent unless the
165
+ // caller resolves it (e.g. from sch-strategy owner_rules via a track).
166
+ export async function generateDeliverablePlan(opts) {
167
+ const ctx = newPlanGenContext(opts);
168
+ const task = {
169
+ id: opts.target.slug,
170
+ local_id: opts.target.localId,
171
+ name: opts.target.info.deliverable.name,
172
+ mode: opts.mode ?? "edit",
173
+ ...(opts.approach ? { approach: opts.approach } : {}),
174
+ ...(opts.owner ? { owner: opts.owner } : {}),
175
+ schedule_file: "",
176
+ fifo_rank: 0,
177
+ critical_first_rank: 0,
178
+ };
179
+ return await writeTaskPlan(ctx, task, {
180
+ deliverable: opts.target.info,
181
+ ...(opts.outPath ? { outPath: opts.outPath } : {}),
182
+ ...(opts.stem ? { stem: opts.stem } : {}),
183
+ });
184
+ }
185
+ function newPlanGenContext(opts) {
186
+ const plansDir = join(opts.executionPath, "exec", "plans");
187
+ mkdirSync(plansDir, { recursive: true });
188
+ return {
189
+ plansDir,
190
+ executionPath: opts.executionPath,
191
+ projectId: opts.projectId,
192
+ catalogPath: opts.catalogPath,
193
+ vpMap: opts.viewpointsPath
194
+ ? loadViewpoints(opts.viewpointsPath)
195
+ : new Map(),
196
+ roleMap: loadRoles(opts.rolesPath),
197
+ projectContext: [
198
+ ...(opts.projectContext ??
199
+ (opts.projectId ? DEFAULT_PROJECT_CONTEXT : [])),
200
+ ],
201
+ templateCache: new Map(),
202
+ };
203
+ }
204
+ // Move a completed plan to exec/plans/done/ with a unique UTC + random suffix
205
+ // (same convention as event filenames), or delete it. The plan is regenerable
206
+ // from the catalog, so deletion is safe; the result remains as the record.
@@ -0,0 +1,131 @@
1
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync } from "node:fs";
2
+ import { join, relative } from "node:path";
3
+ import { specdojoRootDir } from "./specdojo-config.js";
4
+ import { nowUtcIsoSeconds, randomHex, tsForFilenameUtc } from "./exec-shared.js";
5
+ import { readSpecdojoNamespace } from "./frontmatter-namespace.js";
6
+ import { gradeFindingDisplayMessage, gradeResultPathForDocument, readGradeResultForDocument, } from "./grade-result.js";
7
+ import { lookupDocIndex } from "./doc-index.js";
8
+ export function archivePlan(opts) {
9
+ const plansDir = join(opts.executionPath, "exec", "plans");
10
+ const from = join(plansDir, `${opts.slug}-plan.md`);
11
+ if (!existsSync(from))
12
+ throw new Error(`plan not found: ${from}`);
13
+ if (opts.delete) {
14
+ rmSync(from, { force: true });
15
+ return { from, deleted: true };
16
+ }
17
+ const doneDir = join(plansDir, "done");
18
+ mkdirSync(doneDir, { recursive: true });
19
+ const stamp = tsForFilenameUtc(nowUtcIsoSeconds());
20
+ const to = join(doneDir, `${opts.slug}-${stamp}-${randomHex(2)}-plan.md`);
21
+ renameSync(from, to);
22
+ return { from, to, deleted: false };
23
+ }
24
+ export function planPathForTask(executionPath, taskId) {
25
+ return join(executionPath, "exec", "plans", `${taskId}-plan.md`);
26
+ }
27
+ export function loadPlan(executionPath, taskId) {
28
+ const planPath = planPathForTask(executionPath, taskId);
29
+ if (existsSync(planPath))
30
+ return readFileSync(planPath, "utf8");
31
+ return null;
32
+ }
33
+ const PLAN_APPROACHES = [
34
+ "fully-guided",
35
+ "recipe-guided",
36
+ "freeform",
37
+ "bootstrap",
38
+ "retrofit",
39
+ "cross-deliverable-dedup",
40
+ "rulebook-maintenance",
41
+ "recipe-maintenance",
42
+ "sample-maintenance",
43
+ "template-maintenance",
44
+ "finalize",
45
+ "bootstrap-finalize",
46
+ ];
47
+ // Parse an exec-plan file's frontmatter to recover the task identity. Returns
48
+ // null when the frontmatter is missing or has no usable task_id, in which case
49
+ // the caller treats the plan as an ad-hoc plan with no managed identity.
50
+ export function parsePlanTaskIdentity(planContent) {
51
+ // exec-plan frontmatter は `specdojo:` 名前空間配下にある。
52
+ const parsed = readSpecdojoNamespace(planContent);
53
+ const taskId = typeof parsed.task_id === "string" ? parsed.task_id.trim() : "";
54
+ if (!taskId)
55
+ return null;
56
+ const mode = parsed.mode === "review" ? "review" : "edit";
57
+ const projectId = typeof parsed.project_id === "string" ? parsed.project_id.trim() : "";
58
+ const approach = typeof parsed.approach === "string" &&
59
+ PLAN_APPROACHES.includes(parsed.approach)
60
+ ? parsed.approach
61
+ : undefined;
62
+ const targets = Array.isArray(parsed.targets)
63
+ ? parsed.targets.filter((entry) => typeof entry === "string")
64
+ : [];
65
+ // 未知の値は採用せず undefined(= schedule)として扱う。
66
+ const origin = parsed.origin === "register" || parsed.origin === "schedule"
67
+ ? parsed.origin
68
+ : undefined;
69
+ return {
70
+ taskId,
71
+ mode,
72
+ projectId,
73
+ approach,
74
+ ...(origin ? { origin } : {}),
75
+ ...(targets.length > 0 ? { targets } : {}),
76
+ };
77
+ }
78
+ export function registerGradeFindingsText(projectId, ticketPath) {
79
+ if (!existsSync(ticketPath))
80
+ return "- なし";
81
+ const content = readFileSync(ticketPath, "utf8");
82
+ const metadata = readSpecdojoNamespace(content);
83
+ const targets = Array.isArray(metadata.targets)
84
+ ? metadata.targets
85
+ .filter((target) => typeof target === "string")
86
+ .map((target) => target.trim())
87
+ .filter((target) => target.length > 0)
88
+ : [];
89
+ if (targets.length === 0)
90
+ return "- なし";
91
+ const docIndexPath = join(specdojoRootDir(), ".specdojo", "doc-index.json");
92
+ const MAX_DOCS = 10;
93
+ const MAX_FINDINGS = 20;
94
+ const lines = [];
95
+ let docCount = 0;
96
+ for (const id of targets) {
97
+ if (docCount >= MAX_DOCS) {
98
+ lines.push(`- その他 ${targets.length - MAX_DOCS} 件の文書は省略されました`);
99
+ break;
100
+ }
101
+ const targetPath = lookupDocIndex(id, docIndexPath);
102
+ if (!targetPath)
103
+ continue;
104
+ const result = readGradeResultForDocument({ documentPath: targetPath, project: projectId });
105
+ if (!result || result.findings.length === 0) {
106
+ lines.push(`- [[${id}]]: finding なし`);
107
+ docCount++;
108
+ continue;
109
+ }
110
+ const sidecarPath = gradeResultPathForDocument({
111
+ documentPath: targetPath,
112
+ project: projectId,
113
+ });
114
+ // Use posix separators
115
+ const sidecarRel = relative(specdojoRootDir(), sidecarPath).replace(/\\/g, "/");
116
+ lines.push(`- [[${id}]] (サイドカー: \`${sidecarRel}\`):`);
117
+ let findingCount = 0;
118
+ for (const finding of result.findings) {
119
+ if (findingCount >= MAX_FINDINGS) {
120
+ lines.push(` - 他 ${result.findings.length - MAX_FINDINGS} 件の finding があります。詳細はサイドカーを参照してください。`);
121
+ break;
122
+ }
123
+ lines.push(` - [${finding.severity}/${finding.rule}; line=${finding.line}; anchor=${JSON.stringify(finding.anchor)}]: ${gradeFindingDisplayMessage(finding)}`);
124
+ findingCount++;
125
+ }
126
+ docCount++;
127
+ }
128
+ if (lines.length === 0)
129
+ return "- なし";
130
+ return lines.join("\n");
131
+ }