specdojo 0.3.1 → 0.4.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/CHANGELOG.md +47 -0
- package/README.md +77 -18
- 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} +98 -32
- package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
- 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} +5 -3
- package/dist/{devcontainer-scaffold.js → devcontainer/scaffold.js} +94 -2
- 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} +33 -4
- 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} +4 -4
- package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +16 -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} +92 -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} +13 -10
- 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} +29 -12
- package/dist/{exec-results.js → exec/results.js} +256 -22
- package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +32 -12
- package/dist/{exec-run-agent.js → exec/run/agent.js} +79 -27
- package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
- package/dist/{exec-run-job.js → exec/run/job.js} +64 -35
- 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} +18 -10
- package/dist/{exec-run-register-core.js → exec/run/register-core.js} +46 -21
- package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +20 -16
- package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +22 -17
- 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} +54 -23
- 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} +61 -11
- 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} +2 -2
- 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} +13 -7
- package/dist/{register-create-commands.js → register/create-commands.js} +115 -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} +32 -3
- package/dist/{register-events.js → register/events.js} +9 -3
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +23 -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} +4 -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/{exec-worktree.js → shared/git.js} +83 -241
- 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} +3 -1
- 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} +93 -5
- package/dist/{exec-shared.js → shared/text.js} +0 -134
- package/dist/shared/time.js +28 -0
- package/dist/specdojo.js +22 -22
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +29 -17
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -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/guides/exec-config-guide.md +91 -16
- package/docs/ja/specdojo/guides/exec-operation-guide.md +145 -12
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +31 -0
- package/docs/ja/specdojo/guides/quick-start-guide.md +81 -16
- package/docs/ja/specdojo/guides/register-operation-guide.md +2 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +10 -1
- 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/use-case-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +52 -28
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +17 -11
- 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 +20 -0
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +23 -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 +26 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +70 -7
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +1 -1
- package/package.json +1 -1
- package/templates/antigravity/README.md +5 -1
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
- 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/codex/README.md +23 -4
- package/templates/devcontainer/devcontainer.json +2 -2
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +69 -0
- package/templates/devcontainer/remote-host/ssh-config.sample +16 -0
- package/templates/init-agent-members.yaml +75 -25
- package/templates/init-exec-defaults.yaml +24 -8
- 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/dist/exec-schedule-gantt-chart.js +0 -2
- 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,9 +1,9 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import { PARENT_VALIDATION_PROJECT_REPO, failedParentValidationReason, } from "./
|
|
4
|
-
import { getProjectExecutionPath, resolveRepoRoot, specdojoRootDir, } from "
|
|
5
|
-
import { MAX_TEXT_LENGTH, parseReporterOutput, reporterOutputSchemaForMode, } from "./
|
|
6
|
-
export { REPORTER_OUTPUT_SCHEMA, REVIEW_VERDICTS, parseReporterOutput, reporterOutputSchemaForMode, } from "./
|
|
3
|
+
import { PARENT_VALIDATION_PROJECT_REPO, failedParentValidationReason, } from "./parent-validation.js";
|
|
4
|
+
import { getProjectExecutionPath, resolveRepoRoot, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
5
|
+
import { MAX_TEXT_LENGTH, parseReporterOutput, reporterOutputSchemaForMode, } from "./reporter-output.js";
|
|
6
|
+
export { REPORTER_OUTPUT_SCHEMA, REVIEW_VERDICTS, parseReporterOutput, reporterOutputSchemaForMode, } from "./reporter-output.js";
|
|
7
7
|
const REPORTER_FORMAT_ATTEMPTS = 3;
|
|
8
8
|
function isProjectConfig(value) {
|
|
9
9
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -244,6 +244,20 @@ function invokedScriptNameOf(command) {
|
|
|
244
244
|
return "test";
|
|
245
245
|
return /^npm run ([A-Za-z0-9:_.-]+)(?:\s|$)/u.exec(command)?.[1];
|
|
246
246
|
}
|
|
247
|
+
// `npm init` が入れる仮の test script(`echo "Error: no test specified" && exit 1`)。引用符の
|
|
248
|
+
// 有無・種類と空白の違いを許す。中身が常に失敗する仮置きなので、適用条件では script がないものとみなす。
|
|
249
|
+
const NPM_INIT_PLACEHOLDER_TEST_PATTERN = /^echo\s+(["']?)Error:\s*no\s+test\s+specified\1\s*&&\s*exit\s+1\s*;?$/iu;
|
|
250
|
+
function isNpmInitPlaceholderTestScript(body) {
|
|
251
|
+
return NPM_INIT_PLACEHOLDER_TEST_PATTERN.test(body.trim());
|
|
252
|
+
}
|
|
253
|
+
// 適用条件の判定で script があるとみなすか。`test` の仮の script は executor と runner の判断を
|
|
254
|
+
// そろえるため、ないものとして扱う(PJR-6EF8)。
|
|
255
|
+
function hasApplicableScript(scripts, scriptName) {
|
|
256
|
+
const body = scripts[scriptName];
|
|
257
|
+
if (body === undefined)
|
|
258
|
+
return false;
|
|
259
|
+
return !(scriptName === "test" && isNpmInitPlaceholderTestScript(body));
|
|
260
|
+
}
|
|
247
261
|
function npxPackageNameOf(command) {
|
|
248
262
|
return /^npx\s+((?:@[A-Za-z0-9_.-]+\/)?[A-Za-z0-9_.-]+)(?:\s|$)/u.exec(command)?.[1];
|
|
249
263
|
}
|
|
@@ -324,8 +338,10 @@ export function mechanicallyNotApplicableReason(command, options = {}) {
|
|
|
324
338
|
const manifest = commandManifest(normalized, options, config);
|
|
325
339
|
const packageJson = manifest.repoName === undefined ? "package.json" : `${manifest.repoName} の package.json`;
|
|
326
340
|
const scriptName = invokedScriptNameOf(manifest.command);
|
|
327
|
-
if (scriptName !== undefined && manifest.scripts
|
|
328
|
-
return
|
|
341
|
+
if (scriptName !== undefined && !hasApplicableScript(manifest.scripts, scriptName)) {
|
|
342
|
+
return manifest.scripts[scriptName] === undefined
|
|
343
|
+
? `${packageJson} に npm script '${scriptName}' がない`
|
|
344
|
+
: `${packageJson} の npm script '${scriptName}' は npm init の仮の script である`;
|
|
329
345
|
}
|
|
330
346
|
const packageName = npxPackageNameOf(manifest.command);
|
|
331
347
|
if (packageName !== undefined && !manifest.dependencies.has(packageName)) {
|
|
@@ -343,7 +359,7 @@ function isValidNotApplicableValidation(command, reason, options) {
|
|
|
343
359
|
return specdojo.applicable !== true;
|
|
344
360
|
const manifest = commandManifest(normalized, options, config);
|
|
345
361
|
const scriptName = invokedScriptNameOf(manifest.command);
|
|
346
|
-
if (scriptName !== undefined && manifest.scripts
|
|
362
|
+
if (scriptName !== undefined && hasApplicableScript(manifest.scripts, scriptName))
|
|
347
363
|
return false;
|
|
348
364
|
const packageName = npxPackageNameOf(manifest.command);
|
|
349
365
|
return packageName === undefined || !manifest.dependencies.has(packageName);
|
|
@@ -547,11 +563,12 @@ misread it as emphasis.
|
|
|
547
563
|
The plan below was written as generic instructions for a single agent that both edits the
|
|
548
564
|
deliverable and records its own result. In this pipeline, those two responsibilities are split:
|
|
549
565
|
the executor already completed the deliverable edit and intentionally left the result file
|
|
550
|
-
untouched because the runner writes it from your prose and machine facts. For edit mode,
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
566
|
+
untouched because the runner writes it from your prose and machine facts. For edit mode, explain
|
|
567
|
+
what was changed in each file in changed_files, especially deliverables (docs/), source files (src/),
|
|
568
|
+
and test files (tests/). Identify each changed_files summary with the exact path from its evidence.changes
|
|
569
|
+
entry. The runner matches descriptions by path: order does not matter, missing descriptions are filled
|
|
570
|
+
with Git change metadata by the runner, and paths absent from evidence are discarded. Do not include
|
|
571
|
+
statuses. An empty changes list requires an empty changed_files list. Validation entries with source="runner" were executed by the parent
|
|
555
572
|
process and remain authoritative machine facts. Do not turn them into outcome or block_reason
|
|
556
573
|
fields. When runner_context is present, it contains additional authoritative facts: do not ask for
|
|
557
574
|
a command in mechanically_not_applicable to be run, because the runner already determined that it
|
|
@@ -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 { 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);
|
|
@@ -310,8 +330,127 @@ function reporterBulletList(values, empty) {
|
|
|
310
330
|
return `- ${empty}`;
|
|
311
331
|
return values.map((value) => `- ${reporterInlineText(value)}`).join("\n");
|
|
312
332
|
}
|
|
313
|
-
function
|
|
333
|
+
function findGitRoot(startDir) {
|
|
334
|
+
try {
|
|
335
|
+
let current = resolve(startDir);
|
|
336
|
+
while (true) {
|
|
337
|
+
if (existsSync(join(current, ".git"))) {
|
|
338
|
+
return current;
|
|
339
|
+
}
|
|
340
|
+
const parent = dirname(current);
|
|
341
|
+
if (parent === current)
|
|
342
|
+
return null;
|
|
343
|
+
current = parent;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function collectGitLineStats(worktreeDir, files) {
|
|
351
|
+
const stats = new Map();
|
|
352
|
+
try {
|
|
353
|
+
const raw = execFileSync("git", ["diff", "--numstat", "-z", "HEAD", "--"], {
|
|
354
|
+
cwd: worktreeDir,
|
|
355
|
+
env: gitEnvironment(),
|
|
356
|
+
encoding: "utf8",
|
|
357
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
358
|
+
});
|
|
359
|
+
const parts = raw.split("\0");
|
|
360
|
+
for (let i = 0; i < parts.length; i++) {
|
|
361
|
+
const part = parts[i];
|
|
362
|
+
if (!part)
|
|
363
|
+
continue;
|
|
364
|
+
const match = part.match(/^(\d+|-)\t(\d+|-)\t(.*)$/);
|
|
365
|
+
if (match) {
|
|
366
|
+
const adds = match[1] === "-" ? 0 : parseInt(match[1], 10);
|
|
367
|
+
const dels = match[2] === "-" ? 0 : parseInt(match[2], 10);
|
|
368
|
+
let p = match[3];
|
|
369
|
+
if (!p && i + 2 < parts.length) {
|
|
370
|
+
const oldPath = parts[++i];
|
|
371
|
+
const newPath = parts[++i];
|
|
372
|
+
p = newPath;
|
|
373
|
+
stats.set(newPath, { additions: adds, deletions: dels });
|
|
374
|
+
stats.set(`${oldPath} -> ${newPath}`, { additions: adds, deletions: dels });
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
stats.set(p, { additions: adds, deletions: dels });
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
// git diff failed or worktree is not a git repository
|
|
383
|
+
}
|
|
384
|
+
for (const file of files) {
|
|
385
|
+
const targetPath = file.path.includes(" -> ") ? file.path.split(" -> ")[1] : file.path;
|
|
386
|
+
if (!stats.has(targetPath) && !stats.has(file.path)) {
|
|
387
|
+
if (file.status === "??" || file.status.includes("A")) {
|
|
388
|
+
try {
|
|
389
|
+
const fullPath = join(worktreeDir, targetPath);
|
|
390
|
+
if (existsSync(fullPath)) {
|
|
391
|
+
const stat = statSync(fullPath);
|
|
392
|
+
if (stat.isFile()) {
|
|
393
|
+
const fileContent = readFileSync(fullPath, "utf8");
|
|
394
|
+
const lines = fileContent.length === 0 ? 0 : fileContent.split("\n").length;
|
|
395
|
+
const entry = { additions: lines, deletions: 0 };
|
|
396
|
+
stats.set(targetPath, entry);
|
|
397
|
+
if (file.path !== targetPath) {
|
|
398
|
+
stats.set(file.path, entry);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
catch {
|
|
404
|
+
// ignore unreadable files
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return stats;
|
|
410
|
+
}
|
|
411
|
+
function formatMissingSummary(file, stats) {
|
|
412
|
+
const isRename = file.status.includes("R") || file.path.includes(" -> ");
|
|
413
|
+
const isAdd = file.status === "??" || file.status.includes("A");
|
|
414
|
+
const isDelete = file.status.includes("D");
|
|
415
|
+
let action;
|
|
416
|
+
if (isRename) {
|
|
417
|
+
const oldPath = file.path.includes(" -> ") ? file.path.split(" -> ")[0] : undefined;
|
|
418
|
+
action = oldPath ? `名前の変更(${reporterInlineText(oldPath)} から)` : "名前の変更";
|
|
419
|
+
}
|
|
420
|
+
else if (isAdd) {
|
|
421
|
+
action = "追加";
|
|
422
|
+
}
|
|
423
|
+
else if (isDelete) {
|
|
424
|
+
action = "削除";
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
action = "変更";
|
|
428
|
+
}
|
|
429
|
+
if (stats !== undefined) {
|
|
430
|
+
return `${action}、+${stats.additions} / -${stats.deletions} 行`;
|
|
431
|
+
}
|
|
432
|
+
return action;
|
|
433
|
+
}
|
|
434
|
+
function getFileDirectory(filePath) {
|
|
435
|
+
let cleanPath = filePath;
|
|
436
|
+
let repoPrefix = "";
|
|
437
|
+
if (filePath.includes(":")) {
|
|
438
|
+
const colonIdx = filePath.indexOf(":");
|
|
439
|
+
repoPrefix = filePath.slice(0, colonIdx + 1);
|
|
440
|
+
cleanPath = filePath.slice(colonIdx + 1);
|
|
441
|
+
}
|
|
442
|
+
const dir = dirname(cleanPath).split(sep).join("/");
|
|
443
|
+
if (dir === "." || dir === "") {
|
|
444
|
+
return repoPrefix ? `${repoPrefix}./` : "./";
|
|
445
|
+
}
|
|
446
|
+
return repoPrefix ? `${repoPrefix}${dir}/` : `${dir}/`;
|
|
447
|
+
}
|
|
448
|
+
export function renderEditReporterBody(output, evidence, options) {
|
|
314
449
|
const facts = deriveReporterFacts(evidence);
|
|
450
|
+
const lineStats = options?.lineStats ??
|
|
451
|
+
(options?.worktreeDir
|
|
452
|
+
? collectGitLineStats(options.worktreeDir, facts.changed_files)
|
|
453
|
+
: undefined);
|
|
315
454
|
const summariesByPath = new Map();
|
|
316
455
|
for (const file of output.changed_files) {
|
|
317
456
|
// The evidence path list remains authoritative. Ignore invented paths and keep the first
|
|
@@ -319,11 +458,90 @@ function renderEditReporterBody(output, evidence) {
|
|
|
319
458
|
if (!summariesByPath.has(file.path))
|
|
320
459
|
summariesByPath.set(file.path, file.summary);
|
|
321
460
|
}
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
461
|
+
const maxIndividual = options?.maxIndividualChangedFiles ?? MAX_INDIVIDUAL_CHANGED_FILES;
|
|
462
|
+
let changedFiles;
|
|
463
|
+
if (facts.changed_files.length === 0) {
|
|
464
|
+
changedFiles = "- なし";
|
|
465
|
+
}
|
|
466
|
+
else if (facts.changed_files.length <= maxIndividual) {
|
|
467
|
+
changedFiles = facts.changed_files
|
|
468
|
+
.map((file) => {
|
|
469
|
+
const displayPath = file.path.includes(" -> ") ? file.path.split(" -> ")[1] : file.path;
|
|
470
|
+
const reporterSummary = summariesByPath.get(displayPath) ?? summariesByPath.get(file.path);
|
|
471
|
+
const summary = reporterSummary !== undefined && reporterSummary.trim().length > 0
|
|
472
|
+
? reporterSummary
|
|
473
|
+
: formatMissingSummary(file, lineStats?.get(displayPath) ?? lineStats?.get(file.path));
|
|
474
|
+
return `- \`${reporterInlineText(displayPath).replace(/`/g, "'")}\`: ${reporterInlineText(summary)}`;
|
|
475
|
+
})
|
|
326
476
|
.join("\n");
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
// Over threshold: list described files individually, and group undescribed files by directory.
|
|
480
|
+
const describedFiles = [];
|
|
481
|
+
const undescribedFiles = [];
|
|
482
|
+
const describedCountByDir = new Map();
|
|
483
|
+
for (const file of facts.changed_files) {
|
|
484
|
+
const displayPath = file.path.includes(" -> ") ? file.path.split(" -> ")[1] : file.path;
|
|
485
|
+
const reporterSummary = summariesByPath.get(displayPath) ?? summariesByPath.get(file.path);
|
|
486
|
+
if (reporterSummary !== undefined && reporterSummary.trim().length > 0) {
|
|
487
|
+
describedFiles.push({ displayPath, summary: reporterSummary });
|
|
488
|
+
const dir = getFileDirectory(displayPath);
|
|
489
|
+
describedCountByDir.set(dir, (describedCountByDir.get(dir) ?? 0) + 1);
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
undescribedFiles.push({ displayPath, file });
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
const lines = [];
|
|
496
|
+
for (const entry of describedFiles) {
|
|
497
|
+
lines.push(`- \`${reporterInlineText(entry.displayPath).replace(/`/g, "'")}\`: ${reporterInlineText(entry.summary)}`);
|
|
498
|
+
}
|
|
499
|
+
const dirGroups = new Map();
|
|
500
|
+
for (const entry of undescribedFiles) {
|
|
501
|
+
const dir = getFileDirectory(entry.displayPath);
|
|
502
|
+
let group = dirGroups.get(dir);
|
|
503
|
+
if (!group) {
|
|
504
|
+
group = {
|
|
505
|
+
count: 0,
|
|
506
|
+
operations: new Map(),
|
|
507
|
+
additions: 0,
|
|
508
|
+
deletions: 0,
|
|
509
|
+
hasLineStats: false,
|
|
510
|
+
};
|
|
511
|
+
dirGroups.set(dir, group);
|
|
512
|
+
}
|
|
513
|
+
group.count++;
|
|
514
|
+
const isRename = entry.file.status.includes("R") || entry.file.path.includes(" -> ");
|
|
515
|
+
const isAdd = entry.file.status === "??" || entry.file.status.includes("A");
|
|
516
|
+
const isDelete = entry.file.status.includes("D");
|
|
517
|
+
const op = isRename ? "名前の変更" : isAdd ? "追加" : isDelete ? "削除" : "変更";
|
|
518
|
+
group.operations.set(op, (group.operations.get(op) ?? 0) + 1);
|
|
519
|
+
const stats = lineStats?.get(entry.displayPath) ?? lineStats?.get(entry.file.path);
|
|
520
|
+
if (stats !== undefined) {
|
|
521
|
+
group.additions += stats.additions;
|
|
522
|
+
group.deletions += stats.deletions;
|
|
523
|
+
group.hasLineStats = true;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const sortedDirs = [...dirGroups.keys()].sort((a, b) => a.localeCompare(b));
|
|
527
|
+
const operationOrder = ["変更", "追加", "削除", "名前の変更"];
|
|
528
|
+
for (const dir of sortedDirs) {
|
|
529
|
+
const group = dirGroups.get(dir);
|
|
530
|
+
const describedInDir = describedCountByDir.get(dir) ?? 0;
|
|
531
|
+
const countText = describedInDir > 0 ? `ほか ${group.count} 件` : `${group.count} 件`;
|
|
532
|
+
const sortedOps = [...group.operations.keys()].sort((a, b) => {
|
|
533
|
+
const idxA = operationOrder.indexOf(a);
|
|
534
|
+
const idxB = operationOrder.indexOf(b);
|
|
535
|
+
return (idxA === -1 ? 999 : idxA) - (idxB === -1 ? 999 : idxB);
|
|
536
|
+
});
|
|
537
|
+
const opParts = sortedOps.map((op) => `${op} ${group.operations.get(op)} 件`);
|
|
538
|
+
const lineStatsPart = group.hasLineStats
|
|
539
|
+
? `、+${group.additions} / -${group.deletions} 行`
|
|
540
|
+
: "";
|
|
541
|
+
lines.push(`- \`${reporterInlineText(dir)}\`: ${countText}(${opParts.join("、")}${lineStatsPart})`);
|
|
542
|
+
}
|
|
543
|
+
changedFiles = lines.length === 0 ? "- なし" : lines.join("\n");
|
|
544
|
+
}
|
|
327
545
|
const unchangedTargetNotes = (evidence?.target_coverage ?? [])
|
|
328
546
|
.filter((entry) => entry.status === "unchanged")
|
|
329
547
|
.map((entry) => {
|
|
@@ -363,6 +581,9 @@ function renderEditReporterBody(output, evidence) {
|
|
|
363
581
|
const command = reporterInlineText(validation.command).replace(/`/g, "'");
|
|
364
582
|
return [`適用外の検証(runner の判定): \`${command}\`(${reporterInlineText(reason)})`];
|
|
365
583
|
});
|
|
584
|
+
const rateLimitRecoveryNotes = (evidence.rate_limit_events ?? []).map((event) => event.action === "wait"
|
|
585
|
+
? `rate limit 後に ${event.resume_at ?? "再開可能時刻"} まで待ち、${event.to_actor} で ${event.resumed_at} に再開`
|
|
586
|
+
: `rate limit 後に ${event.from_actor} から ${event.to_actor} へ切り替え、${event.resumed_at} に再開`);
|
|
366
587
|
return [
|
|
367
588
|
"# Edit Result",
|
|
368
589
|
"",
|
|
@@ -383,16 +604,20 @@ function renderEditReporterBody(output, evidence) {
|
|
|
383
604
|
...runnerOwnedValidationNotes,
|
|
384
605
|
...runnerJudgedNotApplicableNotes,
|
|
385
606
|
...humanValidationNotes,
|
|
607
|
+
...rateLimitRecoveryNotes,
|
|
386
608
|
], "なし"),
|
|
387
609
|
"",
|
|
388
|
-
"## 4. 進め方と実践の型の適用",
|
|
610
|
+
options?.approach ? "## 4. 進め方と実践の型の適用" : "## 4. 進め方",
|
|
389
611
|
"",
|
|
390
612
|
reporterInlineText(output.approach),
|
|
391
613
|
].join("\n");
|
|
392
614
|
}
|
|
393
615
|
// review result の章立ては xrr-template.md と一致させる。review は成果物を再評価しないため、
|
|
394
616
|
// 観点別の結果ではなく評価結果の確認・判断根拠・改善指示・verdict を記録する。
|
|
395
|
-
function renderReviewReporterBody(output) {
|
|
617
|
+
function renderReviewReporterBody(output, evidence) {
|
|
618
|
+
const rateLimitRecoveryNotes = (evidence.rate_limit_events ?? []).map((event) => event.action === "wait"
|
|
619
|
+
? `rate limit 後に ${event.resume_at ?? "再開可能時刻"} まで待ち、${event.to_actor} で ${event.resumed_at} に再開`
|
|
620
|
+
: `rate limit 後に ${event.from_actor} から ${event.to_actor} へ切り替え、${event.resumed_at} に再開`);
|
|
396
621
|
return [
|
|
397
622
|
"# Review Result",
|
|
398
623
|
"",
|
|
@@ -402,7 +627,7 @@ function renderReviewReporterBody(output) {
|
|
|
402
627
|
"",
|
|
403
628
|
"## 2. 判断根拠",
|
|
404
629
|
"",
|
|
405
|
-
reporterBulletList(output.rationale, "なし"),
|
|
630
|
+
reporterBulletList([...output.rationale, ...rateLimitRecoveryNotes], "なし"),
|
|
406
631
|
"",
|
|
407
632
|
"## 3. 未充足事項・改善指示",
|
|
408
633
|
"",
|
|
@@ -421,7 +646,7 @@ function renderReviewReporterBody(output) {
|
|
|
421
646
|
* Replaces only the result body from schema-validated reporter data. The scaffolded frontmatter
|
|
422
647
|
* remains byte-for-byte runner-owned until the lifecycle status update serializes it.
|
|
423
648
|
*/
|
|
424
|
-
export async function renderReporterResult(resultPath, output, evidence) {
|
|
649
|
+
export async function renderReporterResult(resultPath, output, evidence, options) {
|
|
425
650
|
if (!existsSync(resultPath))
|
|
426
651
|
throw new Error(`Result not found: ${resultPath}`);
|
|
427
652
|
const content = readFileSync(resultPath, "utf8");
|
|
@@ -432,9 +657,18 @@ export async function renderReporterResult(resultPath, output, evidence) {
|
|
|
432
657
|
const frontmatter = content.match(/^---\r?\n[\s\S]*?\r?\n---/)?.[0];
|
|
433
658
|
if (!frontmatter)
|
|
434
659
|
throw new Error(`Result frontmatter not found: ${resultPath}`);
|
|
660
|
+
const approach = options?.approach ??
|
|
661
|
+
(typeof parsed.data.approach === "string" && parsed.data.approach.trim().length > 0
|
|
662
|
+
? parsed.data.approach
|
|
663
|
+
: undefined);
|
|
664
|
+
const resolvedOptions = {
|
|
665
|
+
...options,
|
|
666
|
+
...(approach ? { approach } : {}),
|
|
667
|
+
worktreeDir: options?.worktreeDir ?? findGitRoot(dirname(resultPath)) ?? undefined,
|
|
668
|
+
};
|
|
435
669
|
const body = output.mode === "edit"
|
|
436
|
-
? renderEditReporterBody(output, evidence)
|
|
437
|
-
: renderReviewReporterBody(output);
|
|
670
|
+
? renderEditReporterBody(output, evidence, resolvedOptions)
|
|
671
|
+
: renderReviewReporterBody(output, evidence);
|
|
438
672
|
writeFileSync(resultPath, frontmatterWithBody(frontmatter, body), "utf8");
|
|
439
673
|
await formatMarkdownFile(resultPath);
|
|
440
674
|
}
|
|
@@ -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";
|
|
@@ -157,7 +171,7 @@ export async function runAgentPipeline(params) {
|
|
|
157
171
|
...(params.resumedExecutor ? { resumeHandoff: params.resumeHandoff ?? [] } : {}),
|
|
158
172
|
}), params.productWorktrees);
|
|
159
173
|
const changesBeforeAttempt = snapshotWorktreeChanges(cwd, params.productWorktrees);
|
|
160
|
-
const runExecutor = () => runWithRetry([executor], executorPrompt, execDefaults, cwd, env, resultPath);
|
|
174
|
+
const runExecutor = () => runWithRetry([executor], executorPrompt, execDefaults, cwd, env, resultPath, params.executorRateLimitOptions);
|
|
161
175
|
const outcome = params.providerConcurrencyGate
|
|
162
176
|
? await params.providerConcurrencyGate.run(executor.provider, runExecutor, `${taskId} executor`)
|
|
163
177
|
: await runExecutor();
|
|
@@ -167,7 +181,7 @@ export async function runAgentPipeline(params) {
|
|
|
167
181
|
executionPath,
|
|
168
182
|
taskId,
|
|
169
183
|
runId,
|
|
170
|
-
actor: executor.actor,
|
|
184
|
+
actor: outcome.actor ?? executor.actor,
|
|
171
185
|
status: outcome.result === "success"
|
|
172
186
|
? "succeeded"
|
|
173
187
|
: outcome.result === "rate_limit"
|
|
@@ -181,6 +195,7 @@ export async function runAgentPipeline(params) {
|
|
|
181
195
|
stderr: outcome.stderr,
|
|
182
196
|
changesBeforeAttempt,
|
|
183
197
|
productWorktrees: params.productWorktrees,
|
|
198
|
+
rateLimitEvents: outcome.rateLimitEvents,
|
|
184
199
|
});
|
|
185
200
|
const coverageFailure = outcome.result === "success"
|
|
186
201
|
? resumedTargetCoverageFailure({
|
|
@@ -203,8 +218,10 @@ export async function runAgentPipeline(params) {
|
|
|
203
218
|
? "rate_limited"
|
|
204
219
|
: "failed",
|
|
205
220
|
attempts: outcome.attempts,
|
|
221
|
+
actor: outcome.actor ?? executor.actor,
|
|
206
222
|
completed_at: executorCompletedAt,
|
|
207
223
|
artifact_ref: evidenceRef,
|
|
224
|
+
...(outcome.rateLimitEvents.length > 0 ? { rate_limit_events: outcome.rateLimitEvents } : {}),
|
|
208
225
|
}, executorCompletedAt);
|
|
209
226
|
writePipelineState(stateLocation.path, state);
|
|
210
227
|
process.stdout.write(` Executor evidence: ${evidenceRef}\n`);
|
|
@@ -219,6 +236,7 @@ export async function runAgentPipeline(params) {
|
|
|
219
236
|
blockReason,
|
|
220
237
|
stateRef: stateLocation.ref,
|
|
221
238
|
evidenceRef,
|
|
239
|
+
rateLimitEvents: outcome.rateLimitEvents,
|
|
222
240
|
};
|
|
223
241
|
}
|
|
224
242
|
recorded.evidence = await appendParentValidationsToExecutorEvidence({
|
|
@@ -245,6 +263,7 @@ export async function runAgentPipeline(params) {
|
|
|
245
263
|
providerConcurrencyGate: params.providerConcurrencyGate,
|
|
246
264
|
productWorktrees: params.productWorktrees,
|
|
247
265
|
mode: params.mode,
|
|
266
|
+
rateLimitOptions: params.reporterRateLimitOptions,
|
|
248
267
|
});
|
|
249
268
|
return {
|
|
250
269
|
exitCode: reporterOutcome.exitCode,
|
|
@@ -252,5 +271,6 @@ export async function runAgentPipeline(params) {
|
|
|
252
271
|
blockReason: reporterOutcome.blockReason,
|
|
253
272
|
stateRef: stateLocation.ref,
|
|
254
273
|
evidenceRef,
|
|
274
|
+
rateLimitEvents: recorded.evidence.rate_limit_events ?? [],
|
|
255
275
|
};
|
|
256
276
|
}
|