@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
@@ -1047,6 +1047,10 @@ export const EPIC_BRANCH_RULES_REASONS = [
1047
1047
  "approvals_required",
1048
1048
  "approvals_not_required",
1049
1049
  "no_rules_apply",
1050
+ // Additive closed token: GitHub's definitive "your plan has no rulesets / branch
1051
+ // protection here" answer. It is confirmed absence of applicable rules, unlike
1052
+ // the other non-200 reasons, which are uncertainty.
1053
+ "plan_unavailable",
1050
1054
  ];
1051
1055
  /** Closed reason tokens for {@link assessApprovalExemptionScope} / {@link applyApprovalExemption}. */
1052
1056
  export const EXEMPTION_REASONS = [
@@ -1089,7 +1093,16 @@ function encodeBranchPath(branch) {
1089
1093
  return branch.split("/").map(encodeURIComponent).join("/");
1090
1094
  }
1091
1095
  const GH_JSON_HEADERS = ["-H", "Accept: application/vnd.github+json", "-H", "X-GitHub-Api-Version: 2022-11-28"];
1092
- /** Run `gh api ...` and parse JSON. Output text is inspected for status only and never returned. */
1096
+ /**
1097
+ * The one definitive plan-limit reply: HTTP 403 whose message, right after the
1098
+ * `gh: ` wrapper at the very start of stderr, begins with this text. Anchored so
1099
+ * a bare 403 or an unrelated "upgrade" message never matches.
1100
+ */
1101
+ const PLAN_LIMIT_STDERR_RE = /^\s*gh: Upgrade to GitHub Pro or make this repository public/;
1102
+ /**
1103
+ * Run `gh api ...` and parse JSON. Output text is inspected for the HTTP status and
1104
+ * the exact plan-limit message condition only, and is never returned.
1105
+ */
1093
1106
  async function ghApiJson(run, args, input) {
1094
1107
  let result;
1095
1108
  try {
@@ -1104,6 +1117,9 @@ async function ghApiJson(run, args, input) {
1104
1117
  const err = typeof result.stderr === "string" ? result.stderr : "";
1105
1118
  if (/HTTP 404\b/.test(err))
1106
1119
  return { ok: false, reason: "not_found" };
1120
+ if (/HTTP 403\b/.test(err) && PLAN_LIMIT_STDERR_RE.test(err) && !/HTTP (?:401|404|500)\b/.test(err)) {
1121
+ return { ok: false, reason: "plan_unavailable" };
1122
+ }
1107
1123
  if (/HTTP 401\b|gh auth login|not logged in|authentication required/i.test(err)) {
1108
1124
  return { ok: false, reason: "gh_unauthenticated" };
1109
1125
  }
@@ -1197,6 +1213,8 @@ export async function readDefaultBranchClassicContextViaGh(run, ownerRepo) {
1197
1213
  const branchPath = encodeBranchPath(defaultBranch);
1198
1214
  const prot = await ghApiJson(run, [`repos/${ownerRepo}/branches/${branchPath}/protection`]);
1199
1215
  if (!prot.ok) {
1216
+ if (prot.reason === "plan_unavailable")
1217
+ return { defaultBranch, approvals: "no", count: null };
1200
1218
  if (prot.reason !== "not_found")
1201
1219
  return unknown;
1202
1220
  const exists = await branchExists(run, ownerRepo, defaultBranch);
@@ -1243,9 +1261,12 @@ export async function readDefaultBranchRequiredChecksViaGh(run, ownerRepo, known
1243
1261
  if (!validBranch(defaultBranch))
1244
1262
  return { status: "unknown", reason: "invalid_input" };
1245
1263
  const rules = await readBranchRules(run, ownerRepo, defaultBranch);
1246
- if (!rules.ok)
1264
+ // A plan-limited source is an empty source, judged independently of the other.
1265
+ const rulesPlanLimited = !rules.ok && rules.reason === "plan_unavailable";
1266
+ if (!rules.ok && !rulesPlanLimited) {
1247
1267
  return { status: "unknown", reason: rules.reason };
1248
- const checks = new Set(rules.rules.statusChecks);
1268
+ }
1269
+ const checks = new Set(rules.ok ? rules.rules.statusChecks : []);
1249
1270
  const protection = await ghApiJson(run, [
1250
1271
  `repos/${ownerRepo}/branches/${encodeBranchPath(defaultBranch)}/protection`,
1251
1272
  ]);
@@ -1274,6 +1295,9 @@ export async function readDefaultBranchRequiredChecksViaGh(run, ownerRepo, known
1274
1295
  }
1275
1296
  }
1276
1297
  }
1298
+ else if (protection.reason === "plan_unavailable") {
1299
+ // Empty source; the rules source (if readable) already supplied its checks.
1300
+ }
1277
1301
  else if (protection.reason === "not_found") {
1278
1302
  // A 404 can mean "no classic protection" or "cannot see it": only a branch
1279
1303
  // proven visible makes it the former.
@@ -1318,8 +1342,11 @@ function rulesCouldNotTell(branch, reason) {
1318
1342
  * a branch with that name will be returned"
1319
1343
  * (https://docs.github.com/en/rest/repos/rules#get-rules-for-a-branch). That is
1320
1344
  * documented but not yet live-verified (Bridge-GPT/bridge-api is a private
1321
- * repository whose plan lacks rulesets), hence `inferred`. A non-200 reply,
1322
- * including the 403 a plan without rulesets returns, stays `could_not_tell`. It also
1345
+ * repository whose plan lacks rulesets), hence `inferred`. The one definitive
1346
+ * exception is the exact plan-limit 403 ("Upgrade to GitHub Pro or make this
1347
+ * repository public"): the plan has no rules, so that is `no` / `exact` with reason
1348
+ * `plan_unavailable`. Every other non-200 reply (a bare 403, permissions, SSO, rate
1349
+ * limit, 500) is uncertainty and stays `could_not_tell`. It also
1323
1350
  * attaches the default branch's classic protection as separately labelled
1324
1351
  * CONTEXT ({@link readDefaultBranchClassicContextViaGh}); that context never
1325
1352
  * changes `approvalsRequired`. Never throws.
@@ -1341,6 +1368,17 @@ export async function readEpicBranchRulesViaGh(run, ownerRepo, branch) {
1341
1368
  }
1342
1369
  async function readEpicBranchRulesOnly(run, ownerRepo, branch) {
1343
1370
  const read = await readBranchRules(run, ownerRepo, branch);
1371
+ if (!read.ok && read.reason === "plan_unavailable") {
1372
+ // Definitive: the plan has no rules to apply. No branch probe is needed.
1373
+ return {
1374
+ branch,
1375
+ approvalsRequired: "no",
1376
+ requiredApprovingReviewCount: null,
1377
+ requiredStatusChecks: [],
1378
+ observationQuality: "exact",
1379
+ reason: "plan_unavailable",
1380
+ };
1381
+ }
1344
1382
  if (!read.ok)
1345
1383
  return rulesCouldNotTell(branch, read.reason);
1346
1384
  const { pullRequestRules, statusChecks } = read.rules;
@@ -1433,8 +1471,12 @@ export async function assessApprovalExemptionScope(run, ownerRepo, branch) {
1433
1471
  if (!validOwnerRepo(ownerRepo) || !validBranch(branch))
1434
1472
  return ineligible("rules_unreadable");
1435
1473
  const read = await readBranchRules(run, ownerRepo, branch);
1436
- if (!read.ok)
1474
+ if (!read.ok) {
1475
+ // A plan without rulesets has no approval rule to exempt; no ruleset details are read.
1476
+ if (read.reason === "plan_unavailable")
1477
+ return ineligible("no_approval_rule");
1437
1478
  return ineligible(read.reason === "malformed_rule" ? "malformed_rule" : "rules_unreadable");
1479
+ }
1438
1480
  const prRules = read.rules.pullRequestRules;
1439
1481
  if (prRules.length === 0)
1440
1482
  return ineligible("no_approval_rule");
@@ -1470,6 +1512,8 @@ function sameList(a, b) {
1470
1512
  * Never attempts a repair. The caller must have the user's explicit consent.
1471
1513
  */
1472
1514
  export async function applyApprovalExemption(run, ownerRepo, branch, assessment) {
1515
+ // Pre-write refusals return attempted:false; once the PUT loop may start, or an
1516
+ // exception is caught, the write is conservatively treated as attempted.
1473
1517
  try {
1474
1518
  if (!assessment ||
1475
1519
  assessment.eligible !== true ||
@@ -1478,35 +1522,36 @@ export async function applyApprovalExemption(run, ownerRepo, branch, assessment)
1478
1522
  !assessment.rulesetIds.every(isNonNegInt) ||
1479
1523
  !validOwnerRepo(ownerRepo) ||
1480
1524
  !validBranch(branch)) {
1481
- return { confirmed: false, reason: "scope_not_eligible" };
1525
+ return { confirmed: false, reason: "scope_not_eligible", attempted: false };
1482
1526
  }
1483
1527
  const before = await readBranchRules(run, ownerRepo, branch);
1484
1528
  if (!before.ok)
1485
- return { confirmed: false, reason: "ruleset_changed" };
1529
+ return { confirmed: false, reason: "ruleset_changed", attempted: false };
1486
1530
  const bodies = [];
1487
1531
  for (const id of assessment.rulesetIds) {
1488
1532
  const check = await checkRuleset(run, ownerRepo, id);
1489
1533
  if (!check.ok)
1490
- return { confirmed: false, reason: "ruleset_changed" };
1534
+ return { confirmed: false, reason: "ruleset_changed", attempted: false };
1491
1535
  bodies.push({ id, body: check.body });
1492
1536
  }
1493
1537
  for (const { id, body } of bodies) {
1494
1538
  const put = await ghApiJson(run, ["--method", "PUT", `repos/${ownerRepo}/rulesets/${id}`, "--input", "-"], JSON.stringify(body));
1495
1539
  if (!put.ok)
1496
- return { confirmed: false, reason: "apply_failed" };
1540
+ return { confirmed: false, reason: "apply_failed", attempted: true };
1497
1541
  }
1498
1542
  const after = await readBranchRules(run, ownerRepo, branch);
1499
1543
  if (!after.ok)
1500
- return { confirmed: false, reason: "verification_failed" };
1501
- if (after.rules.pullRequestRules.length > 0)
1502
- return { confirmed: false, reason: "approvals_still_required" };
1544
+ return { confirmed: false, reason: "verification_failed", attempted: true };
1545
+ if (after.rules.pullRequestRules.length > 0) {
1546
+ return { confirmed: false, reason: "approvals_still_required", attempted: true };
1547
+ }
1503
1548
  if (!sameList(before.rules.statusChecks, after.rules.statusChecks)) {
1504
- return { confirmed: false, reason: "status_checks_changed" };
1549
+ return { confirmed: false, reason: "status_checks_changed", attempted: true };
1505
1550
  }
1506
- return { confirmed: true, reason: "confirmed" };
1551
+ return { confirmed: true, reason: "confirmed", attempted: true };
1507
1552
  }
1508
1553
  catch {
1509
- return { confirmed: false, reason: "verification_failed" };
1554
+ return { confirmed: false, reason: "verification_failed", attempted: true };
1510
1555
  }
1511
1556
  }
1512
1557
  /**
@@ -169,6 +169,13 @@ export function getConductorUsage() {
169
169
  " A worker borrows the epic server at its own head for a bounded turn, then",
170
170
  " releases it with the lease handle acquire printed. A timeout or a missing",
171
171
  " server prints a no_live_server observation for the hand-off; nothing parks.",
172
+ " epic-server sfcc-upload --ticket <KEY> --head <SHA>",
173
+ " epic-server sfcc-upload --full --epic <KEY> --epic-run-id <id> --head <SHA>",
174
+ " epic-server sfcc-upload --check",
175
+ " Uploads committed cartridge files to the run's one shared SFCC code version,",
176
+ " in any epic-server mode (worker: changed files; --full: the driver's whole",
177
+ " tree plus a baseline; --check: read-only readiness). A failure prints a",
178
+ " no_live_server observation for the hand-off; nothing parks.",
172
179
  " prerequisite-inputs --epic-key <KEY> --child <KEY> [--child <KEY> ...] [--json]",
173
180
  " Reads stored ticket descriptions and reports, per child, cached, in_flight,",
174
181
  " scan_needed (with a private scanner input file under",
@@ -183,6 +190,10 @@ export function getConductorUsage() {
183
190
  " Release this session from supervision: done (run terminal) and handoff",
184
191
  " (report published) are checked on the server; owner only on the owner's",
185
192
  " explicit instruction. Changes nothing on the run.",
193
+ " driver-pass --epic-run-id <id> [--ticket-key <key>] [--json]",
194
+ " Read-only: report the driver's clock facts (no-progress time, job pause,",
195
+ " attach window, reconciler liveness) from the server's own clock. Decides",
196
+ " and changes nothing; unreadable facts print as unknown.",
186
197
  " driver-guard The /drive-epic-run Stop hook. Reads hook JSON on stdin, decides locally",
187
198
  " with no network call, always exits 0. Off switch: BRIDGE_EI_DRIVER_GUARD=off.",
188
199
  " declare-blocked --epic-run-id <id> --ticket-key <K>... --entry 1|2|3|4|5|wedge --requirement <text>",
@@ -429,6 +440,8 @@ const VALID_COMMANDS = new Set([
429
440
  "driver-release",
430
441
  "driver-guard",
431
442
  "declare-blocked",
443
+ // BAPI-1682: CLI-only read-only driver clock report — never an MCP tool.
444
+ "driver-pass",
432
445
  // Private, and deliberately ABSENT from the usage text: `__hook-bin` exists as
433
446
  // the bundled-artifact regression guard for BAPI-772 (mirroring `plane
434
447
  // __entrypoint`), not as a supported operator workflow.
@@ -1812,6 +1825,26 @@ export async function runEpicImplementerCli(argv, likelyTestsDeps) {
1812
1825
  }
1813
1826
  return await runDriverReleaseCommand(parsed.argv);
1814
1827
  }
1828
+ case "driver-pass": {
1829
+ // BAPI-1682: CLI-only, read-only, advisory. A module-load failure is
1830
+ // fail-open like the command itself: one fixed line, a full unavailable
1831
+ // result from the dependency-light output module, exit 0.
1832
+ let runDriverPassCommand;
1833
+ try {
1834
+ ({ runDriverPassCommand } = await import("./driver-pass.js"));
1835
+ }
1836
+ catch {
1837
+ console.error("driver-pass could not be loaded; no run state was read.");
1838
+ const { buildUnavailableDriverPassResult, formatDriverPassResult } = await import("./driver-pass-output.js");
1839
+ const runFlag = parsed.argv.indexOf("--epic-run-id");
1840
+ const ref = runFlag >= 0 ? parsed.argv[runFlag + 1] : undefined;
1841
+ const safeRef = typeof ref === "string" && /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(ref) ? ref : "unknown";
1842
+ const result = buildUnavailableDriverPassResult(safeRef, "computation_failed");
1843
+ console.log(parsed.argv.includes("--json") ? JSON.stringify(result) : formatDriverPassResult(result));
1844
+ return 0;
1845
+ }
1846
+ return await runDriverPassCommand(parsed.argv);
1847
+ }
1815
1848
  case "declare-blocked": {
1816
1849
  let runDeclareBlockedCommand;
1817
1850
  try {