@bridge_gpt/mcp-server 0.2.65 → 0.2.67

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 (132) hide show
  1. package/README.md +269 -82
  2. package/build/agent-capabilities/probes.js +15 -5
  3. package/build/agent-launchers/claude-executor-adapter.js +55 -34
  4. package/build/agent-launchers/executor-adapter.js +34 -4
  5. package/build/agents.generated.js +1 -1
  6. package/build/bounded-wait.js +67 -10
  7. package/build/bridge-config.js +104 -0
  8. package/build/codex-bridge-profile.js +10 -1
  9. package/build/commands.generated.js +12 -12
  10. package/build/conductor/bridge-api-client.js +372 -10
  11. package/build/conductor/bring-up-facts.js +1 -1
  12. package/build/conductor/doctor.js +3 -3
  13. package/build/conductor/epic-child-continuation.js +61 -34
  14. package/build/conductor/epic-implementer-cli.js +34 -6
  15. package/build/conductor/errors.js +4 -3
  16. package/build/conductor/guided-repair.js +327 -0
  17. package/build/conductor/hook-runtime-qualification.js +1 -1
  18. package/build/conductor/merge-execution-contract.js +27 -8
  19. package/build/conductor/merge-execution-eligibility.js +3 -2
  20. package/build/conductor/pr-ci-producer.js +1 -1
  21. package/build/conductor/readiness-cli.js +46 -9
  22. package/build/conductor/readiness-sections.js +41 -6
  23. package/build/conductor/readiness.js +204 -30
  24. package/build/conductor/recovery-cli.js +703 -20
  25. package/build/conductor/recovery-operations.js +392 -3
  26. package/build/conductor/repair-contract.js +112 -3
  27. package/build/conductor/repository-workflow-remedy.js +125 -0
  28. package/build/conductor/tools.js +2 -2
  29. package/build/conductor-bundle-artifacts.js +8 -0
  30. package/build/credential-store.js +5 -4
  31. package/build/diagnostic-text.js +36 -0
  32. package/build/docs.generated.js +8 -3
  33. package/build/doctor.js +70 -10
  34. package/build/drive-epic-key.js +6 -5
  35. package/build/drive-epic.js +479 -131
  36. package/build/epic-coherence-input.js +2 -1
  37. package/build/epic-implementer-bin.js +30 -26
  38. package/build/epic-implementer-bundle-cli.js +2 -2
  39. package/build/epic-launch-diagnostic.js +31 -0
  40. package/build/epic-launch-profile.js +44 -14
  41. package/build/executor/cli.js +3 -2
  42. package/build/executor/completion-contract.js +48 -5
  43. package/build/executor/completion-supervision.js +9 -0
  44. package/build/executor/correction-dispatch.js +60 -0
  45. package/build/executor/env.js +25 -0
  46. package/build/executor/heartbeat.js +1 -1
  47. package/build/executor/http-client.js +35 -0
  48. package/build/executor/integration-job.js +6 -1
  49. package/build/executor/job-errors.js +38 -4
  50. package/build/executor/job-log-registry.js +340 -73
  51. package/build/executor/job-runner.js +485 -74
  52. package/build/executor/job-types.js +8 -13
  53. package/build/executor/observation.js +6 -1
  54. package/build/executor/preflight.js +136 -10
  55. package/build/executor/prompt-spec.js +113 -9
  56. package/build/executor/required-work-ledger.js +6 -1
  57. package/build/executor/resume-pre-spawn.js +2 -0
  58. package/build/executor/runner.js +31 -2
  59. package/build/executor/service-unit.js +7 -1
  60. package/build/executor/stale-artifacts.js +5 -4
  61. package/build/executor/types.js +1 -0
  62. package/build/executor/watch-cli.js +35 -8
  63. package/build/executor/worker-command.js +43 -43
  64. package/build/executor/worker-finalization.js +161 -43
  65. package/build/executor/worker-guard-hook.js +152 -12
  66. package/build/executor/worker-log.js +137 -70
  67. package/build/executor/worktree-gc.js +30 -6
  68. package/build/executor/worktree.js +82 -1
  69. package/build/index.js +482 -660
  70. package/build/init.js +107 -4
  71. package/build/install-bridge-conductor.js +8 -6
  72. package/build/install-bridge.js +287 -23
  73. package/build/install-doctor.js +172 -30
  74. package/build/install-reexec.js +69 -7
  75. package/build/macos-terminal-permission-guidance.js +16 -0
  76. package/build/model-thresholds-tool.js +185 -0
  77. package/build/phase-context-git-probe.js +68 -0
  78. package/build/phase-result-artifacts.js +173 -5
  79. package/build/pipelines.generated.js +19 -25
  80. package/build/plane/alembic-head.js +12 -3
  81. package/build/plane/base-worktree-guard.js +147 -0
  82. package/build/plane/cli.js +217 -17
  83. package/build/plane/code-snapshot.js +468 -0
  84. package/build/plane/defaults.js +48 -3
  85. package/build/plane/endpoint.js +41 -0
  86. package/build/plane/manifest.js +120 -1
  87. package/build/plane/member-roster.js +94 -19
  88. package/build/plane/preflight.js +30 -2
  89. package/build/plane/process-cwd.js +67 -0
  90. package/build/plane/restart.js +542 -0
  91. package/build/plane/shutdown.js +31 -0
  92. package/build/plane/status.js +145 -6
  93. package/build/plane/supervisor.js +588 -177
  94. package/build/plane/types.js +54 -2
  95. package/build/plane/worker-exit-code.js +2 -0
  96. package/build/printed-remedy-commands.js +37 -0
  97. package/build/project-root.js +99 -0
  98. package/build/readiness-check.js +1 -1
  99. package/build/readme.generated.js +1 -1
  100. package/build/review-generation.js +22 -0
  101. package/build/review-tickets.js +156 -13
  102. package/build/setup-epic.js +224 -127
  103. package/build/sfcc/config.js +9 -0
  104. package/build/sfcc/credentials.js +100 -38
  105. package/build/sfcc/hostname.js +67 -0
  106. package/build/sfcc/permissions.js +17 -13
  107. package/build/sfcc/register.js +1 -1
  108. package/build/sfcc/setup-status.js +2 -0
  109. package/build/sfcc/tool-wrapper.js +41 -43
  110. package/build/sfcc/tools-configured.js +96 -0
  111. package/build/sfcc/write-grants.js +17 -11
  112. package/build/sfcc/write-result.js +4 -3
  113. package/build/sfcc/writes-site-preference.js +20 -8
  114. package/build/start-tickets.js +332 -79
  115. package/build/tool-error-envelope.js +61 -0
  116. package/build/upgrade-cli.js +109 -24
  117. package/build/version.generated.js +3 -3
  118. package/build/visual-diff.js +22 -1
  119. package/build/windows-npm-entry.js +103 -0
  120. package/build/worker-guard-hook-bin.js +3 -5
  121. package/build/worker-guard-hook-main.js +47 -0
  122. package/build/worktree-core.js +136 -9
  123. package/docs/EPIC-IMPLEMENTER-INSTALL.md +849 -0
  124. package/docs/EPIC-IMPLEMENTER.md +662 -0
  125. package/docs/install/mcp-tool-integrations.md +25 -15
  126. package/docs/install/sfcc-integration.md +21 -8
  127. package/package.json +1 -1
  128. package/pipelines/implement-ticket.json +1 -1
  129. package/pipelines/plan-epic.json +0 -5
  130. package/pipelines/review-ticket.json +1 -1
  131. package/docs/CONDUCTOR.md +0 -605
  132. package/pipelines/idea-to-pr.json +0 -49
package/build/init.js CHANGED
@@ -10,6 +10,7 @@
10
10
  * effects and depends only on leaf modules.
11
11
  */
12
12
  import { writeFile, mkdir, readFile, stat } from "fs/promises";
13
+ import { execFile } from "child_process";
13
14
  import path from "path";
14
15
  import os from "os";
15
16
  import { COMMANDS } from "./commands.generated.js";
@@ -19,7 +20,7 @@ import { AGENTS } from "./agents.generated.js";
19
20
  import { DOCS } from "./docs.generated.js";
20
21
  import { VERSION, LAUNCHER_ARGS } from "./version.generated.js";
21
22
  import { reconstructAgentMarkdown, translateAgentToCopilot, translateCommandToCopilot, } from "./agent-utils.js";
22
- import { validateRepoName, resolveRepoNameForProjectRoot } from "./bridge-config.js";
23
+ import { BRIDGE_CONFIG_TEAMMATE_NOTICE_LINES, validateBridgeConfigRepoNameRepresentability, validateRepoName, resolveRepoNameForProjectRoot, } from "./bridge-config.js";
23
24
  import { ensureGitignored as ensureGitignoredShared } from "./git-ignore-utils.js";
24
25
  import { resolveBapiCredentials } from "./credential-store.js";
25
26
  import { describeLauncherReason, DUPLICATE_REGISTRATION_GUIDANCE, inspectLauncherConfigs, isPrerequisiteFailure, } from "./launcher-config-inspection.js";
@@ -133,6 +134,8 @@ export function buildBridgeConfigManifest(repoName) {
133
134
  "# Inherited by every git worktree; start-tickets worktree provisioning reads it",
134
135
  "# to decide which Bridge API MCP registrations to write. Do not add credentials,",
135
136
  "# connection URLs, or machine-specific paths here — those are resolved at runtime.",
137
+ "#",
138
+ ...BRIDGE_CONFIG_TEAMMATE_NOTICE_LINES,
136
139
  "",
137
140
  `repo_name = "${repoName}"`,
138
141
  "",
@@ -389,6 +392,65 @@ export class InitPreflightError extends Error {
389
392
  this.failures = failures;
390
393
  }
391
394
  }
395
+ /**
396
+ * Classify `git ls-files --error-unmatch -- <relPath>` from its exit code: 0 is
397
+ * tracked, 1 is untracked, anything else is undetermined. Shared by `runInit`
398
+ * and install so both reach the same verdict from the same probe.
399
+ */
400
+ export function classifyTrackedProbeExitCode(exitCode) {
401
+ if (exitCode === 0)
402
+ return "tracked";
403
+ if (exitCode === 1)
404
+ return "untracked";
405
+ return "undetermined";
406
+ }
407
+ /**
408
+ * Default tracked-config probe for `runInit`: runs git with an ARGUMENT LIST,
409
+ * never a shell string, in `cwd`. Any failure is `undetermined`, which callers
410
+ * treat as untracked — the probe fails OPEN, so a missing git or a non-repo
411
+ * folder still gets today's `BAPI_PROJECT_ROOT = cwd` rewrite.
412
+ */
413
+ export function defaultIsTrackedConfig(cwd) {
414
+ return (relPath) => new Promise((resolve) => {
415
+ try {
416
+ execFile("git", ["ls-files", "--error-unmatch", "--", relPath], { cwd, windowsHide: true, timeout: 10_000 }, (error) => {
417
+ if (!error)
418
+ return resolve("tracked");
419
+ const code = error.code;
420
+ resolve(classifyTrackedProbeExitCode(typeof code === "number" ? code : null));
421
+ });
422
+ }
423
+ catch {
424
+ resolve("undetermined");
425
+ }
426
+ });
427
+ }
428
+ /**
429
+ * Decide the `BAPI_PROJECT_ROOT` an EXISTING Bridge entry should carry (BAPI-1318).
430
+ * A git-tracked config keeps its existing non-blank value exactly: the runtime
431
+ * check in `project-root.ts` makes a committed path harmless for teammates, and
432
+ * rewriting it would put this machine's path into everyone's diff. Untracked and
433
+ * undetermined configs, and blank or absent values, get `cwd` as before.
434
+ *
435
+ * `warnReplaced` is true only when the probe was undetermined AND a different,
436
+ * non-blank value is being replaced — the one case where a tracked path may have
437
+ * been rewritten without the protection applying.
438
+ */
439
+ export function decideExistingProjectRoot(existing, cwd, tracked) {
440
+ const current = typeof existing === "string" ? existing : "";
441
+ const blank = current.trim().length === 0;
442
+ if (tracked === "tracked" && !blank)
443
+ return { value: current, warnReplaced: false };
444
+ return {
445
+ value: cwd,
446
+ warnReplaced: tracked === "undetermined" && !blank && current !== cwd,
447
+ };
448
+ }
449
+ /** The one secret-safe warning for an undetermined probe that replaced a root. */
450
+ export function formatUndeterminedRootReplacedWarning(relPath) {
451
+ return (` Warning: could not tell whether ${relPath} is tracked by git, so its BAPI_PROJECT_ROOT ` +
452
+ "was rewritten to this folder. Review its diff before committing.");
453
+ }
392
454
  /**
393
455
  * Resolve the non-secret identity a NEW Bridge entry should carry.
394
456
  *
@@ -518,6 +580,20 @@ export async function runInit(cwd, options = {}) {
518
580
  const targetSpec = `${MCP_PACKAGE_NAME}@${targetVersion}`;
519
581
  const say = options.stdout ?? ((m) => console.log(m));
520
582
  const warn = options.stderr ?? ((m) => console.error(m));
583
+ const trackedProbe = options.isTrackedConfig ?? defaultIsTrackedConfig(cwd);
584
+ const probeTracked = async (relPath) => {
585
+ try {
586
+ const verdict = await trackedProbe(relPath);
587
+ if (verdict === true)
588
+ return "tracked";
589
+ if (verdict === false)
590
+ return "untracked";
591
+ return verdict === "tracked" || verdict === "untracked" ? verdict : "undetermined";
592
+ }
593
+ catch {
594
+ return "undetermined";
595
+ }
596
+ };
521
597
  // ---- Phase 1: IDE Detection ----
522
598
  // BAPI-708: detection lives in `detectInitIdes` so the commit-safe asset
523
599
  // manifest resolves the SAME conditional targets this scaffolder writes.
@@ -701,7 +777,17 @@ export async function runInit(cwd, options = {}) {
701
777
  entry.args = refreshed;
702
778
  if (!entry.env)
703
779
  entry.env = {};
704
- entry.env.BAPI_PROJECT_ROOT = cwd;
780
+ // BAPI-1318: a git-tracked config keeps its committed BAPI_PROJECT_ROOT.
781
+ // The probe runs only when there is a non-blank value to preserve.
782
+ const existingRoot = entry.env.BAPI_PROJECT_ROOT;
783
+ let trackedVerdict = "untracked";
784
+ if (typeof existingRoot === "string" && existingRoot.trim().length > 0 && existingRoot !== cwd) {
785
+ trackedVerdict = await probeTracked(target.path);
786
+ }
787
+ const rootDecision = decideExistingProjectRoot(existingRoot, cwd, trackedVerdict);
788
+ entry.env.BAPI_PROJECT_ROOT = rootDecision.value;
789
+ if (rootDecision.warnReplaced)
790
+ warn(formatUndeterminedRootReplacedWarning(target.path));
705
791
  await io.writeFile(fullPath, JSON.stringify(parsed, null, 2) + "\n", "utf-8");
706
792
  const kind = found.action === "already-current"
707
793
  ? "already-current"
@@ -1094,9 +1180,24 @@ says to serialize structured output.
1094
1180
  // the credential landed and which generated assets are safe to commit. Removed
1095
1181
  // outright rather than behind an output-mode flag — parameterizing would change
1096
1182
  // the injected `deps.runInit` seam signature for no user-visible gain.
1183
+ // BAPI-1318: a caller that already resolved the project name (install) is
1184
+ // authoritative, so the manifest agrees with the MCP entry. `--init` and
1185
+ // `upgrade` pass no creation context and keep the folder-name default.
1186
+ let bridgeConfigCreated = false;
1187
+ let bridgeConfigRepoName;
1097
1188
  if (!bridgeConfigExists) {
1098
- await mkdir(path.dirname(bridgeConfigPath), { recursive: true });
1099
- await writeFile(bridgeConfigPath, buildBridgeConfigManifest(chooseScaffoldRepoName(cwd)), "utf-8");
1189
+ const scaffoldName = options.creationContext?.repoName ?? chooseScaffoldRepoName(cwd);
1190
+ const representable = validateBridgeConfigRepoNameRepresentability(scaffoldName);
1191
+ if (representable.ok) {
1192
+ await mkdir(path.dirname(bridgeConfigPath), { recursive: true });
1193
+ await writeFile(bridgeConfigPath, buildBridgeConfigManifest(representable.value), "utf-8");
1194
+ bridgeConfigCreated = true;
1195
+ bridgeConfigRepoName = representable.value;
1196
+ }
1197
+ else {
1198
+ warn(" Warning: .bridge/config was not created because this project name cannot be written " +
1199
+ `there (${representable.error}). Worktrees and shell tools will fall back to the git folder name.`);
1200
+ }
1100
1201
  }
1101
1202
  // BAPI-728: authoritative, secret-free outcome. `ok` is false whenever any
1102
1203
  // entry authenticates as nobody, so no caller can report full success over a
@@ -1106,5 +1207,7 @@ says to serialize structured output.
1106
1207
  configActions: structuredActions,
1107
1208
  readinessWarnings,
1108
1209
  targetVersion,
1210
+ bridgeConfigCreated,
1211
+ ...(bridgeConfigRepoName !== undefined ? { bridgeConfigRepoName } : {}),
1109
1212
  };
1110
1213
  }
@@ -106,6 +106,7 @@
106
106
  * The command does NOT persist a repository-level review policy: that is
107
107
  * BAPI-694's. The policy selected here is per-run and is reported as such.
108
108
  */
109
+ import { PRINTED_INSTALL_COMMAND } from "./printed-remedy-commands.js";
109
110
  import { bootstrapConductorSupervisorDefaults, classifySupervisorBootstrapFailure, fetchConductorReadiness, previewConductorSupervisorBootstrap, } from "./conductor/bridge-api-client.js";
110
111
  import { CONDUCTOR_OPERATOR_RUNBOOK_POINTER, EXECUTOR_PROVISIONING_GUIDANCE, conductorInstallDoctorExitCode, conductorInstallDoctorHasFatal, formatConductorInstallDoctorReport, } from "./conductor/install-doctor.js";
111
112
  import { describeNativeLedgerAvailability, } from "./conductor/doctor.js";
@@ -138,7 +139,7 @@ export function getInstallBridgeConductorUsage() {
138
139
  return [
139
140
  "Usage: install conductor [options]",
140
141
  "",
141
- "Bootstrap Epic Conductor v2 for this repository: run the unified read-only",
142
+ "Bootstrap the Epic Implementer for this repository: run the unified read-only",
142
143
  "doctor, write the safe project-default supervisor posture, optionally scaffold",
143
144
  "the claude-review workflow, report the capability matrix, and re-run the doctor.",
144
145
  "",
@@ -183,9 +184,10 @@ export function getInstallBridgeConductorUsage() {
183
184
  " approves one named server and has no default.",
184
185
  " --execution-mode <mode> local | durable (default: durable with",
185
186
  " --executor-id, otherwise local).",
186
- " --policy-file <path> Run policy the profile references; an unattended",
187
- " run needs notify.webhook_url reachable from the",
188
- " API server (notify.local_sink is not enough).",
187
+ " --policy-file <path> Run policy the profile references. An unattended",
188
+ " run escalates to a notify.webhook_url reachable",
189
+ " from the API server or, with none declared, to the",
190
+ " account's email (notify.local_sink is not enough).",
189
191
  " --dry-run Diagnose and preview only. Performs NO writes:",
190
192
  " no POST, no file write, no host MCP config write,",
191
193
  " no Git hook write, no install-state or capability",
@@ -208,7 +210,7 @@ export function getInstallBridgeConductorUsage() {
208
210
  "nor changed. No file is ever created: when no supported config carries a",
209
211
  "a Bridge entry, the run says so and points at the base `install` command.",
210
212
  "The MCP server captures its active groups at startup, so a merge activates on",
211
- "the next launch — restart your MCP client to see the conductor tools.",
213
+ "the next launch — restart your MCP client to see the Epic Implementer tools.",
212
214
  "",
213
215
  "Local observability (a SEPARATE consent): installs or updates this",
214
216
  "repository's managed conductor Git hooks (post-commit,",
@@ -939,7 +941,7 @@ export function formatConductorRestartAdvisory(mergedProfile) {
939
941
  "client to gain access to the Epic Implementer tools.");
940
942
  }
941
943
  /** Remediation printed when no supported host config carries a Bridge entry. */
942
- export const CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION = `run \`npx ${MCP_PACKAGE_NAME} install\` to create and register the host MCP entry, ` +
944
+ export const CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION = `run \`${PRINTED_INSTALL_COMMAND}\` to create and register the host MCP entry, ` +
943
945
  "then re-run `install conductor`.";
944
946
  /** Remediation printed whenever the managed conductor hooks were not installed. */
945
947
  export const CONDUCTOR_HOOKS_MANUAL_REMEDIATION = "re-run `install conductor` and accept the local-observability consent, or run " +