specdojo 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/agents/specdojo-orchestrator.md +61 -2
- package/CHANGELOG.md +90 -0
- package/README.md +85 -25
- package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
- package/dist/catalog/build-render.js +32 -0
- package/dist/{catalog-build.js → catalog/build.js} +9 -9
- package/dist/{catalog.js → catalog/catalog.js} +10 -10
- package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
- package/dist/catalog/paths.js +1 -0
- package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
- package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
- package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
- package/dist/{agent.js → commands/agent.js} +11 -11
- package/dist/{build-command.js → commands/build.js} +2 -2
- package/dist/{init-command.js → commands/init.js} +168 -45
- package/dist/commands/night-orchestrator.js +287 -0
- package/dist/{orchestrator.js → commands/orchestrator.js} +12 -5
- package/dist/{watch.js → commands/watch.js} +3 -3
- package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
- package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
- package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
- package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
- package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
- package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
- package/dist/{timeline.js → dashboard/timeline.js} +1 -1
- package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
- package/dist/{deliverable-trash.js → deliverable/trash.js} +5 -5
- package/dist/{devcontainer-command.js → devcontainer/command.js} +8 -4
- package/dist/devcontainer/scaffold.js +418 -0
- package/dist/{doc-index.js → docs/doc-index.js} +1 -1
- package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
- package/dist/{index-command.js → docs/index-command.js} +1 -1
- package/dist/docs/template-resolution.js +1 -0
- package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +1 -1
- package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
- package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
- package/dist/{exec-agent-config.js → exec/agent-config.js} +92 -5
- package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
- package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
- package/dist/{exec-commands.js → exec/commands.js} +22 -18
- package/dist/{exec-core.js → exec/core.js} +11 -11
- package/dist/{exec-events.js → exec/events.js} +2 -2
- package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
- package/dist/exec/exec.js +2 -0
- package/dist/exec/format.js +1 -0
- package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
- package/dist/{exec-limit.js → exec/limit.js} +93 -12
- package/dist/{exec-parent-validation.js → exec/parent-validation.js} +18 -4
- package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +29 -2
- package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
- package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
- package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
- package/dist/{exec-plans.js → exec/plans.js} +3 -3
- package/dist/{exec-project.js → exec/project.js} +1 -1
- package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
- package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
- package/dist/{exec-register.js → exec/register.js} +114 -9
- package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
- package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
- package/dist/{exec-repo-integration.js → exec/repo-integration.js} +14 -11
- package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
- package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
- package/dist/{exec-reporter.js → exec/reporter.js} +142 -25
- package/dist/{exec-results.js → exec/results.js} +287 -31
- package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +35 -12
- package/dist/{exec-run-agent.js → exec/run/agent.js} +115 -28
- package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
- package/dist/{exec-run-job.js → exec/run/job.js} +65 -36
- package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
- package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
- package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
- package/dist/{exec-run-register-command.js → exec/run/register-command.js} +38 -11
- package/dist/{exec-run-register-core.js → exec/run/register-core.js} +63 -21
- package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +58 -31
- package/dist/exec/run/register-post-review.js +420 -0
- package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +48 -27
- package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
- package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +119 -24
- package/dist/{exec-run.js → exec/run/run.js} +11 -11
- package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
- package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
- package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
- package/dist/{exec-run-shared.js → exec/run/shared.js} +78 -30
- package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
- package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
- package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
- package/dist/exec/schedule/gantt-chart.js +2 -0
- package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
- package/dist/exec/schedule/index.js +1 -0
- package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
- package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
- package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
- package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
- package/dist/exec/shared.js +63 -0
- package/dist/exec/slot-lock.js +1 -0
- package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
- package/dist/{exec-task-repos.js → exec/task-repos.js} +104 -17
- package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
- package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
- package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
- package/dist/{exec-trial.js → exec/trial.js} +2 -2
- package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
- package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
- package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
- package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
- package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
- package/dist/exec/worktree.js +305 -0
- package/dist/{grade-apply.js → grade/apply.js} +9 -9
- package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
- package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
- package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
- package/dist/{grade-core.js → grade/core.js} +3 -3
- package/dist/grade/grade.js +19 -0
- package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
- package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
- package/dist/{grade-plan.js → grade/plan.js} +5 -5
- package/dist/{grade-result.js → grade/result.js} +5 -94
- package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
- package/dist/{grade-targets.js → grade/targets.js} +11 -8
- package/dist/{job-definition.js → job/definition.js} +25 -6
- package/dist/{job.js → job/job.js} +12 -11
- package/dist/{kata-command.js → kata/command.js} +3 -3
- package/dist/{kata.js → kata/kata.js} +5 -5
- package/dist/register/approach.js +134 -0
- package/dist/{register-core.js → register/core.js} +26 -8
- package/dist/{register-create-commands.js → register/create-commands.js} +171 -8
- package/dist/{register-date.js → register/date.js} +1 -1
- package/dist/register/derivation.js +163 -0
- package/dist/{register-event-merge.js → register/event-merge.js} +44 -3
- package/dist/{register-events.js → register/events.js} +13 -3
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +32 -5
- package/dist/register/lifecycle-lock.js +5 -0
- package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
- package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
- package/dist/{register-migration.js → register/migration.js} +5 -4
- package/dist/{register.js → register/register.js} +32 -27
- package/dist/{register-renumber.js → register/renumber.js} +38 -11
- package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
- package/dist/{register-update.js → register/update.js} +5 -5
- package/dist/{register-views.js → register/views.js} +47 -7
- package/dist/{review-grade.js → review/grade.js} +2 -2
- package/dist/{review-plan.js → review/plan.js} +3 -3
- package/dist/{routine-definition.js → routine/definition.js} +2 -2
- package/dist/{routine.js → routine/routine.js} +49 -22
- package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
- package/dist/{schedule-build.js → schedule/build.js} +7 -4
- package/dist/{schedule.js → schedule/schedule.js} +6 -6
- package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
- package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
- package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
- package/dist/shared/agent-types.js +23 -0
- package/dist/shared/artifact-path.js +9 -0
- package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
- package/dist/{catalog-build-render.js → shared/catalog-render.js} +3 -32
- package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
- package/dist/shared/fs.js +30 -0
- package/dist/shared/git.js +346 -0
- package/dist/shared/grade-result.js +94 -0
- package/dist/{package-paths.js → shared/package-paths.js} +3 -3
- package/dist/shared/plan-templates.js +114 -0
- package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +6 -3
- package/dist/shared/random.js +4 -0
- package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
- package/dist/shared/schedule-paths.js +9 -0
- package/dist/{specdojo-config.js → shared/specdojo-config.js} +162 -21
- package/dist/{exec-shared.js → shared/text.js} +4 -135
- package/dist/shared/time.js +28 -0
- package/dist/shared/workspace-scaffold.js +69 -0
- package/dist/specdojo.js +22 -22
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +31 -18
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +3 -2
- package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
- package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
- package/docs/ja/specdojo/exec-templates/xrp-register-post-run-template.md +46 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +34 -1
- package/docs/ja/specdojo/guides/docs-structure-guide.md +2 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +169 -26
- package/docs/ja/specdojo/guides/exec-operation-guide.md +184 -13
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +40 -3
- package/docs/ja/specdojo/guides/quick-start-guide.md +89 -21
- package/docs/ja/specdojo/guides/register-operation-guide.md +44 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +61 -6
- package/docs/ja/specdojo/guides/review-guide.md +1 -1
- package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +1 -1
- package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
- package/docs/ja/specdojo/guides/waza-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +124 -55
- package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +22 -13
- package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
- package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
- package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
- package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +111 -17
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +28 -0
- package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
- package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +38 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +5 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +91 -7
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +36 -1
- package/package.json +17 -17
- package/templates/antigravity/README.md +6 -2
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
- package/templates/antigravity/orchestrator.md +61 -2
- package/templates/claude/README.md +27 -3
- package/templates/claude/agents/claude-executor.md +0 -1
- package/templates/claude/agents/claude-reporter.md +2 -1
- package/templates/claude/agents/claude-review-executor.md +0 -1
- package/templates/claude/agents/specdojo-orchestrator.md +61 -2
- package/templates/codex/README.md +40 -4
- package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
- package/templates/codex/orchestrator.md +61 -2
- package/templates/devcontainer/devcontainer.json +5 -2
- package/templates/devcontainer/post-create.sh +15 -7
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +102 -0
- package/templates/devcontainer/remote-host/ssh-config.sample +19 -0
- package/templates/devcontainer/vim/vimrc +37 -0
- package/templates/init-agent-members.yaml +75 -25
- package/templates/init-exec-defaults.yaml +44 -9
- package/templates/opencode/README.md +17 -3
- package/templates/opencode/agents/opencode-executor.md +0 -1
- package/templates/opencode/agents/opencode-reporter.md +2 -1
- package/templates/opencode/agents/opencode-review-executor.md +0 -1
- package/templates/opencode/agents/specdojo-orchestrator.md +61 -2
- package/dist/devcontainer-scaffold.js +0 -165
- package/dist/exec-schedule-gantt-chart.js +0 -2
- package/dist/exec-worktree.js +0 -474
- package/dist/exec.js +0 -2
- package/dist/grade.js +0 -19
- package/templates/claude/agents/claude-expert-review-executor.md +0 -14
- /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
- /package/dist/{catalog-types.js → catalog/types.js} +0 -0
- /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
- /package/dist/{role-types.js → exec/role-types.js} +0 -0
- /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
- /package/dist/{exec-types.js → exec/types.js} +0 -0
- /package/dist/{grade-command-shared.js → grade/command-shared.js} +0 -0
- /package/dist/{register-command-types.js → register/command-types.js} +0 -0
- /package/dist/{review-types.js → review/types.js} +0 -0
- /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
- /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
- /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
- /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
- /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
- /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
- /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
- /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
- /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
- /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
- /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
- /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
- /package/dist/{yaml.js → shared/yaml.js} +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
3
4
|
import { isDeepStrictEqual } from "node:util";
|
|
4
|
-
import { buildSpecdojoFrontmatter, parseSpecdojoDocument } from "
|
|
5
|
-
import { expandTemplate, stripTerminalControlSequences } from "./
|
|
6
|
-
import { formatMarkdownFile } from "./
|
|
7
|
-
import { deriveReporterFacts, mechanicallyNotApplicableReason, runnerOwnedValidationReason, } from "./
|
|
8
|
-
import { resolveSpecdojoPath, resolveSpecdojoPathIfExists } from "
|
|
9
|
-
import { dump } from "
|
|
10
|
-
|
|
5
|
+
import { buildSpecdojoFrontmatter, parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
|
|
6
|
+
import { escapeMarkdownInline, expandTemplate, stripTerminalControlSequences } from "./shared.js";
|
|
7
|
+
import { formatMarkdownFile } from "./format.js";
|
|
8
|
+
import { deriveReporterFacts, mechanicallyNotApplicableReason, runnerOwnedValidationReason, } from "./reporter.js";
|
|
9
|
+
import { resolveSpecdojoPath, resolveSpecdojoPathIfExists } from "../docs/template-resolution.js";
|
|
10
|
+
import { dump } from "../shared/yaml.js";
|
|
11
|
+
import { gitEnvironment } from "../shared/git-environment.js";
|
|
12
|
+
export const MAX_INDIVIDUAL_CHANGED_FILES = 50;
|
|
11
13
|
// ---------------------------------------------------------------------------
|
|
12
14
|
// Frontmatter helpers
|
|
13
15
|
// ---------------------------------------------------------------------------
|
|
@@ -155,6 +157,16 @@ async function supersedePriorResults(resultsDir, taskId, nextResultPath, superse
|
|
|
155
157
|
}
|
|
156
158
|
return supersededPaths;
|
|
157
159
|
}
|
|
160
|
+
const APPROACH_SECTION_WITH_APPROACH = [
|
|
161
|
+
"## 4. 進め方と実践の型の適用",
|
|
162
|
+
"",
|
|
163
|
+
"_TODO_: `approach` に従ってどう進めたか、その進め方の中で実践の型(rulebook / recipe / sample / template)をどう適用したかを記入する(`fully-guided` で rulebook / recipe / sample / template をどう使い分けたか、`recipe-guided` で recipe のみを基準にした内容、`freeform` で実践の型より優先した実例やプロジェクト文脈、`retrofit` で実際に参照した実装パス・抽出した現在動作・反映/新設判断・未反映の乖離・未確認範囲、`rulebook-maintenance` などの maintenance 系で見直した実践の型とその根拠、など)。実践の型を基準にしなかった場合は、その判断と代わりに根拠にした内容も記入する。複数文書間に矛盾があり rulebook を正として判断した箇所、参照範囲から外れていた文書とその代わりに根拠にした内容があれば、あわせて記録する。",
|
|
164
|
+
].join("\n");
|
|
165
|
+
const APPROACH_SECTION_WITHOUT_APPROACH = [
|
|
166
|
+
"## 4. 進め方",
|
|
167
|
+
"",
|
|
168
|
+
"_TODO_: どう進めたか、根拠にした文書や規約を記入する。",
|
|
169
|
+
].join("\n");
|
|
158
170
|
export async function scaffoldResult(opts) {
|
|
159
171
|
const { executionPath, taskId, mode, projectId, planRef, agent, startedAt, approach } = opts;
|
|
160
172
|
const stem = opts.stem ?? taskId;
|
|
@@ -184,7 +196,12 @@ export async function scaffoldResult(opts) {
|
|
|
184
196
|
...(approach ? { approach } : {}),
|
|
185
197
|
...(opts.targets && opts.targets.length > 0 ? { targets: opts.targets } : {}),
|
|
186
198
|
};
|
|
187
|
-
const values = {
|
|
199
|
+
const values = {
|
|
200
|
+
_FRONTMATTER_: serializeFrontmatter(meta),
|
|
201
|
+
_APPROACH_SECTION_: approach
|
|
202
|
+
? APPROACH_SECTION_WITH_APPROACH
|
|
203
|
+
: APPROACH_SECTION_WITHOUT_APPROACH,
|
|
204
|
+
};
|
|
188
205
|
// Finalize results pre-expand the confirmation record (done_criteria checklist and
|
|
189
206
|
// ready-promotion targets) so every finalize is verified against the same items.
|
|
190
207
|
// When the caller cannot resolve them, leave _TODO_ markers for manual fill-in.
|
|
@@ -192,7 +209,10 @@ export async function scaffoldResult(opts) {
|
|
|
192
209
|
values._DONE_CRITERIA_CHECKLIST_ = opts.finalizeSections?.doneCriteriaChecklist ?? "_TODO_";
|
|
193
210
|
values._FINALIZE_TARGETS_CHECKLIST_ = opts.finalizeSections?.targetsChecklist ?? "_TODO_";
|
|
194
211
|
}
|
|
195
|
-
|
|
212
|
+
let content = expandTemplate(template, values);
|
|
213
|
+
if (!approach && content.includes("## 4. 進め方と実践の型の適用")) {
|
|
214
|
+
content = content.replace(APPROACH_SECTION_WITH_APPROACH, APPROACH_SECTION_WITHOUT_APPROACH);
|
|
215
|
+
}
|
|
196
216
|
writeFileSync(resultPath, content, "utf8");
|
|
197
217
|
await formatMarkdownFile(resultPath);
|
|
198
218
|
const supersededPaths = await supersedePriorResults(resultsDir, taskId, resultPath, startedAt);
|
|
@@ -305,13 +325,154 @@ function reporterInlineText(value) {
|
|
|
305
325
|
.replace(/>/g, ">")
|
|
306
326
|
.trim();
|
|
307
327
|
}
|
|
328
|
+
// reporter / executor 由来の自由記述は result の Markdown 本文へ直接入る。改行や山括弧を
|
|
329
|
+
// 正規化したうえで、強調と解釈される `_` / `*` 入りの ASCII トークンを code span にする。
|
|
330
|
+
// escapeMarkdownInline は既存の code span を保持するため、agent が意図して付けた書式は二重化しない。
|
|
331
|
+
function reporterFreeText(value) {
|
|
332
|
+
return escapeMarkdownInline(reporterInlineText(value));
|
|
333
|
+
}
|
|
334
|
+
// reporter や runner の文を `- ` の箇条書きに描くとき、文が自前のリスト記号(`1.`・`1)`・
|
|
335
|
+
// `-`・`*`・`+`)で始まると `- 1. ...` が入れ子のリストとして解釈され、markdownlint の
|
|
336
|
+
// MD029 などに当たって pre-commit hook で記帳の commit が失敗する。箇条書きの記号は runner が
|
|
337
|
+
// 付けるため、先頭の記号は外す(番号の意味は箇条書きの順序で保たれる)。
|
|
338
|
+
export function stripLeadingListMarker(text) {
|
|
339
|
+
let current = text.trim();
|
|
340
|
+
for (;;) {
|
|
341
|
+
const next = current.replace(/^(?:\d{1,9}[.)]|[-*+])(?:\s+|$)/u, "").trim();
|
|
342
|
+
if (next === current)
|
|
343
|
+
return current;
|
|
344
|
+
current = next;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
308
347
|
function reporterBulletList(values, empty) {
|
|
309
348
|
if (values.length === 0)
|
|
310
349
|
return `- ${empty}`;
|
|
311
|
-
return values
|
|
350
|
+
return values
|
|
351
|
+
.map((value) => reporterFreeText(stripLeadingListMarker(reporterInlineText(value))))
|
|
352
|
+
.map((text) => `- ${text || empty}`)
|
|
353
|
+
.join("\n");
|
|
354
|
+
}
|
|
355
|
+
function findGitRoot(startDir) {
|
|
356
|
+
try {
|
|
357
|
+
let current = resolve(startDir);
|
|
358
|
+
while (true) {
|
|
359
|
+
if (existsSync(join(current, ".git"))) {
|
|
360
|
+
return current;
|
|
361
|
+
}
|
|
362
|
+
const parent = dirname(current);
|
|
363
|
+
if (parent === current)
|
|
364
|
+
return null;
|
|
365
|
+
current = parent;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
function collectGitLineStats(worktreeDir, files) {
|
|
373
|
+
const stats = new Map();
|
|
374
|
+
try {
|
|
375
|
+
const raw = execFileSync("git", ["diff", "--numstat", "-z", "HEAD", "--"], {
|
|
376
|
+
cwd: worktreeDir,
|
|
377
|
+
env: gitEnvironment(),
|
|
378
|
+
encoding: "utf8",
|
|
379
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
380
|
+
});
|
|
381
|
+
const parts = raw.split("\0");
|
|
382
|
+
for (let i = 0; i < parts.length; i++) {
|
|
383
|
+
const part = parts[i];
|
|
384
|
+
if (!part)
|
|
385
|
+
continue;
|
|
386
|
+
const match = part.match(/^(\d+|-)\t(\d+|-)\t(.*)$/);
|
|
387
|
+
if (match) {
|
|
388
|
+
const adds = match[1] === "-" ? 0 : parseInt(match[1], 10);
|
|
389
|
+
const dels = match[2] === "-" ? 0 : parseInt(match[2], 10);
|
|
390
|
+
let p = match[3];
|
|
391
|
+
if (!p && i + 2 < parts.length) {
|
|
392
|
+
const oldPath = parts[++i];
|
|
393
|
+
const newPath = parts[++i];
|
|
394
|
+
p = newPath;
|
|
395
|
+
stats.set(newPath, { additions: adds, deletions: dels });
|
|
396
|
+
stats.set(`${oldPath} -> ${newPath}`, { additions: adds, deletions: dels });
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
stats.set(p, { additions: adds, deletions: dels });
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
catch {
|
|
404
|
+
// git diff failed or worktree is not a git repository
|
|
405
|
+
}
|
|
406
|
+
for (const file of files) {
|
|
407
|
+
const targetPath = file.path.includes(" -> ") ? file.path.split(" -> ")[1] : file.path;
|
|
408
|
+
if (!stats.has(targetPath) && !stats.has(file.path)) {
|
|
409
|
+
if (file.status === "??" || file.status.includes("A")) {
|
|
410
|
+
try {
|
|
411
|
+
const fullPath = join(worktreeDir, targetPath);
|
|
412
|
+
if (existsSync(fullPath)) {
|
|
413
|
+
const stat = statSync(fullPath);
|
|
414
|
+
if (stat.isFile()) {
|
|
415
|
+
const fileContent = readFileSync(fullPath, "utf8");
|
|
416
|
+
const lines = fileContent.length === 0 ? 0 : fileContent.split("\n").length;
|
|
417
|
+
const entry = { additions: lines, deletions: 0 };
|
|
418
|
+
stats.set(targetPath, entry);
|
|
419
|
+
if (file.path !== targetPath) {
|
|
420
|
+
stats.set(file.path, entry);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
catch {
|
|
426
|
+
// ignore unreadable files
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return stats;
|
|
432
|
+
}
|
|
433
|
+
function formatMissingSummary(file, stats) {
|
|
434
|
+
const isRename = file.status.includes("R") || file.path.includes(" -> ");
|
|
435
|
+
const isAdd = file.status === "??" || file.status.includes("A");
|
|
436
|
+
const isDelete = file.status.includes("D");
|
|
437
|
+
let action;
|
|
438
|
+
if (isRename) {
|
|
439
|
+
const oldPath = file.path.includes(" -> ") ? file.path.split(" -> ")[0] : undefined;
|
|
440
|
+
action = oldPath ? `名前の変更(${reporterInlineText(oldPath)} から)` : "名前の変更";
|
|
441
|
+
}
|
|
442
|
+
else if (isAdd) {
|
|
443
|
+
action = "追加";
|
|
444
|
+
}
|
|
445
|
+
else if (isDelete) {
|
|
446
|
+
action = "削除";
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
action = "変更";
|
|
450
|
+
}
|
|
451
|
+
if (stats !== undefined) {
|
|
452
|
+
return `${action}、+${stats.additions} / -${stats.deletions} 行`;
|
|
453
|
+
}
|
|
454
|
+
return action;
|
|
312
455
|
}
|
|
313
|
-
function
|
|
456
|
+
function getFileDirectory(filePath) {
|
|
457
|
+
let cleanPath = filePath;
|
|
458
|
+
let repoPrefix = "";
|
|
459
|
+
if (filePath.includes(":")) {
|
|
460
|
+
const colonIdx = filePath.indexOf(":");
|
|
461
|
+
repoPrefix = filePath.slice(0, colonIdx + 1);
|
|
462
|
+
cleanPath = filePath.slice(colonIdx + 1);
|
|
463
|
+
}
|
|
464
|
+
const dir = dirname(cleanPath).split(sep).join("/");
|
|
465
|
+
if (dir === "." || dir === "") {
|
|
466
|
+
return repoPrefix ? `${repoPrefix}./` : "./";
|
|
467
|
+
}
|
|
468
|
+
return repoPrefix ? `${repoPrefix}${dir}/` : `${dir}/`;
|
|
469
|
+
}
|
|
470
|
+
export function renderEditReporterBody(output, evidence, options) {
|
|
314
471
|
const facts = deriveReporterFacts(evidence);
|
|
472
|
+
const lineStats = options?.lineStats ??
|
|
473
|
+
(options?.worktreeDir
|
|
474
|
+
? collectGitLineStats(options.worktreeDir, facts.changed_files)
|
|
475
|
+
: undefined);
|
|
315
476
|
const summariesByPath = new Map();
|
|
316
477
|
for (const file of output.changed_files) {
|
|
317
478
|
// The evidence path list remains authoritative. Ignore invented paths and keep the first
|
|
@@ -319,29 +480,108 @@ function renderEditReporterBody(output, evidence) {
|
|
|
319
480
|
if (!summariesByPath.has(file.path))
|
|
320
481
|
summariesByPath.set(file.path, file.summary);
|
|
321
482
|
}
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
483
|
+
const maxIndividual = options?.maxIndividualChangedFiles ?? MAX_INDIVIDUAL_CHANGED_FILES;
|
|
484
|
+
let changedFiles;
|
|
485
|
+
if (facts.changed_files.length === 0) {
|
|
486
|
+
changedFiles = "- なし";
|
|
487
|
+
}
|
|
488
|
+
else if (facts.changed_files.length <= maxIndividual) {
|
|
489
|
+
changedFiles = facts.changed_files
|
|
490
|
+
.map((file) => {
|
|
491
|
+
const displayPath = file.path.includes(" -> ") ? file.path.split(" -> ")[1] : file.path;
|
|
492
|
+
const reporterSummary = summariesByPath.get(displayPath) ?? summariesByPath.get(file.path);
|
|
493
|
+
const summary = reporterSummary !== undefined && reporterSummary.trim().length > 0
|
|
494
|
+
? reporterSummary
|
|
495
|
+
: formatMissingSummary(file, lineStats?.get(displayPath) ?? lineStats?.get(file.path));
|
|
496
|
+
return `- \`${reporterInlineText(displayPath).replace(/`/g, "'")}\`: ${reporterFreeText(summary)}`;
|
|
497
|
+
})
|
|
326
498
|
.join("\n");
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
// Over threshold: list described files individually, and group undescribed files by directory.
|
|
502
|
+
const describedFiles = [];
|
|
503
|
+
const undescribedFiles = [];
|
|
504
|
+
const describedCountByDir = new Map();
|
|
505
|
+
for (const file of facts.changed_files) {
|
|
506
|
+
const displayPath = file.path.includes(" -> ") ? file.path.split(" -> ")[1] : file.path;
|
|
507
|
+
const reporterSummary = summariesByPath.get(displayPath) ?? summariesByPath.get(file.path);
|
|
508
|
+
if (reporterSummary !== undefined && reporterSummary.trim().length > 0) {
|
|
509
|
+
describedFiles.push({ displayPath, summary: reporterSummary });
|
|
510
|
+
const dir = getFileDirectory(displayPath);
|
|
511
|
+
describedCountByDir.set(dir, (describedCountByDir.get(dir) ?? 0) + 1);
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
undescribedFiles.push({ displayPath, file });
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
const lines = [];
|
|
518
|
+
for (const entry of describedFiles) {
|
|
519
|
+
lines.push(`- \`${reporterInlineText(entry.displayPath).replace(/`/g, "'")}\`: ${reporterFreeText(entry.summary)}`);
|
|
520
|
+
}
|
|
521
|
+
const dirGroups = new Map();
|
|
522
|
+
for (const entry of undescribedFiles) {
|
|
523
|
+
const dir = getFileDirectory(entry.displayPath);
|
|
524
|
+
let group = dirGroups.get(dir);
|
|
525
|
+
if (!group) {
|
|
526
|
+
group = {
|
|
527
|
+
count: 0,
|
|
528
|
+
operations: new Map(),
|
|
529
|
+
additions: 0,
|
|
530
|
+
deletions: 0,
|
|
531
|
+
hasLineStats: false,
|
|
532
|
+
};
|
|
533
|
+
dirGroups.set(dir, group);
|
|
534
|
+
}
|
|
535
|
+
group.count++;
|
|
536
|
+
const isRename = entry.file.status.includes("R") || entry.file.path.includes(" -> ");
|
|
537
|
+
const isAdd = entry.file.status === "??" || entry.file.status.includes("A");
|
|
538
|
+
const isDelete = entry.file.status.includes("D");
|
|
539
|
+
const op = isRename ? "名前の変更" : isAdd ? "追加" : isDelete ? "削除" : "変更";
|
|
540
|
+
group.operations.set(op, (group.operations.get(op) ?? 0) + 1);
|
|
541
|
+
const stats = lineStats?.get(entry.displayPath) ?? lineStats?.get(entry.file.path);
|
|
542
|
+
if (stats !== undefined) {
|
|
543
|
+
group.additions += stats.additions;
|
|
544
|
+
group.deletions += stats.deletions;
|
|
545
|
+
group.hasLineStats = true;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
const sortedDirs = [...dirGroups.keys()].sort((a, b) => a.localeCompare(b));
|
|
549
|
+
const operationOrder = ["変更", "追加", "削除", "名前の変更"];
|
|
550
|
+
for (const dir of sortedDirs) {
|
|
551
|
+
const group = dirGroups.get(dir);
|
|
552
|
+
const describedInDir = describedCountByDir.get(dir) ?? 0;
|
|
553
|
+
const countText = describedInDir > 0 ? `ほか ${group.count} 件` : `${group.count} 件`;
|
|
554
|
+
const sortedOps = [...group.operations.keys()].sort((a, b) => {
|
|
555
|
+
const idxA = operationOrder.indexOf(a);
|
|
556
|
+
const idxB = operationOrder.indexOf(b);
|
|
557
|
+
return (idxA === -1 ? 999 : idxA) - (idxB === -1 ? 999 : idxB);
|
|
558
|
+
});
|
|
559
|
+
const opParts = sortedOps.map((op) => `${op} ${group.operations.get(op)} 件`);
|
|
560
|
+
const lineStatsPart = group.hasLineStats
|
|
561
|
+
? `、+${group.additions} / -${group.deletions} 行`
|
|
562
|
+
: "";
|
|
563
|
+
lines.push(`- \`${reporterInlineText(dir)}\`: ${countText}(${opParts.join("、")}${lineStatsPart})`);
|
|
564
|
+
}
|
|
565
|
+
changedFiles = lines.length === 0 ? "- なし" : lines.join("\n");
|
|
566
|
+
}
|
|
327
567
|
const unchangedTargetNotes = (evidence?.target_coverage ?? [])
|
|
328
568
|
.filter((entry) => entry.status === "unchanged")
|
|
329
569
|
.map((entry) => {
|
|
330
570
|
const target = reporterInlineText(entry.target).replace(/`/g, "'");
|
|
331
|
-
return `対象 \`${target}\` は未変更: ${
|
|
571
|
+
return `対象 \`${target}\` は未変更: ${reporterFreeText(entry.reason)}`;
|
|
332
572
|
});
|
|
333
573
|
const humanValidationNotes = evidence.validations
|
|
334
574
|
.filter((validation) => validation.source !== "runner" && validation.status === "requires_human")
|
|
335
575
|
.map((validation) => {
|
|
336
576
|
const command = reporterInlineText(validation.command).replace(/`/g, "'");
|
|
337
|
-
const summary =
|
|
577
|
+
const summary = reporterFreeText(validation.summary) || "要約なし";
|
|
338
578
|
return `人の確認が必要: \`${command}\`(${summary})`;
|
|
339
579
|
});
|
|
340
580
|
const notApplicableValidationNotes = evidence.validations
|
|
341
581
|
.filter((validation) => validation.source !== "runner" && validation.status === "not_applicable")
|
|
342
582
|
.map((validation) => {
|
|
343
583
|
const command = reporterInlineText(validation.command).replace(/`/g, "'");
|
|
344
|
-
const reason =
|
|
584
|
+
const reason = reporterFreeText(validation.reason ?? "") || "理由なし";
|
|
345
585
|
return `適用外の検証: \`${command}\`(${reason})`;
|
|
346
586
|
});
|
|
347
587
|
const changedPaths = evidence.changes.map((change) => change.path);
|
|
@@ -352,7 +592,7 @@ function renderEditReporterBody(output, evidence) {
|
|
|
352
592
|
if (reason === undefined)
|
|
353
593
|
return [];
|
|
354
594
|
const command = reporterInlineText(validation.command).replace(/`/g, "'");
|
|
355
|
-
return [`runner が担う検証: \`${command}\`(${
|
|
595
|
+
return [`runner が担う検証: \`${command}\`(${reporterFreeText(reason)})`];
|
|
356
596
|
});
|
|
357
597
|
const runnerJudgedNotApplicableNotes = evidence.validations
|
|
358
598
|
.filter((validation) => validation.source !== "runner" && validation.status === "not_run")
|
|
@@ -361,8 +601,11 @@ function renderEditReporterBody(output, evidence) {
|
|
|
361
601
|
if (reason === undefined)
|
|
362
602
|
return [];
|
|
363
603
|
const command = reporterInlineText(validation.command).replace(/`/g, "'");
|
|
364
|
-
return [`適用外の検証(runner の判定): \`${command}\`(${
|
|
604
|
+
return [`適用外の検証(runner の判定): \`${command}\`(${reporterFreeText(reason)})`];
|
|
365
605
|
});
|
|
606
|
+
const rateLimitRecoveryNotes = (evidence.rate_limit_events ?? []).map((event) => event.action === "wait"
|
|
607
|
+
? `rate limit 後に ${event.resume_at ?? "再開可能時刻"} まで待ち、${event.to_actor} で ${event.resumed_at} に再開`
|
|
608
|
+
: `${event.trigger === "connection_error" ? "接続エラー" : "rate limit"}後に ${event.from_actor} から ${event.to_actor} へ切り替え、${event.resumed_at} に再開`);
|
|
366
609
|
return [
|
|
367
610
|
"# Edit Result",
|
|
368
611
|
"",
|
|
@@ -383,26 +626,30 @@ function renderEditReporterBody(output, evidence) {
|
|
|
383
626
|
...runnerOwnedValidationNotes,
|
|
384
627
|
...runnerJudgedNotApplicableNotes,
|
|
385
628
|
...humanValidationNotes,
|
|
629
|
+
...rateLimitRecoveryNotes,
|
|
386
630
|
], "なし"),
|
|
387
631
|
"",
|
|
388
|
-
"## 4. 進め方と実践の型の適用",
|
|
632
|
+
options?.approach ? "## 4. 進め方と実践の型の適用" : "## 4. 進め方",
|
|
389
633
|
"",
|
|
390
|
-
|
|
634
|
+
reporterFreeText(output.approach),
|
|
391
635
|
].join("\n");
|
|
392
636
|
}
|
|
393
637
|
// review result の章立ては xrr-template.md と一致させる。review は成果物を再評価しないため、
|
|
394
638
|
// 観点別の結果ではなく評価結果の確認・判断根拠・改善指示・verdict を記録する。
|
|
395
|
-
function renderReviewReporterBody(output) {
|
|
639
|
+
function renderReviewReporterBody(output, evidence) {
|
|
640
|
+
const rateLimitRecoveryNotes = (evidence.rate_limit_events ?? []).map((event) => event.action === "wait"
|
|
641
|
+
? `rate limit 後に ${event.resume_at ?? "再開可能時刻"} まで待ち、${event.to_actor} で ${event.resumed_at} に再開`
|
|
642
|
+
: `${event.trigger === "connection_error" ? "接続エラー" : "rate limit"}後に ${event.from_actor} から ${event.to_actor} へ切り替え、${event.resumed_at} に再開`);
|
|
396
643
|
return [
|
|
397
644
|
"# Review Result",
|
|
398
645
|
"",
|
|
399
646
|
"## 1. 評価結果の確認",
|
|
400
647
|
"",
|
|
401
|
-
|
|
648
|
+
reporterFreeText(output.grade_check),
|
|
402
649
|
"",
|
|
403
650
|
"## 2. 判断根拠",
|
|
404
651
|
"",
|
|
405
|
-
reporterBulletList(output.rationale, "なし"),
|
|
652
|
+
reporterBulletList([...output.rationale, ...rateLimitRecoveryNotes], "なし"),
|
|
406
653
|
"",
|
|
407
654
|
"## 3. 未充足事項・改善指示",
|
|
408
655
|
"",
|
|
@@ -410,7 +657,7 @@ function renderReviewReporterBody(output) {
|
|
|
410
657
|
"",
|
|
411
658
|
"## 4. approach に応じた確認",
|
|
412
659
|
"",
|
|
413
|
-
|
|
660
|
+
reporterFreeText(output.approach),
|
|
414
661
|
"",
|
|
415
662
|
"## 5. decision",
|
|
416
663
|
"",
|
|
@@ -421,7 +668,7 @@ function renderReviewReporterBody(output) {
|
|
|
421
668
|
* Replaces only the result body from schema-validated reporter data. The scaffolded frontmatter
|
|
422
669
|
* remains byte-for-byte runner-owned until the lifecycle status update serializes it.
|
|
423
670
|
*/
|
|
424
|
-
export async function renderReporterResult(resultPath, output, evidence) {
|
|
671
|
+
export async function renderReporterResult(resultPath, output, evidence, options) {
|
|
425
672
|
if (!existsSync(resultPath))
|
|
426
673
|
throw new Error(`Result not found: ${resultPath}`);
|
|
427
674
|
const content = readFileSync(resultPath, "utf8");
|
|
@@ -432,9 +679,18 @@ export async function renderReporterResult(resultPath, output, evidence) {
|
|
|
432
679
|
const frontmatter = content.match(/^---\r?\n[\s\S]*?\r?\n---/)?.[0];
|
|
433
680
|
if (!frontmatter)
|
|
434
681
|
throw new Error(`Result frontmatter not found: ${resultPath}`);
|
|
682
|
+
const approach = options?.approach ??
|
|
683
|
+
(typeof parsed.data.approach === "string" && parsed.data.approach.trim().length > 0
|
|
684
|
+
? parsed.data.approach
|
|
685
|
+
: undefined);
|
|
686
|
+
const resolvedOptions = {
|
|
687
|
+
...options,
|
|
688
|
+
...(approach ? { approach } : {}),
|
|
689
|
+
worktreeDir: options?.worktreeDir ?? findGitRoot(dirname(resultPath)) ?? undefined,
|
|
690
|
+
};
|
|
435
691
|
const body = output.mode === "edit"
|
|
436
|
-
? renderEditReporterBody(output, evidence)
|
|
437
|
-
: renderReviewReporterBody(output);
|
|
692
|
+
? renderEditReporterBody(output, evidence, resolvedOptions)
|
|
693
|
+
: renderReviewReporterBody(output, evidence);
|
|
438
694
|
writeFileSync(resultPath, frontmatterWithBody(frontmatter, body), "utf8");
|
|
439
695
|
await formatMarkdownFile(resultPath);
|
|
440
696
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { relative, sep } from "node:path";
|
|
2
|
-
import { recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "
|
|
3
|
-
import { failedParentValidationReason, hasRecordedParentValidations, parentValidationRoots, replaceParentValidationResults, } from "
|
|
4
|
-
import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "
|
|
5
|
-
import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "
|
|
6
|
-
import { renderReporterResult } from "
|
|
7
|
-
import { randomHex } from "
|
|
8
|
-
import { withProductRepoPrompt } from "
|
|
9
|
-
import { worktreeStatusPaths } from "
|
|
10
|
-
import { agentEnvironment, appendParentValidationsToExecutorEvidence, buildExecutorPrompt, extractBlockReason, resumedTargetCoverageFailure, runConfiguredParentValidationBatch, runWithRetry, } from "./
|
|
2
|
+
import { recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "../evidence.js";
|
|
3
|
+
import { failedParentValidationReason, hasRecordedParentValidations, parentValidationRoots, replaceParentValidationResults, } from "../parent-validation.js";
|
|
4
|
+
import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "../pipeline-state.js";
|
|
5
|
+
import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "../reporter.js";
|
|
6
|
+
import { renderReporterResult } from "../results.js";
|
|
7
|
+
import { randomHex } from "../shared.js";
|
|
8
|
+
import { withProductRepoPrompt } from "../task-repos.js";
|
|
9
|
+
import { worktreeStatusPaths } from "../worktree-ops.js";
|
|
10
|
+
import { agentEnvironment, appendParentValidationsToExecutorEvidence, buildExecutorPrompt, extractBlockReason, resumedTargetCoverageFailure, runConfiguredParentValidationBatch, runWithRetry, } from "./agent.js";
|
|
11
11
|
export async function refreshParentValidationsForReporterResume(params) {
|
|
12
12
|
const configuredEntries = params.execDefaults.pipeline?.parent_validations;
|
|
13
13
|
const force = params.force === true && (configuredEntries?.length ?? 0) > 0;
|
|
@@ -56,13 +56,17 @@ export async function runReporterStage(params) {
|
|
|
56
56
|
writePipelineState(params.statePath, state);
|
|
57
57
|
process.stdout.write(` Running reporter: ${reporterCandidates[0]?.command ?? ""}\n`);
|
|
58
58
|
let reporterAttempts = 0;
|
|
59
|
+
let reporterActor = reporterCandidates[0]?.actor;
|
|
60
|
+
const rateLimitEvents = [];
|
|
59
61
|
const runReporter = () => runReporterWithFormatRetry({
|
|
60
62
|
plan: params.planPrompt,
|
|
61
63
|
evidence: reporterEvidence,
|
|
62
64
|
mode: params.mode ?? "edit",
|
|
63
65
|
invoke: async (reporterPrompt) => {
|
|
64
|
-
const reporterOutcome = await runWithRetry(reporterCandidates, reporterPrompt, execDefaults, cwd, env, params.resultPath);
|
|
66
|
+
const reporterOutcome = await runWithRetry(reporterCandidates, reporterPrompt, execDefaults, cwd, env, params.resultPath, params.rateLimitOptions);
|
|
65
67
|
reporterAttempts += reporterOutcome.attempts;
|
|
68
|
+
reporterActor = reporterOutcome.actor ?? reporterActor;
|
|
69
|
+
rateLimitEvents.push(...reporterOutcome.rateLimitEvents);
|
|
66
70
|
return {
|
|
67
71
|
result: reporterOutcome.result,
|
|
68
72
|
stdout: reporterOutcome.stdout,
|
|
@@ -73,6 +77,14 @@ export async function runReporterStage(params) {
|
|
|
73
77
|
const reporter = params.providerConcurrencyGate
|
|
74
78
|
? await params.providerConcurrencyGate.run(reporterCandidates[0]?.provider, runReporter, `${params.evidence.task_id} reporter`)
|
|
75
79
|
: await runReporter();
|
|
80
|
+
if (rateLimitEvents.length > 0) {
|
|
81
|
+
params.evidence.rate_limit_events = [
|
|
82
|
+
...(params.evidence.rate_limit_events ?? []),
|
|
83
|
+
...rateLimitEvents,
|
|
84
|
+
];
|
|
85
|
+
reporterEvidence.rate_limit_events = params.evidence.rate_limit_events;
|
|
86
|
+
writeExecutorEvidence(params.evidencePath, params.evidence);
|
|
87
|
+
}
|
|
76
88
|
let exitCode = 1;
|
|
77
89
|
let blockReason;
|
|
78
90
|
if (reporter.result === "success") {
|
|
@@ -104,10 +116,12 @@ export async function runReporterStage(params) {
|
|
|
104
116
|
state = updatePipelineStage(state, "reporter", {
|
|
105
117
|
status: exitCode === 0 ? "succeeded" : reporter.result === "rate_limit" ? "rate_limited" : "failed",
|
|
106
118
|
attempts: state.stages.reporter.attempts + reporterAttempts,
|
|
119
|
+
actor: reporterActor ?? null,
|
|
107
120
|
completed_at: reporterCompletedAt,
|
|
108
121
|
artifact_ref: reporter.result === "success"
|
|
109
122
|
? relative(cwd, params.resultPath).split(sep).join("/")
|
|
110
123
|
: state.stages.reporter.artifact_ref,
|
|
124
|
+
...(rateLimitEvents.length > 0 ? { rate_limit_events: rateLimitEvents } : {}),
|
|
111
125
|
}, reporterCompletedAt);
|
|
112
126
|
writePipelineState(params.statePath, state);
|
|
113
127
|
const runResult = exitCode === 0 ? "success" : reporter.result === "rate_limit" ? "rate_limit" : "failure";
|
|
@@ -143,6 +157,9 @@ export async function runAgentPipeline(params) {
|
|
|
143
157
|
plan_ref: relative(repoRoot, params.planPath).split(sep).join("/"),
|
|
144
158
|
result_ref: relative(cwd, resultPath).split(sep).join("/"),
|
|
145
159
|
},
|
|
160
|
+
...(params.integrationBranchOverrides
|
|
161
|
+
? { integrationBranches: { ...params.integrationBranchOverrides } }
|
|
162
|
+
: {}),
|
|
146
163
|
});
|
|
147
164
|
state = updatePipelineStage(state, "executor", { status: "running", started_at: startedAt }, startedAt);
|
|
148
165
|
writePipelineState(stateLocation.path, state);
|
|
@@ -157,7 +174,7 @@ export async function runAgentPipeline(params) {
|
|
|
157
174
|
...(params.resumedExecutor ? { resumeHandoff: params.resumeHandoff ?? [] } : {}),
|
|
158
175
|
}), params.productWorktrees);
|
|
159
176
|
const changesBeforeAttempt = snapshotWorktreeChanges(cwd, params.productWorktrees);
|
|
160
|
-
const runExecutor = () => runWithRetry([executor], executorPrompt, execDefaults, cwd, env, resultPath);
|
|
177
|
+
const runExecutor = () => runWithRetry([executor], executorPrompt, execDefaults, cwd, env, resultPath, params.executorRateLimitOptions);
|
|
161
178
|
const outcome = params.providerConcurrencyGate
|
|
162
179
|
? await params.providerConcurrencyGate.run(executor.provider, runExecutor, `${taskId} executor`)
|
|
163
180
|
: await runExecutor();
|
|
@@ -167,7 +184,7 @@ export async function runAgentPipeline(params) {
|
|
|
167
184
|
executionPath,
|
|
168
185
|
taskId,
|
|
169
186
|
runId,
|
|
170
|
-
actor: executor.actor,
|
|
187
|
+
actor: outcome.actor ?? executor.actor,
|
|
171
188
|
status: outcome.result === "success"
|
|
172
189
|
? "succeeded"
|
|
173
190
|
: outcome.result === "rate_limit"
|
|
@@ -181,6 +198,7 @@ export async function runAgentPipeline(params) {
|
|
|
181
198
|
stderr: outcome.stderr,
|
|
182
199
|
changesBeforeAttempt,
|
|
183
200
|
productWorktrees: params.productWorktrees,
|
|
201
|
+
rateLimitEvents: outcome.rateLimitEvents,
|
|
184
202
|
});
|
|
185
203
|
const coverageFailure = outcome.result === "success"
|
|
186
204
|
? resumedTargetCoverageFailure({
|
|
@@ -203,8 +221,10 @@ export async function runAgentPipeline(params) {
|
|
|
203
221
|
? "rate_limited"
|
|
204
222
|
: "failed",
|
|
205
223
|
attempts: outcome.attempts,
|
|
224
|
+
actor: outcome.actor ?? executor.actor,
|
|
206
225
|
completed_at: executorCompletedAt,
|
|
207
226
|
artifact_ref: evidenceRef,
|
|
227
|
+
...(outcome.rateLimitEvents.length > 0 ? { rate_limit_events: outcome.rateLimitEvents } : {}),
|
|
208
228
|
}, executorCompletedAt);
|
|
209
229
|
writePipelineState(stateLocation.path, state);
|
|
210
230
|
process.stdout.write(` Executor evidence: ${evidenceRef}\n`);
|
|
@@ -219,6 +239,7 @@ export async function runAgentPipeline(params) {
|
|
|
219
239
|
blockReason,
|
|
220
240
|
stateRef: stateLocation.ref,
|
|
221
241
|
evidenceRef,
|
|
242
|
+
rateLimitEvents: outcome.rateLimitEvents,
|
|
222
243
|
};
|
|
223
244
|
}
|
|
224
245
|
recorded.evidence = await appendParentValidationsToExecutorEvidence({
|
|
@@ -245,6 +266,7 @@ export async function runAgentPipeline(params) {
|
|
|
245
266
|
providerConcurrencyGate: params.providerConcurrencyGate,
|
|
246
267
|
productWorktrees: params.productWorktrees,
|
|
247
268
|
mode: params.mode,
|
|
269
|
+
rateLimitOptions: params.reporterRateLimitOptions,
|
|
248
270
|
});
|
|
249
271
|
return {
|
|
250
272
|
exitCode: reporterOutcome.exitCode,
|
|
@@ -252,5 +274,6 @@ export async function runAgentPipeline(params) {
|
|
|
252
274
|
blockReason: reporterOutcome.blockReason,
|
|
253
275
|
stateRef: stateLocation.ref,
|
|
254
276
|
evidenceRef,
|
|
277
|
+
rateLimitEvents: recorded.evidence.rate_limit_events ?? [],
|
|
255
278
|
};
|
|
256
279
|
}
|