@bridge_gpt/mcp-server 0.2.72 → 0.2.73

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 (146) hide show
  1. package/README.md +5 -5
  2. package/build/agent-launchers/claude-executor-adapter.js +3 -0
  3. package/build/agents.generated.js +6 -6
  4. package/build/bridge-permissions.js +27 -0
  5. package/build/ci-system-detection.js +50 -0
  6. package/build/ci-trigger-adapters.js +631 -0
  7. package/build/ci-trigger-install.js +106 -0
  8. package/build/codex-launcher-pin.js +33 -2
  9. package/build/codex-skill-adapter.js +3 -1
  10. package/build/command-host.js +33 -0
  11. package/build/commands.generated.js +7 -6
  12. package/build/conductor/bridge-api-client.js +842 -35
  13. package/build/conductor/bring-up-facts.js +18 -5
  14. package/build/conductor/command-drift-production.js +42 -17
  15. package/build/conductor/command-drift.js +47 -0
  16. package/build/conductor/declare-blocked.js +554 -0
  17. package/build/conductor/doctor.js +106 -21
  18. package/build/conductor/driver-commands.js +141 -0
  19. package/build/conductor/driver-guard.js +277 -0
  20. package/build/conductor/driver-lapse.js +321 -0
  21. package/build/conductor/driver-register.js +176 -0
  22. package/build/conductor/driver-release.js +174 -0
  23. package/build/conductor/driver-session-state.js +315 -0
  24. package/build/conductor/epic-branch-ci-inspection.js +222 -29
  25. package/build/conductor/epic-implementer-cli.js +166 -15
  26. package/build/conductor/epic-server-database.js +162 -0
  27. package/build/conductor/epic-server-guidance.js +278 -0
  28. package/build/conductor/epic-server-journal.js +239 -0
  29. package/build/conductor/epic-server-processes.js +324 -0
  30. package/build/conductor/epic-server-recipe.js +397 -0
  31. package/build/conductor/epic-server-runtime.js +1207 -0
  32. package/build/conductor/epic-server-sfcc.js +107 -0
  33. package/build/conductor/epic-server-state.js +427 -0
  34. package/build/conductor/epic-server.js +594 -0
  35. package/build/conductor/gate-discovery.js +150 -5
  36. package/build/conductor/gate-settings-review.js +224 -4
  37. package/build/conductor/launch-need-probes.js +6 -53
  38. package/build/conductor/launch-plan.js +313 -156
  39. package/build/conductor/prerequisite-inputs.js +879 -45
  40. package/build/conductor/readiness-assessment.js +16 -1
  41. package/build/conductor/readiness-cli.js +20 -9
  42. package/build/conductor/readiness-prerequisites.js +28 -9
  43. package/build/conductor/readiness-sections.js +133 -126
  44. package/build/conductor/readiness.js +1 -1
  45. package/build/conductor/recovery-cli.js +13 -2
  46. package/build/conductor/tools.js +6 -5
  47. package/build/conductor/wait-run-attention.js +2 -2
  48. package/build/conductor/wait-run-cli.js +208 -22
  49. package/build/conductor/worker-database-doctor-inspector.js +33 -2
  50. package/build/conductor/worker-setup-tally.js +27 -0
  51. package/build/credential-store.js +71 -1
  52. package/build/dependency-install-declarations.js +55 -0
  53. package/build/docs.generated.js +2 -2
  54. package/build/doctor.js +54 -3
  55. package/build/drive-epic-help.js +21 -2
  56. package/build/drive-epic.js +1811 -351
  57. package/build/engine-paths.js +20 -0
  58. package/build/epic-branch-ci-summary.js +140 -0
  59. package/build/epic-capability-statement.js +107 -0
  60. package/build/epic-ci-workflow-drift.js +30 -15
  61. package/build/epic-ci-workflow-install.js +110 -42
  62. package/build/epic-ci-workflow-v2.js +274 -0
  63. package/build/epic-ci-workflow.js +38 -12
  64. package/build/epic-implementer-bin.js +2101 -44
  65. package/build/epic-launch-context.js +607 -0
  66. package/build/epic-server-record.js +273 -0
  67. package/build/epic-shared/bridge-client.js +11 -3
  68. package/build/escalation-reachability.js +43 -0
  69. package/build/executor/ci-fix-test-runs.js +334 -0
  70. package/build/executor/completion-contract.js +8 -1
  71. package/build/executor/env.js +59 -22
  72. package/build/executor/epic-server-context.js +141 -0
  73. package/build/executor/gate-qualification-job.js +127 -26
  74. package/build/executor/http-client.js +52 -5
  75. package/build/executor/job-runner.js +423 -69
  76. package/build/executor/observation.js +8 -0
  77. package/build/executor/pre-pr-checks.js +363 -0
  78. package/build/executor/prompt-spec.js +114 -2
  79. package/build/executor/reconcile-overlap-job.js +5 -3
  80. package/build/executor/required-work-diagnostics.js +4 -2
  81. package/build/executor/required-work-ledger.js +936 -38
  82. package/build/executor/results.js +58 -0
  83. package/build/executor/terminal-mutation.js +8 -0
  84. package/build/executor/worker-command.js +72 -3
  85. package/build/executor/worker-database-config.js +281 -0
  86. package/build/executor/worker-database-target.js +16 -12
  87. package/build/executor/worker-database.js +320 -101
  88. package/build/executor/worker-finalization.js +7 -1
  89. package/build/executor/worker-resources.js +25 -3
  90. package/build/executor/worker-verification-guidance.js +18 -3
  91. package/build/executor/worktree.js +20 -1
  92. package/build/executor-launch.js +54 -2
  93. package/build/generated-assets-catalog.js +2 -2
  94. package/build/index.js +664 -335
  95. package/build/init.js +26 -11
  96. package/build/install-bridge-conductor-answers.js +465 -0
  97. package/build/install-bridge-conductor-apply.js +259 -0
  98. package/build/install-bridge-conductor-assessment.js +895 -0
  99. package/build/install-bridge-conductor-compact.js +161 -0
  100. package/build/install-bridge-conductor-contracts.js +63 -0
  101. package/build/install-bridge-conductor-gate.js +1197 -196
  102. package/build/install-bridge-conductor-setup.js +535 -79
  103. package/build/install-bridge-conductor.js +2885 -560
  104. package/build/install-bridge.js +199 -21
  105. package/build/install-maintenance.js +26 -3
  106. package/build/launcher-config-inspection.js +162 -1
  107. package/build/mcp-grant-candidates.js +767 -0
  108. package/build/mcp-grant-doctor.js +63 -0
  109. package/build/mcp-grant.js +288 -0
  110. package/build/mcp-host-targets.js +8 -0
  111. package/build/mcp-identity.js +23 -0
  112. package/build/mcp-invoke.js +126 -13
  113. package/build/mcp-presets.js +107 -0
  114. package/build/mcp-provisioning.js +134 -2
  115. package/build/mcp-registration-doctor.js +31 -2
  116. package/build/mcp-server-invocation.js +6 -1
  117. package/build/merge-workflow-install.js +234 -109
  118. package/build/pipelines.generated.js +5 -5
  119. package/build/plan-discovery.js +97 -4
  120. package/build/plan-execution-ledger.js +100 -7
  121. package/build/plan-generation-io.js +262 -0
  122. package/build/plan-generation.js +424 -0
  123. package/build/plane/build-freshness.js +6 -1
  124. package/build/plane/cli.js +75 -9
  125. package/build/plane/plane-freshness.js +17 -0
  126. package/build/plane/preflight.js +50 -10
  127. package/build/plane/shutdown.js +19 -0
  128. package/build/plane/terminal-run-cleanup.js +18 -4
  129. package/build/printed-remedy-commands.js +206 -12
  130. package/build/readiness-check.js +77 -0
  131. package/build/readiness-prerequisites.generated.js +122 -14
  132. package/build/readme.generated.js +1 -1
  133. package/build/repository-state-paths.js +38 -0
  134. package/build/run-unit-tests-launcher.js +8 -1
  135. package/build/setup-epic.js +1190 -196
  136. package/build/setup-progress.js +44 -0
  137. package/build/setup-question.js +122 -4
  138. package/build/third-party-mcp-targets.js +30 -0
  139. package/build/ticket-delivery-enrollment.js +9 -0
  140. package/build/upgrade-cli.js +85 -2
  141. package/build/v2-readiness-requirements.js +28 -1
  142. package/build/version.generated.js +3 -3
  143. package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
  144. package/docs/epic-implementer/getting-started.md +3 -1
  145. package/docs/epic-implementer/self-hosting.md +14 -1
  146. package/package.json +2 -2
@@ -0,0 +1,106 @@
1
+ /**
2
+ * BAPI-1654 — deliver an approved CI trigger edit as a pull request.
3
+ *
4
+ * A thin wrapper over the setup-PR engine ({@link installArtifactSet}): one
5
+ * artifact (the edited workflow), one stable CI-only managed branch, and a
6
+ * deterministic pull request the owner reviews and merges. The engine already
7
+ * does everything else: it reads the default branch at the snapshot head,
8
+ * reconciles an open pull request or a pushed managed branch before building
9
+ * anything (so a retry never opens a second one), builds in a detached
10
+ * temporary worktree, pushes only the managed branch, and never merges.
11
+ *
12
+ * The existing-file mode needs no new engine code. The artifact's `classify`
13
+ * authorizes replacing the file only when the default branch holds exactly the
14
+ * approved source bytes and the adapter reproduces and re-validates the same
15
+ * edit from them. The file already holding the edited bytes is `identical`
16
+ * (the change is merged). Any other content is a conflict, refused untouched.
17
+ * An open pull request must change only this one file and carry exactly the
18
+ * edited bytes, so its whole diff is the trigger insertion.
19
+ */
20
+ import { classifyEpicPullRequestTrigger } from "./conductor/epic-branch-ci-inspection.js";
21
+ import { GITHUB_ACTIONS_TRIGGER_ADAPTER, sha256Hex, } from "./ci-trigger-adapters.js";
22
+ import { installArtifactSet, } from "./merge-workflow-install.js";
23
+ /** The CI-only managed branch. Distinct from every setup branch. */
24
+ export const CI_TRIGGER_BRANCH = "bridge/epic-ci-trigger";
25
+ export function ciTriggerCommitSubject(path) {
26
+ return `ci: also run ${path} on pull requests into epic branches`;
27
+ }
28
+ /** The pull request body: what changes, what does not, and what the owner does. */
29
+ export function renderCiTriggerPrBody(edit) {
30
+ const before = edit.branchesBefore.map((b) => `\`${b}\``).join(", ");
31
+ return [
32
+ `This pull request adds \`'epic/**'\` to the \`pull_request\` branch list in \`${edit.path}\`.`,
33
+ "",
34
+ `Today that workflow runs on pull requests into ${before}. After this change it also runs on`,
35
+ "pull requests into epic branches, which are the child pull requests the Bridge Epic Implementer",
36
+ "merges into an epic branch. Its checks then run before each child merges.",
37
+ "",
38
+ "## What changes",
39
+ "",
40
+ "- One line in one file: the `pull_request` branch list gains `'epic/**'`.",
41
+ "- Nothing else: no job, step, environment, secret, or permission changes. Comments and",
42
+ " formatting are kept byte for byte.",
43
+ "",
44
+ "## What you must do",
45
+ "",
46
+ "Review the one-line diff and merge this pull request yourself. Bridge never merges it, and",
47
+ "until you merge it, child pull requests merge into the epic branch without these checks.",
48
+ "The branch, the commit, and this pull request were created with your own git and `gh`, from",
49
+ "a temporary copy of your default branch; your own folder was not touched.",
50
+ "",
51
+ ].join("\n");
52
+ }
53
+ /** Classify the default branch's bytes for one approved edit. */
54
+ export function classifyCiTriggerTarget(edit, existing) {
55
+ if (existing === null)
56
+ return { state: "conflict", reason: "workflow_modified_or_unrecognized", text: "the workflow is no longer on the default branch" };
57
+ if (existing === edit.edited)
58
+ return { state: "identical", text: "already includes 'epic/**'" };
59
+ // Coverage already in place by any means (for example the owner's own edit) completes the change:
60
+ // nothing is opened, and it is never reported as a stale proposal.
61
+ if (classifyEpicPullRequestTrigger(existing.startsWith("\uFEFF") ? existing.slice(1) : existing).coverage === "covers") {
62
+ return { state: "identical", text: "already runs on pull requests into epic branches" };
63
+ }
64
+ if (sha256Hex(existing) !== edit.sourceSha256) {
65
+ return { state: "conflict", reason: "workflow_modified_or_unrecognized", text: "changed since setup proposed the edit" };
66
+ }
67
+ // The approved source: rebuild the edit from these exact bytes and re-validate it.
68
+ const rebuilt = GITHUB_ACTIONS_TRIGGER_ADAPTER.buildEdit(edit.path, existing);
69
+ if (rebuilt === null || rebuilt.edited !== edit.edited || rebuilt.patchSha256 !== edit.patchSha256) {
70
+ return { state: "conflict", reason: "workflow_modified_or_unrecognized", text: "the edit could not be reproduced" };
71
+ }
72
+ const valid = GITHUB_ACTIONS_TRIGGER_ADAPTER.validateEdit(edit.path, existing, rebuilt.edited, rebuilt);
73
+ if (!valid.ok)
74
+ return { state: "conflict", reason: "workflow_modified_or_unrecognized", text: "the edit did not validate" };
75
+ // The engine's replace-an-existing-file state; authorized only for the approved source.
76
+ return { state: "managed_version_older", text: "adds 'epic/**' to the pull_request branch list" };
77
+ }
78
+ /** The one-artifact set for an approved trigger edit. */
79
+ export function buildCiTriggerArtifactSet(edit) {
80
+ const subject = ciTriggerCommitSubject(edit.path);
81
+ return {
82
+ setName: "epic-ci-trigger",
83
+ installBranch: CI_TRIGGER_BRANCH,
84
+ upgradeBranch: CI_TRIGGER_BRANCH,
85
+ installCommitSubject: subject,
86
+ upgradeCommitSubject: subject,
87
+ installPrTitle: subject,
88
+ upgradePrTitle: subject,
89
+ renderPrBody: () => renderCiTriggerPrBody(edit),
90
+ artifacts: [
91
+ {
92
+ relPath: edit.path,
93
+ render: () => edit.edited,
94
+ progressLabel: "workflow",
95
+ classify: (existing) => classifyCiTriggerTarget(edit, existing),
96
+ },
97
+ ],
98
+ };
99
+ }
100
+ /**
101
+ * Open (or reconcile) the CI-only pull request for an approved edit. Never
102
+ * pushes to the default branch or an epic branch, and never merges.
103
+ */
104
+ export async function installCiTriggerEdit(edit, options, deps) {
105
+ return await installArtifactSet(buildCiTriggerArtifactSet(edit), options, deps);
106
+ }
@@ -24,12 +24,14 @@
24
24
  * - A result carries only the registration name, the parsed launcher
25
25
  * arguments, and splice coordinates. It never carries the file text, the
26
26
  * command, any environment value, a parse excerpt, or a raw error. The
27
+ * `command` is read only to recognize a local build (BAPI-1636, through the
28
+ * pure `isLocalBuildLauncher()` predicate) and is never returned. The
27
29
  * `.env` table is scanned only to keep lexical state and table boundaries.
28
30
  * - Offsets are half-open JavaScript string offsets in UTF-16 code units, not
29
31
  * UTF-8 byte positions. Callers must read and write the file as UTF-8 text so
30
32
  * string offsets and file content stay in step.
31
33
  */
32
- import { MCP_PACKAGE_NAME, RECOGNIZED_SERVER_NAMES, WORKTREE_SHIM_TOKEN, } from "./mcp-identity.js";
34
+ import { isLocalBuildLauncher, MCP_PACKAGE_NAME, RECOGNIZED_SERVER_NAMES, WORKTREE_SHIM_TOKEN, } from "./mcp-identity.js";
33
35
  /** The only error {@link applyCodexRepin} throws. Carries no source text. */
34
36
  export const CODEX_SPLICE_ERROR_MESSAGE = "the Codex launcher splice no longer matches the inspected configuration";
35
37
  // ---------------------------------------------------------------------------
@@ -509,8 +511,15 @@ function classifyDocument(content, doc) {
509
511
  if (args.includes(WORKTREE_SHIM_TOKEN)) {
510
512
  return { kind: "worktree-shim", registrationName: base.name, args };
511
513
  }
512
- if (tokenElements.length === 0)
514
+ if (tokenElements.length === 0) {
515
+ // BAPI-1636: the `command` is read only here, to recognize a local build.
516
+ // An escaped build path or any doubt about `command` stays unlocatable.
517
+ const command = readSingleCommand(content, items, base.headerIndex);
518
+ if (command !== null && elements.length > 0 && !elements[0].hasBackslash && isLocalBuildLauncher(command, args)) {
519
+ return { kind: "local-build", registrationName: base.name, args };
520
+ }
513
521
  return UNLOCATABLE;
522
+ }
514
523
  const [token] = tokenElements;
515
524
  return {
516
525
  kind: "located",
@@ -519,6 +528,28 @@ function classifyDocument(content, doc) {
519
528
  splice: spliceFor(token),
520
529
  };
521
530
  }
531
+ /**
532
+ * The base table's one `command` value when it is a plain single-line string
533
+ * with no escape, else null. A repeated, dotted, or non-string `command` is null.
534
+ */
535
+ function readSingleCommand(content, items, headerIndex) {
536
+ const commands = [];
537
+ for (let k = headerIndex + 1; k < items.length; k++) {
538
+ const item = items[k];
539
+ if (item.type === "header")
540
+ break;
541
+ if (item.keySegments[0] !== "command")
542
+ continue;
543
+ if (item.keySegments.length > 1)
544
+ return null;
545
+ commands.push(item);
546
+ }
547
+ if (commands.length !== 1)
548
+ return null;
549
+ const raw = content.slice(commands[0].valueStart, commands[0].valueEnd);
550
+ const match = /^"([^"\\\r\n]*)"$/.exec(raw) ?? /^'([^'\r\n]*)'$/.exec(raw);
551
+ return match ? match[1] : null;
552
+ }
522
553
  function spliceFor(token) {
523
554
  const tokenText = token.value;
524
555
  const common = {
@@ -8,6 +8,7 @@
8
8
  * translates references to shipped slash commands into Codex skill names.
9
9
  */
10
10
  import { CODEX_AUTO_RECOVERY_POLICY, CODEX_AUTO_RECOVERY_WORKFLOWS } from "./codex-auto-recovery.js";
11
+ import { stripClaudeOnlyFrontmatter } from "./command-host.js";
11
12
  export const CODEX_SKILLS_DIR = ".agents/skills";
12
13
  function commandStem(filename) {
13
14
  if (!/^[a-z][a-z0-9-]*\.md$/.test(filename)) {
@@ -30,7 +31,8 @@ export function renderCodexSkill(filename, command, knownCommands = [commandStem
30
31
  "If no input follows the invocation, follow the canonical workflow's existing usage/error behavior.",
31
32
  ].join("\n");
32
33
  const commandPattern = new RegExp(`(?<![A-Za-z0-9_./-])/(${knownCommands.join("|")})(?=[^A-Za-z0-9-]|$)`, "g");
33
- const adaptedCommand = command
34
+ // BAPI-1642: Claude-only frontmatter (the drive-epic-run Stop hook) never reaches Codex.
35
+ const adaptedCommand = stripClaudeOnlyFrontmatter(command)
34
36
  .split("\n")
35
37
  .map((line) => (line.trim() === "$ARGUMENTS" ? inputContract : line))
36
38
  .join("\n")
@@ -1,5 +1,7 @@
1
1
  /** Specialize the shared front-door command for a known installation host. */
2
2
  export function renderCommandForHost(filename, content, host) {
3
+ if (host === "cursor")
4
+ content = stripClaudeOnlyFrontmatter(content);
3
5
  if (filename !== "review-and-start.md" || host !== "cursor")
4
6
  return content;
5
7
  const marker = "**Command host default: none.**";
@@ -7,3 +9,34 @@ export function renderCommandForHost(filename, content, host) {
7
9
  throw new Error("review-and-start host default marker is missing");
8
10
  return content.replace(marker, "**Command host default: cursor.**");
9
11
  }
12
+ /** Frontmatter keys only Claude Code understands. BAPI-1642: the `/drive-epic-run` Stop-hook guard. */
13
+ export const CLAUDE_ONLY_FRONTMATTER_KEYS = ["hooks"];
14
+ /**
15
+ * Remove Claude-only keys (and their indented values) from a command's leading
16
+ * YAML frontmatter, for every non-Claude output: Cursor, Copilot, and Codex.
17
+ * Every other key, and everything after the frontmatter, is kept byte for byte.
18
+ * Content with no leading frontmatter is returned unchanged.
19
+ *
20
+ * `commands/build.js` carries a CommonJS copy of this function for the Cursor
21
+ * mirror; a test keeps the two in step.
22
+ */
23
+ export function stripClaudeOnlyFrontmatter(content) {
24
+ if (!content.startsWith("---\n"))
25
+ return content;
26
+ const close = content.indexOf("\n---\n", 3);
27
+ if (close < 0)
28
+ return content;
29
+ const lines = content.slice(4, close).split("\n");
30
+ const kept = [];
31
+ let skipping = false;
32
+ for (const line of lines) {
33
+ const topLevel = /^[A-Za-z_][A-Za-z0-9_-]*:/.exec(line);
34
+ if (topLevel)
35
+ skipping = CLAUDE_ONLY_FRONTMATTER_KEYS.includes(topLevel[0].slice(0, -1));
36
+ else if (line.length > 0 && !/^[ \t-]/.test(line))
37
+ skipping = false;
38
+ if (!skipping)
39
+ kept.push(line);
40
+ }
41
+ return `---\n${kept.join("\n")}${content.slice(close)}`;
42
+ }