@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
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-repository state records kept OUTSIDE every worktree (BAPI-1545).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Three record families live here, one file per repository:
|
|
5
5
|
*
|
|
6
6
|
* - `mcp-grants/<repo>.json` — the owner-approved MCP grant (`mcp-grant.ts`).
|
|
7
7
|
* - `epic-server/<repo>.json` — the epic-server record child 3 writes
|
|
8
8
|
* (`epic-server-record.ts` owns the contract).
|
|
9
|
+
* - `worker-credentials/<repo>.json` — the owner-approved credential
|
|
10
|
+
* references, names and source locations only, never values
|
|
11
|
+
* (`credential-references.ts` owns the contract).
|
|
9
12
|
*
|
|
10
|
-
*
|
|
13
|
+
* All sit beside the user credential store, under `~/.config/bridge` (or
|
|
11
14
|
* `$XDG_CONFIG_HOME/bridge` when that is set, exactly as the credential store
|
|
12
15
|
* resolves it). A worker's worktree never contains them, so nothing a worker
|
|
13
16
|
* commits or edits inside its checkout can change them.
|
|
@@ -66,8 +66,11 @@ const JAVASCRIPT_LOCKFILES = [
|
|
|
66
66
|
"bun.lockb",
|
|
67
67
|
];
|
|
68
68
|
const PYTHON_LOCKFILES = ["uv.lock", "poetry.lock", "requirements.txt"];
|
|
69
|
-
/**
|
|
70
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Python manifests that name dependencies but that Bridge does not install.
|
|
71
|
+
* BAPI-1698: exported so dependency discovery can name them as coverage gaps.
|
|
72
|
+
*/
|
|
73
|
+
export const UNSUPPORTED_PYTHON_MANIFESTS = ["pyproject.toml", "Pipfile", "setup.py", "environment.yml"];
|
|
71
74
|
/** Whether the set provisions nothing. */
|
|
72
75
|
export function hasNoProvisionedToolchain(toolchains) {
|
|
73
76
|
return toolchains.javascript === null && toolchains.python === null && toolchains.go === null;
|
|
@@ -530,15 +533,21 @@ export function installArgvForJavaScript(js) {
|
|
|
530
533
|
}
|
|
531
534
|
/**
|
|
532
535
|
* BAPI-1551 — the fixed install argv for a Python toolchain. pip's argv is kept
|
|
533
|
-
* for the description only: a bare `pip install` targets whatever
|
|
534
|
-
* first on `PATH`, so a dependency refresh never proposes
|
|
536
|
+
* for the toolchain description only: a bare `pip install` targets whatever
|
|
537
|
+
* interpreter is first on `PATH`, so a dependency refresh never proposes THIS
|
|
538
|
+
* argv. BAPI-1698: discovery may instead propose a separate, checkout-local
|
|
539
|
+
* `.venv` bootstrap for pip (see `proposeDependencyInstall`); this function and
|
|
540
|
+
* its description are unchanged by that.
|
|
541
|
+
*
|
|
542
|
+
* BAPI-1677 — `extras` holds only keys the install target declares. With none, every
|
|
543
|
+
* caller's argv is byte-identical to before. pip takes none.
|
|
535
544
|
*/
|
|
536
|
-
export function installArgvForPython(py) {
|
|
545
|
+
export function installArgvForPython(py, extras = []) {
|
|
537
546
|
switch (py.manager) {
|
|
538
547
|
case "uv":
|
|
539
|
-
return ["uv", "sync", "--frozen"];
|
|
548
|
+
return ["uv", "sync", "--frozen", ...extras.flatMap((name) => ["--extra", name])];
|
|
540
549
|
case "poetry":
|
|
541
|
-
return ["poetry", "install"];
|
|
550
|
+
return ["poetry", "install", ...extras.flatMap((name) => ["-E", name])];
|
|
542
551
|
case "pip":
|
|
543
552
|
return ["pip", "install", "-r", "requirements.txt"];
|
|
544
553
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Saved Epic Implementer test commands: built-MCP `config_field` driver (BAPI-1699).
|
|
4
|
+
*
|
|
5
|
+
* A Python `subprocess` boundary that lets a real pytest suite drive the REAL built
|
|
6
|
+
* MCP server (`build/index.js`) over its normal stdio transport against the real
|
|
7
|
+
* FastAPI `/jira/config-field/*` routes, using only the registered `config_field`
|
|
8
|
+
* tool. It is test-support infrastructure, not an MCP tool.
|
|
9
|
+
*
|
|
10
|
+
* node saved-commands-config-field-driver.js <commandsJsonPath> <resultsJsonPath>
|
|
11
|
+
*
|
|
12
|
+
* `commandsJsonPath` holds `{ baseUrl, apiKey, repoName, calls: [...] }` and each call is
|
|
13
|
+
* `{ operation: "get" | "update", field_name, value? }`. Credentials arrive through the
|
|
14
|
+
* file and the child environment only, never argv. One MCP session serves every call;
|
|
15
|
+
* the results file gets `{ tools: string[], results: [{ isError, text }] }`. stdout stays
|
|
16
|
+
* empty so a caller never captures incidental noise.
|
|
17
|
+
*/
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
22
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
23
|
+
async function main() {
|
|
24
|
+
const [commandsPath, resultsPath] = process.argv.slice(2);
|
|
25
|
+
if (!commandsPath || !resultsPath) {
|
|
26
|
+
process.stderr.write("usage: saved-commands-config-field-driver <commandsJsonPath> <resultsJsonPath>\n");
|
|
27
|
+
process.exit(2);
|
|
28
|
+
}
|
|
29
|
+
const input = JSON.parse(fs.readFileSync(commandsPath, "utf-8"));
|
|
30
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
31
|
+
const transport = new StdioClientTransport({
|
|
32
|
+
command: "node",
|
|
33
|
+
args: [path.join(here, "..", "index.js")],
|
|
34
|
+
env: {
|
|
35
|
+
...process.env,
|
|
36
|
+
BAPI_BASE_URL: input.baseUrl,
|
|
37
|
+
BAPI_API_KEY: input.apiKey,
|
|
38
|
+
BAPI_REPO_NAME: input.repoName,
|
|
39
|
+
BAPI_MCP_UPDATE_CHECK_ENABLED: "false",
|
|
40
|
+
},
|
|
41
|
+
stderr: "ignore",
|
|
42
|
+
});
|
|
43
|
+
const client = new Client({ name: "saved-commands-contract-driver", version: "0.0.1" });
|
|
44
|
+
const results = [];
|
|
45
|
+
let tools = [];
|
|
46
|
+
try {
|
|
47
|
+
await client.connect(transport);
|
|
48
|
+
tools = (await client.listTools()).tools.map((t) => t.name);
|
|
49
|
+
for (const call of input.calls) {
|
|
50
|
+
const response = (await client.callTool({ name: "config_field", arguments: { ...call } }));
|
|
51
|
+
const text = (response.content ?? []).map((c) => (c.type === "text" ? c.text ?? "" : "")).join("\n");
|
|
52
|
+
results.push({ isError: response.isError === true, text });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await transport.close();
|
|
57
|
+
}
|
|
58
|
+
const tmp = `${resultsPath}.tmp`;
|
|
59
|
+
fs.writeFileSync(tmp, JSON.stringify({ tools, results }), "utf-8");
|
|
60
|
+
fs.renameSync(tmp, resultsPath);
|
|
61
|
+
}
|
|
62
|
+
main().catch((error) => {
|
|
63
|
+
process.stderr.write(`saved-commands-config-field-driver failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
});
|
package/build/setup-epic.js
CHANGED
|
@@ -2784,6 +2784,41 @@ export async function readCanonicalParseTruth(access, fetchImpl) {
|
|
|
2784
2784
|
}
|
|
2785
2785
|
return { ok: true, cutCommitSha: evidence.sourceCommitSha };
|
|
2786
2786
|
}
|
|
2787
|
+
/**
|
|
2788
|
+
* Classify a remote epic branch against an authoritative target SHA. One decision,
|
|
2789
|
+
* shared by the preview and the create-time preflight.
|
|
2790
|
+
*
|
|
2791
|
+
* Remote reads and commit-object acquisition only: it reads the remote tip, makes
|
|
2792
|
+
* both commit objects resolvable locally with a read-only fetch by SHA, and
|
|
2793
|
+
* compares ancestry. It never updates a branch (local or remote), and it never
|
|
2794
|
+
* trusts a local `origin/{base}` tracking ref: the target is supplied by the caller.
|
|
2795
|
+
*/
|
|
2796
|
+
export async function classifyRemoteEpicBranch(deps, branch, targetSha) {
|
|
2797
|
+
const unreadable = (tipSha, detail) => ({ status: "unknown", tipSha, detail });
|
|
2798
|
+
try {
|
|
2799
|
+
const head = await readRemoteBranchHead(deps, branch);
|
|
2800
|
+
if (!head.ok)
|
|
2801
|
+
return unreadable(null, head.error);
|
|
2802
|
+
if (head.sha === null)
|
|
2803
|
+
return { status: "absent" };
|
|
2804
|
+
const tipSha = head.sha;
|
|
2805
|
+
if (tipSha === targetSha)
|
|
2806
|
+
return { status: "at_target", tipSha };
|
|
2807
|
+
if (!(await ensureCommitResolvableLocally(deps, targetSha)) ||
|
|
2808
|
+
!(await ensureCommitResolvableLocally(deps, tipSha))) {
|
|
2809
|
+
return unreadable(tipSha, `Could not resolve origin/${branch} (${tipSha}) and ${targetSha} locally.`);
|
|
2810
|
+
}
|
|
2811
|
+
const ancestry = await runGit(deps, ["merge-base", "--is-ancestor", tipSha, targetSha]);
|
|
2812
|
+
if (ancestry.exitCode === 0)
|
|
2813
|
+
return { status: "behind_target", tipSha, targetSha };
|
|
2814
|
+
if (ancestry.exitCode === 1)
|
|
2815
|
+
return { status: "has_own_commits", tipSha, targetSha };
|
|
2816
|
+
return unreadable(tipSha, `Could not compare origin/${branch} (${tipSha}) with ${targetSha}.`);
|
|
2817
|
+
}
|
|
2818
|
+
catch {
|
|
2819
|
+
return unreadable(null, `Could not classify origin/${branch}.`);
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2787
2822
|
/** The strict subset of `SetupEpicDeps` the shared cut protocol consumes. */
|
|
2788
2823
|
function cutProtocolDeps(deps, runCommand) {
|
|
2789
2824
|
return {
|
|
@@ -2942,10 +2977,13 @@ function recordStoredRunFacts(sink, storedPolicy) {
|
|
|
2942
2977
|
* same exit codes — and differs only in what it hands back.
|
|
2943
2978
|
*/
|
|
2944
2979
|
export async function runSetupEpicWorkflow(argv, overrides = {}, handoff) {
|
|
2945
|
-
const sink = {};
|
|
2980
|
+
const sink = { createRequestAttempted: false };
|
|
2946
2981
|
const exitCode = await executeSetupEpic(argv, overrides, sink, handoff);
|
|
2947
2982
|
return {
|
|
2948
2983
|
exitCode,
|
|
2984
|
+
...(exitCode !== 0 && sink.createRequestAttempted === false && sink.existingRunEstablished !== true &&
|
|
2985
|
+
sink.epicRunId === undefined ? { refusedBeforeCreate: true } : {}),
|
|
2986
|
+
...(sink.branchMove !== undefined ? { branchMove: { ...sink.branchMove } } : {}),
|
|
2949
2987
|
...(sink.epicRunId !== undefined ? { epicRunId: sink.epicRunId } : {}),
|
|
2950
2988
|
...(sink.epicRunId !== undefined ? { runExists: true } : {}),
|
|
2951
2989
|
...(sink.runCreated !== undefined ? { runCreated: sink.runCreated } : {}),
|
|
@@ -2955,6 +2993,8 @@ export async function runSetupEpicWorkflow(argv, overrides = {}, handoff) {
|
|
|
2955
2993
|
...(sink.runPosture !== undefined ? { runPosture: sink.runPosture } : {}),
|
|
2956
2994
|
...(sink.launchOutcome !== undefined ? { launchOutcome: sink.launchOutcome } : {}),
|
|
2957
2995
|
...(sink.runStatus !== undefined ? { runStatus: sink.runStatus } : {}),
|
|
2996
|
+
...(sink.storedPlanHash !== undefined ? { storedPlanHash: sink.storedPlanHash } : {}),
|
|
2997
|
+
...(sink.orderingEdgesAdded !== undefined ? { orderingEdgesAdded: sink.orderingEdgesAdded } : {}),
|
|
2958
2998
|
...(sink.observations !== undefined && sink.observations.length > 0
|
|
2959
2999
|
? { observations: [...sink.observations] }
|
|
2960
3000
|
: {}),
|
|
@@ -3172,8 +3212,10 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
|
|
|
3172
3212
|
existingNotificationSink = state?.notification_sink ?? null;
|
|
3173
3213
|
// BAPI-1581 — the live run's governing facts, captured the moment it resolves
|
|
3174
3214
|
// so every later early return (attach-only, refusal, failure) still has them.
|
|
3175
|
-
if (existingRunId !== null)
|
|
3215
|
+
if (existingRunId !== null) {
|
|
3176
3216
|
recordStoredRunFacts(runIdSink, existingPolicy);
|
|
3217
|
+
runIdSink.existingRunEstablished = true;
|
|
3218
|
+
}
|
|
3177
3219
|
const existingBase = existingPolicy && typeof existingPolicy === "object"
|
|
3178
3220
|
? existingPolicy.base_branch
|
|
3179
3221
|
: undefined;
|
|
@@ -3945,20 +3987,79 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
|
|
|
3945
3987
|
`created and no branch was changed.`);
|
|
3946
3988
|
return 1;
|
|
3947
3989
|
}
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3990
|
+
if (existingRunId === null) {
|
|
3991
|
+
// A NEW run: classify the leftover branch against the exact cut.
|
|
3992
|
+
const branch = effectiveFeatureBranch;
|
|
3993
|
+
const classified = await classifyRemoteEpicBranch(gitDeps, branch, cutCommitSha);
|
|
3994
|
+
if (classified.status === "has_own_commits") {
|
|
3995
|
+
deps.errorLog(`origin/${branch} already exists at ${classified.tipSha} and holds commits that are not in ` +
|
|
3996
|
+
`the canonical indexed commit ${cutCommitSha}. setup-epic never force-updates an existing ` +
|
|
3997
|
+
`branch. Inspect it with: git log origin/${scopeBaseBranch}..origin/${branch}. ` +
|
|
3998
|
+
`Then finish that work, or delete the branch with: git push origin --delete ${branch}. ` +
|
|
3999
|
+
`No run was created and no branch was changed.`);
|
|
4000
|
+
return 1;
|
|
4001
|
+
}
|
|
4002
|
+
if (classified.status === "unknown") {
|
|
4003
|
+
deps.errorLog(classified.tipSha === null
|
|
4004
|
+
? `${classified.detail} No run was created and no branch was changed.`
|
|
4005
|
+
: `origin/${branch} already exists at ${classified.tipSha}, and its relationship to the ` +
|
|
4006
|
+
`canonical indexed commit ${cutCommitSha} could not be established. setup-epic never ` +
|
|
4007
|
+
`force-updates an existing branch: delete it, or finish the previous run first. ` +
|
|
4008
|
+
`No run was created and no branch was changed.`);
|
|
4009
|
+
return 1;
|
|
4010
|
+
}
|
|
4011
|
+
if (classified.status === "behind_target") {
|
|
4012
|
+
// One plain push (no force, no leading '+'). Whatever it returns, the remote
|
|
4013
|
+
// is re-read once; only an exact match with the cut lets setup continue.
|
|
4014
|
+
try {
|
|
4015
|
+
await runGit(gitDeps, ["push", "origin", `${cutCommitSha}:refs/heads/${branch}`]);
|
|
4016
|
+
}
|
|
4017
|
+
catch { /* judged by the re-read below */ }
|
|
4018
|
+
let reread;
|
|
4019
|
+
try {
|
|
4020
|
+
reread = await readRemoteBranchHead(gitDeps, branch);
|
|
4021
|
+
}
|
|
4022
|
+
catch {
|
|
4023
|
+
reread = { ok: false, error: `git ls-remote could not read origin/${branch}.` };
|
|
4024
|
+
}
|
|
4025
|
+
if (!reread.ok || reread.sha !== cutCommitSha) {
|
|
4026
|
+
deps.errorLog(!reread.ok
|
|
4027
|
+
? `Tried to move origin/${branch} from ${classified.tipSha} to the canonical indexed commit ` +
|
|
4028
|
+
`${cutCommitSha}, but could not read the branch afterwards. Check it with: ` +
|
|
4029
|
+
`git ls-remote origin refs/heads/${branch}. No run was created.`
|
|
4030
|
+
: reread.sha === null
|
|
4031
|
+
? `Tried to move origin/${branch} to the canonical indexed commit ${cutCommitSha}, but the ` +
|
|
4032
|
+
`branch is now absent. No run was created.`
|
|
4033
|
+
: `Tried to move origin/${branch} to the canonical indexed commit ${cutCommitSha}, but it is ` +
|
|
4034
|
+
`now at ${reread.sha}. No run was created.`);
|
|
4035
|
+
return 1;
|
|
4036
|
+
}
|
|
4037
|
+
runIdSink.branchMove = { branch, from: classified.tipSha, to: cutCommitSha };
|
|
4038
|
+
say(`Branch: moved origin/${branch} from ${classified.tipSha} to the cut commit ${cutCommitSha}`);
|
|
4039
|
+
}
|
|
4040
|
+
else {
|
|
4041
|
+
say(classified.status === "absent"
|
|
4042
|
+
? `Branch: origin/${branch} is absent; it will be cut at ${cutCommitSha}`
|
|
4043
|
+
: `Branch: origin/${branch} already sits at the cut commit ${cutCommitSha}`);
|
|
4044
|
+
}
|
|
3952
4045
|
}
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
4046
|
+
else {
|
|
4047
|
+
// A reused run keeps its prior cut validation unchanged: no branch is ever moved.
|
|
4048
|
+
const remoteHead = await readRemoteBranchHead(gitDeps, effectiveFeatureBranch);
|
|
4049
|
+
if (!remoteHead.ok) {
|
|
4050
|
+
deps.errorLog(`${remoteHead.error} No run was created and no branch was changed.`);
|
|
4051
|
+
return 1;
|
|
4052
|
+
}
|
|
4053
|
+
if (remoteHead.sha !== null && remoteHead.sha !== cutCommitSha) {
|
|
4054
|
+
deps.errorLog(`origin/${effectiveFeatureBranch} already exists at ${remoteHead.sha}, which is not the ` +
|
|
4055
|
+
`canonical indexed commit ${cutCommitSha}. setup-epic never force-updates an existing ` +
|
|
4056
|
+
`branch: delete it, or finish the previous run first. No run was created and no branch was changed.`);
|
|
4057
|
+
return 1;
|
|
4058
|
+
}
|
|
4059
|
+
say(remoteHead.sha === null
|
|
4060
|
+
? `Branch: origin/${effectiveFeatureBranch} is absent; it will be cut at ${cutCommitSha}`
|
|
4061
|
+
: `Branch: origin/${effectiveFeatureBranch} already sits at the cut commit ${cutCommitSha}`);
|
|
3958
4062
|
}
|
|
3959
|
-
say(remoteHead.sha === null
|
|
3960
|
-
? `Branch: origin/${effectiveFeatureBranch} is absent; it will be cut at ${cutCommitSha}`
|
|
3961
|
-
: `Branch: origin/${effectiveFeatureBranch} already sits at the cut commit ${cutCommitSha}`);
|
|
3962
4063
|
}
|
|
3963
4064
|
const result = {
|
|
3964
4065
|
epic_run_id: existingRunId ?? "",
|
|
@@ -4161,6 +4262,8 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
|
|
|
4161
4262
|
: { epicKey: opts.epicKey };
|
|
4162
4263
|
let createResponse;
|
|
4163
4264
|
try {
|
|
4265
|
+
// From here a create request may commit even if its response is lost.
|
|
4266
|
+
runIdSink.createRequestAttempted = true;
|
|
4164
4267
|
createResponse = await createEpicRunWithDisposition(access, createRequest, deps.fetch);
|
|
4165
4268
|
}
|
|
4166
4269
|
catch (createErr) {
|
|
@@ -4388,7 +4491,7 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
|
|
|
4388
4491
|
// and a fresh probe would just re-confirm what a prior run already ensured
|
|
4389
4492
|
// or deferred). Non-fatal in every outcome: setup-epic's provisioning
|
|
4390
4493
|
// workflow (plan storage, approval, scope polling) proceeds unchanged.
|
|
4391
|
-
if (cut.branchCreated && scopeBaseBranch !== null) {
|
|
4494
|
+
if ((cut.branchCreated || runIdSink.branchMove !== undefined) && scopeBaseBranch !== null) {
|
|
4392
4495
|
const ghRunner = deps.epicIntegrationGh ?? createProductionEpicIntegrationGhRunner();
|
|
4393
4496
|
let outcome;
|
|
4394
4497
|
try {
|
|
@@ -4426,8 +4529,15 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
|
|
|
4426
4529
|
result.plan_stored = true;
|
|
4427
4530
|
runIdSink.planStored = true;
|
|
4428
4531
|
const serverHash = stored?.plan_hash;
|
|
4429
|
-
if (typeof serverHash === "string")
|
|
4532
|
+
if (typeof serverHash === "string") {
|
|
4430
4533
|
result.plan_hash = serverHash;
|
|
4534
|
+
runIdSink.storedPlanHash = serverHash;
|
|
4535
|
+
}
|
|
4536
|
+
// BAPI-1706 — optional: an older server omits it, and absence stays absence.
|
|
4537
|
+
const edgesAdded = stored?.ordering_edges_added;
|
|
4538
|
+
if (typeof edgesAdded === "number" && Number.isSafeInteger(edgesAdded) && edgesAdded >= 0) {
|
|
4539
|
+
runIdSink.orderingEdgesAdded = edgesAdded;
|
|
4540
|
+
}
|
|
4431
4541
|
say(`Plan: stored v${plan.plan_version}`);
|
|
4432
4542
|
}
|
|
4433
4543
|
catch (err) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* first-pick. Secret values (client_secret, tokens) are never included in
|
|
8
8
|
* any returned or thrown string — only source and target are reported.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { ensureGitInfoExcludedSerialized } from "../git-exclude-lock.js";
|
|
11
11
|
import { canonicalizeSfccHostname, formatSafeHost } from "./hostname.js";
|
|
12
12
|
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
13
13
|
import path from "path";
|
|
@@ -57,7 +57,8 @@ async function loadDwJson(deps) {
|
|
|
57
57
|
const mk = deps.mkdir ?? ((p, opts) => mkdir(p, opts));
|
|
58
58
|
// Ensure dw.json is excluded from git tracking.
|
|
59
59
|
try {
|
|
60
|
-
|
|
60
|
+
// BAPI-1647: serialized with every other Bridge exclude writer.
|
|
61
|
+
await ensureGitInfoExcludedSerialized(cwd, DW_JSON, { readFile: rf, writeFile: wf, mkdir: mk });
|
|
61
62
|
}
|
|
62
63
|
catch {
|
|
63
64
|
// Non-fatal — continue even if we can't update .git/info/exclude.
|
package/build/sfcc/hostname.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `canonicalizeSfccHostname` lives here so the target boundary
|
|
5
5
|
* (`tool-wrapper.ts`), the credential resolver, and `check_permissions` all
|
|
6
|
-
* canonicalize and display hosts the same way.
|
|
7
|
-
* so
|
|
6
|
+
* canonicalize and display hosts the same way. It also owns the approved
|
|
7
|
+
* sandbox-host policy so the credential scan can reuse it without importing
|
|
8
|
+
* tool configuration or credential resolution. `tool-wrapper.ts` re-exports
|
|
9
|
+
* these so its public import surface is unchanged.
|
|
8
10
|
*/
|
|
9
11
|
/** Longest hostname echoed in a diagnostic. */
|
|
10
12
|
export const MAX_DIAGNOSTIC_HOST_LENGTH = 120;
|
|
@@ -65,3 +67,97 @@ export function formatSafeHost(raw) {
|
|
|
65
67
|
? `${canonical.slice(0, MAX_DIAGNOSTIC_HOST_LENGTH)}…`
|
|
66
68
|
: canonical;
|
|
67
69
|
}
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// Sandbox host policy
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
/**
|
|
74
|
+
* The DNS suffix every approved sandbox form shares.
|
|
75
|
+
*
|
|
76
|
+
* Every SFCC developer-sandbox hostname evidenced anywhere in this repository —
|
|
77
|
+
* `credentials.ts`'s JSDoc, the install guide's prerequisites, the BAPI-399
|
|
78
|
+
* live smoke-test record, and the existing test fixtures — lives under this
|
|
79
|
+
* suffix. Legacy `*.demandware.net` hosts are deliberately NOT accepted: that
|
|
80
|
+
* domain covers sandbox, staging, development, and production instances alike
|
|
81
|
+
* with no suffix that separates them, so admitting it would reintroduce exactly
|
|
82
|
+
* the unbounded target this boundary exists to close. It appears in this repo
|
|
83
|
+
* only as a test fixture, never in production code or the SFCC install docs.
|
|
84
|
+
*/
|
|
85
|
+
const SFCC_DX_SUFFIX = ".dx.commercecloud.salesforce.com";
|
|
86
|
+
/**
|
|
87
|
+
* First labels that name a non-sandbox environment on the B2C platform.
|
|
88
|
+
*
|
|
89
|
+
* Checked against the leading label of every candidate, so a host like
|
|
90
|
+
* `production-zzrf.dx.commercecloud.salesforce.com` or
|
|
91
|
+
* `staging-zzrf.sandbox.us01.dx.commercecloud.salesforce.com` is refused even
|
|
92
|
+
* though it would otherwise satisfy a form below. This is belt-and-braces: form
|
|
93
|
+
* B alone would already admit `production-001`, and a named production instance
|
|
94
|
+
* is precisely the target the ticket was filed about.
|
|
95
|
+
*/
|
|
96
|
+
const RESERVED_ENVIRONMENT_LABELS = [
|
|
97
|
+
"production",
|
|
98
|
+
"prod",
|
|
99
|
+
"staging",
|
|
100
|
+
"stg",
|
|
101
|
+
"development",
|
|
102
|
+
];
|
|
103
|
+
/**
|
|
104
|
+
* Human-readable description of every accepted form, for the refusal envelope
|
|
105
|
+
* and the documentation contract test. Keep in sync with
|
|
106
|
+
* `isApprovedSfccSandboxHost` — the tests assert both directions.
|
|
107
|
+
*/
|
|
108
|
+
export const APPROVED_SANDBOX_HOST_FORMS = [
|
|
109
|
+
"<realm>-<nnn>.sandbox.<region>.dx.commercecloud.salesforce.com",
|
|
110
|
+
"<realm>-<nnn>.sandbox.dx.commercecloud.salesforce.com",
|
|
111
|
+
"<realm>-<nnn>.dx.commercecloud.salesforce.com",
|
|
112
|
+
];
|
|
113
|
+
/** Form B's leading label: an SFCC realm id followed by a numeric instance. */
|
|
114
|
+
const REALM_INSTANCE_LABEL = /^[a-z0-9]+-\d{3}$/;
|
|
115
|
+
/**
|
|
116
|
+
* Decide whether a canonical hostname is an approved developer sandbox.
|
|
117
|
+
*
|
|
118
|
+
* Matching is ANCHORED on both ends: the host must END with the platform suffix
|
|
119
|
+
* and the labels in front of it must form one of the shapes below. This is the
|
|
120
|
+
* property a substring test lacks — `.includes(".sandbox.")` matches
|
|
121
|
+
* `zzzz-001.sandbox.evil.example.com`, whose registrable domain is not
|
|
122
|
+
* Salesforce's at all.
|
|
123
|
+
*
|
|
124
|
+
* Form A — explicit sandbox label, with or without a region:
|
|
125
|
+
* `zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com`
|
|
126
|
+
* `zzzz-001.sandbox.dx.commercecloud.salesforce.com`
|
|
127
|
+
* Form B — realm + numeric instance, the on-demand sandbox form this project
|
|
128
|
+
* actually smoke-tested against (`docs/BAPI-399-sfcc-mcp-smoke-test.md`
|
|
129
|
+
* records sandbox `zyis-001`):
|
|
130
|
+
* `zyis-001.dx.commercecloud.salesforce.com`
|
|
131
|
+
*
|
|
132
|
+
* Form B is required for correctness, not convenience: without it the boundary
|
|
133
|
+
* would refuse the very sandbox this repository documents itself using, and a
|
|
134
|
+
* safety check that blocks the intended workflow gets disabled rather than
|
|
135
|
+
* obeyed. It is kept safe by requiring the `<realm>-<nnn>` shape (named
|
|
136
|
+
* environments such as `production-zzrf` do not match) and by the reserved-label
|
|
137
|
+
* check.
|
|
138
|
+
*
|
|
139
|
+
* Anything not matching — including every `*.demandware.net` host and any other
|
|
140
|
+
* registrable domain — is refused. Widening this set is a deliberate decision,
|
|
141
|
+
* not a bug fix: the ticket's Decision 1(b), an explicit per-instance opt-in, is
|
|
142
|
+
* the sanctioned way to reach an instance this policy does not recognize.
|
|
143
|
+
*/
|
|
144
|
+
export function isApprovedSfccSandboxHost(canonical) {
|
|
145
|
+
if (!canonical.endsWith(SFCC_DX_SUFFIX))
|
|
146
|
+
return false;
|
|
147
|
+
const prefix = canonical.slice(0, -SFCC_DX_SUFFIX.length);
|
|
148
|
+
if (prefix === "")
|
|
149
|
+
return false;
|
|
150
|
+
const labels = prefix.split(".");
|
|
151
|
+
const first = labels[0];
|
|
152
|
+
for (const reserved of RESERVED_ENVIRONMENT_LABELS) {
|
|
153
|
+
if (first === reserved || first.startsWith(`${reserved}-`))
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
// Form A: <label>.sandbox[.<region>]
|
|
157
|
+
if ((labels.length === 2 || labels.length === 3) && labels[1] === "sandbox")
|
|
158
|
+
return true;
|
|
159
|
+
// Form B: <realm>-<nnn>
|
|
160
|
+
if (labels.length === 1 && REALM_INSTANCE_LABEL.test(first))
|
|
161
|
+
return true;
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
@@ -65,104 +65,15 @@ import { SFCC_VERSIONS, getSfccVersionConfig } from "./config.js";
|
|
|
65
65
|
import { publishSfccVersion } from "./tools-configured.js";
|
|
66
66
|
import { resolveSfccCredentials } from "./credentials.js";
|
|
67
67
|
import { formatSfccFailure } from "./sfcc-result.js";
|
|
68
|
-
import { canonicalizeSfccHostname, formatSafeHost } from "./hostname.js";
|
|
69
|
-
// `canonicalizeSfccHostname` moved to hostname.ts;
|
|
70
|
-
// importers of this module are unaffected.
|
|
71
|
-
export { canonicalizeSfccHostname };
|
|
68
|
+
import { APPROVED_SANDBOX_HOST_FORMS, canonicalizeSfccHostname, formatSafeHost, isApprovedSfccSandboxHost, } from "./hostname.js";
|
|
69
|
+
// `canonicalizeSfccHostname` and the sandbox-host policy moved to hostname.ts;
|
|
70
|
+
// re-exported so existing importers of this module are unaffected.
|
|
71
|
+
export { APPROVED_SANDBOX_HOST_FORMS, canonicalizeSfccHostname, isApprovedSfccSandboxHost };
|
|
72
72
|
// ---------------------------------------------------------------------------
|
|
73
73
|
// Hostname policy
|
|
74
74
|
// ---------------------------------------------------------------------------
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
* Every SFCC developer-sandbox hostname evidenced anywhere in this repository —
|
|
79
|
-
* `credentials.ts`'s JSDoc, the install guide's prerequisites, the BAPI-399
|
|
80
|
-
* live smoke-test record, and the existing test fixtures — lives under this
|
|
81
|
-
* suffix. Legacy `*.demandware.net` hosts are deliberately NOT accepted: that
|
|
82
|
-
* domain covers sandbox, staging, development, and production instances alike
|
|
83
|
-
* with no suffix that separates them, so admitting it would reintroduce exactly
|
|
84
|
-
* the unbounded target this boundary exists to close. It appears in this repo
|
|
85
|
-
* only as a test fixture, never in production code or the SFCC install docs.
|
|
86
|
-
*/
|
|
87
|
-
const SFCC_DX_SUFFIX = ".dx.commercecloud.salesforce.com";
|
|
88
|
-
/**
|
|
89
|
-
* First labels that name a non-sandbox environment on the B2C platform.
|
|
90
|
-
*
|
|
91
|
-
* Checked against the leading label of every candidate, so a host like
|
|
92
|
-
* `production-zzrf.dx.commercecloud.salesforce.com` or
|
|
93
|
-
* `staging-zzrf.sandbox.us01.dx.commercecloud.salesforce.com` is refused even
|
|
94
|
-
* though it would otherwise satisfy a form below. This is belt-and-braces: form
|
|
95
|
-
* B alone would already admit `production-001`, and a named production instance
|
|
96
|
-
* is precisely the target the ticket was filed about.
|
|
97
|
-
*/
|
|
98
|
-
const RESERVED_ENVIRONMENT_LABELS = [
|
|
99
|
-
"production",
|
|
100
|
-
"prod",
|
|
101
|
-
"staging",
|
|
102
|
-
"stg",
|
|
103
|
-
"development",
|
|
104
|
-
];
|
|
105
|
-
/**
|
|
106
|
-
* Human-readable description of every accepted form, for the refusal envelope
|
|
107
|
-
* and the documentation contract test. Keep in sync with
|
|
108
|
-
* `isApprovedSfccSandboxHost` — the tests assert both directions.
|
|
109
|
-
*/
|
|
110
|
-
export const APPROVED_SANDBOX_HOST_FORMS = [
|
|
111
|
-
"<realm>-<nnn>.sandbox.<region>.dx.commercecloud.salesforce.com",
|
|
112
|
-
"<realm>-<nnn>.sandbox.dx.commercecloud.salesforce.com",
|
|
113
|
-
"<realm>-<nnn>.dx.commercecloud.salesforce.com",
|
|
114
|
-
];
|
|
115
|
-
/** Form B's leading label: an SFCC realm id followed by a numeric instance. */
|
|
116
|
-
const REALM_INSTANCE_LABEL = /^[a-z0-9]+-\d{3}$/;
|
|
117
|
-
/**
|
|
118
|
-
* Decide whether a canonical hostname is an approved developer sandbox.
|
|
119
|
-
*
|
|
120
|
-
* Matching is ANCHORED on both ends: the host must END with the platform suffix
|
|
121
|
-
* and the labels in front of it must form one of the shapes below. This is the
|
|
122
|
-
* property a substring test lacks — `.includes(".sandbox.")` matches
|
|
123
|
-
* `zzzz-001.sandbox.evil.example.com`, whose registrable domain is not
|
|
124
|
-
* Salesforce's at all.
|
|
125
|
-
*
|
|
126
|
-
* Form A — explicit sandbox label, with or without a region:
|
|
127
|
-
* `zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com`
|
|
128
|
-
* `zzzz-001.sandbox.dx.commercecloud.salesforce.com`
|
|
129
|
-
* Form B — realm + numeric instance, the on-demand sandbox form this project
|
|
130
|
-
* actually smoke-tested against (`docs/BAPI-399-sfcc-mcp-smoke-test.md`
|
|
131
|
-
* records sandbox `zyis-001`):
|
|
132
|
-
* `zyis-001.dx.commercecloud.salesforce.com`
|
|
133
|
-
*
|
|
134
|
-
* Form B is required for correctness, not convenience: without it the boundary
|
|
135
|
-
* would refuse the very sandbox this repository documents itself using, and a
|
|
136
|
-
* safety check that blocks the intended workflow gets disabled rather than
|
|
137
|
-
* obeyed. It is kept safe by requiring the `<realm>-<nnn>` shape (named
|
|
138
|
-
* environments such as `production-zzrf` do not match) and by the reserved-label
|
|
139
|
-
* check.
|
|
140
|
-
*
|
|
141
|
-
* Anything not matching — including every `*.demandware.net` host and any other
|
|
142
|
-
* registrable domain — is refused. Widening this set is a deliberate decision,
|
|
143
|
-
* not a bug fix: the ticket's Decision 1(b), an explicit per-instance opt-in, is
|
|
144
|
-
* the sanctioned way to reach an instance this policy does not recognize.
|
|
145
|
-
*/
|
|
146
|
-
export function isApprovedSfccSandboxHost(canonical) {
|
|
147
|
-
if (!canonical.endsWith(SFCC_DX_SUFFIX))
|
|
148
|
-
return false;
|
|
149
|
-
const prefix = canonical.slice(0, -SFCC_DX_SUFFIX.length);
|
|
150
|
-
if (prefix === "")
|
|
151
|
-
return false;
|
|
152
|
-
const labels = prefix.split(".");
|
|
153
|
-
const first = labels[0];
|
|
154
|
-
for (const reserved of RESERVED_ENVIRONMENT_LABELS) {
|
|
155
|
-
if (first === reserved || first.startsWith(`${reserved}-`))
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
// Form A: <label>.sandbox[.<region>]
|
|
159
|
-
if ((labels.length === 2 || labels.length === 3) && labels[1] === "sandbox")
|
|
160
|
-
return true;
|
|
161
|
-
// Form B: <realm>-<nnn>
|
|
162
|
-
if (labels.length === 1 && REALM_INSTANCE_LABEL.test(first))
|
|
163
|
-
return true;
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
75
|
+
// The sandbox-host policy (`isApprovedSfccSandboxHost`,
|
|
76
|
+
// `APPROVED_SANDBOX_HOST_FORMS`) lives in hostname.ts and is re-exported above.
|
|
166
77
|
/**
|
|
167
78
|
* The one refusal envelope every SFCC tool returns for an unapproved target.
|
|
168
79
|
*
|