@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.
Files changed (123) hide show
  1. package/README.md +14 -7
  2. package/build/agent-launchers/claude-executor-adapter.js +12 -0
  3. package/build/agent-launchers/prompt.js +9 -21
  4. package/build/agents.generated.js +4 -4
  5. package/build/authored-plan.js +542 -0
  6. package/build/bridge-config.js +7 -1
  7. package/build/bridge-permissions.js +11 -0
  8. package/build/command-provisioning.js +4 -3
  9. package/build/commands.generated.js +6 -6
  10. package/build/conductor/bridge-api-client.js +692 -47
  11. package/build/conductor/command-drift.js +1 -1
  12. package/build/conductor/declared-extras.js +335 -0
  13. package/build/conductor/doctor.js +2 -0
  14. package/build/conductor/driver-pass-output.js +104 -0
  15. package/build/conductor/driver-pass.js +571 -0
  16. package/build/conductor/epic-branch-ci-inspection.js +61 -16
  17. package/build/conductor/epic-implementer-cli.js +370 -93
  18. package/build/conductor/epic-server-sfcc-upload.js +1567 -0
  19. package/build/conductor/epic-server-sfcc.js +58 -80
  20. package/build/conductor/epic-server.js +57 -4
  21. package/build/conductor/gate-discovery.js +253 -13
  22. package/build/conductor/gate-settings-review.js +58 -25
  23. package/build/conductor/launch-plan.js +58 -12
  24. package/build/conductor/open-decision-phrases.js +50 -0
  25. package/build/conductor/prerequisite-inputs.js +181 -14
  26. package/build/connect-github-api.js +18 -0
  27. package/build/connect-github.js +35 -18
  28. package/build/credential-delivery.js +280 -0
  29. package/build/credential-launch-safety.js +142 -0
  30. package/build/credential-materialization.js +91 -16
  31. package/build/credential-references-node-deps.js +29 -0
  32. package/build/credential-references.js +1394 -0
  33. package/build/credential-references.test-fixtures.js +211 -0
  34. package/build/credential-scan-conventions.js +145 -0
  35. package/build/credential-scan.js +517 -0
  36. package/build/credential-store.js +50 -0
  37. package/build/credentials-cli.js +252 -3
  38. package/build/dependency-install-declarations.js +47 -1
  39. package/build/docs.generated.js +8 -1
  40. package/build/doctor.js +41 -0
  41. package/build/drive-epic.js +684 -49
  42. package/build/epic-branch-ci-summary.js +18 -1
  43. package/build/epic-capability-statement.js +71 -3
  44. package/build/epic-ci-workflow-drift.js +52 -13
  45. package/build/epic-ci-workflow-install.js +31 -6
  46. package/build/epic-ci-workflow-v3.js +273 -0
  47. package/build/epic-ci-workflow.js +129 -7
  48. package/build/epic-implementer-bin.js +288 -83
  49. package/build/epic-implementer-bundle-cli.js +61 -0
  50. package/build/epic-implementer-claude-hook-bin.js +1 -1
  51. package/build/epic-implementer-env.js +3 -4
  52. package/build/epic-integration-pr.js +5 -2
  53. package/build/epic-launch-context.js +102 -7
  54. package/build/epic-server-record.js +30 -15
  55. package/build/executor/completion-contract.js +24 -1
  56. package/build/executor/credential-delivery-step.js +168 -0
  57. package/build/executor/deps.js +3 -1
  58. package/build/executor/env.js +39 -1
  59. package/build/executor/epic-server-context.js +23 -7
  60. package/build/executor/gate-qualification-job.js +193 -23
  61. package/build/executor/gate-qualification-tests-ran.js +232 -0
  62. package/build/executor/guarded-fast-forward-push.js +13 -8
  63. package/build/executor/job-runner.js +167 -738
  64. package/build/executor/job-type-wrappers.js +734 -0
  65. package/build/executor/permissions.js +85 -3
  66. package/build/executor/preflight.js +6 -2
  67. package/build/executor/process-containment.js +8 -1
  68. package/build/executor/prompt-spec.js +37 -3
  69. package/build/executor/required-verification.js +28 -2
  70. package/build/executor/runner.js +4 -1
  71. package/build/executor/types.js +9 -0
  72. package/build/executor/worker-database.js +6 -1
  73. package/build/executor/worker-guard-hook.js +24 -2
  74. package/build/executor-launch.js +4 -2
  75. package/build/generated/ticket-status.js +20 -0
  76. package/build/git-exclude-lock.js +187 -0
  77. package/build/index.js +589 -326
  78. package/build/install-bridge-conductor-answers.js +112 -22
  79. package/build/install-bridge-conductor-apply.js +38 -1
  80. package/build/install-bridge-conductor-assessment.js +482 -53
  81. package/build/install-bridge-conductor-compact.js +29 -2
  82. package/build/install-bridge-conductor-contracts.js +10 -1
  83. package/build/install-bridge-conductor-gate.js +379 -89
  84. package/build/install-bridge-conductor-setup.js +46 -8
  85. package/build/install-bridge-conductor-trial-report.js +170 -0
  86. package/build/install-bridge-conductor.js +925 -141
  87. package/build/install-bridge.js +88 -11
  88. package/build/install-doctor.js +38 -8
  89. package/build/install-sfcc-detection.js +120 -0
  90. package/build/install-sfcc-setup.js +185 -0
  91. package/build/mcp-grant-candidates.js +108 -96
  92. package/build/mcp-invoke.js +168 -4
  93. package/build/mcp-provisioning.js +21 -4
  94. package/build/mcp-server-invocation.js +13 -0
  95. package/build/merge-workflow-install.js +9 -1
  96. package/build/pipelines.generated.js +8 -7
  97. package/build/plan-generation.js +17 -0
  98. package/build/plane/status.js +8 -2
  99. package/build/printed-remedy-commands.js +59 -0
  100. package/build/project-root.js +40 -0
  101. package/build/readme.generated.js +1 -1
  102. package/build/repository-state-paths.js +5 -2
  103. package/build/repository-toolchains.js +16 -7
  104. package/build/scripts/saved-commands-config-field-driver.js +65 -0
  105. package/build/setup-epic.js +126 -16
  106. package/build/sfcc/credentials.js +3 -2
  107. package/build/sfcc/hostname.js +98 -2
  108. package/build/sfcc/tool-wrapper.js +6 -95
  109. package/build/start-tickets.js +193 -29
  110. package/build/test-support/executor-source-files.js +200 -0
  111. package/build/testing-config-client.js +25 -2
  112. package/build/third-party-mcp-targets.js +35 -4
  113. package/build/v2-readiness-requirements.js +5 -1
  114. package/build/version.generated.js +3 -3
  115. package/build/with-credentials.js +208 -0
  116. package/build/worker-guard-hook-bin.js +2 -2
  117. package/build/worktree-credential-delivery.js +340 -0
  118. package/docs/EPIC-IMPLEMENTER.md +4 -4
  119. package/docs/install/github-app.md +79 -92
  120. package/package.json +1 -1
  121. package/build/conductor/epic-reconcile.js +0 -603
  122. package/build/conductor/epic-runtime.js +0 -2020
  123. package/build/conductor/epic-state.js +0 -774
@@ -1,23 +1,26 @@
1
1
  /**
2
- * SFCC shared-active-version mode (BAPI-1546).
2
+ * SFCC shared-active-version policy (BAPI-1546, reworked by BAPI-1669).
3
3
  *
4
- * There is no local server and no turns. The run uses the ONE sandbox approved
5
- * at setup. The driver uploads the epic's code, branched from base, onto that
6
- * sandbox's active code version at run start; each worker uploads its own
7
- * branch's changes onto the same active version as it works. Briefly seeing
8
- * other workers' changes is accepted.
4
+ * There is no local server and no turns in `sfcc_shared_active` mode. The run
5
+ * uses the ONE sandbox approved at setup. The driver uploads the whole cartridge
6
+ * tree at the epic head at run start (`epic-server sfcc-upload --full`) and
7
+ * records a baseline. Each worker uploads only the cartridge files its branch
8
+ * changed (`epic-server sfcc-upload --ticket <KEY> --head <SHA>`) onto the same
9
+ * code version as it works. Briefly seeing other workers' changes is accepted.
9
10
  *
10
- * Uploads go through the granted SFCC MCP or CLI, which resolves the sandbox
11
- * account's credential reference outside every worktree. No credential value is
12
- * ever an argument here, and none reaches a prompt, the tally, or evidence.
11
+ * Upload is independent of the epic-server mode: it needs only an approved
12
+ * sandbox in the record. The mode only picks where browser checks run. A `head`
13
+ * in upload evidence names the source commit of THIS invocation's uploaded files.
14
+ * It is not proof that the whole shared version equals that commit.
13
15
  *
14
- * The testable rules live here, behind injected uploader and check seams, and
15
- * the worker prompt states them from these same constants:
16
+ * No credential value is ever an argument, and none reaches a prompt, the tally,
17
+ * or evidence. The testable rules live in `epic-server-sfcc-upload.ts`. The
18
+ * worker prompt states the same rules from the constants below:
16
19
  *
17
20
  * - every check runs after the worker's OWN upload;
18
21
  * - a failed check is retried exactly ONCE, after a FRESH upload;
19
22
  * - evidence is labeled `shared_active_version` and carries each upload's
20
- * start and end time;
23
+ * code version, source head, and start and end time;
21
24
  * - a failed upload is a missing server (`no_live_server`, hand-off eligible);
22
25
  * - a check that still fails after the retry is a real verification failure
23
26
  * and is never relabeled unrunnable because the sandbox is shared.
@@ -28,80 +31,55 @@ export const SFCC_EVIDENCE_LABEL = "shared_active_version";
28
31
  export const SFCC_CHECK_RETRIES = 1;
29
32
  /** The hand-off cause for a failed upload. */
30
33
  export const SFCC_UPLOAD_FAILURE_CAUSE = "no_live_server";
31
- const SHA_RE = /^[0-9a-f]{40}$/;
34
+ /** The pinned b2c CLI used when the repository has no local bin. */
35
+ export const SFCC_B2C_CLI_PINNED_PACKAGE = "@salesforce/b2c-cli@2.10.2";
36
+ /** The minimum Node version for the pinned npx fallback. */
37
+ export const SFCC_B2C_NPX_MIN_NODE = "22.16.0";
38
+ // Worker form: cumulative b2c budget, per-call cap, and whole-command ceiling.
39
+ export const SFCC_UPLOAD_WORKER_BUDGET_SECONDS = 300;
40
+ export const SFCC_UPLOAD_WORKER_CALL_SECONDS = 120;
41
+ /** The longest a worker upload command can run before it prints. The prompt and the spawn env both use it. */
42
+ export const SFCC_UPLOAD_WORKER_COMMAND_SECONDS = 660;
43
+ // Full (driver) form.
44
+ export const SFCC_UPLOAD_FULL_BUDGET_SECONDS = 900;
45
+ export const SFCC_UPLOAD_FULL_CALL_SECONDS = 600;
46
+ export const SFCC_UPLOAD_FULL_COMMAND_SECONDS = 1020;
47
+ // Lock.
48
+ export const SFCC_UPLOAD_LOCK_WAIT_SECONDS = 300;
49
+ export const SFCC_UPLOAD_FULL_LOCK_WAIT_SECONDS = 60;
50
+ export const SFCC_UPLOAD_LOCK_POLL_SECONDS = 2;
51
+ export const SFCC_UPLOAD_LOCK_MAX_HOLD_SECONDS = 960;
52
+ /** The largest one archive may be before any b2c mutation. */
53
+ export const SFCC_UPLOAD_MAX_ARCHIVE_BYTES = 64 * 1024 * 1024;
54
+ /** The most remote deletes one worker run sends. */
55
+ export const SFCC_UPLOAD_MAX_WORKER_DELETES = 50;
32
56
  /**
33
- * Run one SFCC check under the shared-active-version rules: upload, check, and
34
- * only if that check fails, one fresh upload and exactly one retry. The upload
35
- * always targets the APPROVED sandbox; a request for any other sandbox is refused.
57
+ * The shared upload sentences, for both the SFCC and the local-with-sandbox
58
+ * worker texts so they never drift. Single-line, and free of `;`, quotes, and
59
+ * apostrophes, like the other launch-prompt instructions.
36
60
  */
37
- export async function runSfccSharedActiveCheck(input) {
38
- if (input.sandboxId !== input.approved.sandbox_id)
39
- return { outcome: "refused", reason: "sandbox_mismatch" };
40
- if (!SHA_RE.test(input.head))
41
- return { outcome: "refused", reason: "invalid_head" };
42
- const evidence = {
43
- label: SFCC_EVIDENCE_LABEL,
44
- sandbox_id: input.approved.sandbox_id,
45
- worker_head: input.head,
46
- uploads: [],
47
- check_attempts: 0,
48
- first_check: "not_run",
49
- };
50
- const upload = async () => {
51
- const started = input.now().toISOString();
52
- let ok = false;
53
- try {
54
- ok = (await input.uploader.upload({
55
- sandbox_id: input.approved.sandbox_id,
56
- credential_ref: input.approved.credential_ref,
57
- head: input.head,
58
- })).ok;
59
- }
60
- catch {
61
- ok = false;
62
- }
63
- evidence.uploads.push({ started_at: started, ended_at: input.now().toISOString(), ok });
64
- return ok;
65
- };
66
- const check = async () => {
67
- evidence.check_attempts += 1;
68
- try {
69
- return (await input.check.run()).passed;
70
- }
71
- catch {
72
- return false;
73
- }
74
- };
75
- if (!(await upload()))
76
- return { outcome: "unavailable", cause: SFCC_UPLOAD_FAILURE_CAUSE, evidence };
77
- const first = await check();
78
- evidence.first_check = first ? "passed" : "failed";
79
- if (first)
80
- return { outcome: "passed", evidence };
81
- for (let retry = 0; retry < SFCC_CHECK_RETRIES; retry++) {
82
- // The retry follows a FRESH upload of the worker's own head.
83
- if (!(await upload()))
84
- return { outcome: "unavailable", cause: SFCC_UPLOAD_FAILURE_CAUSE, evidence };
85
- if (await check())
86
- return { outcome: "passed", evidence };
87
- }
88
- // Still failing after the retry: a real failure, never relabeled unrunnable.
89
- return { outcome: "failed", evidence };
61
+ export function buildSfccUploadWorkerText(ticketKey, commandSeconds) {
62
+ return ("Commit your work first. Before each e2e_tests or rendered_ui_review check, run " +
63
+ "epic-implementer epic-server sfcc-upload --ticket " + ticketKey + " --head <your full head SHA> through the " +
64
+ "epic-implementer launcher on your PATH, in the foreground, with a command timeout of at least " + commandSeconds +
65
+ " seconds. It uploads only the cartridge files your branch changed onto the shared sandbox code version. " +
66
+ "Outcome uploaded or nothing_to_upload means run the check. That is permission to run it and not proof that it passes. " +
67
+ "Never upload any other way and never put a credential value in a command. Other workers upload onto the same " +
68
+ "version, so if a check fails, rerun the upload once and retry that check exactly " + SFCC_CHECK_RETRIES +
69
+ " time, no more. Label the step evidence " + SFCC_EVIDENCE_LABEL + " and record each upload code_version, head, " +
70
+ "and start and end times. Any other upload outcome means rerun the same command once as the corrected invocation. " +
71
+ "If that also fails, record the step escalated with a hand-off whose cause is " + SFCC_UPLOAD_FAILURE_CAUSE +
72
+ ", quoting the command, its output, and your head SHA. Nothing parks for this. A check that still fails after " +
73
+ "the retry is a real verification failure. Record it as failed and never relabel it unrunnable because the " +
74
+ "sandbox is shared.");
90
75
  }
91
76
  /**
92
77
  * The SFCC worker paragraph, generated from the constants above so the prompt
93
78
  * and the rules cannot drift. Single-line, and free of `;`, quotes, and
94
- * apostrophes, like the other launch-prompt instructions.
79
+ * apostrophes.
95
80
  */
96
- export function buildSfccWorkerPolicyText(origin) {
81
+ export function buildSfccWorkerPolicyText(origin, ticketKey, commandSeconds) {
97
82
  return ("Epic server, SFCC shared active version: there is no local epic server and there are no turns. " +
98
- "Browser checks run against the approved sandbox storefront at " + origin + ". Before each e2e_tests " +
99
- "or rendered_ui_review check, upload your own branch changes onto the sandbox active code version through " +
100
- "the granted SFCC MCP or CLI, never with a credential value in a command. Other workers upload onto the " +
101
- "same version, so if a check fails, do one fresh upload of your own head and retry that check exactly " +
102
- SFCC_CHECK_RETRIES + " time, no more. Label the step evidence " + SFCC_EVIDENCE_LABEL + " and record each " +
103
- "upload start and end time and your head SHA. If an upload fails, that is an unavailable server: record the " +
104
- "step escalated with a hand-off whose cause is " + SFCC_UPLOAD_FAILURE_CAUSE + " under the hand-off rules " +
105
- "above. A check that still fails after the retry is a real verification failure. Record it as failed and " +
106
- "never relabel it unrunnable because the sandbox is shared.");
83
+ "Browser checks run against the approved sandbox storefront at " + origin + ". " +
84
+ buildSfccUploadWorkerText(ticketKey, commandSeconds));
107
85
  }
@@ -15,6 +15,12 @@
15
15
  *
16
16
  * epic-server turn acquire --ticket <KEY> --head <SHA> --wait <seconds>
17
17
  * epic-server turn release --lease <handle>
18
+ * epic-server sfcc-upload --ticket <KEY> --head <SHA>
19
+ *
20
+ * SFCC upload verbs (BAPI-1669; work in any epic-server mode):
21
+ *
22
+ * epic-server sfcc-upload --full --epic <KEY> --epic-run-id <id> --head <SHA> (driver)
23
+ * epic-server sfcc-upload --check (read-only)
18
24
  *
19
25
  * Intentional output is one JSON document on stdout; a failure is one sanitized
20
26
  * line on stderr. Exit codes are 0 and 1. Nothing printed ever carries a login,
@@ -42,7 +48,8 @@ import { fetchEpicRunState, resolveConductorBridgeApiAccess } from "./bridge-api
42
48
  import { readMcpGrant } from "../mcp-grant.js";
43
49
  import { PLAYWRIGHT_PRESET_NAME } from "../mcp-presets.js";
44
50
  export { readEpicServerRecord, writeEpicServerRecord, validateEpicServerRecord, } from "../epic-server-record.js";
45
- export { SFCC_CHECK_RETRIES, SFCC_EVIDENCE_LABEL, runSfccSharedActiveCheck, buildSfccWorkerPolicyText, } from "./epic-server-sfcc.js";
51
+ export { SFCC_CHECK_RETRIES, SFCC_EVIDENCE_LABEL, buildSfccUploadWorkerText, buildSfccWorkerPolicyText, } from "./epic-server-sfcc.js";
52
+ import { createDefaultSfccUploadDeps, runSfccUpload, } from "./epic-server-sfcc-upload.js";
46
53
  /** The private helper launch action. Absent from usage. */
47
54
  export const EPIC_SERVER_HELPER_ACTION = "__helper";
48
55
  /** Default and ceiling for a worker's bounded turn wait. */
@@ -63,6 +70,10 @@ export function getEpicServerUsage() {
63
70
  "Worker verbs (run id from BRIDGE_EPIC_SERVER_RUN_ID):",
64
71
  " turn acquire --ticket <KEY> --head <SHA> --wait <seconds>",
65
72
  " turn release --lease <handle>",
73
+ "SFCC verbs:",
74
+ " sfcc-upload --ticket <KEY> --head <SHA> Upload this branch's changed cartridge files (worker)",
75
+ " sfcc-upload --full --epic <KEY> --epic-run-id <id> --head <SHA> Upload the whole cartridge tree and record a baseline (driver)",
76
+ " sfcc-upload --check Say, with no network call, whether upload is possible",
66
77
  ].join("\n");
67
78
  }
68
79
  const TICKET_RE = /^[A-Z][A-Z0-9_]{0,19}-\d{1,9}$/;
@@ -154,6 +165,43 @@ export function parseEpicServerArgs(argv) {
154
165
  }
155
166
  return bad("turn takes acquire or release");
156
167
  }
168
+ case "sfcc-upload": {
169
+ const malformed = "sfcc-upload takes exactly one of: --ticket <KEY> --head <SHA> | --full --epic <KEY> --epic-run-id <id> --head <SHA> | --check";
170
+ if (rest.length === 0)
171
+ return bad(malformed);
172
+ if (rest.includes("--check")) {
173
+ // Status-style: `--json` is accepted and ignored. Nothing else may be mixed in.
174
+ const others = rest.filter((arg) => arg !== "--check" && arg !== "--json");
175
+ if (others.length !== 0 || rest.filter((a) => a === "--check").length !== 1 || rest.filter((a) => a === "--json").length > 1)
176
+ return bad(malformed);
177
+ return { verb: "sfcc-upload", upload: { form: "check" } };
178
+ }
179
+ if (rest[0] === "--full") {
180
+ const flags = readFlags(rest.slice(1), ["--epic", "--epic-run-id", "--head"]);
181
+ if (flags === null || flags.size !== 3)
182
+ return bad(malformed);
183
+ const epicKey = flags.get("--epic");
184
+ const epicRunId = flags.get("--epic-run-id");
185
+ const head = flags.get("--head");
186
+ if (!isValidEpicKey(epicKey))
187
+ return bad("--epic is not a usable epic key");
188
+ if (!isValidEpicRunId(epicRunId))
189
+ return bad("--epic-run-id is not a usable run id");
190
+ if (!isFullCommitSha(head))
191
+ return bad("--head must be a full 40-character commit SHA");
192
+ return { verb: "sfcc-upload", upload: { form: "full", epicKey, epicRunId, head } };
193
+ }
194
+ const flags = readFlags(rest, ["--ticket", "--head"]);
195
+ if (flags === null || flags.size !== 2)
196
+ return bad(malformed);
197
+ const ticket = flags.get("--ticket");
198
+ const head = flags.get("--head");
199
+ if (!TICKET_RE.test(ticket))
200
+ return bad("--ticket is not a usable ticket key");
201
+ if (!isFullCommitSha(head))
202
+ return bad("--head must be a full 40-character commit SHA");
203
+ return { verb: "sfcc-upload", upload: { form: "worker", ticket, head } };
204
+ }
157
205
  case EPIC_SERVER_HELPER_ACTION: {
158
206
  const flags = readFlags(rest, ["--epic", "--epic-run-id", "--head", "--repo-name", "--repo-root"]);
159
207
  if (flags === null || flags.size !== 5)
@@ -340,7 +388,8 @@ async function requireLocalMode(deps, verb) {
340
388
  return { ok: false, code: 1 };
341
389
  }
342
390
  if (record.record.mode === "sfcc_shared_active") {
343
- deps.stderr(`epic-server ${verb}: this repository uses the SFCC shared active version; there is no local helper or turn`);
391
+ deps.stderr(`epic-server ${verb}: this repository uses the SFCC shared active version; it has no local helper or turn. ` +
392
+ "Uploads use epic-server sfcc-upload, which works in any mode");
344
393
  return { ok: false, code: 1 };
345
394
  }
346
395
  return { ok: true, repoName };
@@ -398,7 +447,7 @@ async function runStart(deps, cmd) {
398
447
  async function runMode(deps) {
399
448
  const repoName = await deps.resolveRepoName();
400
449
  if (repoName === null) {
401
- emit(deps, { mode: "unknown", playwright_grant: "unknown" });
450
+ emit(deps, { mode: "unknown", playwright_grant: "unknown", sfcc_sandbox: "unknown" });
402
451
  return 0;
403
452
  }
404
453
  let record;
@@ -409,7 +458,9 @@ async function runMode(deps) {
409
458
  record = { state: "unusable" };
410
459
  }
411
460
  const mode = record.state === "ok" ? record.record.mode : record.state === "absent" ? "none" : "unknown";
412
- emit(deps, { mode, playwright_grant: await deps.readPlaywrightGrant(repoName) });
461
+ // Value-free: whether the record approves a sandbox, never a field of it.
462
+ const sfccSandbox = record.state === "ok" ? (record.record.sfcc !== undefined ? "approved" : "absent") : record.state === "absent" ? "absent" : "unknown";
463
+ emit(deps, { mode, playwright_grant: await deps.readPlaywrightGrant(repoName), sfcc_sandbox: sfccSandbox });
413
464
  return 0;
414
465
  }
415
466
  async function runStatus(deps, cmd) {
@@ -582,6 +633,8 @@ export async function runEpicServerCommand(argv, deps = createDefaultEpicServerC
582
633
  return await runAcquire(deps, cmd);
583
634
  case "release":
584
635
  return await runRelease(deps, cmd);
636
+ case "sfcc-upload":
637
+ return await runSfccUpload(cmd.upload, (deps.sfccUpload ?? createDefaultSfccUploadDeps)(deps));
585
638
  case "helper":
586
639
  return await runHelper(deps, cmd);
587
640
  }
@@ -57,8 +57,9 @@ import { describeCheckEvidence } from "../check-evidence.js";
57
57
  import fs from "node:fs/promises";
58
58
  import path from "node:path";
59
59
  import { LEGACY_EPIC_IMPLEMENTER_NODE_PATH_ENV } from "../epic-implementer-env.js";
60
+ import { deriveDeclaredExtras } from "./declared-extras.js";
60
61
  import { MAX_MUST_ORDER_PATHS, canonicalMustOrderPaths, isValidMustOrderPath, } from "../dependency-install-declarations.js";
61
- import { TOOLCHAIN_CONTENT_FILES, installArgvForJavaScript, installArgvForPython, resolveRepositoryToolchains, } from "../repository-toolchains.js";
62
+ import { TOOLCHAIN_CONTENT_FILES, UNSUPPORTED_PYTHON_MANIFESTS, installArgvForJavaScript, installArgvForPython, resolveRepositoryToolchains, } from "../repository-toolchains.js";
62
63
  // ---------------------------------------------------------------------------
63
64
  // Bounds and fixed vocabularies
64
65
  // ---------------------------------------------------------------------------
@@ -1224,8 +1225,178 @@ export async function proposeWorkerDatabase(fsSeam) {
1224
1225
  }
1225
1226
  return undefined;
1226
1227
  }
1228
+ /**
1229
+ * BAPI-1698 — the ONE pip install discovery may propose: a checkout-local
1230
+ * virtual environment, recreated from scratch, then `requirements.txt` installed
1231
+ * into it with that environment's own interpreter. It never touches whatever
1232
+ * Python is first on the executor's `PATH` beyond creating the environment.
1233
+ */
1234
+ export const PIP_BOOTSTRAP_COMMAND = "python3 -m venv --clear .venv && .venv/bin/python -m pip install -r requirements.txt";
1235
+ export const PIP_BOOTSTRAP_ARGV = Object.freeze(["sh", "-c", PIP_BOOTSTRAP_COMMAND]);
1236
+ const VENV_IGNORE_DECLARATIONS = new Set([".venv", ".venv/", "/.venv", "/.venv/"]);
1237
+ /** A minimal gitignore glob test for ONE path segment: `*`, `?`, and `[...]`. */
1238
+ function globSegmentMatches(pattern, name) {
1239
+ let source = "^";
1240
+ for (let i = 0; i < pattern.length; i += 1) {
1241
+ const ch = pattern[i];
1242
+ if (ch === "*")
1243
+ source += "[^/]*";
1244
+ else if (ch === "?")
1245
+ source += "[^/]";
1246
+ else if (ch === "[") {
1247
+ const end = pattern.indexOf("]", i + 1);
1248
+ if (end === -1)
1249
+ return null;
1250
+ const body = pattern.slice(i + 1, end).replace(/^!/, "^");
1251
+ if (/[\\\]]/.test(body))
1252
+ return null;
1253
+ source += `[${body}]`;
1254
+ i = end;
1255
+ }
1256
+ else
1257
+ source += ch.replace(/[.+^${}()|]/g, "\\$&");
1258
+ }
1259
+ try {
1260
+ return new RegExp(`${source}$`).test(name);
1261
+ }
1262
+ catch {
1263
+ return null;
1264
+ }
1265
+ }
1266
+ /**
1267
+ * BAPI-1698 — whether the ROOT `.gitignore` plainly ignores `.venv`. Only the four
1268
+ * plain forms count. A `!` line after the declaration that could re-include the
1269
+ * `.venv` directory (`!.venv`, `!.*`, `!*`, `!**`...) suppresses the proposal;
1270
+ * a negation that cannot match it (`!README.md`) is ignored. Anything this reader
1271
+ * cannot interpret with certainty is `uncertain`. Global excludes are never read.
1272
+ */
1273
+ export function gitignoreVenvCoverage(text) {
1274
+ let declared = false;
1275
+ for (const raw of text.split(/\r?\n/)) {
1276
+ const line = raw.replace(/[ \t]+$/, "");
1277
+ if (line.length === 0 || line.startsWith("#"))
1278
+ continue;
1279
+ if (line.includes("\\")) {
1280
+ // An escape changes meaning in ways this reader does not model.
1281
+ if (declared)
1282
+ return "uncertain";
1283
+ continue;
1284
+ }
1285
+ if (VENV_IGNORE_DECLARATIONS.has(line)) {
1286
+ declared = true;
1287
+ continue;
1288
+ }
1289
+ if (!declared || !line.startsWith("!"))
1290
+ continue;
1291
+ let pattern = line.slice(1).replace(/^\//, "").replace(/\/$/, "");
1292
+ while (pattern.startsWith("**/"))
1293
+ pattern = pattern.slice(3);
1294
+ if (pattern.length === 0)
1295
+ continue;
1296
+ const first = pattern.split("/")[0];
1297
+ if (first === "**")
1298
+ return "negated";
1299
+ if (!/[*?[]/.test(first)) {
1300
+ if (first === ".venv")
1301
+ return "negated";
1302
+ continue;
1303
+ }
1304
+ const matches = globSegmentMatches(first, ".venv");
1305
+ if (matches === null)
1306
+ return "uncertain";
1307
+ if (matches)
1308
+ return "negated";
1309
+ }
1310
+ return declared ? "covered" : "missing";
1311
+ }
1312
+ /** BAPI-1698 — whether the isolated pip bootstrap may be proposed, and why not. */
1313
+ async function pipBootstrapEligibility(fsSeam, platform) {
1314
+ if (platform === "win32")
1315
+ return { ok: false, reason: "windows_host" };
1316
+ const text = await readBounded(fsSeam, ".gitignore");
1317
+ if (text === null)
1318
+ return { ok: false, reason: "ignore_file_missing" };
1319
+ switch (gitignoreVenvCoverage(text)) {
1320
+ case "covered":
1321
+ return { ok: true };
1322
+ case "missing":
1323
+ return { ok: false, reason: "ignore_declaration_missing" };
1324
+ case "negated":
1325
+ return { ok: false, reason: "ignore_negation" };
1326
+ default:
1327
+ return { ok: false, reason: "ignore_coverage_unestablished" };
1328
+ }
1329
+ }
1330
+ /** Root requirement files: `requirements.txt`, `requirements-dev.txt`, `requirements_test.txt`, ... */
1331
+ const ROOT_REQUIREMENTS_RE = /^requirements(?:[-_.][A-Za-z0-9_.-]+)?\.txt$/;
1332
+ /**
1333
+ * BAPI-1698 — the root dependency manifests no candidate covers. Reads ONE root
1334
+ * listing. A manifest counts as covered when a candidate watches it, or when it
1335
+ * is the project file of the manager a candidate installs with (`package.json`
1336
+ * for JavaScript, `pyproject.toml` for uv and poetry). Advisory only.
1337
+ */
1338
+ async function uncoveredRootManifests(fsSeam, candidates, pythonManager, hasJavaScript) {
1339
+ const names = (await fsSeam.listDir("")) ?? [];
1340
+ const covered = new Set(candidates.flatMap((c) => (c.cwd === "." ? c.lockfiles : [])));
1341
+ if (hasJavaScript)
1342
+ covered.add("package.json");
1343
+ if (pythonManager === "uv" || pythonManager === "poetry")
1344
+ covered.add("pyproject.toml");
1345
+ const manifests = names.filter((name) => ROOT_REQUIREMENTS_RE.test(name) ||
1346
+ UNSUPPORTED_PYTHON_MANIFESTS.includes(name) ||
1347
+ name === "package.json");
1348
+ return manifests.filter((name) => !covered.has(name)).sort(byCodeUnit);
1349
+ }
1350
+ /**
1351
+ * BAPI-1698 — the plain sentences every setup surface shows for the dependency
1352
+ * notes, pip reason, and uncovered manifests of one discovery. One sentence per
1353
+ * fact, each file named once. Advisory: none of them stops setup.
1354
+ */
1355
+ export function dependencyInstallNoteSentences(fields) {
1356
+ const sentences = [];
1357
+ for (const note of fields.dependencyInstallNotes ?? []) {
1358
+ if (note === "dependency_install_toolchain_unresolved") {
1359
+ sentences.push("The repository's toolchains could not be read with certainty, so nothing is proposed.");
1360
+ }
1361
+ else if (note === "dependency_install_pip_not_proposed") {
1362
+ sentences.push(`requirements.txt was found, but no install is proposed for it: ${PIP_REASON_TEXT[fields.dependencyInstallPipReason ?? "ignore_coverage_unestablished"]}. Workers and the test trial will not install it unless you add an entry.`);
1363
+ }
1364
+ }
1365
+ for (const file of fields.dependencyInstallUncoveredManifests ?? []) {
1366
+ sentences.push(`No proposed install covers ${file}. Workers and the test trial will not install what it lists unless you add an entry.`);
1367
+ }
1368
+ return sentences;
1369
+ }
1370
+ const PIP_REASON_TEXT = Object.freeze({
1371
+ windows_host: "the isolated .venv install is not offered on a Windows host",
1372
+ ignore_file_missing: "there is no readable .gitignore at the repository root, so a created .venv folder would not be ignored",
1373
+ ignore_declaration_missing: "the root .gitignore does not ignore .venv",
1374
+ ignore_negation: "a later line in the root .gitignore could bring .venv back",
1375
+ ignore_coverage_unestablished: "setup could not tell for certain whether the root .gitignore ignores .venv",
1376
+ });
1377
+ /**
1378
+ * BAPI-1698 — the same seam with ONE root listing shared by every proposer in a
1379
+ * discovery run (must-order paths and the uncovered-manifest scan), so adding a
1380
+ * reader never adds a second listing of the repository root.
1381
+ */
1382
+ export function withSharedRootListing(fsSeam) {
1383
+ let root;
1384
+ return {
1385
+ readText: (relPath) => fsSeam.readText(relPath),
1386
+ exists: (relPath) => fsSeam.exists(relPath),
1387
+ listDir: (relPath) => (relPath === "" ? (root ??= fsSeam.listDir("")) : fsSeam.listDir(relPath)),
1388
+ };
1389
+ }
1227
1390
  /** BAPI-1551 — the root dependency-refresh proposals and the notes on what was left out. */
1228
- export async function proposeDependencyInstall(fsSeam) {
1391
+ export async function proposeDependencyInstall(fsSeam,
1392
+ /**
1393
+ * BAPI-1677 — the learned-text snapshot extras are worked out from. Absent means no
1394
+ * derivation was asked for. `null` means the text could not be read: a limitation.
1395
+ *
1396
+ * BAPI-1698 — `platform` is the executor host's platform, defaulting to
1397
+ * `process.platform`; the isolated pip bootstrap is never proposed on Windows.
1398
+ */
1399
+ options = {}) {
1229
1400
  let resolution;
1230
1401
  try {
1231
1402
  resolution = await resolveRepositoryToolchains(toolchainReader(fsSeam));
@@ -1248,13 +1419,54 @@ export async function proposeDependencyInstall(fsSeam) {
1248
1419
  });
1249
1420
  }
1250
1421
  const py = resolution.toolchains.python;
1422
+ let limitations = [];
1423
+ let unknown = false;
1424
+ let pipReason;
1251
1425
  if (py !== null) {
1252
- if (py.manager === "pip")
1253
- notes.push("dependency_install_pip_not_proposed");
1254
- else
1255
- candidates.push({ cwd: ".", argv: installArgvForPython(py), lockfiles: [py.dependencyFile], label: py.manager });
1426
+ if (py.manager === "pip") {
1427
+ // BAPI-1698 — one checkout-local `.venv` bootstrap, only when it is portable
1428
+ // and the root `.gitignore` plainly keeps the created folder out of git.
1429
+ const eligibility = await pipBootstrapEligibility(fsSeam, options.platform ?? process.platform);
1430
+ if (eligibility.ok) {
1431
+ candidates.push({
1432
+ cwd: ".",
1433
+ argv: [...PIP_BOOTSTRAP_ARGV],
1434
+ lockfiles: [py.dependencyFile],
1435
+ label: "pip (isolated .venv)",
1436
+ });
1437
+ }
1438
+ else {
1439
+ notes.push("dependency_install_pip_not_proposed");
1440
+ pipReason = eligibility.reason;
1441
+ }
1442
+ }
1443
+ else {
1444
+ // The install target is resolved first: its own file, never a union across projects.
1445
+ const derived = options.learned === undefined
1446
+ ? null
1447
+ : await deriveDeclaredExtras({ manager: py.manager, cwd: ".", baseArgvLength: installArgvForPython(py).length }, options.learned, (relPath) => readBounded(fsSeam, relPath));
1448
+ limitations = derived?.notes ?? [];
1449
+ unknown = derived !== null && !derived.complete;
1450
+ candidates.push({
1451
+ cwd: ".",
1452
+ argv: installArgvForPython(py, derived?.extras ?? []),
1453
+ lockfiles: [py.dependencyFile],
1454
+ label: py.manager,
1455
+ ...(derived !== null && derived.evidence.length > 0 ? { extraEvidence: derived.evidence } : {}),
1456
+ });
1457
+ }
1256
1458
  }
1257
- return { candidates, notes };
1459
+ // BAPI-1698 — name every root manifest nothing covers. Root `requirements.txt`
1460
+ // is already named by the pip note when it got no proposal.
1461
+ const uncovered = (await uncoveredRootManifests(fsSeam, candidates, py?.manager ?? null, js !== null)).filter((name) => !(pipReason !== undefined && name === "requirements.txt"));
1462
+ return {
1463
+ candidates,
1464
+ notes,
1465
+ ...(pipReason !== undefined ? { pipReason } : {}),
1466
+ ...(uncovered.length > 0 ? { uncoveredManifests: uncovered } : {}),
1467
+ ...(limitations.length > 0 ? { limitations } : {}),
1468
+ ...(unknown ? { unknown: true } : {}),
1469
+ };
1258
1470
  }
1259
1471
  async function collectWorkflows(fsSeam, evidence, lookups, extras) {
1260
1472
  const entries = await fsSeam.listDir(WORKFLOWS_DIR);
@@ -1522,7 +1734,9 @@ async function queryHistory(lookupHistory, names) {
1522
1734
  * than presenting an empty provider list as a gate.
1523
1735
  */
1524
1736
  export async function discoverGate(input) {
1525
- const { fs: fsSeam, lookupHistory } = input;
1737
+ const { lookupHistory } = input;
1738
+ // BAPI-1698: one root listing for the whole run.
1739
+ const fsSeam = withSharedRootListing(input.fs);
1526
1740
  const evidence = [];
1527
1741
  const localCandidates = [];
1528
1742
  const lookups = new LookupNames();
@@ -1565,7 +1779,10 @@ export async function discoverGate(input) {
1565
1779
  const localCommandIds = providerChecks.length > 0 ? [] : validLocal.filter((c) => c.confidence === "high").map((c) => c.id);
1566
1780
  const workerEnv = resolveWorkerEnv(extras.envObservations);
1567
1781
  const hints = await proposeReproductionHints(fsSeam, providerChecks, extras.hintJobs);
1568
- const dependencyInstall = await proposeDependencyInstall(fsSeam);
1782
+ const dependencyInstall = await proposeDependencyInstall(fsSeam, {
1783
+ ...(input.learned !== undefined ? { learned: input.learned } : {}),
1784
+ ...(input.platform !== undefined ? { platform: input.platform } : {}),
1785
+ });
1569
1786
  const mustOrder = await proposeMustOrderPaths(fsSeam);
1570
1787
  return {
1571
1788
  providerCandidates,
@@ -1592,11 +1809,16 @@ export async function discoverGate(input) {
1592
1809
  * Makes no provider-history call.
1593
1810
  */
1594
1811
  export async function discoverDeclarations(input) {
1812
+ // BAPI-1698: one root listing for the whole run.
1813
+ const fsSeam = withSharedRootListing(input.fs);
1595
1814
  const extras = { envObservations: [], hintJobs: new Map(), workflowFiles: [] };
1596
- await collectWorkflows(input.fs, [], new LookupNames(), extras);
1597
- const dependencyInstall = await proposeDependencyInstall(input.fs);
1598
- const mustOrder = await proposeMustOrderPaths(input.fs);
1599
- return declarationFields(dependencyInstall, proposeCiDatabase(input.providerChecks, extras.workflowFiles), mustOrder, await proposeWorkerDatabase(input.fs));
1815
+ await collectWorkflows(fsSeam, [], new LookupNames(), extras);
1816
+ const dependencyInstall = await proposeDependencyInstall(fsSeam, {
1817
+ ...(input.learned !== undefined ? { learned: input.learned } : {}),
1818
+ ...(input.platform !== undefined ? { platform: input.platform } : {}),
1819
+ });
1820
+ const mustOrder = await proposeMustOrderPaths(fsSeam);
1821
+ return declarationFields(dependencyInstall, proposeCiDatabase(input.providerChecks, extras.workflowFiles), mustOrder, await proposeWorkerDatabase(fsSeam));
1600
1822
  }
1601
1823
  /**
1602
1824
  * BAPI-1551 — the declaration fields of a proposal. Each is present only when it
@@ -1608,6 +1830,12 @@ function declarationFields(dependencyInstall, ciDatabase, mustOrder, workerDatab
1608
1830
  ...(workerDatabase !== undefined ? { workerDatabaseProposal: workerDatabase } : {}),
1609
1831
  ...(dependencyInstall.candidates.length > 0 ? { dependencyInstallCandidates: dependencyInstall.candidates } : {}),
1610
1832
  ...(dependencyInstall.notes.length > 0 ? { dependencyInstallNotes: dependencyInstall.notes } : {}),
1833
+ ...(dependencyInstall.limitations !== undefined ? { dependencyInstallLimitations: dependencyInstall.limitations } : {}),
1834
+ ...(dependencyInstall.pipReason !== undefined ? { dependencyInstallPipReason: dependencyInstall.pipReason } : {}),
1835
+ ...(dependencyInstall.uncoveredManifests !== undefined
1836
+ ? { dependencyInstallUncoveredManifests: dependencyInstall.uncoveredManifests }
1837
+ : {}),
1838
+ ...(dependencyInstall.unknown === true ? { dependencyInstallUnknown: true } : {}),
1611
1839
  ...(ciDatabase.value !== "unknown" ? { ciDatabaseProposal: ciDatabase } : {}),
1612
1840
  ...(mustOrder.candidates.length > 0 ? { mustOrderPathCandidates: mustOrder.candidates } : {}),
1613
1841
  ...(mustOrder.overflow > 0 ? { mustOrderPathOverflow: mustOrder.overflow } : {}),
@@ -1673,3 +1901,15 @@ async function proposeReproductionHints(fsSeam, reportedChecks, hintJobs) {
1673
1901
  }
1674
1902
  return { proposed, skipped };
1675
1903
  }
1904
+ /**
1905
+ * BAPI-1677 — the test commands the repository's own files name, without any provider
1906
+ * lookup. The same collectors, in the same order, as {@link discoverGate}.
1907
+ */
1908
+ export async function discoverLocalTestCandidates(fsSeam) {
1909
+ const evidence = [];
1910
+ const localCandidates = [];
1911
+ await collectPackageJson(fsSeam, evidence, localCandidates);
1912
+ await collectMakefile(fsSeam, evidence, localCandidates);
1913
+ await collectPython(fsSeam, evidence, localCandidates);
1914
+ return localCandidates.filter((c) => isGateCommandName(c.name));
1915
+ }