@bridge_gpt/mcp-server 0.2.69 → 0.2.71

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 (164) hide show
  1. package/README.md +140 -292
  2. package/build/agent-launchers/claude-executor-adapter.js +27 -5
  3. package/build/agent-registry.js +5 -5
  4. package/build/agents.generated.js +15 -5
  5. package/build/artifact-diff.js +110 -0
  6. package/build/bin-entrypoint.js +36 -0
  7. package/build/bounded-wait.js +9 -1
  8. package/build/bridge-permissions.js +36 -9
  9. package/build/claude-review-workflow-drift.js +3 -3
  10. package/build/codex-bridge-profile.js +1 -1
  11. package/build/commands.generated.js +6 -6
  12. package/build/conductor/bridge-api-client.js +858 -21
  13. package/build/conductor/bring-up-facts.js +9 -9
  14. package/build/conductor/command-drift-production.js +7 -2
  15. package/build/conductor/doctor.js +472 -18
  16. package/build/conductor/epic-child-continuation.js +54 -3
  17. package/build/conductor/epic-implementer-cli.js +136 -34
  18. package/build/conductor/epic-runtime.js +2 -2
  19. package/build/conductor/epic-state.js +1 -1
  20. package/build/conductor/gate-discovery.js +524 -10
  21. package/build/conductor/gate-settings-review.js +451 -0
  22. package/build/conductor/hook-runtime-qualification.js +1 -1
  23. package/build/conductor/install-doctor.js +4 -2
  24. package/build/conductor/launch-need-probes.js +342 -0
  25. package/build/conductor/launch-plan.js +145 -0
  26. package/build/conductor/local-merge.js +241 -56
  27. package/build/conductor/merge-credential.js +172 -0
  28. package/build/conductor/merge-execution-eligibility.js +1 -1
  29. package/build/conductor/merged-child-check.js +95 -0
  30. package/build/conductor/plan-trim.js +30 -0
  31. package/build/conductor/pr-ci-producer.js +1 -1
  32. package/build/conductor/precheck-timings.js +14 -0
  33. package/build/conductor/preview-observations.js +10 -0
  34. package/build/conductor/readiness-cli.js +11 -6
  35. package/build/conductor/readiness-prerequisites.js +41 -0
  36. package/build/conductor/readiness-sections.js +348 -55
  37. package/build/conductor/readiness.js +99 -87
  38. package/build/conductor/recovery-cli.js +665 -23
  39. package/build/conductor/recovery-operations.js +350 -8
  40. package/build/conductor/repair-contract.js +47 -2
  41. package/build/conductor/repository-workflow-remedy.js +8 -6
  42. package/build/conductor/stored-merge-credential.js +76 -0
  43. package/build/conductor/stored-merge-token-probe.js +28 -0
  44. package/build/conductor/temporary-plan.js +50 -0
  45. package/build/conductor/wait-run-cli.js +759 -0
  46. package/build/conductor/worker-database-doctor-inspector.js +49 -0
  47. package/build/conductor-bin.js +2 -2
  48. package/build/conductor-claude-hook-bin.js +2 -2
  49. package/build/conductor-claude-hook-removed-stub-bin.js +2 -5
  50. package/build/conductor-removed-stub-bin.js +2 -5
  51. package/build/credential-store.js +356 -13
  52. package/build/docs.generated.js +26 -13
  53. package/build/doctor.js +94 -32
  54. package/build/drive-epic-help.js +212 -0
  55. package/build/drive-epic.js +1989 -379
  56. package/build/epic-ci-workflow-drift.js +125 -0
  57. package/build/epic-ci-workflow-install.js +240 -0
  58. package/build/epic-ci-workflow-v1.js +132 -0
  59. package/build/epic-ci-workflow.js +318 -0
  60. package/build/epic-contract-context.js +326 -0
  61. package/build/epic-implementer-bin.js +58 -42
  62. package/build/epic-implementer-claude-hook-bin.js +2 -2
  63. package/build/escalation-reachability.js +134 -0
  64. package/build/executor/ci-rerun-job.js +220 -14
  65. package/build/executor/cleanup-report.js +99 -0
  66. package/build/executor/cli.js +12 -1
  67. package/build/executor/completion-contract.js +66 -11
  68. package/build/executor/completion-supervision.js +99 -0
  69. package/build/executor/delivery-outcome.js +179 -0
  70. package/build/executor/deps.js +3 -0
  71. package/build/executor/env.js +276 -1
  72. package/build/executor/failure-reason-codes.js +126 -0
  73. package/build/executor/gate-qualification-job.js +20 -5
  74. package/build/executor/heartbeat.js +38 -0
  75. package/build/executor/http-client.js +72 -0
  76. package/build/executor/integration-job.js +298 -5
  77. package/build/executor/job-errors.js +36 -6
  78. package/build/executor/job-runner.js +830 -45
  79. package/build/executor/likely-tests.js +42 -3
  80. package/build/executor/merge-job.js +145 -2
  81. package/build/executor/observation.js +73 -4
  82. package/build/executor/permissions.js +193 -97
  83. package/build/executor/preflight.js +19 -3
  84. package/build/executor/process-containment.js +46 -2
  85. package/build/executor/prompt-spec.js +113 -9
  86. package/build/executor/rebase-finalization.js +38 -3
  87. package/build/executor/reconcile-overlap-job.js +41 -8
  88. package/build/executor/required-work-ledger.js +236 -81
  89. package/build/executor/resume-pre-spawn.js +38 -1
  90. package/build/executor/runner.js +91 -3
  91. package/build/executor/test-clock.js +8 -0
  92. package/build/executor/types.js +37 -2
  93. package/build/executor/worker-cli-launcher.js +259 -0
  94. package/build/executor/worker-command.js +177 -5
  95. package/build/executor/worker-database-target.js +91 -0
  96. package/build/executor/worker-database.js +927 -0
  97. package/build/executor/worker-finalization.js +106 -0
  98. package/build/executor/worker-guard-hook.js +203 -0
  99. package/build/executor/worker-resources.js +58 -0
  100. package/build/executor/worker-verification-guidance.js +44 -2
  101. package/build/executor/worktree.js +303 -15
  102. package/build/executor-launch.js +11 -1
  103. package/build/generated-assets-doctor.js +9 -1
  104. package/build/generated-assets-health.js +13 -4
  105. package/build/generated-assets-legacy.js +39 -0
  106. package/build/generated-assets-paths.js +12 -1
  107. package/build/generated-assets-repair.js +4 -1
  108. package/build/generated-assets-test-support.js +12 -0
  109. package/build/github-remote.js +33 -0
  110. package/build/github-sign-in.js +62 -0
  111. package/build/index.js +1133 -546
  112. package/build/init.js +39 -1
  113. package/build/install-bridge-conductor-gate.js +270 -11
  114. package/build/install-bridge-conductor-setup.js +427 -0
  115. package/build/install-bridge-conductor.js +1545 -268
  116. package/build/install-bridge.js +376 -60
  117. package/build/mcp-install-state.js +8 -2
  118. package/build/merge-pull-request.js +6 -0
  119. package/build/merge-workflow-install.js +782 -344
  120. package/build/phase-result-artifacts.js +75 -20
  121. package/build/pipeline-orchestrator.js +247 -4
  122. package/build/pipelines.generated.js +35 -35
  123. package/build/plan-discovery.js +15 -2
  124. package/build/plan-execution-ledger.js +321 -17
  125. package/build/plan-phase-routing.js +48 -13
  126. package/build/plane/cli.js +105 -51
  127. package/build/plane/defaults.js +3 -0
  128. package/build/plane/plane-freshness.js +298 -0
  129. package/build/plane/preflight.js +19 -0
  130. package/build/plane/schema-compatibility.js +137 -0
  131. package/build/plane/shutdown-deps.js +38 -0
  132. package/build/plane/shutdown.js +83 -8
  133. package/build/plane/terminal-run-cleanup.js +303 -0
  134. package/build/printed-remedy-commands.js +33 -4
  135. package/build/readiness-check.js +6 -2
  136. package/build/readiness-prerequisites.generated.js +532 -0
  137. package/build/readme.generated.js +1 -1
  138. package/build/repository-toolchains.js +581 -0
  139. package/build/setup-epic.js +421 -34
  140. package/build/shared-resources.generated.js +5 -0
  141. package/build/start-tickets.js +28 -15
  142. package/build/test-command-detection.js +284 -0
  143. package/build/test-command-validation.js +73 -0
  144. package/build/testing-config-client.js +150 -0
  145. package/build/ticket-delivery-artifacts.js +265 -0
  146. package/build/ticket-delivery-enrollment.js +369 -0
  147. package/build/ticket-delivery.js +205 -0
  148. package/build/ticket-review-summary.js +14 -0
  149. package/build/upgrade-cli.js +13 -0
  150. package/build/v2-readiness-requirements.js +552 -0
  151. package/build/version.generated.js +3 -3
  152. package/build/worker-guard-hook-bin.js +2 -2
  153. package/build/worktree-core.js +22 -7
  154. package/docs/BRIDGE-DIRECTORY-README.md +48 -0
  155. package/docs/EPIC-IMPLEMENTER-INSTALL.md +12 -867
  156. package/docs/EPIC-IMPLEMENTER.md +142 -63
  157. package/docs/epic-implementer/getting-started.md +187 -0
  158. package/docs/epic-implementer/self-hosting.md +133 -0
  159. package/package.json +4 -4
  160. package/pipelines/idea-to-ticket.json +1 -1
  161. package/pipelines/implement-ticket.json +8 -8
  162. package/pipelines/review-ticket.json +2 -2
  163. package/design-assets/favicon/favicon-32x32.png +0 -0
  164. package/design-assets/just-logo-rough-draft.png +0 -0
@@ -0,0 +1,451 @@
1
+ /**
2
+ * The interactive review of discovered CI settings (BAPI-1520).
3
+ *
4
+ * `install-bridge conductor` can propose two optional settings beside the gate:
5
+ *
6
+ * - **worker variables** — literal environment values found in CI config; and
7
+ * - **local reproduction hints** — a structured command for a reported provider
8
+ * check, so a worker can reproduce a failing check locally.
9
+ *
10
+ * Both are stored now and delivered to workers later (a follow-up ticket). Both
11
+ * are high-trust: a value is confirmed by the repository owner, one decision at
12
+ * a time, and only in an interactive terminal.
13
+ *
14
+ * ## Why values stay in this module
15
+ *
16
+ * A worker variable's VALUE is rendered here, through {@link terminalSafe}, to
17
+ * the interactive prompt channel and nowhere else. Everything this module
18
+ * returns for logs, reports, or MCP output is names and counts. A run with no
19
+ * terminal never reaches {@link reviewDiscoveredSettings}, so it neither shows
20
+ * nor sends either setting.
21
+ *
22
+ * ## Presence-aware results
23
+ *
24
+ * {@link SettingsEdit} separates "untouched" (`undefined`) from "changed". An
25
+ * untouched setting is omitted from the write, so the server keeps what it has;
26
+ * an empty `workerEnv` list is a deliberate removal of every stored variable.
27
+ */
28
+ import { LOCAL_COMMAND_TIMEOUT_SECONDS, } from "./gate-discovery.js";
29
+ /** Limits that mirror `gate_profile.py` for hand-typed hints. */
30
+ const MAX_HINT_WORDS = 32;
31
+ const MAX_HINT_WORD_CHARS = 1024;
32
+ const MAX_REVIEW_ATTEMPTS = 3;
33
+ // ---------------------------------------------------------------------------
34
+ // Terminal-safe rendering
35
+ // ---------------------------------------------------------------------------
36
+ /**
37
+ * Quote `text` for a terminal so it cannot act on the terminal: quotes and
38
+ * backslashes are escaped, and control characters (including ESC and the C1
39
+ * range), line and paragraph separators, zero-width and bidirectional
40
+ * formatting characters are written as `\u{hex}`. Nothing is truncated; callers
41
+ * pass values already bounded by the validated input limits.
42
+ */
43
+ export function terminalSafe(text) {
44
+ let out = "";
45
+ for (const ch of text) {
46
+ const cp = ch.codePointAt(0) ?? 0;
47
+ if (ch === '"')
48
+ out += '\\"';
49
+ else if (ch === "\\")
50
+ out += "\\\\";
51
+ else if (cp < 0x20 ||
52
+ cp === 0x7f ||
53
+ (cp >= 0x80 && cp <= 0x9f) ||
54
+ cp === 0x2028 ||
55
+ cp === 0x2029 ||
56
+ (cp >= 0x200b && cp <= 0x200f) ||
57
+ (cp >= 0x202a && cp <= 0x202e) ||
58
+ (cp >= 0x2066 && cp <= 0x2069) ||
59
+ cp === 0xfeff) {
60
+ out += `\\u{${cp.toString(16)}}`;
61
+ }
62
+ else
63
+ out += ch;
64
+ }
65
+ return `"${out}"`;
66
+ }
67
+ function safeList(names) {
68
+ return names.map(terminalSafe).join(", ");
69
+ }
70
+ // ---------------------------------------------------------------------------
71
+ // Equality (flag-normalized, order-insensitive for variables)
72
+ // ---------------------------------------------------------------------------
73
+ function sameEntry(a, b) {
74
+ return a.name === b.name && a.value === b.value && (a.committed_literal === true) === (b.committed_literal === true);
75
+ }
76
+ /** Whether two variable lists are the same set (ordering never matters; `false` and omitted flags are equal). */
77
+ export function workerEnvEqual(a, b) {
78
+ const left = a ?? [];
79
+ const right = b ?? [];
80
+ if (left.length !== right.length)
81
+ return false;
82
+ return left.every((entry) => {
83
+ const other = right.find((e) => e.name === entry.name);
84
+ return other !== undefined && sameEntry(entry, other);
85
+ });
86
+ }
87
+ /** Whether two reproduction hints are identical. */
88
+ export function hintEqual(a, b) {
89
+ return (a.timeout_seconds === b.timeout_seconds && a.argv.length === b.argv.length && a.argv.every((w, i) => w === b.argv[i]));
90
+ }
91
+ /**
92
+ * Whether `edit` leaves the stored settings exactly as they are. Omitted
93
+ * settings and per-check hints resolve against `stored` first, so a request
94
+ * that restates what is stored is a no-op rather than a write.
95
+ */
96
+ export function settingsMatchStored(edit, stored) {
97
+ if (edit.workerEnv !== undefined && !workerEnvEqual(edit.workerEnv, stored?.worker_env))
98
+ return false;
99
+ for (const [check, hint] of edit.reproduce ?? []) {
100
+ const current = stored?.reproduction_hints?.get(check) ?? null;
101
+ if (hint === null) {
102
+ if (current !== null)
103
+ return false;
104
+ }
105
+ else if (current === null || !hintEqual(hint, current)) {
106
+ return false;
107
+ }
108
+ }
109
+ return true;
110
+ }
111
+ // ---------------------------------------------------------------------------
112
+ // Rows
113
+ // ---------------------------------------------------------------------------
114
+ function candidateEntry(candidate) {
115
+ return {
116
+ name: candidate.name,
117
+ value: candidate.value,
118
+ ...(candidate.committedLiteral ? { committed_literal: true } : {}),
119
+ };
120
+ }
121
+ function envRows(proposal, stored) {
122
+ const storedList = stored?.worker_env ?? [];
123
+ const rows = [];
124
+ for (const entry of storedList) {
125
+ const candidate = proposal.workerEnvCandidates.find((c) => c.name === entry.name);
126
+ if (candidate !== undefined && candidate.value !== entry.value) {
127
+ rows.push({
128
+ name: entry.name,
129
+ status: "Changed",
130
+ stored: entry,
131
+ proposed: candidateEntry(candidate),
132
+ sources: candidate.sources,
133
+ });
134
+ }
135
+ else {
136
+ rows.push({ name: entry.name, status: "Stored", stored: entry, sources: candidate?.sources ?? [] });
137
+ }
138
+ }
139
+ for (const candidate of proposal.workerEnvCandidates) {
140
+ if (storedList.some((e) => e.name === candidate.name))
141
+ continue;
142
+ rows.push({ name: candidate.name, status: "Proposed", proposed: candidateEntry(candidate), sources: candidate.sources });
143
+ }
144
+ return rows;
145
+ }
146
+ function describeEnvRow(row, index) {
147
+ const label = index === null ? " " : ` [${index}] `;
148
+ const lines = [];
149
+ if (row.status === "Stored" && row.stored) {
150
+ lines.push(`${label}${row.name} = ${terminalSafe(row.stored.value)} — Stored`);
151
+ }
152
+ else if (row.status === "Changed" && row.stored && row.proposed) {
153
+ lines.push(`${label}${row.name} = ${terminalSafe(row.proposed.value)} — Changed (stored: ${terminalSafe(row.stored.value)})`);
154
+ }
155
+ else if (row.proposed) {
156
+ lines.push(`${label}${row.name} = ${terminalSafe(row.proposed.value)} — Proposed`);
157
+ }
158
+ if (row.proposed?.committed_literal === true) {
159
+ lines.push(" Requires confirmation: the name looks secret, so this is a plain-text value committed to CI. " +
160
+ "Storing it makes it readable to anyone who can read this repository's gate profile.");
161
+ }
162
+ if (row.sources.length > 0)
163
+ lines.push(` from ${safeList(row.sources)}`);
164
+ return lines;
165
+ }
166
+ const NO_HINT_TEXT = "No local command declared; the stored test command remains the fallback.";
167
+ function hintRows(proposal, stored, providerChecks) {
168
+ return providerChecks.map((check) => ({
169
+ check,
170
+ stored: stored?.reproduction_hints?.get(check) ?? null,
171
+ proposed: proposal.reproductionHints.find((h) => h.check === check) ?? null,
172
+ }));
173
+ }
174
+ function describeHint(hint) {
175
+ return `${hint.argv.map(terminalSafe).join(" ")} (timeout ${hint.timeout_seconds}s)`;
176
+ }
177
+ // ---------------------------------------------------------------------------
178
+ // Rendering
179
+ // ---------------------------------------------------------------------------
180
+ /** Whether there is anything to show or decide. */
181
+ export function hasSettingsToReview(proposal, stored, providerChecks) {
182
+ return (proposal.workerEnvCandidates.length > 0 ||
183
+ (stored?.worker_env?.length ?? 0) > 0 ||
184
+ proposal.workerEnvConflicts.length > 0 ||
185
+ hintRows(proposal, stored, providerChecks).some((r) => r.stored !== null || r.proposed !== null));
186
+ }
187
+ /**
188
+ * Print the review surface. Values appear only when `showValues` is true (an
189
+ * interactive terminal); otherwise only names and counts are printed.
190
+ */
191
+ export function renderSettingsReview(io, proposal, stored, providerChecks, showValues) {
192
+ io.log("");
193
+ io.log("Review discovered CI settings");
194
+ io.log("─────────────────────────────");
195
+ io.log(" These are repository-specific, non-secret execution facts. Worker variables reach workers and");
196
+ io.log(" qualification jobs; reproduction commands appear in repair prompts as hints only, and never");
197
+ io.log(" change which checks gate a merge. A secret-looking name is refused unless you individually");
198
+ io.log(" confirm that it holds a plain-text value already committed to CI. Removing every variable means");
199
+ io.log(" workers receive none, not the old built-in defaults. Nothing is stored until you confirm it below.");
200
+ io.log("");
201
+ io.log(" Worker variables");
202
+ const rows = envRows(proposal, stored);
203
+ if (rows.length === 0) {
204
+ io.log(" None stored and none proposed.");
205
+ }
206
+ else if (showValues) {
207
+ let number = 0;
208
+ for (const row of rows) {
209
+ const selectable = row.status !== "Stored";
210
+ if (selectable)
211
+ number += 1;
212
+ for (const line of describeEnvRow(row, selectable ? number : null))
213
+ io.log(line);
214
+ }
215
+ }
216
+ else {
217
+ io.log(` ${rows.length} variable(s): ${safeList(rows.map((r) => r.name))} (values are shown only in a terminal)`);
218
+ }
219
+ if (proposal.workerEnvConflicts.length > 0) {
220
+ io.log(` Conflict (declared with different values; not proposed): ${safeList(proposal.workerEnvConflicts)}`);
221
+ }
222
+ if (proposal.workerEnvSkipped.length > 0) {
223
+ io.log(` Not proposed (unsupported, reserved, or out of bounds): ${safeList(proposal.workerEnvSkipped)}`);
224
+ }
225
+ if (proposal.workerEnvOverflow > 0) {
226
+ io.log(` ${proposal.workerEnvOverflow} more eligible variable(s) were left out by the 32-variable limit.`);
227
+ }
228
+ if (rows.length === 0 && proposal.noCandidates) {
229
+ io.log(" Discovery found nothing to propose. Cargo, Go, and Gradle command candidates must be entered by hand.");
230
+ }
231
+ io.log("");
232
+ io.log(" Local reproduction hints — Hint only — never changes gating or completion.");
233
+ const hints = hintRows(proposal, stored, providerChecks);
234
+ if (hints.length === 0)
235
+ io.log(` ${NO_HINT_TEXT}`);
236
+ for (const row of hints) {
237
+ io.log(` ${terminalSafe(row.check)}`);
238
+ if (!showValues) {
239
+ io.log(row.stored || row.proposed
240
+ ? ` ${row.stored ? "a hint is stored" : "a hint is proposed"} (commands are shown only in a terminal)`
241
+ : ` ${NO_HINT_TEXT}`);
242
+ continue;
243
+ }
244
+ if (row.stored)
245
+ io.log(` Stored: ${describeHint(row.stored)}`);
246
+ if (row.proposed && (row.stored === null || !hintEqual(row.stored, hintFrom(row.proposed)))) {
247
+ io.log(` ${row.stored ? "Changed" : "Proposed"}: ${describeHint({ argv: row.proposed.argv, timeout_seconds: row.proposed.timeoutSeconds })}`);
248
+ }
249
+ if (!row.stored && !row.proposed)
250
+ io.log(` ${NO_HINT_TEXT}`);
251
+ }
252
+ if (proposal.reproductionHintsSkipped.length > 0) {
253
+ io.log(` Not proposed (no single plain command could be read for): ${safeList(proposal.reproductionHintsSkipped)}`);
254
+ }
255
+ io.log("");
256
+ }
257
+ function hintFrom(candidate) {
258
+ return { argv: [...candidate.argv], timeout_seconds: candidate.timeoutSeconds };
259
+ }
260
+ function parseEnvChoice(answer, hasStored, hasProposals) {
261
+ const a = answer.trim().toLowerCase();
262
+ if (a === "")
263
+ return hasStored || !hasProposals ? "keep" : "ignore";
264
+ if (a === "k" || a === "keep")
265
+ return hasStored ? "keep" : null;
266
+ if (a === "e" || a === "edit")
267
+ return "edit";
268
+ if (a === "i" || a === "ignore")
269
+ return hasProposals ? "ignore" : null;
270
+ if (a === "r" || a === "remove")
271
+ return hasStored ? "remove" : null;
272
+ return null;
273
+ }
274
+ async function yes(prompt, text) {
275
+ const answer = (await prompt(text)).trim().toLowerCase();
276
+ return answer === "y" || answer === "yes";
277
+ }
278
+ /**
279
+ * Ask about worker variables. Returns the complete new list, or `undefined`
280
+ * when the owner leaves the stored settings untouched.
281
+ */
282
+ async function reviewWorkerEnv(io, proposal, stored) {
283
+ const prompt = io.promptLine;
284
+ const storedList = stored?.worker_env ?? [];
285
+ const rows = envRows(proposal, stored);
286
+ const proposals = rows.filter((r) => r.status !== "Stored");
287
+ if (storedList.length === 0 && proposals.length === 0)
288
+ return undefined;
289
+ const options = [
290
+ ...(storedList.length > 0 ? ["[k]eep stored variables as they are"] : []),
291
+ "[e]dit — decide each variable one at a time",
292
+ ...(proposals.length > 0 ? ["[i]gnore the proposals (stored settings stay untouched)"] : []),
293
+ ...(storedList.length > 0 ? ["[r]emove every stored variable"] : []),
294
+ ];
295
+ let choice = null;
296
+ for (let attempt = 0; attempt < MAX_REVIEW_ATTEMPTS && choice === null; attempt++) {
297
+ choice = parseEnvChoice(await prompt(`Worker variables — ${options.join(", ")} (Enter leaves them untouched): `), storedList.length > 0, proposals.length > 0);
298
+ if (choice === null)
299
+ io.log(" Choose one of the listed letters, or press Enter.");
300
+ }
301
+ if (choice === "ignore" && proposals.length > 0) {
302
+ io.log(` Ignored ${proposals.length} proposal(s): ${safeList(proposals.map((r) => r.name))}. ` +
303
+ "Stored settings are untouched; nothing was removed.");
304
+ }
305
+ if (choice === null || choice === "keep" || choice === "ignore")
306
+ return undefined;
307
+ if (choice === "remove") {
308
+ io.log(` Removal requested for ${storedList.length} stored variable(s): ${safeList(storedList.map((e) => e.name))}.`);
309
+ const confirmed = await yes(prompt, "Remove every stored worker variable? [y/N]: ");
310
+ return confirmed ? [] : undefined;
311
+ }
312
+ // edit: one decision per proposal, then one per stored variable.
313
+ let result = storedList.map((e) => ({ ...e }));
314
+ for (const row of proposals) {
315
+ const entry = row.proposed;
316
+ if (entry === undefined)
317
+ continue;
318
+ if (entry.committed_literal === true) {
319
+ io.log(` ${row.name} looks secret. Its value is a plain-text literal committed to CI; storing it makes it ` +
320
+ "readable to anyone who can read this repository's gate profile.");
321
+ const answer = (await prompt(`Type "yes" to confirm ${row.name} = ${terminalSafe(entry.value)} is a committed literal (anything else skips it): `)).trim();
322
+ if (answer !== "yes") {
323
+ io.log(` Ignored the proposal for ${row.name}: not stored. Stored settings are untouched; nothing was removed.`);
324
+ continue;
325
+ }
326
+ }
327
+ else if (!(await yes(prompt, `Apply ${row.name} = ${terminalSafe(entry.value)}? [y/N]: `))) {
328
+ io.log(` Ignored the proposal for ${row.name}: not stored. Stored settings are untouched; nothing was removed.`);
329
+ continue;
330
+ }
331
+ result = [...result.filter((e) => e.name !== row.name), { ...entry }];
332
+ }
333
+ for (const entry of storedList) {
334
+ if (!result.some((e) => e.name === entry.name))
335
+ continue;
336
+ if (await yes(prompt, `Remove stored ${entry.name}? [y/N]: `)) {
337
+ io.log(` Removal requested: ${entry.name}.`);
338
+ result = result.filter((e) => e.name !== entry.name);
339
+ }
340
+ }
341
+ result.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
342
+ return workerEnvEqual(result, storedList) ? undefined : result;
343
+ }
344
+ /** Parse hand-typed command words; `null` when they cannot be a reproduction command. */
345
+ export function parseHintWords(line) {
346
+ const words = line.trim().split(/\s+/).filter((w) => w !== "");
347
+ if (words.length === 0 || words.length > MAX_HINT_WORDS)
348
+ return null;
349
+ if (words.some((w) => w.length > MAX_HINT_WORD_CHARS || w.includes("\0")))
350
+ return null;
351
+ return words;
352
+ }
353
+ async function typedHint(prompt, io) {
354
+ const line = await prompt("Command words, space separated, no shell syntax (Enter cancels): ");
355
+ if (line.trim() === "")
356
+ return null;
357
+ const argv = parseHintWords(line);
358
+ if (argv === null) {
359
+ io.log(` A hint needs 1 to ${MAX_HINT_WORDS} words of at most ${MAX_HINT_WORD_CHARS} characters.`);
360
+ return null;
361
+ }
362
+ const rawTimeout = (await prompt(`Timeout seconds, 1-1800 (Enter = ${LOCAL_COMMAND_TIMEOUT_SECONDS}): `)).trim();
363
+ const timeout = rawTimeout === "" ? LOCAL_COMMAND_TIMEOUT_SECONDS : Number(rawTimeout);
364
+ if (!Number.isInteger(timeout) || timeout < 1 || timeout > 1800) {
365
+ io.log(" The timeout must be a whole number from 1 to 1800.");
366
+ return null;
367
+ }
368
+ return { argv, timeout_seconds: timeout };
369
+ }
370
+ async function reviewHints(io, proposal, stored, providerChecks) {
371
+ const prompt = io.promptLine;
372
+ const edits = new Map();
373
+ for (const row of hintRows(proposal, stored, providerChecks)) {
374
+ const proposed = row.proposed === null ? null : hintFrom(row.proposed);
375
+ const newProposal = proposed !== null && (row.stored === null || !hintEqual(row.stored, proposed));
376
+ if (row.stored === null && !newProposal)
377
+ continue;
378
+ const letters = [
379
+ ...(row.stored ? ["[k]eep stored"] : []),
380
+ ...(newProposal ? ["[a]pply proposed"] : []),
381
+ "[e]dit",
382
+ ...(row.stored ? ["[d]rop stored"] : ["[i]gnore"]),
383
+ ];
384
+ const answer = (await prompt(`Hint for ${terminalSafe(row.check)} — ${letters.join(", ")} (Enter leaves it untouched): `))
385
+ .trim()
386
+ .toLowerCase();
387
+ if (answer === "" || answer === "k" || answer === "keep" || answer === "i" || answer === "ignore")
388
+ continue;
389
+ if ((answer === "a" || answer === "apply") && newProposal && proposed !== null) {
390
+ edits.set(row.check, proposed);
391
+ }
392
+ else if ((answer === "d" || answer === "drop") && row.stored !== null) {
393
+ io.log(` Removal requested: the stored hint for ${terminalSafe(row.check)}.`);
394
+ edits.set(row.check, null);
395
+ }
396
+ else if (answer === "e" || answer === "edit") {
397
+ const typed = await typedHint(prompt, io);
398
+ if (typed !== null)
399
+ edits.set(row.check, typed);
400
+ }
401
+ else {
402
+ io.log(" Not recognized; the hint is left untouched.");
403
+ }
404
+ }
405
+ // Restating the stored hint is not an edit.
406
+ for (const [check, hint] of [...edits]) {
407
+ const current = stored?.reproduction_hints?.get(check) ?? null;
408
+ if (hint === null ? current === null : current !== null && hintEqual(hint, current))
409
+ edits.delete(check);
410
+ }
411
+ return edits.size > 0 ? edits : undefined;
412
+ }
413
+ /**
414
+ * Show the review surface and collect the owner's decisions. Requires a
415
+ * terminal. Returns what changed; nothing is stored here.
416
+ */
417
+ export async function reviewDiscoveredSettings(io, proposal, stored, providerChecks) {
418
+ renderSettingsReview(io, proposal, stored, providerChecks, true);
419
+ const edit = {};
420
+ const workerEnv = await reviewWorkerEnv(io, proposal, stored);
421
+ if (workerEnv !== undefined)
422
+ edit.workerEnv = workerEnv;
423
+ const reproduce = await reviewHints(io, proposal, stored, providerChecks);
424
+ if (reproduce !== undefined)
425
+ edit.reproduce = reproduce;
426
+ return edit;
427
+ }
428
+ /** Name-only lines describing what an edit changes, for the gate comparison. */
429
+ export function describeSettingsEdit(edit, stored) {
430
+ const lines = [];
431
+ if (edit.workerEnv !== undefined) {
432
+ const before = stored?.worker_env ?? [];
433
+ const added = edit.workerEnv.filter((e) => !before.some((b) => b.name === e.name)).map((e) => e.name);
434
+ const changed = edit.workerEnv
435
+ .filter((e) => before.some((b) => b.name === e.name && !sameEntry(b, e)))
436
+ .map((e) => e.name);
437
+ const removed = before.filter((b) => !(edit.workerEnv ?? []).some((e) => e.name === b.name)).map((b) => b.name);
438
+ const parts = [
439
+ added.length > 0 ? `added ${safeList(added)}` : "",
440
+ changed.length > 0 ? `changed ${safeList(changed)}` : "",
441
+ removed.length > 0 ? `removal requested for ${safeList(removed)}` : "",
442
+ ].filter((p) => p !== "");
443
+ lines.push(` worker variables: ${edit.workerEnv.length} after this change (${parts.join("; ")})`);
444
+ }
445
+ for (const [check, hint] of edit.reproduce ?? []) {
446
+ lines.push(hint === null
447
+ ? ` reproduction hint for ${terminalSafe(check)}: removal requested`
448
+ : ` reproduction hint for ${terminalSafe(check)}: set (hint only — never changes gating)`);
449
+ }
450
+ return lines;
451
+ }
@@ -89,7 +89,7 @@ export const HOOK_RUNTIME_ACTIONS = {
89
89
  "from a persistent install.",
90
90
  "unqualified-runtime": "the hook runtime is not a qualified persistent installation (supported: a persistent npm " +
91
91
  `install of ${MCP_PACKAGE_NAME} ${HOOK_RUNTIME_COMPATIBLE_RANGE} on macOS or Linux with an even ` +
92
- `Node LTS line >= ${HOOK_RUNTIME_MIN_NODE_MAJOR}). See mcp_server/docs/EPIC-IMPLEMENTER.md.`,
92
+ `Node LTS line >= ${HOOK_RUNTIME_MIN_NODE_MAJOR}). See docs/EPIC-IMPLEMENTER.md in the ${MCP_PACKAGE_NAME} package.`,
93
93
  "node-unavailable": "`node` could not be launched from PATH, so the hook cannot run. Put a qualified Node on PATH " +
94
94
  "and re-run `epic-implementer doctor`.",
95
95
  "native-unavailable": "better-sqlite3 does not load for the hook's Node, so no event can be recorded. Reinstall the " +
@@ -129,7 +129,9 @@ export async function runConductorInstallDoctor(deps) {
129
129
  }
130
130
  else {
131
131
  try {
132
- readiness = await fetchConductorReadiness(deps.access, deps.fetch);
132
+ readiness = deps.epicRunId
133
+ ? await fetchConductorReadiness(deps.access, deps.fetch, { epicRunId: deps.epicRunId })
134
+ : await fetchConductorReadiness(deps.access, deps.fetch);
133
135
  }
134
136
  catch (err) {
135
137
  const kind = err instanceof ConductorBridgeApiError ? err.kind : "network";
@@ -158,7 +160,7 @@ export async function runConductorInstallDoctor(deps) {
158
160
  // BAPI-1405 — the three warn-only epic-branch CI rows, beside the gate
159
161
  // profile they qualify. Never fatal, so they cannot change the exit code or
160
162
  // the installer's pre-write abort. An older server renders them as
161
- // "Unreported — upgrade the server", never as "no warning".
163
+ // "Unreported by the server", never as "no warning".
162
164
  sections.push(...epicBranchCiSections(readiness.epic_branch_ci));
163
165
  sections.push(githubCredentialsSection(readiness));
164
166
  sections.push(githubActionsSection(readiness));