@bridge_gpt/mcp-server 0.2.72 → 0.2.74
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 +5 -5
- package/build/agent-launchers/claude-executor-adapter.js +15 -0
- package/build/agents.generated.js +6 -6
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +30 -0
- package/build/ci-system-detection.js +50 -0
- package/build/ci-trigger-adapters.js +631 -0
- package/build/ci-trigger-install.js +106 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +3 -1
- package/build/command-host.js +33 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +867 -35
- package/build/conductor/bring-up-facts.js +18 -5
- package/build/conductor/command-drift-production.js +42 -17
- package/build/conductor/command-drift.js +48 -1
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +108 -21
- package/build/conductor/driver-commands.js +141 -0
- package/build/conductor/driver-guard.js +277 -0
- package/build/conductor/driver-lapse.js +321 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/driver-register.js +176 -0
- package/build/conductor/driver-release.js +174 -0
- package/build/conductor/driver-session-state.js +315 -0
- package/build/conductor/epic-branch-ci-inspection.js +281 -43
- package/build/conductor/epic-implementer-cli.js +199 -15
- package/build/conductor/epic-server-database.js +162 -0
- package/build/conductor/epic-server-guidance.js +278 -0
- package/build/conductor/epic-server-journal.js +239 -0
- package/build/conductor/epic-server-processes.js +324 -0
- package/build/conductor/epic-server-recipe.js +397 -0
- package/build/conductor/epic-server-runtime.js +1207 -0
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +85 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +647 -0
- package/build/conductor/gate-discovery.js +196 -11
- package/build/conductor/gate-settings-review.js +261 -4
- package/build/conductor/launch-need-probes.js +6 -53
- package/build/conductor/launch-plan.js +313 -156
- package/build/conductor/prerequisite-inputs.js +879 -45
- package/build/conductor/readiness-assessment.js +16 -1
- package/build/conductor/readiness-cli.js +20 -9
- package/build/conductor/readiness-prerequisites.js +28 -9
- package/build/conductor/readiness-sections.js +133 -126
- package/build/conductor/readiness.js +1 -1
- package/build/conductor/recovery-cli.js +13 -2
- package/build/conductor/tools.js +6 -5
- package/build/conductor/wait-run-attention.js +2 -2
- package/build/conductor/wait-run-cli.js +208 -22
- package/build/conductor/worker-database-doctor-inspector.js +33 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- 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 +121 -1
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +102 -1
- package/build/docs.generated.js +10 -3
- package/build/doctor.js +95 -3
- package/build/drive-epic-help.js +21 -2
- package/build/drive-epic.js +2095 -375
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +157 -0
- package/build/epic-capability-statement.js +175 -0
- package/build/epic-ci-workflow-drift.js +77 -23
- package/build/epic-ci-workflow-install.js +137 -44
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +165 -18
- package/build/epic-implementer-bin.js +2204 -56
- package/build/epic-launch-context.js +702 -0
- package/build/epic-server-record.js +288 -0
- package/build/epic-shared/bridge-client.js +11 -3
- package/build/escalation-reachability.js +43 -0
- package/build/executor/ci-fix-test-runs.js +334 -0
- package/build/executor/completion-contract.js +8 -1
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +98 -23
- package/build/executor/epic-server-context.js +157 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/http-client.js +52 -5
- package/build/executor/job-runner.js +577 -81
- package/build/executor/observation.js +8 -0
- package/build/executor/permissions.js +85 -3
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +149 -3
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-work-diagnostics.js +4 -2
- package/build/executor/required-work-ledger.js +936 -38
- package/build/executor/results.js +58 -0
- package/build/executor/terminal-mutation.js +8 -0
- package/build/executor/worker-command.js +72 -3
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +320 -101
- package/build/executor/worker-finalization.js +7 -1
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +18 -3
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +58 -4
- package/build/generated-assets-catalog.js +2 -2
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +824 -366
- package/build/init.js +26 -11
- package/build/install-bridge-conductor-answers.js +528 -0
- package/build/install-bridge-conductor-apply.js +288 -0
- package/build/install-bridge-conductor-assessment.js +1222 -0
- package/build/install-bridge-conductor-compact.js +186 -0
- package/build/install-bridge-conductor-contracts.js +72 -0
- package/build/install-bridge-conductor-gate.js +1312 -198
- package/build/install-bridge-conductor-setup.js +577 -83
- package/build/install-bridge-conductor.js +3381 -544
- package/build/install-bridge.js +280 -25
- package/build/install-doctor.js +38 -8
- package/build/install-maintenance.js +26 -3
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/launcher-config-inspection.js +162 -1
- package/build/mcp-grant-candidates.js +779 -0
- package/build/mcp-grant-doctor.js +63 -0
- package/build/mcp-grant.js +288 -0
- package/build/mcp-host-targets.js +8 -0
- package/build/mcp-identity.js +23 -0
- package/build/mcp-invoke.js +292 -15
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +155 -6
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +19 -1
- package/build/merge-workflow-install.js +243 -110
- package/build/pipelines.generated.js +7 -6
- package/build/plan-discovery.js +97 -4
- package/build/plan-execution-ledger.js +100 -7
- package/build/plan-generation-io.js +262 -0
- package/build/plan-generation.js +424 -0
- package/build/plane/build-freshness.js +6 -1
- package/build/plane/cli.js +75 -9
- package/build/plane/plane-freshness.js +17 -0
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/status.js +8 -2
- package/build/plane/terminal-run-cleanup.js +18 -4
- package/build/printed-remedy-commands.js +211 -12
- package/build/project-root.js +40 -0
- package/build/readiness-check.js +77 -0
- package/build/readiness-prerequisites.generated.js +122 -14
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +41 -0
- package/build/repository-toolchains.js +6 -3
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-epic.js +1305 -210
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +122 -4
- 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 +63 -2
- package/build/ticket-delivery-enrollment.js +9 -0
- package/build/upgrade-cli.js +85 -2
- package/build/v2-readiness-requirements.js +28 -1
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worktree-credential-delivery.js +340 -0
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/epic-implementer/getting-started.md +3 -1
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FROZEN version-3 Epic Implementer CI workflow renderer (BAPI-1677).
|
|
3
|
+
*
|
|
4
|
+
* Version 3 (BAPI-1603) runs only for epic-targeted pull requests and installs
|
|
5
|
+
* dependencies with fixed toolchain lines. Version 4 installs the commands the owner
|
|
6
|
+
* approved. Customers hold files this renderer wrote, and the drift classifier
|
|
7
|
+
* recognizes such a file only by reproducing its ENTIRE bytes, so this module is a
|
|
8
|
+
* published contract: its output for a given command and toolchain set must never
|
|
9
|
+
* change, whatever happens to the current renderer (`epic-ci-workflow.ts`). It
|
|
10
|
+
* therefore owns every literal it emits and imports nothing from the current
|
|
11
|
+
* renderer. Only the validators and the canonical toolchain serializer are shared,
|
|
12
|
+
* and a change to either of those is a compatibility break for every renderer
|
|
13
|
+
* version, not only this one.
|
|
14
|
+
*
|
|
15
|
+
* Do not edit this file to change what the workflow does. A behavior change is a
|
|
16
|
+
* new renderer version in `epic-ci-workflow.ts`, with this function left as is.
|
|
17
|
+
*
|
|
18
|
+
* Leaf module: no filesystem, network, or subprocess access.
|
|
19
|
+
*/
|
|
20
|
+
import { serializeRepositoryToolchains, validateRepositoryToolchains, } from "./repository-toolchains.js";
|
|
21
|
+
import { validateTestCommand } from "./test-command-validation.js";
|
|
22
|
+
const V3_WORKFLOW_PATH = ".github/workflows/epic-implementer-ci.yml";
|
|
23
|
+
const V3_RENDERER_VERSION = 3;
|
|
24
|
+
const V3_VERSION_MARKER_KEY = "x-bridge-ci-renderer-version";
|
|
25
|
+
const V3_TOOLCHAINS_MARKER_KEY = "x-bridge-ci-toolchains";
|
|
26
|
+
const V3_COMMAND_STEP_NAME = "Run the stored test command";
|
|
27
|
+
/** The pinned action majors version 3 wrote. */
|
|
28
|
+
const V3_ACTION_CHECKOUT = "actions/checkout@v7";
|
|
29
|
+
const V3_ACTION_SETUP_NODE = "actions/setup-node@v7";
|
|
30
|
+
const V3_ACTION_SETUP_PYTHON = "actions/setup-python@v7";
|
|
31
|
+
const V3_ACTION_SETUP_GO = "actions/setup-go@v6";
|
|
32
|
+
const V3_ACTION_SETUP_PNPM = "pnpm/action-setup@v4";
|
|
33
|
+
const V3_ACTION_SETUP_BUN = "oven-sh/setup-bun@v2";
|
|
34
|
+
const V3_ACTION_SETUP_UV = "astral-sh/setup-uv@v6";
|
|
35
|
+
/** The fixed fallbacks version 3 wrote when a repository declared nothing. */
|
|
36
|
+
const V3_NODE_FALLBACK_MAJOR = "24";
|
|
37
|
+
const V3_PYTHON_FALLBACK_MINOR = "3.12";
|
|
38
|
+
const V3_PNPM_FALLBACK_MAJOR = "10";
|
|
39
|
+
const V3_YARN_BERRY_FALLBACK_MAJOR = "4";
|
|
40
|
+
const V3_BUN_VERSION_RANGE = "1.x";
|
|
41
|
+
const V3_POETRY_VERSION = "2.1.3";
|
|
42
|
+
const V3_WORKFLOW_NAME = "epic-implementer-ci";
|
|
43
|
+
const V3_CHECK_NAME = "epic-implementer-ci / gate";
|
|
44
|
+
const V3_TEST_JOB_TIMEOUT_MINUTES = 30;
|
|
45
|
+
const V3_GATE_JOB_TIMEOUT_MINUTES = 5;
|
|
46
|
+
const V3_COMMAND_LINE_PREFIX = " run: ";
|
|
47
|
+
/**
|
|
48
|
+
* Characters `JSON.stringify` leaves raw that a YAML parser may read as a line
|
|
49
|
+
* break or a byte-order mark (YAML 1.1 treats U+0085, U+2028 and U+2029 as
|
|
50
|
+
* breaks), plus DEL and the C1 controls. They are escaped as `\uXXXX`, which is
|
|
51
|
+
* still valid JSON and a valid YAML double-quoted escape.
|
|
52
|
+
*/
|
|
53
|
+
const YAML_UNSAFE_RAW = /[\u007f-\u009f\u2028\u2029\ufeff]/g;
|
|
54
|
+
/** Encode the command as one JSON string that is also a safe YAML scalar. */
|
|
55
|
+
function encodeCommandScalar(testCommand) {
|
|
56
|
+
return JSON.stringify(testCommand).replace(YAML_UNSAFE_RAW, (ch) => "\\u" + ch.charCodeAt(0).toString(16).padStart(4, "0"));
|
|
57
|
+
}
|
|
58
|
+
function nodeSetupLines(node) {
|
|
59
|
+
return [
|
|
60
|
+
" - name: Set up Node.js",
|
|
61
|
+
" uses: " + V3_ACTION_SETUP_NODE,
|
|
62
|
+
" with:",
|
|
63
|
+
node === "fixed"
|
|
64
|
+
? ' node-version: "' + V3_NODE_FALLBACK_MAJOR + '"'
|
|
65
|
+
: " node-version-file: " + node,
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
function pythonSetupLines(python) {
|
|
69
|
+
return [
|
|
70
|
+
" - name: Set up Python",
|
|
71
|
+
" uses: " + V3_ACTION_SETUP_PYTHON,
|
|
72
|
+
" with:",
|
|
73
|
+
python === "fixed"
|
|
74
|
+
? ' python-version: "' + V3_PYTHON_FALLBACK_MINOR + '"'
|
|
75
|
+
: " python-version-file: " + python,
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
function javaScriptSetupLines(js) {
|
|
79
|
+
switch (js.manager) {
|
|
80
|
+
case "npm":
|
|
81
|
+
return [...nodeSetupLines(js.node), " - name: Install dependencies", " run: npm ci"];
|
|
82
|
+
case "pnpm":
|
|
83
|
+
return [
|
|
84
|
+
" - name: Set up pnpm",
|
|
85
|
+
" uses: " + V3_ACTION_SETUP_PNPM,
|
|
86
|
+
// A declared `packageManager` is read by the action itself at CI runtime.
|
|
87
|
+
// Passing `version:` as well makes it fail with "Multiple versions of pnpm
|
|
88
|
+
// specified" whenever the two strings differ (a Corepack `+sha` suffix is
|
|
89
|
+
// enough), so the input is given only for the fixed fallback.
|
|
90
|
+
...(js.pnpm.source === "default" ? [" with:", ' version: "' + V3_PNPM_FALLBACK_MAJOR + '"'] : []),
|
|
91
|
+
...nodeSetupLines(js.node),
|
|
92
|
+
" - name: Install dependencies",
|
|
93
|
+
" run: pnpm install --frozen-lockfile",
|
|
94
|
+
];
|
|
95
|
+
case "yarn":
|
|
96
|
+
if (js.generation === "classic") {
|
|
97
|
+
return [...nodeSetupLines(js.node), " - name: Install dependencies", " run: yarn install --frozen-lockfile"];
|
|
98
|
+
}
|
|
99
|
+
// Corepack reads a declared Yarn version from package.json at CI runtime;
|
|
100
|
+
// the activation below is only the fallback major when none is declared.
|
|
101
|
+
return [
|
|
102
|
+
...nodeSetupLines(js.node),
|
|
103
|
+
" - name: Enable Corepack",
|
|
104
|
+
" run: corepack enable",
|
|
105
|
+
" - name: Activate Yarn",
|
|
106
|
+
" run: corepack prepare yarn@" + V3_YARN_BERRY_FALLBACK_MAJOR + " --activate",
|
|
107
|
+
" - name: Install dependencies",
|
|
108
|
+
" run: yarn install --immutable",
|
|
109
|
+
];
|
|
110
|
+
case "bun":
|
|
111
|
+
return [
|
|
112
|
+
" - name: Set up Bun",
|
|
113
|
+
" uses: " + V3_ACTION_SETUP_BUN,
|
|
114
|
+
" with:",
|
|
115
|
+
' bun-version: "' + V3_BUN_VERSION_RANGE + '"',
|
|
116
|
+
" - name: Install dependencies",
|
|
117
|
+
" run: bun install --frozen-lockfile",
|
|
118
|
+
];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const PROJECT_ENVIRONMENT_PATH_LINES = [
|
|
122
|
+
" - name: Add the project environment to PATH",
|
|
123
|
+
' run: echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH"',
|
|
124
|
+
];
|
|
125
|
+
function pythonSetupLinesFor(py) {
|
|
126
|
+
const setup = pythonSetupLines(py.python);
|
|
127
|
+
switch (py.manager) {
|
|
128
|
+
case "uv":
|
|
129
|
+
return [
|
|
130
|
+
...setup,
|
|
131
|
+
" - name: Set up uv",
|
|
132
|
+
" uses: " + V3_ACTION_SETUP_UV,
|
|
133
|
+
" - name: Install dependencies",
|
|
134
|
+
" run: uv sync --frozen",
|
|
135
|
+
...PROJECT_ENVIRONMENT_PATH_LINES,
|
|
136
|
+
];
|
|
137
|
+
case "poetry":
|
|
138
|
+
return [
|
|
139
|
+
...setup,
|
|
140
|
+
" - name: Install Poetry",
|
|
141
|
+
" run: python -m pip install poetry==" + V3_POETRY_VERSION,
|
|
142
|
+
" - name: Configure Poetry",
|
|
143
|
+
" run: poetry config virtualenvs.in-project true",
|
|
144
|
+
" - name: Install dependencies",
|
|
145
|
+
" run: poetry install",
|
|
146
|
+
...PROJECT_ENVIRONMENT_PATH_LINES,
|
|
147
|
+
];
|
|
148
|
+
case "pip":
|
|
149
|
+
return [...setup, " - name: Install dependencies", " run: pip install -r requirements.txt"];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** The setup steps for a validated set, in the fixed JavaScript, Python, Go order. */
|
|
153
|
+
function toolchainSetupLines(toolchains) {
|
|
154
|
+
const lines = [];
|
|
155
|
+
if (toolchains.javascript !== null)
|
|
156
|
+
lines.push(...javaScriptSetupLines(toolchains.javascript));
|
|
157
|
+
if (toolchains.python !== null)
|
|
158
|
+
lines.push(...pythonSetupLinesFor(toolchains.python));
|
|
159
|
+
if (toolchains.go !== null) {
|
|
160
|
+
lines.push(" - name: Set up Go", " uses: " + V3_ACTION_SETUP_GO, " with:", " go-version-file: " + toolchains.go.dependencyFile);
|
|
161
|
+
}
|
|
162
|
+
return lines;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Render the version-3 workflow for `testCommand` and the resolved `toolchains`.
|
|
166
|
+
* Deterministic: the same inputs always give the same bytes. Throws
|
|
167
|
+
* `TestCommandValidationError` for a bad command and `RepositoryToolchainError`
|
|
168
|
+
* for a toolchain set outside the closed vocabulary.
|
|
169
|
+
*/
|
|
170
|
+
export function renderEpicCiWorkflowV3(testCommand, toolchains) {
|
|
171
|
+
const command = validateTestCommand(testCommand);
|
|
172
|
+
const validated = validateRepositoryToolchains(toolchains);
|
|
173
|
+
const lines = [
|
|
174
|
+
"# ===========================================================================",
|
|
175
|
+
"# Epic Implementer CI gate — MANAGED FILE",
|
|
176
|
+
"#",
|
|
177
|
+
"# Generated by Bridge (`" + V3_WORKFLOW_PATH + "`). Do not hand-edit: the",
|
|
178
|
+
"# installer compares this file byte for byte against what it renders and",
|
|
179
|
+
"# refuses to overwrite a modified or unrecognized copy.",
|
|
180
|
+
"#",
|
|
181
|
+
"# " + V3_VERSION_MARKER_KEY + ": " + String(V3_RENDERER_VERSION),
|
|
182
|
+
"# " + V3_TOOLCHAINS_MARKER_KEY + ": " + serializeRepositoryToolchains(validated),
|
|
183
|
+
"#",
|
|
184
|
+
"# WHAT THIS WORKFLOW IS",
|
|
185
|
+
"#",
|
|
186
|
+
"# It publishes one required check, `" + V3_CHECK_NAME + "`, that the",
|
|
187
|
+
"# Bridge Epic Implementer reads before it merges a child pull request. The",
|
|
188
|
+
"# check is green only when the repository's stored test command passes.",
|
|
189
|
+
"#",
|
|
190
|
+
"# SCOPE: EPIC-TARGETED, SAME-REPOSITORY PULL REQUESTS ONLY",
|
|
191
|
+
"#",
|
|
192
|
+
"# The workflow runs only for pull requests that target an `epic/**` branch:",
|
|
193
|
+
"# the child pull requests the Epic Implementer merges into an epic branch. It",
|
|
194
|
+
"# does not run for other pull requests, including the final pull request into",
|
|
195
|
+
"# the default branch.",
|
|
196
|
+
"#",
|
|
197
|
+
"# The `tests` job runs only when the pull request head is this repository.",
|
|
198
|
+
"# A fork pull request never checks out or runs repository code; the gate",
|
|
199
|
+
"# passes for it immediately and says so. Nothing here uses a secret, and the",
|
|
200
|
+
"# token is read-only.",
|
|
201
|
+
"#",
|
|
202
|
+
"# DEPENDENCIES",
|
|
203
|
+
"#",
|
|
204
|
+
"# The setup steps before the test command were chosen from the lockfiles in",
|
|
205
|
+
"# the root of the repository's default branch when this file was generated;",
|
|
206
|
+
"# the toolchains line above records the choice. They install dependencies and",
|
|
207
|
+
"# nothing else. When no supported dependency file was found, nothing is",
|
|
208
|
+
"# installed for that ecosystem and the command must install what it needs",
|
|
209
|
+
"# itself.",
|
|
210
|
+
"#",
|
|
211
|
+
"# THE TEST COMMAND",
|
|
212
|
+
"#",
|
|
213
|
+
"# The command below is the repository's stored test command, run with bash",
|
|
214
|
+
"# from the repository root after the setup steps. To change it, save a new",
|
|
215
|
+
"# command through Bridge setup (`--test-command`) and re-run the installer; do",
|
|
216
|
+
"# not edit it here.",
|
|
217
|
+
"# ===========================================================================",
|
|
218
|
+
"name: " + V3_WORKFLOW_NAME,
|
|
219
|
+
"",
|
|
220
|
+
"on:",
|
|
221
|
+
" pull_request:",
|
|
222
|
+
" branches: ['epic/**']",
|
|
223
|
+
"",
|
|
224
|
+
"permissions:",
|
|
225
|
+
" contents: read",
|
|
226
|
+
"",
|
|
227
|
+
"jobs:",
|
|
228
|
+
" tests:",
|
|
229
|
+
" name: tests",
|
|
230
|
+
" if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}",
|
|
231
|
+
" runs-on: ubuntu-latest",
|
|
232
|
+
" timeout-minutes: " + String(V3_TEST_JOB_TIMEOUT_MINUTES),
|
|
233
|
+
" steps:",
|
|
234
|
+
" - name: Check out the pull request",
|
|
235
|
+
" uses: " + V3_ACTION_CHECKOUT,
|
|
236
|
+
" with:",
|
|
237
|
+
" persist-credentials: false",
|
|
238
|
+
...toolchainSetupLines(validated),
|
|
239
|
+
" - name: " + V3_COMMAND_STEP_NAME,
|
|
240
|
+
" shell: bash",
|
|
241
|
+
V3_COMMAND_LINE_PREFIX + encodeCommandScalar(command),
|
|
242
|
+
"",
|
|
243
|
+
" gate:",
|
|
244
|
+
" name: " + V3_CHECK_NAME,
|
|
245
|
+
" needs: [tests]",
|
|
246
|
+
" if: ${{ always() }}",
|
|
247
|
+
" runs-on: ubuntu-latest",
|
|
248
|
+
" timeout-minutes: " + String(V3_GATE_JOB_TIMEOUT_MINUTES),
|
|
249
|
+
" steps:",
|
|
250
|
+
" - name: Aggregate the Epic Implementer CI result",
|
|
251
|
+
" env:",
|
|
252
|
+
" HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}",
|
|
253
|
+
" THIS_REPOSITORY: ${{ github.repository }}",
|
|
254
|
+
" TESTS_RESULT: ${{ needs.tests.result }}",
|
|
255
|
+
" run: |",
|
|
256
|
+
" if [ -z \"$HEAD_REPOSITORY\" ] || [ -z \"$THIS_REPOSITORY\" ]; then",
|
|
257
|
+
" echo \"The pull request head repository could not be identified; the gate fails.\"",
|
|
258
|
+
" exit 1",
|
|
259
|
+
" fi",
|
|
260
|
+
" if [ \"$HEAD_REPOSITORY\" != \"$THIS_REPOSITORY\" ]; then",
|
|
261
|
+
" echo \"Fork pull request: repository code is never run for a fork, so the gate passes without running tests.\"",
|
|
262
|
+
" exit 0",
|
|
263
|
+
" fi",
|
|
264
|
+
" echo \"Tests: $TESTS_RESULT\"",
|
|
265
|
+
" if [ \"$TESTS_RESULT\" = \"success\" ]; then",
|
|
266
|
+
" exit 0",
|
|
267
|
+
" fi",
|
|
268
|
+
" echo \"The stored test command did not conclude 'success'; the gate fails.\"",
|
|
269
|
+
" exit 1",
|
|
270
|
+
"",
|
|
271
|
+
];
|
|
272
|
+
return lines.join("\n");
|
|
273
|
+
}
|
|
@@ -23,22 +23,40 @@
|
|
|
23
23
|
*
|
|
24
24
|
* ## Safe by default
|
|
25
25
|
*
|
|
26
|
-
* `on: pull_request`
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* `on: pull_request` for pull requests that target `epic/**` only (renderer
|
|
27
|
+
* version 3, BAPI-1603), `permissions: contents: read`, no secrets, no path
|
|
28
|
+
* filters, `ubuntu-latest`. The execution job runs only when the pull request
|
|
29
|
+
* head is this repository; a fork pull request never checks out or runs
|
|
29
30
|
* repository code. The checkout does not persist its token.
|
|
30
31
|
*
|
|
32
|
+
* ## Why only epic-targeted pull requests (renderer version 3)
|
|
33
|
+
*
|
|
34
|
+
* Versions 1 and 2 ran on every pull request. The Epic Implementer reads this
|
|
35
|
+
* check on the child pull requests it merges into an `epic/<EPIC>` branch, and an
|
|
36
|
+
* owner who has their own CI should not pay for a second run on every ordinary
|
|
37
|
+
* pull request. The final pull request into the default branch targets the
|
|
38
|
+
* default branch, so this workflow does not run there: a default-branch rule that
|
|
39
|
+
* requires `epic-implementer-ci / gate` would wait for a check that never starts.
|
|
40
|
+
* The setup warns about that rule; it never edits one. The frozen version-2
|
|
41
|
+
* renderer (`epic-ci-workflow-v2.ts`) keeps unmodified version-2 files
|
|
42
|
+
* recognizable as upgradeable.
|
|
43
|
+
*
|
|
31
44
|
* ## Toolchain provisioning (renderer version 2, BAPI-1536)
|
|
32
45
|
*
|
|
33
46
|
* Version 1 provisioned nothing, so a command that needed installed dependencies
|
|
34
47
|
* had to install them itself. Version 2 adds fixed setup steps between the
|
|
35
48
|
* checkout and the stored command, chosen from the repository's own lockfiles by
|
|
36
49
|
* the shared resolver (`repository-toolchains.ts`) at the moment the workflow is
|
|
37
|
-
* generated.
|
|
38
|
-
* metadata is deliberately NOT an input: it can be stale, absent, or describe a
|
|
50
|
+
* generated. Through version 2 the resolver read the local working tree. Server
|
|
51
|
+
* indexing metadata is deliberately NOT an input: it can be stale, absent, or describe a
|
|
39
52
|
* different checkout, and the workflow must be reproducible from the files it is
|
|
40
53
|
* committed next to.
|
|
41
54
|
*
|
|
55
|
+
* From version 3 the resolver reads the remote default branch at the installer's
|
|
56
|
+
* captured head, not the person's working tree: the workflow is committed onto
|
|
57
|
+
* that head, so uncommitted or unpushed local files must not choose its
|
|
58
|
+
* toolchains.
|
|
59
|
+
*
|
|
42
60
|
* - JavaScript, Python, and Go are provisioned, in that order, when found.
|
|
43
61
|
* Manager priority, version-file precedence, and fixed fallbacks are defined in
|
|
44
62
|
* `repository-toolchains.ts`; the user-facing summary is the packaged
|
|
@@ -58,19 +76,38 @@
|
|
|
58
76
|
* line) so a later run can re-render the file byte for byte and tell a
|
|
59
77
|
* legitimate toolchain change from a hand edit.
|
|
60
78
|
*
|
|
79
|
+
* ## Approved install commands (renderer version 4, BAPI-1677)
|
|
80
|
+
*
|
|
81
|
+
* Version 3 always ran the fixed install line for each toolchain. A project whose
|
|
82
|
+
* tests need an optional extra failed in CI the way it failed on a worker. Version 4
|
|
83
|
+
* takes the entries the owner approved, the same ones the test trial and every worker
|
|
84
|
+
* use. With none, or with a list that only repeats fixed install lines, it keeps
|
|
85
|
+
* version 3's install lines. With any other list, it keeps the runtime setup, manager
|
|
86
|
+
* bootstrap, and PATH steps, and renders each entry as its own step in its own
|
|
87
|
+
* directory, every argument quoted for the shell. An entry replaces a fixed install
|
|
88
|
+
* line only when it runs that line's manager at the repository root. Every other fixed
|
|
89
|
+
* line stays, so a partial list loses nothing. The pip line always stays, because setup
|
|
90
|
+
* never proposes pip. Entry steps use a block scalar, so the stored test command stays
|
|
91
|
+
* the only double-quoted `run:` line. The entries are recorded in the header, so a later
|
|
92
|
+
* run can reproduce the file.
|
|
93
|
+
*
|
|
61
94
|
* The command still never receives a prefix or an install: it stays on its one
|
|
62
95
|
* protected scalar line.
|
|
63
96
|
*/
|
|
64
97
|
import { BUN_VERSION_RANGE, NODE_FALLBACK_MAJOR, PNPM_FALLBACK_MAJOR, POETRY_VERSION, PYTHON_FALLBACK_MINOR, YARN_BERRY_FALLBACK_MAJOR, serializeRepositoryToolchains, validateRepositoryToolchains, } from "./repository-toolchains.js";
|
|
98
|
+
import { DEPENDENCY_INSTALL_UNSAFE_MESSAGE, parseDependencyInstallStrict, } from "./dependency-install-declarations.js";
|
|
99
|
+
import { posixShellQuote } from "./platform-escaping.js";
|
|
65
100
|
import { validateTestCommand } from "./test-command-validation.js";
|
|
66
101
|
/** Repository-relative path of the managed workflow. */
|
|
67
102
|
export const EPIC_CI_WORKFLOW_PATH = ".github/workflows/epic-implementer-ci.yml";
|
|
68
103
|
/** The renderer version written into the managed header. */
|
|
69
|
-
export const EPIC_CI_WORKFLOW_RENDERER_VERSION =
|
|
104
|
+
export const EPIC_CI_WORKFLOW_RENDERER_VERSION = 4;
|
|
70
105
|
/** The header marker key; the line is `# <key>: <version>`. */
|
|
71
106
|
export const EPIC_CI_WORKFLOW_VERSION_MARKER_KEY = "x-bridge-ci-renderer-version";
|
|
72
107
|
/** The header marker key for the canonical toolchain set; the line is `# <key>: <json>`. */
|
|
73
108
|
export const EPIC_CI_WORKFLOW_TOOLCHAINS_MARKER_KEY = "x-bridge-ci-toolchains";
|
|
109
|
+
/** BAPI-1677 — the header marker key for the approved install commands; the line is `# <key>: <json>`. */
|
|
110
|
+
export const EPIC_CI_WORKFLOW_DEPENDENCY_INSTALL_MARKER_KEY = "x-bridge-ci-dependency-install";
|
|
74
111
|
/** The `name:` of the one step that runs the stored command. */
|
|
75
112
|
export const EPIC_CI_COMMAND_STEP_NAME = "Run the stored test command";
|
|
76
113
|
/** Pinned action majors. Changing any of these is a renderer-version change. */
|
|
@@ -128,6 +165,53 @@ function pythonSetupLines(python) {
|
|
|
128
165
|
: " python-version-file: " + python,
|
|
129
166
|
];
|
|
130
167
|
}
|
|
168
|
+
const INSTALL_STEP_NAME = " - name: Install dependencies";
|
|
169
|
+
/** The run text of each fixed "Install dependencies" step, in file order. Every such step is two lines. */
|
|
170
|
+
function fixedInstallCommands(lines) {
|
|
171
|
+
const fixed = [];
|
|
172
|
+
lines.forEach((line, index) => {
|
|
173
|
+
if (line === INSTALL_STEP_NAME)
|
|
174
|
+
fixed.push((lines[index + 1] ?? "").replace(/^ *run: /, ""));
|
|
175
|
+
});
|
|
176
|
+
return fixed;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* True when an approved entry replaces this fixed install command: it runs the same manager at the
|
|
180
|
+
* repository root, where the fixed step runs. An entry elsewhere does not install the root's
|
|
181
|
+
* dependencies. pip is never replaced, because setup never proposes it, so an approved list that
|
|
182
|
+
* leaves pip out has not decided anything about it.
|
|
183
|
+
*/
|
|
184
|
+
function entriesReplaceFixedInstall(command, entries) {
|
|
185
|
+
const manager = command.split(" ")[0];
|
|
186
|
+
return manager !== "pip" && entries.some((entry) => entry.cwd === "." && entry.argv[0] === manager);
|
|
187
|
+
}
|
|
188
|
+
/** Drop only the fixed install steps the approved entries replace, keeping everything around them. */
|
|
189
|
+
function withoutReplacedInstallSteps(lines, entries) {
|
|
190
|
+
const kept = [];
|
|
191
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
192
|
+
if (lines[i] === INSTALL_STEP_NAME && entriesReplaceFixedInstall((lines[i + 1] ?? "").replace(/^ *run: /, ""), entries)) {
|
|
193
|
+
i += 1;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
kept.push(lines[i]);
|
|
197
|
+
}
|
|
198
|
+
return kept;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* True when every entry is one of the fixed install commands at the repository root, in the fixed
|
|
202
|
+
* order. The list may name only some of them, because the others keep running either way.
|
|
203
|
+
*/
|
|
204
|
+
function repeatsFixedInstallLines(lines, entries) {
|
|
205
|
+
const fixed = fixedInstallCommands(lines);
|
|
206
|
+
let next = 0;
|
|
207
|
+
return entries.every((entry) => {
|
|
208
|
+
if (entry.cwd !== ".")
|
|
209
|
+
return false;
|
|
210
|
+
const found = fixed.indexOf(entry.argv.join(" "), next);
|
|
211
|
+
next = found + 1;
|
|
212
|
+
return found !== -1;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
131
215
|
function javaScriptSetupLines(js) {
|
|
132
216
|
switch (js.manager) {
|
|
133
217
|
case "npm":
|
|
@@ -214,15 +298,62 @@ function toolchainSetupLines(toolchains) {
|
|
|
214
298
|
}
|
|
215
299
|
return lines;
|
|
216
300
|
}
|
|
301
|
+
/** Raised for approved entries the renderer will not write. Its message is fixed text. */
|
|
302
|
+
export class EpicCiDependencyInstallError extends Error {
|
|
303
|
+
constructor() {
|
|
304
|
+
super(DEPENDENCY_INSTALL_UNSAFE_MESSAGE);
|
|
305
|
+
this.name = "EpicCiDependencyInstallError";
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/** Escape every non-ASCII character, so a permitted separator cannot start a new header line. */
|
|
309
|
+
function asciiJson(value) {
|
|
310
|
+
return JSON.stringify(value).replace(/[\u007f-\uffff]/g, (ch) => "\\u" + ch.charCodeAt(0).toString(16).padStart(4, "0"));
|
|
311
|
+
}
|
|
312
|
+
/** The one header form of the entries: fixed key order, and every list in its own order. */
|
|
313
|
+
export function serializeEpicCiDependencyInstall(entries) {
|
|
314
|
+
return asciiJson(entries.map((e) => ({ cwd: e.cwd, argv: e.argv, lockfiles: e.lockfiles })));
|
|
315
|
+
}
|
|
316
|
+
/** Characters a YAML reader could take as a break, or refuse, inside a block scalar. */
|
|
317
|
+
const BLOCK_SCALAR_UNSAFE = /([\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u2028\u2029\ufeff]+)/;
|
|
318
|
+
/** One argument for bash. Such characters are written as `$'\\xNN'` bytes, so the line stays one line. */
|
|
319
|
+
function shellWord(arg) {
|
|
320
|
+
const parts = arg.split(BLOCK_SCALAR_UNSAFE).filter((part) => part.length > 0);
|
|
321
|
+
return parts
|
|
322
|
+
.map((part) => BLOCK_SCALAR_UNSAFE.test(part)
|
|
323
|
+
? "$'" + [...Buffer.from(part, "utf8")].map((b) => "\\x" + b.toString(16).padStart(2, "0")).join("") + "'"
|
|
324
|
+
: posixShellQuote(part))
|
|
325
|
+
.join("");
|
|
326
|
+
}
|
|
327
|
+
function dependencyInstallStepLines(entries) {
|
|
328
|
+
return entries.flatMap((entry, index) => [
|
|
329
|
+
" - name: Install declared dependencies (" + String(index + 1) + " of " + String(entries.length) + ")",
|
|
330
|
+
" shell: bash",
|
|
331
|
+
" working-directory: " + encodeCommandScalar(entry.cwd),
|
|
332
|
+
" run: |-",
|
|
333
|
+
" " + entry.argv.map(shellWord).join(" "),
|
|
334
|
+
]);
|
|
335
|
+
}
|
|
217
336
|
/**
|
|
218
|
-
* Render the workflow for `testCommand
|
|
219
|
-
* Deterministic: the same inputs always give the same bytes. Throws
|
|
220
|
-
* `TestCommandValidationError` for a bad command
|
|
221
|
-
*
|
|
337
|
+
* Render the workflow for `testCommand`, the resolved `toolchains`, and the approved
|
|
338
|
+
* install `entries`. Deterministic: the same inputs always give the same bytes. Throws
|
|
339
|
+
* `TestCommandValidationError` for a bad command, `RepositoryToolchainError` for a
|
|
340
|
+
* toolchain set outside the closed vocabulary, and `EpicCiDependencyInstallError` for
|
|
341
|
+
* entries the shared rules refuse, so a value an older server accepted cannot reach a
|
|
342
|
+
* workflow.
|
|
222
343
|
*/
|
|
223
|
-
export function renderEpicImplementerCiWorkflow(testCommand, toolchains) {
|
|
344
|
+
export function renderEpicImplementerCiWorkflow(testCommand, toolchains, dependencyInstall = []) {
|
|
224
345
|
const command = validateTestCommand(testCommand);
|
|
225
346
|
const validated = validateRepositoryToolchains(toolchains);
|
|
347
|
+
const entries = parseDependencyInstallStrict(dependencyInstall);
|
|
348
|
+
if (entries === null)
|
|
349
|
+
throw new EpicCiDependencyInstallError();
|
|
350
|
+
const fixedLines = toolchainSetupLines(validated);
|
|
351
|
+
// A list that only repeats fixed install lines installs the same thing, so it renders the same
|
|
352
|
+
// bytes. Otherwise storing `npm ci` would turn an up-to-date workflow into an upgrade offer.
|
|
353
|
+
const sealed = repeatsFixedInstallLines(fixedLines, entries) ? [] : entries;
|
|
354
|
+
const setupLines = sealed.length === 0
|
|
355
|
+
? fixedLines
|
|
356
|
+
: [...withoutReplacedInstallSteps(fixedLines, sealed), ...dependencyInstallStepLines(sealed)];
|
|
226
357
|
const lines = [
|
|
227
358
|
"# ===========================================================================",
|
|
228
359
|
"# Epic Implementer CI gate — MANAGED FILE",
|
|
@@ -233,6 +364,7 @@ export function renderEpicImplementerCiWorkflow(testCommand, toolchains) {
|
|
|
233
364
|
"#",
|
|
234
365
|
"# " + EPIC_CI_WORKFLOW_VERSION_MARKER_KEY + ": " + String(EPIC_CI_WORKFLOW_RENDERER_VERSION),
|
|
235
366
|
"# " + EPIC_CI_WORKFLOW_TOOLCHAINS_MARKER_KEY + ": " + serializeRepositoryToolchains(validated),
|
|
367
|
+
"# " + EPIC_CI_WORKFLOW_DEPENDENCY_INSTALL_MARKER_KEY + ": " + serializeEpicCiDependencyInstall(sealed),
|
|
236
368
|
"#",
|
|
237
369
|
"# WHAT THIS WORKFLOW IS",
|
|
238
370
|
"#",
|
|
@@ -240,7 +372,12 @@ export function renderEpicImplementerCiWorkflow(testCommand, toolchains) {
|
|
|
240
372
|
"# Bridge Epic Implementer reads before it merges a child pull request. The",
|
|
241
373
|
"# check is green only when the repository's stored test command passes.",
|
|
242
374
|
"#",
|
|
243
|
-
"# SCOPE: SAME-REPOSITORY PULL REQUESTS ONLY",
|
|
375
|
+
"# SCOPE: EPIC-TARGETED, SAME-REPOSITORY PULL REQUESTS ONLY",
|
|
376
|
+
"#",
|
|
377
|
+
"# The workflow runs only for pull requests that target an `epic/**` branch:",
|
|
378
|
+
"# the child pull requests the Epic Implementer merges into an epic branch. It",
|
|
379
|
+
"# does not run for other pull requests, including the final pull request into",
|
|
380
|
+
"# the default branch.",
|
|
244
381
|
"#",
|
|
245
382
|
"# The `tests` job runs only when the pull request head is this repository.",
|
|
246
383
|
"# A fork pull request never checks out or runs repository code; the gate",
|
|
@@ -250,21 +387,31 @@ export function renderEpicImplementerCiWorkflow(testCommand, toolchains) {
|
|
|
250
387
|
"# DEPENDENCIES",
|
|
251
388
|
"#",
|
|
252
389
|
"# The setup steps before the test command were chosen from the lockfiles in",
|
|
253
|
-
"# the repository
|
|
254
|
-
"# records the choice. They install dependencies and
|
|
255
|
-
"# supported dependency file was found, nothing is
|
|
256
|
-
"# ecosystem and the command must install what it needs
|
|
390
|
+
"# the root of the repository's default branch when this file was generated;",
|
|
391
|
+
"# the toolchains line above records the choice. They install dependencies and",
|
|
392
|
+
"# nothing else. When no supported dependency file was found, nothing is",
|
|
393
|
+
"# installed for that ecosystem and the command must install what it needs",
|
|
394
|
+
"# itself.",
|
|
395
|
+
"#",
|
|
396
|
+
"# When the install commands line above lists any, those approved commands run",
|
|
397
|
+
"# in that order. One that runs a toolchain's manager at the repository root",
|
|
398
|
+
"# replaces that manager's fixed install line. Every other fixed install line",
|
|
399
|
+
"# still runs, and the pip line always does.",
|
|
400
|
+
"# When it is empty, the fixed install lines for the toolchains run.",
|
|
401
|
+
"# To change the commands, correct them through Bridge setup and re-run it.",
|
|
257
402
|
"#",
|
|
258
403
|
"# THE TEST COMMAND",
|
|
259
404
|
"#",
|
|
260
405
|
"# The command below is the repository's stored test command, run with bash",
|
|
261
406
|
"# from the repository root after the setup steps. To change it, save a new",
|
|
262
|
-
"# command through Bridge setup and re-run the installer; do
|
|
407
|
+
"# command through Bridge setup (`--test-command`) and re-run the installer; do",
|
|
408
|
+
"# not edit it here.",
|
|
263
409
|
"# ===========================================================================",
|
|
264
410
|
"name: " + EPIC_CI_WORKFLOW_NAME,
|
|
265
411
|
"",
|
|
266
412
|
"on:",
|
|
267
413
|
" pull_request:",
|
|
414
|
+
" branches: ['epic/**']",
|
|
268
415
|
"",
|
|
269
416
|
"permissions:",
|
|
270
417
|
" contents: read",
|
|
@@ -280,7 +427,7 @@ export function renderEpicImplementerCiWorkflow(testCommand, toolchains) {
|
|
|
280
427
|
" uses: " + EPIC_CI_ACTION_CHECKOUT,
|
|
281
428
|
" with:",
|
|
282
429
|
" persist-credentials: false",
|
|
283
|
-
...
|
|
430
|
+
...setupLines,
|
|
284
431
|
" - name: " + EPIC_CI_COMMAND_STEP_NAME,
|
|
285
432
|
" shell: bash",
|
|
286
433
|
EPIC_CI_COMMAND_LINE_PREFIX + encodeCommandScalar(command),
|