@bridge_gpt/mcp-server 0.2.67 → 0.2.69

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 (127) hide show
  1. package/README.md +272 -51
  2. package/build/agent-launchers/claude-executor-adapter.js +27 -0
  3. package/build/agents.generated.js +22 -2
  4. package/build/bitbucket-workspace-remote.js +136 -0
  5. package/build/bootstrap-project-identity.js +24 -0
  6. package/build/bridge-permissions.js +1362 -0
  7. package/build/check-update-cli.js +74 -0
  8. package/build/claude-settings.js +102 -2
  9. package/build/cli-help.js +27 -0
  10. package/build/codex-home.js +9 -1
  11. package/build/codex-launcher-pin.js +598 -0
  12. package/build/command-assets-doctor.js +24 -70
  13. package/build/command-provisioning.js +29 -5
  14. package/build/commands.generated.js +9 -9
  15. package/build/conductor/bridge-api-client.js +714 -0
  16. package/build/conductor/command-drift-production.js +92 -0
  17. package/build/conductor/command-drift.js +89 -0
  18. package/build/conductor/doctor.js +69 -26
  19. package/build/conductor/epic-branch-ci-inspection.js +1375 -0
  20. package/build/conductor/epic-implementer-cli.js +76 -22
  21. package/build/conductor/gate-discovery.js +890 -0
  22. package/build/conductor/install-doctor.js +15 -3
  23. package/build/conductor/json-output.js +63 -0
  24. package/build/conductor/readiness-cli.js +95 -10
  25. package/build/conductor/readiness-sections.js +369 -3
  26. package/build/conductor/readiness.js +211 -8
  27. package/build/conductor/recovery-cli.js +110 -4
  28. package/build/conductor/recovery-operations.js +99 -1
  29. package/build/connect-bitbucket-api.js +41 -6
  30. package/build/connect-bitbucket.js +106 -33
  31. package/build/connect-github-api.js +33 -14
  32. package/build/credential-store.js +207 -47
  33. package/build/docs.generated.js +57 -3
  34. package/build/doctor.js +198 -4
  35. package/build/drive-epic.js +45 -8
  36. package/build/epic-coherence-input.test-fixtures.js +4 -3
  37. package/build/epic-implementer-bin.js +1369 -25
  38. package/build/epic-workarounds-path.js +39 -0
  39. package/build/executor/cli.js +30 -0
  40. package/build/executor/completion-contract.js +20 -5
  41. package/build/executor/deps.js +4 -1
  42. package/build/executor/gate-qualification-job.js +499 -0
  43. package/build/executor/guarded-fast-forward-push.js +129 -0
  44. package/build/executor/http-client.js +43 -4
  45. package/build/executor/integration-job.js +122 -8
  46. package/build/executor/job-errors.js +8 -1
  47. package/build/executor/job-runner.js +589 -47
  48. package/build/executor/likely-tests.js +290 -0
  49. package/build/executor/live-worker-registry.js +1 -1
  50. package/build/executor/observation.js +31 -2
  51. package/build/executor/packaged-recipe.js +106 -0
  52. package/build/executor/permissions.js +115 -28
  53. package/build/executor/platform.js +1 -1
  54. package/build/executor/preflight.js +61 -12
  55. package/build/executor/process-containment.js +36 -12
  56. package/build/executor/process.js +15 -7
  57. package/build/executor/prompt-spec.js +33 -1
  58. package/build/executor/recently-failed-tests-file.js +71 -0
  59. package/build/executor/reconcile-overlap-job.js +41 -23
  60. package/build/executor/required-verification.js +1 -1
  61. package/build/executor/required-work-ledger.js +105 -17
  62. package/build/executor/retirement.js +69 -0
  63. package/build/executor/runner.js +114 -11
  64. package/build/executor/test-clock.js +15 -0
  65. package/build/executor/types.js +32 -0
  66. package/build/executor/viewer-tabs.js +58 -8
  67. package/build/executor/worker-command.js +23 -7
  68. package/build/executor/worker-diagnostics.js +37 -0
  69. package/build/executor/worker-finalization.js +31 -5
  70. package/build/executor/worker-guard-hook.js +179 -25
  71. package/build/executor/worker-log.js +4 -3
  72. package/build/executor/worker-verification-guidance.js +37 -0
  73. package/build/executor/worktree.js +88 -11
  74. package/build/first-build-advisory.js +97 -0
  75. package/build/generated-assets-advisory.js +14 -0
  76. package/build/generated-assets-catalog.js +66 -0
  77. package/build/generated-assets-context.js +46 -0
  78. package/build/generated-assets-dependencies.js +26 -0
  79. package/build/generated-assets-doctor.js +50 -0
  80. package/build/generated-assets-health.js +65 -0
  81. package/build/generated-assets-host.js +17 -0
  82. package/build/generated-assets-inventory.js +17 -0
  83. package/build/generated-assets-paths.js +60 -0
  84. package/build/generated-assets-publisher.js +133 -0
  85. package/build/generated-assets-remedy.js +25 -0
  86. package/build/generated-assets-repair.js +72 -0
  87. package/build/generated-assets-session.js +71 -0
  88. package/build/generated-assets-test-support.js +35 -0
  89. package/build/index.js +1109 -695
  90. package/build/init.js +54 -177
  91. package/build/install-bridge-conductor-gate.js +1372 -0
  92. package/build/install-bridge-conductor.js +289 -36
  93. package/build/install-bridge.js +722 -252
  94. package/build/launcher-config-inspection.js +184 -19
  95. package/build/mcp-host-targets.js +4 -0
  96. package/build/mcp-identity.js +7 -0
  97. package/build/mcp-install-state.js +50 -4
  98. package/build/merge-workflow-install.js +3 -4
  99. package/build/pipeline-utils.js +6 -2
  100. package/build/pipelines.generated.js +22 -142
  101. package/build/plan-execution-ledger.js +2 -32
  102. package/build/plane/manifest.js +16 -1
  103. package/build/plane/preflight.js +54 -1
  104. package/build/printed-remedy-commands.js +16 -1
  105. package/build/readme.generated.js +1 -1
  106. package/build/repair-assets.js +93 -0
  107. package/build/run-unit-tests-launcher.js +130 -49
  108. package/build/secret-redaction.js +33 -0
  109. package/build/session-upgrade-notice.js +86 -0
  110. package/build/setup-epic.js +108 -3
  111. package/build/start-tickets-prereqs.js +70 -16
  112. package/build/start-tickets.js +44 -5
  113. package/build/tool-call-advisory.js +162 -0
  114. package/build/tool-surface-gating.js +32 -57
  115. package/build/update-check.js +97 -16
  116. package/build/update-status.js +61 -71
  117. package/build/upgrade-advice.js +15 -11
  118. package/build/upgrade-cli.js +398 -17
  119. package/build/version.generated.js +3 -3
  120. package/build/worker-guard-hook-bin.js +3 -2
  121. package/build/worker-guard-hook-main.js +1 -1
  122. package/build/worktree-core.js +15 -2
  123. package/docs/EPIC-IMPLEMENTER-INSTALL.md +30 -12
  124. package/docs/EPIC-IMPLEMENTER.md +68 -2
  125. package/package.json +3 -3
  126. package/pipelines/greenfield-setup.json +4 -128
  127. package/pipelines/implement-ticket.json +3 -2
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Internal `check-update` subcommand (BAPI-1446).
3
+ *
4
+ * The Claude Code SessionStart hook runs `check-update --hook claude-session-start`
5
+ * and reads one JSON object from stdout. This command answers from the local
6
+ * update cache only: it never constructs an MCP server and never touches the
7
+ * network, so a cold start stays well inside the hook's timeout.
8
+ *
9
+ * Protocol:
10
+ * - eligible: exactly one newline-terminated JSON object whose
11
+ * `systemMessage` (shown to the person) and
12
+ * `hookSpecificOutput.additionalContext` (seen by the model) carry the same
13
+ * notice text;
14
+ * - silent: no output at all;
15
+ * - always exit 0 in the supported mode, even after an unexpected error, which
16
+ * is contained without logging. A hook must never block a session.
17
+ *
18
+ * Any other argument form is a usage error: a concise stderr message and a
19
+ * nonzero exit.
20
+ */
21
+ import { getNoticeDecision } from "./session-upgrade-notice.js";
22
+ import { formatSessionUpgradeNotice } from "./upgrade-advice.js";
23
+ import { VERSION } from "./version.generated.js";
24
+ /** The only supported hook mode. */
25
+ export const CLAUDE_SESSION_START_HOOK_MODE = "claude-session-start";
26
+ /** The usage line printed to stderr for an unsupported argument form. */
27
+ export const CHECK_UPDATE_USAGE = `Usage: check-update --hook ${CLAUDE_SESSION_START_HOOK_MODE}`;
28
+ function writeStdout(text) {
29
+ return new Promise((resolve, reject) => {
30
+ process.stdout.write(text, (error) => {
31
+ if (error) {
32
+ reject(error);
33
+ return;
34
+ }
35
+ resolve();
36
+ });
37
+ });
38
+ }
39
+ /**
40
+ * Run the command. Resolves to the process exit code: 0 for the supported hook
41
+ * mode (whether or not it printed anything), 2 for any other argument form.
42
+ */
43
+ export async function runCheckUpdateCli(argv, options = {}) {
44
+ const stderr = options.stderr ?? ((text) => void process.stderr.write(`${text}\n`));
45
+ const supported = argv.length === 2 && argv[0] === "--hook" && argv[1] === CLAUDE_SESSION_START_HOOK_MODE;
46
+ if (!supported) {
47
+ try {
48
+ stderr(CHECK_UPDATE_USAGE);
49
+ }
50
+ catch {
51
+ // A stderr failure cannot change the usage-error result.
52
+ }
53
+ return 2;
54
+ }
55
+ try {
56
+ const env = options.env ?? process.env;
57
+ const decision = getNoticeDecision(env, options.version ?? VERSION);
58
+ if (decision.show) {
59
+ const notice = formatSessionUpgradeNotice(decision.current, decision.latest);
60
+ const payload = {
61
+ systemMessage: notice,
62
+ hookSpecificOutput: {
63
+ hookEventName: "SessionStart",
64
+ additionalContext: notice,
65
+ },
66
+ };
67
+ await (options.stdout ?? writeStdout)(`${JSON.stringify(payload)}\n`);
68
+ }
69
+ }
70
+ catch {
71
+ // Contained without logging: a hook must never fail a session start.
72
+ }
73
+ return 0;
74
+ }
@@ -62,8 +62,16 @@ export function mergeClaudeSettingsWithCommandHook(settings, command, events, op
62
62
  hooks[event] = entries;
63
63
  continue;
64
64
  }
65
- const newEntry = { hooks: [{ type: "command", command }] };
66
- if (event === "PreToolUse") {
65
+ const leaf = { type: "command", command };
66
+ const timeout = options.eventTimeouts?.[event];
67
+ if (timeout !== undefined)
68
+ leaf.timeout = timeout;
69
+ const newEntry = { hooks: [leaf] };
70
+ const eventMatcher = options.eventMatchers?.[event];
71
+ if (eventMatcher !== undefined) {
72
+ newEntry.matcher = eventMatcher;
73
+ }
74
+ else if (event === "PreToolUse") {
67
75
  // Explicit matcher wins; else mirror any existing PreToolUse matcher; else
68
76
  // fall back to the broad default.
69
77
  newEntry.matcher =
@@ -75,6 +83,80 @@ export function mergeClaudeSettingsWithCommandHook(settings, command, events, op
75
83
  }
76
84
  return { ...settings, hooks };
77
85
  }
86
+ function isPlainObject(value) {
87
+ return value !== null && typeof value === "object" && !Array.isArray(value);
88
+ }
89
+ /**
90
+ * Shape guard for the hook containers a provisioner is about to write into
91
+ * (BAPI-1446). An ABSENT `hooks` object or event array is fine: it will be
92
+ * created. A PRESENT one of the wrong type (`hooks` that is an array, a string, or
93
+ * null; an event that is an object or a string) is `malformed`, and must be
94
+ * reported and left alone rather than replaced with an empty container.
95
+ */
96
+ export function inspectClaudeHookContainers(settings, events) {
97
+ const hooks = settings.hooks;
98
+ if (hooks === undefined)
99
+ return "ok";
100
+ if (!isPlainObject(hooks))
101
+ return "malformed";
102
+ for (const event of events) {
103
+ const entries = hooks[event];
104
+ if (entries !== undefined && !Array.isArray(entries))
105
+ return "malformed";
106
+ }
107
+ return "ok";
108
+ }
109
+ /**
110
+ * {@link mergeClaudeSettingsWithCommandHook} behind the shape guard. A malformed
111
+ * existing container is refused: nothing is merged and the caller's settings are
112
+ * not touched. Use this for new provisioning; the legacy merge keeps its
113
+ * original lenient behavior for its existing callers.
114
+ */
115
+ export function mergeClaudeSettingsWithCommandHookChecked(settings, command, events, options = {}) {
116
+ const checked = options.enablePreToolUse && !events.includes("PreToolUse")
117
+ ? [...events, "PreToolUse"]
118
+ : events;
119
+ if (inspectClaudeHookContainers(settings, checked) === "malformed") {
120
+ return { ok: false, reason: "malformed-hooks" };
121
+ }
122
+ return { ok: true, settings: mergeClaudeSettingsWithCommandHook(settings, command, events, options) };
123
+ }
124
+ /**
125
+ * Remove ONE exact command from an event, immutably. Only command leaves whose
126
+ * command string equals `command` are removed; an entry left with no hooks is
127
+ * dropped, and everything else (other leaves, other entries, other events, other
128
+ * settings) is kept as is. Returns the SAME object when nothing matches or the
129
+ * relevant structure is malformed, so a caller can detect "no change" by identity.
130
+ * An emptied event array or `hooks` object is left in place: the user may own it.
131
+ */
132
+ export function removeClaudeSettingsCommandHook(settings, event, command) {
133
+ const hooks = settings.hooks;
134
+ if (!isPlainObject(hooks))
135
+ return settings;
136
+ const entries = hooks[event];
137
+ if (!Array.isArray(entries))
138
+ return settings;
139
+ let changed = false;
140
+ const nextEntries = [];
141
+ for (const entry of entries) {
142
+ if (!isPlainObject(entry) || !Array.isArray(entry.hooks)) {
143
+ nextEntries.push(entry);
144
+ continue;
145
+ }
146
+ const leaves = entry.hooks;
147
+ const kept = leaves.filter((leaf) => !(isPlainObject(leaf) && leaf.type === "command" && leaf.command === command));
148
+ if (kept.length === leaves.length) {
149
+ nextEntries.push(entry);
150
+ continue;
151
+ }
152
+ changed = true;
153
+ if (kept.length > 0)
154
+ nextEntries.push({ ...entry, hooks: kept });
155
+ }
156
+ if (!changed)
157
+ return settings;
158
+ return { ...settings, hooks: { ...hooks, [event]: nextEntries } };
159
+ }
78
160
  /**
79
161
  * Provision (merge into) ONE worktree's `.claude/settings.local.json`. Missing
80
162
  * settings are treated as `{}`; malformed JSON is a safety stop (the file is
@@ -127,3 +209,21 @@ export async function provisionClaudeSettingsForWorktree(worktreePath, mergeSett
127
209
  }
128
210
  return { ok: true };
129
211
  }
212
+ /**
213
+ * The Claude Code settings key that turns auto-memory off (BAPI-1397, F6).
214
+ *
215
+ * Confirmed against the installed Claude Code 2.1.287: auto-memory is OFF when
216
+ * the merged settings carry `autoMemoryEnabled: false`, or when the environment
217
+ * sets `CLAUDE_CODE_DISABLE_AUTO_MEMORY` to a truthy value (which wins over the
218
+ * setting). Both forms are applied to executor workers.
219
+ */
220
+ export const CLAUDE_AUTO_MEMORY_SETTING_KEY = "autoMemoryEnabled";
221
+ /** The environment form of the same control; a truthy value turns auto-memory off. */
222
+ export const CLAUDE_DISABLE_AUTO_MEMORY_ENV = "CLAUDE_CODE_DISABLE_AUTO_MEMORY";
223
+ /**
224
+ * Merge `autoMemoryEnabled: false` into a Claude settings object, keeping every
225
+ * other entry. Idempotent: re-applying it yields an equal object.
226
+ */
227
+ export function mergeClaudeSettingsWithAutoMemoryDisabled(settings) {
228
+ return { ...settings, [CLAUDE_AUTO_MEMORY_SETTING_KEY]: false };
229
+ }
@@ -0,0 +1,27 @@
1
+ import { MCP_PACKAGE_NAME } from "./mcp-identity.js";
2
+ /** The one recovery command shared by terminal guidance surfaces. */
3
+ export const INSTALL_RECOVERY_COMMAND = `npx -y ${MCP_PACKAGE_NAME} install`;
4
+ /**
5
+ * Returns static CLI orientation text without resolving configuration or doing I/O.
6
+ *
7
+ * Internal subcommands (`mcp-invoke`, `check-update`) are routed by the
8
+ * dispatcher but are intentionally not listed: they are launched by tools and
9
+ * hooks, not typed by a person.
10
+ */
11
+ export function getTopLevelCliUsage() {
12
+ return `Usage: bridge-api-mcp-server [command]
13
+
14
+ Commands:
15
+ install Guided project and MCP host setup.
16
+ serve Run the MCP server over stdio.
17
+ No command also starts the stdio MCP server.
18
+
19
+ Already ran npm i ${MCP_PACKAGE_NAME}?
20
+ The package is installed; project and MCP host setup still need the installer.
21
+ From your intended project root, run:
22
+ ${INSTALL_RECOVERY_COMMAND}
23
+
24
+ No uninstall is needed. Follow the remaining setup instructions.
25
+ Run install --help for detailed installer options.
26
+ `;
27
+ }
@@ -1,7 +1,15 @@
1
1
  import path from "node:path";
2
2
  import os from "node:os";
3
+ /**
4
+ * True when `CODEX_HOME` is set to an absolute path, which is the only override
5
+ * Codex's user config root accepts. A relative or blank value is ignored.
6
+ */
7
+ export function isCodexHomeOverrideHonored(env) {
8
+ const override = env.CODEX_HOME?.trim();
9
+ return Boolean(override) && path.isAbsolute(override);
10
+ }
3
11
  /** Codex's user config root; only an absolute CODEX_HOME is accepted. */
4
12
  export function codexHome(env, homedir = os.homedir()) {
5
13
  const override = env.CODEX_HOME?.trim();
6
- return override && path.isAbsolute(override) ? override : path.join(homedir, ".codex");
14
+ return isCodexHomeOverrideHonored(env) ? override : path.join(homedir, ".codex");
7
15
  }