specdojo 0.4.5 → 0.4.7

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 (101) hide show
  1. package/.github/agents/specdojo-orchestrator.md +4 -4
  2. package/CHANGELOG.md +41 -0
  3. package/dist/catalog/document-target.js +75 -0
  4. package/dist/commands/agent.js +2 -80
  5. package/dist/commands/init.js +33 -7
  6. package/dist/devcontainer/scaffold.js +5 -1
  7. package/dist/exec/agent-config.js +28 -16
  8. package/dist/exec/agent-plan.js +108 -0
  9. package/dist/exec/commands.js +3 -3
  10. package/dist/exec/evidence.js +35 -3
  11. package/dist/exec/grade-checkpoint.js +12 -0
  12. package/dist/exec/pipeline-state.js +1 -0
  13. package/dist/exec/plans-core.js +11 -67
  14. package/dist/exec/plans-generation.js +22 -5
  15. package/dist/exec/project.js +4 -1
  16. package/dist/exec/register-resume.js +8 -4
  17. package/dist/exec/register.js +66 -5
  18. package/dist/exec/reporter.js +8 -1
  19. package/dist/exec/results.js +1 -1
  20. package/dist/exec/run/agent-pipeline.js +7 -5
  21. package/dist/exec/run/agent.js +14 -1
  22. package/dist/exec/run/lifecycle-commands.js +2 -0
  23. package/dist/exec/run/register-resume.js +2 -0
  24. package/dist/exec/run/register-state.js +4 -1
  25. package/dist/exec/run/register-worktree.js +8 -1
  26. package/dist/exec/run/schedule-prepare.js +7 -1
  27. package/dist/exec/worktree-command.js +8 -1
  28. package/dist/exec/worktree-ops-lifecycle.js +4 -2
  29. package/dist/exec/worktree-ops-merge.js +40 -1
  30. package/dist/grade/apply.js +7 -5
  31. package/dist/grade/command-inspect.js +2 -1
  32. package/dist/grade/command-run.js +39 -0
  33. package/dist/grade/grade.js +3 -1
  34. package/dist/grade/markdown.js +4 -4
  35. package/dist/grade/pipeline-state.js +8 -6
  36. package/dist/grade/plan.js +8 -6
  37. package/dist/grade/run.js +307 -0
  38. package/dist/grade/target-discovery.js +1 -1
  39. package/dist/grade/targets.js +44 -22
  40. package/dist/kata/command.js +54 -9
  41. package/dist/register/approach.js +16 -0
  42. package/dist/register/core.js +2 -0
  43. package/dist/register/create-commands.js +57 -7
  44. package/dist/register/deliverable-target.js +215 -0
  45. package/dist/register/events.js +4 -0
  46. package/dist/register/external-project.js +18 -7
  47. package/dist/register/item.js +8 -0
  48. package/dist/register/views.js +3 -0
  49. package/dist/review/grade.js +19 -17
  50. package/dist/shared/agent-plan.js +1 -0
  51. package/dist/shared/git.js +3 -2
  52. package/dist/shared/lefthook-scaffold.js +5 -22
  53. package/dist/shared/markdownlint-scaffold.js +67 -0
  54. package/dist/shared/provider-scaffold.js +7 -5
  55. package/dist/shared/slidev-scaffold.js +102 -0
  56. package/dist/shared/specdojo-config.js +9 -3
  57. package/dist/specdojo.js +5 -1
  58. package/docs/ja/specdojo/exec-templates/xep-register-template.md +5 -4
  59. package/docs/ja/specdojo/exec-templates/xrp-freeform-template.md +2 -2
  60. package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +2 -2
  61. package/docs/ja/specdojo/exec-templates/xrp-recipe-guided-template.md +2 -2
  62. package/docs/ja/specdojo/exec-templates/xrp-recipe-maintenance-template.md +2 -2
  63. package/docs/ja/specdojo/exec-templates/xrp-retrofit-template.md +2 -2
  64. package/docs/ja/specdojo/exec-templates/xrp-rulebook-maintenance-template.md +2 -2
  65. package/docs/ja/specdojo/exec-templates/xrp-sample-maintenance-template.md +2 -2
  66. package/docs/ja/specdojo/exec-templates/xrp-template-maintenance-template.md +2 -2
  67. package/docs/ja/specdojo/exec-templates/xrp-template.md +2 -2
  68. package/docs/ja/specdojo/guides/exec-config-guide.md +81 -19
  69. package/docs/ja/specdojo/guides/exec-operation-guide.md +4 -0
  70. package/docs/ja/specdojo/guides/kata-guide.md +108 -1
  71. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +6 -6
  72. package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +3 -1
  73. package/docs/ja/specdojo/guides/quick-start-guide.md +22 -2
  74. package/docs/ja/specdojo/guides/register-operation-guide.md +2 -0
  75. package/docs/ja/specdojo/guides/remote-host-development-guide.md +15 -1
  76. package/docs/ja/specdojo/guides/review-guide.md +2 -2
  77. package/docs/ja/specdojo/guides/ryu-guide.md +12 -0
  78. package/docs/ja/specdojo/references/command-reference.md +178 -62
  79. package/docs/ja/specdojo/references/specdojo-config-reference.md +31 -8
  80. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +28 -22
  81. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +17 -1
  82. package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +1 -1
  83. package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
  84. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +33 -1
  85. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +16 -3
  86. package/package.json +5 -5
  87. package/templates/antigravity/orchestrator.md +4 -4
  88. package/templates/claude/README.md +2 -0
  89. package/templates/claude/agents/specdojo-orchestrator.md +4 -4
  90. package/templates/codex/README.md +38 -9
  91. package/templates/codex/agents/codex-executor.toml +1 -1
  92. package/templates/codex/agents/codex-expert-executor.toml +1 -1
  93. package/templates/codex/agents/codex-expert-review-executor.toml +1 -1
  94. package/templates/codex/agents/codex-review-executor.toml +1 -1
  95. package/templates/codex/agents/specdojo-orchestrator.toml +5 -5
  96. package/templates/codex/orchestrator.md +4 -4
  97. package/templates/devcontainer/devcontainer.json +1 -0
  98. package/templates/init-agent-members.yaml +131 -16
  99. package/templates/opencode/README.md +118 -14
  100. package/templates/opencode/agents/specdojo-orchestrator.md +5 -5
  101. package/templates/opencode/opencode.json +25 -0
@@ -5,6 +5,8 @@ import { gitOutput } from "./worktree.js";
5
5
  const MAX_LOG_BYTES = 64 * 1024;
6
6
  const MAX_CHANGE_FILES = 1_000;
7
7
  const MAX_FINAL_MESSAGE_LENGTH = 4_000;
8
+ const MAX_HANDOFF_ITEMS = 100;
9
+ const MAX_HANDOFF_LENGTH = 4_000;
8
10
  const MAX_DIFF_SUMMARY_LENGTH = 4_000;
9
11
  const MAX_VALIDATIONS = 50;
10
12
  const MAX_VALIDATION_COMMAND_LENGTH = 500;
@@ -107,12 +109,33 @@ export function parseExecutorReport(stdout) {
107
109
  }
108
110
  }
109
111
  const fallback = stdout.replace(REPORT_PATTERN, "").trim();
112
+ const handoff = Array.isArray(report.handoff)
113
+ ? report.handoff
114
+ .slice(0, MAX_HANDOFF_ITEMS)
115
+ .map((item) => boundedText(item, MAX_HANDOFF_LENGTH))
116
+ .filter(Boolean)
117
+ : [];
110
118
  return {
111
119
  finalMessage: boundedText(report.final_message ?? fallback, MAX_FINAL_MESSAGE_LENGTH),
120
+ ...(report.completion_status !== undefined
121
+ ? {
122
+ completionStatus: report.completion_status === "complete"
123
+ ? "complete"
124
+ : "incomplete",
125
+ }
126
+ : {}),
127
+ handoff,
112
128
  validations,
113
129
  targetCoverage,
114
130
  };
115
131
  }
132
+ /** A successful process or validation batch cannot override an explicit incomplete report. */
133
+ export function executorCompletionFailure(evidence) {
134
+ if (evidence.completion_status !== "incomplete")
135
+ return undefined;
136
+ const detail = boundedText(evidence.final_message, MAX_VALIDATION_SUMMARY_LENGTH);
137
+ return boundedText(detail ? `executor reported incomplete: ${detail}` : "executor reported incomplete", MAX_VALIDATION_SUMMARY_LENGTH);
138
+ }
116
139
  function normalizedEvidencePath(value) {
117
140
  const normalized = value.replaceAll("\\", "/").replace(/^\.\//u, "");
118
141
  if (!normalized ||
@@ -313,9 +336,18 @@ export function buildExecutorEvidence(input) {
313
336
  ...(report.targetCoverage.length > 0 ? { target_coverage: report.targetCoverage } : {}),
314
337
  ...(input.rateLimitEvents?.length ? { rate_limit_events: input.rateLimitEvents } : {}),
315
338
  final_message: report.finalMessage,
316
- ...(input.status === "succeeded"
317
- ? {}
318
- : { block_reason: executorBlockReason(input.status, input.stderr) }),
339
+ ...(report.completionStatus ? { completion_status: report.completionStatus } : {}),
340
+ ...(report.handoff.length > 0 ? { handoff: report.handoff } : {}),
341
+ ...(input.status !== "succeeded"
342
+ ? { block_reason: executorBlockReason(input.status, input.stderr) }
343
+ : report.completionStatus === "incomplete"
344
+ ? {
345
+ block_reason: executorCompletionFailure({
346
+ completion_status: "incomplete",
347
+ final_message: report.finalMessage,
348
+ }),
349
+ }
350
+ : {}),
319
351
  log_refs: [
320
352
  {
321
353
  kind: "agent-output-excerpt",
@@ -0,0 +1,12 @@
1
+ import { resolve } from "node:path";
2
+ import { repoRelative, worktreeStatusPaths } from "../shared/git.js";
3
+ /** Include canonical grade sidecars, including deletions, in the execution checkpoint. */
4
+ export function gradeCheckpointPaths(context) {
5
+ const execution = repoRelative(context.repoRoot, context.executionPath);
6
+ return worktreeStatusPaths(context.repoRoot)
7
+ .filter((path) => isGradeCheckpointPath(path, execution))
8
+ .map((path) => resolve(context.repoRoot, path));
9
+ }
10
+ export function isGradeCheckpointPath(path, execution) {
11
+ return ["results", "criteria", "pipeline"].some((kind) => path.startsWith(`${execution}/grade/${kind}/`));
12
+ }
@@ -241,6 +241,7 @@ export function loadPipelineResumeCheckpoint(input) {
241
241
  statePath,
242
242
  executorEvidence: evidence,
243
243
  ...(evidence.stage.status === "succeeded" &&
244
+ evidence.completion_status !== "incomplete" &&
244
245
  (state.stages.executor.status === "succeeded" || state.stages.executor.status === "running")
245
246
  ? { evidence }
246
247
  : {}),
@@ -1,3 +1,5 @@
1
+ import { deliverableDocId, loadPlanCatalogDocs as loadCatalogDocs, } from "../catalog/document-target.js";
2
+ export { deliverableDocId, resolveDeliverableByDocId, loadPlanCatalogDocs as loadCatalogDocs, } from "../catalog/document-target.js";
1
3
  import { existsSync, readFileSync } from "node:fs";
2
4
  import { basename, join, relative, resolve } from "node:path";
3
5
  import { load } from "../shared/yaml.js";
@@ -5,7 +7,7 @@ import { specdojoRootDir } from "../shared/specdojo-config.js";
5
7
  import { kataDirsForKinds, resolveIncludedRulebooks, resolveKataRefs } from "../kata/kata.js";
6
8
  import { resolveBasePath, resolveDeliverablePath } from "../catalog/paths.js";
7
9
  import { isDctPlanFileName } from "../catalog/plan.js";
8
- import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
10
+ import { buildSpecdojoFrontmatter } from "../docs/frontmatter-namespace.js";
9
11
  import { qualifyPracticeId, SPECDOJO_PRACTICE_AUTHORITY } from "../shared/practice-id.js";
10
12
  import { MISSING } from "../shared/plan-templates.js";
11
13
  export { MISSING, execTemplatePath, execTemplatesDir, injectCommonConventions, loadPlanTemplate, } from "../shared/plan-templates.js";
@@ -84,28 +86,6 @@ export function findDeliverableInfo(catalogPath, localId) {
84
86
  }
85
87
  return null;
86
88
  }
87
- export function loadCatalogDocs(catalogPath) {
88
- if (!catalogPath || !existsSync(catalogPath))
89
- return [];
90
- // Catalog scans walk subdirectories, so agent judgment plans (plans/dct-plan-*.yaml)
91
- // must be excluded; they share the dct- prefix but carry no catalog structure.
92
- const files = listFilesRecursive(catalogPath)
93
- .filter((f) => {
94
- const name = f.split("/").pop() ?? "";
95
- return /^dct-.+\.ya?ml$/i.test(name) && !isDctPlanFileName(name);
96
- })
97
- .sort();
98
- const docs = [];
99
- for (const filePath of files) {
100
- try {
101
- docs.push(load(readFileSync(filePath, "utf8")));
102
- }
103
- catch {
104
- continue;
105
- }
106
- }
107
- return docs;
108
- }
109
89
  function resolvedDeliverablesInCatalog(catalogPath) {
110
90
  const deliverables = [];
111
91
  const visit = (sections, parentBase, domain) => {
@@ -130,25 +110,6 @@ function resolvedDeliverablesInCatalog(catalogPath) {
130
110
  }
131
111
  return deliverables;
132
112
  }
133
- // Register targets use document IDs rather than schedule local_ids. Resolve the document ID
134
- // back to its catalog entry so register-originated approach plans can share schedule rendering.
135
- export function resolveDeliverableByDocId(catalogPath, projectId, targetId) {
136
- const matches = resolvedDeliverablesInCatalog(catalogPath).filter((target) => {
137
- const docId = deliverableDocId(projectId, target.info.deliverable.local_id, target.info.resolvedPath);
138
- return (targetId === docId ||
139
- targetId === target.localId ||
140
- targetId === qualifiedDocId(projectId, target.localId));
141
- });
142
- if (matches.length === 0) {
143
- throw new Error(`catalog deliverable target not found for document id: ${targetId}`);
144
- }
145
- if (matches.length > 1) {
146
- throw new Error(`ambiguous catalog deliverable target for document id ${targetId}: ${matches
147
- .map((match) => match.localId)
148
- .join(", ")}`);
149
- }
150
- return matches[0];
151
- }
152
113
  /** Resolve a project-repository-relative file path to its catalog entry, if any. */
153
114
  export function findDeliverableByPath(catalogPath, targetPath) {
154
115
  const normalized = targetPath.replaceAll("\\", "/").replace(/^\/+/, "");
@@ -333,7 +294,7 @@ export function gradeResultRef(projectId, subjectPath) {
333
294
  export function kataRefState(refPath) {
334
295
  if (refPath === MISSING)
335
296
  return "unresolved";
336
- return existsSync(join(specdojoRootDir(), refPath)) ? "existing" : "missing";
297
+ return existsSync(resolve(specdojoRootDir(), refPath)) ? "existing" : "missing";
337
298
  }
338
299
  // 対象成果物の depends_on を、依存先 doc の [[id]] 参照の入れ子リストで提示する。
339
300
  // id は依存先の frontmatter、未作成なら配置規約から解決する。agent へ plan を渡すときに
@@ -478,28 +439,6 @@ const TARGET_REF_KINDS = {
478
439
  function qualifiedDocId(projectId, localId) {
479
440
  return projectId ? `${projectId}:${localId}` : localId;
480
441
  }
481
- // 成果物の doc id は、既存文書では frontmatter を正本とする。author 前など文書が
482
- // 未作成の場合は配置規約に従い、product 配下だけをローカル ID、projects 配下を含む
483
- // その他の配置を従来どおり project 修飾 ID とする。
484
- export function deliverableDocId(projectId, localId, resolvedPath) {
485
- if (resolvedPath) {
486
- const absolutePath = resolve(specdojoRootDir(), resolvedPath);
487
- if (existsSync(absolutePath)) {
488
- try {
489
- const id = readSpecdojoNamespace(readFileSync(absolutePath, "utf8")).id;
490
- if (typeof id === "string" && id.trim())
491
- return id.trim();
492
- }
493
- catch {
494
- // 読み取り不能・不正 frontmatter は配置によるフォールバックへ進む。
495
- }
496
- }
497
- const normalizedPath = resolvedPath.replaceAll("\\", "/").replace(/^\/+/, "");
498
- if (/^docs\/[a-z]{2}\/product(?:\/|$)/.test(normalizedPath))
499
- return localId;
500
- }
501
- return qualifiedDocId(projectId, localId);
502
- }
503
442
  // タスクが対象とする文書の doc id リスト。先頭は対象成果物(配置に対応する doc id)、
504
443
  // 以降は approach に応じて変更・確定しうる実践の型の doc id。いずれも doc-index で
505
444
  // パスへ解決できる id にし、schedule やファイル名の命名規約に依存せず対象を機械的に
@@ -657,12 +596,17 @@ export function finalizeResultSectionsForDeliverable(catalogPath, localId, appro
657
596
  targetsChecklist: finalizeTargetsChecklist(info, approach),
658
597
  };
659
598
  }
599
+ // owner ロール視点の記述ガイドを構成するデータ値。prose ラベルや見出しは
600
+ // テンプレート側(言語別 docs/<lang>/.../exec-templates)に置き、ここでは値のみを供給する。
601
+ const MISSING_VIEWPOINTS = `- ${MISSING}`;
660
602
  // owner の Role code から、pm-roles.yaml の責務(project_note)と
661
603
  // pm-review-viewpoints.yaml の該当 role 観点を取り出す。owner 未設定や情報欠落時は
662
604
  // 他のプレースホルダと同様に MISSING を返し、表示構造はテンプレート側に委ねる。
605
+ // ただし viewpoints はテンプレートで単独の段落に置かれるため、欠落時も箇条書きの
606
+ // 1 項目(`- _MISSING_`)にする。強調だけの段落は markdownlint MD036 に違反する(PJR-SS72)。
663
607
  export function ownerRoleFields(owner, roleMap, vpMap, rulebook) {
664
608
  if (!owner) {
665
- return { label: MISSING, note: MISSING, viewpoints: MISSING };
609
+ return { label: MISSING, note: MISSING, viewpoints: MISSING_VIEWPOINTS };
666
610
  }
667
611
  const role = roleMap.get(owner);
668
612
  const label = role?.name ? `${owner}(${role.name})` : owner;
@@ -671,7 +615,7 @@ export function ownerRoleFields(owner, roleMap, vpMap, rulebook) {
671
615
  const roleViewpoints = [...vpMap.values()].filter((vp) => vp.role === owner && viewpointAppliesToDocument(vp, metadata));
672
616
  const viewpoints = roleViewpoints.length > 0
673
617
  ? roleViewpoints.map((vp) => `- ${vp.title}: ${vp.check}`).join("\n")
674
- : MISSING;
618
+ : MISSING_VIEWPOINTS;
675
619
  return { label, note, viewpoints };
676
620
  }
677
621
  // edit plan は観点別の自己レビューを行わない。done_criteria は §3 の owner 視点とは別に
@@ -39,7 +39,9 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
39
39
  _DELIVERABLE_DEPENDS_ON_: deliverableDependsOn(deliverable, projectId, catalogPath),
40
40
  _PROJECT_CONTEXT_: projectContextSection(projectContext, deliverable, task.approach, projectId),
41
41
  _DELIVERABLE_OVERVIEW_: deliverableOverview(deliverable),
42
- _IMPLEMENTATION_EVIDENCE_: implementationEvidence(deliverable),
42
+ _IMPLEMENTATION_EVIDENCE_: deliverable?.catalogless
43
+ ? "個票に指定された実装のパスを読み取り専用の調査入力とする。パスが未指定なら実装反映の前に個票へ明記する。"
44
+ : implementationEvidence(deliverable),
43
45
  _DELIVERABLE_PATH_: deliverablePath(deliverable),
44
46
  _RESULT_REF_: resultRef,
45
47
  _RULEBOOK_REF_: refs.rulebook,
@@ -54,7 +56,9 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
54
56
  _OWNER_ROLE_LABEL_: ownerRole.label,
55
57
  _OWNER_ROLE_NOTE_: ownerRole.note,
56
58
  _OWNER_ROLE_VIEWPOINTS_: ownerRole.viewpoints,
57
- _DONE_CRITERIA_GOALS_: doneCriteriaGoals(criteria, task.owner),
59
+ _DONE_CRITERIA_GOALS_: deliverable?.catalogless
60
+ ? "カタログの `done_criteria` はない。個票の完了条件と rulebook を完了基準とする。"
61
+ : doneCriteriaGoals(criteria, task.owner),
58
62
  _DONE_CRITERIA_CHECKLIST_: doneCriteriaChecklist(criteria),
59
63
  _DONE_CRITERIA_ITEMS_: doneCriteriaItems(criteria),
60
64
  _GRADE_FINDINGS_: gradeFindingsText(projectId, gradeFindingTargetPath(task.approach, deliverable, refs)),
@@ -68,13 +72,24 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
68
72
  .map((example) => `- \`${example.id}\`: ${example.name}(\`${example.path}\`、${example.catalog ? "現在の参照" : "参照更新"}: \`${example.currentReference}\`)`)
69
73
  .join("\n") || "- なし(kata だけを新規作成する)",
70
74
  };
71
- const body = expandTemplate(template, values);
75
+ const effectiveTemplate = deliverable?.catalogless
76
+ ? template
77
+ .split("\n")
78
+ .filter((line) => !["recipe", "sample", "template"].some((kind) => refs[kind] === MISSING && line.includes(`_${kind.toUpperCase()}_REF_`)))
79
+ .join("\n")
80
+ : template;
81
+ let body = expandTemplate(effectiveTemplate, values);
82
+ if (deliverable?.catalogless && task.approach === "retrofit") {
83
+ body = body.replace("成果物カタログの `evidence_refs` から展開した", "個票に明記する");
84
+ }
72
85
  if (!planOverrides?.additionalConditions)
73
86
  return body;
74
87
  const section = [
75
88
  "## 個票の追加完了条件",
76
89
  "",
77
- "成果物カタログの `done_criteria` に加え、登録簿の個票が定める次の条件も満たす。",
90
+ deliverable?.catalogless
91
+ ? "個票が定める次の条件と rulebook を満たす。"
92
+ : "成果物カタログの `done_criteria` に加え、登録簿の個票が定める次の条件も満たす。",
78
93
  "",
79
94
  planOverrides.additionalConditions.trim(),
80
95
  "",
@@ -158,7 +173,9 @@ async function writeTaskPlan(ctx, task, override) {
158
173
  throw new Error(`Task ${task.id} has execution: human; claim it to create and use its result instead of a plan.`);
159
174
  }
160
175
  const planTask = { ...task, mode };
161
- if (task.approach === "retrofit" && implementationEvidence(deliverable) === MISSING) {
176
+ if (task.approach === "retrofit" &&
177
+ !deliverable?.catalogless &&
178
+ implementationEvidence(deliverable) === MISSING) {
162
179
  throw new Error(`Task ${task.id} uses approach: retrofit but the target deliverable has no evidence_refs.`);
163
180
  }
164
181
  const template = loadPlanTemplate(mode, task.approach, ctx.templateCache);
@@ -1,5 +1,6 @@
1
1
  import { join, resolve } from "node:path";
2
2
  import { getProjectCatalogPath, getProjectContext, getProjectExecutionPath, getProjectRolesPath, getProjectSchedulePath, getProjectViewpointsPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
3
+ import { commonViewpointsPath } from "../review/plan.js";
3
4
  function projectBaseDir() {
4
5
  return specdojoRootDir();
5
6
  }
@@ -65,7 +66,9 @@ export function resolveProjectPaths(opts) {
65
66
  executionPath: resolveProjectRelative(baseDir, getProjectExecutionPath(project)),
66
67
  catalogPath: catalogPath ? resolveProjectRelative(baseDir, catalogPath) : undefined,
67
68
  rolesPath: rolesPath ? resolveProjectRelative(baseDir, rolesPath) : undefined,
68
- viewpointsPath: viewpointsPath ? resolveProjectRelative(baseDir, viewpointsPath) : undefined,
69
+ viewpointsPath: viewpointsPath
70
+ ? resolveProjectRelative(baseDir, viewpointsPath)
71
+ : commonViewpointsPath(),
69
72
  projectContext: getProjectContext(project),
70
73
  };
71
74
  }
@@ -5,6 +5,9 @@ import { safeSlug } from "./shared.js";
5
5
  function executorResumeHandoff(evidence) {
6
6
  if (!evidence)
7
7
  return [];
8
+ if (evidence.completion_status === "incomplete") {
9
+ return [evidence.block_reason || evidence.final_message, ...(evidence.handoff ?? [])].filter((note) => note.trim());
10
+ }
8
11
  const failedParentValidations = evidence.validations
9
12
  .filter((validation) => validation.source === "runner" && validation.status === "failed")
10
13
  .map((validation) => {
@@ -78,13 +81,13 @@ export function selectResumableRegisterRun(candidates, options = {}) {
78
81
  return a.runId < b.runId ? -1 : a.runId > b.runId ? 1 : 0;
79
82
  });
80
83
  const latest = ordered[candidates.length - 1];
81
- // The earliest rate-limited executor attempt is the stable lower bound for every later resume.
84
+ // The earliest interrupted or incomplete attempt is the stable lower bound for later resumes.
82
85
  // Rejected protection-block changes are intentionally excluded; the handoff requires removing
83
86
  // them before resume. `attempt_changes` also excludes runner lifecycle changes that predated the
84
87
  // executor invocation.
85
88
  const firstAttemptEvidence = ordered
86
89
  .map((candidate) => candidate.executorEvidence ?? candidate.evidence)
87
- .find((evidence) => evidence?.stage.status === "rate_limited");
90
+ .find((evidence) => evidence?.stage.status === "rate_limited" || evidence?.completion_status === "incomplete");
88
91
  const initialChanges = [
89
92
  ...new Set((firstAttemptEvidence?.attempt_changes ?? firstAttemptEvidence?.changes ?? [])
90
93
  .map((change) => change.path.trim())
@@ -99,10 +102,11 @@ export function selectResumableRegisterRun(candidates, options = {}) {
99
102
  initialChanges: [...changes],
100
103
  handoff: executorResumeHandoff(candidate.executorEvidence ?? candidate.evidence),
101
104
  });
102
- // rate limit または保護機構の block で打ち切られた executor は、evidence が記録されていても
105
+ // 未完了の申告、rate limit または保護機構の block で打ち切られた executor は、evidence が記録されていても
103
106
  // 作業を完了していない。reporter へ進めず、申し送りを反映できるよう既存 worktree 上で
104
107
  // executor を再開する。通常のプロセス失敗は failed のまま区別し、再開対象にしない。
105
- if (latest.state.stages.executor.status === "rate_limited" ||
108
+ if ((latest.executorEvidence ?? latest.evidence)?.completion_status === "incomplete" ||
109
+ latest.state.stages.executor.status === "rate_limited" ||
106
110
  latest.state.stages.executor.status === "blocked") {
107
111
  return {
108
112
  kind: "resumable",
@@ -1,3 +1,4 @@
1
+ import { resolveRegisterDeliverableTarget, } from "../register/deliverable-target.js";
1
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
3
  import { basename, extname, join, relative, resolve } from "node:path";
3
4
  import { findRegisterItem, loadRegisterItems, PJR_ID_RE, resolveRegisterPaths, TERMINAL_STATUSES_SET, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "../register/register.js";
@@ -324,6 +325,51 @@ function catalogSource(catalogPath, projectId, source) {
324
325
  }
325
326
  return findDeliverableByPath(catalogPath, source.path);
326
327
  }
328
+ function cataloglessPlanFields(resolved, item, targetId, ticketPath) {
329
+ let targets = [targetId];
330
+ let conditionsText = "";
331
+ if (resolved.catalogless) {
332
+ conditionsText =
333
+ "カタログの `done_criteria` はない。個票の完了条件と rulebook を完了基準とする。";
334
+ if (item.approach === "bootstrap") {
335
+ targets = [targetId, ...(resolved.kataIds ?? [])];
336
+ conditionsText += `\n\n成果物の frontmatter に \`specdojo.id: ${targetId}\` と \`specdojo.rulebook: ${resolved.info.deliverable.rulebook}\` を記入する。未作成の kata は次の ID とパスで整備し、recipe・sample・template の ID を rulebook frontmatter に宣言する。不要な型は作らず \`not-needed\` と宣言する。\n\n`;
337
+ conditionsText += (resolved.kataIds ?? [])
338
+ .map((id, index) => {
339
+ const kind = ["rulebook", "recipe", "sample", "template"][index];
340
+ return `- \`${id}\`: \`${kind ? resolved.refs?.[kind] : ""}\`(未作成 / missing)`;
341
+ })
342
+ .join("\n");
343
+ }
344
+ else {
345
+ conditionsText += `\n\n成果物の frontmatter に \`specdojo.id: ${targetId}\` と \`specdojo.rulebook: ${resolved.info.deliverable.rulebook}\` を維持・記入する。`;
346
+ }
347
+ if (item.approach === "finalize" || item.approach === "bootstrap-finalize") {
348
+ if (item.approach === "bootstrap-finalize")
349
+ targets = [targetId, ...(resolved.kataIds ?? [])];
350
+ const conditions = registerCompletionConditions(item, ticketPath);
351
+ const checklist = conditions
352
+ .split(/\r?\n/)
353
+ .filter((line) => line.trim())
354
+ .map((line) => {
355
+ const text = line.replace(/^\s*(?:[-*+]\s+(?:\[[ xX]\]\s*)?|\d+\.\s*)/, "");
356
+ return `- [ ] ${text}`;
357
+ })
358
+ .join("\n");
359
+ conditionsText += `\n\n### 人による確定のチェック表\n\n${checklist}\n\n### 確定対象\n\n- [ ] 成果物: \`${resolved.info.resolvedPath}\``;
360
+ if (item.approach === "bootstrap-finalize") {
361
+ conditionsText +=
362
+ "\n" +
363
+ (resolved.kataTargets ?? [])
364
+ .map(({ id, path }) => `- [ ] \`${id}\`: \`${path}\`(frontmatter から辿った kata)`)
365
+ .join("\n");
366
+ }
367
+ conditionsText +=
368
+ "\n\n人が各条件と確定対象を確認する。agent は成果物の `status` を `ready` へ変更しない。";
369
+ }
370
+ }
371
+ return { targets, conditions: conditionsText };
372
+ }
327
373
  export async function generateRegisterPlan(opts) {
328
374
  const { item } = opts;
329
375
  const category = requireRunnableRegisterItem(item);
@@ -336,6 +382,8 @@ export async function generateRegisterPlan(opts) {
336
382
  approach: item.approach,
337
383
  targets: item.targets,
338
384
  sources: item.sources,
385
+ targetPath: item.targetPath,
386
+ targetRulebook: item.targetRulebook,
339
387
  });
340
388
  const [targetId] = item.targets ?? [];
341
389
  if (!targetId)
@@ -344,6 +392,8 @@ export async function generateRegisterPlan(opts) {
344
392
  const maintenanceKind = MAINTENANCE_TARGET_KIND[item.approach];
345
393
  let deliverable = null;
346
394
  let refs;
395
+ let cataloglessConditions = "";
396
+ let planTargets = [targetId];
347
397
  let authoring;
348
398
  if (newKataKind) {
349
399
  const sourceRefs = [...(item.targets ?? []).slice(1), ...(item.sources ?? [])];
@@ -412,10 +462,20 @@ export async function generateRegisterPlan(opts) {
412
462
  refs = { ...refs, [maintenanceKind]: indexedDocumentPath(targetId) };
413
463
  }
414
464
  else {
415
- if (!opts.catalogPath) {
416
- throw new Error(`Register item ${item.id} approach requires catalog_path to resolve ${targetId}.`);
417
- }
418
- deliverable = resolveDeliverableByDocId(opts.catalogPath, opts.projectId, targetId).info;
465
+ const resolved = resolveRegisterDeliverableTarget({
466
+ repoRoot: specdojoRootDir(),
467
+ projectId: opts.projectId,
468
+ catalogPath: opts.catalogPath,
469
+ approach: item.approach,
470
+ targetId,
471
+ targetPath: item.targetPath,
472
+ targetRulebook: item.targetRulebook,
473
+ });
474
+ deliverable = resolved.info;
475
+ refs = resolved.refs;
476
+ const fields = cataloglessPlanFields(resolved, item, targetId, ticketPath);
477
+ planTargets = fields.targets;
478
+ cataloglessConditions = fields.conditions;
419
479
  }
420
480
  const planPath = await generateRegisterApproachPlan({
421
481
  executionPath: opts.executionPath,
@@ -429,11 +489,12 @@ export async function generateRegisterPlan(opts) {
429
489
  description: item.description,
430
490
  ...(item.owner && item.owner !== "-" && item.owner !== "_TODO_" ? { owner: item.owner } : {}),
431
491
  approach: item.approach,
432
- targets: targetId ? [targetId] : [],
492
+ targets: planTargets,
433
493
  deliverable,
434
494
  ...(refs ? { refs } : {}),
435
495
  ...(authoring ? { authoring } : {}),
436
496
  additionalConditions: [
497
+ cataloglessConditions,
437
498
  registerCompletionConditions(item, ticketPath),
438
499
  registerAutopilotConstraints(item),
439
500
  ]
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { join, relative, resolve, sep } from "node:path";
3
+ import { executorCompletionFailure } from "./evidence.js";
3
4
  import { PARENT_VALIDATION_PROJECT_REPO, failedParentValidationReason, } from "./parent-validation.js";
4
5
  import { getProjectExecutionPath, resolveRepoRoot, specdojoRootDir, } from "../shared/specdojo-config.js";
5
6
  import { MAX_TEXT_LENGTH, parseReporterOutput, reporterOutputSchemaForMode, } from "./reporter-output.js";
@@ -126,6 +127,10 @@ export function deriveReporterFacts(evidence, options = {}) {
126
127
  : "executor stage failed");
127
128
  return { outcome: "blocked", changed_files: changedFiles, block_reason: blockReason };
128
129
  }
130
+ const completionFailure = executorCompletionFailure(evidence);
131
+ if (completionFailure) {
132
+ return { outcome: "blocked", changed_files: changedFiles, block_reason: completionFailure };
133
+ }
129
134
  const validationFailure = failedParentValidationReason(evidence.validations);
130
135
  if (validationFailure) {
131
136
  return {
@@ -648,7 +653,9 @@ export function buildReporterPrompt(opts) {
648
653
  from the stored grade result. Record that judgement in verdict and put unmet items and improvement
649
654
  instructions in improvements. If evidence.final_message identifies "確認できなかった範囲",
650
655
  record that scope in rationale or improvements and reflect it in the verdict.`
651
- : "";
656
+ : `\n\nThe runner preserves evidence.handoff mechanically in the result's handoff section, even when
657
+ your handoff is empty. Do not omit, reinterpret, or contradict those executor notes. Use your
658
+ handoff only for additional notes supported by evidence; do not repeat evidence.handoff.`;
652
659
  return `You are the reporter stage of a SpecDojo executor/reporter pipeline.
653
660
  Use only the supplied plan and bounded executor evidence. Do not edit or inspect files. Do not
654
661
  invent facts that are absent from evidence. Return exactly one JSON object matching the supplied
@@ -620,7 +620,7 @@ export function renderEditReporterBody(output, evidence, options) {
620
620
  "## 3. 申し送り",
621
621
  "",
622
622
  reporterBulletList([
623
- ...output.handoff,
623
+ ...new Set([...output.handoff, ...(evidence.handoff ?? [])]),
624
624
  ...unchangedTargetNotes,
625
625
  ...notApplicableValidationNotes,
626
626
  ...runnerOwnedValidationNotes,
@@ -1,5 +1,5 @@
1
1
  import { relative, sep } from "node:path";
2
- import { recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "../evidence.js";
2
+ import { executorCompletionFailure, recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "../evidence.js";
3
3
  import { failedParentValidationReason, hasRecordedParentValidations, parentValidationRoots, replaceParentValidationResults, } from "../parent-validation.js";
4
4
  import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "../pipeline-state.js";
5
5
  import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "../reporter.js";
@@ -200,7 +200,8 @@ export async function runAgentPipeline(params) {
200
200
  productWorktrees: params.productWorktrees,
201
201
  rateLimitEvents: outcome.rateLimitEvents,
202
202
  });
203
- const coverageFailure = outcome.result === "success"
203
+ const completionFailure = outcome.result === "success" ? executorCompletionFailure(recorded.evidence) : undefined;
204
+ const coverageFailure = outcome.result === "success" && !completionFailure
204
205
  ? resumedTargetCoverageFailure({
205
206
  resumed: !!params.resumedExecutor,
206
207
  plan: planPrompt,
@@ -209,13 +210,13 @@ export async function runAgentPipeline(params) {
209
210
  initialChangeTargets: params.initialChangeTargets,
210
211
  })
211
212
  : undefined;
212
- const executorResult = coverageFailure ? "failure" : outcome.result;
213
+ const executorResult = completionFailure || coverageFailure ? "failure" : outcome.result;
213
214
  const evidenceRef = relative(cwd, recorded.evidencePath).split(sep).join("/");
214
215
  const executorCompletedAt = new Date().toISOString();
215
216
  state = updatePipelineStage(state, "executor", {
216
217
  status: executorResult === "success"
217
218
  ? "succeeded"
218
- : outcome.protectionBlock
219
+ : outcome.protectionBlock || completionFailure
219
220
  ? "blocked"
220
221
  : executorResult === "rate_limit"
221
222
  ? "rate_limited"
@@ -229,7 +230,8 @@ export async function runAgentPipeline(params) {
229
230
  writePipelineState(stateLocation.path, state);
230
231
  process.stdout.write(` Executor evidence: ${evidenceRef}\n`);
231
232
  if (executorResult !== "success") {
232
- const blockReason = coverageFailure ??
233
+ const blockReason = completionFailure ??
234
+ coverageFailure ??
233
235
  (executorResult === "rate_limit"
234
236
  ? "executor rate limit reached"
235
237
  : extractBlockReason(outcome.stderr));
@@ -111,6 +111,19 @@ artifacts required by the plan, but do not create or update the result file. Any
111
111
  that assigns result writing or lifecycle transitions to the agent belongs to the later reporter or
112
112
  runner stage and does not apply here.
113
113
 
114
+ Put unresolved decisions, proposed protected-configuration changes, and next actions in the
115
+ report's optional \`handoff\` array (up to 100 non-empty strings, each at most 4000 characters).
116
+ For register tasks, also record them in the ticket's response/results section. If a completion
117
+ condition asks for a note in the result, write it in both places instead of editing the result.
118
+ The runner preserves \`handoff\` in the edit result's handoff section after the reporter stage.
119
+ Use an empty array when there are no handoff notes. Reports without this field remain valid.
120
+
121
+ Report task completion in \`completion_status\`: use \`complete\` only when all work required by
122
+ the plan is done. If you stop with unfinished work, use \`incomplete\`, summarize the reason in
123
+ \`final_message\`, and list the remaining work in \`handoff\`. A zero exit code and passing parent
124
+ validations do not override \`incomplete\`; the runner preserves the worktree for executor resume.
125
+ Omitting this field is supported for legacy reports and implies \`complete\`.
126
+
114
127
  The parent runner owns Git commits and repository configuration. Do not run git commit or change
115
128
  local, global, or system Git configuration, including user.name and user.email. A Git state change
116
129
  will stop the pipeline before validation, reporting, commit, or merge.
@@ -155,7 +168,7 @@ End the final response with exactly one machine-readable report using this envel
155
168
  Markdown fences around the JSON.
156
169
 
157
170
  <specdojo_executor_evidence>
158
- {"final_message":"concise outcome","validations":[{"command":"exact command","status":"passed|failed|not_run|not_applicable|requires_human","summary":"concise result or required human check","reason":"required when status is not_applicable"}]${targetCoverageExample}}
171
+ {"completion_status":"complete|incomplete","final_message":"concise outcome","handoff":[],"validations":[{"command":"exact command","status":"passed|failed|not_run|not_applicable|requires_human","summary":"concise result or required human check","reason":"required when status is not_applicable"}]${targetCoverageExample}}
159
172
  </specdojo_executor_evidence>
160
173
  `;
161
174
  }
@@ -1,3 +1,4 @@
1
+ import { gradeCheckpointPaths } from "../grade-checkpoint.js";
1
2
  import { existsSync } from "node:fs";
2
3
  import { join } from "node:path";
3
4
  import { loadExecDefaultsConfig, providerSlotPoolPath, resolveMaxConcurrency, resolveMaxConcurrentRuns, } from "../agent-config.js";
@@ -277,6 +278,7 @@ export function prepareScheduleIntegrationResume(params) {
277
278
  join(executionPath, "exec", "plans", `${task.id}-plan.md`),
278
279
  resultPath,
279
280
  ...(claimEventPath ? [claimEventPath] : []),
281
+ ...gradeCheckpointPaths({ repoRoot, executionPath }),
280
282
  ];
281
283
  return {
282
284
  task,
@@ -214,6 +214,7 @@ export async function resumeSingleRegisterItemWorktree(context, opts, pjrId, lif
214
214
  // 再開開始前に集合を固定せず finalize の直前に評価する。
215
215
  const bookkeepingPaths = () => registerBookkeepingPaths({
216
216
  repoRoot,
217
+ executionPath,
217
218
  registerPaths,
218
219
  planPath: resolve(repoRoot, artifacts.planRef),
219
220
  resultPath: resolve(repoRoot, artifacts.resultRef),
@@ -350,6 +351,7 @@ export async function resumeSingleRegisterItemWorktree(context, opts, pjrId, lif
350
351
  resultScaffold,
351
352
  agentResult: outcome.runResult,
352
353
  stderr: outcome.blockReason ?? "",
354
+ runnerBlockReason: outcome.blockReason,
353
355
  actor: executor.candidate.actor,
354
356
  bookkeepingPaths: bookkeepingPaths(),
355
357
  pipelineStatePath: resolve(worktree.path, outcome.stateRef),
@@ -1,3 +1,4 @@
1
+ import { gradeCheckpointPaths } from "../grade-checkpoint.js";
1
2
  import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
3
  import { basename, dirname, resolve } from "node:path";
3
4
  import { sanitizeRegisterConclusion, } from "../register.js";
@@ -157,7 +158,9 @@ export function registerTransitionPaths(registerPaths, ticketPath) {
157
158
  // runner 管理パスとして扱う。この集合を失敗時の wait commit、merge 前の root 解放で使う。
158
159
  export function registerBookkeepingPaths(params) {
159
160
  const { repoRoot, registerPaths, planPath, resultPath, ticketPath } = params;
160
- return registerRunnerManagedPaths(repoRoot, registerPaths, planPath, resultPath, worktreeStatusPaths(repoRoot), ticketPath).map((path) => resolve(repoRoot, path));
161
+ return registerRunnerManagedPaths(repoRoot, registerPaths, planPath, resultPath, worktreeStatusPaths(repoRoot), ticketPath)
162
+ .map((path) => resolve(repoRoot, path))
163
+ .concat(gradeCheckpointPaths(params));
161
164
  }
162
165
  // root の登録簿派生ビュー(pjr-index / generated)は非追跡の生成物で、merge や複製では更新され
163
166
  // ない。個票の状態を root 側へ反映したあとに再生成して、root の表示を個票と揃える。失敗しても