@bridge_gpt/mcp-server 0.2.73 → 0.2.75

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 (123) hide show
  1. package/README.md +14 -7
  2. package/build/agent-launchers/claude-executor-adapter.js +12 -0
  3. package/build/agent-launchers/prompt.js +9 -21
  4. package/build/agents.generated.js +4 -4
  5. package/build/authored-plan.js +542 -0
  6. package/build/bridge-config.js +7 -1
  7. package/build/bridge-permissions.js +11 -0
  8. package/build/command-provisioning.js +4 -3
  9. package/build/commands.generated.js +6 -6
  10. package/build/conductor/bridge-api-client.js +692 -47
  11. package/build/conductor/command-drift.js +1 -1
  12. package/build/conductor/declared-extras.js +335 -0
  13. package/build/conductor/doctor.js +2 -0
  14. package/build/conductor/driver-pass-output.js +104 -0
  15. package/build/conductor/driver-pass.js +571 -0
  16. package/build/conductor/epic-branch-ci-inspection.js +61 -16
  17. package/build/conductor/epic-implementer-cli.js +370 -93
  18. package/build/conductor/epic-server-sfcc-upload.js +1567 -0
  19. package/build/conductor/epic-server-sfcc.js +58 -80
  20. package/build/conductor/epic-server.js +57 -4
  21. package/build/conductor/gate-discovery.js +253 -13
  22. package/build/conductor/gate-settings-review.js +58 -25
  23. package/build/conductor/launch-plan.js +58 -12
  24. package/build/conductor/open-decision-phrases.js +50 -0
  25. package/build/conductor/prerequisite-inputs.js +181 -14
  26. package/build/connect-github-api.js +18 -0
  27. package/build/connect-github.js +35 -18
  28. package/build/credential-delivery.js +280 -0
  29. package/build/credential-launch-safety.js +142 -0
  30. package/build/credential-materialization.js +91 -16
  31. package/build/credential-references-node-deps.js +29 -0
  32. package/build/credential-references.js +1394 -0
  33. package/build/credential-references.test-fixtures.js +211 -0
  34. package/build/credential-scan-conventions.js +145 -0
  35. package/build/credential-scan.js +517 -0
  36. package/build/credential-store.js +50 -0
  37. package/build/credentials-cli.js +252 -3
  38. package/build/dependency-install-declarations.js +47 -1
  39. package/build/docs.generated.js +8 -1
  40. package/build/doctor.js +41 -0
  41. package/build/drive-epic.js +684 -49
  42. package/build/epic-branch-ci-summary.js +18 -1
  43. package/build/epic-capability-statement.js +71 -3
  44. package/build/epic-ci-workflow-drift.js +52 -13
  45. package/build/epic-ci-workflow-install.js +31 -6
  46. package/build/epic-ci-workflow-v3.js +273 -0
  47. package/build/epic-ci-workflow.js +129 -7
  48. package/build/epic-implementer-bin.js +288 -83
  49. package/build/epic-implementer-bundle-cli.js +61 -0
  50. package/build/epic-implementer-claude-hook-bin.js +1 -1
  51. package/build/epic-implementer-env.js +3 -4
  52. package/build/epic-integration-pr.js +5 -2
  53. package/build/epic-launch-context.js +102 -7
  54. package/build/epic-server-record.js +30 -15
  55. package/build/executor/completion-contract.js +24 -1
  56. package/build/executor/credential-delivery-step.js +168 -0
  57. package/build/executor/deps.js +3 -1
  58. package/build/executor/env.js +39 -1
  59. package/build/executor/epic-server-context.js +23 -7
  60. package/build/executor/gate-qualification-job.js +193 -23
  61. package/build/executor/gate-qualification-tests-ran.js +232 -0
  62. package/build/executor/guarded-fast-forward-push.js +13 -8
  63. package/build/executor/job-runner.js +167 -738
  64. package/build/executor/job-type-wrappers.js +734 -0
  65. package/build/executor/permissions.js +85 -3
  66. package/build/executor/preflight.js +6 -2
  67. package/build/executor/process-containment.js +8 -1
  68. package/build/executor/prompt-spec.js +37 -3
  69. package/build/executor/required-verification.js +28 -2
  70. package/build/executor/runner.js +4 -1
  71. package/build/executor/types.js +9 -0
  72. package/build/executor/worker-database.js +6 -1
  73. package/build/executor/worker-guard-hook.js +24 -2
  74. package/build/executor-launch.js +4 -2
  75. package/build/generated/ticket-status.js +20 -0
  76. package/build/git-exclude-lock.js +187 -0
  77. package/build/index.js +589 -326
  78. package/build/install-bridge-conductor-answers.js +112 -22
  79. package/build/install-bridge-conductor-apply.js +38 -1
  80. package/build/install-bridge-conductor-assessment.js +482 -53
  81. package/build/install-bridge-conductor-compact.js +29 -2
  82. package/build/install-bridge-conductor-contracts.js +10 -1
  83. package/build/install-bridge-conductor-gate.js +379 -89
  84. package/build/install-bridge-conductor-setup.js +46 -8
  85. package/build/install-bridge-conductor-trial-report.js +170 -0
  86. package/build/install-bridge-conductor.js +925 -141
  87. package/build/install-bridge.js +88 -11
  88. package/build/install-doctor.js +38 -8
  89. package/build/install-sfcc-detection.js +120 -0
  90. package/build/install-sfcc-setup.js +185 -0
  91. package/build/mcp-grant-candidates.js +108 -96
  92. package/build/mcp-invoke.js +168 -4
  93. package/build/mcp-provisioning.js +21 -4
  94. package/build/mcp-server-invocation.js +13 -0
  95. package/build/merge-workflow-install.js +9 -1
  96. package/build/pipelines.generated.js +8 -7
  97. package/build/plan-generation.js +17 -0
  98. package/build/plane/status.js +8 -2
  99. package/build/printed-remedy-commands.js +59 -0
  100. package/build/project-root.js +40 -0
  101. package/build/readme.generated.js +1 -1
  102. package/build/repository-state-paths.js +5 -2
  103. package/build/repository-toolchains.js +16 -7
  104. package/build/scripts/saved-commands-config-field-driver.js +65 -0
  105. package/build/setup-epic.js +126 -16
  106. package/build/sfcc/credentials.js +3 -2
  107. package/build/sfcc/hostname.js +98 -2
  108. package/build/sfcc/tool-wrapper.js +6 -95
  109. package/build/start-tickets.js +193 -29
  110. package/build/test-support/executor-source-files.js +200 -0
  111. package/build/testing-config-client.js +25 -2
  112. package/build/third-party-mcp-targets.js +35 -4
  113. package/build/v2-readiness-requirements.js +5 -1
  114. package/build/version.generated.js +3 -3
  115. package/build/with-credentials.js +208 -0
  116. package/build/worker-guard-hook-bin.js +2 -2
  117. package/build/worktree-credential-delivery.js +340 -0
  118. package/docs/EPIC-IMPLEMENTER.md +4 -4
  119. package/docs/install/github-app.md +79 -92
  120. package/package.json +1 -1
  121. package/build/conductor/epic-reconcile.js +0 -603
  122. package/build/conductor/epic-runtime.js +0 -2020
  123. package/build/conductor/epic-state.js +0 -774
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Best-effort evidence that a gate-qualification command executed tests (BAPI-1698).
3
+ *
4
+ * WHY THIS MODULE EXISTS. A trial run that "passed" because its command was
5
+ * `echo ok`, `pytest --collect-only`, or a runner that found nothing to run tells
6
+ * the owner their gate works when it does not. This module looks for PLAIN signs
7
+ * that an exit-zero command executed no tests, so the qualification can report
8
+ * the qualification-only `no_tests_ran` instead of a pass.
9
+ *
10
+ * It is deliberately conservative. It is not proof that tests ran, and it never
11
+ * tries to be: every unfamiliar, quiet, mixed, or ambiguous case answers `ran`,
12
+ * so a working command is never refused for being unusual. In particular:
13
+ *
14
+ * - argv rules cover a small fixed set of non-test utilities (`echo`, `true`,
15
+ * `ls`, `printf`, `:`) and the listing, collection, help, and version modes of
16
+ * a few well-known runners;
17
+ * - a package-manager `test` script is inspected exactly ONE level deep, and a
18
+ * script with shell control (`&&`, `;`, `|`, quoting, substitution) is `ran`;
19
+ * - an output summary counts only when it has a known runner's own structure
20
+ * with a whole-number count, and any positive execution count wins.
21
+ *
22
+ * Nothing here runs a command, reads beyond the checkout's root `package.json`,
23
+ * or keeps more output than the caller already holds. The output and argv it sees
24
+ * are local only; it returns a closed token and nothing else.
25
+ */
26
+ import path from "node:path";
27
+ /** Plainly non-test programs. Exiting zero says nothing about tests. */
28
+ const NON_TEST_UTILITIES = new Set(["echo", "true", "ls", "printf", ":"]);
29
+ /** Interpreters that may run pytest as `-m pytest`. */
30
+ const PYTHON_RE = /^python(?:3(?:\.\d+)?)?(?:\.exe)?$/;
31
+ const PYTEST_NON_EXECUTING = new Set(["--collect-only", "--co", "--help", "-h", "--version", "-V"]);
32
+ const JEST_NON_EXECUTING = new Set(["--listTests", "--help", "-h", "--version", "-v"]);
33
+ const VITEST_NON_EXECUTING = new Set(["list", "--help", "-h", "--version", "-v"]);
34
+ const MOCHA_NON_EXECUTING = new Set(["--help", "-h", "--version", "-V", "--dry-run"]);
35
+ const PACKAGE_MANAGERS = new Set(["npm", "yarn", "pnpm"]);
36
+ /** Shell control a script may contain. Its presence makes the script `ran`. */
37
+ const SHELL_CONTROL_RE = /&&|;|\||\|\||[`$'"<>()\\]/;
38
+ function baseName(program) {
39
+ return path.basename(program.replace(/\\/g, "/"));
40
+ }
41
+ /**
42
+ * Strip one leading launcher that only resolves a program (`npx`, `uv run`,
43
+ * `poetry run`, `pipenv run`, `pnpm exec`, `yarn exec`), with its own flags.
44
+ */
45
+ function stripLauncher(argv) {
46
+ if (argv.length === 0)
47
+ return argv;
48
+ const first = baseName(argv[0]);
49
+ let rest = null;
50
+ if (first === "npx")
51
+ rest = argv.slice(1);
52
+ else if ((first === "uv" || first === "poetry" || first === "pipenv") && argv[1] === "run")
53
+ rest = argv.slice(2);
54
+ else if ((first === "pnpm" || first === "yarn") && argv[1] === "exec")
55
+ rest = argv.slice(2);
56
+ if (rest === null)
57
+ return argv;
58
+ let index = 0;
59
+ while (index < rest.length && rest[index].startsWith("-"))
60
+ index += 1;
61
+ return rest.slice(index);
62
+ }
63
+ /**
64
+ * Classify a command's argv on its own. `no_tests` only for a plain non-test
65
+ * utility or a well-known runner in a mode that executes no test.
66
+ */
67
+ export function classifyArgv(argv) {
68
+ const resolved = stripLauncher(argv);
69
+ if (resolved.length === 0)
70
+ return "ran";
71
+ const program = baseName(resolved[0]);
72
+ const args = resolved.slice(1);
73
+ if (NON_TEST_UTILITIES.has(program))
74
+ return "no_tests";
75
+ const any = (set) => args.some((arg) => set.has(arg));
76
+ if (program === "pytest" || program === "py.test")
77
+ return any(PYTEST_NON_EXECUTING) ? "no_tests" : "ran";
78
+ if (PYTHON_RE.test(program) && args[0] === "-m" && args[1] === "pytest") {
79
+ return args.slice(2).some((arg) => PYTEST_NON_EXECUTING.has(arg)) ? "no_tests" : "ran";
80
+ }
81
+ if (program === "jest")
82
+ return any(JEST_NON_EXECUTING) ? "no_tests" : "ran";
83
+ if (program === "vitest")
84
+ return any(VITEST_NON_EXECUTING) ? "no_tests" : "ran";
85
+ if (program === "mocha")
86
+ return any(MOCHA_NON_EXECUTING) ? "no_tests" : "ran";
87
+ return "ran";
88
+ }
89
+ /**
90
+ * True when `argv` runs the package `test` script through npm, yarn, or pnpm:
91
+ * `npm test`, `npm t`, `npm run test`, `yarn test`, `yarn run test`, `pnpm test`,
92
+ * `pnpm run test`. Returns the arguments forwarded after `--`, or null.
93
+ */
94
+ function packageTestInvocation(argv) {
95
+ if (argv.length < 2)
96
+ return null;
97
+ const manager = baseName(argv[0]);
98
+ if (!PACKAGE_MANAGERS.has(manager))
99
+ return null;
100
+ let index = 1;
101
+ if (argv[index] === "run" || argv[index] === "run-script")
102
+ index += 1;
103
+ const script = argv[index];
104
+ if (script !== "test" && !(manager === "npm" && script === "t" && index === 1))
105
+ return null;
106
+ const rest = argv.slice(index + 1);
107
+ if (rest.length === 0)
108
+ return { forwarded: [] };
109
+ // Only a plain `-- args` tail is understood; anything else is not ours to read.
110
+ if (rest[0] !== "--")
111
+ return manager === "npm" ? null : { forwarded: [...rest] };
112
+ return { forwarded: rest.slice(1) };
113
+ }
114
+ /**
115
+ * Classify a package `test` script exactly one level deep. Shell control makes
116
+ * it `ran`; a nested script (`npm run test:unit`) is not followed and is `ran`.
117
+ */
118
+ function classifyPackageScript(script, forwarded) {
119
+ const trimmed = script.trim();
120
+ if (trimmed.length === 0 || SHELL_CONTROL_RE.test(trimmed))
121
+ return "ran";
122
+ const tokens = trimmed.split(/\s+/);
123
+ if (PACKAGE_MANAGERS.has(baseName(tokens[0])))
124
+ return "ran";
125
+ return classifyArgv([...tokens, ...forwarded]);
126
+ }
127
+ // ---------------------------------------------------------------------------
128
+ // Output summaries
129
+ // ---------------------------------------------------------------------------
130
+ /** Known runners' own "nothing ran" summary lines. Anchored; whole counts only. */
131
+ const ZERO_TEST_SUMMARIES = [
132
+ // pytest
133
+ /^=+ no tests ran(?: in \d+(?:\.\d+)?s)? =+$/m,
134
+ /^collected 0 items\s*$/m,
135
+ // unittest
136
+ /^Ran 0 tests in \d+(?:\.\d+)?s$/m,
137
+ // jest / vitest with pass-with-no-tests
138
+ /^No tests found, exiting with code 0$/m,
139
+ /^No test files found, exiting with code 0$/m,
140
+ /^Tests:\s+0 total$/m,
141
+ // mocha
142
+ /^\s*0 passing(?: \(\d+m?s\))?\s*$/m,
143
+ // node:test (TAP)
144
+ /^# tests 0$/m,
145
+ ];
146
+ /** Recognized positive execution counts. Any one of these means tests ran. */
147
+ const POSITIVE_COUNTS = [
148
+ /\b[1-9]\d* (?:passed|failed|errors?|xfailed|xpassed)\b/,
149
+ /^Ran [1-9]\d* tests? in /m,
150
+ /^Tests:\s+.*\b[1-9]\d* (?:passed|failed|total)\b/m,
151
+ /^\s*[1-9]\d* (?:passing|failing|pending)\b/m,
152
+ /^# (?:tests|pass|fail) [1-9]\d*$/m,
153
+ /^ok\s+\S+\s+\d/m,
154
+ /^--- (?:PASS|FAIL): /m,
155
+ /^collected [1-9]\d* items?\b/m,
156
+ ];
157
+ const GO_NO_TEST_FILES_RE = /^\?\s+\S+\s+\[no test files\]$/;
158
+ function isGoTest(argv) {
159
+ const resolved = stripLauncher(argv);
160
+ return resolved.length >= 2 && baseName(resolved[0]) === "go" && resolved[1] === "test";
161
+ }
162
+ /**
163
+ * Classify the output tail. `no_tests` only when a known runner's own zero-test
164
+ * summary is present and no positive execution count is; `go test` counts only
165
+ * when EVERY nonblank line reports no test files.
166
+ */
167
+ export function classifyOutput(argv, output) {
168
+ if (POSITIVE_COUNTS.some((re) => re.test(output)))
169
+ return "ran";
170
+ if (isGoTest(argv)) {
171
+ const lines = output.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
172
+ return lines.length > 0 && lines.every((line) => GO_NO_TEST_FILES_RE.test(line)) ? "no_tests" : "ran";
173
+ }
174
+ return ZERO_TEST_SUMMARIES.some((re) => re.test(output)) ? "no_tests" : "ran";
175
+ }
176
+ /**
177
+ * The pure classifier: argv first (including a resolved package `test` script,
178
+ * one level deep), then the output tail. Never throws; defaults to `ran`.
179
+ */
180
+ export function assessTestsRan(input) {
181
+ try {
182
+ if (classifyArgv(input.argv) === "no_tests")
183
+ return "no_tests";
184
+ const invocation = packageTestInvocation(input.argv);
185
+ if (invocation !== null && typeof input.packageTestScript === "string") {
186
+ if (classifyPackageScript(input.packageTestScript, invocation.forwarded) === "no_tests")
187
+ return "no_tests";
188
+ }
189
+ return classifyOutput(input.argv, input.output);
190
+ }
191
+ catch {
192
+ return "ran";
193
+ }
194
+ }
195
+ /**
196
+ * The checkout's root `package.json` `test` script when `argv` runs it through
197
+ * npm, yarn, or pnpm; `null` on any read or parse error, a missing script, or an
198
+ * unusable shape. Never throws.
199
+ */
200
+ export async function resolvePackageTestScript(argv, checkoutDir, readFile) {
201
+ if (packageTestInvocation(argv) === null)
202
+ return null;
203
+ try {
204
+ const parsed = JSON.parse(await readFile(path.join(checkoutDir, "package.json")));
205
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
206
+ return null;
207
+ const scripts = parsed.scripts;
208
+ if (typeof scripts !== "object" || scripts === null || Array.isArray(scripts))
209
+ return null;
210
+ const test = scripts.test;
211
+ return typeof test === "string" ? test : null;
212
+ }
213
+ catch {
214
+ return null;
215
+ }
216
+ }
217
+ /**
218
+ * The checkout-reading adapter: resolves the package `test` script (when argv
219
+ * runs one) and classifies. Any read or parse failure falls back to classifying
220
+ * without the script, which can only answer `ran` for the indirection itself.
221
+ * Never throws.
222
+ */
223
+ export async function assessTestsRanInCheckout(input) {
224
+ let packageTestScript = null;
225
+ try {
226
+ packageTestScript = await resolvePackageTestScript(input.argv, input.checkoutDir, input.readFile);
227
+ }
228
+ catch {
229
+ packageTestScript = null;
230
+ }
231
+ return assessTestsRan({ argv: input.argv, output: input.output, packageTestScript });
232
+ }
@@ -12,9 +12,14 @@ export function isSafePublicationBranch(branch) {
12
12
  /** No command text, remote URL, or environment escapes this closed outcome. */
13
13
  export async function guardedFastForwardPush(input) {
14
14
  const refuse = (reason) => ({ status: "refused", reason });
15
- if (!isSafePublicationBranch(input.branch) || !SHA.test(input.expectedOriginSha) ||
15
+ const creating = input.expectedOriginSha === null;
16
+ // Ordinary publication needs a remote SHA and no create-only input; create-only needs a local start SHA and no remote SHA.
17
+ const baseSha = creating ? input.createOnly?.startSha : input.expectedOriginSha;
18
+ if (!isSafePublicationBranch(input.branch) || baseSha === undefined || baseSha === null || !SHA.test(baseSha) ||
19
+ (creating ? input.createOnly === undefined : input.createOnly !== undefined) ||
16
20
  input.trustedExcludedShas?.some(sha => !SHA.test(sha)) ||
17
- (input.candidateSha !== undefined && (!SHA.test(input.candidateSha) || input.candidateSha === input.expectedOriginSha)))
21
+ (creating && input.candidateSha === undefined) ||
22
+ (input.candidateSha !== undefined && (!SHA.test(input.candidateSha) || input.candidateSha.toLowerCase() === baseSha.toLowerCase())))
18
23
  return refuse("invalid_input");
19
24
  let timedOut = false;
20
25
  const git = async (args) => {
@@ -36,10 +41,10 @@ export async function guardedFastForwardPush(input) {
36
41
  const candidate = head.stdout.trim().toLowerCase();
37
42
  if (head.exitCode !== 0 || !SHA.test(candidate))
38
43
  return refuse("ancestry_unknown");
39
- if (candidate === input.expectedOriginSha.toLowerCase() ||
44
+ if (candidate === baseSha.toLowerCase() ||
40
45
  (input.candidateSha !== undefined && candidate !== input.candidateSha.toLowerCase()))
41
46
  return refuse("invalid_input");
42
- const ancestor = await git(["merge-base", "--is-ancestor", input.expectedOriginSha, "HEAD"]);
47
+ const ancestor = await git(["merge-base", "--is-ancestor", baseSha, "HEAD"]);
43
48
  if (ancestor.exitCode === 1)
44
49
  return refuse("not_fast_forward");
45
50
  if (ancestor.exitCode !== 0)
@@ -49,7 +54,7 @@ export async function guardedFastForwardPush(input) {
49
54
  (await git(["merge-base", "--is-ancestor", sha, "HEAD"])).exitCode !== 0)
50
55
  return refuse("range_unreadable");
51
56
  }
52
- const range = await git(["rev-list", "HEAD", `^${input.expectedOriginSha}`, ...(input.trustedExcludedShas ?? []).map(sha => `^${sha}`)]);
57
+ const range = await git(["rev-list", "HEAD", `^${baseSha}`, ...(input.trustedExcludedShas ?? []).map(sha => `^${sha}`)]);
53
58
  const commits = range.stdout.trim().split(/\s+/);
54
59
  if (range.exitCode !== 0 || commits.length === 0 || commits.some(sha => !SHA.test(sha)))
55
60
  return refuse("range_unreadable");
@@ -105,7 +110,7 @@ export async function guardedFastForwardPush(input) {
105
110
  return refuse("timeout");
106
111
  const destination = `refs/heads/${input.branch}`;
107
112
  const push = await git(["push", "--no-verify", "--porcelain",
108
- `--force-with-lease=${destination}:${input.expectedOriginSha}`, "origin", `HEAD:${destination}`]);
113
+ `--force-with-lease=${destination}:${creating ? "" : baseSha}`, "origin", `HEAD:${destination}`]);
109
114
  const text = `${push.stdout}\n${push.stderr}`;
110
115
  if (timedOut || push.exitCode === 124 || /timed out|timeout/i.test(text))
111
116
  return refuse("timeout");
@@ -117,11 +122,11 @@ export async function guardedFastForwardPush(input) {
117
122
  return refuse("remote_rejected");
118
123
  const update = push.stdout.split("\n").some(line => {
119
124
  const parts = line.split("\t");
120
- return parts[0] === " " && parts[1] === `HEAD:${destination}`;
125
+ return parts[0] === (creating ? "*" : " ") && parts[1] === `HEAD:${destination}`;
121
126
  });
122
127
  if (!update)
123
128
  return refuse("lease_rejected");
124
- return { status: "published", from_sha: input.expectedOriginSha.toLowerCase(), to_sha: candidate };
129
+ return { status: "published", from_sha: baseSha.toLowerCase(), to_sha: candidate };
125
130
  }
126
131
  catch {
127
132
  return refuse(timedOut || input.remainingMs() <= 0 ? "timeout" : "remote_rejected");