@bridge_gpt/mcp-server 0.2.70 → 0.2.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +55 -17
  2. package/build/agent-launchers/claude-executor-adapter.js +29 -4
  3. package/build/agent-notes.js +171 -95
  4. package/build/agent-registry.js +5 -5
  5. package/build/agents.generated.js +12 -2
  6. package/build/bounded-wait.js +9 -1
  7. package/build/bridge-permissions.js +17 -5
  8. package/build/bridge-worktree-inspection.js +237 -0
  9. package/build/check-evidence.js +6 -0
  10. package/build/claude-review-workflow.js +1 -1
  11. package/build/cli-help.js +6 -0
  12. package/build/codex-auto-recovery.js +126 -0
  13. package/build/codex-skill-adapter.js +2 -0
  14. package/build/commands.generated.js +5 -5
  15. package/build/conductor/bridge-api-client.js +776 -23
  16. package/build/conductor/command-drift-production.js +7 -2
  17. package/build/conductor/doctor.js +93 -13
  18. package/build/conductor/epic-implementer-cli.js +55 -2
  19. package/build/conductor/gate-discovery.js +659 -19
  20. package/build/conductor/gate-settings-review.js +751 -0
  21. package/build/conductor/git-hooks-uninstall.js +112 -0
  22. package/build/conductor/git-hooks.js +81 -15
  23. package/build/conductor/guided-repair.js +10 -1
  24. package/build/conductor/install-doctor.js +2 -4
  25. package/build/conductor/launch-need-probes.js +16 -11
  26. package/build/conductor/launch-plan.js +185 -0
  27. package/build/conductor/local-merge.js +12 -1
  28. package/build/conductor/merge-execution-contract.js +1 -1
  29. package/build/conductor/merged-child-check.js +2 -1
  30. package/build/conductor/precheck-timings.js +14 -0
  31. package/build/conductor/prerequisite-inputs.js +379 -0
  32. package/build/conductor/preview-observations.js +10 -0
  33. package/build/conductor/readiness-assessment.js +78 -0
  34. package/build/conductor/readiness-cli.js +10 -0
  35. package/build/conductor/readiness-prerequisites.js +53 -0
  36. package/build/conductor/readiness-sections.js +25 -9
  37. package/build/conductor/readiness.js +20 -2
  38. package/build/conductor/recovery-cli.js +281 -14
  39. package/build/conductor/recovery-operations.js +78 -5
  40. package/build/conductor/repair-contract.js +33 -0
  41. package/build/conductor/tools.js +34 -3
  42. package/build/conductor/wait-run-attention.js +115 -0
  43. package/build/conductor/wait-run-cli.js +96 -3
  44. package/build/conductor/worker-database-doctor-inspector.js +1 -0
  45. package/build/credential-store.js +25 -20
  46. package/build/dependency-install-declarations.js +157 -0
  47. package/build/docs.generated.js +4 -4
  48. package/build/doctor.js +37 -5
  49. package/build/drive-epic-help.js +2 -2
  50. package/build/drive-epic.js +240 -56
  51. package/build/epic-ci-workflow-drift.js +71 -23
  52. package/build/epic-ci-workflow-install.js +83 -26
  53. package/build/epic-ci-workflow-v1.js +132 -0
  54. package/build/epic-ci-workflow.js +174 -13
  55. package/build/epic-implementer-bin.js +119 -44
  56. package/build/epic-launch-profile.js +1 -1
  57. package/build/executor/ci-rerun-job.js +220 -14
  58. package/build/executor/cli.js +2 -0
  59. package/build/executor/completion-contract.js +16 -0
  60. package/build/executor/credentials.js +1 -1
  61. package/build/executor/delivery-observations.js +113 -0
  62. package/build/executor/delivery-outcome.js +30 -0
  63. package/build/executor/dependency-refresh-runner.js +132 -0
  64. package/build/executor/dependency-refresh.js +530 -0
  65. package/build/executor/deps.js +4 -0
  66. package/build/executor/env.js +274 -5
  67. package/build/executor/gate-qualification-job.js +20 -5
  68. package/build/executor/harness-coverage.js +19 -0
  69. package/build/executor/http-client.js +35 -1
  70. package/build/executor/index.js +2 -1
  71. package/build/executor/install-preflight.js +1 -1
  72. package/build/executor/job-runner.js +355 -36
  73. package/build/executor/likely-tests.js +100 -98
  74. package/build/executor/preflight.js +5 -0
  75. package/build/executor/process-containment.js +18 -0
  76. package/build/executor/prompt-spec.js +84 -15
  77. package/build/executor/reconcile-overlap-job.js +6 -1
  78. package/build/executor/required-verification.js +28 -0
  79. package/build/executor/required-work-diagnostics.js +30 -0
  80. package/build/executor/required-work-ledger.js +19 -1
  81. package/build/executor/results.js +42 -0
  82. package/build/executor/service-discovery.js +42 -0
  83. package/build/executor/service-lifecycle.js +109 -2
  84. package/build/executor/service-uninstall.js +205 -0
  85. package/build/executor/service-unit.js +5 -3
  86. package/build/executor/test-clock.js +3 -0
  87. package/build/executor/verification-hints.js +179 -0
  88. package/build/executor/worker-command.js +188 -1
  89. package/build/executor/worker-database.js +299 -40
  90. package/build/executor/worker-finalization.js +65 -10
  91. package/build/executor/worker-guard-hook.js +10 -2
  92. package/build/executor/worker-resources.js +12 -1
  93. package/build/executor/worker-verification-guidance.js +64 -0
  94. package/build/executor/worktree-inspection.js +42 -0
  95. package/build/github-sign-in.js +1 -1
  96. package/build/index.js +767 -310
  97. package/build/init.js +3 -3
  98. package/build/install-bridge-conductor-gate.js +416 -41
  99. package/build/install-bridge-conductor-setup.js +135 -32
  100. package/build/install-bridge-conductor.js +769 -353
  101. package/build/install-bridge.js +419 -124
  102. package/build/install-maintenance.js +104 -0
  103. package/build/install-reexec.js +1 -1
  104. package/build/local-cleanup.js +59 -0
  105. package/build/mcp-install-state.js +68 -2
  106. package/build/merge-workflow-install.js +22 -2
  107. package/build/package-script-semantics.js +10 -0
  108. package/build/pipeline-utils.js +1 -1
  109. package/build/pipelines.generated.js +6 -6
  110. package/build/plan-execution-ledger.js +171 -10
  111. package/build/plane/plane-freshness.js +12 -9
  112. package/build/plane/preflight.js +19 -0
  113. package/build/plane/terminal-run-cleanup.js +5 -1
  114. package/build/plane/terminal-run-status.js +4 -0
  115. package/build/printed-remedy-commands.js +31 -4
  116. package/build/readiness-check.js +1 -78
  117. package/build/readiness-prerequisites.generated.js +199 -0
  118. package/build/readme.generated.js +1 -1
  119. package/build/repository-toolchains.js +623 -0
  120. package/build/setup-change-policy.js +32 -0
  121. package/build/setup-epic.js +26 -9
  122. package/build/setup-question.js +62 -0
  123. package/build/start-tickets.js +4 -0
  124. package/build/test-command-detection.js +61 -80
  125. package/build/test-support/notes-fs.js +40 -0
  126. package/build/ticket-delivery-artifacts.js +7 -0
  127. package/build/ticket-delivery-enrollment.js +80 -4
  128. package/build/ticket-delivery-run-scope.js +128 -0
  129. package/build/version.generated.js +3 -3
  130. package/build/worker-guard-hook-bin.js +2 -2
  131. package/build/worktrees.js +105 -0
  132. package/docs/EPIC-IMPLEMENTER.md +43 -0
  133. package/docs/epic-implementer/getting-started.md +95 -14
  134. package/package.json +2 -2
@@ -0,0 +1,104 @@
1
+ /** One run's secret-bearing credential decision. Nothing here is a printable result. */
2
+ import { askSetupQuestion } from "./setup-question.js";
3
+ import { classifySetupAction } from "./setup-change-policy.js";
4
+ import { resolveBapiCredentials, readStoredBindingState } from "./credential-store.js";
5
+ const endpoint = (value) => value.trim().replace(/\/+$/, "");
6
+ /** Every consequential question uses the shared effect classifier and explained-question contract. */
7
+ export async function authorizeMaintenanceEffect(action, terminal, evidence, consequences) {
8
+ const classification = classifySetupAction(action);
9
+ if (classification === "routine" || classification === "no-op")
10
+ return true;
11
+ if (classification === "missing-information")
12
+ return false;
13
+ const decision = await askSetupQuestion({ purpose: action.effect, evidence,
14
+ options: [{ id: "yes", label: "Authorize this change" }, { id: "no", label: "Preserve existing state" }],
15
+ consequences, deferred: "Only this change is deferred. Independent maintenance remains available.",
16
+ recovery: "Rerun interactively after checking the affected project and destination." }, terminal);
17
+ return decision.status === "accept";
18
+ }
19
+ export async function settleMaintenanceCredential(input) {
20
+ const { repoName, baseUrl, terminal, report } = input;
21
+ const store = { ...input.store, env: { ...input.store.env, BAPI_API_KEY: undefined } };
22
+ const stored = await resolveBapiCredentials(repoName, store);
23
+ if (!stored.ok && stored.kind !== "not-found" && stored.kind !== "missing-key") {
24
+ return { ok: false, reason: `Saved credential ${stored.kind}; repair the credential store before reconnecting. Signup was not selected.` };
25
+ }
26
+ const observedKey = stored.ok ? stored.credentials.apiKey : null;
27
+ const binding = await readStoredBindingState(`bapi:${repoName}`, store);
28
+ if (binding.state === "unreadable" || binding.state === "invalid")
29
+ return { ok: false, reason: "Saved endpoint approval is unreadable or invalid; repair it before reconnecting." };
30
+ const storedEndpoint = binding.state === "bound" ? binding.baseUrl : input.productionBaseUrl;
31
+ const hosts = input.hosts.filter(host => host.repo === repoName);
32
+ const existing = [
33
+ ...(observedKey ? [{ key: observedKey, source: "store", label: "saved credential", baseUrl: storedEndpoint }] : []),
34
+ ...hosts.map(host => ({ key: host.key, source: "host", label: host.source, baseUrl: host.baseUrl ?? input.productionBaseUrl })),
35
+ ];
36
+ let retained = existing[0];
37
+ let reconcileHosts = false;
38
+ if (new Set(existing.map(item => item.key)).size > 1) {
39
+ const choices = existing.filter((item, index) => existing.findIndex(other => other.key === item.key) === index);
40
+ const decision = await askSetupQuestion({ purpose: "Reconcile conflicting installed Bridge credentials",
41
+ evidence: choices.map(item => `${item.label}: project ${repoName}; destination ${endpoint(item.baseUrl) === endpoint(baseUrl) ? baseUrl : "a different configured endpoint (details withheld)"}`),
42
+ options: choices.map((item, i) => ({ id: String(i + 1), label: `Use ${item.label}` })),
43
+ consequences: ["Selected host bindings and the saved credential will use the chosen identity after validation. No credential value is displayed."],
44
+ deferred: "All conflicting bindings remain unchanged; independent assets can still be refreshed.",
45
+ recovery: "Inspect the configured projects and rerun interactively." }, terminal);
46
+ if (decision.status !== "selected")
47
+ return { ok: false, reason: "Installed credential conflict remains unresolved; existing bindings preserved." };
48
+ retained = choices[Number(decision.id) - 1];
49
+ reconcileHosts = true;
50
+ }
51
+ let candidate = input.candidate ?? (retained ? { key: retained.key, source: retained.source } : undefined);
52
+ if (reconcileHosts && retained && candidate && existing.some(item => item.key === candidate.key))
53
+ candidate = { key: retained.key, source: retained.source };
54
+ if (!candidate?.key)
55
+ return { ok: false, reason: stored.ok ? "No usable installed credential." : `Saved credential ${stored.kind}; supply a token for this project or use an explicit onboarding route.` };
56
+ const sameEndpoint = (value) => endpoint(value) === endpoint(baseUrl);
57
+ const inheritedPair = typeof input.originalEnvironment.BAPI_BASE_URL === "string" && sameEndpoint(input.originalEnvironment.BAPI_BASE_URL);
58
+ const observedCandidate = existing.find(item => item.key === candidate.key);
59
+ const transferNeeded = observedCandidate ? !sameEndpoint(observedCandidate.baseUrl)
60
+ : candidate.source === "env" && !inheritedPair && !sameEndpoint(input.productionBaseUrl);
61
+ let transferred = false;
62
+ if (transferNeeded) {
63
+ transferred = await authorizeMaintenanceEffect({ category: "credential", state: { status: "present", identity: repoName },
64
+ unchanged: false, context: baseUrl, effect: "Authorize the credential for this Bridge destination?", repository: repoName, trusted: true }, terminal, [`Project: ${repoName}`, `Credential source: ${candidate.source}`, `Destination: ${baseUrl}`, "Account and wider credential scope: unknown until validation"], ["Authenticated validation sends the credential to this destination. Saving approval replaces its previous endpoint binding; this does not authorize a different identity."]);
65
+ if (!transferred) {
66
+ if (!retained || !sameEndpoint(retained.baseUrl))
67
+ return { ok: false, reason: "Endpoint transfer deferred; retained credential is unavailable to this destination." };
68
+ candidate = { key: retained.key, source: retained.source };
69
+ if (input.originalEnvironment.BAPI_API_KEY)
70
+ report("Environment candidate declined. Unset BAPI_API_KEY in future shells to use the saved identity.");
71
+ }
72
+ }
73
+ let validated = false;
74
+ const different = !!retained && candidate.key !== retained.key;
75
+ if (different || transferred || reconcileHosts) {
76
+ try {
77
+ validated = await input.validate(candidate.key);
78
+ }
79
+ catch {
80
+ validated = false;
81
+ }
82
+ if (reconcileHosts && !validated)
83
+ return { ok: false, reason: "Chosen installed credential could not be validated; conflicting bindings remain unchanged." };
84
+ let accepted = validated;
85
+ if (different && validated)
86
+ accepted = await authorizeMaintenanceEffect({ category: "credential", state: { status: "present", identity: repoName },
87
+ unchanged: false, context: baseUrl, effect: "Replace the installed Bridge credential?", repository: repoName, trusted: true }, terminal, [`Project: ${repoName}`, `Destination: ${baseUrl}`, "Candidate access validated through /jira/ping. Account and wider scope metadata remain unknown."], ["The saved credential, selected host bindings, future requests and launches will use the replacement. Optional declined capabilities remain unavailable."]);
88
+ if (!accepted) {
89
+ if (!retained || !sameEndpoint(retained.baseUrl))
90
+ return { ok: false, reason: "Candidate validation or replacement deferred; no usable retained identity for this destination." };
91
+ candidate = { key: retained.key, source: retained.source };
92
+ validated = false;
93
+ transferred = false;
94
+ reconcileHosts = false;
95
+ report("Candidate validation failed or replacement was declined; installed identity preserved.");
96
+ if (input.originalEnvironment.BAPI_API_KEY)
97
+ report("Unset BAPI_API_KEY in future shells to use the saved identity.");
98
+ }
99
+ }
100
+ return { ok: true, identity: { repoName, baseUrl, apiKey: candidate.key, source: candidate.source,
101
+ observedKey, persist: candidate.key !== observedKey, bindEndpoint: transferred || (candidate.key !== observedKey && !sameEndpoint(input.productionBaseUrl)),
102
+ replacementAccepted: (different && candidate.key !== retained?.key) || reconcileHosts,
103
+ validation: validated ? "validated" : "required" } };
104
+ }
@@ -170,7 +170,7 @@ export function prepareInstallReexecArguments(argv) {
170
170
  * 1. Strip sentinels (before anything reads argv).
171
171
  * 2. If a sentinel was present, or the first remaining token is `conductor`,
172
172
  * delegate straight to the local installer — no registry lookup, no spawn.
173
- * The nested `install conductor` surface is intercepted inside
173
+ * The nested `install epic-implementer` surface is intercepted inside
174
174
  * `runInstallBridgeCli`, so it must reach it as `["conductor", ...]` rather
175
175
  * than being collapsed into bare onboarding.
176
176
  * 3. Otherwise look up the latest version, defaulting the comparison target to
@@ -0,0 +1,59 @@
1
+ /** Shared bounded process and default-deny consent boundaries for local cleanup. */
2
+ import { spawn } from "node:child_process";
3
+ import { createInterface } from "node:readline/promises";
4
+ export async function confirmLocalCleanup(question) {
5
+ if (!process.stdin.isTTY || !process.stdout.isTTY)
6
+ return false;
7
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
8
+ try {
9
+ return /^(y|yes)$/i.test((await rl.question(`${question} (y/N) `)).trim());
10
+ }
11
+ finally {
12
+ rl.close();
13
+ }
14
+ }
15
+ export function runLocalCommand(executable, args, cwd, timeoutMs = 10_000) {
16
+ return new Promise((resolve) => {
17
+ const child = spawn(executable, args, { cwd, shell: false, detached: process.platform !== "win32", stdio: ["ignore", "pipe", "pipe"] });
18
+ const stdout = [], stderr = [];
19
+ let bytes = 0, finished = false;
20
+ const finish = (exitCode) => {
21
+ if (finished)
22
+ return;
23
+ finished = true;
24
+ clearTimeout(timer);
25
+ resolve({ exitCode, stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8") });
26
+ };
27
+ const terminate = () => {
28
+ // Git can spawn an SSH helper. Kill this invocation's own process group,
29
+ // so a timed-out observation cannot leave that helper behind on POSIX.
30
+ try {
31
+ if (process.platform !== "win32" && child.pid)
32
+ process.kill(-child.pid, "SIGKILL");
33
+ else
34
+ child.kill("SIGKILL");
35
+ }
36
+ catch {
37
+ child.kill("SIGKILL");
38
+ }
39
+ child.stdout.destroy();
40
+ child.stderr.destroy();
41
+ finish(-1);
42
+ };
43
+ const timer = setTimeout(terminate, Math.max(1, Math.min(timeoutMs, 10_000)));
44
+ const collect = (chunks, chunk) => {
45
+ if (finished)
46
+ return;
47
+ bytes += chunk.length;
48
+ if (bytes > 1024 * 1024) {
49
+ terminate();
50
+ return;
51
+ }
52
+ chunks.push(chunk);
53
+ };
54
+ child.stdout.on("data", (chunk) => collect(stdout, chunk));
55
+ child.stderr.on("data", (chunk) => collect(stderr, chunk));
56
+ child.on("error", () => finish(-1));
57
+ child.on("close", (code) => finish(code ?? -1));
58
+ });
59
+ }
@@ -17,6 +17,8 @@
17
17
  * unit-testable with in-memory fakes.
18
18
  */
19
19
  import { validPackagedAssetInventory } from "./generated-assets-context.js";
20
+ import { lstat, readFile, open, rename, unlink } from "node:fs/promises";
21
+ import { randomUUID } from "node:crypto";
20
22
  import { currentDestinationForLegacyDoc } from "./generated-assets-legacy.js";
21
23
  import { executorIdFromLaunchdFilename, executorIdFromSystemdFilename, } from "./executor/service-unit.js";
22
24
  import { HOST_PLATFORM_ORDER, isHostPlatformId, } from "./mcp-host-targets.js";
@@ -24,8 +26,72 @@ import { HOST_PLATFORM_ORDER, isHostPlatformId, } from "./mcp-host-targets.js";
24
26
  export const MCP_INSTALL_STATE_VERSION = 1;
25
27
  /** The relative path of the state file within a project. */
26
28
  export const MCP_INSTALL_STATE_RELPATH = ".bridge/install-state.json";
29
+ /** Narrow inverse: preserve the complete document and remove only this locator. */
30
+ export async function forgetInstalledExecutorServiceUnit(cwd, unitPath, homeDir, deps = { lstat, readFile, open, rename, unlink }) {
31
+ const locator = canonicalExecutorServiceUnitLocator(unitPath, homeDir);
32
+ if (!locator)
33
+ return { ok: false, reason: "invalid-target" };
34
+ const target = installStatePath(cwd);
35
+ let snapshot, raw;
36
+ try {
37
+ const parent = await deps.lstat(joinCwd(cwd, ".bridge"));
38
+ if (parent.isSymbolicLink() || !parent.isDirectory())
39
+ return { ok: false, reason: "unsafe-state" };
40
+ snapshot = await deps.lstat(target);
41
+ if (!snapshot.isFile() || snapshot.isSymbolicLink())
42
+ return { ok: false, reason: "unsafe-state" };
43
+ raw = await deps.readFile(target);
44
+ }
45
+ catch (error) {
46
+ return error.code === "ENOENT" ? { ok: true, outcome: "missing-state" } : { ok: false, reason: "unsafe-state" };
47
+ }
48
+ let doc;
49
+ try {
50
+ doc = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(raw));
51
+ const supported = new Set(["version", "selectedPlatforms", "projectConfigPaths", "executorServiceUnitPaths", "capabilities", "packagedAssets"]);
52
+ if (!doc || Array.isArray(doc) || doc.version !== MCP_INSTALL_STATE_VERSION || Object.keys(doc).some(key => !supported.has(key)) ||
53
+ !Array.isArray(doc.selectedPlatforms) || !doc.selectedPlatforms.every(isHostPlatformId) ||
54
+ (doc.projectConfigPaths !== undefined && (!Array.isArray(doc.projectConfigPaths) || !doc.projectConfigPaths.every(isRecordableProjectPath))) ||
55
+ (doc.capabilities !== undefined && (!Array.isArray(doc.capabilities) || !doc.capabilities.every(isMcpInstallCapabilityId))) ||
56
+ (doc.packagedAssets !== undefined && !validPackagedAssetInventory(doc.packagedAssets)) ||
57
+ (doc.executorServiceUnitPaths !== undefined && (!Array.isArray(doc.executorServiceUnitPaths) || !doc.executorServiceUnitPaths.every(v => typeof v === "string" && isGeneratedExecutorUnitLocator(v))))) {
58
+ return { ok: false, reason: "unsafe-state" };
59
+ }
60
+ }
61
+ catch {
62
+ return { ok: false, reason: "unsafe-state" };
63
+ }
64
+ if (!Array.isArray(doc.executorServiceUnitPaths) || !doc.executorServiceUnitPaths.includes(locator))
65
+ return { ok: true, outcome: "unrecorded" };
66
+ doc.executorServiceUnitPaths = doc.executorServiceUnitPaths.filter(v => v !== locator);
67
+ const temp = `${target}.${randomUUID()}.tmp`;
68
+ let owned = false;
69
+ try {
70
+ const handle = await deps.open(temp, "wx", snapshot.mode & 0o777);
71
+ owned = true;
72
+ try {
73
+ await handle.writeFile(JSON.stringify(doc, null, 2) + "\n", "utf8");
74
+ }
75
+ finally {
76
+ await handle.close();
77
+ }
78
+ const now = await deps.lstat(target);
79
+ if (!now.isFile() || now.isSymbolicLink() || now.dev !== snapshot.dev || now.ino !== snapshot.ino || now.mode !== snapshot.mode || !(await deps.readFile(target)).equals(raw))
80
+ return { ok: false, reason: "concurrent-change" };
81
+ await deps.rename(temp, target);
82
+ owned = false;
83
+ return { ok: true, outcome: "forgotten" };
84
+ }
85
+ catch {
86
+ return { ok: false, reason: "publication-failed" };
87
+ }
88
+ finally {
89
+ if (owned)
90
+ await deps.unlink(temp).catch(() => { });
91
+ }
92
+ }
27
93
  /**
28
- * The conductor capabilities `install conductor` may record (BAPI-775).
94
+ * The conductor capabilities `install epic-implementer` may record (BAPI-775).
29
95
  *
30
96
  * A CLOSED vocabulary, validated on read and on write: install state is a
31
97
  * diagnostic inventory of what this tool provisioned, so an arbitrary
@@ -460,7 +526,7 @@ export async function recordInstalledExecutorServiceUnit(cwd, unitPath, homeDir,
460
526
  * {@link MCP_INSTALL_CAPABILITY_IDS} vocabulary BEFORE any read or write, so an
461
527
  * unrecognized identifier is refused with an advisory result and touches
462
528
  * nothing — never silently dropped after a rewrite. Repeating a capability is a
463
- * set-style no-op, so re-running `install conductor` cannot duplicate an entry.
529
+ * set-style no-op, so re-running `install epic-implementer` cannot duplicate an entry.
464
530
  */
465
531
  export async function recordInstalledConductorCapability(cwd, capability, deps) {
466
532
  if (!isMcpInstallCapabilityId(capability)) {
@@ -6,7 +6,7 @@
6
6
  * identity, and opens a pull request with the customer's own `gh`. It never
7
7
  * merges that pull request, and Bridge never writes to the repository at all.
8
8
  * Two sets exist today: the Epic Implementer merge workflow with its two review
9
- * artifacts (`install-bridge conductor --merge-workflow`, below), and the
9
+ * artifacts (`install epic-implementer --merge-workflow`, below), and the
10
10
  * Epic Implementer CI workflow (`epic-ci-workflow-install.ts`).
11
11
  *
12
12
  * ## Domain logic lives here, not in the CLI
@@ -138,6 +138,11 @@ export const MERGE_WORKFLOW_INSTALL_FAILURE_REASONS = [
138
138
  "worktree_failed",
139
139
  /** The test command for the CI workflow is missing or invalid. */
140
140
  "test_command_invalid",
141
+ // --- BAPI-1536 -----------------------------------------------------------
142
+ /** The CI workflow's toolchain set is outside the closed vocabulary. */
143
+ "toolchains_invalid",
144
+ /** A pull request from an earlier published renderer version's managed branch is still open. */
145
+ "historical_managed_pr_open",
141
146
  ];
142
147
  // ---------------------------------------------------------------------------
143
148
  // Path safety
@@ -206,6 +211,8 @@ const REMEDIATION = {
206
211
  managed_state_changed: "Another managed branch or pull request appeared while this command ran; review it, then re-run.",
207
212
  worktree_failed: "A temporary git worktree could not be created; check free disk space and `git worktree list`, then re-run.",
208
213
  test_command_invalid: "Save a valid test command through Bridge setup, then re-run.",
214
+ toolchains_invalid: "Re-run setup so the repository's dependency files are inspected again; nothing was written.",
215
+ historical_managed_pr_open: "An earlier Bridge setup pull request is still open for this workflow; merge or close it, then re-run. Bridge does not close or rewrite it.",
209
216
  };
210
217
  /** The remediation sentence for a reason. */
211
218
  export function artifactSetRemediation(reason) {
@@ -775,6 +782,19 @@ export async function installArtifactSet(descriptor, options, deps) {
775
782
  if (preflight.classification === "identical") {
776
783
  return { outcome: "identical", artifacts: [...preflight.proposals.keys()], warnings: [] };
777
784
  }
785
+ // An open pull request from an earlier renderer version's branch comes first:
786
+ // it targets the same managed file, so new work would race it.
787
+ for (const historical of descriptor.historicalBranches ?? []) {
788
+ const lookup = await findExistingManagedPr(deps, preflight.repository, historical);
789
+ if (lookup.kind === "lookup_failed")
790
+ return fail("remote_state_unverifiable", { branch: historical });
791
+ if (lookup.kind === "found") {
792
+ return fail("historical_managed_pr_open", {
793
+ branch: historical,
794
+ ...(lookup.pr.url.length > 0 ? { prUrl: lookup.pr.url } : {}),
795
+ });
796
+ }
797
+ }
778
798
  const managedPaths = descriptor.artifacts.map((a) => a.relPath);
779
799
  let upgrade = false;
780
800
  let branch = "";
@@ -984,7 +1004,7 @@ export async function installArtifactSet(descriptor, options, deps) {
984
1004
  /**
985
1005
  * Generate the merge-workflow artifacts and open the customer's review PR.
986
1006
  *
987
- * Compatibility wrapper for `install-bridge conductor --merge-workflow` around
1007
+ * Compatibility wrapper for `install epic-implementer --merge-workflow` around
988
1008
  * {@link installArtifactSet}. Returns a process exit code: `0` for every
989
1009
  * success shape (new pull request, upgrade pull request, verified existing pull
990
1010
  * request, byte-identical no-op, dry run) and `1` for every failure. A failure
@@ -0,0 +1,10 @@
1
+ /** Shared, conservative npm script evidence. Bodies are never executed. */
2
+ export const NPM_PLACEHOLDER_TEST_SCRIPT = 'echo "Error: no test specified" && exit 1';
3
+ export function isUsablePackageScript(value) {
4
+ return typeof value === "string" && value.trim() !== ""
5
+ && !/^echo\s+['"]?Error:\s*no test specified['"]?\s*&&\s*exit\s+1\s*;?$/i.test(value.trim());
6
+ }
7
+ export function isTestScript(name, body) {
8
+ return /^(test([:_-].+)?|unit|integration|e2e)$/.test(name)
9
+ && isUsablePackageScript(body) && !/(?:&&|\|\||[;|])/.test(body);
10
+ }
@@ -256,7 +256,7 @@ export function resolveRecipe(pipeline, instructions, variables, skipSteps, auto
256
256
  "If requires_approval is true, pause before executing. For agent_task steps, the instruction file's own approval format is authoritative — follow it verbatim and do not substitute your own short confirmation prompt. For mcp_call steps with no instruction file, present the resolved params as bullet points and ask for approval. " +
257
257
  'For on_error "halt", stop the pipeline immediately on failure. ' +
258
258
  'For on_error "warn_and_continue", log a warning and proceed. ' +
259
- "Recipes are re-entrant: a recovery run may begin again at step 1, and a step whose tool reports a server-side reuse (e.g. reused: true) has completed successfully — treat that as the expected fast path, not a failure, and continue. " +
259
+ "An interrupted initial workflow may re-enter only as permitted by its recipe and checkpoint rules. Separately dispatched remaining-work corrections follow their focused intent and must not restart a full implementation or planning recipe. A step whose tool reports server-side reuse (e.g. reused: true) has completed successfully — treat that as the expected fast path, not a failure, and continue. " +
260
260
  'A step can succeed (no on_error handling applies) while its own returned content is a JSON envelope shaped like error: "GATEWAY_TIMEOUT", status: 504, and a recovery_get field — recognize that shape and read it as "server-side processing may still be running", not as a failure or an invitation to retry. Poll the named retrieval tool (or the recovery_get URL) with the same artifact identifier until a terminal response is reached, and never reissue the original request tool. Only fall back to on_error handling if that retrieval itself terminally fails. ' +
261
261
  "Do not skip steps, reorder them, or substitute your own tool calls.";
262
262
  // Default-on: include the upgrade-advice surfacing convention unless the