@bridge_gpt/mcp-server 0.2.36 → 0.2.37

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 (90) hide show
  1. package/README.md +44 -6
  2. package/build/base-url.js +79 -0
  3. package/build/bridge-api-urls.js +9 -0
  4. package/build/chain-orchestrator.js +93 -15
  5. package/build/claude-user-config-doctor.js +317 -0
  6. package/build/commands.generated.js +2 -1
  7. package/build/conductor/bridge-api-client.js +178 -4
  8. package/build/conductor-bin.js +1 -1
  9. package/build/conductor-bundle-artifacts.js +7 -6
  10. package/build/credential-store.js +205 -4
  11. package/build/direct-ticket-tools.js +70 -0
  12. package/build/doctor.js +239 -80
  13. package/build/executor/cli.js +51 -1
  14. package/build/executor/credentials.js +1 -7
  15. package/build/executor/deps.js +18 -1
  16. package/build/executor/env.js +51 -25
  17. package/build/executor/heartbeat.js +138 -17
  18. package/build/executor/http-client.js +49 -8
  19. package/build/executor/job-errors.js +4 -0
  20. package/build/executor/job-runner.js +422 -22
  21. package/build/executor/observation.js +130 -0
  22. package/build/executor/permissions.js +104 -8
  23. package/build/executor/preflight.js +32 -0
  24. package/build/executor/runner.js +8 -0
  25. package/build/executor/test-clock.js +67 -3
  26. package/build/executor/types.js +4 -1
  27. package/build/executor/worker-command.js +11 -3
  28. package/build/executor/worker-config-isolation.js +287 -0
  29. package/build/executor/worker-finalization.js +68 -14
  30. package/build/executor/worktree.js +46 -4
  31. package/build/index.js +614 -244
  32. package/build/init.js +363 -73
  33. package/build/install-bridge.js +568 -80
  34. package/build/launcher-config-inspection.js +351 -0
  35. package/build/mcp-invoke.js +49 -6
  36. package/build/mcp-provisioning.js +30 -7
  37. package/build/mcp-registration-doctor.js +14 -5
  38. package/build/notifications.js +553 -0
  39. package/build/pipeline-orchestrator.js +146 -4
  40. package/build/pipeline-utils.js +3 -0
  41. package/build/pipelines.generated.js +22 -9
  42. package/build/plan-execution-ledger.js +550 -0
  43. package/build/plan-phase-routing.js +272 -0
  44. package/build/plane/alembic-head.js +110 -0
  45. package/build/plane/build-freshness.js +167 -0
  46. package/build/plane/cli.js +480 -0
  47. package/build/plane/defaults.js +266 -0
  48. package/build/plane/manifest.js +377 -0
  49. package/build/plane/member-logs.js +147 -0
  50. package/build/plane/member-roster.js +147 -0
  51. package/build/plane/preflight.js +289 -0
  52. package/build/plane/shutdown.js +195 -0
  53. package/build/plane/status.js +125 -0
  54. package/build/plane/supervisor.js +569 -0
  55. package/build/plane/test-fakes.js +156 -0
  56. package/build/plane/types.js +75 -0
  57. package/build/readme.generated.js +1 -1
  58. package/build/run-unit-tests-launcher.js +2 -0
  59. package/build/setup-epic.js +662 -27
  60. package/build/sfcc/log-gate.js +38 -11
  61. package/build/sfcc/log-query.js +55 -15
  62. package/build/sfcc/ocapi-shape.js +51 -14
  63. package/build/sfcc/output.js +41 -11
  64. package/build/sfcc/permissions.js +24 -2
  65. package/build/sfcc/read-projection.js +181 -0
  66. package/build/sfcc/read-result.js +158 -0
  67. package/build/sfcc/reads-custom-object-def.js +29 -18
  68. package/build/sfcc/reads-site-preference.js +75 -29
  69. package/build/sfcc/reads-system-object.js +40 -34
  70. package/build/sfcc/sfcc-result.js +106 -0
  71. package/build/sfcc/tool-wrapper.js +56 -13
  72. package/build/sfcc/write-grants.js +45 -22
  73. package/build/sfcc/write-guard.js +21 -13
  74. package/build/sfcc/write-result.js +61 -14
  75. package/build/sfcc/write-tool-common.js +126 -32
  76. package/build/sfcc/writes-system-object.js +11 -50
  77. package/build/start-tickets-prereqs.js +129 -0
  78. package/build/start-tickets.js +17 -13
  79. package/build/ticket-backend-metadata.js +59 -0
  80. package/build/ticket-key-utils.js +92 -0
  81. package/build/tool-error-envelope.js +71 -0
  82. package/build/tool-surface-gating.js +72 -0
  83. package/build/update-status.js +102 -0
  84. package/build/upgrade-advice.js +47 -0
  85. package/build/upgrade-cli.js +417 -101
  86. package/build/version.generated.js +1 -1
  87. package/build/worktree-core.js +73 -0
  88. package/docs/CONDUCTOR.md +23 -8
  89. package/package.json +3 -3
  90. package/pipelines/implement-ticket.json +15 -5
@@ -144,6 +144,13 @@ export async function isExistingBranchSafeToReuse(deps, branch, baseStartPoint)
144
144
  * instead of being silently reused as-is. This stays executor-agnostic: no
145
145
  * job-type logic lives here — the caller decides the start point, the stale
146
146
  * guard, and the freshen behavior.
147
+ *
148
+ * BAPI-727: each of the two RESET paths is followed by an untracked-file cleanup
149
+ * (see {@link cleanUntrackedWorktree}). That coupling is what keeps `resume`
150
+ * excluded BY CONSTRUCTION rather than by a job-type check: the resume caller
151
+ * supplies neither `freshenFromOrigin` nor `alignExistingBranchTo`, so it reaches
152
+ * neither reset and therefore neither cleanup, and its unpushed local work is
153
+ * preserved exactly as before.
147
154
  */
148
155
  /**
149
156
  * Hard-reset the branch checked out in `worktreePath` onto `ref`. Returns null on
@@ -159,6 +166,64 @@ async function hardResetWorktree(deps, worktreePath, ref) {
159
166
  }
160
167
  return null;
161
168
  }
169
+ /** The one fixed, sanitized diagnostic emitted for ANY cleanup failure. */
170
+ const CLEANUP_FAILURE_DIAGNOSTIC = "untracked-file cleanup did not complete; continuing with the reset worktree";
171
+ /**
172
+ * BAPI-727: remove untracked residue from a worktree that was just hard-reset.
173
+ *
174
+ * `git reset --hard` restores TRACKED files but leaves untracked ones in place, so
175
+ * a reused worktree carried a prior attempt's scratch files into the next run. This
176
+ * removes them with exactly `git clean -fd`.
177
+ *
178
+ * `-x` IS FORBIDDEN, and `-fdx` doubly so: ignored paths in a prepared worktree are
179
+ * precisely the executor-owned assets — `.mcp.json` / `.cursor/mcp.json`
180
+ * registrations, worker environment files, installed dependencies, worker logs, and
181
+ * the provisioned `.claude/commands/` assets. `-fdx` would destroy all of them.
182
+ *
183
+ * Note that `.claude/settings.local.json` is NOT ignored by this repository, so
184
+ * plain `-fd` may remove it on some hosts. That is safe only because of WHERE this
185
+ * runs: cleanup happens during worktree PREPARATION, before command assets, deny
186
+ * settings, MCP registrations/trust, and worker logging are provisioned again — so
187
+ * anything cleanup removes is re-created by the provisioning that follows it.
188
+ *
189
+ * Stale, non-ignored `.conductor/result.json` and `.conductor/critique.md` from a
190
+ * prior attempt are removed intentionally: a leftover verdict artifact read by a
191
+ * later attempt would be a prior run's answer presented as this one's.
192
+ *
193
+ * FAIL-OPEN. Pre-change behavior performed no cleanup at all, so being unable to
194
+ * clean must never change the worktree row or the job outcome. Every failure path —
195
+ * a non-zero exit, a thrown runner — emits the one fixed diagnostic and returns
196
+ * normally, and the throw is caught HERE so the outer `createWorktreeForTicket()`
197
+ * catch cannot convert it into `create-failed`.
198
+ */
199
+ async function cleanUntrackedWorktree(deps, worktreePath) {
200
+ const emit = deps.onCleanupDiagnostic;
201
+ const report = (message) => {
202
+ if (emit)
203
+ emit(message);
204
+ };
205
+ try {
206
+ const result = await deps.runCommand("git", ["clean", "-fd"], { cwd: worktreePath });
207
+ // Report removals even when the command later failed: paths Git printed on
208
+ // stdout were genuinely removed, and losing that record would make a partial
209
+ // cleanup invisible. Only lines with Git's standard `Removing ` prefix are
210
+ // read; all other output is discarded rather than serialized.
211
+ for (const line of result.stdout.split(/\r?\n/)) {
212
+ if (!line.startsWith("Removing "))
213
+ continue;
214
+ const removed = line.slice("Removing ".length).trim();
215
+ if (removed.length > 0)
216
+ report(`removed untracked path: ${removed}`);
217
+ }
218
+ if (!commandSucceeded(result))
219
+ report(CLEANUP_FAILURE_DIAGNOSTIC);
220
+ }
221
+ catch {
222
+ // Never interpolate the thrown exception: a command-runner error message can
223
+ // carry an environment dump or an argv fragment.
224
+ report(CLEANUP_FAILURE_DIAGNOSTIC);
225
+ }
226
+ }
162
227
  /**
163
228
  * BAPI-586: resolve the worktree's `HEAD^{commit}` and the `expected` ref/commit
164
229
  * and confirm they are equal. Returns null when they match, or a bounded,
@@ -223,6 +288,10 @@ export async function createWorktreeForTicket(deps, key, branchOverrides, worktr
223
288
  if (resetError) {
224
289
  return { key, branch, status: "create-failed", error: resetError };
225
290
  }
291
+ // BAPI-727: the reset restored tracked files; drop the untracked residue a
292
+ // prior attempt left behind. Only after a SUCCESSFUL reset — a failed reset
293
+ // returns above, so a worktree in an unknown state is never cleaned.
294
+ await cleanUntrackedWorktree(deps, worktreePath);
226
295
  }
227
296
  // BAPI-586 (fresh dispatch): a guard-approved pre-existing branch is an
228
297
  // ancestor of base but may sit at an OLDER tip. Align it EXACTLY to the
@@ -235,6 +304,10 @@ export async function createWorktreeForTicket(deps, key, branchOverrides, worktr
235
304
  if (resetError) {
236
305
  return { key, branch, status: "create-failed", error: resetError };
237
306
  }
307
+ // BAPI-727: same cleanup on the fresh-dispatch alignment path. The resulting
308
+ // fresh-dispatch order is: stale-branch guard, Worktrunk switch, hard reset,
309
+ // untracked clean, then `verifyHeadMatches` below.
310
+ await cleanUntrackedWorktree(deps, worktreePath);
238
311
  }
239
312
  // BAPI-586 (fresh dispatch): verify the worktree actually starts at the
240
313
  // pinned base. If Worktrunk seeded from an unexpected sibling despite
package/docs/CONDUCTOR.md CHANGED
@@ -64,9 +64,17 @@ pipeline step. `setup-epic` validates it locally (unique ticket keys, resolvable
64
64
  `depends_on`/edge references, acyclicity) before sending anything, so a malformed
65
65
  plan fails legibly instead of as a bare HTTP 400.
66
66
 
67
+ Since BAPI-754 it then calls the server's **real** validator
68
+ (`POST /jira/epic-runs/plan/validate`) before creating anything, so a plan the
69
+ server would reject — a node missing `status`, say, which the local checks do not
70
+ cover — no longer creates a run and incurs an automation-start charge on its way
71
+ to failing.
72
+
67
73
  It is **idempotent**: re-running it on an epic that already has a live run reuses
68
- that run rather than minting a second one. Use `--dry-run` to validate a plan and
69
- preview the calls without mutating anything.
74
+ that run rather than minting a second one. Use `--dry-run` to run that
75
+ authoritative validation and preview the calls without mutating anything; add
76
+ `--local-only` to skip the server entirely, which reports
77
+ `partial (local checks only)` and is never a substitute for the server's verdict.
70
78
 
71
79
  Once the plan is approved the run becomes `active`, the server-side reconciler
72
80
  picks it up within ~30s, and your local `executor` starts claiming jobs.
@@ -139,12 +147,19 @@ the real, always-reporting required context **`conductor-ci / gate`**; set
139
147
  on every run you want gated. The workflow existing is not enough — the context has
140
148
  to be in the run policy.
141
149
 
142
- > **`setup-epic` has no flag for this.** There is no `--required-checks` option, so a
143
- > run created by `setup-epic` starts with an **empty** `required_checks` and its `ci`
144
- > gate short-circuits to `PASSED` until you wire it. Because `setup-epic` also
145
- > approves the plan making the run `active` and visible to the reconciler within
146
- > ~30s wire the policy by PATCH **immediately** after setup, before any ticket can
147
- > reach its `ci` gate.
150
+ > **Wire it at creation with `--policy-file` (BAPI-754).** There is still no
151
+ > `--required-checks` option, but `setup-epic --policy-file <path>` sends the
152
+ > **complete** run policy on the create that mints the run, so the run is born with
153
+ > `required_checks` already in force. A run created *without* a policy still starts
154
+ > with an **empty** `required_checks` and a `ci` gate that short-circuits to
155
+ > `PASSED` and because `setup-epic` also approves the plan, making the run
156
+ > `active` and visible to the reconciler within ~30s, there is no comfortable window
157
+ > to fix that afterwards. Supply the policy file up front.
158
+ >
159
+ > To change the policy on a run that is already live, re-run with `--policy-file`:
160
+ > an identical policy is a no-op, and a divergent one is **refused** with a redacted
161
+ > diff unless you also pass `--replace-policy` (which applies it as a complete
162
+ > replacement).
148
163
 
149
164
  > **This is NOT `done_gate_config`.** The per-run `policy_json.required_checks`
150
165
  > read by the reconciler `ci` gate is a *different* surface from the supervisor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bridge_gpt/mcp-server",
3
- "version": "0.2.36",
3
+ "version": "0.2.37",
4
4
  "description": "Bridge API MCP server — exposes Jira endpoints as MCP tools for Claude Code agents",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "test": "npm run test:normal && npm run test:module-mocks",
30
30
  "test:normal": "node scripts/run-unit-tests.js normal",
31
31
  "test:module-mocks": "node scripts/run-unit-tests.js module-mocks",
32
- "test:integration": "node --test build/integration/refresh-main.integration.test.js build/integration/command-provisioning.integration.test.js build/integration/start-tickets.integration.test.js build/integration/start-tickets-tier-handoff.integration.test.js build/integration/doctor.integration.test.js build/integration/agent-capabilities.integration.test.js build/integration/conductor-producer.integration.test.js build/integration/conductor-message-relay.integration.test.js build/integration/executor-http-runner.integration.test.js build/integration/executor-job-behaviors.integration.test.js build/integration/executor-recovery-jobs.integration.test.js build/integration/executor-spec-review-prompt.integration.test.js build/integration/resume-pre-spawn.git.integration.test.js build/integration/worker-finalization-origin.integration.test.js build/integration/post-remediation-merge-ci-wait.integration.test.js build/integration/executor-merge-supervision.integration.test.js build/integration/attachment-binary-roundtrip.integration.test.js build/integration/dependent-ticket-fresh-base.integration.test.js build/integration/execute-plan-instructions.integration.test.js build/integration/implement-ticket-finalization-order.integration.test.js build/integration/conductor-bundle-artifacts.integration.test.js build/integration/install-bridge-repo-resolution.integration.test.js build/integration/capability-report-contract.integration.test.js build/integration/request-brainstorm-general.integration.test.js build/integration/request-council-trigger-drop.integration.test.js build/integration/install-bridge-onboarding-launch.integration.test.js build/integration/install-bridge-conductor.integration.test.js build/integration/install-bridge-failure-guards.integration.test.js build/integration/learn-repository-pipeline.integration.test.js build/integration/visual-diff-mcp.integration.test.js build/integration/executor-mcp-provisioning.integration.test.js build/integration/serve-stdio.integration.test.js build/integration/install-alias.integration.test.js",
32
+ "test:integration": "node --test build/integration/refresh-main.integration.test.js build/integration/command-provisioning.integration.test.js build/integration/start-tickets.integration.test.js build/integration/start-tickets-tier-handoff.integration.test.js build/integration/doctor.integration.test.js build/integration/agent-capabilities.integration.test.js build/integration/conductor-producer.integration.test.js build/integration/conductor-message-relay.integration.test.js build/integration/executor-http-runner.integration.test.js build/integration/executor-job-behaviors.integration.test.js build/integration/executor-recovery-jobs.integration.test.js build/integration/executor-spec-review-prompt.integration.test.js build/integration/resume-pre-spawn.git.integration.test.js build/integration/worker-finalization-origin.integration.test.js build/integration/post-remediation-merge-ci-wait.integration.test.js build/integration/executor-merge-supervision.integration.test.js build/integration/attachment-binary-roundtrip.integration.test.js build/integration/dependent-ticket-fresh-base.integration.test.js build/integration/execute-plan-instructions.integration.test.js build/integration/implement-ticket-finalization-order.integration.test.js build/integration/conductor-bundle-artifacts.integration.test.js build/integration/install-bridge-repo-resolution.integration.test.js build/integration/capability-report-contract.integration.test.js build/integration/request-brainstorm-general.integration.test.js build/integration/request-council-trigger-drop.integration.test.js build/integration/install-bridge-onboarding-launch.integration.test.js build/integration/install-bridge-conductor.integration.test.js build/integration/install-bridge-failure-guards.integration.test.js build/integration/learn-repository-pipeline.integration.test.js build/integration/visual-diff-mcp.integration.test.js build/integration/executor-mcp-provisioning.integration.test.js build/integration/executor-worktree-reentry.integration.test.js build/integration/sfcc-read-error-contract.integration.test.js build/integration/sfcc-response-envelope.integration.test.js build/integration/sfcc-total-error-contract.integration.test.js build/integration/serve-stdio.integration.test.js build/integration/install-alias.integration.test.js build/integration/setup-epic-validation.integration.test.js build/integration/plane-cli.integration.test.js",
33
33
  "test:smoke": "node --test build/integration/packaged-cli-smoke.test.js",
34
34
  "canary:agent-capabilities": "npm run build && node scripts/agent-capabilities-canary.mjs",
35
35
  "prepublishOnly": "node scripts/bundle-assets.js && npm run build && node scripts/verify-shebang.cjs"
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "overrides": {
58
58
  "fast-uri": ">=4.1.1",
59
- "hono": ">=4.12.31",
59
+ "hono": ">=4.13.1",
60
60
  "@hono/node-server": "^1.19.13",
61
61
  "ip-address": ">=10.1.1"
62
62
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "implement-ticket",
3
- "description": "Generate plan, execute implementation, commit, open PR, verify, and monitor CI.",
4
- "variables": ["ticket_key", "docs_dir"],
3
+ "description": "Generate plan, produce artifacts, checkpoint them to origin, run the plan's remaining verification faithfully, commit, open PR, close post-PR gaps, and monitor CI. Re-entrant: recovery jobs (ci_fix/remediate/rebase) safely re-run this whole recipe from step 1 — the plan-generation step reuses a fresh existing plan (reused: true, no new run) and the produce phase recognizes work already recorded in the durable ledger instead of redoing it.",
4
+ "variables": ["ticket_key", "docs_dir", "provider"],
5
5
  "steps": [
6
6
  {
7
7
  "type": "mcp_call",
@@ -18,12 +18,22 @@
18
18
  "save_locally": true,
19
19
  "provider": "{provider}"
20
20
  },
21
- "description": "Generate implementation plan"
21
+ "description": "Generate implementation plan. Re-entry-safe: a non-forced request against a fresh existing plan returns reused: true and runs nothing new — the expected fast path on recovery re-entry. force is reserved for deliberate regeneration; this step never sets it. On a GATEWAY_TIMEOUT/504 response, poll get_plan (or the response's recovery_get URL) until a terminal result — never reissue this step."
22
22
  },
23
23
  {
24
24
  "type": "agent_task",
25
25
  "instruction_file": "execute-plan.md",
26
- "description": "Execute the implementation plan"
26
+ "description": "Produce the plan's implementation artifacts"
27
+ },
28
+ {
29
+ "type": "agent_task",
30
+ "instruction_file": "checkpoint-work.md",
31
+ "description": "Checkpoint produced work to origin before verification begins"
32
+ },
33
+ {
34
+ "type": "agent_task",
35
+ "instruction_file": "execute-plan-verification.md",
36
+ "description": "Execute the plan's remaining review, test, and rendered-UI steps before the PR opens"
27
37
  },
28
38
  {
29
39
  "type": "agent_task",
@@ -39,7 +49,7 @@
39
49
  {
40
50
  "type": "agent_task",
41
51
  "instruction_file": "verify-plan.md",
42
- "description": "Run bounded post-finalization verification and push any correction"
52
+ "description": "Close post-PR plan gaps and push any correction"
43
53
  },
44
54
  {
45
55
  "type": "mcp_call",