@bridge_gpt/mcp-server 0.2.73 → 0.2.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/build/agent-launchers/claude-executor-adapter.js +12 -0
- package/build/agent-launchers/prompt.js +9 -21
- package/build/agents.generated.js +4 -4
- package/build/authored-plan.js +542 -0
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +11 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +6 -6
- package/build/conductor/bridge-api-client.js +692 -47
- package/build/conductor/command-drift.js +1 -1
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +2 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/epic-branch-ci-inspection.js +61 -16
- package/build/conductor/epic-implementer-cli.js +370 -93
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +58 -80
- package/build/conductor/epic-server.js +57 -4
- package/build/conductor/gate-discovery.js +253 -13
- package/build/conductor/gate-settings-review.js +58 -25
- package/build/conductor/launch-plan.js +58 -12
- package/build/conductor/open-decision-phrases.js +50 -0
- package/build/conductor/prerequisite-inputs.js +181 -14
- package/build/connect-github-api.js +18 -0
- package/build/connect-github.js +35 -18
- package/build/credential-delivery.js +280 -0
- package/build/credential-launch-safety.js +142 -0
- package/build/credential-materialization.js +91 -16
- package/build/credential-references-node-deps.js +29 -0
- package/build/credential-references.js +1394 -0
- package/build/credential-references.test-fixtures.js +211 -0
- package/build/credential-scan-conventions.js +145 -0
- package/build/credential-scan.js +517 -0
- package/build/credential-store.js +50 -0
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +47 -1
- package/build/docs.generated.js +8 -1
- package/build/doctor.js +41 -0
- package/build/drive-epic.js +684 -49
- package/build/epic-branch-ci-summary.js +18 -1
- package/build/epic-capability-statement.js +71 -3
- package/build/epic-ci-workflow-drift.js +52 -13
- package/build/epic-ci-workflow-install.js +31 -6
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +129 -7
- package/build/epic-implementer-bin.js +288 -83
- package/build/epic-implementer-bundle-cli.js +61 -0
- package/build/epic-implementer-claude-hook-bin.js +1 -1
- package/build/epic-implementer-env.js +3 -4
- package/build/epic-integration-pr.js +5 -2
- package/build/epic-launch-context.js +102 -7
- package/build/epic-server-record.js +30 -15
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +39 -1
- package/build/executor/epic-server-context.js +23 -7
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/job-runner.js +167 -738
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/permissions.js +85 -3
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/prompt-spec.js +37 -3
- package/build/executor/required-verification.js +28 -2
- package/build/executor/runner.js +4 -1
- package/build/executor/types.js +9 -0
- package/build/executor/worker-database.js +6 -1
- package/build/executor/worker-guard-hook.js +24 -2
- package/build/executor-launch.js +4 -2
- package/build/generated/ticket-status.js +20 -0
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +589 -326
- package/build/install-bridge-conductor-answers.js +112 -22
- package/build/install-bridge-conductor-apply.js +38 -1
- package/build/install-bridge-conductor-assessment.js +482 -53
- package/build/install-bridge-conductor-compact.js +29 -2
- package/build/install-bridge-conductor-contracts.js +10 -1
- package/build/install-bridge-conductor-gate.js +379 -89
- package/build/install-bridge-conductor-setup.js +46 -8
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +925 -141
- package/build/install-bridge.js +88 -11
- package/build/install-doctor.js +38 -8
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/mcp-grant-candidates.js +108 -96
- package/build/mcp-invoke.js +168 -4
- package/build/mcp-provisioning.js +21 -4
- package/build/mcp-server-invocation.js +13 -0
- package/build/merge-workflow-install.js +9 -1
- package/build/pipelines.generated.js +8 -7
- package/build/plan-generation.js +17 -0
- package/build/plane/status.js +8 -2
- package/build/printed-remedy-commands.js +59 -0
- package/build/project-root.js +40 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +5 -2
- package/build/repository-toolchains.js +16 -7
- package/build/scripts/saved-commands-config-field-driver.js +65 -0
- package/build/setup-epic.js +126 -16
- package/build/sfcc/credentials.js +3 -2
- package/build/sfcc/hostname.js +98 -2
- package/build/sfcc/tool-wrapper.js +6 -95
- package/build/start-tickets.js +193 -29
- package/build/test-support/executor-source-files.js +200 -0
- package/build/testing-config-client.js +25 -2
- package/build/third-party-mcp-targets.js +35 -4
- package/build/v2-readiness-requirements.js +5 -1
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-credential-delivery.js +340 -0
- package/docs/EPIC-IMPLEMENTER.md +4 -4
- package/docs/install/github-app.md +79 -92
- package/package.json +1 -1
- package/build/conductor/epic-reconcile.js +0 -603
- package/build/conductor/epic-runtime.js +0 -2020
- package/build/conductor/epic-state.js +0 -774
package/build/install-bridge.js
CHANGED
|
@@ -153,6 +153,9 @@ import { discoverMcpGrantCandidates, publishMcpGrant } from "./mcp-grant-candida
|
|
|
153
153
|
import { readMcpGrant } from "./mcp-grant.js";
|
|
154
154
|
import { readEpicServerRecord, writeEpicServerRecord } from "./epic-server-record.js";
|
|
155
155
|
import { readEpicServerGuidance } from "./conductor/epic-server-guidance.js";
|
|
156
|
+
import { checkSfccUpload, createDefaultSfccUploadDeps } from "./conductor/epic-server-sfcc-upload.js";
|
|
157
|
+
import { readCredentialReferenceRecord } from "./credential-references.js";
|
|
158
|
+
import { createNodeCredentialReferenceDeps } from "./credential-references-node-deps.js";
|
|
156
159
|
import { writeEpicCapabilityStatement } from "./conductor/bridge-api-client.js";
|
|
157
160
|
import { detectClaudeLogin } from "./claude-login.js";
|
|
158
161
|
import { checkGithubSignIn } from "./github-sign-in.js";
|
|
@@ -167,6 +170,7 @@ import readline from "readline";
|
|
|
167
170
|
import { runInit, InitPreflightError, buildBridgeApiEntry, buildBridgeConfigManifest, mergeBridgeApiProfileToken, resolveInitScaffoldAssets, refreshBridgeApiPackageSpec, currentBridgePackageSpec, classifyTrackedProbeExitCode, decideExistingProjectRoot, formatUndeterminedRootReplacedWarning, } from "./init.js";
|
|
168
171
|
import { hasProjectRootMarker as sharedHasProjectRootMarker } from "./project-root.js";
|
|
169
172
|
import { resolveDocsDirForRoot } from "./project-root.js";
|
|
173
|
+
import { hasVcsWorkTreeMarker, isHomeDirectory } from "./project-root.js";
|
|
170
174
|
import { createSetupRecordWriter } from "./install-bridge-conductor-apply.js";
|
|
171
175
|
import { VERSION } from "./version.generated.js";
|
|
172
176
|
import { bridgeConfigPath, parseBridgeConfigToml, rewriteBridgeConfigRepoName, validateBridgeConfigRepoNameRepresentability, validateRepoName, } from "./bridge-config.js";
|
|
@@ -977,6 +981,18 @@ export const INSTALL_BRIDGE_GITHUB_CONNECT_PROMPT = "Connect GitHub? [y/N]: ";
|
|
|
977
981
|
* Reuses the shared connect-github flow rather than duplicating the API, polling,
|
|
978
982
|
* browser, or picker logic — there is exactly one implementation of that handshake.
|
|
979
983
|
*/
|
|
984
|
+
/**
|
|
985
|
+
* BAPI-1677 — the installer options the conductor's `installCiWorkflow` forwards, field
|
|
986
|
+
* by field. A field left out here silently reverts a sealed list to the toolchain lines.
|
|
987
|
+
*/
|
|
988
|
+
export function ciWorkflowInstallOptions(options) {
|
|
989
|
+
return {
|
|
990
|
+
dryRun: options.dryRun,
|
|
991
|
+
...(options.snapshot !== undefined ? { snapshot: options.snapshot } : {}),
|
|
992
|
+
...(options.createOnly === true ? { createOnly: true } : {}),
|
|
993
|
+
...(options.dependencyInstall !== undefined ? { dependencyInstall: options.dependencyInstall } : {}),
|
|
994
|
+
};
|
|
995
|
+
}
|
|
980
996
|
export async function offerGithubConnection(repoName, baseUrl, deps, log, session) {
|
|
981
997
|
// No prompt surface → no offer. Never assume consent on a non-interactive run.
|
|
982
998
|
if (!deps.isTTY || !deps.promptLine)
|
|
@@ -1741,11 +1757,7 @@ export function buildConductorSetupDeps(deps, log, errorLog) {
|
|
|
1741
1757
|
return captured.ok ? captured.snapshot : null;
|
|
1742
1758
|
},
|
|
1743
1759
|
readSnapshotFile: (snapshot, relPath) => readSnapshotFile(installerDeps, snapshot, relPath),
|
|
1744
|
-
installCiWorkflow: (testCommand, toolchains, options, confirmWrite) => installEpicCiWorkflow(testCommand, toolchains, {
|
|
1745
|
-
dryRun: options.dryRun,
|
|
1746
|
-
...(options.snapshot !== undefined ? { snapshot: options.snapshot } : {}),
|
|
1747
|
-
...(options.createOnly === true ? { createOnly: true } : {}),
|
|
1748
|
-
}, {
|
|
1760
|
+
installCiWorkflow: (testCommand, toolchains, options, confirmWrite) => installEpicCiWorkflow(testCommand, toolchains, ciWorkflowInstallOptions(options), {
|
|
1749
1761
|
...installerDeps,
|
|
1750
1762
|
...(options.quiet === true ? { log: () => { }, errorLog: () => { } } : {}),
|
|
1751
1763
|
confirmWrite,
|
|
@@ -1810,6 +1822,20 @@ export function buildConductorSetupDeps(deps, log, errorLog) {
|
|
|
1810
1822
|
unlink: deps.unlink,
|
|
1811
1823
|
}),
|
|
1812
1824
|
guidancePresent: async () => (await readEpicServerGuidance((rel) => deps.readFile(path.join(deps.cwd, rel)))).state === "ok",
|
|
1825
|
+
// BAPI-1667: child 2's check, called directly on the owner's checkout. It writes
|
|
1826
|
+
// nothing and contacts no network. The run-only seams it never reads stay inert.
|
|
1827
|
+
sfccUploadCheck: ({ approvedSandboxId }) => checkSfccUpload({ repoRoot: deps.cwd, env: deps.env, approvedSandboxId }, createDefaultSfccUploadDeps({
|
|
1828
|
+
env: deps.env,
|
|
1829
|
+
homedir: deps.homedir,
|
|
1830
|
+
tmpdir: os.tmpdir,
|
|
1831
|
+
cwd: () => deps.cwd,
|
|
1832
|
+
stdout: () => { },
|
|
1833
|
+
stderr: () => { },
|
|
1834
|
+
resolveRepoName: async () => null,
|
|
1835
|
+
resolveRepoRoot: () => deps.cwd,
|
|
1836
|
+
readRecord: async () => ({ state: "absent" }),
|
|
1837
|
+
})),
|
|
1838
|
+
readCredentialReferences: (repoName) => readCredentialReferenceRecord(repoName, createNodeCredentialReferenceDeps(deps.env)),
|
|
1813
1839
|
},
|
|
1814
1840
|
};
|
|
1815
1841
|
}
|
|
@@ -5574,9 +5600,11 @@ export function buildInstallBridgeLaunchStepLabel(agent) {
|
|
|
5574
5600
|
// launch materialization, and every write — so a decline can abort with nothing
|
|
5575
5601
|
// minted, exchanged, or written.
|
|
5576
5602
|
//
|
|
5577
|
-
//
|
|
5578
|
-
//
|
|
5579
|
-
//
|
|
5603
|
+
// BAPI-1664: the gate now REFUSES the home directory outright (exit 1, before the
|
|
5604
|
+
// no-`.git` prompt). For every non-home folder, declining is still a user-initiated
|
|
5605
|
+
// CANCEL, not a failure: it exits 0. A non-TTY run warns and continues, preserving
|
|
5606
|
+
// automation compatibility (legitimate non-git, greenfield installs exist, so
|
|
5607
|
+
// blocking them outright was rejected).
|
|
5580
5608
|
// ---------------------------------------------------------------------------
|
|
5581
5609
|
/** Prefix of the always-printed "where am I installing" banner. */
|
|
5582
5610
|
export const INSTALL_BRIDGE_CWD_BANNER_PREFIX = "Installing Bridge into: ";
|
|
@@ -5588,6 +5616,22 @@ export const INSTALL_BRIDGE_NO_GIT_PROMPT = `${INSTALL_BRIDGE_NO_GIT_WARNING}
|
|
|
5588
5616
|
export const INSTALL_BRIDGE_NO_GIT_ABORT = "Aborted — run install from your project root, or re-run and confirm to continue.";
|
|
5589
5617
|
/** The non-TTY form: same finding, stated as a warning, then the run continues. */
|
|
5590
5618
|
export const INSTALL_BRIDGE_NO_GIT_NONINTERACTIVE_WARNING = `Warning: ${INSTALL_BRIDGE_NO_GIT_WARNING} — continuing (non-interactive).`;
|
|
5619
|
+
/**
|
|
5620
|
+
* BAPI-1664 refusal lines. Each is ONE line; the working directory is rendered
|
|
5621
|
+
* through {@link renderDiagnosticValue} so it cannot split the diagnostic.
|
|
5622
|
+
*/
|
|
5623
|
+
export function installBridgeEpicImplementerHomeRefusal(cwd) {
|
|
5624
|
+
return (`Error: ${renderDiagnosticValue(cwd)} is your home folder, and the home folder is never a project root. ` +
|
|
5625
|
+
"Run install epic-implementer from the repository root instead.");
|
|
5626
|
+
}
|
|
5627
|
+
export function installBridgeEpicImplementerNotRepoRootRefusal(cwd) {
|
|
5628
|
+
return (`Error: ${renderDiagnosticValue(cwd)} is not a project root (the folder that holds your repository). ` +
|
|
5629
|
+
"Run install epic-implementer from that project root, where .git lives.");
|
|
5630
|
+
}
|
|
5631
|
+
export function installBridgeHomeRefusal(cwd) {
|
|
5632
|
+
return (`Error: ${renderDiagnosticValue(cwd)} is your home folder, and the home folder is not a project root. ` +
|
|
5633
|
+
"Run install from a project folder instead.");
|
|
5634
|
+
}
|
|
5591
5635
|
/**
|
|
5592
5636
|
* Existence probe for `<cwd>/.git`, delegated to the shared project-root probe
|
|
5593
5637
|
* (BAPI-818) so `--init` and `install` use exactly one marker definition. A git
|
|
@@ -5747,7 +5791,23 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5747
5791
|
// `epic-implementer` name. This nested `install epic-implementer` surface is
|
|
5748
5792
|
// untouched by that rename.
|
|
5749
5793
|
if (argv[0] === "conductor" || argv[0] === "epic-implementer") {
|
|
5750
|
-
// ---- BAPI-
|
|
5794
|
+
// ---- BAPI-1664: root guard, ahead of EVERYTHING below ----------------
|
|
5795
|
+
// Refuse the home folder, then any folder without a repository marker, before
|
|
5796
|
+
// merge-workflow handling, prerequisite assessment, refresh, credential
|
|
5797
|
+
// access, prompts, network, or writes. Checks the supplied cwd itself (no git
|
|
5798
|
+
// top-level resolution), so a checkout subdirectory is refused. stderr only.
|
|
5799
|
+
// `-h` / `--help` is let through: help writes nothing, and a user outside a
|
|
5800
|
+
// repository root still needs to read the usage text.
|
|
5801
|
+
const wantsHelp = argv.slice(1).some((arg) => arg === "-h" || arg === "--help");
|
|
5802
|
+
if (!wantsHelp && isHomeDirectory(deps.cwd, deps.homedir())) {
|
|
5803
|
+
errorLog(installBridgeEpicImplementerHomeRefusal(deps.cwd));
|
|
5804
|
+
return 1;
|
|
5805
|
+
}
|
|
5806
|
+
if (!wantsHelp && !(await hasVcsWorkTreeMarker(deps.cwd, deps.stat))) {
|
|
5807
|
+
errorLog(installBridgeEpicImplementerNotRepoRootRefusal(deps.cwd));
|
|
5808
|
+
return 1;
|
|
5809
|
+
}
|
|
5810
|
+
// ---- BAPI-1136:`install epic-implementer --merge-workflow` ----------
|
|
5751
5811
|
//
|
|
5752
5812
|
// Intercepted ahead of `parseInstallBridgeConductorArgs` on purpose. That
|
|
5753
5813
|
// parser REQUIRES at least one `--required-check` because an empty done gate
|
|
@@ -5806,6 +5866,14 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5806
5866
|
// In `--json` mode stdout is reserved for the single JSON document the
|
|
5807
5867
|
// conductor writes through `conductorDeps.log`; human narration goes to stderr.
|
|
5808
5868
|
const humanOutputSink = argv.includes("--json") ? errorLog : log;
|
|
5869
|
+
// BAPI-1650: the readiness checks still run after a refused credential, and they
|
|
5870
|
+
// read deps.env. A refused environment key must not reach them.
|
|
5871
|
+
const dropEnvironmentKey = () => {
|
|
5872
|
+
const { BAPI_API_KEY: _refused, ...kept } = deps.env;
|
|
5873
|
+
deps.env = kept;
|
|
5874
|
+
conductorDeps.env = kept;
|
|
5875
|
+
deps.startTicketsDeps = { ...deps.startTicketsDeps, env: kept };
|
|
5876
|
+
};
|
|
5809
5877
|
const conductorDeps = {
|
|
5810
5878
|
prerequisites: async (executorRequested) => {
|
|
5811
5879
|
const lookup = deps.lookupExecutable ?? defaultExecutablePresenceProbe;
|
|
@@ -5840,8 +5908,10 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5840
5908
|
// BAPI-1650: read-only approval evidence, attached only when proven.
|
|
5841
5909
|
const endpointApproval = await classifyEndpointApproval(project, resolvedBaseUrl, credential, resolveDeps);
|
|
5842
5910
|
const approval = endpointApproval !== undefined ? { endpointApproval } : {};
|
|
5843
|
-
|
|
5844
|
-
|
|
5911
|
+
if (credential.ok)
|
|
5912
|
+
return { ok: true, access: { repoName: project, baseUrl: resolvedBaseUrl, apiKey: credential.apiKey }, ...approval };
|
|
5913
|
+
dropEnvironmentKey();
|
|
5914
|
+
return { ok: false, error: "Credential validation and endpoint authorization deferred during dry run.", ...approval };
|
|
5845
5915
|
}
|
|
5846
5916
|
const parsedIdentity = parseInstallBridgeArgs(repoName ? ["--repo", repoName] : []);
|
|
5847
5917
|
if (parsedIdentity.status !== "ok")
|
|
@@ -5860,6 +5930,7 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5860
5930
|
terminal: { write: humanOutputSink, read: deps.isTTY ? deps.promptLine : undefined },
|
|
5861
5931
|
validate: async (key) => (await verifyConnectivity(deps, resolvedBaseUrl, access.access.repoName, key)).ok });
|
|
5862
5932
|
if (!settled.ok) {
|
|
5933
|
+
dropEnvironmentKey();
|
|
5863
5934
|
return { ok: false, error: settled.reason };
|
|
5864
5935
|
}
|
|
5865
5936
|
const identity = settled.identity;
|
|
@@ -6132,6 +6203,12 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
6132
6203
|
// ahead of ALL credential and configuration work so a decline costs nothing.
|
|
6133
6204
|
log(`${INSTALL_BRIDGE_CWD_BANNER_PREFIX}${deps.cwd}`);
|
|
6134
6205
|
log(`Bridge destination: ${baseUrl} (${deps.env.BAPI_BASE_URL === undefined ? "production default" : "BAPI_BASE_URL"}).`);
|
|
6206
|
+
// BAPI-1664: the home folder is never a project root. Refuse before the no-.git
|
|
6207
|
+
// prompt/warning so neither a "y" nor a non-TTY run can continue into it.
|
|
6208
|
+
if (isHomeDirectory(deps.cwd, deps.homedir())) {
|
|
6209
|
+
errorLog(installBridgeHomeRefusal(deps.cwd));
|
|
6210
|
+
return 1;
|
|
6211
|
+
}
|
|
6135
6212
|
if (!(await hasProjectRootMarker(deps))) {
|
|
6136
6213
|
if (deps.isTTY && deps.promptLine) {
|
|
6137
6214
|
let answer = "";
|
package/build/install-doctor.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import path from "path";
|
|
23
23
|
import { createReadinessCheck, createReadinessCheckSafely, } from "./readiness-check.js";
|
|
24
|
-
import { resolveBapiCredentials } from "./credential-store.js";
|
|
24
|
+
import { normalizeBoundBaseUrl, readStoredBindingState, resolveBapiCredentials } from "./credential-store.js";
|
|
25
25
|
import { detectClaudeLogin, formatClaudeLoginAdvisory } from "./claude-login.js";
|
|
26
26
|
import { getProjectJsonTargets, hostAdapterForTarget } from "./mcp-host-targets.js";
|
|
27
27
|
import { existingRegistrationKey, MCP_PACKAGE_NAME, } from "./mcp-identity.js";
|
|
@@ -341,6 +341,21 @@ function readGithubConfiguredFlag(body) {
|
|
|
341
341
|
}
|
|
342
342
|
return null;
|
|
343
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* BAPI-1650: whether a saved key may go to this address. Production needs no
|
|
346
|
+
* approval unless the key is bound elsewhere; every other address needs its own.
|
|
347
|
+
* An unreadable or invalid binding is not approval.
|
|
348
|
+
*/
|
|
349
|
+
async function savedKeyApprovedForTarget(repoName, baseUrl, deps) {
|
|
350
|
+
const target = normalizeBoundBaseUrl(baseUrl);
|
|
351
|
+
if (target === null)
|
|
352
|
+
return false;
|
|
353
|
+
const binding = await readStoredBindingState(`bapi:${repoName}`, deps);
|
|
354
|
+
if (binding.state === "bound")
|
|
355
|
+
return binding.baseUrl === target;
|
|
356
|
+
return ((binding.state === "absent" || binding.state === "no-entry") &&
|
|
357
|
+
target === normalizeBoundBaseUrl(DEFAULT_BASE_URL));
|
|
358
|
+
}
|
|
344
359
|
/**
|
|
345
360
|
* Collect the install-status checklist. Never throws; every failure path becomes
|
|
346
361
|
* a WARN or SKIP check line. Performs at most three read-only GETs, and only
|
|
@@ -387,6 +402,15 @@ export async function collectInstallStatusChecks(deps) {
|
|
|
387
402
|
stat: deps.stat,
|
|
388
403
|
stderr: () => { },
|
|
389
404
|
};
|
|
405
|
+
const pushSkippedKeyChecks = (detail) => {
|
|
406
|
+
for (const [id, label] of [
|
|
407
|
+
["connectivity", "Server connectivity"],
|
|
408
|
+
["bootstrap", "Bootstrap config fields"],
|
|
409
|
+
["indexing", "Repository indexing"],
|
|
410
|
+
]) {
|
|
411
|
+
checks.push({ id, label, status: "SKIP", detail });
|
|
412
|
+
}
|
|
413
|
+
};
|
|
390
414
|
const cred = await resolveBapiCredentials(target.repoName, credDeps);
|
|
391
415
|
if (!cred.ok) {
|
|
392
416
|
checks.push({
|
|
@@ -397,13 +421,19 @@ export async function collectInstallStatusChecks(deps) {
|
|
|
397
421
|
remediation: "set BAPI_API_KEY or persist it via /install-bridge / the credentials subcommand; " +
|
|
398
422
|
"until then the remaining install checks are skipped.",
|
|
399
423
|
});
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
424
|
+
pushSkippedKeyChecks("no credential resolved");
|
|
425
|
+
return checks;
|
|
426
|
+
}
|
|
427
|
+
if (cred.credentials.source !== "env" &&
|
|
428
|
+
!(await savedKeyApprovedForTarget(target.repoName, target.baseUrl, credDeps))) {
|
|
429
|
+
checks.push({
|
|
430
|
+
id: "credential",
|
|
431
|
+
label: "Bridge API credential",
|
|
432
|
+
status: "WARN",
|
|
433
|
+
detail: `the saved key is not approved for ${target.baseUrl}, so it was not sent`,
|
|
434
|
+
remediation: "run install-bridge against this address and allow the key when asked.",
|
|
435
|
+
});
|
|
436
|
+
pushSkippedKeyChecks("the saved key is not approved for this address");
|
|
407
437
|
return checks;
|
|
408
438
|
}
|
|
409
439
|
checks.push({
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1667 — the read-only SFCC repository detector setup uses.
|
|
3
|
+
*
|
|
4
|
+
* It reads the checkout through the existing discovery seam and returns closed
|
|
5
|
+
* tokens and booleans only. `dw.json`, `.env`, and every MCP configuration file
|
|
6
|
+
* are checked by name, never opened: the only file this module reads is
|
|
7
|
+
* `package.json`, and from it only dependency key names and whether `scripts`
|
|
8
|
+
* has a `dev` key. The MCP signal comes from the inventory setup already built.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here throws or stops setup. Evidence that could not be read is `null`,
|
|
11
|
+
* which is different from a confirmed absence.
|
|
12
|
+
*/
|
|
13
|
+
/** The closed list of dependency names that count as SFCC tooling. */
|
|
14
|
+
export const SFCC_TOOLING_PACKAGES = Object.freeze([
|
|
15
|
+
"@salesforce/b2c-cli",
|
|
16
|
+
"@salesforce/storefront-next-dev",
|
|
17
|
+
"sfcc-ci",
|
|
18
|
+
"sgmf-scripts",
|
|
19
|
+
]);
|
|
20
|
+
/** The npm package name of the Salesforce B2C DX MCP server. */
|
|
21
|
+
export const B2C_DX_MCP_PACKAGE = "@salesforce/b2c-dx-mcp";
|
|
22
|
+
/** The fixed order `signals` is reported in. */
|
|
23
|
+
const SIGNAL_ORDER = ["cartridges_dir", "dw_json", "b2c_tooling_dependency", "b2c_dx_mcp_candidate"];
|
|
24
|
+
/** True when one argument names the DX MCP package, with or without a version suffix. */
|
|
25
|
+
export function isB2cDxMcpPackageArg(arg) {
|
|
26
|
+
return arg === B2C_DX_MCP_PACKAGE || arg.startsWith(`${B2C_DX_MCP_PACKAGE}@`);
|
|
27
|
+
}
|
|
28
|
+
/** True when a definition's args name the DX MCP package. */
|
|
29
|
+
export function definitionNamesB2cDxMcp(definition) {
|
|
30
|
+
return definition.args.some(isB2cDxMcpPackageArg);
|
|
31
|
+
}
|
|
32
|
+
function ownKeys(value) {
|
|
33
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? Object.keys(value) : [];
|
|
34
|
+
}
|
|
35
|
+
/** What `package.json` shows: key names only. `null` when it could not be read or parsed. */
|
|
36
|
+
function readPackageEvidence(text) {
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = JSON.parse(text);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
45
|
+
return null;
|
|
46
|
+
const doc = parsed;
|
|
47
|
+
const names = new Set([...ownKeys(doc.dependencies), ...ownKeys(doc.devDependencies)]);
|
|
48
|
+
return {
|
|
49
|
+
tooling: SFCC_TOOLING_PACKAGES.filter((name) => names.has(name)).length,
|
|
50
|
+
devScript: ownKeys(doc.scripts).includes("dev"),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Detect an SFCC repository. A top-level `cartridges/` or `dw.json` settles it;
|
|
55
|
+
* otherwise two contributions do (each distinct tooling package counts once, and
|
|
56
|
+
* the MCP candidate counts once, so the MCP candidate alone is never enough).
|
|
57
|
+
* The answer is `false` only when unread evidence could not change it.
|
|
58
|
+
*/
|
|
59
|
+
export async function detectSfccRepository(fs, inventory) {
|
|
60
|
+
let root = null;
|
|
61
|
+
try {
|
|
62
|
+
root = await fs.listDir("");
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
root = null;
|
|
66
|
+
}
|
|
67
|
+
let cartridges = false;
|
|
68
|
+
if (root?.includes("cartridges") === true) {
|
|
69
|
+
try {
|
|
70
|
+
cartridges = (await fs.listDir("cartridges")) !== null;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
cartridges = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const dwJson = root?.includes("dw.json") === true;
|
|
77
|
+
// A readable root that does not list package.json confirms there is none. Without a
|
|
78
|
+
// listing, a failed read could be either fact, so it stays unknown.
|
|
79
|
+
let packageEvidence = null;
|
|
80
|
+
let packageKnown = root !== null && !root.includes("package.json");
|
|
81
|
+
if (!packageKnown) {
|
|
82
|
+
let text = null;
|
|
83
|
+
try {
|
|
84
|
+
text = await fs.readText("package.json");
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
text = null;
|
|
88
|
+
}
|
|
89
|
+
packageEvidence = text === null ? null : readPackageEvidence(text);
|
|
90
|
+
packageKnown = packageEvidence !== null;
|
|
91
|
+
}
|
|
92
|
+
const candidate = inventory?.candidates.some((c) => c.definitions.some(definitionNamesB2cDxMcp)) === true;
|
|
93
|
+
const tooling = packageEvidence?.tooling ?? 0;
|
|
94
|
+
const present = new Set();
|
|
95
|
+
if (cartridges)
|
|
96
|
+
present.add("cartridges_dir");
|
|
97
|
+
if (dwJson)
|
|
98
|
+
present.add("dw_json");
|
|
99
|
+
if (tooling > 0)
|
|
100
|
+
present.add("b2c_tooling_dependency");
|
|
101
|
+
if (candidate)
|
|
102
|
+
present.add("b2c_dx_mcp_candidate");
|
|
103
|
+
const contributions = tooling + (candidate ? 1 : 0);
|
|
104
|
+
let detected;
|
|
105
|
+
if (cartridges || dwJson || contributions >= 2)
|
|
106
|
+
detected = true;
|
|
107
|
+
else if (root === null)
|
|
108
|
+
detected = null;
|
|
109
|
+
else if (!packageKnown)
|
|
110
|
+
detected = null;
|
|
111
|
+
else if (inventory === null && contributions >= 1)
|
|
112
|
+
detected = null;
|
|
113
|
+
else
|
|
114
|
+
detected = false;
|
|
115
|
+
return {
|
|
116
|
+
detected,
|
|
117
|
+
signals: SIGNAL_ORDER.filter((signal) => present.has(signal)),
|
|
118
|
+
dev_script: packageEvidence !== null ? packageEvidence.devScript : packageKnown ? false : null,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1667 — the shared SFCC evidence both setup paths read: the bounded,
|
|
3
|
+
* fail-open wrapper around child 2's upload check, the names-only view of the
|
|
4
|
+
* worker credential record, and the fixed wording built from them.
|
|
5
|
+
*
|
|
6
|
+
* Nothing here refuses or stops setup. Every sentence is fixed text or a closed
|
|
7
|
+
* token: raw check results, exception text, source paths, selectors, and values
|
|
8
|
+
* never reach an answer, a prompt, or the assessment.
|
|
9
|
+
*/
|
|
10
|
+
import { SFCC_UPLOAD_CHECK_MISSING_REASONS } from "./conductor/epic-server-sfcc-upload.js";
|
|
11
|
+
import { definitionNamesB2cDxMcp } from "./install-sfcc-detection.js";
|
|
12
|
+
import { PLAYWRIGHT_PRESET_NAME } from "./mcp-presets.js";
|
|
13
|
+
/**
|
|
14
|
+
* Matches the 15-second bound child 2's `--check` form uses, so a slow CLI version
|
|
15
|
+
* probe does not read as `unknown` here when the same check passes on the command line.
|
|
16
|
+
*/
|
|
17
|
+
export const SFCC_SETUP_UPLOAD_CHECK_TIMEOUT_MS = 15_000;
|
|
18
|
+
/** Setup's own reason, added beside child 2's closed reasons. */
|
|
19
|
+
export const NO_WORKER_SANDBOX_CREDENTIAL = "no_worker_sandbox_credential";
|
|
20
|
+
/** The whole-file sandbox entry `/install-bridge` records. */
|
|
21
|
+
export const SUGGESTED_SFCC_CREDENTIAL_ENTRY = "sfcc-dw-json";
|
|
22
|
+
export const WORKER_UPLOAD_ADVISORY = "Workers cannot upload until /install-bridge records the dw.json sandbox entry.";
|
|
23
|
+
export const SANDBOX_SKIPPED_LINE = "No approved sandbox was recorded; uploads stay off.";
|
|
24
|
+
export const SANDBOX_MISMATCH_ADVISORY = "This sandbox id does not match the first DNS label of the sandbox host in dw.json; every upload will be refused with sandbox_mismatch until they match.";
|
|
25
|
+
export const CREDENTIAL_NOT_FOUND_ADVISORY = "Not found in this repository's worker credential record; workers receive it only after /install-bridge records it.";
|
|
26
|
+
export const CREDENTIAL_RECORD_UNAVAILABLE_LINE = "This repository's worker credential record is absent or unusable; run /install-bridge to record a sandbox entry.";
|
|
27
|
+
const SFCC_MISSING_TEXT = Object.freeze({
|
|
28
|
+
cli_unavailable: "the b2c CLI was not found",
|
|
29
|
+
node_too_old: "this Node.js version is too old for the b2c CLI",
|
|
30
|
+
server_missing: "no sandbox host is set in dw.json or the environment",
|
|
31
|
+
not_a_sandbox_host: "the configured host is not an SFCC sandbox host",
|
|
32
|
+
sandbox_mismatch: "the approved sandbox id does not match the configured sandbox host",
|
|
33
|
+
code_version_missing: "no code version is set",
|
|
34
|
+
credentials_missing: "no sandbox client credentials were found",
|
|
35
|
+
interactive_auth_required: "the sandbox login needs an interactive sign-in",
|
|
36
|
+
config_unreadable: "the sandbox configuration could not be read",
|
|
37
|
+
[NO_WORKER_SANDBOX_CREDENTIAL]: "no sandbox credential reaches workers (run /install-bridge)",
|
|
38
|
+
});
|
|
39
|
+
function reachesWorkerTools(entry) {
|
|
40
|
+
return entry.level === "sandbox" && entry.consumers.some((c) => c.kind === "worktree_file" || c.kind === "env");
|
|
41
|
+
}
|
|
42
|
+
/** Project a record read into names-only rows. Production entries are never listed. */
|
|
43
|
+
export function projectCredentialEvidence(read) {
|
|
44
|
+
if (read.state === "absent")
|
|
45
|
+
return { recordState: "absent", rows: [] };
|
|
46
|
+
if (read.state !== "ok")
|
|
47
|
+
return { recordState: "unusable", rows: [] };
|
|
48
|
+
const rows = [];
|
|
49
|
+
for (const entry of read.record.credentials) {
|
|
50
|
+
if (entry.level === "production")
|
|
51
|
+
continue;
|
|
52
|
+
rows.push({ name: entry.name, level: entry.level, reaches_worker_tools: reachesWorkerTools(entry) });
|
|
53
|
+
}
|
|
54
|
+
rows.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
55
|
+
return { recordState: "ok", rows };
|
|
56
|
+
}
|
|
57
|
+
/** Read the credential evidence. A failed read is `unusable`, never an error. */
|
|
58
|
+
export async function collectCredentialEvidence(read) {
|
|
59
|
+
try {
|
|
60
|
+
return projectCredentialEvidence(await read());
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return { recordState: "unusable", rows: [] };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** The closed-token view of child 2's result, or null for anything unrecognized. */
|
|
67
|
+
function readCheckResult(raw) {
|
|
68
|
+
if (raw === null || typeof raw !== "object")
|
|
69
|
+
return null;
|
|
70
|
+
const { outcome, missing } = raw;
|
|
71
|
+
if (!Array.isArray(missing))
|
|
72
|
+
return null;
|
|
73
|
+
const known = SFCC_UPLOAD_CHECK_MISSING_REASONS;
|
|
74
|
+
if (!missing.every((reason) => known.includes(reason)))
|
|
75
|
+
return null;
|
|
76
|
+
if (outcome === "ready" && missing.length === 0)
|
|
77
|
+
return { outcome, missing: [] };
|
|
78
|
+
if (outcome === "unavailable" && missing.length > 0)
|
|
79
|
+
return { outcome, missing: missing };
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Run child 2's check under the timeout. A timeout, a throw, or an unrecognized
|
|
84
|
+
* result is `unknown`, and a late result is ignored. It never rejects.
|
|
85
|
+
*/
|
|
86
|
+
export async function runSfccUploadCheck(check, input) {
|
|
87
|
+
const unknown = { state: "unknown", missing: [] };
|
|
88
|
+
let timer;
|
|
89
|
+
const deadline = new Promise((resolve) => {
|
|
90
|
+
timer = setTimeout(() => resolve(TIMED_OUT), input.timeoutMs ?? SFCC_SETUP_UPLOAD_CHECK_TIMEOUT_MS);
|
|
91
|
+
timer.unref?.();
|
|
92
|
+
});
|
|
93
|
+
let raw;
|
|
94
|
+
try {
|
|
95
|
+
raw = await Promise.race([Promise.resolve().then(() => check({ approvedSandboxId: input.approvedSandboxId })), deadline]);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return unknown;
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
clearTimeout(timer);
|
|
102
|
+
}
|
|
103
|
+
if (raw === TIMED_OUT)
|
|
104
|
+
return unknown;
|
|
105
|
+
const result = readCheckResult(raw);
|
|
106
|
+
if (result === null)
|
|
107
|
+
return unknown;
|
|
108
|
+
// Null credentials mean nothing was collected, which is not evidence that no entry exists.
|
|
109
|
+
const workerMissing = input.credentials !== null && !input.credentials.rows.some((r) => r.reaches_worker_tools);
|
|
110
|
+
const missing = workerMissing ? [...result.missing, NO_WORKER_SANDBOX_CREDENTIAL] : result.missing;
|
|
111
|
+
if (result.outcome === "ready")
|
|
112
|
+
return { state: workerMissing ? "possible_with_advisory" : "possible", missing };
|
|
113
|
+
return { state: "not_possible", missing };
|
|
114
|
+
}
|
|
115
|
+
const TIMED_OUT = Symbol("sfcc-upload-check-timed-out");
|
|
116
|
+
/** The one rule for "upload can work here", for every recommendation and optional question. */
|
|
117
|
+
export function isSfccUploadCapable(check) {
|
|
118
|
+
return check?.state === "possible" || check?.state === "possible_with_advisory";
|
|
119
|
+
}
|
|
120
|
+
/** The fixed sentence for the upload check. Empty when the check passed outright or did not run. */
|
|
121
|
+
export function describeSfccUpload(check) {
|
|
122
|
+
if (check === null || check === undefined || check.state === "possible")
|
|
123
|
+
return "";
|
|
124
|
+
if (check.state === "possible_with_advisory")
|
|
125
|
+
return WORKER_UPLOAD_ADVISORY;
|
|
126
|
+
if (check.state === "unknown")
|
|
127
|
+
return "The upload check could not run, so setup cannot say whether upload works here.";
|
|
128
|
+
return `Upload is not possible yet: ${check.missing.map((reason) => SFCC_MISSING_TEXT[reason]).join("; ")}.`;
|
|
129
|
+
}
|
|
130
|
+
/** Re-check an entered sandbox id. Returns the fixed advisory lines; it never refuses. */
|
|
131
|
+
export async function recheckSfccSandboxId(check, sandboxId, input) {
|
|
132
|
+
const result = await runSfccUploadCheck(check, { approvedSandboxId: sandboxId, ...input });
|
|
133
|
+
return result.missing.includes("sandbox_mismatch") ? [SANDBOX_MISMATCH_ADVISORY] : [];
|
|
134
|
+
}
|
|
135
|
+
/** The entry Enter selects, when the record lists it. */
|
|
136
|
+
export function suggestedCredentialEntry(credentials) {
|
|
137
|
+
return credentials?.rows.some((r) => r.name === SUGGESTED_SFCC_CREDENTIAL_ENTRY) === true ? SUGGESTED_SFCC_CREDENTIAL_ENTRY : null;
|
|
138
|
+
}
|
|
139
|
+
function describeRow(row) {
|
|
140
|
+
return `${row.name} (${row.level}, ${row.reaches_worker_tools ? "reaches workers" : "does not reach workers"})`;
|
|
141
|
+
}
|
|
142
|
+
/** The format line for the credential question. Names, levels, and reach only. */
|
|
143
|
+
export function credentialQuestionLines(credentials, defaultRef) {
|
|
144
|
+
const enter = defaultRef === null ? "" : ` Press Enter for ${defaultRef}.`;
|
|
145
|
+
const head = "Name of the worker credential entry for the sandbox account (from /install-bridge).";
|
|
146
|
+
if (credentials === null)
|
|
147
|
+
return [`${head}${enter}`];
|
|
148
|
+
if (credentials.recordState !== "ok")
|
|
149
|
+
return [`${head}${enter}`, CREDENTIAL_RECORD_UNAVAILABLE_LINE];
|
|
150
|
+
const entries = credentials.rows.length === 0 ? "none" : credentials.rows.map(describeRow).join(", ");
|
|
151
|
+
return [`${head} Entries: ${entries}.${enter}`];
|
|
152
|
+
}
|
|
153
|
+
/** The advisory for a reference the record does not list. A valid reference is always accepted. */
|
|
154
|
+
export function credentialReferenceAdvisories(credentials, reference) {
|
|
155
|
+
if (credentials === null)
|
|
156
|
+
return [];
|
|
157
|
+
if (credentials.recordState !== "ok")
|
|
158
|
+
return [CREDENTIAL_RECORD_UNAVAILABLE_LINE];
|
|
159
|
+
return credentials.rows.some((r) => r.name === reference) ? [] : [CREDENTIAL_NOT_FOUND_ADVISORY];
|
|
160
|
+
}
|
|
161
|
+
const PROJECT_ORIGIN_PREFERENCE = ["project-claude", "project-cursor"];
|
|
162
|
+
/**
|
|
163
|
+
* The definition ids to recommend for an SFCC repository: the one preferred
|
|
164
|
+
* b2c-dx-mcp definition from this repository's own MCP configuration, and the
|
|
165
|
+
* built-in Playwright preset, when each is offered. Sorted. The inventory, its ids,
|
|
166
|
+
* and its fingerprint are read and never changed.
|
|
167
|
+
*/
|
|
168
|
+
export function sfccRecommendedDefinitionIds(inventory) {
|
|
169
|
+
const definitions = inventory.candidates.flatMap((c) => c.definitions.map((definition) => ({ name: c.name, definition })));
|
|
170
|
+
const ids = [];
|
|
171
|
+
for (const origin of PROJECT_ORIGIN_PREFERENCE) {
|
|
172
|
+
const matches = definitions
|
|
173
|
+
.filter(({ definition }) => definition.origins.includes(origin) && definitionNamesB2cDxMcp(definition))
|
|
174
|
+
.map(({ definition }) => definition.id)
|
|
175
|
+
.sort();
|
|
176
|
+
if (matches.length > 0) {
|
|
177
|
+
ids.push(matches[0]);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const preset = definitions.find(({ name, definition }) => name === PLAYWRIGHT_PRESET_NAME && definition.origins.includes("preset"));
|
|
182
|
+
if (preset !== undefined)
|
|
183
|
+
ids.push(preset.definition.id);
|
|
184
|
+
return ids.sort();
|
|
185
|
+
}
|