@rsaglobaltech/specgate 0.19.1 → 0.21.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 +164 -4
- package/README.md +31 -31
- package/bin/specgate.ts +26 -20
- package/dist/bin/specgate.js +16 -11
- package/dist/bin/specgate.js.map +1 -1
- package/dist/packages/core/src/application/AddRequirementUseCase.js +11 -1
- package/dist/packages/core/src/application/AddRequirementUseCase.js.map +1 -1
- package/dist/packages/core/src/application/ArchiveChangeUseCase.js +7 -2
- package/dist/packages/core/src/application/ArchiveChangeUseCase.js.map +1 -1
- package/dist/packages/core/src/application/ValidateProjectUseCase.js +9 -3
- package/dist/packages/core/src/application/ValidateProjectUseCase.js.map +1 -1
- package/dist/packages/core/src/domain/ArchivePlan.js.map +1 -1
- package/dist/packages/core/src/domain/ChangeTemplates.js +19 -0
- package/dist/packages/core/src/domain/ChangeTemplates.js.map +1 -1
- package/dist/packages/core/src/domain/DeltaSpec.js +14 -7
- package/dist/packages/core/src/domain/DeltaSpec.js.map +1 -1
- package/dist/packages/core/src/domain/DerivedMatrix.js +2 -2
- package/dist/packages/core/src/domain/DerivedMatrix.js.map +1 -1
- package/dist/packages/core/src/domain/Diagnostic.js.map +1 -1
- package/dist/packages/core/src/domain/DoneVerification.js +12 -4
- package/dist/packages/core/src/domain/DoneVerification.js.map +1 -1
- package/dist/packages/core/src/domain/DraftChecklist.js +1 -1
- package/dist/packages/core/src/domain/DraftChecklist.js.map +1 -1
- package/dist/packages/core/src/domain/GherkinQuality.js +5 -2
- package/dist/packages/core/src/domain/GherkinQuality.js.map +1 -1
- package/dist/packages/core/src/domain/HarnessConfig.js +1 -0
- package/dist/packages/core/src/domain/HarnessConfig.js.map +1 -1
- package/dist/packages/core/src/domain/HarnessEvents.js +129 -0
- package/dist/packages/core/src/domain/HarnessEvents.js.map +1 -0
- package/dist/packages/core/src/domain/HarnessRun.js.map +1 -1
- package/dist/packages/core/src/domain/Language.js +5 -2
- package/dist/packages/core/src/domain/Language.js.map +1 -1
- package/dist/packages/core/src/domain/PackContribution.js.map +1 -1
- package/dist/packages/core/src/domain/PackDelta.js +5 -2
- package/dist/packages/core/src/domain/PackDelta.js.map +1 -1
- package/dist/packages/core/src/domain/PackSpec.js +16 -2
- package/dist/packages/core/src/domain/PackSpec.js.map +1 -1
- package/dist/packages/core/src/domain/QuotedText.js +36 -0
- package/dist/packages/core/src/domain/QuotedText.js.map +1 -0
- package/dist/packages/core/src/domain/RequirementPlan.js.map +1 -1
- package/dist/packages/core/src/domain/SpecParser.js +2 -9
- package/dist/packages/core/src/domain/SpecParser.js.map +1 -1
- package/dist/packages/core/src/domain/TraceabilityFormat.js.map +1 -1
- package/dist/packages/core/src/domain/TraceabilityMatrix.js +3 -3
- package/dist/packages/core/src/domain/TraceabilityMatrix.js.map +1 -1
- package/dist/packages/core/src/domain/YamlLite.js +3 -0
- package/dist/packages/core/src/domain/YamlLite.js.map +1 -1
- package/dist/packages/core/src/infrastructure/ChangeWorkspace.js.map +1 -1
- package/dist/packages/core/src/infrastructure/ConsoleReporter.js.map +1 -1
- package/dist/packages/core/src/infrastructure/DiskLanguageRepository.js +1 -0
- package/dist/packages/core/src/infrastructure/DiskLanguageRepository.js.map +1 -1
- package/dist/packages/core/src/infrastructure/DiskPackDeltaRepository.js +3 -1
- package/dist/packages/core/src/infrastructure/DiskPackDeltaRepository.js.map +1 -1
- package/dist/packages/core/src/infrastructure/DiskPackRepository.js +0 -2
- package/dist/packages/core/src/infrastructure/DiskPackRepository.js.map +1 -1
- package/dist/packages/core/src/infrastructure/DiskRequirementGraphRepository.js.map +1 -1
- package/dist/packages/core/src/infrastructure/GitContributionStager.js +0 -4
- package/dist/packages/core/src/infrastructure/GitContributionStager.js.map +1 -1
- package/dist/packages/core/src/infrastructure/GitMergeDriver.js +0 -3
- package/dist/packages/core/src/infrastructure/GitMergeDriver.js.map +1 -1
- package/dist/packages/core/src/infrastructure/HarnessConfigFile.js +16 -13
- package/dist/packages/core/src/infrastructure/HarnessConfigFile.js.map +1 -1
- package/dist/packages/core/src/infrastructure/PackChangeDeposit.js.map +1 -1
- package/dist/packages/core/src/infrastructure/RemotePackResolver.js +0 -7
- package/dist/packages/core/src/infrastructure/RemotePackResolver.js.map +1 -1
- package/dist/packages/core/src/infrastructure/SpecopsConfigFile.js.map +1 -1
- package/dist/packages/core/test/unit/declared-artifacts.test.js +6 -2
- package/dist/packages/core/test/unit/declared-artifacts.test.js.map +1 -1
- package/dist/packages/core/test/unit/derived-matrix.test.js +3 -0
- package/dist/packages/core/test/unit/derived-matrix.test.js.map +1 -1
- package/dist/packages/core/test/unit/done-verification.test.js +3 -0
- package/dist/packages/core/test/unit/done-verification.test.js.map +1 -1
- package/dist/packages/core/test/unit/matrix-dependencies.test.js.map +1 -1
- package/dist/packages/core/test/unit/reconciliation.test.js.map +1 -1
- package/dist/packages/core/test/unit/requirement-readiness.test.js +2 -2
- package/dist/packages/core/test/unit/requirement-readiness.test.js.map +1 -1
- package/dist/packages/core/test/unit/resume-state.test.js +4 -1
- package/dist/packages/core/test/unit/resume-state.test.js.map +1 -1
- package/dist/packages/core/test/unit/run-budget.test.js +3 -0
- package/dist/packages/core/test/unit/run-budget.test.js.map +1 -1
- package/dist/packages/core/test/unit/untouched-delta.test.js +52 -0
- package/dist/packages/core/test/unit/untouched-delta.test.js.map +1 -0
- package/dist/packages/core/test/unit/validate-project.test.js +6 -2
- package/dist/packages/core/test/unit/validate-project.test.js.map +1 -1
- package/dist/packages/mcp-spec-driven/src/server.js +4 -3
- package/dist/packages/mcp-spec-driven/src/server.js.map +1 -1
- package/dist/packages/mcp-spec-driven/src/tools.js.map +1 -1
- package/dist/scripts/add.js +10 -0
- package/dist/scripts/add.js.map +1 -0
- package/dist/scripts/agents/commands.js +49 -37
- package/dist/scripts/agents/commands.js.map +1 -1
- package/dist/scripts/agents/detect.js.map +1 -1
- package/dist/scripts/agents/init.js.map +1 -1
- package/dist/scripts/alm/cli.js +2 -2
- package/dist/scripts/alm/cli.js.map +1 -1
- package/dist/scripts/alm/core.js +1 -0
- package/dist/scripts/alm/core.js.map +1 -1
- package/dist/scripts/apply.js +9 -0
- package/dist/scripts/apply.js.map +1 -0
- package/dist/scripts/archive.js +9 -0
- package/dist/scripts/archive.js.map +1 -0
- package/dist/scripts/change/archive.js.map +1 -1
- package/dist/scripts/change/artifacts.js.map +1 -1
- package/dist/scripts/change/delta.js +0 -8
- package/dist/scripts/change/delta.js.map +1 -1
- package/dist/scripts/change/instructions.js +9 -11
- package/dist/scripts/change/instructions.js.map +1 -1
- package/dist/scripts/cli/commands/alm/PullCommand.js +4 -2
- package/dist/scripts/cli/commands/alm/PullCommand.js.map +1 -1
- package/dist/scripts/cli/commands/change/ChangeCommand.js +91 -17
- package/dist/scripts/cli/commands/change/ChangeCommand.js.map +1 -1
- package/dist/scripts/cli/commands/config/ConfigSetCommand.js +20 -11
- package/dist/scripts/cli/commands/config/ConfigSetCommand.js.map +1 -1
- package/dist/scripts/cli/commands/harness/RunCommand.js +243 -34
- package/dist/scripts/cli/commands/harness/RunCommand.js.map +1 -1
- package/dist/scripts/cli/commands/mcp/McpInstallCommand.js +1 -0
- package/dist/scripts/cli/commands/mcp/McpInstallCommand.js.map +1 -1
- package/dist/scripts/cli/commands/pack/BundlePackCommand.js +2 -1
- package/dist/scripts/cli/commands/pack/BundlePackCommand.js.map +1 -1
- package/dist/scripts/cli/commands/pack/ExpandDomainPackCommand.js +32 -17
- package/dist/scripts/cli/commands/pack/ExpandDomainPackCommand.js.map +1 -1
- package/dist/scripts/cli/commands/pack/InferPackCommand.js +8 -5
- package/dist/scripts/cli/commands/pack/InferPackCommand.js.map +1 -1
- package/dist/scripts/cli/commands/pack/LintPackCommand.js +36 -44
- package/dist/scripts/cli/commands/pack/LintPackCommand.js.map +1 -1
- package/dist/scripts/cli/commands/pack/pack-args.js.map +1 -1
- package/dist/scripts/cli/commands/project/AddCommand.js +75 -0
- package/dist/scripts/cli/commands/project/AddCommand.js.map +1 -0
- package/dist/scripts/cli/commands/project/AdoptCommand.js +4 -2
- package/dist/scripts/cli/commands/project/AdoptCommand.js.map +1 -1
- package/dist/scripts/cli/commands/project/Forja.js +104 -0
- package/dist/scripts/cli/commands/project/Forja.js.map +1 -0
- package/dist/scripts/cli/commands/project/InitFromPackCommand.js.map +1 -1
- package/dist/scripts/cli/commands/project/InitProjectCommand.js +55 -2
- package/dist/scripts/cli/commands/project/InitProjectCommand.js.map +1 -1
- package/dist/scripts/cli/commands/project/OnboardCommand.js +40 -4
- package/dist/scripts/cli/commands/project/OnboardCommand.js.map +1 -1
- package/dist/scripts/cli/commands/project/UpdateCommand.js.map +1 -1
- package/dist/scripts/cli/commands/project/WizardCommand.js.map +1 -1
- package/dist/scripts/cli/commands/quality/CheckCommand.js +96 -17
- package/dist/scripts/cli/commands/quality/CheckCommand.js.map +1 -1
- package/dist/scripts/cli/commands/quality/DoctorCommand.js +8 -4
- package/dist/scripts/cli/commands/quality/DoctorCommand.js.map +1 -1
- package/dist/scripts/cli/commands/quality/FixCommand.js.map +1 -1
- package/dist/scripts/cli/commands/quality/LicenseCheckCommand.js +3 -1
- package/dist/scripts/cli/commands/quality/LicenseCheckCommand.js.map +1 -1
- package/dist/scripts/cli/commands/quality/ReportCommand.js +8 -3
- package/dist/scripts/cli/commands/quality/ReportCommand.js.map +1 -1
- package/dist/scripts/cli/commands/quality/ValidateSpecsCommand.js +39 -30
- package/dist/scripts/cli/commands/quality/ValidateSpecsCommand.js.map +1 -1
- package/dist/scripts/cli/commands/quality/VerifyCommand.js +3 -2
- package/dist/scripts/cli/commands/quality/VerifyCommand.js.map +1 -1
- package/dist/scripts/cli/commands/spec/DoneCommand.js +212 -80
- package/dist/scripts/cli/commands/spec/DoneCommand.js.map +1 -1
- package/dist/scripts/cli/commands/spec/DraftCommand.js +56 -33
- package/dist/scripts/cli/commands/spec/DraftCommand.js.map +1 -1
- package/dist/scripts/cli/commands/spec/ExploreCommand.js +224 -0
- package/dist/scripts/cli/commands/spec/ExploreCommand.js.map +1 -0
- package/dist/scripts/cli/commands/spec/MatrixCommand.js +35 -5
- package/dist/scripts/cli/commands/spec/MatrixCommand.js.map +1 -1
- package/dist/scripts/cli/commands/spec/NewCommand.js +4 -4
- package/dist/scripts/cli/commands/spec/NewCommand.js.map +1 -1
- package/dist/scripts/cli/commands/spec/PetCommand.js.map +1 -1
- package/dist/scripts/cli/commands/spec/PlanCommand.js +8 -3
- package/dist/scripts/cli/commands/spec/PlanCommand.js.map +1 -1
- package/dist/scripts/cli/commands/spec/ReqCommand.js +8 -9
- package/dist/scripts/cli/commands/spec/ReqCommand.js.map +1 -1
- package/dist/scripts/cli/commands/spec/StatusCommand.js +121 -23
- package/dist/scripts/cli/commands/spec/StatusCommand.js.map +1 -1
- package/dist/scripts/cli/commands/spec/StudioCommand.js +76 -4
- package/dist/scripts/cli/commands/spec/StudioCommand.js.map +1 -1
- package/dist/scripts/cli/commands/specops/ContributeCommand.js +6 -2
- package/dist/scripts/cli/commands/specops/ContributeCommand.js.map +1 -1
- package/dist/scripts/cli/commands/specops/DiffCommand.js +19 -5
- package/dist/scripts/cli/commands/specops/DiffCommand.js.map +1 -1
- package/dist/scripts/cli/commands/specops/SyncCommand.js +4 -2
- package/dist/scripts/cli/commands/specops/SyncCommand.js.map +1 -1
- package/dist/scripts/docs/build-site.js +81 -1
- package/dist/scripts/docs/build-site.js.map +1 -1
- package/dist/scripts/docs/components.js +6 -1
- package/dist/scripts/docs/components.js.map +1 -1
- package/dist/scripts/docs/icons.js +0 -6
- package/dist/scripts/docs/icons.js.map +1 -1
- package/dist/scripts/docs/journey-storyboard.js +23 -20
- package/dist/scripts/docs/journey-storyboard.js.map +1 -1
- package/dist/scripts/docs/nav.js +136 -22
- package/dist/scripts/docs/nav.js.map +1 -1
- package/dist/scripts/docs/record-terminal.js +1 -1
- package/dist/scripts/docs/record-terminal.js.map +1 -1
- package/dist/scripts/docs/terminal-storyboard.js +24 -21
- package/dist/scripts/docs/terminal-storyboard.js.map +1 -1
- package/dist/scripts/draft/brief-setup.js +9 -8
- package/dist/scripts/draft/brief-setup.js.map +1 -1
- package/dist/scripts/draft/confined-agent.js +3 -2
- package/dist/scripts/draft/confined-agent.js.map +1 -1
- package/dist/scripts/draft/drafting-guide.js +7 -6
- package/dist/scripts/draft/drafting-guide.js.map +1 -1
- package/dist/scripts/explore.js +10 -0
- package/dist/scripts/explore.js.map +1 -0
- package/dist/scripts/gen_mcp_tools.js +15 -7
- package/dist/scripts/gen_mcp_tools.js.map +1 -1
- package/dist/scripts/harness/events.js +202 -0
- package/dist/scripts/harness/events.js.map +1 -0
- package/dist/scripts/harness/init.js +6 -2
- package/dist/scripts/harness/init.js.map +1 -1
- package/dist/scripts/harness/run.js +2 -1
- package/dist/scripts/harness/run.js.map +1 -1
- package/dist/scripts/lib/agent.js.map +1 -1
- package/dist/scripts/lib/base-ids.js +179 -0
- package/dist/scripts/lib/base-ids.js.map +1 -0
- package/dist/scripts/lib/capability-specs.js.map +1 -1
- package/dist/scripts/lib/diagnostics.js +0 -10
- package/dist/scripts/lib/diagnostics.js.map +1 -1
- package/dist/scripts/lib/harness-events.js +74 -0
- package/dist/scripts/lib/harness-events.js.map +1 -0
- package/dist/scripts/lib/in-flight.js +191 -0
- package/dist/scripts/lib/in-flight.js.map +1 -0
- package/dist/scripts/lib/live-model.js +145 -0
- package/dist/scripts/lib/live-model.js.map +1 -0
- package/dist/scripts/lib/live-page.js +89 -0
- package/dist/scripts/lib/live-page.js.map +1 -0
- package/dist/scripts/lib/monorepo-fanout.js.map +1 -1
- package/dist/scripts/lib/placeholders.js.map +1 -1
- package/dist/scripts/lib/project-root.js.map +1 -1
- package/dist/scripts/lib/run-with-deadline.js +6 -1
- package/dist/scripts/lib/run-with-deadline.js.map +1 -1
- package/dist/scripts/lib/surface.js +109 -24
- package/dist/scripts/lib/surface.js.map +1 -1
- package/dist/scripts/lib/tour.js +149 -0
- package/dist/scripts/lib/tour.js.map +1 -0
- package/dist/scripts/propose.js +21 -0
- package/dist/scripts/propose.js.map +1 -0
- package/dist/scripts/schema/cli.js +1 -1
- package/dist/scripts/schema/cli.js.map +1 -1
- package/dist/scripts/schema/registry.js +1 -0
- package/dist/scripts/schema/registry.js.map +1 -1
- package/dist/scripts/specops/add.js +2 -1
- package/dist/scripts/specops/add.js.map +1 -1
- package/dist/scripts/specops/against_lock.js +22 -25
- package/dist/scripts/specops/against_lock.js.map +1 -1
- package/dist/scripts/specops/as_change.js.map +1 -1
- package/dist/scripts/specops/lock.js +0 -5
- package/dist/scripts/specops/lock.js.map +1 -1
- package/dist/scripts/specops/manifest.js +0 -8
- package/dist/scripts/specops/manifest.js.map +1 -1
- package/dist/scripts/specops/remove.js +2 -1
- package/dist/scripts/specops/remove.js.map +1 -1
- package/dist/scripts/specops/verify.js.map +1 -1
- package/package.json +1 -1
- package/templates/adopt/spec.md.tpl +1 -1
- package/templates/adopt/traceability.md.tpl +1 -1
- package/templates/base/AGENTS.md.tpl +12 -6
- package/templates/harness/prompt-prefix.md.tpl +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigSetCommand.js","sourceRoot":"","sources":["../../../../../scripts/cli/commands/config/ConfigSetCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ConfigSetCommand.js","sourceRoot":"","sources":["../../../../../scripts/cli/commands/config/ConfigSetCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,gCAEC;AAKD,oBAMC;AAED,sBAKC;AAzED,4CAA8B;AAC9B,gDAAkC;AAClC,0DAAiD;AACjD,8CAAuE;AACvE,kDAAmD;AACnD,sGAIwE;AAE3D,QAAA,UAAU,GAAG,WAAW,CAAC;AACzB,QAAA,WAAW,GAAG,aAAa,CAAC;AAE5B,QAAA,IAAI,GAAkE;IACjF,OAAO,EAAE;QACP,MAAM,E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C;QACF,OAAO,CAAC,IAAI,CAAC,YAAI,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;CACF;AArHD,4CAqHC"}
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
* 5. Emit a pass/fail/attempts report.
|
|
20
20
|
*
|
|
21
21
|
* Vendor-neutral by construction: the agent is any shell command. The
|
|
22
|
-
* harness never merges a branch — a human reviews and merges
|
|
22
|
+
* harness never merges a branch — a human reviews and merges — except with
|
|
23
|
+
* `--chain`, which a person asks for and which merges only what passed the
|
|
24
|
+
* gate twice: on its branch and merged (ADR-0036).
|
|
23
25
|
*/
|
|
24
26
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
25
27
|
if (k2 === undefined) k2 = k;
|
|
@@ -75,6 +77,25 @@ const node_child_process_1 = require("node:child_process");
|
|
|
75
77
|
const command_1 = require("../../../lib/command");
|
|
76
78
|
const project_root_1 = require("../../../lib/project-root");
|
|
77
79
|
const prompt_1 = require("../../../harness/prompt");
|
|
80
|
+
const init_1 = require("../../../harness/init");
|
|
81
|
+
const in_flight_1 = require("../../../lib/in-flight");
|
|
82
|
+
const harness_events_1 = require("../../../lib/harness-events");
|
|
83
|
+
const HarnessEvents_1 = require("../../../../packages/core/src/domain/HarnessEvents");
|
|
84
|
+
/**
|
|
85
|
+
* `read` against the project as it will be after its open changes are
|
|
86
|
+
* archived (ADR-0035), so the harness sees, prompts for and gates a change's
|
|
87
|
+
* requirements while they are in flight. The project itself when none is open.
|
|
88
|
+
*/
|
|
89
|
+
function judged(dir, read) {
|
|
90
|
+
const view = (0, in_flight_1.inFlightView)(dir);
|
|
91
|
+
try {
|
|
92
|
+
return read(view ? view.dir : dir, view ? view.toProject : (text) => text);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
if (view)
|
|
96
|
+
view.cleanup();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
78
99
|
const GherkinQuality_1 = require("../../../../packages/core/src/domain/GherkinQuality");
|
|
79
100
|
const HarnessConfigFile_1 = require("../../../../packages/core/src/infrastructure/HarnessConfigFile");
|
|
80
101
|
const agent_1 = require("../../../lib/agent");
|
|
@@ -156,6 +177,15 @@ function usage() {
|
|
|
156
177
|
" --req <REQ-NNN> Limit to specific requirement(s); repeatable.\n" +
|
|
157
178
|
" --project-dir <path> Project root (auto-detected from cwd if omitted).\n" +
|
|
158
179
|
" --base-branch <ref> Branch/ref each worktree is cut from (default: current HEAD).\n" +
|
|
180
|
+
" --setup-cmd <cmd> Run in each new worktree before the agent. Default: the\n" +
|
|
181
|
+
" install the lockfile implies (npm ci, pnpm, yarn);\n" +
|
|
182
|
+
" `none` runs nothing. The agent gets SPECGATE_REQ and\n" +
|
|
183
|
+
" SPECGATE_ATTEMPT in its environment.\n" +
|
|
184
|
+
" --chain One requirement at a time, in order, each cut from the\n" +
|
|
185
|
+
" previous merge: a green one is merged into the branch\n" +
|
|
186
|
+
" you are on (a merge commit, its prompts left on its\n" +
|
|
187
|
+
" branch), the gate runs again on the merge, and a red\n" +
|
|
188
|
+
" result is undone. Stops at the first failure.\n" +
|
|
159
189
|
" --timeout <seconds> Per-agent-invocation timeout (default 1200).\n" +
|
|
160
190
|
" --keep-worktrees Do not remove worktrees after each requirement.\n" +
|
|
161
191
|
" --force Recreate harness/REQ-NNN branches that already exist.\n" +
|
|
@@ -212,6 +242,8 @@ function parseArgs(argv) {
|
|
|
212
242
|
push: false,
|
|
213
243
|
remote: "",
|
|
214
244
|
prCmd: "",
|
|
245
|
+
setupCmd: "",
|
|
246
|
+
chain: false,
|
|
215
247
|
};
|
|
216
248
|
for (let i = 0; i < argv.length; i += 1) {
|
|
217
249
|
const token = argv[i];
|
|
@@ -247,6 +279,12 @@ function parseArgs(argv) {
|
|
|
247
279
|
else if (token === "--base-branch") {
|
|
248
280
|
args.baseBranch = argv[++i] || "";
|
|
249
281
|
}
|
|
282
|
+
else if (token === "--setup-cmd") {
|
|
283
|
+
args.setupCmd = argv[++i] || "";
|
|
284
|
+
}
|
|
285
|
+
else if (token === "--chain") {
|
|
286
|
+
args.chain = true;
|
|
287
|
+
}
|
|
250
288
|
else if (token === "--timeout") {
|
|
251
289
|
const n = Number(argv[++i]);
|
|
252
290
|
if (!Number.isInteger(n) || n < 1)
|
|
@@ -335,9 +373,9 @@ function branchExists(projectDir, branch) {
|
|
|
335
373
|
return r.status === 0 && r.stdout.trim() !== "";
|
|
336
374
|
}
|
|
337
375
|
function runPlan(projectDir) {
|
|
338
|
-
const r = (0, node_child_process_1.spawnSync)(process.execPath, [PLAN_SCRIPT, "--project-dir",
|
|
376
|
+
const r = judged(projectDir, (dir) => (0, node_child_process_1.spawnSync)(process.execPath, [PLAN_SCRIPT, "--project-dir", dir, "--format", "json"], {
|
|
339
377
|
encoding: "utf8",
|
|
340
|
-
});
|
|
378
|
+
}));
|
|
341
379
|
if (r.status !== 0) {
|
|
342
380
|
throw new Error(`plan failed:\n${r.stderr || r.stdout}`);
|
|
343
381
|
}
|
|
@@ -346,6 +384,7 @@ function runPlan(projectDir) {
|
|
|
346
384
|
parsed = JSON.parse(r.stdout);
|
|
347
385
|
}
|
|
348
386
|
catch (err) {
|
|
387
|
+
// `JSON.parse` only ever throws a SyntaxError.
|
|
349
388
|
throw new Error(`plan produced invalid JSON: ${err.message}`);
|
|
350
389
|
}
|
|
351
390
|
return parsed;
|
|
@@ -388,21 +427,26 @@ function readGateMessages(worktreeDir, reportPath) {
|
|
|
388
427
|
const run = (0, CucumberMessages_1.parseCucumberMessages)(raw);
|
|
389
428
|
return run.parsed ? run : null;
|
|
390
429
|
}
|
|
391
|
-
function runGate(worktreeDir, testCmd, timeoutMs, req = {}, settings = {}) {
|
|
430
|
+
function runGate(worktreeDir, testCmd, timeoutMs, req = {}, settings = {}, report = () => { }) {
|
|
392
431
|
// `--delivering`: the requirement is still Draft while its gate runs, and a
|
|
393
432
|
// Draft row owes no files. Without it the gate would skip the one
|
|
394
433
|
// requirement this attempt exists to deliver.
|
|
395
434
|
// The agent's tests are new evidence for a generated matrix: refresh it so
|
|
396
435
|
// the gate judges the attempt, not the matrix as it was before it.
|
|
397
436
|
(0, MatrixCommand_1.refreshDerivedMatrix)(worktreeDir);
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
437
|
+
const validate = judged(worktreeDir, (dir, toProject) => {
|
|
438
|
+
const validateArgs = [VALIDATE_SCRIPT, dir, "--strict"];
|
|
439
|
+
if (req.requirement)
|
|
440
|
+
validateArgs.push("--delivering", req.requirement);
|
|
441
|
+
const run = (0, node_child_process_1.spawnSync)(process.execPath, validateArgs, {
|
|
442
|
+
encoding: "utf8",
|
|
443
|
+
timeout: timeoutMs,
|
|
444
|
+
maxBuffer: SUBPROCESS_MAX_BUFFER,
|
|
445
|
+
});
|
|
446
|
+
// The agent is told about its worktree, not about the copy it was judged in.
|
|
447
|
+
return { ...run, stdout: toProject(run.stdout || ""), stderr: toProject(run.stderr || "") };
|
|
405
448
|
});
|
|
449
|
+
report("validate --strict", validate.status === 0 ? "pass" : "fail");
|
|
406
450
|
if (validate.status !== 0) {
|
|
407
451
|
return {
|
|
408
452
|
ok: false,
|
|
@@ -411,6 +455,28 @@ function runGate(worktreeDir, testCmd, timeoutMs, req = {}, settings = {}) {
|
|
|
411
455
|
hint: "",
|
|
412
456
|
};
|
|
413
457
|
}
|
|
458
|
+
// ADR-0028: the architecture check runs between validation and the tests,
|
|
459
|
+
// and its failure goes back to the agent like any other gate failure.
|
|
460
|
+
const archCmd = String(settings.archCmd || "").trim();
|
|
461
|
+
if (archCmd) {
|
|
462
|
+
const arch = (0, node_child_process_1.spawnSync)(archCmd, {
|
|
463
|
+
shell: true,
|
|
464
|
+
cwd: worktreeDir,
|
|
465
|
+
encoding: "utf8",
|
|
466
|
+
timeout: timeoutMs,
|
|
467
|
+
maxBuffer: SUBPROCESS_MAX_BUFFER,
|
|
468
|
+
});
|
|
469
|
+
report(`architecture check: ${archCmd}`, arch.status === 0 ? "pass" : "fail");
|
|
470
|
+
if (arch.status !== 0) {
|
|
471
|
+
return {
|
|
472
|
+
ok: false,
|
|
473
|
+
stage: `architecture check: ${archCmd}`,
|
|
474
|
+
output: (arch.stdout || "") + (arch.stderr || ""),
|
|
475
|
+
hint: "The code is in a place the architecture does not allow. Move it to the layer the " +
|
|
476
|
+
"rule names; do not change the rule.",
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
}
|
|
414
480
|
if (testCmd) {
|
|
415
481
|
let resolved = (0, HarnessRun_1.substituteGateCommand)(testCmd, req);
|
|
416
482
|
// Where the message stream will be, if there is one to have.
|
|
@@ -442,6 +508,7 @@ function runGate(worktreeDir, testCmd, timeoutMs, req = {}, settings = {}) {
|
|
|
442
508
|
maxBuffer: SUBPROCESS_MAX_BUFFER,
|
|
443
509
|
stdio: settings.verbose ? ["ignore", 2, 2] : undefined,
|
|
444
510
|
});
|
|
511
|
+
report(`test command: ${(0, HarnessEvents_1.maskCommand)(resolved)}`, test.status === 0 ? "pass" : "fail", (0, HarnessEvents_1.testCounts)(`${test.stdout || ""}${test.stderr || ""}`));
|
|
445
512
|
if (test.status !== 0) {
|
|
446
513
|
// Name the command. A gate that silently does the wrong thing — running
|
|
447
514
|
// the whole suite because a filter did not apply, say — produces a
|
|
@@ -711,7 +778,7 @@ function checkWriteScopeInWorktree(worktreeDir, settings) {
|
|
|
711
778
|
`makes a passing gate meaningless. Revert them and satisfy the scenario as written.\n` +
|
|
712
779
|
(evidence ? `\nWhat was changed:\n\n\`\`\`diff\n${evidence}\n\`\`\`\n` : "") +
|
|
713
780
|
`\nIf the change is genuinely required, it belongs in a spec change ` +
|
|
714
|
-
`(\`specgate
|
|
781
|
+
`(\`specgate propose\`), reviewed by a person — not in this attempt.`,
|
|
715
782
|
};
|
|
716
783
|
}
|
|
717
784
|
/**
|
|
@@ -744,12 +811,14 @@ function checkGateCommandInWorktree(worktreeDir, baseRef, testCmd) {
|
|
|
744
811
|
const result = (0, GateCommandIntegrity_1.gateCommandIntegrity)(testCmd, before, after);
|
|
745
812
|
if (!result.checked || !result.changed)
|
|
746
813
|
return null;
|
|
814
|
+
// A checked result always names its script: the probe above resolved it.
|
|
815
|
+
const changed = result.script;
|
|
747
816
|
return {
|
|
748
817
|
manifest,
|
|
749
|
-
script:
|
|
818
|
+
script: changed.script,
|
|
750
819
|
message: `agent_rewrote_gate_command — the gate runs \`${testCmd}\`, and this attempt ` +
|
|
751
820
|
`changed what that means.\n\n` +
|
|
752
|
-
` ${manifest} → scripts.${
|
|
821
|
+
` ${manifest} → scripts.${changed.script}\n` +
|
|
753
822
|
` before: ${result.before === null ? "(absent)" : result.before}\n` +
|
|
754
823
|
` after: ${result.after === null ? "(absent)" : result.after}\n\n` +
|
|
755
824
|
`The command the gate runs is part of the contract this requirement is ` +
|
|
@@ -821,13 +890,23 @@ function attemptRequirement(req, ctx) {
|
|
|
821
890
|
const firstAttempt = Math.max(1, (ctx.resumeAt && ctx.resumeAt.attempt) || 1);
|
|
822
891
|
/** Set when another attempt cannot change the outcome (#50). */
|
|
823
892
|
let stopRetrying = false;
|
|
893
|
+
// The live view's file (ADR-0037), in the project, not the worktree.
|
|
894
|
+
const eventsFile = (0, harness_events_1.eventsFileFor)(ctx.projectDir || worktreeDir, req.requirement);
|
|
824
895
|
for (let attempt = firstAttempt; attempt <= settings.maxAttempts; attempt += 1) {
|
|
825
896
|
info(`${req.requirement}: attempt ${attempt}/${settings.maxAttempts}`);
|
|
826
897
|
const attemptStart = Date.now();
|
|
898
|
+
const event = (e) => (0, harness_events_1.appendEvent)(eventsFile, e, req.requirement, attempt);
|
|
899
|
+
event({ type: "attempt", state: "start" });
|
|
827
900
|
let agentMs = 0;
|
|
828
901
|
/** Which roles ran this attempt, in order — the run record's answer to "who did this". */
|
|
829
902
|
const profilesUsed = [];
|
|
830
903
|
const record = (stage) => {
|
|
904
|
+
event({
|
|
905
|
+
type: "attempt",
|
|
906
|
+
state: "end",
|
|
907
|
+
result: stage === "pass" ? "pass" : "fail",
|
|
908
|
+
...(stage === "pass" ? {} : { stage }),
|
|
909
|
+
});
|
|
831
910
|
attemptLog.push({
|
|
832
911
|
attempt,
|
|
833
912
|
endedAt: stage,
|
|
@@ -850,7 +929,7 @@ function attemptRequirement(req, ctx) {
|
|
|
850
929
|
// implementing step that follows must see what it said. Building once
|
|
851
930
|
// up front meant findings only ever reached the *next* attempt, which
|
|
852
931
|
// is not what a reviewer is for.
|
|
853
|
-
const prompt = (0, prompt_1.buildPrompt)(req,
|
|
932
|
+
const prompt = judged(worktreeDir, (dir) => (0, prompt_1.buildPrompt)(req, dir, {
|
|
854
933
|
promptPrefix: settings.promptPrefix,
|
|
855
934
|
hint,
|
|
856
935
|
previousFailure: previousFailure || undefined,
|
|
@@ -861,7 +940,7 @@ function attemptRequirement(req, ctx) {
|
|
|
861
940
|
// commit — the precedent must be work already accepted, not a
|
|
862
941
|
// sibling requirement this same run happens to be writing.
|
|
863
942
|
withPrecedents: settings.promptPrecedents === true,
|
|
864
|
-
});
|
|
943
|
+
}));
|
|
865
944
|
const promptFile = path.join(os.tmpdir(), `specgate-harness-prompt-${req.requirement}-${crypto.randomBytes(4).toString("hex")}.md`);
|
|
866
945
|
fs.writeFileSync(promptFile, prompt, "utf8");
|
|
867
946
|
archivePrompt(worktreeDir, req.requirement, attempt, step, prompt);
|
|
@@ -882,6 +961,15 @@ function attemptRequirement(req, ctx) {
|
|
|
882
961
|
cwd: worktreeDir,
|
|
883
962
|
timeoutMs,
|
|
884
963
|
maxBuffer: SUBPROCESS_MAX_BUFFER,
|
|
964
|
+
// Which requirement and attempt this is, for agents and the wrappers
|
|
965
|
+
// around them (ADR-0036).
|
|
966
|
+
env: {
|
|
967
|
+
SPECGATE_REQ: req.requirement,
|
|
968
|
+
SPECGATE_ATTEMPT: String(attempt),
|
|
969
|
+
[HarnessEvents_1.EVENTS_FILE_VAR]: eventsFile,
|
|
970
|
+
[HarnessEvents_1.EVENTS_REQ_VAR]: req.requirement,
|
|
971
|
+
[HarnessEvents_1.EVENTS_ATTEMPT_VAR]: String(attempt),
|
|
972
|
+
},
|
|
885
973
|
});
|
|
886
974
|
// Node reports a timeout as an errno-carrying Error; the base `Error`
|
|
887
975
|
// type the spawnSync signature declares does not have `code`.
|
|
@@ -976,10 +1064,7 @@ function attemptRequirement(req, ctx) {
|
|
|
976
1064
|
}
|
|
977
1065
|
// `verbose` is a run flag, not a project setting, so it travels on the
|
|
978
1066
|
// context rather than in `harness.config.yaml`.
|
|
979
|
-
const gate = runGate(worktreeDir, settings.testCmd, timeoutMs, req, {
|
|
980
|
-
...settings,
|
|
981
|
-
verbose: ctx.verbose,
|
|
982
|
-
});
|
|
1067
|
+
const gate = runGate(worktreeDir, settings.testCmd, timeoutMs, req, { ...settings, verbose: ctx.verbose }, (stage, result, extra) => event({ type: "gate", stage, result, ...(extra || {}) }));
|
|
983
1068
|
if (!gate.ok) {
|
|
984
1069
|
previousFailure =
|
|
985
1070
|
`Gate failed at: ${gate.stage}\n\n` + (gate.hint ? `⚠ ${gate.hint}\n\n` : "") + gate.output;
|
|
@@ -1239,7 +1324,7 @@ function resolveGeneratedConflicts(worktree) {
|
|
|
1239
1324
|
* @param passed REQ → branch, for the dependencies that passed in this run
|
|
1240
1325
|
*/
|
|
1241
1326
|
function deriveBase(projectDir, reqId, deps, passed, ctx) {
|
|
1242
|
-
const branches = deps.map((d) => passed.get(d)).filter(Boolean);
|
|
1327
|
+
const branches = deps.map((d) => passed.get(d)).filter((b) => Boolean(b));
|
|
1243
1328
|
if (branches.length === 0)
|
|
1244
1329
|
return { base: ctx.baseRef };
|
|
1245
1330
|
if (branches.length === 1)
|
|
@@ -1361,7 +1446,7 @@ function preserveFailedAttempt(worktreeDir, req, failure) {
|
|
|
1361
1446
|
`wip(${req.requirement}): FAILED the gate — do not merge as is\n\n` +
|
|
1362
1447
|
`${firstLine}\n\n` +
|
|
1363
1448
|
"Committed by `specgate harness run` so the attempt is reviewable rather than\n" +
|
|
1364
|
-
"discarded. The requirement is still Draft: `specgate
|
|
1449
|
+
"discarded. The requirement is still Draft: `specgate apply` never ran.",
|
|
1365
1450
|
]);
|
|
1366
1451
|
return commit.status === 0;
|
|
1367
1452
|
}
|
|
@@ -1790,6 +1875,7 @@ function printReport(results, format, recorded) {
|
|
|
1790
1875
|
process.stdout.write(` ${ui.muted(`Run recorded in ${recorded} — specgate harness report sums them up`)}\n`);
|
|
1791
1876
|
}
|
|
1792
1877
|
if (pass > 0) {
|
|
1878
|
+
// `pass > 0`, so there is one.
|
|
1793
1879
|
const first = results.find((r) => r.result === "pass");
|
|
1794
1880
|
process.stdout.write(ui.next(`git diff HEAD...${first.branch}`, "review and merge the harness/* branches you trust"));
|
|
1795
1881
|
}
|
|
@@ -1811,7 +1897,7 @@ function printReport(results, format, recorded) {
|
|
|
1811
1897
|
* scoped to one requirement, so a parallel run and a serial run execute the
|
|
1812
1898
|
* same code.
|
|
1813
1899
|
*/
|
|
1814
|
-
async
|
|
1900
|
+
const dispatchLevel = async (runnable, byId, hintByReq, ctx, concurrency) => {
|
|
1815
1901
|
if (concurrency <= 1) {
|
|
1816
1902
|
const results = [];
|
|
1817
1903
|
for (const id of runnable) {
|
|
@@ -1823,6 +1909,7 @@ async function dispatchLevel(runnable, byId, hintByReq, ctx, concurrency) {
|
|
|
1823
1909
|
results.push(notAttempted(byId.get(id), id, ctx.stopReason()));
|
|
1824
1910
|
continue;
|
|
1825
1911
|
}
|
|
1912
|
+
// Every id in a level comes from the queue `byId` was built from.
|
|
1826
1913
|
results.push(processRequirement(byId.get(id), {
|
|
1827
1914
|
...ctx,
|
|
1828
1915
|
baseRef: ctx.baseFor ? ctx.baseFor(id) : ctx.baseRef,
|
|
@@ -1832,6 +1919,99 @@ async function dispatchLevel(runnable, byId, hintByReq, ctx, concurrency) {
|
|
|
1832
1919
|
return results;
|
|
1833
1920
|
}
|
|
1834
1921
|
return runWorkers(runnable, byId, ctx, concurrency);
|
|
1922
|
+
};
|
|
1923
|
+
/**
|
|
1924
|
+
* `--chain` (ADR-0036): the one place the harness merges, and only on request.
|
|
1925
|
+
*
|
|
1926
|
+
* Each requirement is cut from the head the previous merge produced, so it
|
|
1927
|
+
* builds on everything before it. A green one is merged into the branch the
|
|
1928
|
+
* run started on with a merge commit — one revertible commit per requirement,
|
|
1929
|
+
* its prompt archive left on its own branch — and the gate runs again on the
|
|
1930
|
+
* merged result: green alone is not green together. A red result is undone,
|
|
1931
|
+
* and the chain stops at the first requirement that does not pass.
|
|
1932
|
+
*/
|
|
1933
|
+
async function runChain(pending, ctx, hintByReq) {
|
|
1934
|
+
const projectDir = ctx.projectDir;
|
|
1935
|
+
const results = [];
|
|
1936
|
+
for (let i = 0; i < pending.length; i += 1) {
|
|
1937
|
+
const req = pending[i];
|
|
1938
|
+
const stop = (reason) => {
|
|
1939
|
+
for (const rest of pending.slice(i + 1)) {
|
|
1940
|
+
results.push(notAttempted(rest, rest.requirement, reason));
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1943
|
+
const [result] = await runLevels([req], ctx, {
|
|
1944
|
+
concurrency: 1,
|
|
1945
|
+
hintByReq,
|
|
1946
|
+
runOne: dispatchLevel,
|
|
1947
|
+
});
|
|
1948
|
+
results.push(result);
|
|
1949
|
+
if (!result || result.result !== "pass") {
|
|
1950
|
+
stop(`the chain stopped at ${req.requirement}`);
|
|
1951
|
+
break;
|
|
1952
|
+
}
|
|
1953
|
+
const branch = `harness/${req.requirement}`;
|
|
1954
|
+
const merge = git(projectDir, ["merge", "--no-ff", "--no-commit", branch]);
|
|
1955
|
+
if (merge.status !== 0) {
|
|
1956
|
+
const unresolved = resolveGeneratedConflicts(projectDir);
|
|
1957
|
+
if (unresolved.length > 0) {
|
|
1958
|
+
git(projectDir, ["merge", "--abort"]);
|
|
1959
|
+
Object.assign(result, {
|
|
1960
|
+
result: "fail",
|
|
1961
|
+
error: `merge into the chain's branch conflicted in: ${unresolved.join(", ")}`,
|
|
1962
|
+
});
|
|
1963
|
+
stop(`the chain stopped at ${req.requirement}`);
|
|
1964
|
+
break;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
// The prompts stay on the requirement's branch, for review and --resume;
|
|
1968
|
+
// they never reach the branch the chain merges into.
|
|
1969
|
+
const prompts = git(projectDir, [
|
|
1970
|
+
"diff",
|
|
1971
|
+
"--cached",
|
|
1972
|
+
"--name-only",
|
|
1973
|
+
"--diff-filter=A",
|
|
1974
|
+
"HEAD",
|
|
1975
|
+
"--",
|
|
1976
|
+
EmptyAttempt_1.PROMPT_ARCHIVE_DIR,
|
|
1977
|
+
])
|
|
1978
|
+
.stdout.split("\n")
|
|
1979
|
+
.filter(Boolean);
|
|
1980
|
+
if (prompts.length > 0) {
|
|
1981
|
+
git(projectDir, ["rm", "-q", "--cached", "--", ...prompts]);
|
|
1982
|
+
for (const f of prompts)
|
|
1983
|
+
fs.rmSync(path.join(projectDir, f), { force: true });
|
|
1984
|
+
}
|
|
1985
|
+
const title = String(req.title || req.use_case || req.useCase || "").replace(/^UC-\d+\s*/, "");
|
|
1986
|
+
git(projectDir, [
|
|
1987
|
+
"commit",
|
|
1988
|
+
"-q",
|
|
1989
|
+
"-m",
|
|
1990
|
+
`Merge ${branch}${title ? ` — ${title}` : ""}\n\n` +
|
|
1991
|
+
`Merged by \`specgate harness run --chain\` after its gate passed on ${branch}.`,
|
|
1992
|
+
]);
|
|
1993
|
+
const eventsFile = (0, harness_events_1.eventsFileFor)(projectDir, req.requirement);
|
|
1994
|
+
const attempt = Number(result.attempts) || undefined;
|
|
1995
|
+
(0, harness_events_1.appendEvent)(eventsFile, { type: "merge", into: "HEAD", branch }, req.requirement, attempt);
|
|
1996
|
+
const gate = runGate(projectDir, ctx.settings.testCmd, ctx.timeoutMs, req, ctx.settings, (stage, res, extra) => (0, harness_events_1.appendEvent)(eventsFile, { type: "gate", stage: `post-merge ${stage}`, result: res, ...(extra || {}) }, req.requirement, attempt));
|
|
1997
|
+
if (!gate.ok) {
|
|
1998
|
+
git(projectDir, ["reset", "-q", "--hard", "HEAD~1"]);
|
|
1999
|
+
Object.assign(result, {
|
|
2000
|
+
result: "fail",
|
|
2001
|
+
error: `post-merge gate: ${gate.stage}\n${String(gate.output || "").slice(-4000)}`,
|
|
2002
|
+
});
|
|
2003
|
+
warn(`${req.requirement}: green on ${branch}, red once merged — the merge was undone`);
|
|
2004
|
+
stop(`the chain stopped at ${req.requirement}`);
|
|
2005
|
+
break;
|
|
2006
|
+
}
|
|
2007
|
+
// The gate may regenerate the matrix: it belongs to the merge commit.
|
|
2008
|
+
if (!isGitClean(projectDir)) {
|
|
2009
|
+
git(projectDir, ["add", "-A"]);
|
|
2010
|
+
git(projectDir, ["commit", "-q", "--amend", "--no-edit"]);
|
|
2011
|
+
}
|
|
2012
|
+
info(`${req.requirement}: merged into the chain's branch, gate green`);
|
|
2013
|
+
}
|
|
2014
|
+
return results;
|
|
1835
2015
|
}
|
|
1836
2016
|
/** A requirement the budget never let start. Not a failure — it was not tried. */
|
|
1837
2017
|
function notAttempted(req, id, reason) {
|
|
@@ -1921,6 +2101,8 @@ function workerArgs(id, ctx) {
|
|
|
1921
2101
|
String(ctx.timeoutSeconds),
|
|
1922
2102
|
"--max-attempts",
|
|
1923
2103
|
String(ctx.settings.maxAttempts),
|
|
2104
|
+
"--setup-cmd",
|
|
2105
|
+
ctx.settings.setupCmd || "none",
|
|
1924
2106
|
...(ctx.force ? ["--force"] : []),
|
|
1925
2107
|
...(ctx.keepWorktrees ? ["--keep-worktrees"] : []),
|
|
1926
2108
|
...(ctx.settings.agent ? ["--agent", ctx.settings.agent] : []),
|
|
@@ -1979,8 +2161,14 @@ async function runLevels(pending, ctx, opts) {
|
|
|
1979
2161
|
};
|
|
1980
2162
|
const budgetStartedAt = Date.now();
|
|
1981
2163
|
let started = 0;
|
|
2164
|
+
// Asserted rather than annotated: it is assigned inside `mayStart`, and an
|
|
2165
|
+
// annotated `null` would stay narrowed to `null` everywhere below.
|
|
1982
2166
|
let stoppedBy = null;
|
|
1983
|
-
const
|
|
2167
|
+
const schedule = (0, HarnessRun_1.scheduleLevels)(pending);
|
|
2168
|
+
const { levels, cycles, graph } = schedule;
|
|
2169
|
+
// REQ → the requirements in this run it waits for. Core builds it as a plain
|
|
2170
|
+
// object and does not declare its shape.
|
|
2171
|
+
const dependsOn = schedule.dependsOn;
|
|
1984
2172
|
const byId = new Map(pending.map((r) => [r.requirement, r]));
|
|
1985
2173
|
if (cycles.length > 0) {
|
|
1986
2174
|
// `validate` is the gate that reports the cycle properly. Here we only
|
|
@@ -2015,7 +2203,7 @@ async function runLevels(pending, ctx, opts) {
|
|
|
2015
2203
|
const derivationFailures = new Map();
|
|
2016
2204
|
const baseFor = (id) => {
|
|
2017
2205
|
const derived = deriveBase(ctx.projectDir, id, dependsOn[id] || [], passedBranches, ctx);
|
|
2018
|
-
if (derived
|
|
2206
|
+
if ("error" in derived) {
|
|
2019
2207
|
derivationFailures.set(id, derived.error);
|
|
2020
2208
|
return ctx.baseRef;
|
|
2021
2209
|
}
|
|
@@ -2047,6 +2235,7 @@ async function runLevels(pending, ctx, opts) {
|
|
|
2047
2235
|
// that, and again with `--budget-seconds`.
|
|
2048
2236
|
const levelResults = await runOne(attemptable, byId, hintByReq, {
|
|
2049
2237
|
...ctx,
|
|
2238
|
+
// Only `attemptable` ids reach the runner, and each has a base.
|
|
2050
2239
|
baseFor: (id) => bases.get(id),
|
|
2051
2240
|
// The level asks before starting each requirement. `started` counts
|
|
2052
2241
|
// what was actually begun, so the count ceiling and the clock agree.
|
|
@@ -2114,6 +2303,12 @@ class RunCommand extends command_1.BaseCommand {
|
|
|
2114
2303
|
const projectDir = (0, project_root_1.resolveProjectDir)(args.projectDir, { requireSentinel: true });
|
|
2115
2304
|
const fileConfig = (0, HarnessConfigFile_1.readHarnessConfig)(projectDir);
|
|
2116
2305
|
const settings = (0, HarnessConfigFile_1.resolveHarnessSettings)(fileConfig, args);
|
|
2306
|
+
// A fresh worktree has no dependencies. Unless told, install what the
|
|
2307
|
+
// lockfile pins (ADR-0036); `--setup-cmd none` runs nothing.
|
|
2308
|
+
if (settings.setupCmd === "none")
|
|
2309
|
+
settings.setupCmd = "";
|
|
2310
|
+
else if (!settings.setupCmd)
|
|
2311
|
+
settings.setupCmd = (0, init_1.detectSetupCommand)(projectDir);
|
|
2117
2312
|
// D1: profile match rules live in `.harness/profiles.yaml`, and a project
|
|
2118
2313
|
// may declare profiles without ever writing a `harness.config.yaml`.
|
|
2119
2314
|
// Reaching them through the config reader made them silently absent
|
|
@@ -2167,13 +2362,15 @@ class RunCommand extends command_1.BaseCommand {
|
|
|
2167
2362
|
}
|
|
2168
2363
|
const hintByReq = new Map((plan.next_steps || []).map((s) => [s.requirement, s.hint]));
|
|
2169
2364
|
if (args.dryRun) {
|
|
2170
|
-
process.stdout.write(ui.header("harness run", `dry run · ${pending.length} requirement(s) would be processed`)
|
|
2365
|
+
process.stdout.write(ui.header("harness run", `dry run · ${pending.length} requirement(s) would be processed`) +
|
|
2366
|
+
ui.kv("Setup", settings.setupCmd || "none", 14) +
|
|
2367
|
+
(args.chain ? ui.kv("Chain", "each green requirement merged into this branch", 14) : ""));
|
|
2171
2368
|
for (const req of pending) {
|
|
2172
|
-
const prompt = (0, prompt_1.buildPrompt)(req,
|
|
2369
|
+
const prompt = judged(projectDir, (dir) => (0, prompt_1.buildPrompt)(req, dir, {
|
|
2173
2370
|
promptPrefix: settings.promptPrefix,
|
|
2174
2371
|
hint: hintByReq.get(req.requirement),
|
|
2175
2372
|
withPrecedents: settings.promptPrecedents === true,
|
|
2176
|
-
});
|
|
2373
|
+
}));
|
|
2177
2374
|
process.stdout.write("\n" +
|
|
2178
2375
|
ui.section(`${req.requirement} · ${req.category} → branch harness/${req.requirement}`) +
|
|
2179
2376
|
"\n");
|
|
@@ -2193,6 +2390,15 @@ class RunCommand extends command_1.BaseCommand {
|
|
|
2193
2390
|
const identity = gitIdentityProblem(projectDir);
|
|
2194
2391
|
if (identity)
|
|
2195
2392
|
throw new Error(identity);
|
|
2393
|
+
if (args.chain) {
|
|
2394
|
+
if (args.baseBranch) {
|
|
2395
|
+
throw new Error("--chain merges into the branch you are on: check that branch out instead of --base-branch.");
|
|
2396
|
+
}
|
|
2397
|
+
const current = git(projectDir, ["rev-parse", "--abbrev-ref", "HEAD"]).stdout.trim();
|
|
2398
|
+
if (!current || current === "HEAD") {
|
|
2399
|
+
throw new Error("--chain needs a branch to merge into; HEAD is detached.");
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2196
2402
|
const baseRef = args.baseBranch || "HEAD";
|
|
2197
2403
|
const concurrencyNote = settings.concurrency > 1 ? `, up to ${settings.concurrency} at a time` : "";
|
|
2198
2404
|
if (jsonMode || process.env.SPECGATE_HARNESS_WORKER) {
|
|
@@ -2224,11 +2430,13 @@ class RunCommand extends command_1.BaseCommand {
|
|
|
2224
2430
|
verbose: args.verbose,
|
|
2225
2431
|
};
|
|
2226
2432
|
const startedAt = new Date().toISOString();
|
|
2227
|
-
const results =
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2433
|
+
const results = args.chain
|
|
2434
|
+
? await runChain(pending, ctx, hintByReq)
|
|
2435
|
+
: await runLevels(pending, ctx, {
|
|
2436
|
+
concurrency: settings.concurrency,
|
|
2437
|
+
hintByReq,
|
|
2438
|
+
runOne: dispatchLevel,
|
|
2439
|
+
});
|
|
2232
2440
|
// Only the run that a person started writes a record. A worker is one
|
|
2233
2441
|
// slice of that run, and its own record would be a second copy of the
|
|
2234
2442
|
// same requirement — `harness report` reads every file in the directory,
|
|
@@ -2258,6 +2466,7 @@ class RunCommand extends command_1.BaseCommand {
|
|
|
2258
2466
|
process.exit(failed > 0 ? 1 : 0);
|
|
2259
2467
|
}
|
|
2260
2468
|
catch (err) {
|
|
2469
|
+
const thrown = err;
|
|
2261
2470
|
let isJson = false;
|
|
2262
2471
|
try {
|
|
2263
2472
|
isJson = parseArgs(this.args).format === "json";
|
|
@@ -2267,7 +2476,7 @@ class RunCommand extends command_1.BaseCommand {
|
|
|
2267
2476
|
}
|
|
2268
2477
|
const io = (0, agent_1.agentIo)(isJson);
|
|
2269
2478
|
return io.fail({ results: null }, [
|
|
2270
|
-
{ severity: "error", code: "harness_run_error", message:
|
|
2479
|
+
{ severity: "error", code: "harness_run_error", message: thrown.message || String(err) },
|
|
2271
2480
|
]);
|
|
2272
2481
|
}
|
|
2273
2482
|
}
|