specdojo 0.3.0 → 0.3.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/catalog-build-references.js +144 -0
  3. package/dist/catalog-build-render.js +144 -0
  4. package/dist/catalog-build.js +13 -290
  5. package/dist/catalog-generate.js +6 -9
  6. package/dist/catalog-plan-generate.js +2 -2
  7. package/dist/catalog-plan.js +6 -6
  8. package/dist/catalog-scaffold.js +4 -4
  9. package/dist/catalog.js +2 -2
  10. package/dist/dashboard-exec-records.js +105 -0
  11. package/dist/dashboard-routines.js +255 -0
  12. package/dist/dashboard-shared.js +14 -0
  13. package/dist/dashboard-timeline.js +175 -0
  14. package/dist/dashboard.js +10 -544
  15. package/dist/deliverable-trash.js +3 -3
  16. package/dist/doc-index.js +3 -3
  17. package/dist/exec-commands.js +557 -0
  18. package/dist/exec-core.js +457 -0
  19. package/dist/exec-plans-core.js +693 -0
  20. package/dist/exec-plans-generation.js +206 -0
  21. package/dist/exec-plans-storage.js +131 -0
  22. package/dist/exec-plans.js +3 -1018
  23. package/dist/exec-repo-integration-git.js +23 -0
  24. package/dist/exec-repo-integration-sync.js +264 -0
  25. package/dist/exec-repo-integration.js +4 -281
  26. package/dist/exec-reporter-output.js +206 -0
  27. package/dist/exec-reporter.js +2 -206
  28. package/dist/exec-results.js +22 -15
  29. package/dist/exec-run-agent-pipeline.js +256 -0
  30. package/dist/exec-run-agent.js +531 -0
  31. package/dist/exec-run-in-place.js +541 -0
  32. package/dist/exec-run-job.js +717 -0
  33. package/dist/exec-run-lifecycle-commands.js +522 -0
  34. package/dist/exec-run-mode-shared.js +140 -0
  35. package/dist/exec-run-register-command.js +244 -0
  36. package/dist/exec-run-register-core.js +386 -0
  37. package/dist/exec-run-register-mode.js +206 -0
  38. package/dist/exec-run-register-resume.js +393 -0
  39. package/dist/exec-run-register-state.js +322 -0
  40. package/dist/exec-run-register-worktree.js +509 -0
  41. package/dist/exec-run-schedule-mode.js +294 -0
  42. package/dist/exec-run-schedule-prepare.js +353 -0
  43. package/dist/exec-run-schedule-task.js +572 -0
  44. package/dist/exec-run-shared.js +399 -0
  45. package/dist/exec-run.js +11 -6182
  46. package/dist/exec-shared.js +2 -2
  47. package/dist/exec-trial-commands.js +558 -0
  48. package/dist/exec-trial-core.js +371 -0
  49. package/dist/exec-trial.js +2 -921
  50. package/dist/exec-worktree-ops-commit.js +707 -0
  51. package/dist/exec-worktree-ops-lifecycle.js +292 -0
  52. package/dist/exec-worktree-ops-merge.js +303 -0
  53. package/dist/exec-worktree-ops.js +3 -1292
  54. package/dist/exec-worktree.js +32 -4
  55. package/dist/exec.js +2 -1006
  56. package/dist/frontmatter-namespace.js +2 -2
  57. package/dist/grade-apply.js +734 -0
  58. package/dist/grade-command-apply.js +250 -0
  59. package/dist/grade-command-inspect.js +138 -0
  60. package/dist/grade-command-plan.js +101 -0
  61. package/dist/grade-command-shared.js +68 -0
  62. package/dist/grade-core.js +307 -0
  63. package/dist/grade-markdown.js +274 -0
  64. package/dist/grade-pipeline-state.js +184 -0
  65. package/dist/grade-plan.js +507 -0
  66. package/dist/grade-result.js +5 -5
  67. package/dist/grade-target-discovery.js +265 -0
  68. package/dist/grade-targets.js +432 -0
  69. package/dist/grade.js +14 -3188
  70. package/dist/init-command.js +7 -7
  71. package/dist/job-definition.js +670 -0
  72. package/dist/job.js +9 -673
  73. package/dist/kata-command.js +2 -2
  74. package/dist/register-command-types.js +1 -0
  75. package/dist/register-core.js +363 -0
  76. package/dist/register-create-commands.js +245 -0
  77. package/dist/register-events.js +4 -4
  78. package/dist/register-item.js +6 -6
  79. package/dist/register-maintenance-commands.js +187 -0
  80. package/dist/register-migration.js +268 -0
  81. package/dist/register-renumber.js +314 -0
  82. package/dist/register-transition-commands.js +248 -0
  83. package/dist/register-update.js +230 -0
  84. package/dist/register-views.js +256 -0
  85. package/dist/register.js +61 -2069
  86. package/dist/review-plan.js +3 -3
  87. package/dist/routine-definition.js +401 -0
  88. package/dist/routine.js +6 -402
  89. package/dist/schedule-approach.js +2 -2
  90. package/dist/schedule-strategy-generate-document.js +273 -0
  91. package/dist/schedule-strategy-generate-scope.js +199 -0
  92. package/dist/schedule-strategy-generate.js +9 -473
  93. package/dist/schedule.js +4 -4
  94. package/dist/specdojo-config.js +3 -4
  95. package/dist/viewpoint-document-kinds-check.js +3 -3
  96. package/dist/yaml-pages.js +4 -4
  97. package/dist/yaml.js +28 -0
  98. package/docs/ja/specdojo/guides/exec-config-guide.md +6 -6
  99. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +20 -18
  100. package/docs/ja/specdojo/guides/routine-operation-guide.md +1 -1
  101. package/package.json +4 -5
  102. package/templates/antigravity/README.md +3 -3
  103. package/templates/antigravity/exec-defaults-snippet.yaml +6 -4
  104. package/templates/init-exec-defaults.yaml +3 -1
@@ -1,921 +1,2 @@
1
- import { spawn } from "node:child_process";
2
- import { createHash, randomUUID } from "node:crypto";
3
- import { copyFileSync, existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
4
- import { basename, dirname, join, relative, resolve, sep } from "node:path";
5
- import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, } from "./exec-agent-config.js";
6
- import { agentProtectedConfigViolation, captureAgentProtectedConfigSnapshot, changedAgentProtectedConfigPaths, isAgentProtectedConfigPath, } from "./exec-agent-protected-config.js";
7
- import { agentGitStateViolation, captureAgentGitStateSnapshot, changedAgentGitStateFields, } from "./exec-agent-git-state.js";
8
- import { recordExecutorEvidence, recordParentValidationFailureOutput, } from "./exec-evidence.js";
9
- import { parentValidationLabels, } from "./exec-parent-validation.js";
10
- import { activateResolvedProjectPaths, resolveProjectPaths } from "./exec-project.js";
11
- import { buildExecutorPrompt, isRateLimitError, loadRosterForExecutionPath, runConfiguredParentValidationBatch, } from "./exec-run.js";
12
- import { parsePlanTaskIdentity } from "./exec-plans.js";
13
- import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "./exec-reporter.js";
14
- import { ensureDir, safeSlug } from "./exec-shared.js";
15
- import { ensureExecWorktree, execBranchExists, findExecWorktree, gitEnvironment, gitOutput, gitResult, resolveWorktreeBase, worktreeNameFromTaskId, } from "./exec-worktree.js";
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
- }
379
- async function runOneTrial(params) {
380
- const { trial, worktree } = params;
381
- const startedAt = new Date();
382
- trial.status = "running";
383
- trial.started_at = startedAt.toISOString();
384
- writeComparison(params.recordPath, params.record);
385
- const outcome = await spawnAgent(params.executorCommand, params.prompt, worktree.path, worktreeEnvironment(params.repoRoot, worktree.path, params.schedulePath, params.executionPath));
386
- const executorCompletedAt = new Date();
387
- trial.executor.duration_ms = executorCompletedAt.getTime() - startedAt.getTime();
388
- trial.parent_validation.configured_ids = [...params.parentValidationIds];
389
- let parentValidations = [];
390
- let parentValidationFailureOutputs = [];
391
- if (params.parentValidationIds.length === 0) {
392
- trial.parent_validation.status = "not_configured";
393
- }
394
- else if (outcome.exitCode !== 0) {
395
- trial.parent_validation.status = "not_run";
396
- }
397
- else {
398
- const parentValidationStartedAt = Date.now();
399
- const parentValidationBatch = await runConfiguredParentValidationBatch(params.execDefaults, worktree.path, {
400
- label: `${params.record.task_id} (${trial.trial_id})`,
401
- });
402
- parentValidations = parentValidationBatch.validations;
403
- parentValidationFailureOutputs = parentValidationBatch.failureOutputs;
404
- trial.parent_validation.duration_ms = Date.now() - parentValidationStartedAt;
405
- trial.parent_validation.status = parentValidations.some((validation) => validation.status !== "passed")
406
- ? "failed"
407
- : "passed";
408
- }
409
- const runId = `${safeSlug(params.record.comparison_id)}-${trial.trial_id}`;
410
- const evidenceRecorded = recordExecutorEvidence({
411
- repoRoot: params.repoRoot,
412
- worktreePath: worktree.path,
413
- executionPath: params.executionPath,
414
- taskId: params.record.task_id,
415
- runId,
416
- actor: trial.agent,
417
- status: outcome.exitCode === 0 ? "succeeded" : "failed",
418
- startedAt: startedAt.toISOString(),
419
- completedAt: executorCompletedAt.toISOString(),
420
- exitCode: outcome.exitCode,
421
- attempts: 1,
422
- stdout: outcome.stdout,
423
- stderr: outcome.stderr,
424
- parentValidations,
425
- });
426
- evidenceRecorded.evidence = recordParentValidationFailureOutput({
427
- worktreePath: worktree.path,
428
- evidencePath: evidenceRecorded.evidencePath,
429
- evidence: evidenceRecorded.evidence,
430
- failureOutputs: parentValidationFailureOutputs,
431
- });
432
- const centralizedEvidenceDir = join(comparisonDir(params.executionPath, params.record.comparison_id), "trials", trial.trial_id);
433
- ensureDir(centralizedEvidenceDir);
434
- const centralizedEvidencePath = join(centralizedEvidenceDir, "evidence.json");
435
- evidenceRecorded.evidence.log_refs = evidenceRecorded.evidence.log_refs.map((ref) => {
436
- const logName = basename(ref.path);
437
- const centralizedLogPath = join(centralizedEvidenceDir, logName);
438
- copyFileSync(join(dirname(evidenceRecorded.evidencePath), logName), centralizedLogPath);
439
- return { ...ref, path: repoRelative(params.repoRoot, centralizedLogPath) };
440
- });
441
- writeFileSync(centralizedEvidencePath, `${JSON.stringify(evidenceRecorded.evidence, null, 2)}\n`, "utf8");
442
- trial.executor.exit_code = outcome.exitCode;
443
- trial.executor.attempts = 1;
444
- trial.executor.evidence_ref = repoRelative(params.repoRoot, centralizedEvidencePath);
445
- updateObjectiveMetrics(trial, evidenceRecorded.evidence, hasValidExecutorEnvelope(outcome.stdout));
446
- let reporterSucceeded = true;
447
- if (outcome.exitCode === 0 && params.reporterCommand) {
448
- const reporterEvidence = evidenceForReporter(evidenceRecorded.evidence, {
449
- repoRoot: params.repoRoot,
450
- worktreePath: worktree.path,
451
- executionPath: params.executionPath,
452
- });
453
- const reporter = await runReporterWithFormatRetry({
454
- plan: params.plan,
455
- evidence: reporterEvidence,
456
- mode: parsePlanTaskIdentity(params.plan)?.mode ?? "edit",
457
- invoke: async (reporterPrompt) => {
458
- const reporterOutcome = await spawnAgent(params.reporterCommand, reporterPrompt, worktree.path, worktreeEnvironment(params.repoRoot, worktree.path, params.schedulePath, params.executionPath));
459
- const result = reporterOutcome.exitCode === 0
460
- ? "success"
461
- : isRateLimitError(reporterOutcome.exitCode, `${reporterOutcome.stdout}\n${reporterOutcome.stderr}`, params.reporterRateLimitDetection)
462
- ? "rate_limit"
463
- : "failure";
464
- return {
465
- result,
466
- stdout: reporterOutcome.stdout,
467
- stderr: reporterOutcome.stderr,
468
- };
469
- },
470
- });
471
- trial.reporter.format_attempts = reporter.formatAttempts;
472
- trial.reporter.format_retries = Math.max(0, reporter.formatAttempts - 1);
473
- if (reporter.result === "success") {
474
- const facts = deriveReporterFacts(reporterEvidence, {
475
- mode: parsePlanTaskIdentity(params.plan)?.mode ?? "edit",
476
- });
477
- trial.reporter.structured_output = true;
478
- trial.reporter.outcome = facts.outcome;
479
- trial.reporter.output = reporter.output;
480
- reporterSucceeded = facts.outcome === "complete";
481
- if (reporterSucceeded) {
482
- trial.reporter.status = "succeeded";
483
- }
484
- else {
485
- trial.reporter.status = "blocked";
486
- trial.reporter.failure_category = "evidence_blocked";
487
- trial.reporter.failure_reason = facts.block_reason;
488
- }
489
- }
490
- else {
491
- trial.reporter.status = "failed";
492
- trial.reporter.failure_category = classifyReporterFailure(reporter.result, reporter.reason);
493
- trial.reporter.failure_reason = reporter.reason;
494
- reporterSucceeded = false;
495
- }
496
- }
497
- const completedAt = new Date();
498
- trial.completed_at = completedAt.toISOString();
499
- trial.duration_ms = completedAt.getTime() - startedAt.getTime();
500
- trial.status =
501
- outcome.exitCode === 0 &&
502
- trial.executor.validations_failed === 0 &&
503
- trial.parent_validation.status !== "failed" &&
504
- trial.parent_validation.status !== "not_run" &&
505
- reporterSucceeded
506
- ? "succeeded"
507
- : "failed";
508
- writeComparison(params.recordPath, params.record);
509
- }
510
- async function runPool(items, parallel) {
511
- let next = 0;
512
- const workers = Array.from({ length: Math.min(parallel, items.length) }, async () => {
513
- while (next < items.length) {
514
- const index = next++;
515
- await items[index]();
516
- }
517
- });
518
- await Promise.all(workers);
519
- }
520
- function parseTrialPair(value) {
521
- const separator = value.indexOf("=");
522
- const executor = value.slice(0, separator).trim();
523
- const reporter = value.slice(separator + 1).trim();
524
- if (separator < 1 || !executor || !reporter || reporter.includes("=")) {
525
- throw new Error(`--pair must use <executor>=<reporter>: ${value}`);
526
- }
527
- return { executor, reporter };
528
- }
529
- function resolveTrialDefinitions(opts) {
530
- const agentValues = (opts.agent ?? []).map((value) => value.trim()).filter(Boolean);
531
- const pairValues = (opts.pair ?? []).map((value) => value.trim()).filter(Boolean);
532
- if (agentValues.length > 0 && pairValues.length > 0) {
533
- throw new Error("Use either --agent or --pair, not both.");
534
- }
535
- if (pairValues.length > 0) {
536
- if (opts.reporterBy)
537
- throw new Error("--pair cannot be combined with --reporter-by.");
538
- const pairs = pairValues.map(parseTrialPair);
539
- const keys = pairs.map((pair) => `${pair.executor}\0${pair.reporter}`);
540
- if (new Set(keys).size < 2 || new Set(keys).size !== keys.length) {
541
- throw new Error("exec trial run requires at least two distinct --pair values.");
542
- }
543
- return { agents: [...new Set(pairs.map((pair) => pair.executor))], pairs };
544
- }
545
- const agents = [...new Set(agentValues)];
546
- if (agents.length < 2) {
547
- throw new Error("exec trial run requires at least two distinct --agent values or --pair values.");
548
- }
549
- return { agents };
550
- }
551
- function resolveBaseCommit(repoRoot, revision) {
552
- const result = gitResult(repoRoot, [
553
- "rev-parse",
554
- "--verify",
555
- "--end-of-options",
556
- `${revision}^{commit}`,
557
- ]);
558
- if (result.status !== 0)
559
- throw new Error(`Trial base is not a commit: ${revision}`);
560
- return String(result.stdout).trim();
561
- }
562
- async function runTrials(opts) {
563
- const paths = resolveProjectPaths({ project: opts.project });
564
- activateResolvedProjectPaths(paths);
565
- const repoRoot = specdojoRootDir();
566
- const projectId = paths.projectId ?? opts.project?.trim();
567
- if (!projectId)
568
- throw new Error("exec trial run requires a project id.");
569
- const planPath = resolve(opts.plan);
570
- if (!existsSync(planPath))
571
- throw new Error(`Plan not found: ${planPath}`);
572
- const planContent = readFileSync(planPath, "utf8");
573
- const identity = parsePlanTaskIdentity(planContent);
574
- if (!identity)
575
- throw new Error("Trial plan must have SpecDojo task_id/mode/project_id frontmatter.");
576
- if (identity.projectId && identity.projectId !== projectId) {
577
- throw new Error(`Plan project_id ${identity.projectId} does not match --project ${projectId}.`);
578
- }
579
- const { agents, pairs } = resolveTrialDefinitions(opts);
580
- const parallel = parsePositiveInteger(opts.parallel ?? "1", "--parallel");
581
- const comparisonId = safeSlug(opts.comparison?.trim() ||
582
- `${identity.taskId}-${new Date().toISOString()}-${randomUUID().slice(0, 8)}`);
583
- const recordPath = comparisonPath(paths.executionPath, comparisonId);
584
- if (existsSync(recordPath))
585
- throw new Error(`Comparison already exists: ${comparisonId}`);
586
- const worktreeBase = resolveWorktreeBase(repoRoot, opts.worktreeBase, configuredWorktreeBase(paths.schedulePath));
587
- const roster = loadRosterForExecutionPath(paths.executionPath);
588
- const defaults = loadExecDefaultsConfig(opts.execDefaults ?? defaultExecDefaultsPath(), paths.executionPath);
589
- const executorCommands = new Map();
590
- for (const agent of agents) {
591
- const command = resolveMemberCommand(defaults, resolveMember(roster, agent, "executor"));
592
- if (!command)
593
- throw new Error(`Agent command could not be resolved: ${agent}`);
594
- executorCommands.set(agent, command);
595
- }
596
- const reporterCommands = new Map();
597
- const reporterRateLimitDetections = new Map();
598
- if (opts.reporterBy) {
599
- const reporterMember = resolveMember(roster, opts.reporterBy, "reporter");
600
- const reporterCommand = resolveMemberCommand(defaults, reporterMember);
601
- if (!reporterCommand)
602
- throw new Error(`Reporter command could not be resolved: ${opts.reporterBy}`);
603
- reporterCommands.set(opts.reporterBy, reporterCommand);
604
- reporterRateLimitDetections.set(opts.reporterBy, resolveRateLimitDetection(defaults, reporterMember.provider));
605
- }
606
- for (const reporter of new Set(pairs?.map((pair) => pair.reporter) ?? [])) {
607
- const reporterMember = resolveMember(roster, reporter, "reporter");
608
- const reporterCommand = resolveMemberCommand(defaults, reporterMember);
609
- if (!reporterCommand)
610
- throw new Error(`Reporter command could not be resolved: ${reporter}`);
611
- reporterCommands.set(reporter, reporterCommand);
612
- reporterRateLimitDetections.set(reporter, resolveRateLimitDetection(defaults, reporterMember.provider));
613
- }
614
- const parentValidationEntries = defaults.pipeline?.parent_validations ?? [];
615
- // Labels are `<id>` for the project repository and `<repo>:<id>` for a product repository.
616
- const parentValidationIds = parentValidationLabels(parentValidationEntries);
617
- const prompt = `${buildExecutorPrompt(planContent, parentValidationEntries).trimEnd()}${TRIAL_PROMPT_SUFFIX}`;
618
- const requestedRevision = opts.base?.trim() || "HEAD";
619
- const headCommit = resolveBaseCommit(repoRoot, "HEAD");
620
- const baseCommit = resolveBaseCommit(repoRoot, requestedRevision);
621
- const planRepoPath = repoRelative(repoRoot, planPath);
622
- const baseValidation = buildTrialBaseValidation({
623
- repoRoot,
624
- requestedRevision,
625
- resolvedCommit: baseCommit,
626
- headCommit,
627
- defaultedToHead: !opts.base?.trim(),
628
- planPath: planRepoPath,
629
- planContent,
630
- });
631
- const record = buildComparisonRecord({
632
- comparisonId,
633
- projectId,
634
- taskId: identity.taskId,
635
- createdAt: new Date().toISOString(),
636
- baseCommit,
637
- baseValidation,
638
- planPath: planRepoPath,
639
- planContent,
640
- prompt,
641
- agents,
642
- pairs,
643
- reporter: opts.reporterBy,
644
- worktreeBase,
645
- parentValidationIds,
646
- });
647
- if (opts.dryRun) {
648
- process.stdout.write(`${JSON.stringify(record, null, 2)}\n`);
649
- return;
650
- }
651
- writeComparison(recordPath, record);
652
- const prepared = new Map();
653
- for (const trial of record.trials) {
654
- const worktreeTaskId = `${projectId}:trial:${comparisonId}:${trial.trial_id}`;
655
- if (findExecWorktree(repoRoot, worktreeTaskId) || execBranchExists(repoRoot, worktreeTaskId)) {
656
- throw new Error(`Trial worktree or branch already exists: ${trial.branch}`);
657
- }
658
- const worktree = ensureExecWorktree({
659
- repoRoot,
660
- worktreeBase,
661
- taskId: worktreeTaskId,
662
- startPoint: record.base_commit,
663
- });
664
- prepared.set(trial.trial_id, worktree);
665
- trial.status = "prepared";
666
- writeComparison(recordPath, record);
667
- }
668
- await runPool(record.trials.map((trial) => async () => {
669
- const worktree = prepared.get(trial.trial_id);
670
- if (!worktree)
671
- throw new Error(`Prepared worktree missing: ${trial.trial_id}`);
672
- await runOneTrial({
673
- record,
674
- recordPath,
675
- trial,
676
- worktree,
677
- plan: planContent,
678
- prompt,
679
- executorCommand: executorCommands.get(trial.agent),
680
- reporterCommand: trial.reporter_agent
681
- ? reporterCommands.get(trial.reporter_agent)
682
- : undefined,
683
- reporterRateLimitDetection: trial.reporter_agent
684
- ? reporterRateLimitDetections.get(trial.reporter_agent)
685
- : undefined,
686
- parentValidationIds,
687
- execDefaults: defaults,
688
- repoRoot,
689
- schedulePath: paths.schedulePath,
690
- executionPath: paths.executionPath,
691
- });
692
- }), parallel);
693
- process.stdout.write(`Comparison recorded: ${repoRelative(repoRoot, recordPath)}\n`);
694
- }
695
- function resolveRecord(opts) {
696
- const paths = resolveProjectPaths({ project: opts.project });
697
- activateResolvedProjectPaths(paths);
698
- const path = comparisonPath(paths.executionPath, opts.comparison);
699
- return { record: readComparison(path), path, repoRoot: specdojoRootDir() };
700
- }
701
- function findTrial(record, selector) {
702
- const matches = record.trials.filter((trial) => trial.trial_id === selector || trial.agent === selector);
703
- if (matches.length !== 1)
704
- throw new Error(`Trial not found or ambiguous: ${selector}`);
705
- return matches[0];
706
- }
707
- function statusTrials(opts) {
708
- const { record } = resolveRecord(opts);
709
- process.stdout.write(`Comparison ${record.comparison_id} [${record.status}] task=${record.task_id}\n`);
710
- process.stdout.write(`plan sha256=${record.plan.sha256} prompt sha256=${record.plan.prompt_sha256}\n`);
711
- process.stdout.write(`base=${record.base_commit} requested=${record.base?.requested_revision ?? "(legacy)"} head_reference=${record.base?.head_commit_at_start ?? "unknown"} compatible=${record.base?.compatible ?? "unknown"} reporter_mode=${record.reporter_mode ?? "shared-or-none"}\n`);
712
- for (const warning of record.base?.warnings ?? []) {
713
- process.stdout.write(`base warning: ${warning}\n`);
714
- }
715
- for (const trial of record.trials) {
716
- const reporterStatus = trial.reporter.status ?? (trial.reporter.structured_output ? "succeeded" : "not_run");
717
- const parentValidation = trial.parent_validation ?? {
718
- status: "not_configured",
719
- duration_ms: null,
720
- validations_passed: 0,
721
- validations_failed: 0,
722
- validations_not_run: 0,
723
- };
724
- process.stdout.write(`${trial.trial_id}\t${trial.status}\ttime(executor/parent/total)=${trial.executor.duration_ms ?? "-"}/${parentValidation.duration_ms ?? "-"}/${trial.duration_ms ?? "-"}ms\tfiles=${trial.executor.files_changed}\texecutor-validations(reported/passed/failed/not_run/requires_human)=${trial.executor.validations_reported ?? trial.executor.validations.length}/${trial.executor.validations_passed}/${trial.executor.validations_failed}/${trial.executor.validations_not_run}/${trial.executor.validations_requires_human ?? 0}\tparent-validations(status/passed/failed/not_run)=${parentValidation.status}/${parentValidation.validations_passed}/${parentValidation.validations_failed}/${parentValidation.validations_not_run}\treporter=${reporterStatus}/${trial.reporter.format_attempts}/${trial.reporter.failure_category ?? "-"}\n`);
725
- }
726
- }
727
- function rateTrial(opts) {
728
- const { record, path } = resolveRecord(opts);
729
- const trial = findTrial(record, opts.trial);
730
- const judgment = parseRating(opts.judgmentQuality, "--judgment-quality");
731
- const writing = parseRating(opts.writingQuality, "--writing-quality");
732
- const scope = parseRating(opts.scopeAdherence, "--scope-adherence");
733
- if (judgment !== undefined)
734
- trial.subjective.judgment_quality = judgment;
735
- if (writing !== undefined)
736
- trial.subjective.writing_quality = writing;
737
- if (scope !== undefined)
738
- trial.subjective.scope_adherence = scope;
739
- if (opts.notes !== undefined)
740
- trial.subjective.notes = opts.notes.trim();
741
- writeComparison(path, record);
742
- process.stdout.write(`Rated trial: ${trial.trial_id}\n`);
743
- }
744
- function changedPaths(worktreePath) {
745
- const output = gitOutput(worktreePath, [
746
- "status",
747
- "--porcelain=v1",
748
- "-z",
749
- "--untracked-files=all",
750
- ]);
751
- const paths = [];
752
- for (const record of output.split("\0").filter(Boolean)) {
753
- if (record.length >= 4)
754
- paths.push(record.slice(3));
755
- }
756
- return paths;
757
- }
758
- function removeTrialWorktree(repoRoot, trial, deleteUnmerged) {
759
- const registered = findExecWorktree(repoRoot, trial.branch.slice("exec/".length));
760
- const worktreePath = registered?.path ?? trial.worktree;
761
- if (existsSync(worktreePath)) {
762
- gitOutput(repoRoot, ["worktree", "remove", "--force", worktreePath]);
763
- }
764
- if (gitResult(repoRoot, ["show-ref", "--verify", "--quiet", `refs/heads/${trial.branch}`])
765
- .status === 0) {
766
- gitOutput(repoRoot, ["branch", deleteUnmerged ? "-D" : "-d", trial.branch]);
767
- }
768
- }
769
- function commitSelectedTrial(repoRoot, record, trial) {
770
- const protectedPaths = changedPaths(trial.worktree).filter(isAgentProtectedConfigPath);
771
- if (protectedPaths.length > 0)
772
- throw new Error(agentProtectedConfigViolation(protectedPaths));
773
- gitOutput(trial.worktree, ["add", "-A"]);
774
- const staged = gitResult(trial.worktree, ["diff", "--cached", "--quiet"]);
775
- if (staged.status === 1) {
776
- const commit = gitResult(trial.worktree, [
777
- "commit",
778
- "-m",
779
- `feat(trial): adopt ${record.task_id} from ${trial.agent}`,
780
- ]);
781
- if (commit.status !== 0) {
782
- gitResult(trial.worktree, ["reset", "--quiet"]);
783
- throw new Error(`Trial commit failed: ${commit.stderr || commit.stdout}`);
784
- }
785
- }
786
- else if (staged.status !== 0) {
787
- throw new Error("Failed to inspect selected trial changes.");
788
- }
789
- const ahead = Number(gitOutput(trial.worktree, ["rev-list", "--count", `${record.base_commit}..HEAD`]).trim());
790
- if (!Number.isFinite(ahead) || ahead < 1)
791
- throw new Error("Selected trial has no changes to adopt.");
792
- }
793
- function adoptTrial(opts) {
794
- const { record, path, repoRoot } = resolveRecord(opts);
795
- if (record.status !== "active")
796
- throw new Error(`Comparison is already ${record.status}.`);
797
- const selected = findTrial(record, opts.trial);
798
- if (selected.status !== "succeeded")
799
- throw new Error(`Only a succeeded trial can be adopted: ${selected.trial_id}`);
800
- if (opts.dryRun) {
801
- process.stdout.write(`[dry-run] adopt ${selected.branch}; discard ${record.trials.length - 1} other trial(s)\n`);
802
- return;
803
- }
804
- commitSelectedTrial(repoRoot, record, selected);
805
- try {
806
- gitOutput(repoRoot, ["merge", "--no-ff", "--no-edit", selected.branch]);
807
- }
808
- catch (error) {
809
- gitResult(repoRoot, ["merge", "--abort"]);
810
- throw error;
811
- }
812
- removeTrialWorktree(repoRoot, selected, false);
813
- selected.status = "adopted";
814
- for (const trial of record.trials) {
815
- if (trial === selected)
816
- continue;
817
- removeTrialWorktree(repoRoot, trial, true);
818
- trial.status = "discarded";
819
- }
820
- record.status = "adopted";
821
- record.selected_trial_id = selected.trial_id;
822
- record.completed_at = new Date().toISOString();
823
- writeComparison(path, record);
824
- process.stdout.write(`Adopted trial ${selected.trial_id}; discarded remaining trial worktrees.\n`);
825
- }
826
- function discardTrials(opts) {
827
- const { record, path, repoRoot } = resolveRecord(opts);
828
- if (record.status !== "active")
829
- throw new Error(`Comparison is already ${record.status}.`);
830
- for (const trial of record.trials) {
831
- removeTrialWorktree(repoRoot, trial, true);
832
- trial.status = "discarded";
833
- }
834
- record.status = "discarded";
835
- record.completed_at = new Date().toISOString();
836
- writeComparison(path, record);
837
- process.stdout.write(`Discarded all trial worktrees; comparison record retained.\n`);
838
- }
839
- function commandError(error) {
840
- process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
841
- process.exitCode = 1;
842
- }
843
- export function registerExecTrialCommands(exec) {
844
- const trial = exec.command("trial").description("Compare multiple agents on one immutable plan");
845
- trial
846
- .command("run")
847
- .requiredOption("--project <projectId>", "Project id")
848
- .requiredOption("--plan <path>", "Existing SpecDojo plan used unchanged by every trial")
849
- .option("--agent <nicknames...>", "Two or more executor agent nicknames")
850
- .option("--pair <executor=reporter...>", "Two or more executor/reporter pairs (alternative to --agent)")
851
- .option("--reporter-by <nickname>", "Shared reporter agent used to assess structured output")
852
- .option("--base <revision>", "Commit used as the trial worktree start point (default: HEAD)")
853
- .option("--comparison <id>", "Stable comparison id (generated when omitted)")
854
- .option("--parallel <n>", "Maximum concurrent trials", "1")
855
- .option("--worktree-base <path>", "Override worktree base directory")
856
- .option("--exec-defaults <path>", "Path to exec-defaults.yaml")
857
- .option("--dry-run", "Print the planned comparison without creating worktrees", false)
858
- .action(async (opts) => {
859
- try {
860
- await runTrials(opts);
861
- }
862
- catch (error) {
863
- commandError(error);
864
- }
865
- });
866
- trial
867
- .command("status")
868
- .requiredOption("--project <projectId>", "Project id")
869
- .requiredOption("--comparison <id>", "Comparison id")
870
- .action((opts) => {
871
- try {
872
- statusTrials(opts);
873
- }
874
- catch (error) {
875
- commandError(error);
876
- }
877
- });
878
- trial
879
- .command("rate")
880
- .requiredOption("--project <projectId>", "Project id")
881
- .requiredOption("--comparison <id>", "Comparison id")
882
- .requiredOption("--trial <idOrAgent>", "Trial id or agent nickname")
883
- .option("--judgment-quality <1-5>", "Human judgment-quality rating")
884
- .option("--writing-quality <1-5>", "Human writing-quality rating")
885
- .option("--scope-adherence <1-5>", "Human scope-adherence rating")
886
- .option("--notes <text>", "Human evaluation notes")
887
- .action((opts) => {
888
- try {
889
- rateTrial(opts);
890
- }
891
- catch (error) {
892
- commandError(error);
893
- }
894
- });
895
- trial
896
- .command("adopt")
897
- .requiredOption("--project <projectId>", "Project id")
898
- .requiredOption("--comparison <id>", "Comparison id")
899
- .requiredOption("--trial <idOrAgent>", "Succeeded trial to merge")
900
- .option("--dry-run", "Print adopt/discard actions", false)
901
- .action((opts) => {
902
- try {
903
- adoptTrial(opts);
904
- }
905
- catch (error) {
906
- commandError(error);
907
- }
908
- });
909
- trial
910
- .command("discard")
911
- .requiredOption("--project <projectId>", "Project id")
912
- .requiredOption("--comparison <id>", "Comparison id")
913
- .action((opts) => {
914
- try {
915
- discardTrials(opts);
916
- }
917
- catch (error) {
918
- commandError(error);
919
- }
920
- });
921
- }
1
+ export { buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, extractPlanRepoPaths, updateObjectiveMetrics, } from "./exec-trial-core.js";
2
+ export { registerExecTrialCommands } from "./exec-trial-commands.js";