@bridge_gpt/mcp-server 0.2.74 → 0.2.76

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 (102) hide show
  1. package/README.md +14 -7
  2. package/build/agent-launchers/prompt.js +9 -21
  3. package/build/agents.generated.js +6 -6
  4. package/build/authored-plan.js +542 -0
  5. package/build/bridge-permissions.js +8 -0
  6. package/build/codex-auto-recovery.js +25 -7
  7. package/build/commands.generated.js +7 -7
  8. package/build/conductor/bridge-api-client.js +807 -52
  9. package/build/conductor/declare-blocked.js +4 -0
  10. package/build/conductor/driver-pass.js +8 -0
  11. package/build/conductor/epic-implementer-cli.js +341 -96
  12. package/build/conductor/epic-server-journal.js +13 -0
  13. package/build/conductor/epic-server-recipe.js +15 -5
  14. package/build/conductor/epic-server-runtime.js +163 -45
  15. package/build/conductor/epic-server.js +13 -6
  16. package/build/conductor/gate-discovery.js +209 -9
  17. package/build/conductor/gate-settings-review.js +7 -11
  18. package/build/conductor/install-doctor.js +30 -2
  19. package/build/conductor/launch-plan.js +58 -12
  20. package/build/conductor/local-merge.js +54 -12
  21. package/build/conductor/open-decision-phrases.js +50 -0
  22. package/build/conductor/pr-ci-producer.js +12 -3
  23. package/build/conductor/prerequisite-inputs.js +181 -14
  24. package/build/conductor/readiness-sections.js +46 -13
  25. package/build/conductor/readiness.js +3 -40
  26. package/build/conductor/recovery-cli.js +12 -12
  27. package/build/conductor/repository-workflow-remedy.js +147 -7
  28. package/build/conductor/ui-readiness.js +224 -0
  29. package/build/conductor/wait-run-attention.js +9 -4
  30. package/build/conductor/wait-run-cli.js +9 -2
  31. package/build/connect-github-api.js +18 -0
  32. package/build/connect-github.js +35 -18
  33. package/build/docs.generated.js +3 -3
  34. package/build/drive-epic.js +787 -37
  35. package/build/epic-ci-workflow.js +3 -2
  36. package/build/epic-implementer-bin.js +200 -66
  37. package/build/epic-implementer-bundle-cli.js +61 -0
  38. package/build/epic-implementer-claude-hook-bin.js +1 -1
  39. package/build/epic-implementer-env.js +3 -4
  40. package/build/epic-integration-pr.js +5 -2
  41. package/build/epic-launch-context.js +8 -1
  42. package/build/epic-shared/cut-protocol.js +55 -3
  43. package/build/executor/completion-contract.js +24 -1
  44. package/build/executor/failure-reason-codes.js +2 -0
  45. package/build/executor/gate-qualification-job.js +193 -23
  46. package/build/executor/gate-qualification-tests-ran.js +232 -0
  47. package/build/executor/integration-job.js +56 -2
  48. package/build/executor/job-runner.js +13 -723
  49. package/build/executor/job-type-wrappers.js +734 -0
  50. package/build/executor/merge-job.js +45 -1
  51. package/build/executor/permissions.js +187 -2
  52. package/build/executor/preflight.js +6 -2
  53. package/build/executor/process-containment.js +8 -1
  54. package/build/executor/provider-checks.js +28 -5
  55. package/build/executor/reconcile-overlap-job.js +70 -17
  56. package/build/executor/required-verification.js +28 -2
  57. package/build/executor/required-work-ledger.js +7 -2
  58. package/build/executor/resume-pre-spawn.js +32 -8
  59. package/build/executor/runner.js +30 -5
  60. package/build/executor/types.js +9 -0
  61. package/build/executor/worker-database.js +6 -1
  62. package/build/executor/worker-guard-hook.js +24 -2
  63. package/build/executor/worktree.js +12 -1
  64. package/build/generated/ticket-status.js +20 -0
  65. package/build/index.js +627 -551
  66. package/build/init.js +16 -0
  67. package/build/install-bridge-conductor-answers.js +32 -1
  68. package/build/install-bridge-conductor-apply.js +21 -3
  69. package/build/install-bridge-conductor-assessment.js +185 -12
  70. package/build/install-bridge-conductor-compact.js +2 -0
  71. package/build/install-bridge-conductor-contracts.js +9 -1
  72. package/build/install-bridge-conductor-gate.js +257 -80
  73. package/build/install-bridge-conductor-setup.js +106 -6
  74. package/build/install-bridge-conductor-trial-report.js +170 -0
  75. package/build/install-bridge-conductor.js +740 -124
  76. package/build/mcp-host-config.js +54 -37
  77. package/build/phase-context-git-probe.js +16 -0
  78. package/build/pipelines.generated.js +15 -15
  79. package/build/plan-execution-ledger.js +27 -0
  80. package/build/plan-generation.js +17 -0
  81. package/build/plane/plane-freshness.js +43 -26
  82. package/build/printed-remedy-commands.js +62 -0
  83. package/build/readme.generated.js +1 -1
  84. package/build/repository-toolchains.js +11 -5
  85. package/build/scripts/saved-commands-config-field-driver.js +65 -0
  86. package/build/secret-redaction.js +3 -0
  87. package/build/setup-epic.js +51 -9
  88. package/build/test-support/create-preview-world.js +232 -0
  89. package/build/test-support/executor-source-files.js +1 -1
  90. package/build/ticket-delivery.js +65 -0
  91. package/build/v2-readiness-requirements.js +13 -4
  92. package/build/version.generated.js +3 -3
  93. package/build/worker-guard-hook-bin.js +2 -2
  94. package/build/worktree-core.js +51 -7
  95. package/docs/EPIC-IMPLEMENTER.md +83 -4
  96. package/docs/epic-implementer/getting-started.md +1 -1
  97. package/docs/install/github-app.md +79 -92
  98. package/package.json +1 -1
  99. package/pipelines/implement-ticket.json +2 -2
  100. package/build/conductor/epic-reconcile.js +0 -603
  101. package/build/conductor/epic-runtime.js +0 -2020
  102. package/build/conductor/epic-state.js +0 -774
@@ -222,6 +222,31 @@ export const ESCALATION_CATEGORIES = [
222
222
  "prerequisite_not_built",
223
223
  "other",
224
224
  ];
225
+ /**
226
+ * BAPI-1712: the observed failure behind an outside escalation category. Optional
227
+ * metadata on an escalated record. The server, not this client, decides whether it
228
+ * is well formed and whether it fits the category: only a well-formed observation
229
+ * whose `observed_head_sha` matches the current head lets the server report the
230
+ * blocker `external` / `report_and_end`. Bridge cannot prove a host-local failure
231
+ * happened, so such an end carries provenance `worker_attested`.
232
+ *
233
+ * The client never validates, coerces, or strips it. A missing or malformed value
234
+ * never rejects a record; the server stores it as absent. Mirrors the server's
235
+ * blocker-observation shape; both sides must agree.
236
+ */
237
+ export const BLOCKER_OBSERVATION_OPERATION_KINDS = [
238
+ "bridge_tool",
239
+ "provider_api",
240
+ "local_command",
241
+ "network",
242
+ ];
243
+ export const BLOCKER_OBSERVATION_FAILURE_KINDS = [
244
+ "denied",
245
+ "not_found",
246
+ "unavailable",
247
+ "timeout",
248
+ "conflict",
249
+ ];
225
250
  /**
226
251
  * Which phase must settle each class of step.
227
252
  *
@@ -599,6 +624,8 @@ function validateRecordShape(record, metadata, phase) {
599
624
  // BAPI-1608: `escalationCategory` is deliberately not checked here. It is
600
625
  // optional advisory metadata, so an unknown string or a non-string value never
601
626
  // rejects an otherwise valid record.
627
+ // BAPI-1712: `blockerObservation` / `blocker_observation` are likewise never
628
+ // checked. The server normalizes them; a malformed value is stored as absent.
602
629
  // BAPI-1552: mirrors the server, which refuses this cause on a non-escalated
603
630
  // record before any generic disposition check can hide the closed code.
604
631
  const handoffValue = record.handoff;
@@ -71,6 +71,8 @@ export const PLAN_GENERATION_EXCLUSION_REASONS = ["unfinished_spike"];
71
71
  export const PLAN_GENERATION_ORDER_SOURCES = ["epic_manifest", "key_order"];
72
72
  /** Why the plan runs one child at a time, when it does. */
73
73
  export const PLAN_GENERATION_SERIALIZED_REASONS = ["unknown_touched_files", "key_order_fallback"];
74
+ /** Why a present ordered-child-manifest section did not supply the plan's order. */
75
+ export const PLAN_GENERATION_ORDER_FALLBACK_REASONS = ["manifest_unreadable"];
74
76
  /** The backend status categories the builder recognizes. */
75
77
  export const RECOGNIZED_STATUS_CATEGORIES = ["new", "indeterminate", "done"];
76
78
  /** Ticket keys in stored text. */
@@ -316,13 +318,26 @@ export function parseGeneratedPlanSummary(value) {
316
318
  return null;
317
319
  unknownFiles.push(key);
318
320
  }
321
+ let fallbackReason;
322
+ if (Object.prototype.hasOwnProperty.call(record, "order_fallback_reason")) {
323
+ if (!isOneOf(PLAN_GENERATION_ORDER_FALLBACK_REASONS, record.order_fallback_reason))
324
+ return null;
325
+ fallbackReason = record.order_fallback_reason;
326
+ }
319
327
  return {
320
328
  order_source: record.order_source,
321
329
  serialized_reason: serialized,
330
+ ...(fallbackReason === undefined ? {} : { order_fallback_reason: fallbackReason }),
322
331
  excluded,
323
332
  unknown_files: unknownFiles,
324
333
  };
325
334
  }
335
+ /** Any Markdown (levels 1-6) or Jira (h1.-h6.) heading starting "ordered child manifest". */
336
+ const ANY_MANIFEST_HEADING = /^\s{0,3}(?:#{1,6}\s+|h[1-6]\.\s*)ordered child manifest/i;
337
+ /** True when the description has a heading line (not prose) naming an ordered child manifest. */
338
+ function hasManifestLikeHeading(description) {
339
+ return description.split(/\r?\n/).some((line) => ANY_MANIFEST_HEADING.test(line));
340
+ }
326
341
  // ---------------------------------------------------------------------------
327
342
  // The builder
328
343
  // ---------------------------------------------------------------------------
@@ -370,6 +385,7 @@ export function buildGeneratedEpicPlan(input) {
370
385
  const items = parseOrderedChildManifest(input.epicDescription);
371
386
  const manifest = items === null ? null : applyManifest(items, allKeys, retained, excludedKeys);
372
387
  const orderSource = manifest === null ? "key_order" : "epic_manifest";
388
+ const manifestUnreadable = manifest === null && hasManifestLikeHeading(input.epicDescription);
373
389
  const order = manifest?.order ?? [...retained].sort(compareTicketKeys);
374
390
  // --- Files. -----------------------------------------------------------------
375
391
  const inventory = buildTrackedInventory(input.trackedFiles);
@@ -417,6 +433,7 @@ export function buildGeneratedEpicPlan(input) {
417
433
  summary: {
418
434
  order_source: orderSource,
419
435
  serialized_reason: serializedReason,
436
+ ...(manifestUnreadable ? { order_fallback_reason: "manifest_unreadable" } : {}),
420
437
  excluded: [...excludedKeys].sort(compareTicketKeys).map((key) => ({ ticket_key: key, reason: "unfinished_spike" })),
421
438
  unknown_files: unknownFiles,
422
439
  },
@@ -24,6 +24,12 @@ import { monotonicNow, elapsedMs } from "../conductor/precheck-timings.js";
24
24
  *
25
25
  * Nothing here mutates the checkout, the plane, the database, power settings, or
26
26
  * any run. `git fetch` updates remote-tracking refs, which is the one write.
27
+ *
28
+ * Two collection modes. Ordinary collection compares the selected plane's pinned
29
+ * snapshot (from its manifest) and checks the database head. The cold-start,
30
+ * snapshot-only mode (`snapshotFromCheckoutHead`, BAPI-1725) runs before any plane
31
+ * exists: it compares the current checkout's `HEAD` with `origin/main` and reads no
32
+ * manifest and no database.
27
33
  */
28
34
  import { checkAlembicHead, } from "./alembic-head.js";
29
35
  import { planeCheckFinding, planeCheckPassed, planeCheckSkipped, } from "./types.js";
@@ -138,22 +144,29 @@ async function resolveCommit(deps, repoRoot, revision, timeoutMs) {
138
144
  return out !== null && HEX_OBJECT_ID.test(out) ? out : null;
139
145
  }
140
146
  async function checkSnapshot(repoRoot, deps, options, timeoutMs, manifestRead) {
141
- if (!options.ownsManifest) {
142
- return unverifiedSnapshot("no plane manifest in this checkout belongs to the selected plane");
143
- }
144
- if (manifestRead === null || manifestRead.kind !== "valid") {
145
- return unverifiedSnapshot("the plane manifest could not be read");
146
- }
147
- const manifest = manifestRead.manifest;
148
- if (manifest.repoRoot !== repoRoot) {
149
- return unverifiedSnapshot("the plane manifest belongs to a different checkout");
150
- }
151
- if (options.expectedPlaneId !== undefined && manifest.planeId !== options.expectedPlaneId) {
152
- return unverifiedSnapshot("the plane manifest is not the selected plane's");
153
- }
154
- const snapshotSha = manifest.snapshotSha;
155
- if (snapshotSha === undefined || !HEX_OBJECT_ID.test(snapshotSha)) {
156
- return unverifiedSnapshot("the plane manifest records no pinned snapshot");
147
+ // Cold-start mode compares the checkout's own HEAD, so the manifest ownership,
148
+ // identity, and pinned-snapshot requirements below do not apply to it.
149
+ const fromCheckoutHead = options.snapshotFromCheckoutHead === true;
150
+ let snapshotSha = "HEAD";
151
+ if (!fromCheckoutHead) {
152
+ if (!options.ownsManifest) {
153
+ return unverifiedSnapshot("no plane manifest in this checkout belongs to the selected plane");
154
+ }
155
+ if (manifestRead === null || manifestRead.kind !== "valid") {
156
+ return unverifiedSnapshot("the plane manifest could not be read");
157
+ }
158
+ const manifest = manifestRead.manifest;
159
+ if (manifest.repoRoot !== repoRoot) {
160
+ return unverifiedSnapshot("the plane manifest belongs to a different checkout");
161
+ }
162
+ if (options.expectedPlaneId !== undefined && manifest.planeId !== options.expectedPlaneId) {
163
+ return unverifiedSnapshot("the plane manifest is not the selected plane's");
164
+ }
165
+ const pinned = manifest.snapshotSha;
166
+ if (pinned === undefined || !HEX_OBJECT_ID.test(pinned)) {
167
+ return unverifiedSnapshot("the plane manifest records no pinned snapshot");
168
+ }
169
+ snapshotSha = pinned;
157
170
  }
158
171
  // Refresh the remote-tracking ref first. A failed fetch stops this check: a
159
172
  // stale cached `origin/main` would read as "fresh" and prove nothing.
@@ -162,7 +175,9 @@ async function checkSnapshot(repoRoot, deps, options, timeoutMs, manifestRead) {
162
175
  }
163
176
  const snapshotCommit = await resolveCommit(deps, repoRoot, snapshotSha, timeoutMs);
164
177
  if (snapshotCommit === null) {
165
- return unverifiedSnapshot("the snapshot commit is not present in this checkout");
178
+ return unverifiedSnapshot(fromCheckoutHead
179
+ ? "the checkout's HEAD could not be resolved"
180
+ : "the snapshot commit is not present in this checkout");
166
181
  }
167
182
  const originCommit = await resolveCommit(deps, repoRoot, "origin/main", timeoutMs);
168
183
  if (originCommit === null) {
@@ -192,17 +207,19 @@ async function checkSnapshot(repoRoot, deps, options, timeoutMs, manifestRead) {
192
207
  // Both sides moved. That is not proof of staleness, and not proof of freshness.
193
208
  return unverifiedSnapshot("the snapshot and origin/main have diverged");
194
209
  }
195
- /**
196
- * Collect the snapshot and database freshness reports, independently: an
197
- * unverified snapshot never suppresses a confirmed database refusal, or the
198
- * reverse.
199
- *
200
- * `checkout` is the code root whose `alembic.ini` the database check reads. When
201
- * the selected plane's manifest pins a snapshot, that snapshot is used instead —
202
- * the code the plane will actually RUN — exactly as plane preflight does.
203
- */
204
210
  export async function checkPlaneFreshness(repoRoot, deps, checkout, options) {
205
211
  const timeoutMs = options.timeoutMs ?? PLANE_FRESHNESS_TIMEOUT_MS;
212
+ if (options.snapshotFromCheckoutHead === true) {
213
+ const started = monotonicNow();
214
+ let report;
215
+ try {
216
+ report = await checkSnapshot(repoRoot, deps, options, timeoutMs, null);
217
+ }
218
+ catch {
219
+ report = unverifiedSnapshot("the check did not complete");
220
+ }
221
+ return { snapshot: { ...report, duration_ms: elapsedMs(started) } };
222
+ }
206
223
  let manifestRead = null;
207
224
  if (options.ownsManifest) {
208
225
  try {
@@ -31,6 +31,14 @@ export const CONSUMER_GUIDE_PATH = "docs/install/epic-implementer-install.md";
31
31
  * not enough, because an older install may not have the file yet.
32
32
  */
33
33
  export const CONSUMER_GUIDE_POINTER = `${CONSUMER_GUIDE_PATH} (write or refresh it with ${PRINTED_INSTALL_COMMAND})`;
34
+ /**
35
+ * Remediation printed when no supported host config carries a Bridge entry
36
+ * (moved here by BAPI-1719 so the pure setup projection can reuse it without
37
+ * importing the orchestration module). `install-bridge-conductor.ts` re-exports
38
+ * it under the same name.
39
+ */
40
+ export const CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION = `run \`${PRINTED_INSTALL_COMMAND}\` to create and register the host MCP entry, ` +
41
+ "then re-run `install epic-implementer`.";
34
42
  /**
35
43
  * Conductor setup. The plain command is the whole remedy (BAPI-1603): setup plans
36
44
  * the repository gate from what it finds, learns and proves the test command, and
@@ -111,6 +119,22 @@ export const READINESS_PREREQUISITE_FIXES = {
111
119
  * Client-only: it is never sent on the wire, so it stays out of the generated table above.
112
120
  */
113
121
  export const PRE_SETUP_READINESS_REMEDY = "Run setup; this item is checked again once this setup is saved.";
122
+ /**
123
+ * Reverse lookup over {@link READINESS_PREREQUISITE_FIXES}, built once. Only this
124
+ * table feeds it: the older-server literals are deliberately not classified here.
125
+ * The table values are pairwise distinct (a test asserts it), so the map is never
126
+ * ambiguous. The empty string is a valid value, so `""` classifies as `"none"`.
127
+ */
128
+ const READINESS_FIX_KEY_BY_VALUE = new Map(Object.entries(READINESS_PREREQUISITE_FIXES).map(([key, value]) => [value, key]));
129
+ /**
130
+ * Classify a remedy string by exact match against the values of
131
+ * {@link READINESS_PREREQUISITE_FIXES}. The match is byte for byte: no trimming, no
132
+ * case folding, no prefix handling, no substring matching. Any other string returns
133
+ * `undefined`.
134
+ */
135
+ export function classifyReadinessFix(fix) {
136
+ return READINESS_FIX_KEY_BY_VALUE.get(fix);
137
+ }
114
138
  const PUBLISHED_INSTALL_COMMAND = `${LAUNCHER} install epic-implementer --required-check "epic-implementer-ci / gate"`;
115
139
  /**
116
140
  * BAPI-1635 — the fix texts the PUBLISHED client (0.2.72) accepts from a server.
@@ -134,6 +158,44 @@ export const PUBLISHED_SERVER_COMPATIBLE_FIXES = [
134
158
  `Run ${LAUNCHER} connect-github, then retry readiness.`,
135
159
  "",
136
160
  ];
161
+ const INDEXED_WORKFLOWS_ROW_ID = "server.indexed-workflows";
162
+ /** The exact wire fix a missing managed workflow arrives with (published bytes). */
163
+ const MISSING_WORKFLOW_WIRE_FIX = `Run ${PUBLISHED_INSTALL_COMMAND}, merge the workflow changes, then re-index the repository.`;
164
+ // BAPI-1700 — shared sentence pieces for the two client-only no-gate remedies.
165
+ const STORE_GATE_OR_ATTENDED = "/install-epic-implementer to store a test gate, or start the run with --attended.";
166
+ const REVIEW_WORKFLOW_FILE = ".github/workflows/claude-review.yml";
167
+ const MANAGED_ONLY_DISPLAY_REMEDY = `Run ${STORE_GATE_OR_ATTENDED}`;
168
+ const REVIEW_INCLUSIVE_DISPLAY_REMEDY = `Add ${REVIEW_WORKFLOW_FILE}. Then run ${STORE_GATE_OR_ATTENDED} Then re-index the repository.`;
169
+ /**
170
+ * True only when the report's repository-scoped `review_workflow` section clearly
171
+ * shows the review file present: the probe succeeded AND the file is present. An
172
+ * absent or unreadable section, a failed probe, or a missing file is not clear.
173
+ */
174
+ function reviewWorkflowClearlySatisfied(report) {
175
+ const section = report?.review_workflow;
176
+ return section !== null && section !== undefined
177
+ && section.probe_succeeded === true && section.workflow_present === true;
178
+ }
179
+ /**
180
+ * BAPI-1700 — display text for the indexed-workflows row. Presentation only.
181
+ *
182
+ * The server sends the managed-workflow wire fix for a repository with no stored
183
+ * test gate. That fix is only half the story: such a repository can also store a
184
+ * gate with `/install-epic-implementer`, or start the run with `--attended`. This
185
+ * swaps in that wording for the EXACT row ID and EXACT published wire text, and
186
+ * returns `row.fix` unchanged for anything else (another ID, a near-miss, or a
187
+ * review-only remedy). It never mutates the row, and its output is never fed back
188
+ * through wire validation or added to any published-fix list.
189
+ *
190
+ * Managed-only wording is used only when the supplied report's `review_workflow`
191
+ * section clearly shows the review file present. With no report, or any unclear or
192
+ * conflicting evidence, the wording keeps the review-workflow step.
193
+ */
194
+ export function indexedWorkflowsDisplayRemedy(row, report) {
195
+ if (row.id !== INDEXED_WORKFLOWS_ROW_ID || row.fix !== MISSING_WORKFLOW_WIRE_FIX)
196
+ return row.fix;
197
+ return reviewWorkflowClearlySatisfied(report) ? MANAGED_ONLY_DISPLAY_REMEDY : REVIEW_INCLUSIVE_DISPLAY_REMEDY;
198
+ }
137
199
  /**
138
200
  * BAPI-1635 — the remedy a KNOWN unmet prerequisite resolves to, by catalog ID.
139
201
  * Each value is a key of the flat {@link READINESS_PREREQUISITE_FIXES}; the map is