@bridge_gpt/mcp-server 0.2.75 → 0.2.77
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.
- package/README.md +8 -6
- package/build/agents.generated.js +5 -5
- package/build/cli-dispatch.js +333 -0
- package/build/codex-auto-recovery.js +25 -7
- package/build/commands.generated.js +8 -8
- package/build/conductor/bridge-api-client.js +193 -13
- package/build/conductor/declare-blocked.js +146 -7
- package/build/conductor/driver-pass.js +8 -0
- package/build/conductor/driver-register.js +8 -2
- package/build/conductor/epic-implementer-cli.js +15 -10
- package/build/conductor/epic-server-journal.js +52 -22
- package/build/conductor/epic-server-recipe.js +15 -5
- package/build/conductor/epic-server-runtime.js +163 -45
- package/build/conductor/epic-server.js +13 -6
- package/build/conductor/install-doctor.js +30 -2
- package/build/conductor/launch-plan.js +28 -7
- package/build/conductor/local-merge.js +55 -13
- package/build/conductor/pr-ci-producer.js +12 -3
- package/build/conductor/readiness-prerequisites.js +89 -2
- package/build/conductor/readiness-sections.js +46 -13
- package/build/conductor/readiness.js +3 -40
- package/build/conductor/recovery-cli.js +14 -12
- package/build/conductor/repository-workflow-remedy.js +147 -7
- package/build/conductor/ui-readiness.js +224 -0
- package/build/conductor/wait-run-attention.js +9 -4
- package/build/conductor/wait-run-cli.js +9 -2
- package/build/docs.generated.js +67 -4
- package/build/doctor.js +97 -1
- package/build/drive-epic.js +625 -33
- package/build/engine-paths.js +10 -0
- package/build/epic-coherence-input-cli.js +105 -10
- package/build/epic-coherence-input.js +877 -4
- package/build/epic-coherence-input.test-fixtures.js +117 -0
- package/build/epic-implementer-bin.js +947 -120
- package/build/epic-implementer-env.js +2 -2
- package/build/epic-launch-context.js +8 -1
- package/build/epic-shared/cut-protocol.js +55 -3
- package/build/executor/completion-contract.js +14 -1
- package/build/executor/failure-reason-codes.js +2 -0
- package/build/executor/guarded-fast-forward-push.js +25 -2
- package/build/executor/integration-job.js +56 -2
- package/build/executor/job-runner.js +87 -28
- package/build/executor/likely-tests.js +78 -6
- package/build/executor/merge-job.js +45 -1
- package/build/executor/permissions.js +187 -2
- package/build/executor/provider-checks.js +101 -5
- package/build/executor/rebase-finalization.js +29 -27
- package/build/executor/reconcile-overlap-job.js +70 -17
- package/build/executor/rename-aside.js +265 -0
- package/build/executor/required-work-ledger.js +89 -6
- package/build/executor/resume-pre-spawn.js +32 -8
- package/build/executor/runner.js +26 -4
- package/build/executor/types.js +121 -0
- package/build/executor/worktree.js +39 -2
- package/build/index.js +2500 -495
- package/build/init.js +16 -0
- package/build/install-bridge-conductor-answers.js +4 -0
- package/build/install-bridge-conductor-apply.js +10 -0
- package/build/install-bridge-conductor-assessment.js +84 -0
- package/build/install-bridge-conductor-contracts.js +9 -1
- package/build/install-bridge-conductor-setup.js +103 -3
- package/build/install-bridge-conductor.js +440 -812
- package/build/install-bridge.js +4 -11
- package/build/language-catalog.generated.js +2649 -0
- package/build/mcp-host-config.js +54 -37
- package/build/phase-context-git-probe.js +16 -0
- package/build/pipelines.generated.js +47 -19
- package/build/plan-execution-ledger.js +35 -0
- package/build/plan-generation.js +34 -0
- package/build/plane/build-freshness.js +6 -0
- package/build/plane/cli.js +12 -5
- package/build/plane/plane-freshness.js +43 -26
- package/build/printed-remedy-commands.js +17 -0
- package/build/readiness-prerequisites.generated.js +28 -0
- package/build/readme.generated.js +1 -1
- package/build/run-unit-tests-launcher.js +3 -1
- package/build/secret-redaction.js +3 -0
- package/build/server.js +7946 -0
- package/build/setup-epic.js +41 -8
- package/build/start-tickets-prereqs.js +3 -6
- package/build/test-support/console-guard.js +30 -0
- package/build/test-support/create-preview-world.js +232 -0
- package/build/test-support/module-imports.js +155 -0
- package/build/test-support/server-client.js +96 -0
- package/build/test-support/stdio-server.js +146 -0
- package/build/ticket-delivery.js +65 -0
- package/build/v2-readiness-requirements.js +39 -5
- package/build/version.generated.js +3 -3
- package/build/worktree-core.js +51 -7
- package/docs/EPIC-IMPLEMENTER.md +150 -2
- package/docs/epic-implementer/getting-started.md +5 -1
- package/package.json +3 -3
- package/pipelines/implement-ticket.json +2 -2
- package/pipelines/learn-repository.json +19 -1
|
@@ -17,22 +17,21 @@ import { withSetupProgress } from "./setup-progress.js";
|
|
|
17
17
|
/**
|
|
18
18
|
* `install epic-implementer` — the nested conductor bootstrap phase (BAPI-679).
|
|
19
19
|
*
|
|
20
|
-
* BAPI-1461 — CONVERGING SETUP
|
|
21
|
-
*
|
|
20
|
+
* BAPI-1461 — CONVERGING SETUP, the only setup flow (BAPI-1721 retired the
|
|
21
|
+
* phased sequence it replaced). Every caller supplies the setup seams
|
|
22
|
+
* (`install-bridge.ts` builds them), and the command is a loop, not a script: it
|
|
22
23
|
* reads the Claude login marker, confirms the base URL, checks `gh auth
|
|
23
24
|
* status`, collects every readiness finding read-only, fixes only the missing
|
|
24
25
|
* items in order (each write surface behind its own consent), checks again —
|
|
25
|
-
* running the deny-enforcement probe once, there — and prints one
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* `install-bridge-conductor-setup.ts` for the item model and fix planner.
|
|
26
|
+
* running the deny-enforcement probe once, there — and prints one readiness
|
|
27
|
+
* verdict. See `install-bridge-conductor-setup.ts` for the item model and fix
|
|
28
|
+
* planner.
|
|
29
29
|
*
|
|
30
30
|
* Standing up Epic Conductor v2 on a fresh repository previously meant a manual
|
|
31
31
|
* sequence of API calls and hand-written config, with five server-side
|
|
32
32
|
* prerequisites that were invisible until an epic was already running and
|
|
33
|
-
* failing. This command replaces that sequence with:
|
|
34
|
-
*
|
|
35
|
-
* capabilities → verify → diagnose again.
|
|
33
|
+
* failing. This command replaces that sequence with one run: a read-only check,
|
|
34
|
+
* the approved missing fixes, a closing check, and one verdict.
|
|
36
35
|
*
|
|
37
36
|
* Four properties are load-bearing and are pinned by tests:
|
|
38
37
|
*
|
|
@@ -53,19 +52,20 @@ import { withSetupProgress } from "./setup-progress.js";
|
|
|
53
52
|
* otherwise. Local lifecycle success and server observation are reported as
|
|
54
53
|
* two separate facts, and the second is never derived from the first.
|
|
55
54
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
55
|
+
* Local host configuration (BAPI-775, narrowed by BAPI-1721). One local
|
|
56
|
+
* operation remains in setup, behind its own consent:
|
|
58
57
|
*
|
|
59
|
-
* tool visibility — merge the `
|
|
60
|
-
* MCP entries (`.mcp.json`, `.vscode/mcp.json`,
|
|
61
|
-
* never Codex or Copilot), then print the restart
|
|
62
|
-
* `ACTIVE_GROUPS` is frozen at MCP server startup.
|
|
63
|
-
* local observability — install the managed Git hooks, then report
|
|
64
|
-
* native ledger loadability. The ledger probe is READ-ONLY, so it needs no
|
|
65
|
-
* consent and runs whether hook consent was accepted or declined.
|
|
58
|
+
* tool visibility — merge the `epic_implementer` token into EXISTING
|
|
59
|
+
* supported host MCP entries (`.mcp.json`, `.vscode/mcp.json`,
|
|
60
|
+
* `.cursor/mcp.json` only, never Codex or Copilot), then print the restart
|
|
61
|
+
* guidance, because `ACTIVE_GROUPS` is frozen at MCP server startup.
|
|
66
62
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
63
|
+
* Optional Git hooks are NOT part of setup. `epic-implementer install-git-hooks`
|
|
64
|
+
* installs them on its own, and the doctor reports hook-target and native-ledger
|
|
65
|
+
* state read-only; setup only recommends the standalone command.
|
|
66
|
+
*
|
|
67
|
+
* Local provisioning cannot produce `complete`: the terminal outcome still turns
|
|
68
|
+
* only on the live server-observed executor claim.
|
|
69
69
|
*
|
|
70
70
|
* DURABLE-HOST MODE (BAPI-1137). The executor phase below is the supported
|
|
71
71
|
* bring-up for a *durable host*: an execution home that is not an interactive
|
|
@@ -132,13 +132,12 @@ import { withSetupProgress } from "./setup-progress.js";
|
|
|
132
132
|
* default branch, not the person's folder. The one stop this adds is the learned
|
|
133
133
|
* stop; everything else it adds only warns.
|
|
134
134
|
*/
|
|
135
|
-
import {
|
|
135
|
+
import { PRINTED_QUALIFY_GATE_COMMAND, CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION } from "./printed-remedy-commands.js";
|
|
136
136
|
import { collectEpicBranchCi, confirmRequestFor, planDeclarations, resolveEffectiveDependencyInstall, describeGateRestoration, desiredFromStored, emptyConductorGateFlags, hasExplicitGateInput, parseLocalCommandFlag, parseEpicBranchCiDecisionFlag, parseMigrationGuardFlag, planManagedProviderGate, reportLearnedCommandTrial, isInformationalNoCommandReason, NO_COMMAND_INFORMATION_TEXT, CANDIDATE_REJECTION_FIX, formatSetupPolicyRefusal, describePolicyChanges, resolveConductorGate, runEpicBranchCiInspection, runGateConsequenceSummary, runClearConductorGate, mapExemptionOutcomeToWriteResult, runConductorGateQualification, runLearnedTestCommandTrial, runQualifyConductorGate, validateConductorGateFlags, } from "./install-bridge-conductor-gate.js";
|
|
137
137
|
import { classifyEpicPullRequestTrigger, readDefaultBranchRequiredChecksViaGh, readPullRequestBranchFilters, } from "./conductor/epic-branch-ci-inspection.js";
|
|
138
138
|
import { describeGateConsequence } from "./conductor/readiness-sections.js";
|
|
139
139
|
import { fetchConductorReadiness, } from "./conductor/bridge-api-client.js";
|
|
140
|
-
import { CONDUCTOR_OPERATOR_RUNBOOK_POINTER,
|
|
141
|
-
import { describeNativeLedgerAvailability, } from "./conductor/doctor.js";
|
|
140
|
+
import { CONDUCTOR_OPERATOR_RUNBOOK_POINTER, conductorInstallDoctorExitCode, conductorInstallDoctorHasFatal, formatConductorInstallDoctorReport, } from "./conductor/install-doctor.js";
|
|
142
141
|
import { resolveGithubMergeRepositoryIdentity, } from "./credential-store.js";
|
|
143
142
|
import { isUsableMergeCredentialValue, resolveLocalMergeCredentialDetailed, } from "./conductor/merge-credential.js";
|
|
144
143
|
import { readStoredTestCommand } from "./testing-config-client.js";
|
|
@@ -157,7 +156,10 @@ import { CANDIDATE_EXCLUSION_TEXT, CANDIDATE_ORIGIN_LABEL, describeInventoryExcl
|
|
|
157
156
|
import { buildEpicCapabilityStatement } from "./epic-capability-statement.js";
|
|
158
157
|
import { MCP_GRANT_MAX_SERVERS } from "./mcp-grant.js";
|
|
159
158
|
import { advisoryFindingLines, assessIndexFreshness, assessSetupIndex, catalogLabel, NPM_SETUP_LAUNCHER, closedSetupPullRequestNotice, compareIndexedToMerge, planSetupFixes, projectSetupItems, readSetupPullRequest, renderSetupAssessment, deriveCompactReadiness, setupItemRemedy, setupVerdictLine, unmetBlockingItems, } from "./install-bridge-conductor-setup.js";
|
|
160
|
-
import {
|
|
159
|
+
import { profileMergeNeededFrom } from "./mcp-host-config.js";
|
|
160
|
+
import { overlayReadinessPrerequisites, toolVisibilityStateFromInspection } from "./conductor/readiness-prerequisites.js";
|
|
161
|
+
import { DuplicateRegistrationError } from "./init.js";
|
|
162
|
+
import { DUPLICATE_REGISTRATION_GUIDANCE } from "./launcher-config-inspection.js";
|
|
161
163
|
import os from "node:os";
|
|
162
164
|
import path from "node:path";
|
|
163
165
|
import { readFile as readFileAsync, stat as statAsync } from "node:fs/promises";
|
|
@@ -165,7 +167,6 @@ import { bindEpicLaunchCredential, readStoredBinding, } from "./credential-store
|
|
|
165
167
|
import { EPIC_LAUNCH_EXECUTION_MODES, EPIC_LAUNCH_PROFILE_NAME_PATTERN, EPIC_LAUNCH_PROFILE_VERSION, createNodeEpicLaunchStoreDeps, readEpicLaunchProfile, renderEpicLaunchCommand, resolveEpicLaunchTarget, shellQuote, writeEpicLaunchProfile, } from "./epic-launch-profile.js";
|
|
166
168
|
import { DEFAULT_BAPI_BASE_URL } from "./executor/credentials.js";
|
|
167
169
|
import { MCP_PACKAGE_NAME } from "./mcp-identity.js";
|
|
168
|
-
import { LOCAL_MERGE_CREDENTIAL_ENV_KEYS } from "./conductor/merge-credential.js";
|
|
169
170
|
import { CLAUDE_REVIEW_WORKFLOW_RELPATH, renderClaudeReviewWorkflow, } from "./claude-review-workflow.js";
|
|
170
171
|
import { formatExecutorInstallPreflight, } from "./executor/install-preflight.js";
|
|
171
172
|
import { buildExecutorServiceStartPlan, formatExecutorServiceStartFailure, } from "./executor/service-lifecycle.js";
|
|
@@ -328,10 +329,11 @@ export function getInstallBridgeConductorUsage() {
|
|
|
328
329
|
"",
|
|
329
330
|
` --review-policy <source> One of: ${CONDUCTOR_REVIEW_POLICY_SOURCES.join(", ")}`,
|
|
330
331
|
" Omitted, setup keeps a project default that is already",
|
|
331
|
-
" stored. With none stored it stores verdict_protocol
|
|
332
|
-
" .github/workflows/claude-review.yml
|
|
333
|
-
" branch,
|
|
334
|
-
"
|
|
332
|
+
" stored. With none stored it stores verdict_protocol only",
|
|
333
|
+
" when Bridge read .github/workflows/claude-review.yml on",
|
|
334
|
+
" your default branch, the file exists, and it emits both the",
|
|
335
|
+
" run-id: and Reviewed-SHA: markers. Otherwise it stores",
|
|
336
|
+
" repository_policy. It scaffolds no Claude review workflow unless you",
|
|
335
337
|
" pass --review-policy verdict_protocol. Supplying any value",
|
|
336
338
|
" persists it as the project default, stamped into a new",
|
|
337
339
|
" run that carries no review policy of its own.",
|
|
@@ -382,18 +384,14 @@ export function getInstallBridgeConductorUsage() {
|
|
|
382
384
|
"setup then applies the previewed bootstrap policy. Without a TTY it shows",
|
|
383
385
|
"the preview and writes no policy.",
|
|
384
386
|
"",
|
|
385
|
-
"Tool visibility (its own consent):
|
|
386
|
-
"BRIDGE_MCP_PROFILE of the Bridge entry in
|
|
387
|
-
"ALREADY have one (.mcp.json, .vscode/mcp.json, and
|
|
388
|
-
"file is ever created
|
|
389
|
-
"says so and points at the base `install` command.
|
|
390
|
-
"see the Epic Implementer tools.",
|
|
387
|
+
"Tool visibility (its own consent): an approved, additive merge of the",
|
|
388
|
+
"`epic_implementer` token into the BRIDGE_MCP_PROFILE of the Bridge entry in",
|
|
389
|
+
"host MCP configurations that ALREADY have one (.mcp.json, .vscode/mcp.json, and",
|
|
390
|
+
".cursor/mcp.json only). No file is ever created, and a missing entry is not a",
|
|
391
|
+
"blocker: the run says so and points at the base `install` command. After a",
|
|
392
|
+
"write, restart your MCP client to see the Epic Implementer tools.",
|
|
391
393
|
"",
|
|
392
|
-
"
|
|
393
|
-
"managed Git hooks (post-commit, reference-transaction) and reports each hook's",
|
|
394
|
-
"action. It then probes native ledger loadability, which is READ-ONLY; a degraded",
|
|
395
|
-
"ledger reports the module, NODE_MODULE_VERSION, and failure kind, and never",
|
|
396
|
-
"triggers an install, rebuild, or migration.",
|
|
394
|
+
"Optional Git hooks are installed separately: run `epic-implementer install-git-hooks`.",
|
|
397
395
|
"",
|
|
398
396
|
`See ${CONDUCTOR_OPERATOR_RUNBOOK_POINTER}.`,
|
|
399
397
|
].join("\n");
|
|
@@ -1074,55 +1072,6 @@ async function confirm(deps, promptText) {
|
|
|
1074
1072
|
const decision = await askSetupQuestion(setupConsentQuestion(promptText), { read: deps.promptLine, write: deps.log });
|
|
1075
1073
|
return decision.status === "accept";
|
|
1076
1074
|
}
|
|
1077
|
-
/**
|
|
1078
|
-
* BAPI-1452 — the merge-credential next step. Value-free configuration guidance
|
|
1079
|
-
* only: it names the configuration keys and never reads, writes, migrates, or
|
|
1080
|
-
* asks for a credential value. `GITHUB_MERGE_TOKEN` is the local merge
|
|
1081
|
-
* credential; the machine-user credential is a distinct key, not an alias.
|
|
1082
|
-
*/
|
|
1083
|
-
export const MERGE_CREDENTIAL_INSTALL_GUIDANCE = `set ${LOCAL_MERGE_CREDENTIAL_ENV_KEYS.local} (the local merge credential) in the environment the ` +
|
|
1084
|
-
`executor is launched from, or ${LOCAL_MERGE_CREDENTIAL_ENV_KEYS.machine_token} for machine-user ` +
|
|
1085
|
-
"mode; Bridge never stores either.";
|
|
1086
|
-
function renderCapabilityMatrix(deps, readiness) {
|
|
1087
|
-
const apiReady = readiness !== null;
|
|
1088
|
-
// BAPI-1391 — a CONFIRMED local-only or `none` gate has no CI checks by
|
|
1089
|
-
// design: its gate is the profile (executor-run commands, or approval for
|
|
1090
|
-
// every merge), so an empty CI list is not "unconfigured" there. Read from
|
|
1091
|
-
// the server's own confirmed-profile state; an older server reports no
|
|
1092
|
-
// `gate_profile` block and keeps the original rule exactly.
|
|
1093
|
-
const gateProfile = readiness?.gate_profile ?? null;
|
|
1094
|
-
const confirmedCiFreeGate = gateProfile !== null &&
|
|
1095
|
-
gateProfile.confirmed === true &&
|
|
1096
|
-
(gateProfile.kind === "local" || gateProfile.kind === "none");
|
|
1097
|
-
// Derived from READINESS, never from the bootstrap's HTTP status: a 200 proves
|
|
1098
|
-
// the write was accepted, not that the resulting posture is safe.
|
|
1099
|
-
const configurationReady = readiness !== null &&
|
|
1100
|
-
readiness.supervisor.setup_present &&
|
|
1101
|
-
readiness.supervisor.config_present &&
|
|
1102
|
-
(!readiness.supervisor.required_checks_empty || confirmedCiFreeGate);
|
|
1103
|
-
// `ready === null` (never provisioned) and `false` (stale) are both "not ready"
|
|
1104
|
-
// here, but only a recent server-observed claim/heartbeat counts as ready — a
|
|
1105
|
-
// configured command or a local process does not.
|
|
1106
|
-
const executorReady = readiness?.executor.ready === true;
|
|
1107
|
-
deps.log("");
|
|
1108
|
-
deps.log("Capability matrix");
|
|
1109
|
-
deps.log("─────────────────");
|
|
1110
|
-
deps.log(` api_ready: ${apiReady}`);
|
|
1111
|
-
deps.log(` configuration_ready: ${configurationReady}`);
|
|
1112
|
-
deps.log(` executor_ready: ${executorReady}`);
|
|
1113
|
-
if (gateProfile !== null) {
|
|
1114
|
-
// Names nothing: the kind, provenance, revision, and qualification state only.
|
|
1115
|
-
deps.log(` repository gate: ${gateProfile.confirmed ? (gateProfile.kind ?? "unknown") : "not confirmed"}` +
|
|
1116
|
-
(gateProfile.confirmed ? ` (${gateProfile.source}, revision ${gateProfile.revision}` +
|
|
1117
|
-
(gateProfile.qualification_state && gateProfile.qualification_state !== "not_required"
|
|
1118
|
-
? `, local gate ${gateProfile.qualification_state})`
|
|
1119
|
-
: ")") : ""));
|
|
1120
|
-
}
|
|
1121
|
-
deps.log(` executor provisioning: ${EXECUTOR_PROVISIONING_GUIDANCE}`);
|
|
1122
|
-
deps.log(` merge credential: ${MERGE_CREDENTIAL_INSTALL_GUIDANCE}`);
|
|
1123
|
-
deps.log(` runbook: ${CONDUCTOR_OPERATOR_RUNBOOK_POINTER}`);
|
|
1124
|
-
return { apiReady, configurationReady, executorReady };
|
|
1125
|
-
}
|
|
1126
1075
|
/**
|
|
1127
1076
|
* Build both plans, or explain why the host cannot be provisioned.
|
|
1128
1077
|
*
|
|
@@ -1335,7 +1284,7 @@ async function runExecutorProvisioningPhase(deps, executor, plans, access) {
|
|
|
1335
1284
|
return null;
|
|
1336
1285
|
}
|
|
1337
1286
|
// ---------------------------------------------------------------------------
|
|
1338
|
-
// Local
|
|
1287
|
+
// Local host configuration: tool visibility (BAPI-775, narrowed by BAPI-1721)
|
|
1339
1288
|
// ---------------------------------------------------------------------------
|
|
1340
1289
|
/**
|
|
1341
1290
|
* The exact restart advisory the SFCC profile merge prints (`index.ts`), reused
|
|
@@ -1353,242 +1302,106 @@ export function formatConductorRestartAdvisory(mergedProfile) {
|
|
|
1353
1302
|
"at startup, so this activates on the next MCP server launch — restart your MCP " +
|
|
1354
1303
|
"client to gain access to the Epic Implementer tools.");
|
|
1355
1304
|
}
|
|
1356
|
-
/** Remediation printed when no supported host config carries a Bridge entry. */
|
|
1357
|
-
export const CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION = `run \`${PRINTED_INSTALL_COMMAND}\` to create and register the host MCP entry, ` +
|
|
1358
|
-
"then re-run `install epic-implementer`.";
|
|
1359
|
-
/** Remediation printed whenever the managed git hooks were not installed. */
|
|
1360
|
-
export const CONDUCTOR_HOOKS_MANUAL_REMEDIATION = "re-run `install epic-implementer` and accept the local-observability consent, or run " +
|
|
1361
|
-
"`epic-implementer install-git-hooks` directly.";
|
|
1362
1305
|
/**
|
|
1363
|
-
* Remediation
|
|
1364
|
-
*
|
|
1306
|
+
* Remediation printed when no supported host config carries a Bridge entry.
|
|
1307
|
+
* Owned by `printed-remedy-commands.ts` since BAPI-1719; re-exported for compatibility.
|
|
1365
1308
|
*/
|
|
1366
|
-
export
|
|
1367
|
-
"`epic-implementer install-git-hooks` (or re-run `install epic-implementer` and accept the " +
|
|
1368
|
-
"local-observability consent).";
|
|
1309
|
+
export { CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION };
|
|
1369
1310
|
/**
|
|
1370
|
-
*
|
|
1371
|
-
*
|
|
1372
|
-
* Adds the `epic_implementer` token to EXISTING supported host MCP entries behind its
|
|
1373
|
-
* own consent, then prints the restart advisory. It never creates a host config
|
|
1374
|
-
* — the merge helper's never-create rule is what keeps a declined or
|
|
1375
|
-
* unconfigured repository from acquiring files it did not ask for.
|
|
1311
|
+
* The plain restart line the converging setup prints once after a confirmed write
|
|
1312
|
+
* (BAPI-1719), and the advisory its structured result carries.
|
|
1376
1313
|
*/
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
"tool visibility: re-run `install epic-implementer` and accept the profile consent to " +
|
|
1385
|
-
"make the Epic Implementer MCP tools visible.",
|
|
1386
|
-
],
|
|
1387
|
-
};
|
|
1388
|
-
}
|
|
1389
|
-
let mergedProfile;
|
|
1390
|
-
try {
|
|
1391
|
-
mergedProfile = await local.mergeProfileToken();
|
|
1392
|
-
}
|
|
1393
|
-
catch {
|
|
1394
|
-
// The thrown value is discarded: it can carry an absolute config path.
|
|
1395
|
-
deps.errorLog(" the host MCP profile could not be updated.");
|
|
1396
|
-
return { manualActions: [], fatal: true };
|
|
1397
|
-
}
|
|
1398
|
-
if (mergedProfile === "") {
|
|
1399
|
-
deps.log(" no supported host MCP configuration carries a Bridge entry, so nothing " +
|
|
1400
|
-
"was written (this command never creates one).");
|
|
1401
|
-
return {
|
|
1402
|
-
manualActions: [
|
|
1403
|
-
`tool visibility: ${CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION}`,
|
|
1404
|
-
],
|
|
1405
|
-
};
|
|
1406
|
-
}
|
|
1407
|
-
// Which configs actually carry the token now. Derived from the READ-ONLY
|
|
1408
|
-
// inspector rather than guessed from the merged profile string, which says
|
|
1409
|
-
// nothing about which files it came from.
|
|
1410
|
-
let carrying = [];
|
|
1411
|
-
try {
|
|
1412
|
-
const inspection = await local.inspectProfileToken();
|
|
1413
|
-
carrying = inspection.configs
|
|
1414
|
-
.filter((c) => c.state === "token-present")
|
|
1415
|
-
.map((c) => c.path);
|
|
1416
|
-
}
|
|
1417
|
-
catch {
|
|
1418
|
-
// A failed read-back is not a failed merge. The advisory below still prints.
|
|
1419
|
-
}
|
|
1420
|
-
deps.log(carrying.length > 0
|
|
1421
|
-
? ` updated: ${carrying.join(", ")}`
|
|
1422
|
-
: " the Epic Implementer profile was merged into your supported host MCP config(s).");
|
|
1423
|
-
// Coverage honesty: the merge path writes these three files and no others.
|
|
1424
|
-
deps.log(" Codex and Copilot host configuration was NOT inspected or changed.");
|
|
1425
|
-
deps.log(` ${formatConductorRestartAdvisory(mergedProfile)}`);
|
|
1426
|
-
const recorded = await local.recordCapability("conductor_tool_visibility");
|
|
1427
|
-
if (!recorded.ok) {
|
|
1428
|
-
// Advisory: install state is a diagnostic aid. A recording failure does not
|
|
1429
|
-
// invalidate the host-config change that just landed.
|
|
1430
|
-
deps.errorLog(` note: install-state not updated (${recorded.error ?? "unknown"})`);
|
|
1431
|
-
}
|
|
1432
|
-
return { manualActions: [] };
|
|
1433
|
-
}
|
|
1314
|
+
export const TOOL_VISIBILITY_RESTART_LINE = "Restart your MCP client so this session can see the Epic Implementer tools.";
|
|
1315
|
+
/** Fixed, secret-free wording for the closed failure cases. Never an exception message. */
|
|
1316
|
+
const TOOL_VISIBILITY_FAILURE_TEXT = Object.freeze({
|
|
1317
|
+
inspection: "the MCP configuration could not be inspected",
|
|
1318
|
+
write: "the host MCP profile could not be updated",
|
|
1319
|
+
duplicate: "a config registers Bridge under two names, so nothing was changed",
|
|
1320
|
+
});
|
|
1434
1321
|
/**
|
|
1435
|
-
*
|
|
1322
|
+
* Add the `epic_implementer` group to the EXISTING project-local Bridge MCP entries.
|
|
1436
1323
|
*
|
|
1437
|
-
*
|
|
1438
|
-
*
|
|
1439
|
-
*
|
|
1440
|
-
*
|
|
1324
|
+
* CONSENT BELONGS TO THE CALLER: this function never asks. It modifies only entries
|
|
1325
|
+
* that already exist (the writer never creates a file, directory, or registration),
|
|
1326
|
+
* and it writes only through `local.mergeProfileToken()`.
|
|
1327
|
+
*
|
|
1328
|
+
* Mutation success is decoupled from what follows it: once the writer returns a
|
|
1329
|
+
* non-empty profile the outcome is `written`, whatever the read-back or the
|
|
1330
|
+
* capability record later report. `deps` is accepted for signature symmetry with the
|
|
1331
|
+
* other setup operations; the helper itself prints nothing.
|
|
1441
1332
|
*/
|
|
1442
|
-
async function
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
"
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
let result = null;
|
|
1333
|
+
export async function applyToolVisibility(deps, local, options = {}) {
|
|
1334
|
+
void deps;
|
|
1335
|
+
const base = {
|
|
1336
|
+
outcome: "failed", changedPaths: [], mergedProfile: "", carryingPaths: [],
|
|
1337
|
+
verification: "not_run", guidance: [], advisories: [], notes: [], failurePaths: [],
|
|
1338
|
+
};
|
|
1339
|
+
let changedPaths = [];
|
|
1340
|
+
if (options.freshInspection !== false) {
|
|
1341
|
+
// Fresh evidence only: nothing from the earlier assessment is reused.
|
|
1342
|
+
let pre;
|
|
1453
1343
|
try {
|
|
1454
|
-
|
|
1344
|
+
pre = await local.inspectProfileToken();
|
|
1455
1345
|
}
|
|
1456
1346
|
catch {
|
|
1457
|
-
|
|
1458
|
-
// The phase is marked fatal but does NOT return here — the read-only
|
|
1459
|
-
// ledger report below still owes the operator its answer.
|
|
1460
|
-
deps.errorLog(" the Epic Implementer Git hooks could not be installed.");
|
|
1461
|
-
manualActions.push(`local observability: ${CONDUCTOR_HOOKS_MANUAL_REMEDIATION}`);
|
|
1462
|
-
fatal = true;
|
|
1347
|
+
return { ...base, failure: TOOL_VISIBILITY_FAILURE_TEXT.inspection, guidance: ["re-run setup once the MCP configuration is readable"] };
|
|
1463
1348
|
}
|
|
1464
|
-
if (
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
// BAPI-1290: the refusal names its fixed classification (e.g.
|
|
1470
|
-
// `ephemeral-cache` for an npx-cache runtime) or its per-hook planning
|
|
1471
|
-
// reasons. It is an OPTIONAL-hook installation refusal — distinct from a
|
|
1472
|
-
// setup-permission stop and from engine admission, which it never gates.
|
|
1473
|
-
deps.errorLog(result.error === CONDUCTOR_BIN_UNRESOLVED_ERROR
|
|
1474
|
-
? ` hook installation refused (${result.classification}) — ${result.reason}`
|
|
1475
|
-
: ` hook installation refused — ${result.reason}`);
|
|
1476
|
-
deps.errorLog(" existing hooks were left unchanged; optional local hook delivery is unavailable " +
|
|
1477
|
-
"(engine admission is unaffected).");
|
|
1478
|
-
// Only BAPI-772's broken-package case stays fatal: the executing artifact
|
|
1479
|
-
// ships no hook binary at all. Every other refusal — an npx-cache runtime
|
|
1480
|
-
// (the documented `npx … install epic-implementer` path), an unqualified or
|
|
1481
|
-
// unloadable runtime, an unsafe existing hook — is a manual action, and
|
|
1482
|
-
// the installer continues to setup-epic verification and executor
|
|
1483
|
-
// provisioning. Optional hooks must never stop the phases that do gate
|
|
1484
|
-
// a run.
|
|
1485
|
-
// A refusal without a classification (an older or injected result shape)
|
|
1486
|
-
// is read as `missing` — fail-closed to BAPI-772's fatal contract.
|
|
1487
|
-
const brokenPackage = result.error === CONDUCTOR_BIN_UNRESOLVED_ERROR &&
|
|
1488
|
-
(result.classification ?? "missing") === "missing";
|
|
1489
|
-
if (brokenPackage) {
|
|
1490
|
-
manualActions.push(`local observability: ${CONDUCTOR_HOOKS_MANUAL_REMEDIATION}`);
|
|
1491
|
-
fatal = true;
|
|
1492
|
-
}
|
|
1493
|
-
else {
|
|
1494
|
-
manualActions.push(`local observability: ${CONDUCTOR_HOOKS_DURABLE_REMEDIATION}`);
|
|
1349
|
+
if (!profileMergeNeededFrom(pre)) {
|
|
1350
|
+
if (pre.bridgeEntryPresent)
|
|
1351
|
+
return { ...base, outcome: "unchanged" };
|
|
1352
|
+
if (pre.configs.some((c) => c.state === "unreadable")) {
|
|
1353
|
+
return { ...base, failure: TOOL_VISIBILITY_FAILURE_TEXT.inspection, guidance: ["re-run setup once the MCP configuration is readable"] };
|
|
1495
1354
|
}
|
|
1355
|
+
return { ...base, outcome: "no_entry", guidance: [CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION] };
|
|
1496
1356
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
if (result.partial) {
|
|
1514
|
-
deps.log(" the hook update is PARTIAL — one managed hook was published and the other was not.");
|
|
1515
|
-
}
|
|
1516
|
-
// Sanitized: the installer's own warnings are secret-free sentences, and
|
|
1517
|
-
// hook CONTENT, env, and caught errors are never rendered.
|
|
1518
|
-
for (const warning of result.warnings)
|
|
1519
|
-
deps.log(` warning: ${warning}`);
|
|
1520
|
-
// Completeness is checked against the managed-hook ROSTER, not against
|
|
1521
|
-
// "at least one hook was installed": a partial install that wrote only
|
|
1522
|
-
// post-commit and warned about nothing would otherwise be recorded as
|
|
1523
|
-
// provisioned observability, and the missing reference-transaction hook
|
|
1524
|
-
// is precisely the one that stops half the events from ever being
|
|
1525
|
-
// emitted.
|
|
1526
|
-
//
|
|
1527
|
-
// BAPI-1290: each hook's `usable` is the installer's shared verdict —
|
|
1528
|
-
// published over a matching snapshot, executable, and backed by the
|
|
1529
|
-
// qualified persistent runtime — and the installer's own `complete`
|
|
1530
|
-
// flag must agree. Anything less is not recorded.
|
|
1531
|
-
const usable = (name) => {
|
|
1532
|
-
const hook = result.installed.find((h) => h.name === name);
|
|
1533
|
-
return (hook !== undefined &&
|
|
1534
|
-
hook.usable === true &&
|
|
1535
|
-
hook.action !== "skipped" &&
|
|
1536
|
-
hook.warning === undefined);
|
|
1537
|
-
};
|
|
1538
|
-
const complete = result.complete === true &&
|
|
1539
|
-
MANAGED_HOOK_NAMES.every((name) => usable(name)) &&
|
|
1540
|
-
result.warnings.length === 0;
|
|
1541
|
-
if (complete) {
|
|
1542
|
-
const recorded = await local.recordCapability("conductor_local_observability");
|
|
1543
|
-
if (!recorded.ok) {
|
|
1544
|
-
deps.errorLog(` note: install-state not updated (${recorded.error ?? "unknown"})`);
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
else {
|
|
1548
|
-
// A skipped or warned hook is NOT provisioned local observability, and
|
|
1549
|
-
// recording the capability here would make install state claim
|
|
1550
|
-
// something a `epic-implementer doctor` run would immediately contradict.
|
|
1551
|
-
deps.log(" the managed hooks are not fully usable, so local observability was not recorded.");
|
|
1552
|
-
manualActions.push(`local observability: ${CONDUCTOR_HOOKS_MANUAL_REMEDIATION}`);
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1357
|
+
changedPaths = pre.configs.filter((c) => c.state === "token-absent").map((c) => c.path);
|
|
1358
|
+
}
|
|
1359
|
+
let merged;
|
|
1360
|
+
try {
|
|
1361
|
+
merged = await local.mergeProfileToken();
|
|
1362
|
+
}
|
|
1363
|
+
catch (error) {
|
|
1364
|
+
// The thrown value is discarded except for a duplicate's fixed config paths:
|
|
1365
|
+
// any other message can carry an absolute path or an environment value.
|
|
1366
|
+
if (error instanceof DuplicateRegistrationError) {
|
|
1367
|
+
return {
|
|
1368
|
+
...base,
|
|
1369
|
+
failure: TOOL_VISIBILITY_FAILURE_TEXT.duplicate,
|
|
1370
|
+
failurePaths: [...error.relPaths],
|
|
1371
|
+
guidance: [DUPLICATE_REGISTRATION_GUIDANCE],
|
|
1372
|
+
};
|
|
1555
1373
|
}
|
|
1374
|
+
return { ...base, failure: TOOL_VISIBILITY_FAILURE_TEXT.write };
|
|
1556
1375
|
}
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
//
|
|
1561
|
-
|
|
1562
|
-
let inspection = null;
|
|
1376
|
+
if (merged === "") {
|
|
1377
|
+
return { ...base, outcome: "no_entry", guidance: [CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION] };
|
|
1378
|
+
}
|
|
1379
|
+
// The write is confirmed. Nothing below can turn it into a failure.
|
|
1380
|
+
const result = { ...base, outcome: "written", changedPaths, mergedProfile: merged, advisories: [TOOL_VISIBILITY_RESTART_LINE] };
|
|
1563
1381
|
try {
|
|
1564
|
-
|
|
1382
|
+
// Which configs carry the group now: the READ-ONLY inspector, not a guess from the merged string.
|
|
1383
|
+
const post = await local.inspectProfileToken();
|
|
1384
|
+
result.carryingPaths = post.configs.filter((c) => c.state === "token-present").map((c) => c.path);
|
|
1385
|
+
result.verification = profileMergeNeededFrom(post) ? "unknown" : "confirmed";
|
|
1565
1386
|
}
|
|
1566
1387
|
catch {
|
|
1567
|
-
|
|
1388
|
+
result.verification = "unknown";
|
|
1568
1389
|
}
|
|
1569
|
-
if (
|
|
1570
|
-
|
|
1390
|
+
if (result.verification === "unknown") {
|
|
1391
|
+
result.guidance.push("the write could not be confirmed by reading the configuration back; run `epic-implementer doctor` after restarting your MCP client");
|
|
1571
1392
|
}
|
|
1572
|
-
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
// Never fatal, and never an install/rebuild/migration attempt: the module,
|
|
1579
|
-
// ABI, and sanitized failure kind are what make an npm optional-dependency
|
|
1580
|
-
// build skip diagnosable.
|
|
1581
|
-
deps.log(` ledger degraded — ${availability.module} did not load ` +
|
|
1582
|
-
`(NODE_MODULE_VERSION ${availability.nodeModulesAbi}, failure: ${availability.failureKind}).`);
|
|
1583
|
-
manualActions.push(`local observability: reinstall ${availability.module} for this Node runtime to ` +
|
|
1584
|
-
"restore the local Epic Implementer event ledger.");
|
|
1585
|
-
}
|
|
1393
|
+
try {
|
|
1394
|
+
const recorded = await local.recordCapability("conductor_tool_visibility");
|
|
1395
|
+
// Advisory: install state is a diagnostic aid. A recording failure does not
|
|
1396
|
+
// invalidate the host-config change that just landed.
|
|
1397
|
+
if (!recorded.ok)
|
|
1398
|
+
result.notes.push(`install-state not updated (${recorded.error ?? "unknown"})`);
|
|
1586
1399
|
}
|
|
1587
|
-
|
|
1400
|
+
catch {
|
|
1401
|
+
result.notes.push("install-state not updated (unknown)");
|
|
1402
|
+
}
|
|
1403
|
+
return result;
|
|
1588
1404
|
}
|
|
1589
|
-
/**
|
|
1590
|
-
* Run the nested conductor installer. Returns the process exit code.
|
|
1591
|
-
*/
|
|
1592
1405
|
// ---------------------------------------------------------------------------
|
|
1593
1406
|
// Epic launch profile phase (BAPI-1260)
|
|
1594
1407
|
// ---------------------------------------------------------------------------
|
|
@@ -2010,43 +1823,34 @@ async function runStandaloneGateAction(options, deps, gateIo, access, accessErro
|
|
|
2010
1823
|
: runQualifyConductorGate(gateIo, access, deps.gate, { dryRun: options.dryRun, baseUrl });
|
|
2011
1824
|
}
|
|
2012
1825
|
/**
|
|
2013
|
-
* Explain the review policy
|
|
2014
|
-
*
|
|
2015
|
-
* without one (a caller with no setup seams) it keeps the original install text.
|
|
1826
|
+
* Explain the review policy the converging setup resolved: whether the source is
|
|
1827
|
+
* explicit, preserved, or inferred from the remote default branch.
|
|
2016
1828
|
*/
|
|
2017
1829
|
function renderReviewPolicy(deps, options, decision) {
|
|
2018
1830
|
deps.log("");
|
|
2019
|
-
if (decision
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
:
|
|
2033
|
-
|
|
2034
|
-
|
|
1831
|
+
if (decision.kind === "preserve") {
|
|
1832
|
+
deps.log(decision.basis === "stored"
|
|
1833
|
+
? `Review policy: kept as the project default already stored (${terminalSafeText(decision.stored ?? "unrecognized")}). ` +
|
|
1834
|
+
"Pass --review-policy to change it."
|
|
1835
|
+
: "Review policy: Bridge could not read the stored review settings, so it leaves them as they are this time.");
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
deps.log(`Review policy: ${decision.source}`);
|
|
1839
|
+
deps.log(decision.basis === "explicit"
|
|
1840
|
+
? " Explicitly selected with --review-policy, so it is ALSO persisted as the supervisor project " +
|
|
1841
|
+
"default and stamped into a new run that sets no review policy of its own. An explicit per-run " +
|
|
1842
|
+
"policy always wins, and changing this later never alters an already-approved run."
|
|
1843
|
+
: decision.basis === "workflow_present"
|
|
1844
|
+
? ` Inferred: ${CLAUDE_REVIEW_WORKFLOW_RELPATH} exists on your default branch and emits both the run-id: and ` +
|
|
1845
|
+
"Reviewed-SHA: markers. It is stored as the project default, and a stored default is never overwritten by a later run. " +
|
|
1846
|
+
"Pass --review-policy to choose another."
|
|
1847
|
+
: decision.basis === "workflow_without_markers"
|
|
1848
|
+
? ` Inferred: ${CLAUDE_REVIEW_WORKFLOW_RELPATH} exists on your default branch but does not emit both the run-id: ` +
|
|
1849
|
+
"and Reviewed-SHA: markers that verdict_protocol needs, so repository_policy was stored as the project default. " +
|
|
1850
|
+
"Pass --review-policy verdict_protocol to opt in; setup then offers to write the workflow."
|
|
2035
1851
|
: ` Inferred: no ${CLAUDE_REVIEW_WORKFLOW_RELPATH} was found on your default branch, so no Claude review ` +
|
|
2036
1852
|
"workflow is needed. It is stored as the project default, and a stored default is never overwritten by a " +
|
|
2037
1853
|
"later run. Pass --review-policy verdict_protocol to opt in to AI review.");
|
|
2038
|
-
return;
|
|
2039
|
-
}
|
|
2040
|
-
deps.log(`Review policy: ${options.reviewPolicy}`);
|
|
2041
|
-
deps.log(options.reviewPolicyExplicit
|
|
2042
|
-
? " Explicitly selected, so it is ALSO persisted as the supervisor project " +
|
|
2043
|
-
"default and stamped into a new run that sets no review policy of its own. " +
|
|
2044
|
-
"An explicit per-run policy always wins, and changing this later never " +
|
|
2045
|
-
"alters an already-approved run."
|
|
2046
|
-
: " Install assumption only: no repository default is persisted and no " +
|
|
2047
|
-
"Claude review workflow is scaffolded. A new feature-branch run receives " +
|
|
2048
|
-
"repository_policy at first approval when nothing else sets one — pass " +
|
|
2049
|
-
"--review-policy verdict_protocol to opt in to AI review.");
|
|
2050
1854
|
}
|
|
2051
1855
|
/** A stored value printed on one line: control characters and over-long text never reach the terminal. */
|
|
2052
1856
|
function terminalSafeText(value) {
|
|
@@ -2236,423 +2040,7 @@ async function runInstallBridgeConductorCore(argv, deps) {
|
|
|
2236
2040
|
return 1;
|
|
2237
2041
|
}
|
|
2238
2042
|
const options = parsed.options;
|
|
2239
|
-
|
|
2240
|
-
// check → fix → check → verdict runner. A caller without them keeps the
|
|
2241
|
-
// original phase sequence below, unchanged.
|
|
2242
|
-
if (deps.setup !== undefined) {
|
|
2243
|
-
return runConvergingSetup(options, deps, deps.setup);
|
|
2244
|
-
}
|
|
2245
|
-
if (options.removeMergeToken === true) {
|
|
2246
|
-
deps.errorLog("Error: --remove-merge-token is unavailable here: this caller supplied no credential-store seams.");
|
|
2247
|
-
return 1;
|
|
2248
|
-
}
|
|
2249
|
-
if (options.testCommand !== undefined) {
|
|
2250
|
-
// Accepting the flag and running an implementation that ignores it would
|
|
2251
|
-
// report success for a command that was never saved.
|
|
2252
|
-
deps.errorLog("Error: --test-command is unavailable here: this caller supplied no test-command seams.");
|
|
2253
|
-
return 1;
|
|
2254
|
-
}
|
|
2255
|
-
const confirmed = await resolveAndConfirmBaseUrl(options, deps, "Bootstrap against this URL? [y/N]: ");
|
|
2256
|
-
if (!confirmed.ok)
|
|
2257
|
-
return confirmed.code;
|
|
2258
|
-
const baseUrl = confirmed.baseUrl;
|
|
2259
|
-
if (!options.dryRun && !(await assessEpicInstallerPrerequisites(deps, Boolean(options.executorId))).available)
|
|
2260
|
-
return 1;
|
|
2261
|
-
const accessResult = await deps.resolveAccess(options.repo, baseUrl);
|
|
2262
|
-
const access = accessResult.ok ? accessResult.access : null;
|
|
2263
|
-
const accessError = accessResult.ok ? undefined : accessResult.error;
|
|
2264
|
-
const earlyPreflight = await runExecutorPreflightPhase(options, deps, baseUrl, access);
|
|
2265
|
-
if (earlyPreflight.kind === "refused")
|
|
2266
|
-
return 1;
|
|
2267
|
-
const gateIo = gateIoFor(deps);
|
|
2268
|
-
const standalone = await runStandaloneGateAction(options, deps, gateIo, access, accessError, baseUrl);
|
|
2269
|
-
if (standalone !== null)
|
|
2270
|
-
return standalone;
|
|
2271
|
-
// ---- Phase 1: unified doctor, BEFORE every write -----------------------
|
|
2272
|
-
deps.log("Phase 1/8 — running the unified epic-implementer doctor (read-only)…");
|
|
2273
|
-
const firstReport = await deps.runDoctor({
|
|
2274
|
-
access,
|
|
2275
|
-
accessError,
|
|
2276
|
-
reviewPolicySource: options.reviewPolicy,
|
|
2277
|
-
assessmentVersion: 1,
|
|
2278
|
-
epicRunId: options.assessmentEpicRunId,
|
|
2279
|
-
});
|
|
2280
|
-
deps.log(formatConductorInstallDoctorReport(firstReport));
|
|
2281
|
-
if (conductorInstallDoctorHasFatal(firstReport)) {
|
|
2282
|
-
deps.errorLog("");
|
|
2283
|
-
deps.errorLog("Fatal prerequisite(s) above. Aborting before any write — no bootstrap, workflow, " +
|
|
2284
|
-
"install-state, or verification step was attempted.");
|
|
2285
|
-
return 1;
|
|
2286
|
-
}
|
|
2287
|
-
// ---- Review policy: per-run, and a repository default when explicit ----
|
|
2288
|
-
renderReviewPolicy(deps, options);
|
|
2289
|
-
// ---- Executor preflight: AFTER the URL consent, BEFORE any mutation ----
|
|
2290
|
-
// Placed here so an unsupported host or a missing `wt`/`git`/`claude` refuses
|
|
2291
|
-
// before the bootstrap POST, the workflow write, or a single filesystem
|
|
2292
|
-
// effect — provisioning a service that cannot run is worse than refusing —
|
|
2293
|
-
// and before the dry-run return, so `--dry-run` reports the same refusal.
|
|
2294
|
-
const executor = deps.executorProvisioning;
|
|
2295
|
-
const local = deps.localProvisioning;
|
|
2296
|
-
const executorPlans = earlyPreflight.plans;
|
|
2297
|
-
// ---- BAPI-1391: the repository gate, decided BEFORE any write ----------
|
|
2298
|
-
// Capability probe first (a read, after the base-URL consent), then the stored
|
|
2299
|
-
// gate, explicit gate flags, or a discovery proposal the owner confirms. Under
|
|
2300
|
-
// --dry-run it only shows the decision: no PUT, no enqueue, no gate prompt.
|
|
2301
|
-
if (!access) {
|
|
2302
|
-
deps.errorLog("Bridge API access could not be resolved; aborting before any write.");
|
|
2303
|
-
return 1;
|
|
2304
|
-
}
|
|
2305
|
-
const gatePhase = await resolveConductorGate(gateIo, access, options.gate, deps.gate, {
|
|
2306
|
-
dryRun: options.dryRun, planningOnly: true,
|
|
2307
|
-
});
|
|
2308
|
-
if (gatePhase.kind === "exit")
|
|
2309
|
-
return gatePhase.code;
|
|
2310
|
-
const gatePlan = gatePhase.kind === "plan" ? gatePhase.plan : null;
|
|
2311
|
-
// The bootstrap's CI list is the gate's provider leg. A local-only or `none`
|
|
2312
|
-
// gate sends an empty list, which the server accepts only for a stored gate
|
|
2313
|
-
// of that kind.
|
|
2314
|
-
const bootstrapChecks = gatePlan?.desired.providerChecks ?? options.requiredChecks;
|
|
2315
|
-
// ---- Dry run: preview and RETURN before every write/prompt -------------
|
|
2316
|
-
if (options.dryRun) {
|
|
2317
|
-
deps.log("");
|
|
2318
|
-
deps.log("Dry run — no writes will be performed.");
|
|
2319
|
-
if (gatePlan !== null)
|
|
2320
|
-
await fixGateAndDefaults(deps, options, access, gatePlan, legacyReviewDefault(options));
|
|
2321
|
-
if (gatePlan === null) {
|
|
2322
|
-
deps.log(" Repository gate: none confirmed — a real run asks you to confirm one before any write.");
|
|
2323
|
-
}
|
|
2324
|
-
else if (gatePlan.write !== null) {
|
|
2325
|
-
// Field NAMES and counts only, as below.
|
|
2326
|
-
deps.log(` Would PUT /jira/epic-runs/supervisor-setup/gate-profile/ (confirm, expected revision ` +
|
|
2327
|
-
`${gatePlan.write.expected_revision}) with field NAMES: kind, ` +
|
|
2328
|
-
`provider_checks (${gatePlan.desired.providerChecks.length}), ` +
|
|
2329
|
-
`local_commands (${gatePlan.desired.localCommands.length}), migration_guard` +
|
|
2330
|
-
(gatePlan.write.customized_commands !== undefined ? ", customized_commands" : ""));
|
|
2331
|
-
}
|
|
2332
|
-
else {
|
|
2333
|
-
deps.log(" Repository gate: already confirmed as shown — no gate write.");
|
|
2334
|
-
}
|
|
2335
|
-
if (gatePlan !== null && gatePlan.desired.localCommands.length > 0) {
|
|
2336
|
-
deps.log(" Gate qualification: would be offered after the gate is stored — no job was queued.");
|
|
2337
|
-
}
|
|
2338
|
-
deps.log(" Epic-branch CI: a real run inspects workflow triggers and epic-branch rules (GitHub only), " +
|
|
2339
|
-
"then asks include or decline — nothing was inspected or recorded.");
|
|
2340
|
-
deps.log(" Would PREVIEW, then POST /jira/epic-runs/supervisor-bootstrap with field NAMES:");
|
|
2341
|
-
// Field NAMES and a COUNT only — never the check values, which are
|
|
2342
|
-
// configuration content, and never the API key.
|
|
2343
|
-
deps.log(" - done_gate_config.required_checks " +
|
|
2344
|
-
`(${bootstrapChecks.length} check(s))`);
|
|
2345
|
-
if (options.reviewPolicyExplicit)
|
|
2346
|
-
deps.log(" - defaults.review_policy");
|
|
2347
|
-
if (options.replaceDoneGate)
|
|
2348
|
-
deps.log(" - replace_done_gate");
|
|
2349
|
-
deps.log(" - auto_merge_enabled");
|
|
2350
|
-
deps.log(" - merge_approval_required");
|
|
2351
|
-
deps.log(" Existing project defaults would be KEPT: missing checks are added, nothing is " +
|
|
2352
|
-
"removed without a previewed, separately approved change.");
|
|
2353
|
-
deps.log(` Would target base URL: ${baseUrl}`);
|
|
2354
|
-
deps.log(options.skipWorkflow || options.reviewPolicy !== "verdict_protocol"
|
|
2355
|
-
? " Workflow scaffold: skipped (not applicable for this policy)"
|
|
2356
|
-
: ` Workflow scaffold target: ${CLAUDE_REVIEW_WORKFLOW_RELPATH}`);
|
|
2357
|
-
deps.log(options.epicKey && options.planFile
|
|
2358
|
-
? ` Would verify with: setup-epic --dry-run --epic-key ${options.epicKey}`
|
|
2359
|
-
: " setup-epic verification: skipped (no --epic-key/--plan-file supplied)");
|
|
2360
|
-
// The REAL planned path and the REAL start command — computed by the same
|
|
2361
|
-
// pure planners the live run uses, so the preview cannot drift from what
|
|
2362
|
-
// would actually happen. Still zero writes: no unit writer, no
|
|
2363
|
-
// install-state recorder, no lifecycle runner, and no consent prompt has
|
|
2364
|
-
// been reached on this branch.
|
|
2365
|
-
// BAPI-775: named as SEPARATE consents so the preview cannot read as one
|
|
2366
|
-
// blanket approval. Nothing below this line invokes the profile merger, the
|
|
2367
|
-
// hook installer, the capability recorder, or the phase's ledger probe —
|
|
2368
|
-
// this branch returns before every one of them.
|
|
2369
|
-
deps.log(local
|
|
2370
|
-
? " Tool visibility: would ask its OWN consent before adding the `epic_implementer` " +
|
|
2371
|
-
"profile to existing .mcp.json / .vscode/mcp.json / .cursor/mcp.json entries."
|
|
2372
|
-
: " Tool visibility: skipped (this caller supplied no local-provisioning seams)");
|
|
2373
|
-
deps.log(local
|
|
2374
|
-
? " Local observability: would ask a SEPARATE consent before installing the " +
|
|
2375
|
-
"managed Git hooks; the ledger probe is read-only."
|
|
2376
|
-
: " Local observability: skipped (this caller supplied no local-provisioning seams)");
|
|
2377
|
-
if (executorPlans) {
|
|
2378
|
-
deps.log(` Would write executor unit: ${executorPlans.install.unitPath}`);
|
|
2379
|
-
deps.log(` Would start it with: ${executorPlans.start.manualCommand}`);
|
|
2380
|
-
deps.log(" Executor provisioning: two separate consents (write, then start) — neither was asked.");
|
|
2381
|
-
}
|
|
2382
|
-
else if (executor) {
|
|
2383
|
-
deps.log(" Executor provisioning: skipped (no --executor-id supplied)");
|
|
2384
|
-
}
|
|
2385
|
-
if (options.launchProfile !== undefined) {
|
|
2386
|
-
deps.log(` Epic launch profile '${options.launchProfile}': would verify target access, credential ` +
|
|
2387
|
-
"binding, consent, notification, and actor, and persist the profile only if all hold " +
|
|
2388
|
-
"(each write behind its own consent) — nothing was read from or written to the profile store.");
|
|
2389
|
-
}
|
|
2390
|
-
renderCapabilityMatrix(deps, firstReport.readiness);
|
|
2391
|
-
deps.log("");
|
|
2392
|
-
deps.log("complete-with-manual-steps (dry run)");
|
|
2393
|
-
return 0;
|
|
2394
|
-
}
|
|
2395
|
-
if (gatePlan === null) {
|
|
2396
|
-
// Unreachable outside a dry run: the gate phase either decided a gate or
|
|
2397
|
-
// returned. Narrowed here so the bootstrap below always has one.
|
|
2398
|
-
deps.errorLog("No confirmed repository gate; aborting before any write.");
|
|
2399
|
-
return 1;
|
|
2400
|
-
}
|
|
2401
|
-
// ---- Phase 2: bootstrap — preview, consent, exact approval, apply -------
|
|
2402
|
-
// BAPI-1288. The server decides what this bootstrap would do to the stored
|
|
2403
|
-
// project defaults; this command only shows that decision and asks. It never
|
|
2404
|
-
// evaluates gate strength itself, and it never falls back to the old
|
|
2405
|
-
// replacing bootstrap when the server cannot preview.
|
|
2406
|
-
deps.log("");
|
|
2407
|
-
deps.log("Phase 2/8 — bootstrapping supervisor project defaults…");
|
|
2408
|
-
const combined = await fixGateAndDefaults(deps, options, access, gatePlan, legacyReviewDefault(options));
|
|
2409
|
-
if (combined.status === "deferred" || combined.status === "unknown")
|
|
2410
|
-
return 1;
|
|
2411
|
-
const storedGate = combined.current
|
|
2412
|
-
? { revision: combined.current.state.revision, qualification_state: combined.current.policy.qualification }
|
|
2413
|
-
: gatePlan.current;
|
|
2414
|
-
const manualActions = [];
|
|
2415
|
-
if (gatePlan.desired.localCommands.length > 0) {
|
|
2416
|
-
const qualified = storedGate.qualification_state === "qualified";
|
|
2417
|
-
let qualify = options.gate.qualifyGate;
|
|
2418
|
-
if (!qualify && !qualified) {
|
|
2419
|
-
deps.log("");
|
|
2420
|
-
deps.log(" The local gate must pass once under the executor before an unattended run is admitted.");
|
|
2421
|
-
qualify = await confirm(deps, "Qualify gate now? [y/N]: ");
|
|
2422
|
-
}
|
|
2423
|
-
if (qualify) {
|
|
2424
|
-
// Non-fatal by design: a failed qualification warns and the install goes on.
|
|
2425
|
-
await runConductorGateQualification(gateIo, access, deps.gate, {
|
|
2426
|
-
revision: storedGate.revision,
|
|
2427
|
-
baseUrl,
|
|
2428
|
-
});
|
|
2429
|
-
}
|
|
2430
|
-
else if (!qualified) {
|
|
2431
|
-
manualActions.push(`gate qualification: run ${PRINTED_QUALIFY_GATE_COMMAND} to qualify the local gate; ` +
|
|
2432
|
-
"until then admission refuses it (local_command_unqualified).");
|
|
2433
|
-
}
|
|
2434
|
-
else {
|
|
2435
|
-
deps.log(` local gate already qualified at revision ${storedGate.revision}.`);
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
// ---- BAPI-1405: epic-branch CI inspection and the explicit decision ----
|
|
2439
|
-
// Runs after the gate is resolved and stored, inside the gate phase. It only
|
|
2440
|
-
// reports and proposes; it never confirms a gate or authorizes a merge. A
|
|
2441
|
-
// failed read or decision write warns and the install continues.
|
|
2442
|
-
const epicBranchCi = await runEpicBranchCiInspection(gateIo, access, deps.gate, {
|
|
2443
|
-
decisionFlag: options.epicBranchCiDecision ?? null,
|
|
2444
|
-
dryRun: false,
|
|
2445
|
-
});
|
|
2446
|
-
if (epicBranchCi.manualAction !== null)
|
|
2447
|
-
manualActions.push(epicBranchCi.manualAction);
|
|
2448
|
-
// BAPI-1637: say what the STORED gate means for merges, from readiness's own facts.
|
|
2449
|
-
await runGateConsequenceSummary(gateIo, access, deps.gate);
|
|
2450
|
-
if (options.reviewPolicy === "verdict_protocol") {
|
|
2451
|
-
// ---- Phase 3: optional workflow scaffold -------------------------------
|
|
2452
|
-
deps.log("");
|
|
2453
|
-
deps.log("Phase 3/8 — claude-review workflow…");
|
|
2454
|
-
if (options.skipWorkflow) {
|
|
2455
|
-
deps.log(` skipped — the '${options.reviewPolicy}' review policy does not consume the ` +
|
|
2456
|
-
"sticky verdict this workflow emits.");
|
|
2457
|
-
}
|
|
2458
|
-
else if (!options.allowedBot || !options.secretName || !options.branches) {
|
|
2459
|
-
deps.log(" skipped — --allowed-bot, --secret-name, and --branches are required to render " +
|
|
2460
|
-
"the workflow template.");
|
|
2461
|
-
}
|
|
2462
|
-
else {
|
|
2463
|
-
const wantWorkflow = await confirm(deps, `Write ${CLAUDE_REVIEW_WORKFLOW_RELPATH}? [y/N]: `);
|
|
2464
|
-
if (!wantWorkflow) {
|
|
2465
|
-
deps.log(" declined — no file was written.");
|
|
2466
|
-
}
|
|
2467
|
-
else {
|
|
2468
|
-
let content;
|
|
2469
|
-
try {
|
|
2470
|
-
content = renderClaudeReviewWorkflow({
|
|
2471
|
-
allowedBot: options.allowedBot,
|
|
2472
|
-
secretName: options.secretName,
|
|
2473
|
-
branches: options.branches,
|
|
2474
|
-
});
|
|
2475
|
-
}
|
|
2476
|
-
catch (err) {
|
|
2477
|
-
deps.errorLog(` workflow parameters rejected: ${err instanceof Error ? err.message : "invalid"}`);
|
|
2478
|
-
return 1;
|
|
2479
|
-
}
|
|
2480
|
-
let result = await deps.writeWorkflow(deps.cwd, content, {});
|
|
2481
|
-
if (result.ok && result.outcome === "skipped") {
|
|
2482
|
-
// A DIFFERENT file already exists. Overwriting review automation needs
|
|
2483
|
-
// its own decision — never inferred from the earlier consents.
|
|
2484
|
-
const overwrite = await confirm(deps, `${CLAUDE_REVIEW_WORKFLOW_RELPATH} exists and differs. Overwrite? [y/N]: `);
|
|
2485
|
-
if (!overwrite) {
|
|
2486
|
-
deps.log(" existing workflow left untouched.");
|
|
2487
|
-
}
|
|
2488
|
-
else {
|
|
2489
|
-
result = await deps.writeWorkflow(deps.cwd, content, { overwriteConsent: true });
|
|
2490
|
-
}
|
|
2491
|
-
}
|
|
2492
|
-
if (!result.ok) {
|
|
2493
|
-
deps.errorLog(` workflow write failed: ${result.error}`);
|
|
2494
|
-
return 1;
|
|
2495
|
-
}
|
|
2496
|
-
if (result.outcome === "written") {
|
|
2497
|
-
deps.log(` wrote ${CLAUDE_REVIEW_WORKFLOW_RELPATH}`);
|
|
2498
|
-
const recorded = await deps.recordArtifact(deps.cwd, CLAUDE_REVIEW_WORKFLOW_RELPATH);
|
|
2499
|
-
if (!recorded.ok) {
|
|
2500
|
-
// Advisory: install-state is a diagnostic aid, not a correctness
|
|
2501
|
-
// dependency, so a failure here warns rather than failing the run.
|
|
2502
|
-
deps.errorLog(` note: install-state not updated (${recorded.error ?? "unknown"})`);
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
else if (result.outcome === "unchanged") {
|
|
2506
|
-
deps.log(` ${CLAUDE_REVIEW_WORKFLOW_RELPATH} already matches — nothing written.`);
|
|
2507
|
-
}
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
// ---- Phases 4 + 5: local out-of-the-box provisioning (BAPI-775) --------
|
|
2512
|
-
// Placed after the workflow scaffold and BEFORE setup-epic verification,
|
|
2513
|
-
// executor provisioning, and the capability report, so a run that stops at a
|
|
2514
|
-
// later phase has still closed the local gap it consented to close.
|
|
2515
|
-
deps.log("");
|
|
2516
|
-
deps.log("Phase 4/8 — Epic Implementer tool visibility…");
|
|
2517
|
-
if (local) {
|
|
2518
|
-
const outcome = await runConductorToolVisibilityPhase(deps, local);
|
|
2519
|
-
manualActions.push(...outcome.manualActions);
|
|
2520
|
-
if (outcome.fatal)
|
|
2521
|
-
return 1;
|
|
2522
|
-
}
|
|
2523
|
-
else {
|
|
2524
|
-
deps.log(" skipped — this caller supplied no local-provisioning seams.");
|
|
2525
|
-
manualActions.push("tool visibility: run the packaged `install epic-implementer` command to add the " +
|
|
2526
|
-
"`epic_implementer` profile to your host MCP configuration.");
|
|
2527
|
-
}
|
|
2528
|
-
deps.log("");
|
|
2529
|
-
deps.log("Phase 5/8 — local observability…");
|
|
2530
|
-
let observabilityFatal = false;
|
|
2531
|
-
if (local) {
|
|
2532
|
-
const outcome = await runConductorLocalObservabilityPhase(deps, local);
|
|
2533
|
-
manualActions.push(...outcome.manualActions);
|
|
2534
|
-
observabilityFatal = outcome.fatal === true;
|
|
2535
|
-
}
|
|
2536
|
-
else {
|
|
2537
|
-
deps.log(" skipped — this caller supplied no local-provisioning seams.");
|
|
2538
|
-
manualActions.push("local observability: run the packaged `install epic-implementer` command, or " +
|
|
2539
|
-
"`epic-implementer install-git-hooks`, to install the managed Git hooks.");
|
|
2540
|
-
}
|
|
2541
|
-
// The fail-loud hook-binary refusal (a package that ships no hook binary)
|
|
2542
|
-
// exits 1 — but only AFTER the phase's read-only ledger report has been
|
|
2543
|
-
// printed, which the phase guarantees. BAPI-1290: qualification refusals are
|
|
2544
|
-
// manual actions, not fatal, so they reach the phases below.
|
|
2545
|
-
if (observabilityFatal)
|
|
2546
|
-
return 1;
|
|
2547
|
-
// ---- Phase 6: setup-epic verification (conditional) --------------------
|
|
2548
|
-
// `parseSetupEpicArgs` hard-requires --epic-key AND --plan-file before any
|
|
2549
|
-
// dry-run branch, so this phase can only run when both are supplied. Fresh
|
|
2550
|
-
// repositories skip it with an explicit message rather than hard-failing.
|
|
2551
|
-
deps.log("");
|
|
2552
|
-
deps.log("Phase 6/8 — setup-epic verification…");
|
|
2553
|
-
if (options.epicKey && options.planFile) {
|
|
2554
|
-
deps.log(" verifying with `setup-epic --dry-run`…");
|
|
2555
|
-
const verification = await deps.runSetupEpicDryRun([
|
|
2556
|
-
"--dry-run",
|
|
2557
|
-
"--epic-key",
|
|
2558
|
-
options.epicKey,
|
|
2559
|
-
"--plan-file",
|
|
2560
|
-
options.planFile,
|
|
2561
|
-
// The SELECTED per-run policy is forwarded so the verification exercises
|
|
2562
|
-
// the same policy a real run would use — including its conflict guard.
|
|
2563
|
-
"--review-policy",
|
|
2564
|
-
options.reviewPolicy,
|
|
2565
|
-
...(options.repo ? ["--repo", options.repo] : []),
|
|
2566
|
-
]);
|
|
2567
|
-
if (verification.exitCode !== 0) {
|
|
2568
|
-
deps.errorLog(" setup-epic verification failed.");
|
|
2569
|
-
return 1;
|
|
2570
|
-
}
|
|
2571
|
-
deps.log(" setup-epic verification passed.");
|
|
2572
|
-
}
|
|
2573
|
-
else {
|
|
2574
|
-
deps.log(" setup-epic verification skipped — pass --epic-key and --plan-file once a plan exists.");
|
|
2575
|
-
}
|
|
2576
|
-
// ---- Phase 5: consented executor provisioning (BAPI-779) ---------------
|
|
2577
|
-
// Runs AFTER the pre-existing phases so a bootstrap failure never leaves a
|
|
2578
|
-
// started daemon behind, and BEFORE the capability report so the matrix can
|
|
2579
|
-
// use the readiness this phase actually observed.
|
|
2580
|
-
deps.log("");
|
|
2581
|
-
deps.log("Phase 7/8 — executor provisioning…");
|
|
2582
|
-
let observedReadiness = null;
|
|
2583
|
-
if (executor && executorPlans) {
|
|
2584
|
-
observedReadiness = await runExecutorProvisioningPhase(deps, executor, executorPlans, access);
|
|
2585
|
-
}
|
|
2586
|
-
else {
|
|
2587
|
-
deps.log(" skipped — " +
|
|
2588
|
-
(executor
|
|
2589
|
-
? "no --executor-id was supplied."
|
|
2590
|
-
: "this caller supplied no executor-provisioning seams."));
|
|
2591
|
-
}
|
|
2592
|
-
// ---- Phase 6: capability matrix + final doctor -------------------------
|
|
2593
|
-
deps.log("");
|
|
2594
|
-
deps.log("Phase 8/8 — capability report…");
|
|
2595
|
-
// The observed payload WINS when the executor phase actually saw the server
|
|
2596
|
-
// report readiness. Otherwise the matrix re-reads readiness itself — it is
|
|
2597
|
-
// never handed a synthesized response, so `executor_ready` still originates
|
|
2598
|
-
// from exactly one place: a live server observation.
|
|
2599
|
-
let postReadiness = observedReadiness;
|
|
2600
|
-
if (postReadiness === null) {
|
|
2601
|
-
try {
|
|
2602
|
-
postReadiness = await fetchConductorReadiness(access, deps.fetchJson, { assessmentVersion: 1, epicRunId: options.assessmentEpicRunId });
|
|
2603
|
-
}
|
|
2604
|
-
catch {
|
|
2605
|
-
// Degraded, not fatal: the write already succeeded, and the matrix simply
|
|
2606
|
-
// reports what it can observe.
|
|
2607
|
-
deps.errorLog(" readiness could not be re-read; capability matrix is best-effort.");
|
|
2608
|
-
}
|
|
2609
|
-
}
|
|
2610
|
-
const matrix = renderCapabilityMatrix(deps, postReadiness);
|
|
2611
|
-
deps.log("");
|
|
2612
|
-
deps.log(" re-running the unified epic-implementer doctor (read-only)…");
|
|
2613
|
-
const finalReport = await deps.runDoctor({
|
|
2614
|
-
access,
|
|
2615
|
-
reviewPolicySource: options.reviewPolicy,
|
|
2616
|
-
assessmentVersion: 1,
|
|
2617
|
-
epicRunId: options.assessmentEpicRunId,
|
|
2618
|
-
});
|
|
2619
|
-
deps.log(formatConductorInstallDoctorReport(finalReport));
|
|
2620
|
-
// Manual actions (BAPI-775): every declined, unavailable, empty, or incomplete
|
|
2621
|
-
// local phase leaves a pointer here. Collected in one place because an
|
|
2622
|
-
// operator who scrolled past a phase still needs to know what is outstanding.
|
|
2623
|
-
if (manualActions.length > 0) {
|
|
2624
|
-
deps.log("");
|
|
2625
|
-
deps.log("Manual actions");
|
|
2626
|
-
deps.log("──────────────");
|
|
2627
|
-
for (const action of manualActions)
|
|
2628
|
-
deps.log(` → ${action}`);
|
|
2629
|
-
}
|
|
2630
|
-
// ---- BAPI-1260: the reusable epic launch profile ------------------------
|
|
2631
|
-
// Last, because it can only be approved on facts every earlier phase
|
|
2632
|
-
// produced: server-observed readiness at THIS target, the executor handshake
|
|
2633
|
-
// for a durable host, and the operator's consents.
|
|
2634
|
-
if (options.launchProfile !== undefined) {
|
|
2635
|
-
const launch = await runLaunchProfilePhase(deps, options, {
|
|
2636
|
-
access,
|
|
2637
|
-
baseUrl,
|
|
2638
|
-
readiness: postReadiness,
|
|
2639
|
-
actorObserved: observedReadiness !== null || postReadiness?.executor.ready === true,
|
|
2640
|
-
runtime: resolveLaunchRuntime(executor, options.executionMode ?? "local"),
|
|
2641
|
-
});
|
|
2642
|
-
deps.log("");
|
|
2643
|
-
if (!launch.complete) {
|
|
2644
|
-
deps.log("incomplete-setup");
|
|
2645
|
-
return 1;
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
deps.log("");
|
|
2649
|
-
// The executor leg can only be true when the server observed a recent claim,
|
|
2650
|
-
// so a bootstrap alone can never print `complete`. The two local phases above
|
|
2651
|
-
// deliberately do NOT feed this predicate: local provisioning cannot
|
|
2652
|
-
// manufacture `complete`, and the terminal outcome is unchanged by BAPI-775.
|
|
2653
|
-
const allReady = matrix.apiReady && matrix.configurationReady && matrix.executorReady;
|
|
2654
|
-
deps.log(allReady ? "complete" : "complete-with-manual-steps");
|
|
2655
|
-
return conductorInstallDoctorExitCode(finalReport);
|
|
2043
|
+
return runConvergingSetup(options, deps, deps.setup);
|
|
2656
2044
|
}
|
|
2657
2045
|
// ---------------------------------------------------------------------------
|
|
2658
2046
|
// The converging setup runner (BAPI-1461)
|
|
@@ -2954,27 +2342,21 @@ function storedReviewSource(policy) {
|
|
|
2954
2342
|
// A stored value this client cannot interpret is still a stored choice.
|
|
2955
2343
|
return "unrecognized";
|
|
2956
2344
|
}
|
|
2957
|
-
/** Whether `.github/workflows/claude-review.yml` exists on the remote default branch snapshot. */
|
|
2958
|
-
async function remoteReviewWorkflowExists(setup, snapshot) {
|
|
2959
|
-
if (snapshot === null || setup.readSnapshotFile === undefined)
|
|
2960
|
-
return false;
|
|
2961
|
-
try {
|
|
2962
|
-
await setup.readSnapshotFile(snapshot, CLAUDE_REVIEW_WORKFLOW_RELPATH);
|
|
2963
|
-
return true;
|
|
2964
|
-
}
|
|
2965
|
-
catch {
|
|
2966
|
-
// Absent and unreadable both fall back to repository_policy, which needs no workflow.
|
|
2967
|
-
return false;
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
2345
|
/**
|
|
2971
2346
|
* Decide the review default: explicit `--review-policy` first; otherwise none when
|
|
2972
|
-
* a project default is already stored (or cannot be read); otherwise
|
|
2973
|
-
*
|
|
2974
|
-
*
|
|
2975
|
-
*
|
|
2347
|
+
* a project default is already stored (or cannot be read); otherwise infer from the
|
|
2348
|
+
* server's own read of the review workflow (BAPI-1714).
|
|
2349
|
+
*
|
|
2350
|
+
* `verdict_protocol` is inferred ONLY when the server's probe succeeded, the file
|
|
2351
|
+
* is present, and it emits BOTH the `run-id:` and `Reviewed-SHA:` markers (each
|
|
2352
|
+
* literally `true`). A workflow that is present but known to lack a marker cannot
|
|
2353
|
+
* produce the evidence `verdict_protocol` needs, so `repository_policy` is stored
|
|
2354
|
+
* with the `workflow_without_markers` basis. An absent workflow, a failed probe, or
|
|
2355
|
+
* any unknown fact keeps the `repository_policy` fallback. Workflow parsing stays
|
|
2356
|
+
* server-owned: this reads the typed observation and adds no YAML parser, marker
|
|
2357
|
+
* scanner, or provider probe. Reads only.
|
|
2976
2358
|
*/
|
|
2977
|
-
async function resolveReviewDefault(deps, options,
|
|
2359
|
+
async function resolveReviewDefault(deps, options, access, reviewWorkflow) {
|
|
2978
2360
|
let stored;
|
|
2979
2361
|
try {
|
|
2980
2362
|
stored = storedReviewSource(await fetchConductorSetupPolicy(access, deps.fetchJson));
|
|
@@ -2989,23 +2371,19 @@ async function resolveReviewDefault(deps, options, setup, access, snapshot) {
|
|
|
2989
2371
|
return { kind: "preserve", basis: "unreadable", stored: null };
|
|
2990
2372
|
if (stored !== null)
|
|
2991
2373
|
return { kind: "preserve", basis: "stored", stored };
|
|
2992
|
-
const
|
|
2374
|
+
const probed = reviewWorkflow?.probe_succeeded === true;
|
|
2375
|
+
const present = probed && reviewWorkflow?.workflow_present === true;
|
|
2376
|
+
if (present && reviewWorkflow?.emits_run_id === true && reviewWorkflow?.emits_reviewed_sha === true) {
|
|
2377
|
+
return { kind: "send", source: "verdict_protocol", basis: "workflow_present", stored: null };
|
|
2378
|
+
}
|
|
2379
|
+
const knownMissingMarker = present && (reviewWorkflow?.emits_run_id === false || reviewWorkflow?.emits_reviewed_sha === false);
|
|
2993
2380
|
return {
|
|
2994
2381
|
kind: "send",
|
|
2995
|
-
source:
|
|
2996
|
-
basis:
|
|
2382
|
+
source: "repository_policy",
|
|
2383
|
+
basis: knownMissingMarker ? "workflow_without_markers" : "workflow_absent",
|
|
2997
2384
|
stored: null,
|
|
2998
2385
|
};
|
|
2999
2386
|
}
|
|
3000
|
-
/**
|
|
3001
|
-
* The review default for a caller that supplies no setup seams: only an explicit
|
|
3002
|
-
* `--review-policy` is sent, exactly as before BAPI-1603.
|
|
3003
|
-
*/
|
|
3004
|
-
function legacyReviewDefault(options) {
|
|
3005
|
-
return options.reviewPolicyExplicit
|
|
3006
|
-
? { kind: "send", source: options.reviewPolicy, basis: "explicit", stored: null }
|
|
3007
|
-
: { kind: "preserve", basis: "stored", stored: null };
|
|
3008
|
-
}
|
|
3009
2387
|
/** The review source the readiness doctor should assume: the one this run sends or keeps. */
|
|
3010
2388
|
function effectiveReviewPolicy(options, reviewDefault) {
|
|
3011
2389
|
if (reviewDefault.kind === "send")
|
|
@@ -3566,11 +2944,8 @@ async function runRemoveMergeToken(options, deps, setup) {
|
|
|
3566
2944
|
function localAdvisories(report) {
|
|
3567
2945
|
const out = [];
|
|
3568
2946
|
const section = (id) => report.sections.find((s) => s.id === id);
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
out.push("to see the Epic Implementer tools in your editor, add `epic_implementer` to BRIDGE_MCP_PROFILE " +
|
|
3572
|
-
"in your MCP configuration, then restart the editor");
|
|
3573
|
-
}
|
|
2947
|
+
// BAPI-1719: the profile-token advisory moved to the `local.tool-visibility` setup item,
|
|
2948
|
+
// the single representation of that gap. Only the hook advisory stays here.
|
|
3574
2949
|
const hooks = section("conductor-hook-targets");
|
|
3575
2950
|
if (hooks !== undefined && hooks.status !== "ok") {
|
|
3576
2951
|
out.push("for local event history, run `epic-implementer install-git-hooks`");
|
|
@@ -4671,6 +4046,13 @@ async function collectDecisionEvidence(input) {
|
|
|
4671
4046
|
...(setupPrOffersWorkflow(input) && workflowState !== "installed" ? { managedWorkflowViaSetupPr: true } : {}),
|
|
4672
4047
|
},
|
|
4673
4048
|
launchProfile: { selected: options.launchProfile ?? null, notification: state.evidence.notification?.state ?? null },
|
|
4049
|
+
// BAPI-1719: from the same collected evidence and planned-fix list setup uses. Present only
|
|
4050
|
+
// when the fix is planned, so every proposal without it keeps its exact evidence and digest.
|
|
4051
|
+
...(fixes.includes("tool_visibility")
|
|
4052
|
+
? { toolVisibility: { planned: true, configPaths: state.evidence.toolVisibility?.state === "needs_merge" ? [...state.evidence.toolVisibility.configPaths] : [] } }
|
|
4053
|
+
: {}),
|
|
4054
|
+
// BAPI-1526: present only when the fix is planned, so every other proposal keeps its digest.
|
|
4055
|
+
...(fixes.includes("qualify_gate") ? { qualifyGate: { planned: true } } : {}),
|
|
4674
4056
|
repositoryFacts: {
|
|
4675
4057
|
...(await collectRepositoryFacts(deps, grantInventory, input.readToolchains)),
|
|
4676
4058
|
...(state.ciSystems !== undefined
|
|
@@ -5018,13 +4400,44 @@ export function workflowWriteResult(outcome, asked, decision) {
|
|
|
5018
4400
|
return { key: "setup_pr", status: outcome.status, target, reason: outcome.reason, fix: "Rerun setup once the cause above is fixed." };
|
|
5019
4401
|
}
|
|
5020
4402
|
}
|
|
4403
|
+
/** BAPI-1526 — why a declined gate qualification leaves the item outstanding. */
|
|
4404
|
+
const QUALIFY_GATE_DECLINED_REASON = "the gate was not qualified, so unattended runs that rely on it stay refused";
|
|
4405
|
+
/**
|
|
4406
|
+
* BAPI-1526 — one `qualify_gate` write result per qualification report. The text is
|
|
4407
|
+
* fixed; the qualification phase already printed its own explanation above.
|
|
4408
|
+
*/
|
|
4409
|
+
export function qualifyGateWriteResult(report, target) {
|
|
4410
|
+
const rerun = `Fix the cause above, then rerun setup or run ${PRINTED_QUALIFY_GATE_COMMAND}.`;
|
|
4411
|
+
switch (report) {
|
|
4412
|
+
case "qualified":
|
|
4413
|
+
return { key: "qualify_gate", status: "written", target };
|
|
4414
|
+
case "not_applicable":
|
|
4415
|
+
return { key: "qualify_gate", status: "unchanged", target, reason: "the stored gate has no local commands to qualify" };
|
|
4416
|
+
case "queued":
|
|
4417
|
+
case "running":
|
|
4418
|
+
case "unverified":
|
|
4419
|
+
return { key: "qualify_gate", status: "uncertain", target, reason: "the qualification has not finished, or its result could not be read", fix: `Check readiness, or run ${PRINTED_QUALIFY_GATE_COMMAND}.` };
|
|
4420
|
+
case "failed":
|
|
4421
|
+
case "could_not_run":
|
|
4422
|
+
case "stale":
|
|
4423
|
+
case "refused":
|
|
4424
|
+
return { key: "qualify_gate", status: "failed", target, reason: `the gate qualification ${report === "failed" ? "failed" : report === "could_not_run" ? "could not run" : report === "stale" ? "was for an older gate revision" : "was refused"}`, fix: rerun };
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
/** BAPI-1718 — why a reference answer did nothing when a merge token is already stored. Fixed text. */
|
|
4428
|
+
const MERGE_TOKEN_REFERENCE_UNUSED_REASON = "a merge token is already stored for this repository, so the reference was not used. " +
|
|
4429
|
+
"To replace it, run install epic-implementer --remove-merge-token, then rerun setup";
|
|
5021
4430
|
function fixOutcomeResult(key, target, outcome) {
|
|
5022
4431
|
if (outcome.status === "failed") {
|
|
5023
|
-
return { key, status: "failed", target, reason: outcome.reason, fix: "Fix the cause above, then rerun setup with the same answers." };
|
|
4432
|
+
return { key, status: "failed", target, reason: outcome.reason, fix: outcome.fix ?? "Fix the cause above, then rerun setup with the same answers." };
|
|
4433
|
+
}
|
|
4434
|
+
if (outcome.status === "unattempted") {
|
|
4435
|
+
return { key, status: "unattempted", target, reason: outcome.reason, fix: outcome.fix };
|
|
5024
4436
|
}
|
|
5025
4437
|
// BAPI-1667: fixed advisory text only. It reports; it never changes the status.
|
|
5026
4438
|
const advisories = [...new Set(outcome.advisories ?? [])];
|
|
5027
|
-
|
|
4439
|
+
const reason = outcome.reason ?? (advisories.length > 0 ? advisories.join(" ") : undefined);
|
|
4440
|
+
return { key, status: outcome.status, target, ...(reason !== undefined ? { reason } : {}) };
|
|
5028
4441
|
}
|
|
5029
4442
|
function indexProgress(index) {
|
|
5030
4443
|
if (index.state === "reached")
|
|
@@ -5280,7 +4693,7 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5280
4693
|
}
|
|
5281
4694
|
const readToolchains = snapshotToolchainReader(setup, snapshot);
|
|
5282
4695
|
// ---- The review default: explicit flag, then what is stored, then the remote workflow ----
|
|
5283
|
-
const reviewDefault = await resolveReviewDefault(deps, options,
|
|
4696
|
+
const reviewDefault = await resolveReviewDefault(deps, options, access, firstReport.readiness?.review_workflow);
|
|
5284
4697
|
renderReviewPolicy(deps, options, reviewDefault);
|
|
5285
4698
|
// ---- The gate: explicit flags win, a stored gate is kept, otherwise facts decide ----
|
|
5286
4699
|
// BAPI-1638: the answers path plans the gate without a terminal, so no discovered
|
|
@@ -5348,6 +4761,8 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5348
4761
|
if (setup.epicServer !== undefined) {
|
|
5349
4762
|
state.evidence = { ...state.evidence, epicServer: await assessEpicServer(setup.epicServer, access.repoName) };
|
|
5350
4763
|
}
|
|
4764
|
+
// BAPI-1719: whether the Bridge MCP entries load the Epic Implementer group, read-only. Its item is advisory.
|
|
4765
|
+
state.evidence = { ...state.evidence, toolVisibility: await collectToolVisibilityEvidence(deps.localProvisioning) };
|
|
5351
4766
|
// BAPI-1635: the selected profile's escalation declaration, read-only.
|
|
5352
4767
|
{
|
|
5353
4768
|
const notification = await collectNotificationEvidence(deps, options, baseUrl);
|
|
@@ -5371,6 +4786,14 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5371
4786
|
gateOrDefaultsNeedWrite: gateOrDefaultsNeedWrite(gatePlan, firstReport.readiness, reviewDefault),
|
|
5372
4787
|
suppliedPolicyInput: options.reviewPolicyExplicit || options.replaceDoneGate || hasExplicitGateInput(options.gate),
|
|
5373
4788
|
...(options.epicServerChange === true ? { epicServerChangeRequested: true } : {}),
|
|
4789
|
+
// BAPI-1526: the two gate-qualification facts. A gate revision with local commands this
|
|
4790
|
+
// pass writes (from explicit gate input, or setup's own policy write), with no test-command
|
|
4791
|
+
// trial in this pass that would qualify it, is offered qualification.
|
|
4792
|
+
...(options.gate.qualifyGate ? { qualifyGateRequested: true } : {}),
|
|
4793
|
+
...(gatePlan !== null && gatePlan.write !== null && gatePlan.desired.localCommands.length > 0
|
|
4794
|
+
&& options.testCommand === undefined && gatePlan.testCommandTrial?.eligible !== true
|
|
4795
|
+
? { explicitLocalGateUnproven: true }
|
|
4796
|
+
: {}),
|
|
5374
4797
|
};
|
|
5375
4798
|
const fixes = planSetupFixes(state.evidence, planContext);
|
|
5376
4799
|
// BAPI-1667: one read-only snapshot for both setup paths. An ordinary interactive run
|
|
@@ -5554,6 +4977,8 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5554
4977
|
}
|
|
5555
4978
|
let policyResult = null;
|
|
5556
4979
|
let epicServerChanged = false;
|
|
4980
|
+
// BAPI-1719: what the profile merge did, for the closing assessment and the closing line.
|
|
4981
|
+
let toolVisibilityApplied = null;
|
|
5557
4982
|
const answerOf = (key) => decisionFor(proposal, key);
|
|
5558
4983
|
const optionOf = (key) => {
|
|
5559
4984
|
const d = answerOf(key);
|
|
@@ -5666,22 +5091,72 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5666
5091
|
key: "test_command",
|
|
5667
5092
|
run: async () => {
|
|
5668
5093
|
// ---- Explicit operations, each behind its own consent (unchanged) -------
|
|
5669
|
-
|
|
5670
|
-
&& policyResult?.status !== "deferred" && policyResult?.status !== "unknown"
|
|
5094
|
+
const qualifiable = gatePlan !== null && gatePlan.desired.localCommands.length > 0
|
|
5095
|
+
&& policyResult?.status !== "deferred" && policyResult?.status !== "unknown";
|
|
5096
|
+
if (options.gate.qualifyGate && qualifiable) {
|
|
5671
5097
|
await runConductorGateQualification(gateIo, access, deps.gate, {
|
|
5672
5098
|
revision: policyResult?.current?.state.revision ?? gatePlan.current.revision,
|
|
5673
5099
|
baseUrl,
|
|
5674
5100
|
});
|
|
5101
|
+
return null;
|
|
5102
|
+
}
|
|
5103
|
+
// BAPI-1526: the `qualify_gate` fix, behind its own consent. Same step, same revision.
|
|
5104
|
+
if (!fixes.includes("qualify_gate"))
|
|
5105
|
+
return null;
|
|
5106
|
+
const target = "repository_gate.qualification";
|
|
5107
|
+
// A test-command trial in this pass already qualifies the gate (promoted), or is still finishing
|
|
5108
|
+
// the same job (uncertain). Asking again would be redundant, so nothing is asked or queued.
|
|
5109
|
+
if (state.trial?.status === "promoted" || state.trial?.status === "uncertain") {
|
|
5110
|
+
return { key: "qualify_gate", status: "unchanged", target, reason: "the test-command check in this pass qualifies the gate" };
|
|
5111
|
+
}
|
|
5112
|
+
if (proposal !== null) {
|
|
5113
|
+
const d = answerOf("qualify_gate");
|
|
5114
|
+
if (d === undefined)
|
|
5115
|
+
return null;
|
|
5116
|
+
if (d.kind === "decline")
|
|
5117
|
+
return { key: "qualify_gate", status: "declined", target, reason: QUALIFY_GATE_DECLINED_REASON };
|
|
5118
|
+
}
|
|
5119
|
+
else {
|
|
5120
|
+
if (deps.promptLine === undefined) {
|
|
5121
|
+
return { key: "qualify_gate", status: "declined", target, reason: "there is no interactive terminal, so the gate was not qualified" };
|
|
5122
|
+
}
|
|
5123
|
+
deps.log("");
|
|
5124
|
+
deps.log("Gate qualification");
|
|
5125
|
+
deps.log(" The local gate must pass once under the executor before an unattended run is admitted. Setup will run it now if you approve.");
|
|
5126
|
+
if (!(await confirm(deps, "Run the local gate once now to qualify it? [y/N]: "))) {
|
|
5127
|
+
deps.log(` declined — ${QUALIFY_GATE_DECLINED_REASON}.`);
|
|
5128
|
+
return { key: "qualify_gate", status: "declined", target, reason: QUALIFY_GATE_DECLINED_REASON };
|
|
5129
|
+
}
|
|
5675
5130
|
}
|
|
5676
|
-
|
|
5131
|
+
if (!qualifiable) {
|
|
5132
|
+
return { key: "qualify_gate", status: "unattempted", target, reason: "the gate this pass would qualify was not stored", fix: "Rerun setup once the gate is stored." };
|
|
5133
|
+
}
|
|
5134
|
+
let report;
|
|
5135
|
+
try {
|
|
5136
|
+
report = await runConductorGateQualification(gateIo, access, deps.gate, {
|
|
5137
|
+
revision: policyResult?.current?.state.revision ?? gatePlan.current.revision,
|
|
5138
|
+
baseUrl,
|
|
5139
|
+
});
|
|
5140
|
+
}
|
|
5141
|
+
catch {
|
|
5142
|
+
return { key: "qualify_gate", status: "uncertain", target, reason: "the qualification's result is unknown", fix: `Check readiness, or run ${PRINTED_QUALIFY_GATE_COMMAND}.` };
|
|
5143
|
+
}
|
|
5144
|
+
// A local result is reported only. The closing verdict still comes from the server's refreshed report.
|
|
5145
|
+
return qualifyGateWriteResult(report, target);
|
|
5677
5146
|
},
|
|
5678
5147
|
},
|
|
5679
5148
|
{
|
|
5680
5149
|
key: "merge_token",
|
|
5681
5150
|
run: async () => {
|
|
5682
5151
|
if (!fixes.includes("merge_token") || state.identity === null) {
|
|
5683
|
-
|
|
5684
|
-
|
|
5152
|
+
if (proposal === null || answerOf("merge_token")?.kind !== "reference")
|
|
5153
|
+
return null;
|
|
5154
|
+
// BAPI-1718: a reference answered against an already configured token is a deliberate
|
|
5155
|
+
// no-op. Say so, without resolving the reference or touching the credential store.
|
|
5156
|
+
// The reason lives here only; the setup record's stable "in place" row is unchanged.
|
|
5157
|
+
return fixes.includes("merge_token")
|
|
5158
|
+
? { key: "merge_token", status: "unchanged", target: "merge_token" }
|
|
5159
|
+
: { key: "merge_token", status: "unchanged", target: "merge_token", reason: MERGE_TOKEN_REFERENCE_UNUSED_REASON };
|
|
5685
5160
|
}
|
|
5686
5161
|
const d = answerOf("merge_token");
|
|
5687
5162
|
const answer = proposal === null || d === undefined ? undefined
|
|
@@ -5711,14 +5186,33 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5711
5186
|
{
|
|
5712
5187
|
key: "worker_mcp_grant",
|
|
5713
5188
|
run: async () => {
|
|
5714
|
-
if (
|
|
5715
|
-
return
|
|
5716
|
-
: { key: "worker_mcp_grant", status: "unchanged", target: "mcp_grant" };
|
|
5717
|
-
}
|
|
5189
|
+
if (setup.mcpGrant === undefined)
|
|
5190
|
+
return null;
|
|
5718
5191
|
const d = answerOf("worker_mcp_grant");
|
|
5192
|
+
const planned = fixes.includes("mcp_grant");
|
|
5193
|
+
// BAPI-1718: a stated selection reaches the writer whether or not the grant was planned
|
|
5194
|
+
// as a fix. Before, a settled grant answered "unchanged" and silently wrote nothing.
|
|
5195
|
+
const stated = proposal !== null && d?.kind === "selection";
|
|
5196
|
+
// Not planned, and no selection to apply: absent, keep, and decline all change nothing.
|
|
5197
|
+
if (!planned && !stated)
|
|
5198
|
+
return null;
|
|
5199
|
+
if (grantInventory === null) {
|
|
5200
|
+
// A planned grant with no stated selection keeps its earlier behavior: nothing to do.
|
|
5201
|
+
if (!stated)
|
|
5202
|
+
return null;
|
|
5203
|
+
return {
|
|
5204
|
+
key: "worker_mcp_grant",
|
|
5205
|
+
status: "unattempted",
|
|
5206
|
+
target: "mcp_grant",
|
|
5207
|
+
reason: "the MCP servers could not be inspected, so the approved selection was not written",
|
|
5208
|
+
fix: "Rerun setup with the same answers.",
|
|
5209
|
+
};
|
|
5210
|
+
}
|
|
5719
5211
|
const answer = proposal === null || d === undefined ? undefined
|
|
5720
5212
|
: d.kind === "selection" ? { decision: "select", ids: d.ids } : { decision: "decline" };
|
|
5721
|
-
const outcome = await fixMcpGrant(deps, setup.mcpGrant, access.repoName, grantInventory, answer, sfccGrantIds(epicServerSnapshot, grantInventory)
|
|
5213
|
+
const outcome = await fixMcpGrant(deps, setup.mcpGrant, access.repoName, grantInventory, answer, sfccGrantIds(epicServerSnapshot, grantInventory),
|
|
5214
|
+
// Only the newly enabled path (a settled grant) is protected from losing servers.
|
|
5215
|
+
stated && !planned ? { keepStored: true } : {});
|
|
5722
5216
|
return fixOutcomeResult("worker_mcp_grant", "mcp_grant", outcome);
|
|
5723
5217
|
},
|
|
5724
5218
|
},
|
|
@@ -5845,13 +5339,69 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5845
5339
|
return written;
|
|
5846
5340
|
},
|
|
5847
5341
|
},
|
|
5342
|
+
{
|
|
5343
|
+
// BAPI-1719: the local MCP profile merge, last, behind terminal or answers approval.
|
|
5344
|
+
// It never gates readiness: a decline, a failure, or an unknown read stays advisory.
|
|
5345
|
+
key: "tool_visibility",
|
|
5346
|
+
run: async () => {
|
|
5347
|
+
const local = deps.localProvisioning;
|
|
5348
|
+
// No planned fix (including a stated conditional answer whose choice is gone) means no apply.
|
|
5349
|
+
if (!fixes.includes("tool_visibility") || local === undefined)
|
|
5350
|
+
return null;
|
|
5351
|
+
const target = "host_mcp_profile";
|
|
5352
|
+
const paths = state.evidence.toolVisibility?.state === "needs_merge" ? state.evidence.toolVisibility.configPaths : [];
|
|
5353
|
+
if (proposal !== null) {
|
|
5354
|
+
const d = answerOf("tool_visibility");
|
|
5355
|
+
if (d === undefined || (d.kind === "option" && d.option === "keep"))
|
|
5356
|
+
return null;
|
|
5357
|
+
if (d.kind === "decline") {
|
|
5358
|
+
return { key: "tool_visibility", status: "declined", target, reason: "no MCP configuration was changed" };
|
|
5359
|
+
}
|
|
5360
|
+
}
|
|
5361
|
+
else {
|
|
5362
|
+
// The terminal path: a plain y/N question. Without a terminal this is "no", and nothing is asked.
|
|
5363
|
+
if (deps.promptLine === undefined)
|
|
5364
|
+
return { key: "tool_visibility", status: "declined", target, reason: "there is no interactive terminal, so no MCP configuration was changed" };
|
|
5365
|
+
deps.log("");
|
|
5366
|
+
deps.log("Epic Implementer tools in your editor");
|
|
5367
|
+
deps.log(` ${paths.length > 0 ? paths.join(", ") : "Your MCP configuration"} does not load the epic_implementer group yet. Approving adds it to the existing Bridge entry and keeps your other groups; you then restart your MCP client.`);
|
|
5368
|
+
const consented = await confirm(deps, "Update existing supported host MCP configurations (.mcp.json, .vscode/mcp.json, " +
|
|
5369
|
+
".cursor/mcp.json) to add the `epic_implementer` profile? [y/N]: ");
|
|
5370
|
+
if (!consented) {
|
|
5371
|
+
deps.log(" declined — no host MCP configuration was changed.");
|
|
5372
|
+
return { key: "tool_visibility", status: "declined", target, reason: "no MCP configuration was changed" };
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
const result = await applyToolVisibility(deps, local);
|
|
5376
|
+
toolVisibilityApplied = result;
|
|
5377
|
+
for (const note of result.notes)
|
|
5378
|
+
deps.errorLog(` note: ${note}`);
|
|
5379
|
+
// A failure is advisory, but never silent: fixed wording and fixed paths only.
|
|
5380
|
+
if (result.outcome === "failed") {
|
|
5381
|
+
deps.errorLog(` ${result.failure ?? TOOL_VISIBILITY_FAILURE_TEXT.write}${result.failurePaths.length > 0 ? ` (${result.failurePaths.join(", ")})` : ""}; the MCP profile was not changed by setup.`);
|
|
5382
|
+
}
|
|
5383
|
+
if (result.outcome === "written") {
|
|
5384
|
+
deps.log(` updated: ${(result.changedPaths.length > 0 ? result.changedPaths : result.carryingPaths).join(", ")}`);
|
|
5385
|
+
// Coverage honesty: the merge path writes these three files and no others.
|
|
5386
|
+
deps.log(" Codex and Copilot host configuration was NOT inspected or changed.");
|
|
5387
|
+
}
|
|
5388
|
+
const guidance = result.guidance.join(" ");
|
|
5389
|
+
const outcome = result.outcome === "failed"
|
|
5390
|
+
? { status: "failed", reason: `${result.failure ?? TOOL_VISIBILITY_FAILURE_TEXT.write}${result.failurePaths.length > 0 ? ` (${result.failurePaths.join(", ")})` : ""}`, ...(guidance.length > 0 ? { fix: guidance } : {}) }
|
|
5391
|
+
: result.outcome === "written"
|
|
5392
|
+
? { status: "written", advisories: [...result.advisories, ...result.guidance] }
|
|
5393
|
+
: { status: "unchanged", ...(result.outcome === "no_entry" ? { advisories: ["no supported Bridge entry exists, so nothing was written (setup never creates one)"] } : {}) };
|
|
5394
|
+
const written = fixOutcomeResult("tool_visibility", target, outcome);
|
|
5395
|
+
return result.outcome === "written" ? { ...written, read_back: { config_paths: result.changedPaths.length > 0 ? result.changedPaths : result.carryingPaths } } : written;
|
|
5396
|
+
},
|
|
5397
|
+
},
|
|
5848
5398
|
];
|
|
5849
5399
|
// The interactive path keeps its original question order: the missing-item fixes
|
|
5850
5400
|
// (merge token, re-index, grant, epic server) come right after the gate and before
|
|
5851
5401
|
// the learned check, the setup PR, and qualification. The answers path runs the
|
|
5852
5402
|
// array as written so the learned check and setup PR chain on the gate.
|
|
5853
5403
|
const ordered = proposal !== null ? operations
|
|
5854
|
-
: [operations[0], ...operations.slice(4, 8), ...operations.slice(1, 4), operations[8], operations[9]];
|
|
5404
|
+
: [operations[0], ...operations.slice(4, 8), ...operations.slice(1, 4), operations[8], operations[9], operations[10]];
|
|
5855
5405
|
const firstApply = await applyInstallProposal({ proposal, digest: proposalDigest, refusal: null }, { operations: ordered });
|
|
5856
5406
|
const applied = firstApply.kind === "applied" ? firstApply.result : { complete: false, results: [] };
|
|
5857
5407
|
if (options.reviewPolicy === "verdict_protocol" && !options.skipWorkflow) {
|
|
@@ -5942,6 +5492,16 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5942
5492
|
? { ...closingEpicServer, statementError }
|
|
5943
5493
|
: closingEpicServer;
|
|
5944
5494
|
}
|
|
5495
|
+
// BAPI-1719: the same read-only collection, run again after the apply. A confirmed write whose
|
|
5496
|
+
// read-back does not show the group stays visible as `unknown` verification, never as satisfied.
|
|
5497
|
+
{
|
|
5498
|
+
const closingVisibility = await collectToolVisibilityEvidence(deps.localProvisioning);
|
|
5499
|
+
const applied = toolVisibilityApplied;
|
|
5500
|
+
closing.evidence.toolVisibility =
|
|
5501
|
+
applied?.outcome === "written" && closingVisibility.state !== "met"
|
|
5502
|
+
? { state: "unknown", reason: "verification" }
|
|
5503
|
+
: closingVisibility;
|
|
5504
|
+
}
|
|
5945
5505
|
// ---- BAPI-1260: the reusable launch profile (explicit) ------------------
|
|
5946
5506
|
// BAPI-1635: this runs BEFORE the final items are projected, so a profile saved by
|
|
5947
5507
|
// this invocation is read back and judged for escalation, not left as pre-save evidence.
|
|
@@ -6049,6 +5609,12 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
6049
5609
|
if (r.fix !== undefined)
|
|
6050
5610
|
deps.log(` ${r.key}: ${r.fix}`);
|
|
6051
5611
|
}
|
|
5612
|
+
// BAPI-1719: once, after a confirmed profile write, even when its verification is unknown.
|
|
5613
|
+
// The same instruction rides in the structured write result's reason.
|
|
5614
|
+
if (toolVisibilityApplied?.outcome === "written") {
|
|
5615
|
+
deps.log("");
|
|
5616
|
+
deps.log(TOOL_VISIBILITY_RESTART_LINE);
|
|
5617
|
+
}
|
|
6052
5618
|
deps.installDocumentSink?.({
|
|
6053
5619
|
items,
|
|
6054
5620
|
decisions: decisionEvidence,
|
|
@@ -6161,6 +5727,9 @@ function confirmedPresentation(readiness, evidence, items, unmet, applyResult) {
|
|
|
6161
5727
|
blockers: unmet.map((item) => ({ label: item.label, fix: setupItemRemedy(item) })),
|
|
6162
5728
|
results: applyResult.results,
|
|
6163
5729
|
protection,
|
|
5730
|
+
// BAPI-1747 — the same overlay the launch preview and doctor use, fed by the
|
|
5731
|
+
// tool-visibility state that backs `local.tool-visibility`.
|
|
5732
|
+
prerequisites: overlayReadinessPrerequisites([], readiness?.prerequisites ?? [], evidence.toolVisibility),
|
|
6164
5733
|
}),
|
|
6165
5734
|
...(ready !== undefined ? { ready } : {}),
|
|
6166
5735
|
...(protection !== undefined ? { merge_test_protection: protection } : {}),
|
|
@@ -6201,7 +5770,7 @@ async function closingMcpGrantState(grantDeps, repoName, inventory) {
|
|
|
6201
5770
|
? { state: "met" }
|
|
6202
5771
|
: { state: "needs_action", reason: "changed" };
|
|
6203
5772
|
}
|
|
6204
|
-
export async function fixMcpGrant(deps, grantDeps, repoName, inventory, answer, sfccRecommendedIds = []) {
|
|
5773
|
+
export async function fixMcpGrant(deps, grantDeps, repoName, inventory, answer, sfccRecommendedIds = [], options = {}) {
|
|
6205
5774
|
deps.log("");
|
|
6206
5775
|
deps.log("Worker MCP servers");
|
|
6207
5776
|
deps.log(` Epic Implementer workers in ${repoName} always get Bridge. You can approve extra MCP servers for them, ` +
|
|
@@ -6234,7 +5803,7 @@ export async function fixMcpGrant(deps, grantDeps, repoName, inventory, answer,
|
|
|
6234
5803
|
return { status: "declined" };
|
|
6235
5804
|
}
|
|
6236
5805
|
if (answer?.decision === "select")
|
|
6237
|
-
return publishApprovedGrant(deps, grantDeps, repoName, inventory, answer.ids);
|
|
5806
|
+
return publishApprovedGrant(deps, grantDeps, repoName, inventory, answer.ids, options);
|
|
6238
5807
|
if (!deps.promptLine) {
|
|
6239
5808
|
deps.log(" skipped approving MCP servers: there is no interactive terminal, so this counts as declined. Nothing changed.");
|
|
6240
5809
|
return { status: "declined" };
|
|
@@ -6314,25 +5883,55 @@ async function publishGrant(deps, grantDeps, repoName, inventory, selectedIds) {
|
|
|
6314
5883
|
* BAPI-1638 — the answers path: the selection is the approved option ids.
|
|
6315
5884
|
* A grant that already holds exactly these servers, for the same inventory, is
|
|
6316
5885
|
* `unchanged` and is not rewritten.
|
|
5886
|
+
*
|
|
5887
|
+
* BAPI-1718 — the stored names are compared whole, with no name filtered out, so a
|
|
5888
|
+
* selection that differs from what is stored is never reported `unchanged`.
|
|
6317
5889
|
*/
|
|
6318
|
-
async function publishApprovedGrant(deps, grantDeps, repoName, inventory, ids) {
|
|
5890
|
+
async function publishApprovedGrant(deps, grantDeps, repoName, inventory, ids, options = {}) {
|
|
6319
5891
|
const names = inventory.candidates
|
|
6320
5892
|
.filter((c) => c.definitions.some((d) => ids.includes(d.id)))
|
|
6321
5893
|
.map((c) => c.name)
|
|
6322
5894
|
.sort();
|
|
5895
|
+
let current;
|
|
5896
|
+
let readFailed = false;
|
|
6323
5897
|
try {
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
5898
|
+
current = await grantDeps.readGrant(repoName);
|
|
5899
|
+
}
|
|
5900
|
+
catch {
|
|
5901
|
+
readFailed = true;
|
|
5902
|
+
}
|
|
5903
|
+
// The keep-stored guard protects a settled grant's selections within this one setup run: it
|
|
5904
|
+
// reads the grant fresh, just before any publish, and refuses to drop an approved server. It
|
|
5905
|
+
// takes no lock (a concurrent edit between the read and the write is not prevented) and it
|
|
5906
|
+
// does not change how a planned replacement behaves, which never sets the flag.
|
|
5907
|
+
if (options.keepStored === true) {
|
|
5908
|
+
if (readFailed || current === undefined || current.state === "unusable") {
|
|
5909
|
+
deps.log(" The approved MCP servers could not be read. Nothing changed.");
|
|
5910
|
+
return {
|
|
5911
|
+
status: "unattempted",
|
|
5912
|
+
reason: "the approved MCP servers could not be read, so the selection was not written",
|
|
5913
|
+
fix: "Rerun setup with the same answers.",
|
|
5914
|
+
};
|
|
5915
|
+
}
|
|
5916
|
+
if (current.state === "ok") {
|
|
5917
|
+
const omitted = current.grant.servers.map((server) => server.name).filter((name) => !names.includes(name)).sort();
|
|
5918
|
+
if (omitted.length > 0) {
|
|
5919
|
+
const reason = `the selection leaves out ${omitted.join(", ")}, which are already approved for workers. ` +
|
|
5920
|
+
"Setup never removes an approved server from a settled grant, so nothing changed. " +
|
|
5921
|
+
"To add a server, list every approved server plus the new one.";
|
|
5922
|
+
deps.log(` declined — ${reason}`);
|
|
5923
|
+
return { status: "declined", reason };
|
|
6330
5924
|
}
|
|
6331
5925
|
}
|
|
6332
5926
|
}
|
|
6333
|
-
|
|
6334
|
-
|
|
5927
|
+
if (current !== undefined && current.state === "ok" && current.grant.candidate_fingerprint === inventory.fingerprint) {
|
|
5928
|
+
const stored = current.grant.servers.map((server) => server.name).sort();
|
|
5929
|
+
if (stored.length === names.length && stored.every((name, i) => name === names[i])) {
|
|
5930
|
+
deps.log(" unchanged — the stored approval already says this.");
|
|
5931
|
+
return { status: "unchanged" };
|
|
5932
|
+
}
|
|
6335
5933
|
}
|
|
5934
|
+
// An unreadable grant (without the flag) is replaced through the same revalidated publication.
|
|
6336
5935
|
deps.log(` Workers in ${repoName} would get: Bridge${names.length > 0 ? ` + ${names.join(", ")}` : " only"}.`);
|
|
6337
5936
|
return publishGrant(deps, grantDeps, repoName, inventory, ids);
|
|
6338
5937
|
}
|
|
@@ -6361,6 +5960,33 @@ async function publishCapabilityStatement(deps, grantDeps, access, verbose) {
|
|
|
6361
5960
|
// BAPI-1546: the epic-server item
|
|
6362
5961
|
// ---------------------------------------------------------------------------
|
|
6363
5962
|
/** Read the record and map it to setup evidence. Read-only; never throws. */
|
|
5963
|
+
/**
|
|
5964
|
+
* BAPI-1719: project one read-only profile inspection onto the setup evidence.
|
|
5965
|
+
* `met` only when every supported Bridge entry loads the group AND the inspection
|
|
5966
|
+
* was conclusive (no unreadable config); a needed merge, a missing entry, and an
|
|
5967
|
+
* inconclusive read stay distinct. Carries fixed config paths only.
|
|
5968
|
+
*
|
|
5969
|
+
* A config that registers Bridge under both names comes first: the writer refuses
|
|
5970
|
+
* it all-or-nothing, so planning a merge would only produce a failed write and a
|
|
5971
|
+
* setup that exits 1 on every run. Setup skips the merge and shows a notice instead,
|
|
5972
|
+
* the way the SFCC profile merge (`index.ts`) and vendor-first host provisioning
|
|
5973
|
+
* (`skipped-duplicate-registration`) leave such a config untouched.
|
|
5974
|
+
*/
|
|
5975
|
+
export function toolVisibilityStateFrom(inspection) {
|
|
5976
|
+
// BAPI-1747 — one owner for this mapping, shared with the readiness overlay.
|
|
5977
|
+
return toolVisibilityStateFromInspection(inspection);
|
|
5978
|
+
}
|
|
5979
|
+
/** Read-only. Unwired dependencies or a throwing inspector are `unknown`, never satisfied. */
|
|
5980
|
+
async function collectToolVisibilityEvidence(local) {
|
|
5981
|
+
if (local === undefined)
|
|
5982
|
+
return { state: "unknown", reason: "inspection" };
|
|
5983
|
+
try {
|
|
5984
|
+
return toolVisibilityStateFrom(await local.inspectProfileToken());
|
|
5985
|
+
}
|
|
5986
|
+
catch {
|
|
5987
|
+
return { state: "unknown", reason: "inspection" };
|
|
5988
|
+
}
|
|
5989
|
+
}
|
|
6364
5990
|
async function assessEpicServer(epicDeps, repoName) {
|
|
6365
5991
|
let read;
|
|
6366
5992
|
try {
|
|
@@ -6584,6 +6210,8 @@ const DRY_RUN_FIX_TEXT = Object.freeze({
|
|
|
6584
6210
|
merge_token: "store a GitHub merge token on this computer (its own consent, read with no echo)",
|
|
6585
6211
|
mcp_grant: "approve which extra MCP servers Epic Implementer workers get in this repository (one consent; the grant is stored outside every worktree)",
|
|
6586
6212
|
epic_server: "choose the epic server for Epic Implementer runs: none, local, or sfcc_shared_active (its own consent; the record is stored outside every worktree)",
|
|
6213
|
+
tool_visibility: "add the epic_implementer group to your existing Bridge MCP entries, keeping the groups already listed, then restart your MCP client (its own consent; no file is created)",
|
|
6214
|
+
qualify_gate: "run the stored local gate once under a short-lived executor to qualify it for its current revision (its own consent; dry run runs nothing)",
|
|
6587
6215
|
reindex: "use the default branch for indexing when it is the only candidate, or ask which branch to use when a different branch exists; then queue one tracked first parse, or one retry you approve. Dry run writes no configuration, queue, retry, authorization record, or file",
|
|
6588
6216
|
});
|
|
6589
6217
|
/**
|