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.
- package/CHANGELOG.md +18 -0
- package/dist/catalog-build-references.js +144 -0
- package/dist/catalog-build-render.js +144 -0
- package/dist/catalog-build.js +13 -290
- package/dist/catalog-generate.js +6 -9
- package/dist/catalog-plan-generate.js +2 -2
- package/dist/catalog-plan.js +6 -6
- package/dist/catalog-scaffold.js +4 -4
- package/dist/catalog.js +2 -2
- package/dist/dashboard-exec-records.js +105 -0
- package/dist/dashboard-routines.js +255 -0
- package/dist/dashboard-shared.js +14 -0
- package/dist/dashboard-timeline.js +175 -0
- package/dist/dashboard.js +10 -544
- package/dist/deliverable-trash.js +3 -3
- package/dist/doc-index.js +3 -3
- package/dist/exec-commands.js +557 -0
- package/dist/exec-core.js +457 -0
- package/dist/exec-plans-core.js +693 -0
- package/dist/exec-plans-generation.js +206 -0
- package/dist/exec-plans-storage.js +131 -0
- package/dist/exec-plans.js +3 -1018
- package/dist/exec-repo-integration-git.js +23 -0
- package/dist/exec-repo-integration-sync.js +264 -0
- package/dist/exec-repo-integration.js +4 -281
- package/dist/exec-reporter-output.js +206 -0
- package/dist/exec-reporter.js +2 -206
- package/dist/exec-results.js +22 -15
- package/dist/exec-run-agent-pipeline.js +256 -0
- package/dist/exec-run-agent.js +531 -0
- package/dist/exec-run-in-place.js +541 -0
- package/dist/exec-run-job.js +717 -0
- package/dist/exec-run-lifecycle-commands.js +522 -0
- package/dist/exec-run-mode-shared.js +140 -0
- package/dist/exec-run-register-command.js +244 -0
- package/dist/exec-run-register-core.js +386 -0
- package/dist/exec-run-register-mode.js +206 -0
- package/dist/exec-run-register-resume.js +393 -0
- package/dist/exec-run-register-state.js +322 -0
- package/dist/exec-run-register-worktree.js +509 -0
- package/dist/exec-run-schedule-mode.js +294 -0
- package/dist/exec-run-schedule-prepare.js +353 -0
- package/dist/exec-run-schedule-task.js +572 -0
- package/dist/exec-run-shared.js +399 -0
- package/dist/exec-run.js +11 -6182
- package/dist/exec-shared.js +2 -2
- package/dist/exec-trial-commands.js +558 -0
- package/dist/exec-trial-core.js +371 -0
- package/dist/exec-trial.js +2 -921
- package/dist/exec-worktree-ops-commit.js +707 -0
- package/dist/exec-worktree-ops-lifecycle.js +292 -0
- package/dist/exec-worktree-ops-merge.js +303 -0
- package/dist/exec-worktree-ops.js +3 -1292
- package/dist/exec-worktree.js +32 -4
- package/dist/exec.js +2 -1006
- package/dist/frontmatter-namespace.js +2 -2
- 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-markdown.js +274 -0
- package/dist/grade-pipeline-state.js +184 -0
- package/dist/grade-plan.js +507 -0
- package/dist/grade-result.js +5 -5
- package/dist/grade-target-discovery.js +265 -0
- package/dist/grade-targets.js +432 -0
- package/dist/grade.js +14 -3188
- package/dist/init-command.js +7 -7
- package/dist/job-definition.js +670 -0
- package/dist/job.js +9 -673
- package/dist/kata-command.js +2 -2
- package/dist/register-command-types.js +1 -0
- package/dist/register-core.js +363 -0
- package/dist/register-create-commands.js +245 -0
- package/dist/register-events.js +4 -4
- package/dist/register-item.js +6 -6
- package/dist/register-maintenance-commands.js +187 -0
- package/dist/register-migration.js +268 -0
- package/dist/register-renumber.js +314 -0
- package/dist/register-transition-commands.js +248 -0
- package/dist/register-update.js +230 -0
- package/dist/register-views.js +256 -0
- package/dist/register.js +61 -2069
- package/dist/review-plan.js +3 -3
- package/dist/routine-definition.js +401 -0
- package/dist/routine.js +6 -402
- package/dist/schedule-approach.js +2 -2
- package/dist/schedule-strategy-generate-document.js +273 -0
- package/dist/schedule-strategy-generate-scope.js +199 -0
- package/dist/schedule-strategy-generate.js +9 -473
- package/dist/schedule.js +4 -4
- package/dist/specdojo-config.js +3 -4
- package/dist/viewpoint-document-kinds-check.js +3 -3
- package/dist/yaml-pages.js +4 -4
- package/dist/yaml.js +28 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +6 -6
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +20 -18
- package/docs/ja/specdojo/guides/routine-operation-guide.md +1 -1
- package/package.json +4 -5
- package/templates/antigravity/README.md +3 -3
- package/templates/antigravity/exec-defaults-snippet.yaml +6 -4
- package/templates/init-exec-defaults.yaml +3 -1
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { relative, sep } from "node:path";
|
|
2
|
+
import { recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "./exec-evidence.js";
|
|
3
|
+
import { failedParentValidationReason, hasRecordedParentValidations, parentValidationRoots, replaceParentValidationResults, } from "./exec-parent-validation.js";
|
|
4
|
+
import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "./exec-pipeline-state.js";
|
|
5
|
+
import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "./exec-reporter.js";
|
|
6
|
+
import { renderReporterResult } from "./exec-results.js";
|
|
7
|
+
import { randomHex } from "./exec-shared.js";
|
|
8
|
+
import { withProductRepoPrompt } from "./exec-task-repos.js";
|
|
9
|
+
import { worktreeStatusPaths } from "./exec-worktree-ops.js";
|
|
10
|
+
import { agentEnvironment, appendParentValidationsToExecutorEvidence, buildExecutorPrompt, extractBlockReason, resumedTargetCoverageFailure, runConfiguredParentValidationBatch, runWithRetry, } from "./exec-run-agent.js";
|
|
11
|
+
export async function refreshParentValidationsForReporterResume(params) {
|
|
12
|
+
const configuredEntries = params.execDefaults.pipeline?.parent_validations;
|
|
13
|
+
const force = params.force === true && (configuredEntries?.length ?? 0) > 0;
|
|
14
|
+
if (!force &&
|
|
15
|
+
hasRecordedParentValidations(params.evidence.validations, configuredEntries) &&
|
|
16
|
+
!failedParentValidationReason(params.evidence.validations)) {
|
|
17
|
+
return params.evidence;
|
|
18
|
+
}
|
|
19
|
+
process.stdout.write(` Refreshing parent validations before ${params.stageLabel ?? "reporter"} resume` +
|
|
20
|
+
`${force ? " (integration targets were merged into the worktree)" : ""}.\n`);
|
|
21
|
+
const parentValidationBatch = await runConfiguredParentValidationBatch(params.execDefaults, parentValidationRoots(params.cwd, params.productWorktrees), { label: params.evidence.task_id });
|
|
22
|
+
const evidenceWithValidations = replaceParentValidationResults(params.evidence, parentValidationBatch.validations);
|
|
23
|
+
const evidence = recordParentValidationFailureOutput({
|
|
24
|
+
worktreePath: params.cwd,
|
|
25
|
+
evidencePath: params.evidencePath,
|
|
26
|
+
evidence: evidenceWithValidations,
|
|
27
|
+
failureOutputs: parentValidationBatch.failureOutputs,
|
|
28
|
+
});
|
|
29
|
+
if (parentValidationBatch.failureOutputs.length === 0) {
|
|
30
|
+
writeExecutorEvidence(params.evidencePath, evidence);
|
|
31
|
+
}
|
|
32
|
+
process.stdout.write(` Refreshed executor evidence: ${relative(params.cwd, params.evidencePath).split(sep).join("/")}\n`);
|
|
33
|
+
return evidence;
|
|
34
|
+
}
|
|
35
|
+
// register pipeline の reporter 段だけを実行する。executor 直後の通常経路と、executor が
|
|
36
|
+
// 成功したまま reporter だけが失敗した run の再開経路の双方から共有し、reporter 起動・
|
|
37
|
+
// result 描画・pipeline-state 更新のみを担う(register の状態遷移と commit は呼び出し側)。
|
|
38
|
+
export async function runReporterStage(params) {
|
|
39
|
+
const { repoRoot, cwd, schedulePath, executionPath, reporterCandidates, execDefaults } = params;
|
|
40
|
+
const env = agentEnvironment(repoRoot, cwd, schedulePath, executionPath, params.productWorktrees);
|
|
41
|
+
const reporterEvidence = evidenceForReporter(params.evidence, {
|
|
42
|
+
repoRoot,
|
|
43
|
+
worktreePath: cwd,
|
|
44
|
+
executionPath,
|
|
45
|
+
resultPath: params.resultPath,
|
|
46
|
+
...(params.registerPaths ? { registerPaths: params.registerPaths } : {}),
|
|
47
|
+
});
|
|
48
|
+
let state = params.state;
|
|
49
|
+
const reporterStartedAt = new Date().toISOString();
|
|
50
|
+
state = updatePipelineStage(state, "reporter", {
|
|
51
|
+
status: "running",
|
|
52
|
+
actor: reporterCandidates[0]?.actor ?? null,
|
|
53
|
+
started_at: reporterStartedAt,
|
|
54
|
+
completed_at: null,
|
|
55
|
+
}, reporterStartedAt);
|
|
56
|
+
writePipelineState(params.statePath, state);
|
|
57
|
+
process.stdout.write(` Running reporter: ${reporterCandidates[0]?.command ?? ""}\n`);
|
|
58
|
+
let reporterAttempts = 0;
|
|
59
|
+
const runReporter = () => runReporterWithFormatRetry({
|
|
60
|
+
plan: params.planPrompt,
|
|
61
|
+
evidence: reporterEvidence,
|
|
62
|
+
mode: params.mode ?? "edit",
|
|
63
|
+
invoke: async (reporterPrompt) => {
|
|
64
|
+
const reporterOutcome = await runWithRetry(reporterCandidates, reporterPrompt, execDefaults, cwd, env, params.resultPath);
|
|
65
|
+
reporterAttempts += reporterOutcome.attempts;
|
|
66
|
+
return {
|
|
67
|
+
result: reporterOutcome.result,
|
|
68
|
+
stdout: reporterOutcome.stdout,
|
|
69
|
+
stderr: reporterOutcome.stderr,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
const reporter = params.providerConcurrencyGate
|
|
74
|
+
? await params.providerConcurrencyGate.run(reporterCandidates[0]?.provider, runReporter, `${params.evidence.task_id} reporter`)
|
|
75
|
+
: await runReporter();
|
|
76
|
+
let exitCode = 1;
|
|
77
|
+
let blockReason;
|
|
78
|
+
if (reporter.result === "success") {
|
|
79
|
+
try {
|
|
80
|
+
await renderReporterResult(params.resultPath, reporter.output, reporterEvidence);
|
|
81
|
+
const facts = deriveReporterFacts(reporterEvidence, { mode: params.mode ?? "edit" });
|
|
82
|
+
exitCode = facts.outcome === "complete" ? 0 : 1;
|
|
83
|
+
blockReason = facts.block_reason || undefined;
|
|
84
|
+
process.stdout.write(` Reporter complete: ${reporterCandidates[0]?.actor ?? "reporter"} (format attempts: ${reporter.formatAttempts})\n`);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
exitCode = 1;
|
|
88
|
+
blockReason =
|
|
89
|
+
error instanceof Error
|
|
90
|
+
? `reporter result rendering failed: ${error.message}`
|
|
91
|
+
: String(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
blockReason = reporter.reason;
|
|
96
|
+
recordReporterFailureOutput({
|
|
97
|
+
worktreePath: cwd,
|
|
98
|
+
evidencePath: params.evidencePath,
|
|
99
|
+
evidence: params.evidence,
|
|
100
|
+
invocationOutputs: reporter.invocationOutputs,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const reporterCompletedAt = new Date().toISOString();
|
|
104
|
+
state = updatePipelineStage(state, "reporter", {
|
|
105
|
+
status: exitCode === 0 ? "succeeded" : reporter.result === "rate_limit" ? "rate_limited" : "failed",
|
|
106
|
+
attempts: state.stages.reporter.attempts + reporterAttempts,
|
|
107
|
+
completed_at: reporterCompletedAt,
|
|
108
|
+
artifact_ref: reporter.result === "success"
|
|
109
|
+
? relative(cwd, params.resultPath).split(sep).join("/")
|
|
110
|
+
: state.stages.reporter.artifact_ref,
|
|
111
|
+
}, reporterCompletedAt);
|
|
112
|
+
writePipelineState(params.statePath, state);
|
|
113
|
+
const runResult = exitCode === 0 ? "success" : reporter.result === "rate_limit" ? "rate_limit" : "failure";
|
|
114
|
+
return { exitCode, runResult, blockReason, state };
|
|
115
|
+
}
|
|
116
|
+
// 1件の plan/result を executor→reporter の2段階で実行する。register 項目と Job Run の
|
|
117
|
+
// 双方が使い、in-place(cwd: repoRoot)・worktree(cwd: worktree.path)から共有する。
|
|
118
|
+
// evidence・pipeline-state の記録先は
|
|
119
|
+
// Schedule タスクの pipeline と同じ形式(exec/evidence/<taskId>/<runId>/)にすることで、
|
|
120
|
+
// 監査証跡のフォーマットを実行経路によらず統一する。state には plan / result の参照も
|
|
121
|
+
// 記録し、reporter だけが失敗した場合に `--resume` が入力を復元できるようにする。
|
|
122
|
+
export async function runAgentPipeline(params) {
|
|
123
|
+
const { repoRoot, cwd, schedulePath, executionPath, taskId, executor, reporterCandidates, planPrompt, resultPath, execDefaults, } = params;
|
|
124
|
+
const startedAt = new Date().toISOString();
|
|
125
|
+
const runId = params.runId ?? `${new Date().toISOString().replace(/[-:.]/g, "")}-${randomHex(4)}`;
|
|
126
|
+
const stateLocation = pipelineStateLocation({
|
|
127
|
+
repoRoot,
|
|
128
|
+
worktreePath: cwd,
|
|
129
|
+
executionPath,
|
|
130
|
+
taskId,
|
|
131
|
+
runId,
|
|
132
|
+
});
|
|
133
|
+
let state = createPipelineState({
|
|
134
|
+
taskId,
|
|
135
|
+
runId,
|
|
136
|
+
updatedAt: startedAt,
|
|
137
|
+
executorActor: executor.actor,
|
|
138
|
+
reporterActor: reporterCandidates[0]?.actor,
|
|
139
|
+
// plan は root(統合ブランチ)で生成して checkpoint 済みのため、repo 相対パスが
|
|
140
|
+
// worktree 内の相対パスと一致する。result は cwd(in-place は root、worktree 実行は
|
|
141
|
+
// worktree)からの相対で、evidence の artifact_ref と同じ基準に揃える。
|
|
142
|
+
artifacts: {
|
|
143
|
+
plan_ref: relative(repoRoot, params.planPath).split(sep).join("/"),
|
|
144
|
+
result_ref: relative(cwd, resultPath).split(sep).join("/"),
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
state = updatePipelineStage(state, "executor", { status: "running", started_at: startedAt }, startedAt);
|
|
148
|
+
writePipelineState(stateLocation.path, state);
|
|
149
|
+
const env = agentEnvironment(repoRoot, cwd, schedulePath, executionPath, params.productWorktrees);
|
|
150
|
+
const executorPrompt = withProductRepoPrompt(buildExecutorPrompt(planPrompt, execDefaults.pipeline?.parent_validations, {
|
|
151
|
+
mode: params.mode ?? "edit",
|
|
152
|
+
resumed: params.resumedExecutor,
|
|
153
|
+
...(params.resumedExecutor ? { existingChanges: worktreeStatusPaths(cwd) } : {}),
|
|
154
|
+
...(params.resumedExecutor
|
|
155
|
+
? { initialChangeTargets: params.initialChangeTargets ?? [] }
|
|
156
|
+
: {}),
|
|
157
|
+
...(params.resumedExecutor ? { resumeHandoff: params.resumeHandoff ?? [] } : {}),
|
|
158
|
+
}), params.productWorktrees);
|
|
159
|
+
const changesBeforeAttempt = snapshotWorktreeChanges(cwd, params.productWorktrees);
|
|
160
|
+
const runExecutor = () => runWithRetry([executor], executorPrompt, execDefaults, cwd, env, resultPath);
|
|
161
|
+
const outcome = params.providerConcurrencyGate
|
|
162
|
+
? await params.providerConcurrencyGate.run(executor.provider, runExecutor, `${taskId} executor`)
|
|
163
|
+
: await runExecutor();
|
|
164
|
+
const recorded = recordExecutorEvidence({
|
|
165
|
+
repoRoot,
|
|
166
|
+
worktreePath: cwd,
|
|
167
|
+
executionPath,
|
|
168
|
+
taskId,
|
|
169
|
+
runId,
|
|
170
|
+
actor: executor.actor,
|
|
171
|
+
status: outcome.result === "success"
|
|
172
|
+
? "succeeded"
|
|
173
|
+
: outcome.result === "rate_limit"
|
|
174
|
+
? "rate_limited"
|
|
175
|
+
: "failed",
|
|
176
|
+
startedAt,
|
|
177
|
+
completedAt: new Date().toISOString(),
|
|
178
|
+
exitCode: outcome.exitCode,
|
|
179
|
+
attempts: outcome.attempts,
|
|
180
|
+
stdout: outcome.stdout,
|
|
181
|
+
stderr: outcome.stderr,
|
|
182
|
+
changesBeforeAttempt,
|
|
183
|
+
productWorktrees: params.productWorktrees,
|
|
184
|
+
});
|
|
185
|
+
const coverageFailure = outcome.result === "success"
|
|
186
|
+
? resumedTargetCoverageFailure({
|
|
187
|
+
resumed: !!params.resumedExecutor,
|
|
188
|
+
plan: planPrompt,
|
|
189
|
+
evidence: recorded.evidence,
|
|
190
|
+
evidencePath: recorded.evidencePath,
|
|
191
|
+
initialChangeTargets: params.initialChangeTargets,
|
|
192
|
+
})
|
|
193
|
+
: undefined;
|
|
194
|
+
const executorResult = coverageFailure ? "failure" : outcome.result;
|
|
195
|
+
const evidenceRef = relative(cwd, recorded.evidencePath).split(sep).join("/");
|
|
196
|
+
const executorCompletedAt = new Date().toISOString();
|
|
197
|
+
state = updatePipelineStage(state, "executor", {
|
|
198
|
+
status: executorResult === "success"
|
|
199
|
+
? "succeeded"
|
|
200
|
+
: outcome.protectionBlock
|
|
201
|
+
? "blocked"
|
|
202
|
+
: executorResult === "rate_limit"
|
|
203
|
+
? "rate_limited"
|
|
204
|
+
: "failed",
|
|
205
|
+
attempts: outcome.attempts,
|
|
206
|
+
completed_at: executorCompletedAt,
|
|
207
|
+
artifact_ref: evidenceRef,
|
|
208
|
+
}, executorCompletedAt);
|
|
209
|
+
writePipelineState(stateLocation.path, state);
|
|
210
|
+
process.stdout.write(` Executor evidence: ${evidenceRef}\n`);
|
|
211
|
+
if (executorResult !== "success") {
|
|
212
|
+
const blockReason = coverageFailure ??
|
|
213
|
+
(executorResult === "rate_limit"
|
|
214
|
+
? "executor rate limit reached"
|
|
215
|
+
: extractBlockReason(outcome.stderr));
|
|
216
|
+
return {
|
|
217
|
+
exitCode: 1,
|
|
218
|
+
runResult: executorResult,
|
|
219
|
+
blockReason,
|
|
220
|
+
stateRef: stateLocation.ref,
|
|
221
|
+
evidenceRef,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
recorded.evidence = await appendParentValidationsToExecutorEvidence({
|
|
225
|
+
execDefaults,
|
|
226
|
+
cwd,
|
|
227
|
+
productWorktrees: params.productWorktrees,
|
|
228
|
+
evidence: recorded.evidence,
|
|
229
|
+
evidencePath: recorded.evidencePath,
|
|
230
|
+
});
|
|
231
|
+
const reporterOutcome = await runReporterStage({
|
|
232
|
+
repoRoot,
|
|
233
|
+
cwd,
|
|
234
|
+
schedulePath,
|
|
235
|
+
executionPath,
|
|
236
|
+
reporterCandidates,
|
|
237
|
+
planPrompt,
|
|
238
|
+
resultPath,
|
|
239
|
+
registerPaths: params.registerPaths,
|
|
240
|
+
execDefaults,
|
|
241
|
+
evidence: recorded.evidence,
|
|
242
|
+
evidencePath: recorded.evidencePath,
|
|
243
|
+
state,
|
|
244
|
+
statePath: stateLocation.path,
|
|
245
|
+
providerConcurrencyGate: params.providerConcurrencyGate,
|
|
246
|
+
productWorktrees: params.productWorktrees,
|
|
247
|
+
mode: params.mode,
|
|
248
|
+
});
|
|
249
|
+
return {
|
|
250
|
+
exitCode: reporterOutcome.exitCode,
|
|
251
|
+
runResult: reporterOutcome.runResult,
|
|
252
|
+
blockReason: reporterOutcome.blockReason,
|
|
253
|
+
stateRef: stateLocation.ref,
|
|
254
|
+
evidenceRef,
|
|
255
|
+
};
|
|
256
|
+
}
|