@bridge_gpt/mcp-server 0.2.73 → 0.2.74

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 (90) hide show
  1. package/README.md +5 -5
  2. package/build/agent-launchers/claude-executor-adapter.js +12 -0
  3. package/build/agents.generated.js +3 -3
  4. package/build/bridge-config.js +7 -1
  5. package/build/bridge-permissions.js +3 -0
  6. package/build/command-provisioning.js +4 -3
  7. package/build/commands.generated.js +5 -5
  8. package/build/conductor/bridge-api-client.js +26 -1
  9. package/build/conductor/command-drift.js +1 -1
  10. package/build/conductor/declared-extras.js +335 -0
  11. package/build/conductor/doctor.js +2 -0
  12. package/build/conductor/driver-pass-output.js +104 -0
  13. package/build/conductor/driver-pass.js +571 -0
  14. package/build/conductor/epic-branch-ci-inspection.js +61 -16
  15. package/build/conductor/epic-implementer-cli.js +33 -0
  16. package/build/conductor/epic-server-sfcc-upload.js +1567 -0
  17. package/build/conductor/epic-server-sfcc.js +58 -80
  18. package/build/conductor/epic-server.js +57 -4
  19. package/build/conductor/gate-discovery.js +46 -6
  20. package/build/conductor/gate-settings-review.js +51 -14
  21. package/build/credential-delivery.js +280 -0
  22. package/build/credential-launch-safety.js +142 -0
  23. package/build/credential-materialization.js +91 -16
  24. package/build/credential-references-node-deps.js +29 -0
  25. package/build/credential-references.js +1394 -0
  26. package/build/credential-references.test-fixtures.js +211 -0
  27. package/build/credential-scan-conventions.js +145 -0
  28. package/build/credential-scan.js +517 -0
  29. package/build/credential-store.js +50 -0
  30. package/build/credentials-cli.js +252 -3
  31. package/build/dependency-install-declarations.js +47 -1
  32. package/build/docs.generated.js +8 -1
  33. package/build/doctor.js +41 -0
  34. package/build/drive-epic.js +297 -37
  35. package/build/epic-branch-ci-summary.js +18 -1
  36. package/build/epic-capability-statement.js +71 -3
  37. package/build/epic-ci-workflow-drift.js +52 -13
  38. package/build/epic-ci-workflow-install.js +31 -6
  39. package/build/epic-ci-workflow-v3.js +273 -0
  40. package/build/epic-ci-workflow.js +128 -7
  41. package/build/epic-implementer-bin.js +161 -70
  42. package/build/epic-launch-context.js +102 -7
  43. package/build/epic-server-record.js +30 -15
  44. package/build/executor/credential-delivery-step.js +168 -0
  45. package/build/executor/deps.js +3 -1
  46. package/build/executor/env.js +39 -1
  47. package/build/executor/epic-server-context.js +23 -7
  48. package/build/executor/guarded-fast-forward-push.js +13 -8
  49. package/build/executor/job-runner.js +159 -17
  50. package/build/executor/permissions.js +85 -3
  51. package/build/executor/prompt-spec.js +37 -3
  52. package/build/executor-launch.js +4 -2
  53. package/build/git-exclude-lock.js +187 -0
  54. package/build/index.js +398 -269
  55. package/build/install-bridge-conductor-answers.js +84 -21
  56. package/build/install-bridge-conductor-apply.js +30 -1
  57. package/build/install-bridge-conductor-assessment.js +375 -48
  58. package/build/install-bridge-conductor-compact.js +27 -2
  59. package/build/install-bridge-conductor-contracts.js +10 -1
  60. package/build/install-bridge-conductor-gate.js +124 -11
  61. package/build/install-bridge-conductor-setup.js +46 -8
  62. package/build/install-bridge-conductor.js +625 -113
  63. package/build/install-bridge.js +88 -11
  64. package/build/install-doctor.js +38 -8
  65. package/build/install-sfcc-detection.js +120 -0
  66. package/build/install-sfcc-setup.js +185 -0
  67. package/build/mcp-grant-candidates.js +108 -96
  68. package/build/mcp-invoke.js +168 -4
  69. package/build/mcp-provisioning.js +21 -4
  70. package/build/mcp-server-invocation.js +13 -0
  71. package/build/merge-workflow-install.js +9 -1
  72. package/build/pipelines.generated.js +2 -1
  73. package/build/plane/status.js +8 -2
  74. package/build/printed-remedy-commands.js +5 -0
  75. package/build/project-root.js +40 -0
  76. package/build/readme.generated.js +1 -1
  77. package/build/repository-state-paths.js +5 -2
  78. package/build/repository-toolchains.js +6 -3
  79. package/build/setup-epic.js +116 -15
  80. package/build/sfcc/credentials.js +3 -2
  81. package/build/sfcc/hostname.js +98 -2
  82. package/build/sfcc/tool-wrapper.js +6 -95
  83. package/build/start-tickets.js +193 -29
  84. package/build/test-support/executor-source-files.js +200 -0
  85. package/build/testing-config-client.js +25 -2
  86. package/build/third-party-mcp-targets.js +35 -4
  87. package/build/version.generated.js +3 -3
  88. package/build/with-credentials.js +208 -0
  89. package/build/worktree-credential-delivery.js +340 -0
  90. package/package.json +1 -1
@@ -21,6 +21,7 @@
21
21
  import { createHash } from "node:crypto";
22
22
  import { CONDITIONAL_ANSWER_KEYS, INSTALL_ANSWER_KEYS, INSTALL_PROPOSAL_DIGEST_VERSION, isInstallAnswerKey, } from "./install-bridge-conductor-contracts.js";
23
23
  import { REINDEX_BRANCH_EFFECTS, REINDEX_RETRY_EFFECTS, choiceFor, resolveEpicBranchCiRecommendation, } from "./install-bridge-conductor-assessment.js";
24
+ import { DEPENDENCY_INSTALL_UNSAFE_MESSAGE, isUnsafeDependencyInstallEntry, parseDependencyInstallStrict, } from "./dependency-install-declarations.js";
24
25
  import { isValidCredentialReference, isValidSfccSandboxId, normalizeStorefrontOrigin } from "./epic-server-record.js";
25
26
  /** The largest answers file read. A setup answers object is a few kilobytes. */
26
27
  export const MAX_ANSWERS_BYTES = 256 * 1024;
@@ -127,19 +128,45 @@ export function parseAnswerValue(key, raw) {
127
128
  }
128
129
  return bad("invalid_value", 'Use "learn", "skip", "keep", or {"command": "<one line>"}.');
129
130
  }
131
+ if (key === "dependency_install" && isPlainObject(raw)) {
132
+ const shape = 'Use "approve", "decline", "keep", or {"entries": [{"cwd": ".", "argv": ["..."], "lockfiles": ["..."]}]}.';
133
+ if (Object.keys(raw).length !== 1 || !Array.isArray(raw.entries))
134
+ return bad("invalid_value", shape);
135
+ // The whole list or a refusal. Neither refusal carries any part of the submitted list.
136
+ if (raw.entries.some(isUnsafeDependencyInstallEntry))
137
+ return bad("literal_credential", DEPENDENCY_INSTALL_UNSAFE_MESSAGE);
138
+ const entries = parseDependencyInstallStrict(raw.entries);
139
+ if (entries === null)
140
+ return bad("invalid_value", shape);
141
+ return { ok: true, decision: { kind: "dependency_install_entries", entries } };
142
+ }
130
143
  if (key === "epic_server" && isPlainObject(raw)) {
131
- if (!onlyKeys(raw, ["mode", "sandbox_id", "credential_ref", "storefront_origin"]) || raw.mode !== "sfcc_shared_active") {
132
- return bad("invalid_value", 'Use "keep", "none", "local", or an sfcc_shared_active object.');
144
+ const mode = raw.mode;
145
+ if (!onlyKeys(raw, ["mode", "sandbox_id", "credential_ref", "storefront_origin"]) || (mode !== "sfcc_shared_active" && mode !== "local" && mode !== "none")) {
146
+ return bad("invalid_value", 'Use "keep", "none", "local", an sfcc_shared_active object, or a local or none object with a sandbox.');
147
+ }
148
+ const originGiven = raw.storefront_origin !== undefined;
149
+ const origin = originGiven || mode === "sfcc_shared_active" ? normalizeStorefrontOrigin(raw.storefront_origin) : null;
150
+ if (mode === "sfcc_shared_active") {
151
+ if (!isValidSfccSandboxId(raw.sandbox_id) || !isValidCredentialReference(raw.credential_ref) || origin === null) {
152
+ return bad("invalid_value", "The sfcc_shared_active answer needs a valid sandbox_id, credential_ref, and storefront_origin.");
153
+ }
154
+ return {
155
+ ok: true,
156
+ decision: {
157
+ kind: "epic_server_sfcc",
158
+ value: { mode, sandbox_id: raw.sandbox_id, credential_ref: raw.credential_ref, storefront_origin: origin },
159
+ },
160
+ };
133
161
  }
134
- const origin = normalizeStorefrontOrigin(raw.storefront_origin);
135
- if (!isValidSfccSandboxId(raw.sandbox_id) || !isValidCredentialReference(raw.credential_ref) || origin === null) {
136
- return bad("invalid_value", "The sfcc_shared_active answer needs a valid sandbox_id, credential_ref, and storefront_origin.");
162
+ if (!isValidSfccSandboxId(raw.sandbox_id) || !isValidCredentialReference(raw.credential_ref) || (originGiven && origin === null)) {
163
+ return bad("invalid_value", `The ${mode} sandbox answer needs a valid sandbox_id and credential_ref, and any storefront_origin must be valid.`);
137
164
  }
138
165
  return {
139
166
  ok: true,
140
167
  decision: {
141
168
  kind: "epic_server_sfcc",
142
- value: { mode: "sfcc_shared_active", sandbox_id: raw.sandbox_id, credential_ref: raw.credential_ref, storefront_origin: origin },
169
+ value: { mode, sandbox_id: raw.sandbox_id, credential_ref: raw.credential_ref, ...(origin !== null ? { storefront_origin: origin } : {}) },
143
170
  },
144
171
  };
145
172
  }
@@ -213,11 +240,13 @@ function effectFor(key, choice, decision) {
213
240
  case "command":
214
241
  return { action: "qualify_owner_test_command", target: "repository_gate.local_commands", params: { command: decision.command }, condition: "only_if_check_passes" };
215
242
  case "epic_server_sfcc":
216
- return effects.sfcc_shared_active !== undefined
217
- ? { ...effects.sfcc_shared_active, params: { ...decision.value } }
243
+ return effects[decision.value.mode] !== undefined
244
+ ? { ...effects[decision.value.mode], params: { ...decision.value } }
218
245
  : null;
219
246
  case "profile":
220
247
  return { action: "write_launch_profile", target: "launch_profile", params: { name: decision.name } };
248
+ case "dependency_install_entries":
249
+ return { action: "store_declaration", target: "repository_gate.dependency_install", params: { value: decision.entries } };
221
250
  }
222
251
  }
223
252
  function intentOf(decision, effect) {
@@ -233,7 +262,7 @@ function consequenceOf(choice, decision) {
233
262
  const id = decision.kind === "option" ? decision.option
234
263
  : decision.kind === "decline" ? "decline"
235
264
  : decision.kind === "reference" ? "reference"
236
- : decision.kind === "epic_server_sfcc" ? "sfcc_shared_active"
265
+ : decision.kind === "epic_server_sfcc" ? decision.value.mode
237
266
  : null;
238
267
  if (decision.kind === "selection") {
239
268
  return decision.ids.length === 0
@@ -242,6 +271,11 @@ function consequenceOf(choice, decision) {
242
271
  }
243
272
  if (decision.kind === "command")
244
273
  return "Bridge proves your command with one bounded check and stores it only if it passes.";
274
+ if (decision.kind === "dependency_install_entries") {
275
+ return decision.entries.length === 0
276
+ ? "Stores an empty list: workers and the test trial run no declared install, and managed CI uses its normal toolchain install."
277
+ : `Stores your ${decision.entries.length} install command${decision.entries.length === 1 ? "" : "s"} in place of the whole list, in the order you gave. Workers, the test trial, and managed CI all use exactly these.`;
278
+ }
245
279
  return choice.options.find((o) => o.id === id)?.consequence ?? "Nothing changes.";
246
280
  }
247
281
  const DEPENDS_ON = Object.freeze({
@@ -257,6 +291,30 @@ const DEPENDS_ON = Object.freeze({
257
291
  // BAPI-1659: `epic_ci_change` has no dependency. It opens its own pull request, so a declined
258
292
  // setup pull request never blocks it, and the test-command dependency stays on `setup_pr` alone.
259
293
  });
294
+ /**
295
+ * The digest refusal. BAPI-1677: a stale approval also names the answers it may have
296
+ * approved something else for. The digest cannot say which input moved, so each key
297
+ * whose approved write depends on repository facts is named. The digest is still
298
+ * compared strictly: naming a key refuses the file, it never lets the file through.
299
+ */
300
+ function digestMismatchReason(actions, ciOmitted = false) {
301
+ const writes = (key) => actions.some((a) => a.key === key && a.intent === "write");
302
+ const named = [
303
+ ["dependency_install", "The install commands setup would store may have changed."],
304
+ ["epic_ci_change", "The CI change setup would make may have changed."],
305
+ ];
306
+ const affected = named.filter(([key]) => writes(key));
307
+ return {
308
+ reason: "digest_mismatch",
309
+ keys: ["proposal_digest", ...(ciOmitted ? ["epic_branch_ci"] : []), ...affected.map(([key]) => key)],
310
+ detail: "The answers no longer match what setup would do now: the repository, destination, credential binding, " +
311
+ "an offered option, or a target changed since the proposal was shown." +
312
+ (ciOmitted
313
+ ? " The epic_branch_ci answer was omitted, so its recommendation was resolved again from your other answers; state it to keep it."
314
+ : "") +
315
+ affected.map(([, text]) => ` ${text}`).join(""),
316
+ };
317
+ }
260
318
  /**
261
319
  * Validate the whole answers object against the assessment, merge the flags,
262
320
  * and build the normalized proposal and its digest. Nothing here writes.
@@ -294,7 +352,7 @@ export function normalizeInstallAnswers(input) {
294
352
  if (choice !== undefined) {
295
353
  const d = parsed.decision;
296
354
  const optionId = d.kind === "option" ? d.option : d.kind === "decline" ? "decline" : d.kind === "reference" ? "reference"
297
- : d.kind === "epic_server_sfcc" ? "sfcc_shared_active" : null;
355
+ : d.kind === "epic_server_sfcc" ? d.value.mode : null;
298
356
  if (optionId !== null && !acceptsOption(choice, optionId)) {
299
357
  add("option_not_offered", rawKey, "This option is not one the assessment offers for this key.");
300
358
  continue;
@@ -383,30 +441,35 @@ export function normalizeInstallAnswers(input) {
383
441
  const digest = computeProposalDigest(proposal);
384
442
  if (input.mode === "apply") {
385
443
  const supplied = envelope.proposal_digest;
444
+ // An omitted epic_branch_ci takes the current recommendation, which the answers around it
445
+ // can change. Name it, so the owner knows to state it; omission is never approval of the
446
+ // newly resolved decision.
447
+ const ciOmitted = !stated.has("epic_branch_ci") && flags.epic_branch_ci === undefined;
386
448
  if (supplied === undefined) {
387
449
  reasons.push({ reason: "digest_missing", keys: ["proposal_digest"], detail: "An answers apply needs the proposal_digest proposal mode returned." });
388
450
  }
389
451
  else if (typeof supplied !== "string" || !DIGEST_RE.test(supplied)) {
390
452
  reasons.push({ reason: "invalid_value", keys: ["proposal_digest"], detail: "proposal_digest must be the 64-character hex digest proposal mode returned." });
391
453
  }
392
- else if (supplied !== digest && reasons.every((r) => r.reason === "missing_consequential" && r.keys.includes("epic_ci_change"))) {
454
+ else if (supplied !== digest &&
455
+ reasons.every((r) => r.reason === "missing_consequential" && r.keys.includes("epic_ci_change") && !r.keys.includes("dependency_install"))) {
393
456
  // BAPI-1659: a saved envelope from before the CI change was independently offered cannot
394
457
  // name it. It is stale, not incomplete: refuse it as a digest mismatch so nothing is
395
- // prompted for, defaulted, or inferred from the setup answer.
458
+ // prompted for, defaulted, or inferred from the setup answer. BAPI-1677: this never
459
+ // clears a missing install answer, which must stay named.
396
460
  reasons.length = 0;
397
- reasons.push({
398
- reason: "digest_mismatch",
399
- keys: ["proposal_digest"],
400
- detail: "The answers no longer match what setup would do now: the repository, destination, credential binding, " +
401
- "an offered option, or a target changed since the proposal was shown.",
402
- });
461
+ reasons.push(digestMismatchReason(actions, ciOmitted));
403
462
  }
404
463
  else if (supplied !== digest && reasons.length === 0) {
464
+ reasons.push(digestMismatchReason(actions, ciOmitted));
465
+ }
466
+ else if (supplied !== digest && actions.some((a) => a.key === "dependency_install" && a.intent === "write")) {
467
+ // BAPI-1677: other reasons are named too, but a stale approval of install commands is
468
+ // always named, so the owner learns the commands may have changed.
405
469
  reasons.push({
406
470
  reason: "digest_mismatch",
407
- keys: ["proposal_digest"],
408
- detail: "The answers no longer match what setup would do now: the repository, destination, credential binding, " +
409
- "an offered option, or a target changed since the proposal was shown.",
471
+ keys: ["dependency_install"],
472
+ detail: "The install commands setup would store may have changed since these answers approved them.",
410
473
  });
411
474
  }
412
475
  }
@@ -135,12 +135,40 @@ export function renderSetupRecord(proposal, digest, results) {
135
135
  continue;
136
136
  }
137
137
  const inPlace = r.status === "written" || r.status === "unchanged";
138
+ // BAPI-1679: the stored decision differs from the approved one, so "in place" would be false.
139
+ if (r.key === "epic_branch_ci" && inPlace && r.reason !== undefined) {
140
+ lines.push(`| ${r.key} | recorded ${String(r.read_back?.decision)} | ${r.target} | ${r.reason.replace(/\|/g, "\\|")} |`);
141
+ continue;
142
+ }
138
143
  const shown = inPlace ? "in place" : r.status;
139
144
  const target = inPlace ? proposal?.actions.find((a) => a.key === r.key)?.effect?.target ?? r.target : r.target;
140
145
  const shownDetail = inPlace ? "" : detail;
141
146
  lines.push(`| ${r.key} | ${shown} | ${target} | ${shownDetail.replace(/\|/g, "\\|")} |`);
142
147
  }
143
148
  lines.push("");
149
+ // BAPI-1677: the approved install commands, once they are confirmed in place. The text comes
150
+ // from the approved proposal, so a replay that finds them unchanged leaves the record alone.
151
+ // An install that worked is not a proven test command, and a failed trial is not a failed install.
152
+ const installResult = results.find((r) => r.key === "dependency_install");
153
+ const installValue = proposal?.actions.find((a) => a.key === "dependency_install")?.effect?.params?.value;
154
+ if (Array.isArray(installValue) && (installResult?.status === "written" || installResult?.status === "unchanged")) {
155
+ lines.push("## Install commands", "");
156
+ if (installValue.length === 0)
157
+ lines.push("None declared. Workers and the test trial run no declared install, and managed CI uses its normal toolchain install.");
158
+ for (const entry of installValue) {
159
+ lines.push(`- \`${entry.argv.join(" ").replace(/`/g, "'")}\` in \`${entry.cwd}\`; runs in each fresh worker worktree, and again only when ${entry.lockfiles.join(", ")} changes.`);
160
+ }
161
+ lines.push("");
162
+ }
163
+ const trial = results.find((r) => r.key === "test_command");
164
+ const ran = trial?.read_back?.ran;
165
+ if (Array.isArray(ran) && (trial?.status === "written" || trial?.status === "unchanged")) {
166
+ // The command the server reports, never the one Bridge expected to try.
167
+ lines.push("## Test trial", "", `Passed. The proven test command is ${ran.map((c) => `\`${c.replace(/`/g, "'")}\``).join(", ")}.`, "");
168
+ }
169
+ else if (trial?.status === "failed" && trial.phase != null) {
170
+ lines.push("## Test trial", "", "Did not pass, so no test command was stored. The install commands are unaffected. Run setup again to try once more.", "");
171
+ }
144
172
  return lines.join("\n");
145
173
  }
146
174
  /**
@@ -170,8 +198,9 @@ function describeDecision(decision) {
170
198
  case "selection": return decision.ids.length === 0 ? "none selected" : `${decision.ids.length} selected`;
171
199
  case "reference": return decision.reference.kind === "env" ? `reference env:${decision.reference.name}` : `reference credential_store:${decision.reference.target}`;
172
200
  case "command": return "owner command";
173
- case "epic_server_sfcc": return "sfcc_shared_active";
201
+ case "epic_server_sfcc": return decision.value.mode;
174
202
  case "profile": return `profile ${decision.name}`;
203
+ case "dependency_install_entries": return decision.entries.length === 0 ? "empty install list" : `${decision.entries.length} install command${decision.entries.length === 1 ? "" : "s"} given`;
175
204
  }
176
205
  }
177
206
  async function writeSetupRecord(input, results, writer) {