@bridge_gpt/mcp-server 0.2.71 → 0.2.72

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 (116) hide show
  1. package/README.md +55 -17
  2. package/build/agent-launchers/claude-executor-adapter.js +19 -3
  3. package/build/agent-notes.js +171 -95
  4. package/build/agents.generated.js +4 -4
  5. package/build/bridge-permissions.js +4 -0
  6. package/build/bridge-worktree-inspection.js +237 -0
  7. package/build/check-evidence.js +6 -0
  8. package/build/claude-review-workflow.js +1 -1
  9. package/build/cli-help.js +6 -0
  10. package/build/codex-auto-recovery.js +126 -0
  11. package/build/codex-skill-adapter.js +2 -0
  12. package/build/commands.generated.js +5 -5
  13. package/build/conductor/bridge-api-client.js +518 -23
  14. package/build/conductor/doctor.js +84 -10
  15. package/build/conductor/epic-implementer-cli.js +51 -2
  16. package/build/conductor/gate-discovery.js +136 -10
  17. package/build/conductor/gate-settings-review.js +305 -5
  18. package/build/conductor/git-hooks-uninstall.js +112 -0
  19. package/build/conductor/git-hooks.js +81 -15
  20. package/build/conductor/guided-repair.js +10 -1
  21. package/build/conductor/install-doctor.js +2 -4
  22. package/build/conductor/launch-plan.js +42 -2
  23. package/build/conductor/local-merge.js +12 -1
  24. package/build/conductor/merge-execution-contract.js +1 -1
  25. package/build/conductor/merged-child-check.js +2 -1
  26. package/build/conductor/prerequisite-inputs.js +379 -0
  27. package/build/conductor/readiness-assessment.js +78 -0
  28. package/build/conductor/readiness-cli.js +10 -0
  29. package/build/conductor/readiness-prerequisites.js +53 -0
  30. package/build/conductor/readiness-sections.js +21 -8
  31. package/build/conductor/readiness.js +20 -2
  32. package/build/conductor/recovery-cli.js +223 -13
  33. package/build/conductor/recovery-operations.js +34 -4
  34. package/build/conductor/repair-contract.js +33 -0
  35. package/build/conductor/tools.js +34 -3
  36. package/build/conductor/wait-run-attention.js +115 -0
  37. package/build/conductor/wait-run-cli.js +96 -3
  38. package/build/conductor/worker-database-doctor-inspector.js +1 -0
  39. package/build/credential-store.js +25 -20
  40. package/build/dependency-install-declarations.js +157 -0
  41. package/build/docs.generated.js +4 -4
  42. package/build/doctor.js +37 -5
  43. package/build/drive-epic-help.js +2 -2
  44. package/build/drive-epic.js +52 -11
  45. package/build/epic-implementer-bin.js +118 -43
  46. package/build/epic-launch-profile.js +1 -1
  47. package/build/executor/cli.js +2 -0
  48. package/build/executor/completion-contract.js +16 -0
  49. package/build/executor/credentials.js +1 -1
  50. package/build/executor/delivery-observations.js +113 -0
  51. package/build/executor/delivery-outcome.js +30 -0
  52. package/build/executor/dependency-refresh-runner.js +132 -0
  53. package/build/executor/dependency-refresh.js +530 -0
  54. package/build/executor/deps.js +4 -0
  55. package/build/executor/env.js +67 -2
  56. package/build/executor/harness-coverage.js +19 -0
  57. package/build/executor/http-client.js +35 -1
  58. package/build/executor/index.js +2 -1
  59. package/build/executor/install-preflight.js +1 -1
  60. package/build/executor/job-runner.js +246 -28
  61. package/build/executor/likely-tests.js +94 -97
  62. package/build/executor/prompt-spec.js +13 -3
  63. package/build/executor/required-verification.js +28 -0
  64. package/build/executor/required-work-diagnostics.js +30 -0
  65. package/build/executor/required-work-ledger.js +19 -1
  66. package/build/executor/results.js +42 -0
  67. package/build/executor/service-discovery.js +42 -0
  68. package/build/executor/service-lifecycle.js +109 -2
  69. package/build/executor/service-uninstall.js +205 -0
  70. package/build/executor/service-unit.js +5 -3
  71. package/build/executor/test-clock.js +3 -0
  72. package/build/executor/verification-hints.js +179 -0
  73. package/build/executor/worker-command.js +54 -2
  74. package/build/executor/worker-database.js +271 -31
  75. package/build/executor/worker-finalization.js +65 -10
  76. package/build/executor/worker-guard-hook.js +10 -2
  77. package/build/executor/worker-verification-guidance.js +37 -2
  78. package/build/executor/worktree-inspection.js +42 -0
  79. package/build/github-sign-in.js +1 -1
  80. package/build/index.js +679 -278
  81. package/build/init.js +3 -3
  82. package/build/install-bridge-conductor-gate.js +236 -42
  83. package/build/install-bridge-conductor-setup.js +115 -26
  84. package/build/install-bridge-conductor.js +448 -350
  85. package/build/install-bridge.js +418 -123
  86. package/build/install-maintenance.js +104 -0
  87. package/build/install-reexec.js +1 -1
  88. package/build/local-cleanup.js +59 -0
  89. package/build/mcp-install-state.js +68 -2
  90. package/build/merge-workflow-install.js +2 -2
  91. package/build/package-script-semantics.js +10 -0
  92. package/build/pipeline-utils.js +1 -1
  93. package/build/pipelines.generated.js +5 -5
  94. package/build/plan-execution-ledger.js +148 -2
  95. package/build/plane/plane-freshness.js +6 -7
  96. package/build/plane/terminal-run-cleanup.js +5 -1
  97. package/build/plane/terminal-run-status.js +4 -0
  98. package/build/printed-remedy-commands.js +24 -4
  99. package/build/readiness-check.js +1 -78
  100. package/build/readiness-prerequisites.generated.js +199 -0
  101. package/build/readme.generated.js +1 -1
  102. package/build/repository-toolchains.js +50 -8
  103. package/build/setup-change-policy.js +32 -0
  104. package/build/setup-epic.js +2 -2
  105. package/build/setup-question.js +62 -0
  106. package/build/start-tickets.js +4 -0
  107. package/build/test-command-detection.js +32 -88
  108. package/build/test-support/notes-fs.js +40 -0
  109. package/build/ticket-delivery-enrollment.js +21 -8
  110. package/build/ticket-delivery-run-scope.js +128 -0
  111. package/build/version.generated.js +3 -3
  112. package/build/worker-guard-hook-bin.js +2 -2
  113. package/build/worktrees.js +105 -0
  114. package/docs/EPIC-IMPLEMENTER.md +5 -0
  115. package/docs/epic-implementer/getting-started.md +40 -15
  116. package/package.json +1 -1
package/build/init.js CHANGED
@@ -625,7 +625,7 @@ export async function runInit(cwd, options = {}) {
625
625
  // A run must either reconcile every config or change nothing. Discovering a
626
626
  // malformed second config only after the first was rewritten would leave the
627
627
  // project half-migrated with no record of what moved.
628
- const inspections = await inspectLauncherConfigs({
628
+ const inspections = options.assetsOnly ? [] : await inspectLauncherConfigs({
629
629
  cwd,
630
630
  targetVersion,
631
631
  readFile: (p) => io.readFile(p, "utf-8"),
@@ -657,7 +657,7 @@ export async function runInit(cwd, options = {}) {
657
657
  const configActions = [];
658
658
  const structuredActions = [];
659
659
  const readinessWarnings = [];
660
- for (const target of configTargets) {
660
+ for (const target of options.assetsOnly ? [] : configTargets) {
661
661
  const found = byPath.get(target.path);
662
662
  const fullPath = path.join(cwd, target.path);
663
663
  if (found.action === "skip-inactive") {
@@ -1098,7 +1098,7 @@ says to serialize structured output.
1098
1098
  // `upgrade` pass no creation context and keep the folder-name default.
1099
1099
  let bridgeConfigCreated = false;
1100
1100
  let bridgeConfigRepoName;
1101
- if (!bridgeConfigExists) {
1101
+ if (!bridgeConfigExists && !options.assetsOnly) {
1102
1102
  const scaffoldName = options.creationContext?.repoName ?? chooseScaffoldRepoName(cwd);
1103
1103
  const representable = validateBridgeConfigRepoNameRepresentability(scaffoldName);
1104
1104
  if (representable.ok) {
@@ -1,5 +1,6 @@
1
+ import { askSetupQuestion, setupConsentQuestion } from "./setup-question.js";
1
2
  /**
2
- * `install-bridge conductor` — the owner-confirmed repository gate (BAPI-1391).
3
+ * `install epic-implementer` — the owner-confirmed repository gate (BAPI-1391).
3
4
  *
4
5
  * Before this module, the conductor installer refused to run without at least
5
6
  * one `--required-check`, so a repository whose CI used other names, ran outside
@@ -41,8 +42,8 @@
41
42
  */
42
43
  import { ConductorBridgeApiError, GATE_PROFILE_CAPABILITY_TOKEN, enqueueConductorGateQualification, fetchConductorGateCheckHistory, fetchConductorGateProfile, fetchConductorGateQualificationJob, probeConductorGateProfileCapability, putConductorGateProfile, putEpicBranchCiDecision, } from "./conductor/bridge-api-client.js";
43
44
  import { applyApprovalExemption, assessApprovalExemptionScope, buildEpicBranchCiEvidence, exemptionManualSteps, inspectEpicBranchWorkflowCoverage, readEpicBranchRulesViaGh, } from "./conductor/epic-branch-ci-inspection.js";
44
- import { describeEvidence, discoverGate, LOCAL_COMMAND_TIMEOUT_SECONDS, } from "./conductor/gate-discovery.js";
45
- import { describeSettingsEdit, hasSettingsToReview, hintEqual, renderSettingsReview, reviewDiscoveredSettings, settingsMatchStored, terminalSafe, workerEnvEqual, } from "./conductor/gate-settings-review.js";
45
+ import { describeEvidence, discoverDeclarations, discoverGate, LOCAL_COMMAND_TIMEOUT_SECONDS, } from "./conductor/gate-discovery.js";
46
+ import { dependencyInstallEqual, describeSettingsEdit, hasSettingsToReview, hasUnstoredDeclarationProposal, hintEqual, renderDeclarationsOnly, renderSettingsReview, reviewDeclarations, reviewDiscoveredSettings, settingsMatchStored, storedCiDatabase, terminalSafe, workerEnvEqual, } from "./conductor/gate-settings-review.js";
46
47
  import { PRINTED_EXECUTOR_INSTALL_SERVICE_COMMAND, PRINTED_EXECUTOR_ID_INSTRUCTION, PRINTED_QUALIFY_GATE_COMMAND, PRINTED_REPO_WIDE_EXECUTOR_COMMAND, } from "./printed-remedy-commands.js";
47
48
  export function emptyConductorGateFlags() {
48
49
  return {
@@ -200,10 +201,8 @@ export function createQualificationExecutorRunner(seams) {
200
201
  }
201
202
  const YES = new Set(["y", "yes"]);
202
203
  async function ask(io, promptText) {
203
- if (!io.promptLine)
204
- return false;
205
- const answer = await io.promptLine(promptText);
206
- return YES.has((answer ?? "").trim().toLowerCase());
204
+ const decision = await askSetupQuestion(setupConsentQuestion(promptText), { read: io.promptLine, write: io.log });
205
+ return decision.status === "accept";
207
206
  }
208
207
  /** The fixed update-required refusal (property 2). */
209
208
  export const GATE_UPDATE_REQUIRED_MESSAGE = `Bridge API update required: this server does not advertise ${GATE_PROFILE_CAPABILITY_TOKEN}, so ` +
@@ -287,6 +286,8 @@ function settingsOf(desired) {
287
286
  return {
288
287
  ...(desired.workerEnv !== undefined ? { workerEnv: desired.workerEnv } : {}),
289
288
  ...(desired.reproduce !== undefined ? { reproduce: desired.reproduce } : {}),
289
+ ...(desired.dependencyInstall !== undefined ? { dependencyInstall: desired.dependencyInstall } : {}),
290
+ ...(desired.ciDatabase !== undefined ? { ciDatabase: desired.ciDatabase } : {}),
290
291
  };
291
292
  }
292
293
  /** Human descriptions of every member `next` removes from `prior`. */
@@ -326,6 +327,10 @@ export function confirmRequestFor(desired, expectedRevision, stored) {
326
327
  return { name, reproduce: { argv: [...edit.argv], timeout_seconds: edit.timeout_seconds } };
327
328
  });
328
329
  const sendWorkerEnv = desired.workerEnv !== undefined && !workerEnvEqual(desired.workerEnv, stored?.worker_env);
330
+ // BAPI-1551: each declaration is sent only when it differs from what is stored;
331
+ // a clear sends `[]`, and a reset of the CI-database value sends `null`.
332
+ const sendDependencyInstall = desired.dependencyInstall !== undefined && !dependencyInstallEqual(desired.dependencyInstall, stored?.dependency_install);
333
+ const sendCiDatabase = desired.ciDatabase !== undefined && desired.ciDatabase !== storedCiDatabase(stored);
329
334
  return {
330
335
  action: "confirm",
331
336
  confirm: true,
@@ -342,6 +347,18 @@ export function confirmRequestFor(desired, expectedRevision, stored) {
342
347
  ...(sendWorkerEnv && desired.workerEnv !== undefined
343
348
  ? { worker_env: desired.workerEnv.map((e) => ({ ...e })) }
344
349
  : {}),
350
+ ...(sendDependencyInstall && desired.dependencyInstall !== undefined
351
+ ? {
352
+ dependency_install: desired.dependencyInstall.map((e) => ({
353
+ cwd: e.cwd,
354
+ argv: [...e.argv],
355
+ lockfiles: [...e.lockfiles],
356
+ })),
357
+ }
358
+ : {}),
359
+ ...(sendCiDatabase && desired.ciDatabase !== undefined
360
+ ? { ci_database: desired.ciDatabase === "unknown" ? null : desired.ciDatabase }
361
+ : {}),
345
362
  };
346
363
  }
347
364
  function resolveLocalCommand(flag, proposal) {
@@ -498,6 +515,8 @@ export function renderGateProposal(io, proposal) {
498
515
  numbered.push({ kind: "provider", name: candidate.name });
499
516
  io.log(` [${numbered.length}] provider check "${candidate.name}" — reported on this repository ` +
500
517
  `(confidence ${candidate.confidence})`);
518
+ if (candidate.checkEvidence)
519
+ io.log(` purpose: ${candidate.checkEvidence.purpose} (${candidate.checkEvidence.purposeProvenance}); source: ${candidate.checkEvidence.discoverySource}; outcome: ${candidate.checkEvidence.executionOutcome}`);
501
520
  for (const e of candidate.evidence)
502
521
  io.log(` evidence: ${describeEvidence(e)}`);
503
522
  }
@@ -611,25 +630,28 @@ function historyLookupFor(io, access) {
611
630
  /** Run discovery, or an explicit empty proposal when no discovery seam exists. */
612
631
  export async function runGateDiscovery(io, access, gateDeps) {
613
632
  const fs = gateDeps?.discoveryFs;
614
- if (!fs) {
615
- return {
616
- providerCandidates: [],
617
- unreportedProviderNames: [],
618
- localCandidates: [],
619
- evidence: [],
620
- history: { status: "not_queried" },
621
- proposed: { kind: "none", providerChecks: [], localCommandIds: [] },
622
- noCandidates: true,
623
- workerEnvCandidates: [],
624
- workerEnvConflicts: [],
625
- workerEnvSkipped: [],
626
- workerEnvOverflow: 0,
627
- reproductionHints: [],
628
- reproductionHintsSkipped: [],
629
- };
630
- }
633
+ if (!fs)
634
+ return emptyProposal();
631
635
  return discoverGate({ fs, lookupHistory: historyLookupFor(io, access) });
632
636
  }
637
+ /** A fresh explicit empty proposal: nothing discovered, nothing proposed. */
638
+ function emptyProposal() {
639
+ return {
640
+ providerCandidates: [],
641
+ unreportedProviderNames: [],
642
+ localCandidates: [],
643
+ evidence: [],
644
+ history: { status: "not_queried" },
645
+ proposed: { kind: "none", providerChecks: [], localCommandIds: [] },
646
+ noCandidates: true,
647
+ workerEnvCandidates: [],
648
+ workerEnvConflicts: [],
649
+ workerEnvSkipped: [],
650
+ workerEnvOverflow: 0,
651
+ reproductionHints: [],
652
+ reproductionHintsSkipped: [],
653
+ };
654
+ }
633
655
  const MAX_SELECTION_ATTEMPTS = 3;
634
656
  const MAX_TYPED_CHECKS = 32;
635
657
  /**
@@ -729,9 +751,113 @@ async function reviewSettingsInto(io, proposal, current, desired) {
729
751
  ...desired,
730
752
  ...(edit.workerEnv !== undefined ? { workerEnv: edit.workerEnv } : {}),
731
753
  ...(edit.reproduce !== undefined ? { reproduce: edit.reproduce } : {}),
754
+ ...(edit.dependencyInstall !== undefined ? { dependencyInstall: edit.dependencyInstall } : {}),
755
+ ...(edit.ciDatabase !== undefined ? { ciDatabase: edit.ciDatabase } : {}),
732
756
  };
733
757
  return { desired: merged, changed: !settingsMatchStored(edit, current.profile) };
734
758
  }
759
+ /**
760
+ * BAPI-1551 — keep the confirmed gate, and offer any unstored declaration
761
+ * proposal as an optional gate change. Declining it (or having none) keeps the
762
+ * no-write plan exactly as before; it never becomes a blocking item.
763
+ */
764
+ async function keptGateWithDeclarations(io, current, currentDesired, gateDeps, options) {
765
+ const unchanged = {
766
+ kind: "plan",
767
+ plan: { current, desired: currentDesired, write: null, removals: [], origin: "stored" },
768
+ };
769
+ const offered = await offerDeclarationChanges(io, current, currentDesired, gateDeps, options);
770
+ if (!offered.changed)
771
+ return unchanged;
772
+ renderGateComparison(io, current, offered.desired, []);
773
+ if (!options.planningOnly && !(await ask(io, "Store these worker setup declarations with the gate? [y/N]: "))) {
774
+ io.log(" Declarations not stored; the stored gate and its settings are unchanged.");
775
+ for (const key of offered.offeredKeys)
776
+ options.declinedDeclarations?.add(key);
777
+ return unchanged;
778
+ }
779
+ return {
780
+ kind: "plan",
781
+ plan: {
782
+ current,
783
+ desired: offered.desired,
784
+ write: confirmRequestFor(offered.desired, current.revision, current.profile),
785
+ removals: [],
786
+ origin: "stored",
787
+ },
788
+ };
789
+ }
790
+ /**
791
+ * BAPI-1551 — with a confirmed gate kept as it is, offer the dependency-refresh
792
+ * and CI-database proposals the stored profile does not hold yet. Advisory: the
793
+ * offer only ever adds a gate change the owner accepts. It runs only in a
794
+ * terminal, never under `--dry-run`, never without a discovery seam, and asks
795
+ * nothing when there is no unstored proposal. Declining keeps the stored values.
796
+ */
797
+ async function offerDeclarationChanges(io, current, desired, gateDeps, options) {
798
+ const none = { desired, changed: false, offeredKeys: [] };
799
+ const prompt = io.promptLine;
800
+ const fs = gateDeps?.discoveryFs;
801
+ if (!prompt || !fs || options.dryRun || current.profile === null)
802
+ return none;
803
+ let declarations;
804
+ try {
805
+ declarations = await discoverDeclarations({ fs, providerChecks: desired.providerChecks });
806
+ }
807
+ catch {
808
+ return none;
809
+ }
810
+ // Never re-offer what the owner already ignored or declined in this invocation.
811
+ const declined = options.declinedDeclarations;
812
+ const candidates = (declarations.dependencyInstallCandidates ?? []).filter((c) => !declined?.has(dependencyProposalKey(c)));
813
+ const ci = declarations.ciDatabaseProposal;
814
+ const proposal = {
815
+ ...emptyProposal(),
816
+ ...(candidates.length > 0 ? { dependencyInstallCandidates: candidates } : {}),
817
+ ...(declarations.dependencyInstallNotes ? { dependencyInstallNotes: declarations.dependencyInstallNotes } : {}),
818
+ ...(ci !== undefined && !declined?.has(ciDatabaseProposalKey(ci.value)) ? { ciDatabaseProposal: ci } : {}),
819
+ };
820
+ if (!hasUnstoredDeclarationProposal(proposal, current.profile))
821
+ return none;
822
+ const offeredKeys = [
823
+ ...(proposal.dependencyInstallCandidates ?? [])
824
+ .filter((c) => !(current.profile?.dependency_install ?? []).some((e) => dependencyInstallEqual([e], [c])))
825
+ .map(dependencyProposalKey),
826
+ ...(proposal.ciDatabaseProposal !== undefined &&
827
+ proposal.ciDatabaseProposal.value !== storedCiDatabase(current.profile)
828
+ ? [ciDatabaseProposalKey(proposal.ciDatabaseProposal.value)]
829
+ : []),
830
+ ];
831
+ io.log("");
832
+ io.log(" Discovery proposes worker setup declarations this gate does not store yet (optional):");
833
+ renderDeclarationsOnly(io, proposal, current.profile, true);
834
+ const edit = await reviewDeclarations({ log: io.log, promptLine: prompt }, proposal, current.profile);
835
+ const merged = {
836
+ ...desired,
837
+ ...(edit.dependencyInstall !== undefined ? { dependencyInstall: edit.dependencyInstall } : {}),
838
+ ...(edit.ciDatabase !== undefined ? { ciDatabase: edit.ciDatabase } : {}),
839
+ };
840
+ // A proposal the owner did not take is remembered as declined for this invocation.
841
+ const resultingList = edit.dependencyInstall ?? current.profile.dependency_install ?? [];
842
+ const resultingCi = edit.ciDatabase ?? storedCiDatabase(current.profile);
843
+ for (const candidate of proposal.dependencyInstallCandidates ?? []) {
844
+ if (!resultingList.some((e) => dependencyInstallEqual([e], [candidate]))) {
845
+ declined?.add(dependencyProposalKey(candidate));
846
+ }
847
+ }
848
+ if (proposal.ciDatabaseProposal !== undefined && proposal.ciDatabaseProposal.value !== resultingCi) {
849
+ declined?.add(ciDatabaseProposalKey(proposal.ciDatabaseProposal.value));
850
+ }
851
+ return { desired: merged, changed: !settingsMatchStored(edit, current.profile), offeredKeys };
852
+ }
853
+ /** BAPI-1551 — a proposal's identity for the per-invocation declined set: the whole entry. */
854
+ export function dependencyProposalKey(entry) {
855
+ return `dependency_install:${JSON.stringify([entry.cwd, entry.argv, entry.lockfiles])}`;
856
+ }
857
+ /** BAPI-1551 — the declined-set key of a CI-database proposal. */
858
+ export function ciDatabaseProposalKey(value) {
859
+ return `ci_database:${value}`;
860
+ }
735
861
  /**
736
862
  * Decide the repository gate for this run (BEFORE any write).
737
863
  *
@@ -789,14 +915,14 @@ export async function resolveConductorGate(io, access, flags, gateDeps, options)
789
915
  io.log(" The confirmed gate already matches — no gate write is needed.");
790
916
  return { kind: "plan", plan: { current, desired: currentDesired, write: null, removals: [], origin: "stored" } };
791
917
  }
792
- if (settingsChanged && !options.dryRun) {
918
+ if (settingsChanged && !options.dryRun && !options.planningOnly) {
793
919
  const ok = await ask(io, "Store these CI settings with the gate? [y/N]: ");
794
920
  if (!ok) {
795
921
  io.errorLog("CI settings not confirmed — nothing was written, and the stored gate is unchanged.");
796
922
  return { kind: "exit", code: 1 };
797
923
  }
798
924
  }
799
- if (removals.length > 0 && !flags.confirmGate && !options.dryRun) {
925
+ if (removals.length > 0 && !flags.confirmGate && !options.dryRun && !options.planningOnly) {
800
926
  const ok = await ask(io, "Confirm this gate, including the removals above? [y/N]: ");
801
927
  if (!ok) {
802
928
  io.errorLog("Gate change not confirmed — nothing was written, and the stored gate is unchanged.");
@@ -824,7 +950,7 @@ export async function resolveConductorGate(io, access, flags, gateDeps, options)
824
950
  : ` Using the confirmed gate (revision ${current.revision}).`);
825
951
  for (const line of describeGate(currentDesired))
826
952
  io.log(line);
827
- return { kind: "plan", plan: { current, desired: currentDesired, write: null, removals: [], origin: "stored" } };
953
+ return keptGateWithDeclarations(io, current, currentDesired, gateDeps, options);
828
954
  }
829
955
  const proposal = await runGateDiscovery(io, access, gateDeps);
830
956
  const numbered = renderGateProposal(io, proposal);
@@ -851,7 +977,7 @@ export async function resolveConductorGate(io, access, flags, gateDeps, options)
851
977
  // BAPI-1520: worker variables and reproduction hints, decided one at a time.
852
978
  const { desired } = await reviewSettingsInto(io, proposal, current, chosen);
853
979
  renderGateComparison(io, current, desired, []);
854
- const confirmed = await ask(io, "Store this repository gate? [y/N]: ");
980
+ const confirmed = options.planningOnly || await ask(io, "Store this repository gate? [y/N]: ");
855
981
  if (!confirmed) {
856
982
  io.errorLog("Gate not confirmed — nothing was written. A confirmed gate is required to continue.");
857
983
  return { kind: "exit", code: 1 };
@@ -900,21 +1026,35 @@ async function ensureProviderCheckPlan(io, access, current, currentDesired, chec
900
1026
  : ` Using the confirmed gate (revision ${current.revision}).`);
901
1027
  for (const line of describeGate(currentDesired))
902
1028
  io.log(line);
903
- return { kind: "plan", plan: { current, desired: currentDesired, write: null, removals: [], origin: "stored" } };
1029
+ return keptGateWithDeclarations(io, current, currentDesired, gateDeps, options);
904
1030
  }
905
- const desired = withProviderCheck(currentDesired, check);
1031
+ // BAPI-1551: unstored declaration proposals ride along with this gate change.
1032
+ const offered = await offerDeclarationChanges(io, current, withProviderCheck(currentDesired, check), gateDeps, options);
1033
+ const desired = offered.desired;
906
1034
  renderGateComparison(io, current, desired, []);
907
1035
  if (currentDesired.kind === "local" || currentDesired.kind === "none") {
908
1036
  if (options.dryRun) {
909
1037
  io.log(" Dry run — a real run asks before adding the CI check to this gate.");
910
1038
  }
911
- else {
1039
+ else if (!options.planningOnly) {
912
1040
  const ok = await ask(io, "Add the CI workflow check to this repository gate? [y/N]: ");
913
1041
  if (!ok) {
914
1042
  io.log(" Kept the stored gate unchanged; the CI check is listed as a step left.");
1043
+ // Declining the check never discards declarations the owner accepted.
1044
+ const kept = {
1045
+ ...currentDesired,
1046
+ ...(desired.dependencyInstall !== undefined ? { dependencyInstall: desired.dependencyInstall } : {}),
1047
+ ...(desired.ciDatabase !== undefined ? { ciDatabase: desired.ciDatabase } : {}),
1048
+ };
915
1049
  return {
916
1050
  kind: "plan",
917
- plan: { current, desired: currentDesired, write: null, removals: [], origin: "stored" },
1051
+ plan: {
1052
+ current,
1053
+ desired: kept,
1054
+ write: offered.changed ? confirmRequestFor(kept, current.revision, current.profile) : null,
1055
+ removals: [],
1056
+ origin: "stored",
1057
+ },
918
1058
  ensureDeclined: true,
919
1059
  };
920
1060
  }
@@ -931,9 +1071,11 @@ async function ensureProviderCheckPlan(io, access, current, currentDesired, chec
931
1071
  },
932
1072
  };
933
1073
  }
934
- const proposal = await runGateDiscovery(io, access, gateDeps);
1074
+ const discovered = await runGateDiscovery(io, access, gateDeps);
1075
+ const proposal = { ...discovered, proposed: { ...discovered.proposed,
1076
+ providerChecks: [...new Set([...discovered.proposed.providerChecks, check])] } };
935
1077
  renderGateProposal(io, proposal);
936
- const desired = withProviderCheck(desiredFromProposalSelection(proposal, proposal.proposed.providerChecks, proposal.proposed.localCommandIds), check);
1078
+ const desired = desiredFromProposalSelection(proposal, proposal.proposed.providerChecks, proposal.proposed.localCommandIds);
937
1079
  renderGateComparison(io, current, desired, []);
938
1080
  return {
939
1081
  kind: "plan",
@@ -957,7 +1099,8 @@ const GATE_WRITE_REFUSAL_TEXT = Object.freeze({
957
1099
  timeout: "the Bridge API did not answer in time.",
958
1100
  server: "the Bridge API reported an internal error.",
959
1101
  rejected: "the Bridge API rejected the request.",
960
- "extension-unsupported": "this server is older than the installer and cannot store worker variables or reproduction hints.",
1102
+ "extension-unsupported": "this server is older than the installer and cannot store worker variables, reproduction hints, " +
1103
+ "dependency refresh declarations, or CI database behavior.",
961
1104
  });
962
1105
  /** Plain-language text for each closed `worker_env` refusal reason (BAPI-1520). */
963
1106
  const WORKER_ENV_REASON_TEXT = Object.freeze({
@@ -966,15 +1109,19 @@ const WORKER_ENV_REASON_TEXT = Object.freeze({
966
1109
  worker_env_secret_name: "looks secret. Drop it, or confirm its committed-literal assertion individually, then confirm again.",
967
1110
  worker_env_duplicate: "appears more than once. Keep one entry, then confirm again.",
968
1111
  });
969
- /** The request without BAPI-1520's extension fields, and the NAMES it dropped. */
1112
+ /** The request without the BAPI-1520 and BAPI-1551 extension fields, and what it dropped. */
970
1113
  function withoutExtensions(request) {
971
1114
  const workerEnvNames = (request.worker_env ?? []).map((e) => e.name);
972
1115
  const hintChecks = (request.provider_checks ?? [])
973
1116
  .filter((c) => c.reproduce !== undefined)
974
1117
  .map((c) => c.name);
975
- const { worker_env: _dropped, ...rest } = request;
1118
+ const { worker_env: _dropped, dependency_install: _install, ci_database: _database, ...rest } = request;
976
1119
  void _dropped;
1120
+ void _install;
1121
+ void _database;
977
1122
  return {
1123
+ ...(request.dependency_install !== undefined ? { dependencyInstall: request.dependency_install } : {}),
1124
+ ...(request.ci_database !== undefined ? { ciDatabase: request.ci_database } : {}),
978
1125
  request: {
979
1126
  ...rest,
980
1127
  ...(request.provider_checks ? { provider_checks: request.provider_checks.map((c) => ({ name: c.name })) } : {}),
@@ -1005,11 +1152,16 @@ export async function storeConductorGate(io, access, plan) {
1005
1152
  let unsaved = null;
1006
1153
  if (!outcome.ok && outcome.refusal === "extension-unsupported") {
1007
1154
  const stripped = withoutExtensions(plan.write);
1008
- unsaved = { workerEnvNames: stripped.workerEnvNames, hintChecks: stripped.hintChecks };
1155
+ unsaved = {
1156
+ workerEnvNames: stripped.workerEnvNames,
1157
+ hintChecks: stripped.hintChecks,
1158
+ ...(stripped.dependencyInstall !== undefined ? { dependencyInstall: stripped.dependencyInstall } : {}),
1159
+ ...(stripped.ciDatabase !== undefined ? { ciDatabase: stripped.ciDatabase } : {}),
1160
+ };
1009
1161
  const storedDesired = plan.current.profile !== null ? desiredFromStored(plan.current.profile) : null;
1010
1162
  const membersUnchanged = plan.current.source === "stored" &&
1011
1163
  storedDesired !== null &&
1012
- gateMatchesStored({ ...plan.desired, workerEnv: undefined, reproduce: undefined }, storedDesired);
1164
+ gateMatchesStored({ ...plan.desired, workerEnv: undefined, reproduce: undefined, dependencyInstall: undefined, ciDatabase: undefined }, storedDesired);
1013
1165
  if (membersUnchanged) {
1014
1166
  reportUnsavedSettings(io, unsaved);
1015
1167
  io.log(" The gate itself already matched, so nothing was written.");
@@ -1031,6 +1183,10 @@ export async function storeConductorGate(io, access, plan) {
1031
1183
  io.errorLog(" A worker variable was refused. Correct it, then confirm again; nothing was truncated or written.");
1032
1184
  }
1033
1185
  io.errorLog(` Nothing was written. ${describeStoredHeading(plan.current)}`);
1186
+ // BAPI-1551: what the owner typed for the declarations stays visible, so a
1187
+ // refused or failed write never silently loses it.
1188
+ for (const line of describeUnsentDeclarations(plan.write))
1189
+ io.errorLog(line);
1034
1190
  if (plan.current.confirmed && plan.current.profile !== null) {
1035
1191
  for (const line of describeGate(desiredFromStored(plan.current.profile)))
1036
1192
  io.errorLog(line);
@@ -1042,10 +1198,42 @@ export async function storeConductorGate(io, access, plan) {
1042
1198
  reportUnsavedSettings(io, unsaved);
1043
1199
  return outcome.profile;
1044
1200
  }
1045
- /** BAPI-1520 — name the settings an older server could not store. Never a value. */
1201
+ /**
1202
+ * BAPI-1551 — the declaration edits a write carried, as the owner typed them, so
1203
+ * they can be re-entered after a refused or failed write. Printed only to the
1204
+ * owner's own installer output; the argv is the owner's own declaration.
1205
+ */
1206
+ function describeUnsentDeclarations(write) {
1207
+ const lines = [];
1208
+ if (write.dependency_install !== undefined) {
1209
+ const entries = write.dependency_install ?? [];
1210
+ if (entries.length === 0) {
1211
+ lines.push(" Not stored — dependency refresh: clear every stored entry");
1212
+ }
1213
+ else {
1214
+ lines.push(" Not stored — dependency refresh entries (re-enter them to keep them):");
1215
+ for (const e of entries) {
1216
+ lines.push(` ${terminalSafe(e.cwd)}, lockfiles ${e.lockfiles.map(terminalSafe).join(", ")}: ` +
1217
+ e.argv.map(terminalSafe).join(" "));
1218
+ }
1219
+ }
1220
+ }
1221
+ if (write.ci_database !== undefined) {
1222
+ lines.push(` Not stored — CI database behavior: ${write.ci_database ?? "unknown (reset)"}`);
1223
+ }
1224
+ return lines;
1225
+ }
1226
+ /**
1227
+ * BAPI-1520 — name the settings an older server could not store. Worker-variable
1228
+ * values are never printed; BAPI-1551 declaration edits are, so they can be re-entered.
1229
+ */
1046
1230
  function reportUnsavedSettings(io, unsaved) {
1047
- if (unsaved.workerEnvNames.length === 0 && unsaved.hintChecks.length === 0)
1231
+ if (unsaved.workerEnvNames.length === 0 &&
1232
+ unsaved.hintChecks.length === 0 &&
1233
+ unsaved.dependencyInstall === undefined &&
1234
+ unsaved.ciDatabase === undefined) {
1048
1235
  return;
1236
+ }
1049
1237
  io.log(" ⚠ Partly stored: this server is older than the installer and cannot store these settings.");
1050
1238
  if (unsaved.workerEnvNames.length > 0) {
1051
1239
  io.log(` Not stored — worker variables: ${unsaved.workerEnvNames.map(terminalSafe).join(", ")}`);
@@ -1053,6 +1241,12 @@ function reportUnsavedSettings(io, unsaved) {
1053
1241
  if (unsaved.hintChecks.length > 0) {
1054
1242
  io.log(` Not stored — reproduction hints for: ${unsaved.hintChecks.map(terminalSafe).join(", ")}`);
1055
1243
  }
1244
+ for (const line of describeUnsentDeclarations({
1245
+ ...(unsaved.dependencyInstall !== undefined ? { dependency_install: unsaved.dependencyInstall } : {}),
1246
+ ...(unsaved.ciDatabase !== undefined ? { ci_database: unsaved.ciDatabase } : {}),
1247
+ })) {
1248
+ io.log(line);
1249
+ }
1056
1250
  io.log(" Upgrade the Bridge API deployment, then re-run to store them.");
1057
1251
  }
1058
1252
  // ---------------------------------------------------------------------------
@@ -1249,7 +1443,7 @@ export async function runQualifyConductorGate(io, access, gateDeps, options) {
1249
1443
  }
1250
1444
  if (!current.confirmed || current.profile === null) {
1251
1445
  io.errorLog("No confirmed repository gate is stored, so there is nothing to qualify. Confirm one first " +
1252
- "with install-bridge conductor. Nothing was queued.");
1446
+ "with install epic-implementer. Nothing was queued.");
1253
1447
  return 1;
1254
1448
  }
1255
1449
  const profile = current.profile;