specdojo 0.2.1 → 0.3.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/.github/agents/specdojo-orchestrator.md +165 -0
- package/CHANGELOG.md +280 -0
- package/README.md +92 -42
- package/dist/agent-response.js +20 -0
- package/dist/agent.js +4 -4
- package/dist/build-command.js +28 -8
- package/dist/dashboard.js +122 -1
- package/dist/devcontainer-command.js +43 -0
- package/dist/devcontainer-scaffold.js +165 -0
- package/dist/exec-agent-config.js +107 -9
- package/dist/exec-agent-git-state.js +18 -0
- package/dist/exec-agent-protected-config.js +46 -8
- package/dist/exec-evidence.js +254 -11
- package/dist/exec-handoff.js +336 -0
- package/dist/exec-parent-validation.js +317 -43
- package/dist/exec-pipeline-state.js +74 -9
- package/dist/exec-plans.js +115 -113
- package/dist/exec-protection-handoff.js +43 -2
- package/dist/exec-provider-scaffold.js +247 -15
- package/dist/exec-register-resume.js +65 -19
- package/dist/exec-register.js +9 -3
- package/dist/exec-repo-integration.js +811 -0
- package/dist/exec-repo-trace.js +182 -0
- package/dist/exec-reporter.js +613 -132
- package/dist/exec-results.js +81 -56
- package/dist/exec-run-lock.js +110 -107
- package/dist/exec-run.js +1585 -356
- package/dist/exec-shared.js +7 -0
- package/dist/exec-slot-lock.js +242 -0
- package/dist/exec-task-repos.js +415 -0
- package/dist/exec-trial.js +51 -25
- package/dist/exec-worktree-command.js +87 -43
- package/dist/exec-worktree-ops.js +502 -57
- package/dist/exec-worktree.js +114 -27
- package/dist/exec.js +13 -6
- package/dist/grade-result.js +128 -0
- package/dist/grade.js +809 -72
- package/dist/init-command.js +443 -0
- package/dist/job.js +160 -10
- package/dist/orchestrator.js +213 -0
- package/dist/register-event-merge.js +169 -0
- package/dist/register-item.js +7 -1
- package/dist/register.js +294 -86
- package/dist/review-grade.js +252 -0
- package/dist/review-plan.js +111 -1
- package/dist/review-types.js +40 -1
- package/dist/routine.js +72 -5
- package/dist/schedule-build.js +2 -2
- package/dist/schedule.js +17 -4
- package/dist/specdojo-config.js +465 -19
- package/dist/specdojo-gitignore.js +135 -0
- package/dist/specdojo.js +6 -0
- package/dist/viewpoint-document-kinds-check.js +128 -0
- package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +348 -90
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +51 -17
- package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +7 -5
- package/docs/ja/specdojo/exec-templates/xrp-freeform-template.md +29 -31
- package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +34 -55
- package/docs/ja/specdojo/exec-templates/xrp-job-template.md +54 -0
- package/docs/ja/specdojo/exec-templates/xrp-recipe-guided-template.md +28 -37
- package/docs/ja/specdojo/exec-templates/xrp-recipe-maintenance-template.md +29 -34
- package/docs/ja/specdojo/exec-templates/xrp-retrofit-template.md +30 -30
- package/docs/ja/specdojo/exec-templates/xrp-rulebook-maintenance-template.md +29 -34
- package/docs/ja/specdojo/exec-templates/xrp-sample-maintenance-template.md +29 -34
- package/docs/ja/specdojo/exec-templates/xrp-template-maintenance-template.md +29 -34
- package/docs/ja/specdojo/exec-templates/xrp-template.md +29 -28
- package/docs/ja/specdojo/exec-templates/xrr-template.md +11 -9
- package/docs/ja/specdojo/guides/docs-editing-guide.md +20 -0
- package/docs/ja/specdojo/guides/docs-structure-guide.md +103 -70
- package/docs/ja/specdojo/guides/exec-config-guide.md +91 -47
- package/docs/ja/specdojo/guides/exec-operation-guide.md +124 -27
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +40 -11
- package/docs/ja/specdojo/guides/kata-guide.md +4 -4
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +25 -4
- package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +1 -1
- package/docs/ja/specdojo/guides/practice-system-composition-guide.md +13 -13
- package/docs/ja/specdojo/guides/quick-start-guide.md +260 -30
- package/docs/ja/specdojo/guides/register-operation-guide.md +31 -14
- package/docs/ja/specdojo/guides/release-v0-3-0-migration-guide.md +264 -0
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +22 -1
- package/docs/ja/specdojo/guides/review-guide.md +195 -158
- package/docs/ja/specdojo/guides/routine-operation-guide.md +74 -9
- package/docs/ja/specdojo/guides/ryu-guide.md +32 -30
- package/docs/ja/specdojo/guides/schedule-design-guide.md +10 -10
- package/docs/ja/specdojo/guides/schedule-operation-guide.md +1 -1
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +58 -33
- package/docs/ja/specdojo/guides/use-case-guide.md +3 -3
- package/docs/ja/specdojo/guides/waza-guide.md +15 -2
- package/docs/ja/specdojo/index.md +2 -2
- package/docs/ja/specdojo/philosophy/specdojo-philosophy.md +5 -5
- package/docs/ja/specdojo/recipes/bps-recipe.md +213 -0
- package/docs/ja/specdojo/recipes/pm-members-recipe.md +52 -117
- package/docs/ja/specdojo/references/command-reference.md +335 -92
- package/docs/ja/specdojo/references/deliverables-reference.md +1 -1
- package/docs/ja/specdojo/references/directory-layout-reference.md +13 -9
- package/docs/ja/specdojo/references/specdojo-config-reference.md +107 -24
- package/docs/ja/specdojo/rulebooks/bps-rulebook.md +132 -220
- package/docs/ja/specdojo/rulebooks/br-rulebook.md +6 -44
- package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +2 -0
- package/docs/ja/specdojo/rulebooks/dmd-rulebook.md +0 -87
- package/docs/ja/specdojo/rulebooks/gl-rulebook.md +61 -39
- package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +0 -87
- package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +1 -33
- package/docs/ja/specdojo/rulebooks/opd-rulebook.md +0 -137
- package/docs/ja/specdojo/rulebooks/opr-rulebook.md +0 -247
- package/docs/ja/specdojo/rulebooks/otp-rulebook.md +0 -83
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +4 -2
- package/docs/ja/specdojo/rulebooks/pm-members-rulebook.md +78 -150
- package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +5 -4
- package/docs/ja/specdojo/rulebooks/sch-rulebook.md +1 -1
- package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +0 -11
- package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +0 -61
- package/docs/ja/specdojo/rulebooks/tml-rulebook.md +2 -47
- package/docs/ja/specdojo/samples/bps-sample.md +74 -21
- package/docs/ja/specdojo/samples/gl-sample.yaml +17 -1
- package/docs/ja/specdojo/samples/ifx-index-sample.yaml +28 -0
- package/docs/ja/specdojo/samples/pm-members-sample.yaml +2 -67
- package/docs/ja/specdojo/samples/pm-organization-sample.md +8 -7
- package/docs/ja/specdojo/samples/pm-raci-sample.md +1 -1
- package/docs/ja/specdojo/samples/tml-sample.yaml +40 -0
- package/docs/ja/specdojo/standards/document-metadata-standard.md +21 -16
- package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +14 -14
- package/docs/ja/specdojo/standards/job-definition-standard.md +37 -17
- package/docs/ja/specdojo/standards/people-and-organization-definition-standard.md +37 -32
- package/docs/ja/specdojo/standards/philosophy-authoring-standard.md +1 -1
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +21 -11
- package/docs/ja/specdojo/templates/agent-members-template.yaml +25 -0
- package/docs/ja/specdojo/templates/bps-template.md +91 -0
- package/docs/ja/specdojo/templates/pm-members-template.yaml +2 -59
- package/docs/specdojo/schemas/v1/agent-members.schema.yaml +76 -0
- package/docs/specdojo/schemas/v1/exec-common.schema.yaml +4 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +55 -2
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +93 -6
- package/docs/specdojo/schemas/v1/exec-reporter-output.schema.yaml +27 -78
- package/docs/specdojo/schemas/v1/gl.schema.yaml +87 -0
- package/docs/specdojo/schemas/v1/grade-result.schema.yaml +33 -0
- package/docs/specdojo/schemas/v1/job-run.schema.yaml +27 -0
- package/docs/specdojo/schemas/v1/job.schema.yaml +25 -0
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +49 -1
- package/docs/specdojo/schemas/v1/pm-members.schema.yaml +9 -169
- package/docs/specdojo/schemas/v1/pm-review-viewpoints.schema.yaml +100 -10
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +13 -0
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/routine.schema.yaml +7 -0
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +110 -0
- package/package.json +15 -9
- package/templates/antigravity/README.md +27 -2
- package/templates/antigravity/{pm-members-snippet.yaml → agent-members-snippet.yaml} +8 -2
- package/templates/antigravity/exec-defaults-snippet.yaml +7 -6
- package/templates/antigravity/orchestrator.md +18 -7
- package/templates/antigravity/settings.global.json +55 -0
- package/templates/claude/agents/claude-executor.md +14 -0
- package/templates/claude/agents/claude-reporter.md +16 -0
- package/templates/claude/agents/specdojo-orchestrator.md +18 -7
- package/templates/claude/settings.edit.json +27 -1
- package/templates/codex/README.md +5 -4
- package/templates/codex/agents/specdojo-orchestrator.toml +18 -7
- package/templates/codex/orchestrator.md +18 -7
- package/templates/copilot/README.md +7 -5
- package/templates/copilot/{pm-members-snippet.yaml → agent-members-snippet.yaml} +4 -2
- package/templates/devcontainer/devcontainer.json +27 -0
- package/templates/devcontainer/emacs/init.el +88 -0
- package/templates/devcontainer/post-create.sh +62 -0
- package/templates/init-agent-members.yaml +200 -0
- package/templates/init-exec-defaults.yaml +72 -0
- package/templates/opencode/agents/specdojo-orchestrator.md +18 -7
- package/docs/ja/specdojo/exec-templates/xrp-viewpoint-detail-template.md +0 -7
- package/docs/ja/specdojo/exec-templates/xrr-viewpoint-detail-template.md +0 -7
package/dist/exec-plans.js
CHANGED
|
@@ -8,11 +8,12 @@ import { isDctPlanFileName } from "./catalog-plan.js";
|
|
|
8
8
|
import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "./frontmatter-namespace.js";
|
|
9
9
|
import { formatMarkdownFile } from "./exec-format.js";
|
|
10
10
|
import { qualifyPracticeId, SPECDOJO_PRACTICE_AUTHORITY } from "./practice-id.js";
|
|
11
|
-
import { resolveViewpointsDoc } from "./review-plan.js";
|
|
11
|
+
import { resolveViewpointsDoc, viewpointAppliesToDocument } from "./review-plan.js";
|
|
12
12
|
import { expandTemplate, listFilesRecursive, nowUtcIsoSeconds, randomHex, tsForFilenameUtc, } from "./exec-shared.js";
|
|
13
|
-
import {
|
|
13
|
+
import { gradeFindingDisplayMessage, gradeResultPathForDocument, readGradeResultForDocument, } from "./grade-result.js";
|
|
14
14
|
import { lookupDocIndex } from "./doc-index.js";
|
|
15
15
|
import { resolveSpecdojoPath, resolveSpecdojoPathIfExists } from "./template-resolution.js";
|
|
16
|
+
import { renderReviewGradeSummary, reviewGradeFreshness } from "./review-grade.js";
|
|
16
17
|
export const MISSING = "_MISSING_";
|
|
17
18
|
function execDocId(projectId, prefix, localBase) {
|
|
18
19
|
const localId = `${prefix}-${localBase.toLowerCase()}`;
|
|
@@ -125,12 +126,6 @@ function loadViewpoints(viewpointsPath) {
|
|
|
125
126
|
const doc = resolveViewpointsDoc(viewpointsPath);
|
|
126
127
|
return new Map((doc.viewpoints ?? []).map((vp) => [vp.id, vp]));
|
|
127
128
|
}
|
|
128
|
-
function loadCoverageTypes(viewpointsPath) {
|
|
129
|
-
if (!viewpointsPath || !existsSync(viewpointsPath))
|
|
130
|
-
return new Map();
|
|
131
|
-
const doc = resolveViewpointsDoc(viewpointsPath);
|
|
132
|
-
return new Map((doc.coverage_types ?? []).map((ct) => [ct.id, ct]));
|
|
133
|
-
}
|
|
134
129
|
function loadRoles(rolesPath) {
|
|
135
130
|
if (!rolesPath || !existsSync(rolesPath))
|
|
136
131
|
return new Map();
|
|
@@ -157,7 +152,7 @@ function frontmatter(meta) {
|
|
|
157
152
|
`type: ${meta.type}`,
|
|
158
153
|
`rulebook: ${meta.rulebook}`,
|
|
159
154
|
`task_id: ${meta.task_id}`,
|
|
160
|
-
...(meta.name ? [`name: ${meta.name}`] : []),
|
|
155
|
+
...(meta.name ? [`name: ${JSON.stringify(meta.name)}`] : []),
|
|
161
156
|
`mode: ${meta.mode}`,
|
|
162
157
|
`status: ${meta.status}`,
|
|
163
158
|
`project_id: ${meta.project_id}`,
|
|
@@ -180,12 +175,6 @@ function frontmatter(meta) {
|
|
|
180
175
|
// ---------------------------------------------------------------------------
|
|
181
176
|
// Template-based generation (edit-plan / review-plan テンプレートの展開)
|
|
182
177
|
// ---------------------------------------------------------------------------
|
|
183
|
-
// レビュー観点 1 件ぶんの記述ブロック断片。prose ラベル(確認基準・チェック観点など)は
|
|
184
|
-
// 言語別 docs/<lang>/.../exec-templates のこの断片に置き、コードは値のみを供給する。
|
|
185
|
-
const REVIEW_VIEWPOINT_DETAIL_TEMPLATE = "xrp-viewpoint-detail-template.md";
|
|
186
|
-
// Per-RVP fragment for a review *result* (section 1). Prose labels for result/evidence/notes
|
|
187
|
-
// live here; code supplies only data values.
|
|
188
|
-
const REVIEW_RESULT_VIEWPOINT_DETAIL_TEMPLATE = "xrr-viewpoint-detail-template.md";
|
|
189
178
|
// Shared conventions (link notation など) appended to every generated plan. The plan is the
|
|
190
179
|
// only context guaranteed to reach the executing agent regardless of tool (it is piped via
|
|
191
180
|
// stdin), so cross-tool rules must travel with the plan rather than tool-specific instruction
|
|
@@ -231,11 +220,33 @@ function readTemplate(templatePath, cache) {
|
|
|
231
220
|
function loadPlanTemplate(mode, approach, cache) {
|
|
232
221
|
return readTemplate(resolvePlanTemplatePath(mode, approach), cache);
|
|
233
222
|
}
|
|
234
|
-
function loadViewpointDetailTemplate(cache) {
|
|
235
|
-
return readTemplate(execTemplatePath(REVIEW_VIEWPOINT_DETAIL_TEMPLATE), cache);
|
|
236
|
-
}
|
|
237
223
|
// Marker a plan template places to control where the shared conventions fragment lands.
|
|
238
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
|
+
}
|
|
239
250
|
// Placeholder in the conventions fragment for the resolved schema path. The agent cannot derive
|
|
240
251
|
// the schema path on its own (it would have to hunt for it and risks burning its turn before
|
|
241
252
|
// filling the result), so the generator resolves it deterministically and bakes it in here.
|
|
@@ -246,8 +257,10 @@ const SCHEMA_REF_PLACEHOLDER = "_SCHEMA_REF_";
|
|
|
246
257
|
// marker get the block appended so the rules are never silently dropped.
|
|
247
258
|
// schemaRef is the resolved schema path: when MISSING (non-yaml deliverable or no schema), the
|
|
248
259
|
// schema-validation bullet is dropped so the plan never asks for a check it cannot specify.
|
|
249
|
-
|
|
250
|
-
|
|
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");
|
|
251
264
|
conventions =
|
|
252
265
|
schemaRef === MISSING
|
|
253
266
|
? conventions
|
|
@@ -280,7 +293,7 @@ function gradeFindingsText(projectId, targetPath) {
|
|
|
280
293
|
if (!result || result.findings.length === 0)
|
|
281
294
|
return "- なし";
|
|
282
295
|
return result.findings
|
|
283
|
-
.map((finding) => `- ${finding.id} [${finding.severity}/${finding.rule}; line=${finding.line}; anchor=${JSON.stringify(finding.anchor)}]: ${finding
|
|
296
|
+
.map((finding) => `- ${finding.id} [${finding.severity}/${finding.rule}; line=${finding.line}; anchor=${JSON.stringify(finding.anchor)}]: ${gradeFindingDisplayMessage(finding)}`)
|
|
284
297
|
.join("\n");
|
|
285
298
|
}
|
|
286
299
|
catch {
|
|
@@ -298,6 +311,47 @@ function gradeFindingTargetPath(approach, deliverable, refs) {
|
|
|
298
311
|
return refs.template;
|
|
299
312
|
return deliverablePath(deliverable);
|
|
300
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
|
+
}
|
|
301
355
|
// plan に表示する実践の型の状態。宣言からパスを解決できたがファイルが無い場合と、
|
|
302
356
|
// 宣言不足・対象外などでパス自体を解決できない場合を分ける。これにより executor は
|
|
303
357
|
// 既存文書の編集、宣言済みパスへの新規作成、前提確認が必要な状態を推測せず判別できる。
|
|
@@ -555,47 +609,24 @@ function crossDeliverableTargetDetails(projectId, localIds, deliverables, catalo
|
|
|
555
609
|
}
|
|
556
610
|
return lines.join("\n").trimEnd();
|
|
557
611
|
}
|
|
558
|
-
|
|
612
|
+
// review plan の完了条件表の行。review は観点ごとに評価せず、done_criteria をタスクの
|
|
613
|
+
// 完了条件として照合するため、ID は DC-NNN とする。
|
|
614
|
+
function reviewDoneCriteriaRows(criteria) {
|
|
559
615
|
if (criteria.length === 0)
|
|
560
616
|
return MISSING;
|
|
561
617
|
const lines = [];
|
|
562
618
|
criteria.forEach((c, i) => {
|
|
563
|
-
const
|
|
564
|
-
lines.push(`| ${
|
|
619
|
+
const criterionId = `DC-${String(i + 1).padStart(3, "0")}`;
|
|
620
|
+
lines.push(`| ${criterionId} | ${c.roles.join(", ")} | ${c.viewpoint} | ${c.text} |`);
|
|
565
621
|
});
|
|
566
622
|
return lines.join("\n");
|
|
567
623
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
return MISSING;
|
|
575
|
-
return criteria
|
|
576
|
-
.map((c, i) => {
|
|
577
|
-
const vpId = `RVP-${String(i + 1).padStart(3, "0")}`;
|
|
578
|
-
return expandTemplate(detailTemplate, {
|
|
579
|
-
_VP_ID_: vpId,
|
|
580
|
-
_VP_ROLES_: c.roles.join(", "),
|
|
581
|
-
_VP_VIEWPOINT_: c.viewpoint,
|
|
582
|
-
_VP_CRITERION_: c.text,
|
|
583
|
-
}).trimEnd();
|
|
584
|
-
})
|
|
585
|
-
.join("\n\n");
|
|
586
|
-
}
|
|
587
|
-
// Resolve the review result sections for a deliverable by local_id. Returns undefined when
|
|
588
|
-
// the catalog, deliverable, or its done_criteria cannot be resolved; the caller then falls
|
|
589
|
-
// back to a generic result body.
|
|
590
|
-
export function reviewResultSectionsForDeliverable(catalogPath, localId) {
|
|
591
|
-
if (!catalogPath || !localId)
|
|
592
|
-
return undefined;
|
|
593
|
-
const info = findDeliverableInfo(catalogPath, localId);
|
|
594
|
-
const criteria = info?.deliverable.done_criteria ?? [];
|
|
595
|
-
if (criteria.length === 0)
|
|
596
|
-
return undefined;
|
|
597
|
-
const detailTemplate = readTemplate(execTemplatePath(REVIEW_RESULT_VIEWPOINT_DETAIL_TEMPLATE), new Map());
|
|
598
|
-
return reviewResultSections(criteria, detailTemplate);
|
|
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
|
+
});
|
|
599
630
|
}
|
|
600
631
|
// done_criteria を確認記録用チェックボックスに整形する。各項目に roles / viewpoint
|
|
601
632
|
// (review-viewpoints の観点 ID)を注記し、どの観点で確認したかが result に残るようにする。
|
|
@@ -643,54 +674,18 @@ export function finalizeResultSectionsForDeliverable(catalogPath, localId, appro
|
|
|
643
674
|
targetsChecklist: finalizeTargetsChecklist(info, approach),
|
|
644
675
|
};
|
|
645
676
|
}
|
|
646
|
-
// coverage_types はビューポート任意項目。持たない観点では coverage_required ブロック
|
|
647
|
-
// ごと省略し、持つ観点では見出し付きブロックを返す。末尾の空行で後続の `**チェック観点:**`
|
|
648
|
-
// と段落を分離する。各項目は `id: description` 形式で展開し、id 単独では意味が読み取れない
|
|
649
|
-
// 問題を避ける。pm-review-viewpoints.yaml の coverage_types 定義に説明が無い id は id のみ出力する。
|
|
650
|
-
function viewpointCoverage(vp, coverageMap) {
|
|
651
|
-
if (!vp?.coverage_types || vp.coverage_types.length === 0)
|
|
652
|
-
return "";
|
|
653
|
-
const items = vp.coverage_types
|
|
654
|
-
.map((ct) => {
|
|
655
|
-
const description = coverageMap.get(ct)?.description;
|
|
656
|
-
return description ? `- ${ct}: ${description}` : `- ${ct}`;
|
|
657
|
-
})
|
|
658
|
-
.join("\n");
|
|
659
|
-
return `**coverage_required:**\n\n${items}\n\n`;
|
|
660
|
-
}
|
|
661
|
-
// レビュー観点ごとに detail 断片テンプレートを展開して結合する。prose ラベルは
|
|
662
|
-
// detailTemplate 側にあり、ここでは値を差し込むだけ。値が無い項目は他のプレースホルダと
|
|
663
|
-
// 同様に MISSING にし、表示構造はテンプレート側に委ねる。
|
|
664
|
-
export function reviewViewpointDetails(criteria, vpMap, detailTemplate, coverageMap = new Map()) {
|
|
665
|
-
if (criteria.length === 0)
|
|
666
|
-
return MISSING;
|
|
667
|
-
return criteria
|
|
668
|
-
.map((c, i) => {
|
|
669
|
-
const vpId = `RVP-${String(i + 1).padStart(3, "0")}`;
|
|
670
|
-
const vp = vpMap.get(c.viewpoint);
|
|
671
|
-
return expandTemplate(detailTemplate, {
|
|
672
|
-
_VP_ID_: vpId,
|
|
673
|
-
_VP_ROLES_: c.roles.join(", "),
|
|
674
|
-
_VP_VIEWPOINT_: c.viewpoint,
|
|
675
|
-
_VP_CRITERION_: c.text,
|
|
676
|
-
_VP_COVERAGE_: viewpointCoverage(vp, coverageMap),
|
|
677
|
-
_VP_CHECK_: vp?.check ?? MISSING,
|
|
678
|
-
_VP_EVIDENCE_: vp?.evidence ?? MISSING,
|
|
679
|
-
}).trimEnd();
|
|
680
|
-
})
|
|
681
|
-
.join("\n\n");
|
|
682
|
-
}
|
|
683
677
|
// owner の Role code から、pm-roles.yaml の責務(project_note)と
|
|
684
678
|
// pm-review-viewpoints.yaml の該当 role 観点を取り出す。owner 未設定や情報欠落時は
|
|
685
679
|
// 他のプレースホルダと同様に MISSING を返し、表示構造はテンプレート側に委ねる。
|
|
686
|
-
export function ownerRoleFields(owner, roleMap, vpMap) {
|
|
680
|
+
export function ownerRoleFields(owner, roleMap, vpMap, rulebook) {
|
|
687
681
|
if (!owner) {
|
|
688
682
|
return { label: MISSING, note: MISSING, viewpoints: MISSING };
|
|
689
683
|
}
|
|
690
684
|
const role = roleMap.get(owner);
|
|
691
685
|
const label = role?.name ? `${owner}(${role.name})` : owner;
|
|
692
686
|
const note = role?.project_note ?? MISSING;
|
|
693
|
-
const
|
|
687
|
+
const metadata = rulebook ? { rulebook } : {};
|
|
688
|
+
const roleViewpoints = [...vpMap.values()].filter((vp) => vp.role === owner && viewpointAppliesToDocument(vp, metadata));
|
|
694
689
|
const viewpoints = roleViewpoints.length > 0
|
|
695
690
|
? roleViewpoints.map((vp) => `- ${vp.title}: ${vp.check}`).join("\n")
|
|
696
691
|
: MISSING;
|
|
@@ -717,7 +712,7 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
717
712
|
...(targets.length > 0 ? { targets } : {}),
|
|
718
713
|
};
|
|
719
714
|
const criteria = deliverable?.deliverable.done_criteria ?? [];
|
|
720
|
-
const ownerRole = ownerRoleFields(task.owner, roleMap, vpMap);
|
|
715
|
+
const ownerRole = ownerRoleFields(task.owner, roleMap, vpMap, deliverable?.deliverable.rulebook);
|
|
721
716
|
const refs = resolveKataRefs(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind);
|
|
722
717
|
const values = {
|
|
723
718
|
_FRONTMATTER_: frontmatter(meta),
|
|
@@ -750,7 +745,9 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
750
745
|
};
|
|
751
746
|
return expandTemplate(template, values);
|
|
752
747
|
}
|
|
753
|
-
|
|
748
|
+
// review plan は成果物を再評価しない。grade の評価結果(サイドカー)の位置と完了条件を示し、
|
|
749
|
+
// 評価結果を事実として受け取ってタスクの完了可否を判断させる(bps-task-completion)。
|
|
750
|
+
function buildReviewPlanMarkdown(template, task, deliverable, criteria, vpMap, projectId, catalogPath, projectContext, resultRef, stem, reviewGradeOutcome) {
|
|
754
751
|
const cpm = task.cpm;
|
|
755
752
|
const onCriticalPath = cpm !== undefined && cpm.slack === 0;
|
|
756
753
|
const targets = targetDocIds(projectId, deliverable, task.approach, task.local_id);
|
|
@@ -769,6 +766,8 @@ function buildReviewPlanMarkdown(template, detailTemplate, task, deliverable, cr
|
|
|
769
766
|
...(targets.length > 0 ? { targets } : {}),
|
|
770
767
|
};
|
|
771
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);
|
|
772
771
|
const values = {
|
|
773
772
|
_FRONTMATTER_: frontmatter(meta),
|
|
774
773
|
_TASK_ID_: task.id,
|
|
@@ -785,8 +784,11 @@ function buildReviewPlanMarkdown(template, detailTemplate, task, deliverable, cr
|
|
|
785
784
|
_RECIPE_REF_: refs.recipe,
|
|
786
785
|
_SAMPLE_REF_: refs.sample,
|
|
787
786
|
_TEMPLATE_REF_: refs.template,
|
|
788
|
-
|
|
789
|
-
|
|
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),
|
|
790
792
|
};
|
|
791
793
|
return expandTemplate(template, values);
|
|
792
794
|
}
|
|
@@ -820,10 +822,10 @@ async function writeTaskPlan(ctx, task, override) {
|
|
|
820
822
|
}
|
|
821
823
|
const template = loadPlanTemplate(mode, task.approach, ctx.templateCache);
|
|
822
824
|
const body = mode === "review"
|
|
823
|
-
? buildReviewPlanMarkdown(template,
|
|
825
|
+
? buildReviewPlanMarkdown(template, planTask, deliverable, criteria, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, ctx.reviewGradeOutcome)
|
|
824
826
|
: buildEditPlanMarkdown(template, planTask, deliverable, ctx.roleMap, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, crossDeliverables);
|
|
825
827
|
const schemaRef = resolveDeliverableSchemaRef(deliverable?.resolvedPath);
|
|
826
|
-
const content = injectCommonConventions(body, schemaRef, ctx.templateCache);
|
|
828
|
+
const content = injectCommonConventions(body, schemaRef, ctx.templateCache, mode);
|
|
827
829
|
writeFileSync(outPath, content, "utf8");
|
|
828
830
|
await formatMarkdownFile(outPath);
|
|
829
831
|
return outPath;
|
|
@@ -835,6 +837,8 @@ export async function generateSinglePlan(opts) {
|
|
|
835
837
|
throw new Error(`Task ${opts.task.id} has execution: human; claim it to create and use its result instead of a plan.`);
|
|
836
838
|
}
|
|
837
839
|
const ctx = newPlanGenContext(opts);
|
|
840
|
+
if (opts.reviewGradeOutcome)
|
|
841
|
+
ctx.reviewGradeOutcome = opts.reviewGradeOutcome;
|
|
838
842
|
const override = opts.outPath || opts.stem
|
|
839
843
|
? {
|
|
840
844
|
...(opts.outPath ? { outPath: opts.outPath } : {}),
|
|
@@ -877,9 +881,6 @@ function newPlanGenContext(opts) {
|
|
|
877
881
|
vpMap: opts.viewpointsPath
|
|
878
882
|
? loadViewpoints(opts.viewpointsPath)
|
|
879
883
|
: new Map(),
|
|
880
|
-
coverageMap: opts.viewpointsPath
|
|
881
|
-
? loadCoverageTypes(opts.viewpointsPath)
|
|
882
|
-
: new Map(),
|
|
883
884
|
roleMap: loadRoles(opts.rolesPath),
|
|
884
885
|
projectContext: [
|
|
885
886
|
...(opts.projectContext ??
|
|
@@ -965,22 +966,23 @@ export function registerGradeFindingsText(projectId, ticketPath) {
|
|
|
965
966
|
if (!existsSync(ticketPath))
|
|
966
967
|
return "- なし";
|
|
967
968
|
const content = readFileSync(ticketPath, "utf8");
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
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)
|
|
975
977
|
return "- なし";
|
|
976
978
|
const docIndexPath = join(specdojoRootDir(), ".specdojo", "doc-index.json");
|
|
977
979
|
const MAX_DOCS = 10;
|
|
978
980
|
const MAX_FINDINGS = 20;
|
|
979
981
|
const lines = [];
|
|
980
982
|
let docCount = 0;
|
|
981
|
-
for (const id of
|
|
983
|
+
for (const id of targets) {
|
|
982
984
|
if (docCount >= MAX_DOCS) {
|
|
983
|
-
lines.push(`- その他 ${
|
|
985
|
+
lines.push(`- その他 ${targets.length - MAX_DOCS} 件の文書は省略されました`);
|
|
984
986
|
break;
|
|
985
987
|
}
|
|
986
988
|
const targetPath = lookupDocIndex(id, docIndexPath);
|
|
@@ -1005,7 +1007,7 @@ export function registerGradeFindingsText(projectId, ticketPath) {
|
|
|
1005
1007
|
lines.push(` - 他 ${result.findings.length - MAX_FINDINGS} 件の finding があります。詳細はサイドカーを参照してください。`);
|
|
1006
1008
|
break;
|
|
1007
1009
|
}
|
|
1008
|
-
lines.push(` - [${finding.severity}/${finding.rule}; line=${finding.line}; anchor=${JSON.stringify(finding.anchor)}]: ${finding
|
|
1010
|
+
lines.push(` - [${finding.severity}/${finding.rule}; line=${finding.line}; anchor=${JSON.stringify(finding.anchor)}]: ${gradeFindingDisplayMessage(finding)}`);
|
|
1009
1011
|
findingCount++;
|
|
1010
1012
|
}
|
|
1011
1013
|
docCount++;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { stripTerminalControlSequences } from "./exec-shared.js";
|
|
3
|
-
import { describeAgentProtectedConfigChanges } from "./exec-agent-protected-config.js";
|
|
4
|
-
import { describeAgentGitStateChanges, } from "./exec-agent-git-state.js";
|
|
3
|
+
import { describeAgentProtectedConfigChanges, qualifiedRepoPaths, } from "./exec-agent-protected-config.js";
|
|
4
|
+
import { describeAgentGitStateChanges, qualifiedGitStateFields, } from "./exec-agent-git-state.js";
|
|
5
5
|
// PJR-VH6R: 保護機構が agent の変更を止めたとき、規約は「対象・変更理由・提案差分・
|
|
6
6
|
// 変更後に必要な検証」を result の申し送りへ書くことを求めている。しかし block は agent の
|
|
7
7
|
// 記入を待たずに成立するため、実際には _TODO_ のまま残り、orchestrator が worktree の
|
|
@@ -156,6 +156,47 @@ export function recordProtectedConfigBlock(params) {
|
|
|
156
156
|
evidence: collectEvidence(() => describeAgentProtectedConfigChanges(params.repoRoot, params.paths)),
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
+
// プロダクトリポジトリの差分には `# repo: <name>` の見出しを付ける。プロジェクトリポジトリだけの
|
|
160
|
+
// 変更は見出しを付けず、`repos` を持たない project の記録内容を変えない。
|
|
161
|
+
function repoSectionHeader(name) {
|
|
162
|
+
return name ? [`# repo: ${name}`] : [];
|
|
163
|
+
}
|
|
164
|
+
/** Record protected-config blocks found in several repositories of one task (PJR-98G4). */
|
|
165
|
+
export function recordProtectedConfigBlockAcrossRepos(params) {
|
|
166
|
+
return recordProtectionHandoff(params.resultPath, {
|
|
167
|
+
mechanism: "agent-config-write",
|
|
168
|
+
subjectLabel: "対象パス",
|
|
169
|
+
subjects: qualifiedRepoPaths(params.changes),
|
|
170
|
+
reason: params.reason,
|
|
171
|
+
evidenceLabel: "提案差分",
|
|
172
|
+
evidenceLanguage: "diff",
|
|
173
|
+
evidence: params.changes
|
|
174
|
+
.map((change) => collectEvidence(() => [
|
|
175
|
+
...repoSectionHeader(change.repo.name),
|
|
176
|
+
describeAgentProtectedConfigChanges(change.repo.root, change.paths),
|
|
177
|
+
].join("\n")))
|
|
178
|
+
.filter((section) => section.trim() !== "")
|
|
179
|
+
.join("\n"),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/** Record Git state blocks found in several repositories of one task (PJR-98G4). */
|
|
183
|
+
export function recordGitStateBlockAcrossRepos(params) {
|
|
184
|
+
return recordProtectionHandoff(params.resultPath, {
|
|
185
|
+
mechanism: "agent-git-state-write",
|
|
186
|
+
subjectLabel: "対象フィールド",
|
|
187
|
+
subjects: qualifiedGitStateFields(params.changes),
|
|
188
|
+
reason: params.reason,
|
|
189
|
+
evidenceLabel: "検知した変更",
|
|
190
|
+
evidenceLanguage: "text",
|
|
191
|
+
evidence: params.changes
|
|
192
|
+
.map((change) => collectEvidence(() => [
|
|
193
|
+
...repoSectionHeader(change.repo.name),
|
|
194
|
+
describeAgentGitStateChanges(change.repo.root, change.before, change.fields),
|
|
195
|
+
].join("\n")))
|
|
196
|
+
.filter((section) => section.trim() !== "")
|
|
197
|
+
.join("\n"),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
159
200
|
export function recordGitStateBlock(params) {
|
|
160
201
|
return recordProtectionHandoff(params.resultPath, {
|
|
161
202
|
mechanism: "agent-git-state-write",
|