@bridge_gpt/mcp-server 0.2.65 → 0.2.66

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 (71) hide show
  1. package/README.md +25 -13
  2. package/build/agent-launchers/claude-executor-adapter.js +12 -18
  3. package/build/agent-launchers/executor-adapter.js +27 -0
  4. package/build/bridge-config.js +104 -0
  5. package/build/codex-bridge-profile.js +10 -1
  6. package/build/commands.generated.js +4 -4
  7. package/build/conductor/bridge-api-client.js +230 -10
  8. package/build/conductor/epic-child-continuation.js +61 -34
  9. package/build/conductor/epic-implementer-cli.js +12 -0
  10. package/build/conductor/guided-repair.js +323 -0
  11. package/build/conductor/readiness-cli.js +30 -9
  12. package/build/conductor/readiness.js +23 -1
  13. package/build/conductor/recovery-cli.js +507 -16
  14. package/build/conductor/recovery-operations.js +325 -2
  15. package/build/conductor/repair-contract.js +61 -3
  16. package/build/credential-store.js +5 -4
  17. package/build/diagnostic-text.js +36 -0
  18. package/build/docs.generated.js +1 -1
  19. package/build/doctor.js +70 -10
  20. package/build/drive-epic.js +395 -78
  21. package/build/epic-implementer-bin.js +24 -22
  22. package/build/epic-launch-diagnostic.js +31 -0
  23. package/build/epic-launch-profile.js +44 -14
  24. package/build/executor/completion-supervision.js +5 -0
  25. package/build/executor/correction-dispatch.js +60 -0
  26. package/build/executor/env.js +6 -0
  27. package/build/executor/http-client.js +15 -0
  28. package/build/executor/integration-job.js +6 -1
  29. package/build/executor/job-errors.js +13 -4
  30. package/build/executor/job-log-registry.js +340 -73
  31. package/build/executor/job-runner.js +260 -33
  32. package/build/executor/job-types.js +8 -13
  33. package/build/executor/preflight.js +91 -2
  34. package/build/executor/prompt-spec.js +113 -9
  35. package/build/executor/runner.js +23 -0
  36. package/build/executor/stale-artifacts.js +5 -4
  37. package/build/executor/types.js +1 -0
  38. package/build/executor/watch-cli.js +35 -8
  39. package/build/executor/worker-command.js +43 -43
  40. package/build/executor/worker-finalization.js +80 -15
  41. package/build/executor/worker-guard-hook.js +46 -10
  42. package/build/executor/worker-log.js +137 -70
  43. package/build/executor/worktree-gc.js +30 -6
  44. package/build/index.js +177 -329
  45. package/build/init.js +107 -4
  46. package/build/install-bridge.js +284 -20
  47. package/build/install-doctor.js +172 -30
  48. package/build/install-reexec.js +69 -7
  49. package/build/macos-terminal-permission-guidance.js +16 -0
  50. package/build/model-thresholds-tool.js +185 -0
  51. package/build/pipelines.generated.js +1 -1
  52. package/build/plane/status.js +4 -0
  53. package/build/plane/supervisor.js +4 -0
  54. package/build/plane/worker-exit-code.js +2 -0
  55. package/build/project-root.js +99 -0
  56. package/build/readme.generated.js +1 -1
  57. package/build/review-tickets.js +156 -13
  58. package/build/setup-epic.js +180 -108
  59. package/build/sfcc/setup-status.js +2 -0
  60. package/build/sfcc/tool-wrapper.js +2 -0
  61. package/build/sfcc/tools-configured.js +96 -0
  62. package/build/start-tickets.js +163 -58
  63. package/build/upgrade-cli.js +109 -24
  64. package/build/version.generated.js +3 -3
  65. package/build/windows-npm-entry.js +103 -0
  66. package/build/worker-guard-hook-bin.js +4 -3
  67. package/build/worktree-core.js +6 -5
  68. package/docs/install/mcp-tool-integrations.md +1 -0
  69. package/docs/install/sfcc-integration.md +12 -7
  70. package/package.json +1 -1
  71. package/pipelines/implement-ticket.json +1 -1
@@ -16,6 +16,7 @@
16
16
  * so this stays trivially testable and swappable.
17
17
  */
18
18
  import path from "path";
19
+ import { renderDiagnosticValue } from "./diagnostic-text.js";
19
20
  /**
20
21
  * Whether `cwd` looks like a project root: presence of `.git`, checked through the
21
22
  * injected `stat` probe. Any probe failure (absent, or an unexpected I/O error) is
@@ -32,3 +33,101 @@ export async function hasProjectRootMarker(cwd, stat) {
32
33
  return false;
33
34
  }
34
35
  }
36
+ /**
37
+ * Validate an explicit project root: it must exist, be a directory, and contain
38
+ * `.git` (a directory, or the `.git` FILE a worktree has) or `.bridge/config`.
39
+ * An absent path is `missing`; anything else that fails — a file, a folder with
40
+ * neither marker, or an inaccessible path — is `not-a-project`. Raw filesystem
41
+ * errors never leave this function.
42
+ *
43
+ * Deliberately a SIBLING of {@link hasProjectRootMarker}, which stays `.git`-only
44
+ * because `install` and `--init` use it and the README pins that wording. A
45
+ * marker proves only that the path looks like a project, not that it is THIS
46
+ * project; the stderr source line is how a wrong-but-valid root is noticed.
47
+ */
48
+ export async function validateExplicitProjectRoot(root, stat) {
49
+ let info;
50
+ try {
51
+ info = await stat(root);
52
+ }
53
+ catch (error) {
54
+ const code = error?.code;
55
+ return { ok: false, reason: code === "ENOENT" || code === "ENOTDIR" ? "missing" : "not-a-project" };
56
+ }
57
+ try {
58
+ if (!info.isDirectory())
59
+ return { ok: false, reason: "not-a-project" };
60
+ }
61
+ catch {
62
+ return { ok: false, reason: "not-a-project" };
63
+ }
64
+ for (const marker of [path.join(root, ".git"), path.join(root, ".bridge", "config")]) {
65
+ try {
66
+ await stat(marker);
67
+ return { ok: true };
68
+ }
69
+ catch {
70
+ /* try the next marker */
71
+ }
72
+ }
73
+ return { ok: false, reason: "not-a-project" };
74
+ }
75
+ /**
76
+ * Resolve the project root in the fixed order: a VALID `BAPI_PROJECT_ROOT`,
77
+ * then MCP `roots/list`, then `CLAUDE_PROJECT_DIR`, then `cwd`. Only the explicit
78
+ * value is validated — it is the one source written into (possibly committed)
79
+ * config files, so it is the one that can name another machine's path. The later
80
+ * sources come from the running host and keep today's behavior. An empty or
81
+ * whitespace `BAPI_PROJECT_ROOT` is treated as unset.
82
+ *
83
+ * Pure apart from the injected seams, so `index.ts` (which cannot be imported in
84
+ * tests) stays a thin wrapper over this.
85
+ */
86
+ export async function resolveProjectRoot(options) {
87
+ let rejectedExplicit;
88
+ const explicit = (options.env.BAPI_PROJECT_ROOT ?? "").trim();
89
+ if (explicit.length > 0) {
90
+ const verdict = await validateExplicitProjectRoot(explicit, options.stat);
91
+ if (verdict.ok)
92
+ return { root: explicit, source: "BAPI_PROJECT_ROOT" };
93
+ rejectedExplicit = { path: explicit, reason: verdict.reason };
94
+ }
95
+ const withRejection = (root, source) => rejectedExplicit ? { root, source, rejectedExplicit } : { root, source };
96
+ let fromRoots = null;
97
+ try {
98
+ fromRoots = await options.listRoots();
99
+ }
100
+ catch {
101
+ fromRoots = null;
102
+ }
103
+ if (fromRoots && fromRoots.length > 0)
104
+ return withRejection(fromRoots, "roots/list");
105
+ const claudeDir = (options.env.CLAUDE_PROJECT_DIR ?? "").trim();
106
+ if (claudeDir.length > 0)
107
+ return withRejection(claudeDir, "CLAUDE_PROJECT_DIR");
108
+ return withRejection(options.cwd(), "cwd");
109
+ }
110
+ /** Resolve `BAPI_DOCS_DIR` (default `docs/tmp`) against the chosen project root. */
111
+ export function resolveDocsDirForRoot(root, env) {
112
+ return path.resolve(root, env.BAPI_DOCS_DIR ?? "docs/tmp");
113
+ }
114
+ /** Human wording for each closed refusal reason. */
115
+ export const PROJECT_ROOT_REFUSAL_TEXT = {
116
+ missing: "does not exist",
117
+ "not-a-project": "is not a project folder (no .git or .bridge/config)",
118
+ };
119
+ /**
120
+ * The one stderr line the server writes when it first resolves the root, e.g.
121
+ * `Bridge MCP: project root /home/b/app (from roots/list); BAPI_PROJECT_ROOT
122
+ * /Users/a/app ignored: does not exist`. Paths are rendered on one line with
123
+ * control characters escaped.
124
+ */
125
+ export function formatProjectRootSourceLine(resolved) {
126
+ let line = `Bridge MCP: project root ${renderDiagnosticValue(resolved.root)} (from ${resolved.source})`;
127
+ if (resolved.rejectedExplicit) {
128
+ line +=
129
+ `; BAPI_PROJECT_ROOT ${renderDiagnosticValue(resolved.rejectedExplicit.path)} ignored: ` +
130
+ PROJECT_ROOT_REFUSAL_TEXT[resolved.rejectedExplicit.reason];
131
+ }
132
+ return line;
133
+ }