@bridge_gpt/mcp-server 0.2.41 → 0.2.42
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/README.md +10 -10
- package/build/agent-capabilities/cli.js +2 -1
- package/build/agent-launchers/claude-executor-adapter.js +17 -4
- package/build/claude-user-config-doctor.js +42 -11
- package/build/cli-release.js +2 -1
- package/build/commands.generated.js +4 -4
- package/build/conduct-epic/bridge-client.js +354 -113
- package/build/conduct-epic/checkpoint-store.js +17 -0
- package/build/conduct-epic/cli.js +752 -99
- package/build/conduct-epic/cut-protocol.js +327 -0
- package/build/conduct-epic/spawn.js +14 -2
- package/build/conductor/bridge-api-client.js +27 -1
- package/build/conductor/cli.js +46 -1
- package/build/conductor/doctor.js +101 -16
- package/build/conductor/epic-reconcile.js +72 -19
- package/build/conductor/epic-runtime.js +15 -3
- package/build/conductor/errors.js +47 -0
- package/build/conductor/git-hooks.js +205 -11
- package/build/conductor/install-doctor.js +230 -1
- package/build/conductor/local-merge.js +130 -28
- package/build/conductor/tools.js +32 -3
- package/build/conductor/worker-ledger-cli.js +27 -1
- package/build/conductor-bin.js +15 -15
- package/build/credentials-cli.js +3 -2
- package/build/doctor.js +107 -41
- package/build/executor/cli.js +48 -1
- package/build/executor/env.js +21 -0
- package/build/executor/index-scope.js +39 -0
- package/build/executor/job-log-registry.js +69 -0
- package/build/executor/job-runner.js +148 -26
- package/build/executor/live-worker-registry.js +83 -0
- package/build/executor/observation.js +167 -6
- package/build/executor/platform.js +147 -3
- package/build/executor/process.js +58 -14
- package/build/executor/runner.js +235 -48
- package/build/executor/test-clock.js +3 -2
- package/build/index-scope-contract.js +96 -0
- package/build/index.js +153 -204
- package/build/init.js +83 -22
- package/build/install-bridge-conductor.js +323 -14
- package/build/install-bridge.js +202 -38
- package/build/install-doctor.js +23 -9
- package/build/install-reexec.js +2 -1
- package/build/launcher-config-inspection.js +83 -22
- package/build/mcp-host-config.js +331 -67
- package/build/mcp-host-targets.js +45 -21
- package/build/mcp-identity.js +92 -0
- package/build/mcp-install-state.js +94 -1
- package/build/mcp-invoke.js +2 -1
- package/build/mcp-provisioning.js +45 -12
- package/build/mcp-registration-doctor.js +35 -13
- package/build/mcp-server-invocation.js +4 -2
- package/build/merge-pull-request.js +208 -9
- package/build/pipelines.generated.js +3 -3
- package/build/plane/defaults.js +4 -1
- package/build/plane/preflight.js +81 -10
- package/build/plane/test-fakes.js +9 -1
- package/build/readme.generated.js +1 -1
- package/build/regression-check.js +3 -2
- package/build/review-tickets.js +8 -7
- package/build/run-unit-tests-launcher.js +74 -1
- package/build/schedule-run.js +3 -2
- package/build/setup-epic.js +453 -78
- package/build/sfcc/tool-wrapper.js +15 -0
- package/build/start-tickets-prereqs.js +11 -6
- package/build/start-tickets.js +91 -85
- package/build/update-check.js +3 -2
- package/build/upgrade-advice.js +2 -1
- package/build/upgrade-cli.js +50 -18
- package/build/version.generated.js +1 -1
- package/docs/CONDUCTOR.md +22 -0
- package/docs/install/mcp-tool-integrations.md +19 -3
- package/package.json +2 -2
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared EXACT-CUT protocol and scope-readiness poll (BAPI-843; BAPI-850).
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `conduct-epic init` so that the LLM-conductor pilot and the v2
|
|
5
|
+
* `setup-epic --feature-branch` entry point drive ONE implementation of the
|
|
6
|
+
* local cut — the same local `git` fetch, the same remote-ref existence check,
|
|
7
|
+
* the same exact-SHA push, and the same mismatch classification. This module is
|
|
8
|
+
* the single owner of those operations; neither CLI re-implements any of them.
|
|
9
|
+
*
|
|
10
|
+
* What the cut is: the server leases a hold on the canonical parse lock and
|
|
11
|
+
* names the commit the canonical index actually covers (`cut/begin`); this
|
|
12
|
+
* module creates `origin/<feature>` at EXACTLY that commit with the operator's
|
|
13
|
+
* own `git` — never the GitHub App, which is `contents: read` and cannot create
|
|
14
|
+
* refs — reads the ref back, and asks the server to record it as the scope's
|
|
15
|
+
* immutable cut (`cut/commit`). The hold is released on every outcome.
|
|
16
|
+
*
|
|
17
|
+
* Contract properties, fixed here and relied on by both CLIs:
|
|
18
|
+
*
|
|
19
|
+
* - **Never force-updates an existing branch.** The push refspec has no leading
|
|
20
|
+
* `+`, so it can only create. A branch that already exists at any commit other
|
|
21
|
+
* than the held cut commit is a refusal, never a repoint.
|
|
22
|
+
* - **Takes an already validated branch and SHA.** Callers validate the branch
|
|
23
|
+
* name (`validateBranchName`) and normalize the candidate SHA before calling;
|
|
24
|
+
* this module re-proves the SHA shape it pushes, but it is not a parser.
|
|
25
|
+
* - **No credential ever reaches argv.** The only subprocess is `git`, and its
|
|
26
|
+
* arguments are refs, remotes, and SHAs. Bridge and GitHub credentials travel
|
|
27
|
+
* only inside the typed client's headers.
|
|
28
|
+
* - **Every failure is classified, never thrown.** Callers get a discriminated
|
|
29
|
+
* outcome with operator-ready sentences and the bounded facts (expected and
|
|
30
|
+
* observed SHAs) they need to report; there is nothing to `try/catch`.
|
|
31
|
+
*/
|
|
32
|
+
import { execFile } from "node:child_process";
|
|
33
|
+
import { abandonIndexScopeCut, beginIndexScopeCut, commitIndexScopeCut, getIndexScopeStatus, } from "./bridge-client.js";
|
|
34
|
+
/**
|
|
35
|
+
* Poll bound for a scope bootstrap, shared by `conduct-epic init` and
|
|
36
|
+
* `setup-epic`. A seed copies a repository's whole parse cache and the
|
|
37
|
+
* verifying parse then downloads and change-detects it, so the ceiling is
|
|
38
|
+
* generous; the interval is what keeps the poll cheap.
|
|
39
|
+
*/
|
|
40
|
+
export const SCOPE_BOOTSTRAP_POLL_INTERVAL_MS = 5_000;
|
|
41
|
+
export const SCOPE_BOOTSTRAP_MAX_POLLS = 240; // ~20 minutes at the interval above.
|
|
42
|
+
/**
|
|
43
|
+
* Build the default list-argument subprocess runner both CLIs use for `git`.
|
|
44
|
+
*
|
|
45
|
+
* One body rather than two copies: `execFile` with `shell: false`, a generous
|
|
46
|
+
* buffer for porcelain output, and an exit code that never throws — a missing
|
|
47
|
+
* binary resolves to a non-zero code the caller classifies.
|
|
48
|
+
*/
|
|
49
|
+
export function createExecFileRunCommand() {
|
|
50
|
+
return (file, args, options) => new Promise((resolve) => {
|
|
51
|
+
execFile(file, args, {
|
|
52
|
+
cwd: options?.cwd,
|
|
53
|
+
// Git porcelain output for a many-worktree checkout can be large.
|
|
54
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
55
|
+
encoding: "utf-8",
|
|
56
|
+
timeout: options?.timeoutMs,
|
|
57
|
+
// Explicit: arguments are a list, never a concatenated shell string.
|
|
58
|
+
shell: false,
|
|
59
|
+
}, (error, stdout, stderr) => {
|
|
60
|
+
const code = error?.code;
|
|
61
|
+
resolve({
|
|
62
|
+
stdout: stdout ?? "",
|
|
63
|
+
stderr: stderr ?? "",
|
|
64
|
+
exitCode: typeof code === "number" ? code : error ? 1 : 0,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** Run `git` in the operator's checkout. */
|
|
70
|
+
export function runGit(deps, args) {
|
|
71
|
+
return Promise.resolve(deps.runCommand("git", args, { cwd: deps.cwd }));
|
|
72
|
+
}
|
|
73
|
+
/** The single trimmed line a `git rev-parse`-style command produced, or null. */
|
|
74
|
+
export function firstOutputLine(result) {
|
|
75
|
+
const value = result.stdout.split("\n")[0]?.trim() ?? "";
|
|
76
|
+
return value.length === 0 ? null : value;
|
|
77
|
+
}
|
|
78
|
+
/** The SHA from `git ls-remote --heads origin <ref>` output, or null. */
|
|
79
|
+
export function lsRemoteSha(result) {
|
|
80
|
+
const line = firstOutputLine(result);
|
|
81
|
+
if (line === null)
|
|
82
|
+
return null;
|
|
83
|
+
const sha = line.split(/\s+/)[0]?.trim() ?? "";
|
|
84
|
+
return sha.length === 0 ? null : sha;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Normalize a commit SHA to its canonical 40-character lowercase form, or `null`.
|
|
88
|
+
*
|
|
89
|
+
* Mirrors the server's own guard so a malformed value is refused HERE — before it
|
|
90
|
+
* becomes a `git push` refspec — rather than becoming an opaque git error or, far
|
|
91
|
+
* worse, a ref pushed at something that is not a commit.
|
|
92
|
+
*/
|
|
93
|
+
export function normalizeCommitSha(value) {
|
|
94
|
+
if (typeof value !== "string")
|
|
95
|
+
return null;
|
|
96
|
+
const normalized = value.trim().toLowerCase();
|
|
97
|
+
return /^[0-9a-f]{40}$/.test(normalized) ? normalized : null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Read the head of `origin/<branch>` WITHOUT mutating anything.
|
|
101
|
+
*
|
|
102
|
+
* `sha: null` means the branch does not exist on origin. A failed `ls-remote`
|
|
103
|
+
* (no remote, no network, no git) is its own outcome, never "absent": treating an
|
|
104
|
+
* unanswered read as absence is how a push lands on top of a branch nobody saw.
|
|
105
|
+
*/
|
|
106
|
+
export async function readRemoteBranchHead(deps, branch) {
|
|
107
|
+
const result = await runGit(deps, ["ls-remote", "--heads", "origin", `refs/heads/${branch}`]);
|
|
108
|
+
if (result.exitCode !== 0) {
|
|
109
|
+
return { ok: false, error: `git ls-remote could not read origin/${branch}.` };
|
|
110
|
+
}
|
|
111
|
+
return { ok: true, sha: lsRemoteSha(result) };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Make sure the exact cut object is resolvable locally, fetching it if needed.
|
|
115
|
+
*
|
|
116
|
+
* The cut is pushed BY SHA, so the object must exist in the operator's
|
|
117
|
+
* repository. A base-branch fetch usually brings it along; when it did not — the
|
|
118
|
+
* index covers a commit that is no longer an ancestor of the base tip — one
|
|
119
|
+
* targeted, NON-MUTATING fetch of that SHA is attempted (it updates no ref,
|
|
120
|
+
* creates no branch, and checks nothing out). Returns `true` when the commit
|
|
121
|
+
* resolves.
|
|
122
|
+
*/
|
|
123
|
+
export async function ensureCommitResolvableLocally(deps, commitSha) {
|
|
124
|
+
const present = await runGit(deps, ["rev-parse", "--verify", "--quiet", `${commitSha}^{commit}`]);
|
|
125
|
+
if (present.exitCode === 0)
|
|
126
|
+
return true;
|
|
127
|
+
await runGit(deps, ["fetch", "origin", commitSha]);
|
|
128
|
+
const retry = await runGit(deps, ["rev-parse", "--verify", "--quiet", `${commitSha}^{commit}`]);
|
|
129
|
+
return retry.exitCode === 0;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Drive the exact cut: `cut/begin` → re-check the remote ref under the hold →
|
|
133
|
+
* create the ref at the held commit (if absent) → read it back → `cut/commit`,
|
|
134
|
+
* releasing the hold on EVERY outcome.
|
|
135
|
+
*
|
|
136
|
+
* Everything between `begin` and the release happens while the SERVER holds the
|
|
137
|
+
* canonical repository's parse lock, so the commit the index covers cannot move
|
|
138
|
+
* underneath the ref this module creates.
|
|
139
|
+
*/
|
|
140
|
+
export async function performExactIndexScopeCut(deps, access, request) {
|
|
141
|
+
const { featureBranch, baseBranch, candidateCommitSha } = request;
|
|
142
|
+
const lease = await beginIndexScopeCut(access, {
|
|
143
|
+
featureBranch,
|
|
144
|
+
baseBranch,
|
|
145
|
+
candidateCommitSha,
|
|
146
|
+
epicRunId: request.epicRunId ?? null,
|
|
147
|
+
}, deps.fetchImpl);
|
|
148
|
+
if (!lease.ok) {
|
|
149
|
+
return {
|
|
150
|
+
ok: false,
|
|
151
|
+
kind: "begin_refused",
|
|
152
|
+
failures: [`The index-scope cut could not begin: ${lease.error}`],
|
|
153
|
+
lease: null,
|
|
154
|
+
expectedSha: candidateCommitSha,
|
|
155
|
+
observedSha: null,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const cut = lease.value;
|
|
159
|
+
try {
|
|
160
|
+
if (cut.cut_commit_sha !== candidateCommitSha) {
|
|
161
|
+
// The server re-read the canonical snapshot under its own hold and named a
|
|
162
|
+
// different commit. Nothing has been pushed yet, so refusing costs nothing
|
|
163
|
+
// and continuing would cut the epic at a commit the preflight never checked.
|
|
164
|
+
return {
|
|
165
|
+
ok: false,
|
|
166
|
+
kind: "canonical_moved",
|
|
167
|
+
failures: [
|
|
168
|
+
`The canonical index moved while init was preparing ` +
|
|
169
|
+
`(preflight saw ${candidateCommitSha}, the cut hold names ${cut.cut_commit_sha}). Re-run init.`,
|
|
170
|
+
],
|
|
171
|
+
lease: cut,
|
|
172
|
+
expectedSha: candidateCommitSha,
|
|
173
|
+
observedSha: cut.cut_commit_sha,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// Re-check `origin/<feature>` WHILE the hold is active. A preflight
|
|
177
|
+
// observation is evidence for a refusal, never for a mutation: another
|
|
178
|
+
// operator may have created the ref in between.
|
|
179
|
+
const held = await readRemoteBranchHead(deps, featureBranch);
|
|
180
|
+
if (!held.ok) {
|
|
181
|
+
return {
|
|
182
|
+
ok: false,
|
|
183
|
+
kind: "ls_remote_failed",
|
|
184
|
+
failures: [held.error],
|
|
185
|
+
lease: cut,
|
|
186
|
+
expectedSha: cut.cut_commit_sha,
|
|
187
|
+
observedSha: null,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const heldSha = held.sha;
|
|
191
|
+
if (heldSha !== null && heldSha !== cut.cut_commit_sha) {
|
|
192
|
+
return {
|
|
193
|
+
ok: false,
|
|
194
|
+
kind: "existing_ref_mismatch",
|
|
195
|
+
failures: [
|
|
196
|
+
`origin/${featureBranch} exists at ${heldSha}, which is not the canonical indexed ` +
|
|
197
|
+
`commit ${cut.cut_commit_sha}. Delete it or finish the previous run first.`,
|
|
198
|
+
],
|
|
199
|
+
lease: cut,
|
|
200
|
+
expectedSha: cut.cut_commit_sha,
|
|
201
|
+
observedSha: heldSha,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
let branchCreated = false;
|
|
205
|
+
if (heldSha === null) {
|
|
206
|
+
// Create the ref from the EXACT commit, with the operator's own git. No
|
|
207
|
+
// local checkout, no branch, no worktree — and deliberately not the GitHub
|
|
208
|
+
// App, which is `contents: read` and cannot create refs. Not a force push:
|
|
209
|
+
// the refspec has no leading `+`, so it can only create.
|
|
210
|
+
const pushed = await runGit(deps, [
|
|
211
|
+
"push",
|
|
212
|
+
"origin",
|
|
213
|
+
`${cut.cut_commit_sha}:refs/heads/${featureBranch}`,
|
|
214
|
+
]);
|
|
215
|
+
if (pushed.exitCode !== 0) {
|
|
216
|
+
return {
|
|
217
|
+
ok: false,
|
|
218
|
+
kind: "push_failed",
|
|
219
|
+
failures: [
|
|
220
|
+
`Could not create origin/${featureBranch} at the canonical indexed commit ${cut.cut_commit_sha}.`,
|
|
221
|
+
],
|
|
222
|
+
lease: cut,
|
|
223
|
+
expectedSha: cut.cut_commit_sha,
|
|
224
|
+
observedSha: null,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
branchCreated = true;
|
|
228
|
+
}
|
|
229
|
+
// Read the ref BACK from origin. What matters is what the remote now holds,
|
|
230
|
+
// not what this process intended to push.
|
|
231
|
+
const confirmed = await readRemoteBranchHead(deps, featureBranch);
|
|
232
|
+
const confirmedSha = confirmed.ok ? confirmed.sha : null;
|
|
233
|
+
if (confirmedSha !== cut.cut_commit_sha) {
|
|
234
|
+
return {
|
|
235
|
+
ok: false,
|
|
236
|
+
kind: "confirm_failed",
|
|
237
|
+
failures: [`origin/${featureBranch} did not resolve to ${cut.cut_commit_sha} after the push.`],
|
|
238
|
+
lease: cut,
|
|
239
|
+
expectedSha: cut.cut_commit_sha,
|
|
240
|
+
observedSha: confirmedSha,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
const committed = await commitIndexScopeCut(access, { scopeId: cut.scope_id, cutHoldId: cut.cut_hold_id, epicRefCommitSha: confirmedSha }, deps.fetchImpl);
|
|
244
|
+
if (!committed.ok) {
|
|
245
|
+
return {
|
|
246
|
+
ok: false,
|
|
247
|
+
kind: "commit_refused",
|
|
248
|
+
failures: [`The index-scope cut could not be recorded: ${committed.error}`],
|
|
249
|
+
lease: cut,
|
|
250
|
+
expectedSha: cut.cut_commit_sha,
|
|
251
|
+
observedSha: confirmedSha,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
return { ok: true, lease: cut, branchCreated, outcome: committed.value.outcome };
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
// The hold is released on EVERY pre-seed outcome, including the success path
|
|
258
|
+
// (where the server already released it — abandon is idempotent). The seed
|
|
259
|
+
// acquires this same canonical lock itself and it is not reentrant, so
|
|
260
|
+
// handing off while still holding it would deadlock the epic against its own
|
|
261
|
+
// seed. A failed release never masks the primary failure: it is reported and
|
|
262
|
+
// the original outcome stands.
|
|
263
|
+
const abandoned = await abandonIndexScopeCut(access, { scopeId: cut.scope_id, cutHoldId: cut.cut_hold_id }, deps.fetchImpl);
|
|
264
|
+
if (!abandoned.ok) {
|
|
265
|
+
deps.errorLog(`announced: the cut hold could not be released cleanly: ${abandoned.error}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
// Scope-readiness poll (BAPI-843; shared with `setup-epic` by BAPI-850)
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
/** The operator-facing label for each lifecycle state the poll reports. */
|
|
273
|
+
export const SCOPE_LIFECYCLE_LABELS = Object.freeze({
|
|
274
|
+
provisioning: "Provisioning",
|
|
275
|
+
seeding: "Seeding",
|
|
276
|
+
verifying: "Verifying",
|
|
277
|
+
ready: "Ready",
|
|
278
|
+
failed: "Failed",
|
|
279
|
+
});
|
|
280
|
+
/**
|
|
281
|
+
* Poll a scope's lifecycle until it is `ready`, `failed`, or the bounded wait
|
|
282
|
+
* elapses, reporting each NEWLY observed lifecycle transition exactly once, in
|
|
283
|
+
* order, through `onTransition`.
|
|
284
|
+
*
|
|
285
|
+
* Readiness is a server-side fact this poll observes rather than concludes from
|
|
286
|
+
* any request of its own: `ready` is accepted ONLY when the status also proves
|
|
287
|
+
* `indexed_commit_sha == cut_commit_sha`. A `ready` whose watermark disagrees is
|
|
288
|
+
* reported as `ready_mismatch` — the control plane contradicting itself, which
|
|
289
|
+
* is worth refusing rather than proceeding on.
|
|
290
|
+
*
|
|
291
|
+
* A transient read failure is not a verdict: the poll keeps going and lets the
|
|
292
|
+
* bound be the thing that gives up. The interval and cap are the shared
|
|
293
|
+
* {@link SCOPE_BOOTSTRAP_POLL_INTERVAL_MS} / {@link SCOPE_BOOTSTRAP_MAX_POLLS}.
|
|
294
|
+
*/
|
|
295
|
+
export async function pollIndexScopeLifecycle(deps, access, scopeId, options = {}) {
|
|
296
|
+
const sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
297
|
+
const maxPolls = options.maxPolls ?? SCOPE_BOOTSTRAP_MAX_POLLS;
|
|
298
|
+
const intervalMs = options.intervalMs ?? SCOPE_BOOTSTRAP_POLL_INTERVAL_MS;
|
|
299
|
+
let lastState = "unknown";
|
|
300
|
+
let lastStatus = null;
|
|
301
|
+
let lastReportedState = null;
|
|
302
|
+
for (let poll = 0; poll < maxPolls; poll += 1) {
|
|
303
|
+
await sleep(intervalMs);
|
|
304
|
+
const status = await getIndexScopeStatus(access, scopeId, deps.fetchImpl);
|
|
305
|
+
if (!status.ok) {
|
|
306
|
+
lastState = `unreadable (${status.error})`;
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
lastStatus = status.value;
|
|
310
|
+
lastState = status.value.lifecycle_state;
|
|
311
|
+
if (lastState !== lastReportedState) {
|
|
312
|
+
lastReportedState = lastState;
|
|
313
|
+
options.onTransition?.(lastState, status.value);
|
|
314
|
+
}
|
|
315
|
+
if (lastState === "ready") {
|
|
316
|
+
if (status.value.indexed_commit_sha !== null &&
|
|
317
|
+
status.value.indexed_commit_sha === status.value.cut_commit_sha) {
|
|
318
|
+
return { kind: "ready", status: status.value };
|
|
319
|
+
}
|
|
320
|
+
return { kind: "ready_mismatch", status: status.value };
|
|
321
|
+
}
|
|
322
|
+
if (lastState === "failed") {
|
|
323
|
+
return { kind: "failed", status: status.value, reason: status.value.last_error ?? "unknown" };
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return { kind: "timeout", lastState, lastStatus };
|
|
327
|
+
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* argv would be visible to every process on the machine via `ps`.
|
|
22
22
|
*/
|
|
23
23
|
import { powershellSquote, shSquoteInner, } from "../start-tickets.js";
|
|
24
|
+
import { INDEX_SCOPE_ENV_VAR } from "../index-scope-contract.js";
|
|
24
25
|
/** The agents `conduct-epic spawn` may launch. */
|
|
25
26
|
export const CONDUCT_EPIC_AGENTS = ["claude", "cursor-agent"];
|
|
26
27
|
/** The repository's established default agent. */
|
|
@@ -52,6 +53,11 @@ export function resolveConductEpicAgent(agent) {
|
|
|
52
53
|
* Returns the command as a string rather than an argv array because that is what
|
|
53
54
|
* every terminal spawner in this repository consumes — a tab is opened by handing
|
|
54
55
|
* a shell a command line, not by `exec`ing a process.
|
|
56
|
+
*
|
|
57
|
+
* BAPI-844: a validated `indexScope` is prefixed as an environment assignment
|
|
58
|
+
* using the SAME quoting helpers as the rest of the command — the shell's own
|
|
59
|
+
* environment mechanism, not an argument the agent can see. An absent scope emits
|
|
60
|
+
* no prefix, so the unscoped command is unchanged byte-for-byte.
|
|
55
61
|
*/
|
|
56
62
|
export function buildConductEpicAgentCommand(input) {
|
|
57
63
|
const resolved = resolveConductEpicAgent(input.agent);
|
|
@@ -61,15 +67,21 @@ export function buildConductEpicAgentCommand(input) {
|
|
|
61
67
|
return { ok: false, error: "A worktree path is required to build the agent command." };
|
|
62
68
|
}
|
|
63
69
|
if (input.platform === "win32") {
|
|
70
|
+
const scopePrefix = input.indexScope
|
|
71
|
+
? `$env:${INDEX_SCOPE_ENV_VAR} = ${powershellSquote(input.indexScope)}; `
|
|
72
|
+
: "";
|
|
64
73
|
return {
|
|
65
74
|
ok: true,
|
|
66
|
-
command:
|
|
75
|
+
command: `${scopePrefix}Set-Location -LiteralPath ${powershellSquote(input.worktreePath)}; ` +
|
|
67
76
|
`${resolved.agent} ${powershellSquote(input.prompt)}`,
|
|
68
77
|
};
|
|
69
78
|
}
|
|
79
|
+
const scopePrefix = input.indexScope
|
|
80
|
+
? `export ${INDEX_SCOPE_ENV_VAR}='${shSquoteInner(input.indexScope)}' && `
|
|
81
|
+
: "";
|
|
70
82
|
return {
|
|
71
83
|
ok: true,
|
|
72
|
-
command:
|
|
84
|
+
command: `${scopePrefix}cd '${shSquoteInner(input.worktreePath)}' && ` +
|
|
73
85
|
`${resolved.agent} '${shSquoteInner(input.prompt)}'`,
|
|
74
86
|
};
|
|
75
87
|
}
|
|
@@ -1078,6 +1078,13 @@ function parseShadowDispatchFreshnessResult(parsed) {
|
|
|
1078
1078
|
indexedCommitSha: typeof obj.indexed_commit_sha === "string" ? obj.indexed_commit_sha : null,
|
|
1079
1079
|
shadowRepoName: typeof obj.shadow_repo_name === "string" ? obj.shadow_repo_name : null,
|
|
1080
1080
|
lastError: typeof obj.last_error === "string" ? obj.last_error : null,
|
|
1081
|
+
// Fail closed: only an explicit `true` expires a deadline. An older backend
|
|
1082
|
+
// that does not send the field at all keeps the previous behavior (hold
|
|
1083
|
+
// forever on this side, bounded by the Python reconciler's own park).
|
|
1084
|
+
deadlineExpired: obj.deadline_expired === true,
|
|
1085
|
+
blockedAdvanceReason: typeof obj.blocked_advance_reason === "string" && obj.blocked_advance_reason.length > 0
|
|
1086
|
+
? obj.blocked_advance_reason
|
|
1087
|
+
: null,
|
|
1081
1088
|
};
|
|
1082
1089
|
}
|
|
1083
1090
|
/**
|
|
@@ -1176,7 +1183,26 @@ function parseValidateEpicPlanResult(parsed) {
|
|
|
1176
1183
|
insertedEdges < 0) {
|
|
1177
1184
|
throw new ConductorBridgeApiError("server");
|
|
1178
1185
|
}
|
|
1179
|
-
|
|
1186
|
+
// BAPI-848 — the coverage diagnostics are read TOLERANTLY, unlike the fields
|
|
1187
|
+
// above. A server that predates them is not a protocol error, and the CLI must
|
|
1188
|
+
// keep working against one; the defaults below are the honest reading of an
|
|
1189
|
+
// absent field (nothing reported), and the renderer states the scope it was
|
|
1190
|
+
// actually given rather than inventing coverage it cannot see.
|
|
1191
|
+
return {
|
|
1192
|
+
planHash,
|
|
1193
|
+
serializationEnabled,
|
|
1194
|
+
insertedEdges,
|
|
1195
|
+
overlappingPairsFound: safeCount(p["overlapping_pairs_found"]),
|
|
1196
|
+
undeclaredNodes: safeCount(p["undeclared_nodes"]),
|
|
1197
|
+
undeclaredPairsSkipped: safeCount(p["undeclared_pairs_skipped"]),
|
|
1198
|
+
coverageScope: typeof p["coverage_scope"] === "string" && p["coverage_scope"].trim() !== ""
|
|
1199
|
+
? p["coverage_scope"]
|
|
1200
|
+
: "unreported",
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
/** Non-negative safe integer, or 0 for anything else (absent field included). */
|
|
1204
|
+
function safeCount(value) {
|
|
1205
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : 0;
|
|
1180
1206
|
}
|
|
1181
1207
|
/**
|
|
1182
1208
|
* POST the immutable plan blob to the durable-store endpoint. The blob is
|
package/build/conductor/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ import { ConductorValidationError, ConductorEpicTickV1FrozenError, toConductorEr
|
|
|
18
18
|
import { emitConductorEvent, purgeConductorLedger, sendWorkerMessage, checkWorkerMessages, } from "./store.js";
|
|
19
19
|
import { isDuplicateConstraintError } from "./producer-ledger.js";
|
|
20
20
|
import { SEMANTIC_EVENT_TYPES } from "./taxonomy.js";
|
|
21
|
-
import { installConductorGitHooks } from "./git-hooks.js";
|
|
21
|
+
import { installConductorGitHooks, resolveConductorHookBin } from "./git-hooks.js";
|
|
22
22
|
import { runFileScopeGuardCli } from "./file-scope-guard.js";
|
|
23
23
|
import { runPostCommitHookProducer, runReferenceTransactionHookProducer } from "./git-producer.js";
|
|
24
24
|
import { buildConductorDoctorReport, formatConductorDoctorReport } from "./doctor.js";
|
|
@@ -159,6 +159,14 @@ export function getConductorUsage() {
|
|
|
159
159
|
" conductor epic-status --epic-key EPIC-405 --json",
|
|
160
160
|
].join("\n");
|
|
161
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Private diagnostic action (BAPI-772): prints the `conductor-bin.js` path the
|
|
164
|
+
* EXECUTING artifact resolves for hook installation. It exists so a test can run
|
|
165
|
+
* `node build/conductor-bin.js __hook-bin` against the real esbuild bundle and
|
|
166
|
+
* assert the printed path exists — a tsc-emit unit test structurally cannot catch
|
|
167
|
+
* the bundled-layout bug this ticket fixes. Mirrors `plane __entrypoint`.
|
|
168
|
+
*/
|
|
169
|
+
export const CONDUCTOR_HOOK_BIN_ACTION = "__hook-bin";
|
|
162
170
|
const VALID_COMMANDS = new Set([
|
|
163
171
|
"emit-event",
|
|
164
172
|
"supervise",
|
|
@@ -172,6 +180,10 @@ const VALID_COMMANDS = new Set([
|
|
|
172
180
|
"install-git-hooks",
|
|
173
181
|
"git-hook",
|
|
174
182
|
"file-scope-guard",
|
|
183
|
+
// Private, and deliberately ABSENT from the usage text: `__hook-bin` exists as
|
|
184
|
+
// the bundled-artifact regression guard for BAPI-772 (mirroring `plane
|
|
185
|
+
// __entrypoint`), not as a supported operator workflow.
|
|
186
|
+
CONDUCTOR_HOOK_BIN_ACTION,
|
|
175
187
|
]);
|
|
176
188
|
/**
|
|
177
189
|
* Parse the top-level conductor argv into a subcommand (without a CLI
|
|
@@ -583,6 +595,11 @@ export async function runDoctorCommand(argv, deps = {}) {
|
|
|
583
595
|
* Run `install-git-hooks`: install/update the local managed `post-commit` and
|
|
584
596
|
* `reference-transaction` hooks. Returns 0 even when the directory is not a git
|
|
585
597
|
* worktree (degraded optional capability) — never a fatal failure.
|
|
598
|
+
*
|
|
599
|
+
* BAPI-772: an unresolvable `conductor-bin.js` IS fatal (exit 1). Writing a hook
|
|
600
|
+
* that points at a nonexistent binary produced a hook that silently did nothing
|
|
601
|
+
* on every commit, so the installer now refuses and this command reports the
|
|
602
|
+
* refusal with the resolver's searched-layout remediation.
|
|
586
603
|
*/
|
|
587
604
|
export function runInstallGitHooksCommand(argv) {
|
|
588
605
|
const { bools } = tokenizeFlags(argv, new Set(), DIAGNOSTIC_BOOL_FLAGS);
|
|
@@ -591,6 +608,14 @@ export function runInstallGitHooksCommand(argv) {
|
|
|
591
608
|
return 0;
|
|
592
609
|
}
|
|
593
610
|
const result = installConductorGitHooks();
|
|
611
|
+
if (!result.ok) {
|
|
612
|
+
if (bools.has("--json")) {
|
|
613
|
+
console.error(JSON.stringify({ error: result.error, reason: result.reason }));
|
|
614
|
+
return 1;
|
|
615
|
+
}
|
|
616
|
+
console.error(`Error: conductor git hooks were NOT installed (${result.error}): ${result.reason}`);
|
|
617
|
+
return 1;
|
|
618
|
+
}
|
|
594
619
|
if (bools.has("--json")) {
|
|
595
620
|
console.log(JSON.stringify(result));
|
|
596
621
|
return 0;
|
|
@@ -600,6 +625,7 @@ export function runInstallGitHooksCommand(argv) {
|
|
|
600
625
|
"───────────────────────────",
|
|
601
626
|
`is git worktree: ${result.is_worktree}`,
|
|
602
627
|
`hooks dir: ${result.hooks_dir ?? "n/a"}`,
|
|
628
|
+
`conductor bin: ${result.conductor_bin}`,
|
|
603
629
|
];
|
|
604
630
|
for (const hook of result.installed) {
|
|
605
631
|
lines.push(` ${hook.name}: ${hook.action}${hook.warning ? ` (${hook.warning})` : ""}`);
|
|
@@ -612,6 +638,21 @@ export function runInstallGitHooksCommand(argv) {
|
|
|
612
638
|
console.log(lines.join("\n"));
|
|
613
639
|
return 0;
|
|
614
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* Run the private `__hook-bin` diagnostic: resolve the hook binary from the
|
|
643
|
+
* executing artifact and print ONLY that canonical path to stdout, so artifact-
|
|
644
|
+
* level automation can consume it directly. A failed resolution prints the
|
|
645
|
+
* sanitized resolver reason to stderr and returns 1 — never a stack trace.
|
|
646
|
+
*/
|
|
647
|
+
export function runHookBinDiagnosticCommand() {
|
|
648
|
+
const resolution = resolveConductorHookBin();
|
|
649
|
+
if (!resolution.ok) {
|
|
650
|
+
console.error(`conductor hook bin UNRESOLVED: ${resolution.reason}`);
|
|
651
|
+
return 1;
|
|
652
|
+
}
|
|
653
|
+
console.log(resolution.path);
|
|
654
|
+
return 0;
|
|
655
|
+
}
|
|
615
656
|
const GIT_HOOK_VALUE_FLAGS = new Set(["--phase", "--stdin-file"]);
|
|
616
657
|
const GIT_HOOK_BOOL_FLAGS = new Set(["--help"]);
|
|
617
658
|
/**
|
|
@@ -1104,6 +1145,10 @@ export async function runConductorCli(argv) {
|
|
|
1104
1145
|
return runInstallGitHooksCommand(parsed.argv);
|
|
1105
1146
|
case "git-hook":
|
|
1106
1147
|
return await runGitHookCommand(parsed.argv);
|
|
1148
|
+
case CONDUCTOR_HOOK_BIN_ACTION:
|
|
1149
|
+
// Dispatched before any MCP server construction or store access: the
|
|
1150
|
+
// guard must be able to run against a bundle whose ledger is absent.
|
|
1151
|
+
return runHookBinDiagnosticCommand();
|
|
1107
1152
|
case "file-scope-guard":
|
|
1108
1153
|
// BAPI-507 (N-2): warn-only worker file-scope guard. Always exits 0.
|
|
1109
1154
|
return runFileScopeGuardCli();
|