@bridge_gpt/mcp-server 0.2.73 → 0.2.75

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 (123) hide show
  1. package/README.md +14 -7
  2. package/build/agent-launchers/claude-executor-adapter.js +12 -0
  3. package/build/agent-launchers/prompt.js +9 -21
  4. package/build/agents.generated.js +4 -4
  5. package/build/authored-plan.js +542 -0
  6. package/build/bridge-config.js +7 -1
  7. package/build/bridge-permissions.js +11 -0
  8. package/build/command-provisioning.js +4 -3
  9. package/build/commands.generated.js +6 -6
  10. package/build/conductor/bridge-api-client.js +692 -47
  11. package/build/conductor/command-drift.js +1 -1
  12. package/build/conductor/declared-extras.js +335 -0
  13. package/build/conductor/doctor.js +2 -0
  14. package/build/conductor/driver-pass-output.js +104 -0
  15. package/build/conductor/driver-pass.js +571 -0
  16. package/build/conductor/epic-branch-ci-inspection.js +61 -16
  17. package/build/conductor/epic-implementer-cli.js +370 -93
  18. package/build/conductor/epic-server-sfcc-upload.js +1567 -0
  19. package/build/conductor/epic-server-sfcc.js +58 -80
  20. package/build/conductor/epic-server.js +57 -4
  21. package/build/conductor/gate-discovery.js +253 -13
  22. package/build/conductor/gate-settings-review.js +58 -25
  23. package/build/conductor/launch-plan.js +58 -12
  24. package/build/conductor/open-decision-phrases.js +50 -0
  25. package/build/conductor/prerequisite-inputs.js +181 -14
  26. package/build/connect-github-api.js +18 -0
  27. package/build/connect-github.js +35 -18
  28. package/build/credential-delivery.js +280 -0
  29. package/build/credential-launch-safety.js +142 -0
  30. package/build/credential-materialization.js +91 -16
  31. package/build/credential-references-node-deps.js +29 -0
  32. package/build/credential-references.js +1394 -0
  33. package/build/credential-references.test-fixtures.js +211 -0
  34. package/build/credential-scan-conventions.js +145 -0
  35. package/build/credential-scan.js +517 -0
  36. package/build/credential-store.js +50 -0
  37. package/build/credentials-cli.js +252 -3
  38. package/build/dependency-install-declarations.js +47 -1
  39. package/build/docs.generated.js +8 -1
  40. package/build/doctor.js +41 -0
  41. package/build/drive-epic.js +684 -49
  42. package/build/epic-branch-ci-summary.js +18 -1
  43. package/build/epic-capability-statement.js +71 -3
  44. package/build/epic-ci-workflow-drift.js +52 -13
  45. package/build/epic-ci-workflow-install.js +31 -6
  46. package/build/epic-ci-workflow-v3.js +273 -0
  47. package/build/epic-ci-workflow.js +129 -7
  48. package/build/epic-implementer-bin.js +288 -83
  49. package/build/epic-implementer-bundle-cli.js +61 -0
  50. package/build/epic-implementer-claude-hook-bin.js +1 -1
  51. package/build/epic-implementer-env.js +3 -4
  52. package/build/epic-integration-pr.js +5 -2
  53. package/build/epic-launch-context.js +102 -7
  54. package/build/epic-server-record.js +30 -15
  55. package/build/executor/completion-contract.js +24 -1
  56. package/build/executor/credential-delivery-step.js +168 -0
  57. package/build/executor/deps.js +3 -1
  58. package/build/executor/env.js +39 -1
  59. package/build/executor/epic-server-context.js +23 -7
  60. package/build/executor/gate-qualification-job.js +193 -23
  61. package/build/executor/gate-qualification-tests-ran.js +232 -0
  62. package/build/executor/guarded-fast-forward-push.js +13 -8
  63. package/build/executor/job-runner.js +167 -738
  64. package/build/executor/job-type-wrappers.js +734 -0
  65. package/build/executor/permissions.js +85 -3
  66. package/build/executor/preflight.js +6 -2
  67. package/build/executor/process-containment.js +8 -1
  68. package/build/executor/prompt-spec.js +37 -3
  69. package/build/executor/required-verification.js +28 -2
  70. package/build/executor/runner.js +4 -1
  71. package/build/executor/types.js +9 -0
  72. package/build/executor/worker-database.js +6 -1
  73. package/build/executor/worker-guard-hook.js +24 -2
  74. package/build/executor-launch.js +4 -2
  75. package/build/generated/ticket-status.js +20 -0
  76. package/build/git-exclude-lock.js +187 -0
  77. package/build/index.js +589 -326
  78. package/build/install-bridge-conductor-answers.js +112 -22
  79. package/build/install-bridge-conductor-apply.js +38 -1
  80. package/build/install-bridge-conductor-assessment.js +482 -53
  81. package/build/install-bridge-conductor-compact.js +29 -2
  82. package/build/install-bridge-conductor-contracts.js +10 -1
  83. package/build/install-bridge-conductor-gate.js +379 -89
  84. package/build/install-bridge-conductor-setup.js +46 -8
  85. package/build/install-bridge-conductor-trial-report.js +170 -0
  86. package/build/install-bridge-conductor.js +925 -141
  87. package/build/install-bridge.js +88 -11
  88. package/build/install-doctor.js +38 -8
  89. package/build/install-sfcc-detection.js +120 -0
  90. package/build/install-sfcc-setup.js +185 -0
  91. package/build/mcp-grant-candidates.js +108 -96
  92. package/build/mcp-invoke.js +168 -4
  93. package/build/mcp-provisioning.js +21 -4
  94. package/build/mcp-server-invocation.js +13 -0
  95. package/build/merge-workflow-install.js +9 -1
  96. package/build/pipelines.generated.js +8 -7
  97. package/build/plan-generation.js +17 -0
  98. package/build/plane/status.js +8 -2
  99. package/build/printed-remedy-commands.js +59 -0
  100. package/build/project-root.js +40 -0
  101. package/build/readme.generated.js +1 -1
  102. package/build/repository-state-paths.js +5 -2
  103. package/build/repository-toolchains.js +16 -7
  104. package/build/scripts/saved-commands-config-field-driver.js +65 -0
  105. package/build/setup-epic.js +126 -16
  106. package/build/sfcc/credentials.js +3 -2
  107. package/build/sfcc/hostname.js +98 -2
  108. package/build/sfcc/tool-wrapper.js +6 -95
  109. package/build/start-tickets.js +193 -29
  110. package/build/test-support/executor-source-files.js +200 -0
  111. package/build/testing-config-client.js +25 -2
  112. package/build/third-party-mcp-targets.js +35 -4
  113. package/build/v2-readiness-requirements.js +5 -1
  114. package/build/version.generated.js +3 -3
  115. package/build/with-credentials.js +208 -0
  116. package/build/worker-guard-hook-bin.js +2 -2
  117. package/build/worktree-credential-delivery.js +340 -0
  118. package/docs/EPIC-IMPLEMENTER.md +4 -4
  119. package/docs/install/github-app.md +79 -92
  120. package/package.json +1 -1
  121. package/build/conductor/epic-reconcile.js +0 -603
  122. package/build/conductor/epic-runtime.js +0 -2020
  123. package/build/conductor/epic-state.js +0 -774
@@ -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
  },
@@ -9,6 +9,7 @@
9
9
  import { planeManifestLifecycle, planeManifestSnapshot, probeManifestMembers, readPlaneManifest, } from "./manifest.js";
10
10
  import { PLANE_RESTART_MIN_SCHEMA_VERSION, PLANE_RUNTIME_DIR, PLANE_RUNTIME_LOG_PATH, } from "./types.js";
11
11
  import { WORKER_STALE_EXIT_CODE } from "./worker-exit-code.js";
12
+ import { BRIDGE_RUN_STATE_DIR } from "../bridge-permissions.js";
12
13
  /** Read the manifest and probe every recorded pid. Strictly read-only. */
13
14
  export async function getPlaneStatus(repoRoot, deps) {
14
15
  const read = await readPlaneManifest(repoRoot, deps.fs);
@@ -80,8 +81,13 @@ function describeLifecycle(phase) {
80
81
  case "ready":
81
82
  return "plane ready (this reports PROCESSES, not whether the run is dispatchable)";
82
83
  case "lanes-failed":
83
- return ("executor lanes FAILED — the lane cohort was stopped and the control plane was " +
84
- "left running; nothing is claiming jobs. Wind it down with `plane down`.");
84
+ // This phase covers two cases the manifest cannot tell apart: lanes that were
85
+ // requested and failed to start, and a launch that ended before lanes were
86
+ // requested at all. The text names both and never blames the lanes alone.
87
+ return ("executor lanes did not start, or the launch ended before lanes were requested — " +
88
+ "the control plane was left running and nothing is claiming jobs. " +
89
+ `See launch-outcome.json in ${BRIDGE_RUN_STATE_DIR}/<EPIC>/ for how the launch ended, ` +
90
+ "then wind it down with `plane down`.");
85
91
  }
86
92
  }
87
93
  /**
@@ -106,6 +106,27 @@ export const READINESS_PREREQUISITE_FIXES = {
106
106
  reindex_manual: "Re-index the repository (/parse-repository).",
107
107
  none: "",
108
108
  };
109
+ /**
110
+ * BAPI-1678: the fix for a readiness item that only means setup has not been saved yet.
111
+ * Client-only: it is never sent on the wire, so it stays out of the generated table above.
112
+ */
113
+ export const PRE_SETUP_READINESS_REMEDY = "Run setup; this item is checked again once this setup is saved.";
114
+ /**
115
+ * Reverse lookup over {@link READINESS_PREREQUISITE_FIXES}, built once. Only this
116
+ * table feeds it: the older-server literals are deliberately not classified here.
117
+ * The table values are pairwise distinct (a test asserts it), so the map is never
118
+ * ambiguous. The empty string is a valid value, so `""` classifies as `"none"`.
119
+ */
120
+ const READINESS_FIX_KEY_BY_VALUE = new Map(Object.entries(READINESS_PREREQUISITE_FIXES).map(([key, value]) => [value, key]));
121
+ /**
122
+ * Classify a remedy string by exact match against the values of
123
+ * {@link READINESS_PREREQUISITE_FIXES}. The match is byte for byte: no trimming, no
124
+ * case folding, no prefix handling, no substring matching. Any other string returns
125
+ * `undefined`.
126
+ */
127
+ export function classifyReadinessFix(fix) {
128
+ return READINESS_FIX_KEY_BY_VALUE.get(fix);
129
+ }
109
130
  const PUBLISHED_INSTALL_COMMAND = `${LAUNCHER} install epic-implementer --required-check "epic-implementer-ci / gate"`;
110
131
  /**
111
132
  * BAPI-1635 — the fix texts the PUBLISHED client (0.2.72) accepts from a server.
@@ -129,6 +150,44 @@ export const PUBLISHED_SERVER_COMPATIBLE_FIXES = [
129
150
  `Run ${LAUNCHER} connect-github, then retry readiness.`,
130
151
  "",
131
152
  ];
153
+ const INDEXED_WORKFLOWS_ROW_ID = "server.indexed-workflows";
154
+ /** The exact wire fix a missing managed workflow arrives with (published bytes). */
155
+ const MISSING_WORKFLOW_WIRE_FIX = `Run ${PUBLISHED_INSTALL_COMMAND}, merge the workflow changes, then re-index the repository.`;
156
+ // BAPI-1700 — shared sentence pieces for the two client-only no-gate remedies.
157
+ const STORE_GATE_OR_ATTENDED = "/install-epic-implementer to store a test gate, or start the run with --attended.";
158
+ const REVIEW_WORKFLOW_FILE = ".github/workflows/claude-review.yml";
159
+ const MANAGED_ONLY_DISPLAY_REMEDY = `Run ${STORE_GATE_OR_ATTENDED}`;
160
+ const REVIEW_INCLUSIVE_DISPLAY_REMEDY = `Add ${REVIEW_WORKFLOW_FILE}. Then run ${STORE_GATE_OR_ATTENDED} Then re-index the repository.`;
161
+ /**
162
+ * True only when the report's repository-scoped `review_workflow` section clearly
163
+ * shows the review file present: the probe succeeded AND the file is present. An
164
+ * absent or unreadable section, a failed probe, or a missing file is not clear.
165
+ */
166
+ function reviewWorkflowClearlySatisfied(report) {
167
+ const section = report?.review_workflow;
168
+ return section !== null && section !== undefined
169
+ && section.probe_succeeded === true && section.workflow_present === true;
170
+ }
171
+ /**
172
+ * BAPI-1700 — display text for the indexed-workflows row. Presentation only.
173
+ *
174
+ * The server sends the managed-workflow wire fix for a repository with no stored
175
+ * test gate. That fix is only half the story: such a repository can also store a
176
+ * gate with `/install-epic-implementer`, or start the run with `--attended`. This
177
+ * swaps in that wording for the EXACT row ID and EXACT published wire text, and
178
+ * returns `row.fix` unchanged for anything else (another ID, a near-miss, or a
179
+ * review-only remedy). It never mutates the row, and its output is never fed back
180
+ * through wire validation or added to any published-fix list.
181
+ *
182
+ * Managed-only wording is used only when the supplied report's `review_workflow`
183
+ * section clearly shows the review file present. With no report, or any unclear or
184
+ * conflicting evidence, the wording keeps the review-workflow step.
185
+ */
186
+ export function indexedWorkflowsDisplayRemedy(row, report) {
187
+ if (row.id !== INDEXED_WORKFLOWS_ROW_ID || row.fix !== MISSING_WORKFLOW_WIRE_FIX)
188
+ return row.fix;
189
+ return reviewWorkflowClearlySatisfied(report) ? MANAGED_ONLY_DISPLAY_REMEDY : REVIEW_INCLUSIVE_DISPLAY_REMEDY;
190
+ }
132
191
  /**
133
192
  * BAPI-1635 — the remedy a KNOWN unmet prerequisite resolves to, by catalog ID.
134
193
  * Each value is a key of the flat {@link READINESS_PREREQUISITE_FIXES}; the map is
@@ -33,6 +33,46 @@ export async function hasProjectRootMarker(cwd, stat) {
33
33
  return false;
34
34
  }
35
35
  }
36
+ /**
37
+ * BAPI-1664: the closed, extensible list of markers that prove a folder is a
38
+ * repository root for `install epic-implementer`. A worktree's `.git` is a FILE,
39
+ * so only existence is checked. Add a marker here to widen the guard.
40
+ */
41
+ export const VCS_WORK_TREE_MARKERS = [".git"];
42
+ /**
43
+ * Whether `cwd` is the user's home directory. Compares RESOLVED LEXICAL paths
44
+ * only and performs no filesystem I/O; it intentionally does not resolve
45
+ * symlinks, so a symlinked home directory is not detected. Returns `false` when
46
+ * `homeDir` is absent or empty, and never throws.
47
+ */
48
+ export function isHomeDirectory(cwd, homeDir) {
49
+ if (!homeDir)
50
+ return false;
51
+ try {
52
+ return path.resolve(cwd) === path.resolve(homeDir);
53
+ }
54
+ catch {
55
+ return false;
56
+ }
57
+ }
58
+ /**
59
+ * Whether `cwd` holds a repository marker from {@link VCS_WORK_TREE_MARKERS},
60
+ * checked through the injected `stat` probe. Any probe failure counts as that
61
+ * marker being absent; this never throws. Sibling of {@link hasProjectRootMarker},
62
+ * which stays the `.git`-only prompt hint for ordinary `install` and `--init`.
63
+ */
64
+ export async function hasVcsWorkTreeMarker(cwd, stat) {
65
+ for (const marker of VCS_WORK_TREE_MARKERS) {
66
+ try {
67
+ await stat(path.join(cwd, marker));
68
+ return true;
69
+ }
70
+ catch {
71
+ /* try the next marker */
72
+ }
73
+ }
74
+ return false;
75
+ }
36
76
  /**
37
77
  * Validate an explicit project root: it must exist, be a directory, and contain
38
78
  * `.git` (a directory, or the `.git` FILE a worktree has) or `.bridge/config`.