specdojo 0.3.0 → 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 +65 -0
- package/README.md +77 -18
- package/dist/catalog/build-references.js +144 -0
- package/dist/catalog/build-render.js +32 -0
- package/dist/{catalog-build.js → catalog/build.js} +18 -295
- package/dist/{catalog.js → catalog/catalog.js} +11 -11
- package/dist/{catalog-generate.js → catalog/generate.js} +13 -16
- package/dist/catalog/paths.js +1 -0
- package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +5 -5
- package/dist/{catalog-plan.js → catalog/plan.js} +9 -9
- package/dist/{catalog-scaffold.js → catalog/scaffold.js} +6 -6
- 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} +103 -37
- package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
- package/dist/{watch.js → commands/watch.js} +3 -3
- package/dist/dashboard/dashboard-timeline.js +175 -0
- package/dist/{dashboard.js → dashboard/dashboard.js} +16 -549
- package/dist/dashboard/exec-records.js +105 -0
- package/dist/dashboard/routines.js +256 -0
- package/dist/dashboard/shared.js +14 -0
- 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} +7 -7
- 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} +3 -3
- package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +2 -2
- 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} +3 -3
- package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
- package/dist/{yaml-pages.js → docs/yaml-pages.js} +5 -5
- 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.js → exec/commands.js} +22 -467
- package/dist/exec/core.js +457 -0
- 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.js → exec/plans-core.js} +97 -468
- package/dist/exec/plans-generation.js +249 -0
- package/dist/exec/plans-storage.js +131 -0
- package/dist/exec/plans.js +3 -0
- 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 +23 -0
- package/dist/exec/repo-integration-sync.js +264 -0
- package/dist/{exec-repo-integration.js → exec/repo-integration.js} +13 -287
- package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
- package/dist/exec/reporter-output.js +206 -0
- package/dist/{exec-reporter.js → exec/reporter.js} +29 -216
- package/dist/{exec-results.js → exec/results.js} +277 -36
- package/dist/exec/run/agent-pipeline.js +276 -0
- package/dist/exec/run/agent.js +583 -0
- package/dist/exec/run/in-place.js +570 -0
- package/dist/exec/run/job.js +746 -0
- package/dist/exec/run/lifecycle-commands.js +530 -0
- package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
- package/dist/exec/run/mode-shared.js +140 -0
- package/dist/exec/run/register-command.js +252 -0
- package/dist/exec/run/register-core.js +411 -0
- package/dist/exec/run/register-mode.js +210 -0
- package/dist/exec/run/register-resume.js +398 -0
- package/dist/exec/run/register-state.js +325 -0
- package/dist/exec/run/register-worktree.js +540 -0
- package/dist/exec/run/run.js +11 -0
- package/dist/exec/run/schedule-mode.js +294 -0
- package/dist/exec/run/schedule-prepare.js +366 -0
- package/dist/exec/run/schedule-task.js +599 -0
- package/dist/exec/run/shared.js +449 -0
- 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.js → exec/trial-commands.js} +23 -388
- package/dist/exec/trial-core.js +371 -0
- package/dist/exec/trial.js +2 -0
- package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
- package/dist/exec/worktree-ops-commit.js +672 -0
- package/dist/exec/worktree-ops-lifecycle.js +297 -0
- package/dist/exec/worktree-ops-merge.js +344 -0
- package/dist/exec/worktree-ops.js +3 -0
- package/dist/exec/worktree.js +305 -0
- package/dist/grade/apply.js +734 -0
- package/dist/grade/command-apply.js +250 -0
- package/dist/grade/command-inspect.js +138 -0
- package/dist/grade/command-plan.js +101 -0
- package/dist/grade/command-shared.js +68 -0
- package/dist/grade/core.js +307 -0
- package/dist/grade/grade.js +19 -0
- package/dist/grade/markdown.js +274 -0
- package/dist/grade/pipeline-state.js +184 -0
- package/dist/grade/plan.js +507 -0
- package/dist/{grade-result.js → grade/result.js} +7 -96
- package/dist/grade/target-discovery.js +265 -0
- package/dist/grade/targets.js +435 -0
- package/dist/{job.js → job/definition.js} +32 -574
- package/dist/job/job.js +568 -0
- package/dist/{kata-command.js → kata/command.js} +4 -4
- package/dist/{kata.js → kata/kata.js} +5 -5
- package/dist/register/approach.js +134 -0
- package/dist/register/command-types.js +1 -0
- package/dist/register/core.js +369 -0
- package/dist/register/create-commands.js +352 -0
- 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} +12 -6
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +28 -10
- package/dist/register/lifecycle-lock.js +5 -0
- package/dist/register/maintenance-commands.js +193 -0
- package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
- package/dist/register/migration.js +268 -0
- package/dist/register/register.js +404 -0
- package/dist/register/renumber.js +341 -0
- package/dist/register/transition-commands.js +248 -0
- package/dist/register/update.js +230 -0
- package/dist/register/views.js +296 -0
- package/dist/{review-grade.js → review/grade.js} +2 -2
- package/dist/{review-plan.js → review/plan.js} +5 -5
- package/dist/routine/definition.js +401 -0
- package/dist/{routine.js → routine/routine.js} +50 -419
- package/dist/{schedule-approach.js → schedule/approach.js} +9 -9
- package/dist/{schedule-build.js → schedule/build.js} +7 -4
- package/dist/{schedule.js → schedule/schedule.js} +9 -9
- package/dist/schedule/strategy-generate-document.js +273 -0
- package/dist/schedule/strategy-generate-scope.js +199 -0
- package/dist/schedule/strategy-generate.js +348 -0
- 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/shared/catalog-render.js +115 -0
- 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 +316 -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} +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} +96 -9
- package/dist/{exec-shared.js → shared/text.js} +0 -134
- package/dist/shared/time.js +28 -0
- package/dist/shared/yaml.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 +97 -22
- 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 +51 -18
- 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 +6 -6
- 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 +4 -5
- package/templates/antigravity/README.md +7 -3
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +10 -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 +26 -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-run.js +0 -6182
- package/dist/exec-schedule-gantt-chart.js +0 -2
- package/dist/exec-worktree-ops.js +0 -1292
- package/dist/exec-worktree.js +0 -446
- package/dist/grade.js +0 -3193
- package/dist/register.js +0 -2407
- package/dist/schedule-strategy-generate.js +0 -812
- 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/{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
|
@@ -1,381 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { getProjectSchedulePath, loadConfig, specdojoRootDir, } from "./specdojo-config.js";
|
|
17
|
-
const TRIAL_PROMPT_SUFFIX = `
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
# Agent comparison trial instructions
|
|
22
|
-
|
|
23
|
-
This is an isolated comparison trial. Edit and validate the artifacts required by the plan, but
|
|
24
|
-
do not update task lifecycle state or create/update the result file. End the final response with
|
|
25
|
-
exactly one machine-readable executor evidence envelope as documented by SpecDojo.
|
|
26
|
-
`;
|
|
27
|
-
function sha256(value) {
|
|
28
|
-
return createHash("sha256").update(value).digest("hex");
|
|
29
|
-
}
|
|
30
|
-
function normalizePlanPathCandidate(value) {
|
|
31
|
-
const candidate = value
|
|
32
|
-
.trim()
|
|
33
|
-
.replace(/^\.\//u, "")
|
|
34
|
-
.replace(/:\d+(?::\d+)?$/u, "")
|
|
35
|
-
.replace(/[.,;]$/u, "");
|
|
36
|
-
if (!candidate ||
|
|
37
|
-
candidate.startsWith("/") ||
|
|
38
|
-
candidate.includes("://") ||
|
|
39
|
-
/[\s<>{}*?$]/u.test(candidate) ||
|
|
40
|
-
candidate === ".env" ||
|
|
41
|
-
candidate.startsWith("secrets/")) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
if (/^(?:\.specdojo|docs|scripts|src|tests|tools)\//u.test(candidate) ||
|
|
45
|
-
/^(?:lefthook\.yml|package\.json|tsconfig[^/]*\.json|vitest[^/]*\.ts)$/u.test(candidate)) {
|
|
46
|
-
return candidate;
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
export function extractPlanRepoPaths(plan) {
|
|
51
|
-
const candidates = [];
|
|
52
|
-
for (const match of plan.matchAll(/`([^`\n]+)`/gu))
|
|
53
|
-
candidates.push(match[1]);
|
|
54
|
-
for (const match of plan.matchAll(/\]\(([^)\s]+)(?:\s+[^)]*)?\)/gu))
|
|
55
|
-
candidates.push(match[1]);
|
|
56
|
-
return [
|
|
57
|
-
...new Set(candidates
|
|
58
|
-
.map(normalizePlanPathCandidate)
|
|
59
|
-
.filter((candidate) => candidate !== null)),
|
|
60
|
-
].sort();
|
|
61
|
-
}
|
|
62
|
-
function objectExistsAtCommit(repoRoot, commit, path) {
|
|
63
|
-
return gitResult(repoRoot, ["cat-file", "-e", `${commit}:${path}`]).status === 0;
|
|
64
|
-
}
|
|
65
|
-
export function buildTrialBaseValidation(params) {
|
|
66
|
-
const referencedPaths = extractPlanRepoPaths(params.planContent).map((path) => ({
|
|
67
|
-
path,
|
|
68
|
-
exists_at_base: objectExistsAtCommit(params.repoRoot, params.resolvedCommit, path),
|
|
69
|
-
}));
|
|
70
|
-
const missingReferencedPaths = referencedPaths
|
|
71
|
-
.filter((entry) => !entry.exists_at_base)
|
|
72
|
-
.map((entry) => entry.path);
|
|
73
|
-
const planPathExistsAtBase = objectExistsAtCommit(params.repoRoot, params.resolvedCommit, params.planPath);
|
|
74
|
-
const warnings = [];
|
|
75
|
-
const baseIsAncestorOfHead = gitResult(params.repoRoot, [
|
|
76
|
-
"merge-base",
|
|
77
|
-
"--is-ancestor",
|
|
78
|
-
params.resolvedCommit,
|
|
79
|
-
params.headCommit,
|
|
80
|
-
]).status === 0;
|
|
81
|
-
if (!baseIsAncestorOfHead) {
|
|
82
|
-
warnings.push("The base commit is not an ancestor of HEAD; the current HEAD cannot be used as a linear reference result.");
|
|
83
|
-
}
|
|
84
|
-
if (!planPathExistsAtBase) {
|
|
85
|
-
warnings.push("The plan file is not present at the base commit; the current plan content will still be supplied to every trial.");
|
|
86
|
-
}
|
|
87
|
-
if (missingReferencedPaths.length > 0) {
|
|
88
|
-
warnings.push(`Referenced paths missing at the base commit: ${missingReferencedPaths.join(", ")}`);
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
requested_revision: params.requestedRevision,
|
|
92
|
-
resolved_commit: params.resolvedCommit,
|
|
93
|
-
head_commit_at_start: params.headCommit,
|
|
94
|
-
base_is_ancestor_of_head: baseIsAncestorOfHead,
|
|
95
|
-
defaulted_to_head: params.defaultedToHead,
|
|
96
|
-
plan_path_exists_at_base: planPathExistsAtBase,
|
|
97
|
-
compatible: baseIsAncestorOfHead && missingReferencedPaths.length === 0,
|
|
98
|
-
referenced_paths: referencedPaths,
|
|
99
|
-
missing_referenced_paths: missingReferencedPaths,
|
|
100
|
-
warnings,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
export function classifyReporterFailure(result, reason) {
|
|
104
|
-
if (result === "rate_limit")
|
|
105
|
-
return "rate_limit";
|
|
106
|
-
return reason.startsWith("reporter output invalid after")
|
|
107
|
-
? "invalid_output"
|
|
108
|
-
: "invocation_failure";
|
|
109
|
-
}
|
|
110
|
-
function hasValidExecutorEnvelope(stdout) {
|
|
111
|
-
const matches = [
|
|
112
|
-
...stdout.matchAll(/<specdojo_executor_evidence>\s*([\s\S]*?)\s*<\/specdojo_executor_evidence>/gu),
|
|
113
|
-
];
|
|
114
|
-
const raw = matches.at(-1)?.[1];
|
|
115
|
-
if (!raw)
|
|
116
|
-
return false;
|
|
117
|
-
try {
|
|
118
|
-
const value = JSON.parse(raw);
|
|
119
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
120
|
-
return false;
|
|
121
|
-
const report = value;
|
|
122
|
-
return typeof report.final_message === "string" && Array.isArray(report.validations);
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function repoRelative(repoRoot, path) {
|
|
129
|
-
const value = relative(repoRoot, path);
|
|
130
|
-
if (!value || value === ".." || value.startsWith(`..${sep}`)) {
|
|
131
|
-
throw new Error(`Path is outside repository root: ${path}`);
|
|
132
|
-
}
|
|
133
|
-
return value.split(sep).join("/");
|
|
134
|
-
}
|
|
135
|
-
function comparisonDir(executionPath, comparisonId) {
|
|
136
|
-
return join(executionPath, "exec", "trials", safeSlug(comparisonId));
|
|
137
|
-
}
|
|
138
|
-
function comparisonPath(executionPath, comparisonId) {
|
|
139
|
-
return join(comparisonDir(executionPath, comparisonId), "comparison.json");
|
|
140
|
-
}
|
|
141
|
-
function writeComparison(path, value) {
|
|
142
|
-
ensureDir(dirname(path));
|
|
143
|
-
const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
144
|
-
writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
145
|
-
renameSync(temporary, path);
|
|
146
|
-
}
|
|
147
|
-
function readComparison(path) {
|
|
148
|
-
if (!existsSync(path))
|
|
149
|
-
throw new Error(`Comparison not found: ${path}`);
|
|
150
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
151
|
-
}
|
|
152
|
-
function configuredWorktreeBase(schedulePath) {
|
|
153
|
-
const { config } = loadConfig();
|
|
154
|
-
if (!config)
|
|
155
|
-
return undefined;
|
|
156
|
-
const rootDir = specdojoRootDir();
|
|
157
|
-
for (const project of Object.values(config.projects)) {
|
|
158
|
-
if (resolve(rootDir, getProjectSchedulePath(project)) === schedulePath) {
|
|
159
|
-
return project.run?.worktree_base;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return undefined;
|
|
163
|
-
}
|
|
164
|
-
function parsePositiveInteger(value, flag) {
|
|
165
|
-
if (!value || !/^\d+$/.test(value) || Number(value) < 1) {
|
|
166
|
-
throw new Error(`${flag} must be a positive integer: ${value ?? ""}`);
|
|
167
|
-
}
|
|
168
|
-
return Number(value);
|
|
169
|
-
}
|
|
170
|
-
function parseRating(value, flag) {
|
|
171
|
-
if (value === undefined)
|
|
172
|
-
return undefined;
|
|
173
|
-
if (!/^[1-5]$/.test(value))
|
|
174
|
-
throw new Error(`${flag} must be an integer from 1 to 5.`);
|
|
175
|
-
return Number(value);
|
|
176
|
-
}
|
|
177
|
-
function resolveMember(roster, nickname, stageRole) {
|
|
178
|
-
const member = roster?.members.find((candidate) => candidate.type === "agent" && candidate.nickname === nickname);
|
|
179
|
-
if (!member)
|
|
180
|
-
throw new Error(`Agent nickname not found in agent-members.yaml: ${nickname}`);
|
|
181
|
-
if (member.disabled)
|
|
182
|
-
throw new Error(`Agent is disabled in agent-members.yaml: ${nickname}`);
|
|
183
|
-
if ((stageRole === "reporter" && member.stage_role !== "reporter") ||
|
|
184
|
-
(stageRole === "executor" && member.stage_role === "reporter")) {
|
|
185
|
-
throw new Error(`Agent must have stage_role: ${stageRole}: ${nickname}`);
|
|
186
|
-
}
|
|
187
|
-
return member;
|
|
188
|
-
}
|
|
189
|
-
function spawnAgent(command, prompt, cwd, env) {
|
|
190
|
-
return new Promise((resolveOutcome) => {
|
|
191
|
-
const protectedConfigBefore = captureAgentProtectedConfigSnapshot(cwd);
|
|
192
|
-
const gitStateBefore = captureAgentGitStateSnapshot(cwd);
|
|
193
|
-
const child = spawn(command, { cwd, env, shell: true, stdio: ["pipe", "pipe", "pipe"] });
|
|
194
|
-
let stdout = "";
|
|
195
|
-
let stderr = "";
|
|
196
|
-
let settled = false;
|
|
197
|
-
child.stdin.on("error", () => undefined);
|
|
198
|
-
child.stdout.setEncoding("utf8");
|
|
199
|
-
child.stderr.setEncoding("utf8");
|
|
200
|
-
child.stdout.on("data", (chunk) => {
|
|
201
|
-
stdout += chunk;
|
|
202
|
-
process.stdout.write(chunk);
|
|
203
|
-
});
|
|
204
|
-
child.stderr.on("data", (chunk) => {
|
|
205
|
-
stderr += chunk;
|
|
206
|
-
process.stderr.write(chunk);
|
|
207
|
-
});
|
|
208
|
-
const finish = (outcome) => {
|
|
209
|
-
if (settled)
|
|
210
|
-
return;
|
|
211
|
-
settled = true;
|
|
212
|
-
const protectedChanges = changedAgentProtectedConfigPaths(cwd, protectedConfigBefore);
|
|
213
|
-
if (protectedChanges.length > 0) {
|
|
214
|
-
outcome.stderr += `${agentProtectedConfigViolation(protectedChanges)}\n`;
|
|
215
|
-
outcome.exitCode = 1;
|
|
216
|
-
}
|
|
217
|
-
const gitStateChanges = changedAgentGitStateFields(cwd, gitStateBefore);
|
|
218
|
-
if (gitStateChanges.length > 0) {
|
|
219
|
-
outcome.stderr += `${agentGitStateViolation(gitStateChanges)}\n`;
|
|
220
|
-
outcome.exitCode = 1;
|
|
221
|
-
}
|
|
222
|
-
resolveOutcome(outcome);
|
|
223
|
-
};
|
|
224
|
-
child.once("error", (error) => {
|
|
225
|
-
stderr += `${error.message}\n`;
|
|
226
|
-
finish({ exitCode: null, stdout, stderr });
|
|
227
|
-
});
|
|
228
|
-
child.once("close", (exitCode) => finish({ exitCode, stdout, stderr }));
|
|
229
|
-
child.stdin.end(prompt);
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
function worktreeEnvironment(repoRoot, worktreePath, schedulePath, executionPath) {
|
|
233
|
-
return {
|
|
234
|
-
...gitEnvironment(),
|
|
235
|
-
SPECDOJO_SCHEDULE_PATH: resolve(worktreePath, repoRelative(repoRoot, schedulePath)),
|
|
236
|
-
SPECDOJO_EXECUTION_PATH: resolve(worktreePath, repoRelative(repoRoot, executionPath)),
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
function blankTrial(params) {
|
|
240
|
-
const trialId = safeSlug(params.trialId ?? params.agent);
|
|
241
|
-
const worktreeTaskId = `${params.projectId}:trial:${params.comparisonId}:${trialId}`;
|
|
242
|
-
const name = worktreeNameFromTaskId(worktreeTaskId);
|
|
243
|
-
return {
|
|
244
|
-
trial_id: trialId,
|
|
245
|
-
agent: params.agent,
|
|
246
|
-
reporter_agent: params.reporter ?? null,
|
|
247
|
-
worktree: resolve(params.worktreeBase, name),
|
|
248
|
-
branch: `exec/${name}`,
|
|
249
|
-
status: "pending",
|
|
250
|
-
started_at: null,
|
|
251
|
-
completed_at: null,
|
|
252
|
-
duration_ms: null,
|
|
253
|
-
executor: {
|
|
254
|
-
exit_code: null,
|
|
255
|
-
attempts: 0,
|
|
256
|
-
duration_ms: null,
|
|
257
|
-
structured_output: false,
|
|
258
|
-
validations_reported: 0,
|
|
259
|
-
validations_passed: 0,
|
|
260
|
-
validations_failed: 0,
|
|
261
|
-
validations_not_run: 0,
|
|
262
|
-
validations_requires_human: 0,
|
|
263
|
-
files_changed: 0,
|
|
264
|
-
evidence_ref: null,
|
|
265
|
-
final_message: "",
|
|
266
|
-
validations: [],
|
|
267
|
-
changes: [],
|
|
268
|
-
diff_summary: "",
|
|
269
|
-
},
|
|
270
|
-
parent_validation: {
|
|
271
|
-
configured_ids: [...(params.parentValidationIds ?? [])],
|
|
272
|
-
status: params.parentValidationIds?.length ? "not_run" : "not_configured",
|
|
273
|
-
duration_ms: null,
|
|
274
|
-
validations_passed: 0,
|
|
275
|
-
validations_failed: 0,
|
|
276
|
-
validations_not_run: 0,
|
|
277
|
-
},
|
|
278
|
-
reporter: {
|
|
279
|
-
status: "not_run",
|
|
280
|
-
structured_output: false,
|
|
281
|
-
format_attempts: 0,
|
|
282
|
-
format_retries: 0,
|
|
283
|
-
outcome: null,
|
|
284
|
-
output: null,
|
|
285
|
-
failure_category: null,
|
|
286
|
-
failure_reason: "",
|
|
287
|
-
},
|
|
288
|
-
subjective: {
|
|
289
|
-
judgment_quality: null,
|
|
290
|
-
writing_quality: null,
|
|
291
|
-
scope_adherence: null,
|
|
292
|
-
notes: "",
|
|
293
|
-
},
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
export function buildComparisonRecord(params) {
|
|
297
|
-
const reporterMode = params.pairs ? "paired" : params.reporter ? "shared" : "none";
|
|
298
|
-
const definitions = params.pairs ??
|
|
299
|
-
(params.agents ?? []).map((agent) => ({ executor: agent, reporter: params.reporter }));
|
|
300
|
-
const trialIds = definitions.map(({ executor, reporter }) => safeSlug(reporterMode === "paired" ? `${executor}-${reporter}` : executor));
|
|
301
|
-
if (new Set(trialIds).size !== trialIds.length) {
|
|
302
|
-
throw new Error("Trial executor/reporter selections must produce distinct trial ids.");
|
|
303
|
-
}
|
|
304
|
-
const baseValidation = params.baseValidation ??
|
|
305
|
-
{
|
|
306
|
-
requested_revision: "HEAD",
|
|
307
|
-
resolved_commit: params.baseCommit,
|
|
308
|
-
head_commit_at_start: params.baseCommit,
|
|
309
|
-
base_is_ancestor_of_head: true,
|
|
310
|
-
defaulted_to_head: true,
|
|
311
|
-
plan_path_exists_at_base: true,
|
|
312
|
-
compatible: true,
|
|
313
|
-
referenced_paths: [],
|
|
314
|
-
missing_referenced_paths: [],
|
|
315
|
-
warnings: [],
|
|
316
|
-
};
|
|
317
|
-
return {
|
|
318
|
-
schema_version: 1,
|
|
319
|
-
comparison_id: params.comparisonId,
|
|
320
|
-
project_id: params.projectId,
|
|
321
|
-
task_id: params.taskId,
|
|
322
|
-
status: "active",
|
|
323
|
-
created_at: params.createdAt,
|
|
324
|
-
completed_at: null,
|
|
325
|
-
base_commit: params.baseCommit,
|
|
326
|
-
base: baseValidation,
|
|
327
|
-
reporter_mode: reporterMode,
|
|
328
|
-
plan: {
|
|
329
|
-
path: params.planPath,
|
|
330
|
-
sha256: sha256(params.planContent),
|
|
331
|
-
prompt_sha256: sha256(params.prompt),
|
|
332
|
-
},
|
|
333
|
-
selected_trial_id: null,
|
|
334
|
-
trials: definitions.map(({ executor, reporter }, index) => blankTrial({
|
|
335
|
-
projectId: params.projectId,
|
|
336
|
-
comparisonId: params.comparisonId,
|
|
337
|
-
agent: executor,
|
|
338
|
-
trialId: trialIds[index],
|
|
339
|
-
reporter,
|
|
340
|
-
worktreeBase: params.worktreeBase,
|
|
341
|
-
parentValidationIds: params.parentValidationIds,
|
|
342
|
-
})),
|
|
343
|
-
agent_selection: {
|
|
344
|
-
policy: "manual",
|
|
345
|
-
target: "agent-members.yaml",
|
|
346
|
-
rationale: "A single comparison does not automatically change agent assignment. A human reviews objective and subjective results, then updates agent-members.yaml priority/capabilities when repeated evidence supports the change.",
|
|
347
|
-
},
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
export function updateObjectiveMetrics(trial, evidence, structuredOutput) {
|
|
351
|
-
trial.executor.structured_output = structuredOutput;
|
|
352
|
-
trial.executor.files_changed = evidence.diff_summary.files_changed;
|
|
353
|
-
trial.executor.final_message = evidence.final_message;
|
|
354
|
-
trial.executor.validations = evidence.validations;
|
|
355
|
-
trial.executor.changes = evidence.changes;
|
|
356
|
-
trial.executor.diff_summary = evidence.diff_summary.summary;
|
|
357
|
-
const executorValidations = evidence.validations.filter((validation) => validation.source !== "runner");
|
|
358
|
-
trial.executor.validations_reported = executorValidations.length;
|
|
359
|
-
trial.executor.validations_passed = 0;
|
|
360
|
-
trial.executor.validations_failed = 0;
|
|
361
|
-
trial.executor.validations_not_run = 0;
|
|
362
|
-
trial.executor.validations_requires_human = 0;
|
|
363
|
-
for (const validation of executorValidations) {
|
|
364
|
-
if (validation.status === "passed")
|
|
365
|
-
trial.executor.validations_passed++;
|
|
366
|
-
else if (validation.status === "failed")
|
|
367
|
-
trial.executor.validations_failed++;
|
|
368
|
-
else if (validation.status === "not_run")
|
|
369
|
-
trial.executor.validations_not_run++;
|
|
370
|
-
else if (validation.status === "requires_human") {
|
|
371
|
-
trial.executor.validations_requires_human++;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
const parentValidations = evidence.validations.filter((validation) => validation.source === "runner");
|
|
375
|
-
trial.parent_validation.validations_passed = parentValidations.filter((validation) => validation.status === "passed").length;
|
|
376
|
-
trial.parent_validation.validations_failed = parentValidations.filter((validation) => validation.status === "failed").length;
|
|
377
|
-
trial.parent_validation.validations_not_run = parentValidations.filter((validation) => validation.status === "not_run").length;
|
|
378
|
-
}
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { copyFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, } from "./agent-config.js";
|
|
5
|
+
import { agentProtectedConfigViolation, isAgentProtectedConfigPath, } from "./agent-protected-config.js";
|
|
6
|
+
import { recordExecutorEvidence, recordParentValidationFailureOutput, } from "./evidence.js";
|
|
7
|
+
import { parentValidationLabels } from "./parent-validation.js";
|
|
8
|
+
import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js";
|
|
9
|
+
import { buildExecutorPrompt, isRateLimitError, loadRosterForExecutionPath, runConfiguredParentValidationBatch, } from "./run/run.js";
|
|
10
|
+
import { parsePlanTaskIdentity } from "./plans.js";
|
|
11
|
+
import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "./reporter.js";
|
|
12
|
+
import { ensureDir, safeSlug } from "./shared.js";
|
|
13
|
+
import { ensureExecWorktree, execBranchExists, findExecWorktree, formatGitResultFailure, gitOutput, gitResult, resolveWorktreeBase, } from "./worktree.js";
|
|
14
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
15
|
+
import { TRIAL_PROMPT_SUFFIX, buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, comparisonDir, comparisonPath, configuredWorktreeBase, hasValidExecutorEnvelope, parsePositiveInteger, parseRating, readComparison, repoRelative, resolveMember, spawnAgent, updateObjectiveMetrics, worktreeEnvironment, writeComparison, } from "./trial-core.js";
|
|
379
16
|
async function runOneTrial(params) {
|
|
380
17
|
const { trial, worktree } = params;
|
|
381
18
|
const startedAt = new Date();
|
|
@@ -549,14 +186,11 @@ function resolveTrialDefinitions(opts) {
|
|
|
549
186
|
return { agents };
|
|
550
187
|
}
|
|
551
188
|
function resolveBaseCommit(repoRoot, revision) {
|
|
552
|
-
const
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
]);
|
|
558
|
-
if (result.status !== 0)
|
|
559
|
-
throw new Error(`Trial base is not a commit: ${revision}`);
|
|
189
|
+
const args = ["rev-parse", "--verify", "--end-of-options", `${revision}^{commit}`];
|
|
190
|
+
const result = gitResult(repoRoot, args);
|
|
191
|
+
if (result.status !== 0) {
|
|
192
|
+
throw new Error(`Trial base is not a commit: ${revision}; ${formatGitResultFailure(args, result)}`);
|
|
193
|
+
}
|
|
560
194
|
return String(result.stdout).trim();
|
|
561
195
|
}
|
|
562
196
|
async function runTrials(opts) {
|
|
@@ -771,7 +405,8 @@ function commitSelectedTrial(repoRoot, record, trial) {
|
|
|
771
405
|
if (protectedPaths.length > 0)
|
|
772
406
|
throw new Error(agentProtectedConfigViolation(protectedPaths));
|
|
773
407
|
gitOutput(trial.worktree, ["add", "-A"]);
|
|
774
|
-
const
|
|
408
|
+
const stagedArgs = ["diff", "--cached", "--quiet"];
|
|
409
|
+
const staged = gitResult(trial.worktree, stagedArgs);
|
|
775
410
|
if (staged.status === 1) {
|
|
776
411
|
const commit = gitResult(trial.worktree, [
|
|
777
412
|
"commit",
|
|
@@ -784,7 +419,7 @@ function commitSelectedTrial(repoRoot, record, trial) {
|
|
|
784
419
|
}
|
|
785
420
|
}
|
|
786
421
|
else if (staged.status !== 0) {
|
|
787
|
-
throw new Error(
|
|
422
|
+
throw new Error(`Failed to inspect selected trial changes: ${formatGitResultFailure(stagedArgs, staged)}`);
|
|
788
423
|
}
|
|
789
424
|
const ahead = Number(gitOutput(trial.worktree, ["rev-list", "--count", `${record.base_commit}..HEAD`]).trim());
|
|
790
425
|
if (!Number.isFinite(ahead) || ahead < 1)
|