@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,631 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1654 — CI trigger adapters: a safe, trigger-only change that makes a
|
|
3
|
+
* project's own CI run on pull requests into `epic/**`.
|
|
4
|
+
*
|
|
5
|
+
* One small interface, implemented for GitHub Actions only:
|
|
6
|
+
*
|
|
7
|
+
* classify — is this workflow file eligible for the edit? Eligible,
|
|
8
|
+
* ineligible (with a bounded reason), or unreadable.
|
|
9
|
+
* buildEdit — the edit itself: one insertion of `'epic/**'` into the
|
|
10
|
+
* `on.pull_request.branches` list.
|
|
11
|
+
* validateEdit — prove the edit changed only that list, byte for byte.
|
|
12
|
+
*
|
|
13
|
+
* Everything here is pure. It performs no filesystem write, no network call,
|
|
14
|
+
* and no subprocess. It never re-serializes YAML: the edit is one insertion
|
|
15
|
+
* into the original text, and every other byte (comments, line endings, the
|
|
16
|
+
* final-newline state) is kept. It cannot change `jobs`, `steps`, `env`,
|
|
17
|
+
* `secrets`, or `permissions`: the insertion lands inside the trigger block,
|
|
18
|
+
* and validation refuses anything else.
|
|
19
|
+
*
|
|
20
|
+
* Coverage is judged by the existing classifier
|
|
21
|
+
* ({@link classifyEpicPullRequestTrigger}); this module adds no second one.
|
|
22
|
+
* A file the classifier cannot read is reported as unreadable, never guessed.
|
|
23
|
+
*
|
|
24
|
+
* Eligible shape (all required):
|
|
25
|
+
* - the classifier says the workflow does not cover epic branches because its
|
|
26
|
+
* branch filter excludes them;
|
|
27
|
+
* - the root trigger is a block mapping with exactly one `pull_request` entry
|
|
28
|
+
* (no `pull_request_target`), itself a block mapping;
|
|
29
|
+
* - `branches` is a literal list (a block list, or a one-line flow list) of
|
|
30
|
+
* plain or quoted names, with no expression;
|
|
31
|
+
* - there is no `branches-ignore`, `paths`, or `paths-ignore`;
|
|
32
|
+
* - no YAML anchor, alias, merge key, or duplicate key anywhere in the file;
|
|
33
|
+
* - no job-level `if` that reads the event or branch context.
|
|
34
|
+
*
|
|
35
|
+
* Adding an adapter for another CI system later is a self-contained change: a
|
|
36
|
+
* new {@link CiTriggerAdapter} in {@link CI_TRIGGER_ADAPTERS}.
|
|
37
|
+
*/
|
|
38
|
+
import { createHash } from "node:crypto";
|
|
39
|
+
import { classifyEpicPullRequestTrigger, readPullRequestBranchFilters, readWorkflowTriggerNames, } from "./conductor/epic-branch-ci-inspection.js";
|
|
40
|
+
import { MAX_DISCOVERY_FILE_BYTES } from "./conductor/gate-discovery.js";
|
|
41
|
+
/** The filter entry the edit adds. */
|
|
42
|
+
export const EPIC_BRANCH_FILTER_ENTRY = "epic/**";
|
|
43
|
+
/** The exact text inserted as a list item. Single-quoted so YAML reads it as a plain string. */
|
|
44
|
+
const QUOTED_ENTRY = "'epic/**'";
|
|
45
|
+
/** The patch representation's format tag. Part of the hashed patch identity. */
|
|
46
|
+
export const CI_TRIGGER_PATCH_FORMAT = "bapi-ci-trigger-insert/v1";
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
// Hashing
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
export function sha256Hex(text) {
|
|
51
|
+
return createHash("sha256").update(text, "utf-8").digest("hex");
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The deterministic patch representation the patch hash covers: the format
|
|
55
|
+
* tag, the path, the insertion's UTF-8 byte offset, and the inserted text, as
|
|
56
|
+
* JSON with keys in a fixed order.
|
|
57
|
+
*/
|
|
58
|
+
export function patchIdentity(path, source, offset, insertion) {
|
|
59
|
+
const byteOffset = Buffer.byteLength(source.slice(0, offset), "utf-8");
|
|
60
|
+
return JSON.stringify({ byte_offset: byteOffset, format: CI_TRIGGER_PATCH_FORMAT, insertion, path });
|
|
61
|
+
}
|
|
62
|
+
function splitLines(text) {
|
|
63
|
+
const lines = [];
|
|
64
|
+
let pos = 0;
|
|
65
|
+
while (pos <= text.length) {
|
|
66
|
+
const nl = text.indexOf("\n", pos);
|
|
67
|
+
const hardEnd = nl === -1 ? text.length : nl;
|
|
68
|
+
const cr = hardEnd > pos && text[hardEnd - 1] === "\r";
|
|
69
|
+
const end = cr ? hardEnd - 1 : hardEnd;
|
|
70
|
+
const raw = text.slice(pos, end);
|
|
71
|
+
const eol = nl === -1 ? "" : cr ? "\r\n" : "\n";
|
|
72
|
+
const trimmed = raw.trim();
|
|
73
|
+
const indent = raw.length - raw.trimStart().length;
|
|
74
|
+
if (!(nl === -1 && raw === "" && pos === text.length && lines.length > 0)) {
|
|
75
|
+
lines.push({ start: pos, end, eol, raw, indent, trimmed, skip: trimmed === "" || trimmed.startsWith("#") });
|
|
76
|
+
}
|
|
77
|
+
if (nl === -1)
|
|
78
|
+
break;
|
|
79
|
+
pos = nl + 1;
|
|
80
|
+
}
|
|
81
|
+
return lines;
|
|
82
|
+
}
|
|
83
|
+
/** The file's line ending: CRLF when its first line ending is CRLF, else LF. */
|
|
84
|
+
function fileEol(lines) {
|
|
85
|
+
return lines.find((l) => l.eol !== "")?.eol ?? "\n";
|
|
86
|
+
}
|
|
87
|
+
const KEY_RE = /^(?:([A-Za-z0-9_][A-Za-z0-9_.-]*)|"([^"\\]*)"|'([^']*)')\s*:(?:\s+(.*))?$/;
|
|
88
|
+
/** A `key: rest` line, with a trailing comment removed from `rest`. `null` when the line is not a plain key. */
|
|
89
|
+
function parseKey(trimmed) {
|
|
90
|
+
const m = KEY_RE.exec(trimmed);
|
|
91
|
+
if (m === null)
|
|
92
|
+
return null;
|
|
93
|
+
const key = m[1] ?? m[2] ?? m[3] ?? "";
|
|
94
|
+
let rest = (m[4] ?? "").trim();
|
|
95
|
+
if (rest.startsWith("#"))
|
|
96
|
+
rest = "";
|
|
97
|
+
return { key, rest: stripTrailingComment(rest) };
|
|
98
|
+
}
|
|
99
|
+
/** Drop a ` #...` comment from a value, outside quotes. */
|
|
100
|
+
function stripTrailingComment(value) {
|
|
101
|
+
let quote = null;
|
|
102
|
+
for (let i = 0; i < value.length; i++) {
|
|
103
|
+
const ch = value[i];
|
|
104
|
+
if (quote !== null) {
|
|
105
|
+
if (ch === quote)
|
|
106
|
+
quote = null;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (ch === '"' || ch === "'")
|
|
110
|
+
quote = ch;
|
|
111
|
+
else if (ch === "#" && (i === 0 || /\s/.test(value[i - 1])))
|
|
112
|
+
return value.slice(0, i).trimEnd();
|
|
113
|
+
}
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
/** Remove quoted strings, so syntax checks never read their contents. */
|
|
117
|
+
function withoutQuoted(value) {
|
|
118
|
+
return value.replace(/"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'/g, '""');
|
|
119
|
+
}
|
|
120
|
+
const TRIGGER_KEY_SPELLINGS = new Set(["on", "true", "True", "TRUE", "yes", "Yes", "YES", "On", "ON"]);
|
|
121
|
+
const BLOCK_SCALAR_RE = /^[|>][-+0-9]*$/;
|
|
122
|
+
const EVENT_CONTEXT_RE = /github\s*\.\s*(event_name|base_ref|head_ref|ref|ref_name|event\s*\.\s*pull_request)/;
|
|
123
|
+
function valueHasAnchorOrAlias(value) {
|
|
124
|
+
const bare = withoutQuoted(value);
|
|
125
|
+
return /(^|[[{,]\s*)[&*][^\s,[\]{}]/.test(bare) || /^!/.test(bare);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Walk the whole file's block structure. Conservative: any line it cannot
|
|
129
|
+
* place answers `unsupported_shape`, which makes the file ineligible.
|
|
130
|
+
*/
|
|
131
|
+
function checkStructure(lines) {
|
|
132
|
+
const stack = [];
|
|
133
|
+
let blockScalarIndent = null;
|
|
134
|
+
const contextFor = (indent) => {
|
|
135
|
+
while (stack.length > 0 && stack[stack.length - 1].indent > indent)
|
|
136
|
+
stack.pop();
|
|
137
|
+
const top = stack[stack.length - 1];
|
|
138
|
+
if (top !== undefined && top.indent === indent)
|
|
139
|
+
return top;
|
|
140
|
+
const parent = stack[stack.length - 1];
|
|
141
|
+
const ctx = {
|
|
142
|
+
indent,
|
|
143
|
+
keys: new Set(),
|
|
144
|
+
path: parent === undefined ? [] : [...parent.path, parent.lastKey ?? "?"],
|
|
145
|
+
lastKey: null,
|
|
146
|
+
};
|
|
147
|
+
stack.push(ctx);
|
|
148
|
+
return ctx;
|
|
149
|
+
};
|
|
150
|
+
for (const line of lines) {
|
|
151
|
+
if (blockScalarIndent !== null) {
|
|
152
|
+
if (line.trimmed === "" || line.indent > blockScalarIndent)
|
|
153
|
+
continue;
|
|
154
|
+
blockScalarIndent = null;
|
|
155
|
+
}
|
|
156
|
+
if (line.skip)
|
|
157
|
+
continue;
|
|
158
|
+
if (line.raw.slice(0, line.indent).includes("\t"))
|
|
159
|
+
return "unsupported_shape";
|
|
160
|
+
if (line.indent === 0 && (line.trimmed === "---" || line.trimmed.startsWith("...")))
|
|
161
|
+
return "unsupported_shape";
|
|
162
|
+
let indent = line.indent;
|
|
163
|
+
let text = line.trimmed;
|
|
164
|
+
// A sequence item: `- value` or `- key: value` (a new mapping inside the item).
|
|
165
|
+
if (text === "-" || text.startsWith("- ")) {
|
|
166
|
+
while (stack.length > 0 && stack[stack.length - 1].indent > indent)
|
|
167
|
+
stack.pop();
|
|
168
|
+
const after = text.slice(1);
|
|
169
|
+
const inner = after.trimStart();
|
|
170
|
+
if (inner === "" || inner.startsWith("#"))
|
|
171
|
+
continue;
|
|
172
|
+
const kv = parseKey(inner);
|
|
173
|
+
if (kv === null) {
|
|
174
|
+
if (valueHasAnchorOrAlias(stripTrailingComment(inner)))
|
|
175
|
+
return "anchor_or_alias";
|
|
176
|
+
if (/^[|>]/.test(inner) && BLOCK_SCALAR_RE.test(stripTrailingComment(inner)))
|
|
177
|
+
blockScalarIndent = indent;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
// The item's mapping starts at the key's column. A fresh item resets it.
|
|
181
|
+
indent = indent + 1 + (after.length - inner.length);
|
|
182
|
+
while (stack.length > 0 && stack[stack.length - 1].indent >= indent)
|
|
183
|
+
stack.pop();
|
|
184
|
+
text = inner;
|
|
185
|
+
}
|
|
186
|
+
const kv = parseKey(text);
|
|
187
|
+
if (kv === null) {
|
|
188
|
+
// A flow continuation, a multi-line scalar, or a complex key: not placed confidently.
|
|
189
|
+
return "unsupported_shape";
|
|
190
|
+
}
|
|
191
|
+
if (kv.key === "<<")
|
|
192
|
+
return "anchor_or_alias";
|
|
193
|
+
if (/^[&*]/.test(text))
|
|
194
|
+
return "anchor_or_alias";
|
|
195
|
+
if (valueHasAnchorOrAlias(kv.rest))
|
|
196
|
+
return "anchor_or_alias";
|
|
197
|
+
const ctx = contextFor(indent);
|
|
198
|
+
if (ctx.keys.has(kv.key))
|
|
199
|
+
return "duplicate_key";
|
|
200
|
+
ctx.keys.add(kv.key);
|
|
201
|
+
ctx.lastKey = kv.key;
|
|
202
|
+
// A job-level condition: `jobs.<id>.if`.
|
|
203
|
+
if (ctx.path.length === 2 && ctx.path[0] === "jobs" && kv.key === "if" && EVENT_CONTEXT_RE.test(kv.rest)) {
|
|
204
|
+
return "job_condition";
|
|
205
|
+
}
|
|
206
|
+
if (BLOCK_SCALAR_RE.test(kv.rest))
|
|
207
|
+
blockScalarIndent = indent;
|
|
208
|
+
else if (/^[[{]/.test(kv.rest) && !flowClosesOnLine(kv.rest))
|
|
209
|
+
return "unsupported_shape";
|
|
210
|
+
}
|
|
211
|
+
return "ok";
|
|
212
|
+
}
|
|
213
|
+
/** Does a flow collection close on its own line (quote-aware)? */
|
|
214
|
+
function flowClosesOnLine(value) {
|
|
215
|
+
let depth = 0;
|
|
216
|
+
let quote = null;
|
|
217
|
+
for (const ch of value) {
|
|
218
|
+
if (quote !== null) {
|
|
219
|
+
if (ch === quote)
|
|
220
|
+
quote = null;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (ch === '"' || ch === "'")
|
|
224
|
+
quote = ch;
|
|
225
|
+
else if (ch === "[" || ch === "{")
|
|
226
|
+
depth++;
|
|
227
|
+
else if (ch === "]" || ch === "}") {
|
|
228
|
+
depth--;
|
|
229
|
+
if (depth === 0)
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
const isContent = (l) => !l.skip;
|
|
236
|
+
/** A list item value a plain branch list may hold: one plain or quoted name, no expression. */
|
|
237
|
+
function plainItem(value) {
|
|
238
|
+
const v = value.trim();
|
|
239
|
+
if (v.length === 0)
|
|
240
|
+
return "bad";
|
|
241
|
+
if (v.includes("${{"))
|
|
242
|
+
return "expression";
|
|
243
|
+
if (v.startsWith('"') || v.startsWith("'")) {
|
|
244
|
+
const q = v[0];
|
|
245
|
+
return v.length >= 2 && v.endsWith(q) && !v.slice(1, -1).includes(q) ? "ok" : "bad";
|
|
246
|
+
}
|
|
247
|
+
if (/^[&*!|>@`%[\]{},#]/.test(v) || v.includes(": ") || v.endsWith(":"))
|
|
248
|
+
return "bad";
|
|
249
|
+
return "ok";
|
|
250
|
+
}
|
|
251
|
+
/** Split a one-line flow list body on commas, outside quotes. */
|
|
252
|
+
function splitFlowItems(body) {
|
|
253
|
+
const items = [];
|
|
254
|
+
let quote = null;
|
|
255
|
+
let current = "";
|
|
256
|
+
for (const ch of body) {
|
|
257
|
+
if (quote !== null) {
|
|
258
|
+
current += ch;
|
|
259
|
+
if (ch === quote)
|
|
260
|
+
quote = null;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (ch === '"' || ch === "'") {
|
|
264
|
+
quote = ch;
|
|
265
|
+
current += ch;
|
|
266
|
+
}
|
|
267
|
+
else if (ch === "[" || ch === "]" || ch === "{" || ch === "}") {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
else if (ch === ",") {
|
|
271
|
+
items.push(current);
|
|
272
|
+
current = "";
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
current += ch;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (quote !== null)
|
|
279
|
+
return null;
|
|
280
|
+
items.push(current);
|
|
281
|
+
// A trailing comma leaves one empty last item; YAML allows it.
|
|
282
|
+
if (items.length > 1 && items[items.length - 1].trim() === "")
|
|
283
|
+
items.pop();
|
|
284
|
+
return items;
|
|
285
|
+
}
|
|
286
|
+
function locateBranchList(source, lines) {
|
|
287
|
+
const content = lines.filter(isContent);
|
|
288
|
+
const roots = content.filter((l) => l.indent === 0);
|
|
289
|
+
const triggers = roots.filter((l) => {
|
|
290
|
+
const kv = parseKey(l.trimmed);
|
|
291
|
+
return kv !== null && TRIGGER_KEY_SPELLINGS.has(kv.key);
|
|
292
|
+
});
|
|
293
|
+
if (triggers.length !== 1)
|
|
294
|
+
return { ok: false, reason: triggers.length === 0 ? "unsupported_shape" : "duplicate_key" };
|
|
295
|
+
const triggerLine = triggers[0];
|
|
296
|
+
if (parseKey(triggerLine.trimmed).rest !== "")
|
|
297
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
298
|
+
// The trigger region: every line after it until the next root-level content line.
|
|
299
|
+
const startIdx = lines.indexOf(triggerLine);
|
|
300
|
+
let endIdx = lines.length;
|
|
301
|
+
for (let i = startIdx + 1; i < lines.length; i++) {
|
|
302
|
+
if (isContent(lines[i]) && lines[i].indent === 0) {
|
|
303
|
+
endIdx = i;
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const region = lines.slice(startIdx + 1, endIdx);
|
|
308
|
+
const regionContent = region.filter(isContent);
|
|
309
|
+
if (regionContent.length === 0)
|
|
310
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
311
|
+
const lastContent = regionContent[regionContent.length - 1];
|
|
312
|
+
const span = { start: triggerLine.start, end: lastContent.end };
|
|
313
|
+
if (regionContent.some((l) => l.trimmed.includes("${{")))
|
|
314
|
+
return { ok: false, reason: "expression" };
|
|
315
|
+
const childIndent = regionContent[0].indent;
|
|
316
|
+
const children = regionContent.filter((l) => l.indent === childIndent);
|
|
317
|
+
if (regionContent.some((l) => l.indent < childIndent))
|
|
318
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
319
|
+
const childKeys = children.map((l) => parseKey(l.trimmed));
|
|
320
|
+
if (childKeys.some((k) => k === null))
|
|
321
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
322
|
+
const names = childKeys.map((k) => k.key);
|
|
323
|
+
if (new Set(names).size !== names.length)
|
|
324
|
+
return { ok: false, reason: "duplicate_key" };
|
|
325
|
+
if (names.includes("pull_request_target"))
|
|
326
|
+
return { ok: false, reason: "multiple_pr_triggers" };
|
|
327
|
+
const prPos = names.indexOf("pull_request");
|
|
328
|
+
if (prPos === -1)
|
|
329
|
+
return { ok: false, reason: "no_pull_request_trigger" };
|
|
330
|
+
if (childKeys[prPos].rest !== "")
|
|
331
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
332
|
+
// The pull_request mapping's lines.
|
|
333
|
+
const prLine = children[prPos];
|
|
334
|
+
const prIdx = region.indexOf(prLine);
|
|
335
|
+
const prBody = [];
|
|
336
|
+
for (let i = prIdx + 1; i < region.length; i++) {
|
|
337
|
+
const l = region[i];
|
|
338
|
+
if (isContent(l) && l.indent <= childIndent)
|
|
339
|
+
break;
|
|
340
|
+
prBody.push(l);
|
|
341
|
+
}
|
|
342
|
+
const prContent = prBody.filter(isContent);
|
|
343
|
+
if (prContent.length === 0)
|
|
344
|
+
return { ok: false, reason: "not_plain_branch_list" };
|
|
345
|
+
const grandIndent = prContent[0].indent;
|
|
346
|
+
if (prContent.some((l) => l.indent < grandIndent))
|
|
347
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
348
|
+
const grand = prContent.filter((l) => l.indent === grandIndent);
|
|
349
|
+
const grandKeys = [];
|
|
350
|
+
for (const l of grand) {
|
|
351
|
+
if (l.trimmed.startsWith("- ") || l.trimmed === "-")
|
|
352
|
+
continue; // a compact list item under `branches:`
|
|
353
|
+
const kv = parseKey(l.trimmed);
|
|
354
|
+
if (kv === null)
|
|
355
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
356
|
+
grandKeys.push({ ...kv, line: l });
|
|
357
|
+
}
|
|
358
|
+
const grandNames = grandKeys.map((k) => k.key);
|
|
359
|
+
if (new Set(grandNames).size !== grandNames.length)
|
|
360
|
+
return { ok: false, reason: "duplicate_key" };
|
|
361
|
+
if (grandNames.includes("branches-ignore"))
|
|
362
|
+
return { ok: false, reason: "branches_ignore" };
|
|
363
|
+
if (grandNames.includes("paths") || grandNames.includes("paths-ignore"))
|
|
364
|
+
return { ok: false, reason: "path_filter" };
|
|
365
|
+
if (grandNames.some((n) => n !== "branches" && n !== "types"))
|
|
366
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
367
|
+
const branches = grandKeys.find((k) => k.key === "branches");
|
|
368
|
+
if (branches === undefined)
|
|
369
|
+
return { ok: false, reason: "not_plain_branch_list" };
|
|
370
|
+
// A one-line flow list: insert before the closing bracket.
|
|
371
|
+
if (branches.rest !== "") {
|
|
372
|
+
const line = branches.line;
|
|
373
|
+
const rest = branches.rest;
|
|
374
|
+
if (!rest.startsWith("[") || !rest.endsWith("]"))
|
|
375
|
+
return { ok: false, reason: "not_plain_branch_list" };
|
|
376
|
+
const items = splitFlowItems(rest.slice(1, -1));
|
|
377
|
+
if (items === null || items.length === 0 || (items.length === 1 && items[0].trim() === "")) {
|
|
378
|
+
return { ok: false, reason: "not_plain_branch_list" };
|
|
379
|
+
}
|
|
380
|
+
for (const item of items) {
|
|
381
|
+
const verdict = plainItem(item);
|
|
382
|
+
if (verdict !== "ok")
|
|
383
|
+
return { ok: false, reason: verdict === "expression" ? "expression" : "not_plain_branch_list" };
|
|
384
|
+
}
|
|
385
|
+
// Nothing may continue the `branches` value on deeper lines.
|
|
386
|
+
const after = prBody.slice(prBody.indexOf(line) + 1).filter(isContent);
|
|
387
|
+
const nextGrand = after.findIndex((l) => l.indent <= grandIndent);
|
|
388
|
+
const deeper = nextGrand === -1 ? after : after.slice(0, nextGrand);
|
|
389
|
+
if (deeper.length > 0)
|
|
390
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
391
|
+
// The closing bracket in the raw line: the last `]` before any trailing comment.
|
|
392
|
+
const rawRestStart = line.raw.indexOf(rest);
|
|
393
|
+
if (rawRestStart === -1)
|
|
394
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
395
|
+
const closeInLine = rawRestStart + rest.length - 1;
|
|
396
|
+
let insertAt = closeInLine;
|
|
397
|
+
while (insertAt > 0 && /\s/.test(line.raw[insertAt - 1]))
|
|
398
|
+
insertAt--;
|
|
399
|
+
const hasTrailingComma = line.raw[insertAt - 1] === ",";
|
|
400
|
+
const insertion = hasTrailingComma ? ` ${QUOTED_ENTRY}` : `, ${QUOTED_ENTRY}`;
|
|
401
|
+
return { ok: true, offset: line.start + insertAt, insertion, span };
|
|
402
|
+
}
|
|
403
|
+
// A block list: the item lines that follow `branches:` (deeper, or compact at the same column).
|
|
404
|
+
const bIdx = prBody.indexOf(branches.line);
|
|
405
|
+
const itemLines = [];
|
|
406
|
+
let seqIndent = null;
|
|
407
|
+
for (let i = bIdx + 1; i < prBody.length; i++) {
|
|
408
|
+
const l = prBody[i];
|
|
409
|
+
if (!isContent(l))
|
|
410
|
+
continue;
|
|
411
|
+
const isItem = l.trimmed === "-" || l.trimmed.startsWith("- ");
|
|
412
|
+
if (l.indent < grandIndent || (l.indent === grandIndent && !isItem))
|
|
413
|
+
break;
|
|
414
|
+
if (!isItem)
|
|
415
|
+
return { ok: false, reason: "not_plain_branch_list" };
|
|
416
|
+
seqIndent ??= l.indent;
|
|
417
|
+
if (l.indent !== seqIndent)
|
|
418
|
+
return { ok: false, reason: "not_plain_branch_list" };
|
|
419
|
+
const verdict = plainItem(stripTrailingComment(l.trimmed.slice(1).trim()));
|
|
420
|
+
if (verdict !== "ok")
|
|
421
|
+
return { ok: false, reason: verdict === "expression" ? "expression" : "not_plain_branch_list" };
|
|
422
|
+
itemLines.push(l);
|
|
423
|
+
}
|
|
424
|
+
if (itemLines.length === 0)
|
|
425
|
+
return { ok: false, reason: "not_plain_branch_list" };
|
|
426
|
+
const last = itemLines[itemLines.length - 1];
|
|
427
|
+
const indentText = last.raw.slice(0, last.indent);
|
|
428
|
+
if (!/^ *$/.test(indentText))
|
|
429
|
+
return { ok: false, reason: "unsupported_shape" };
|
|
430
|
+
const eol = last.eol !== "" ? last.eol : fileEol(lines);
|
|
431
|
+
return { ok: true, offset: last.end, insertion: `${eol}${indentText}- ${QUOTED_ENTRY}`, span };
|
|
432
|
+
}
|
|
433
|
+
// ---------------------------------------------------------------------------
|
|
434
|
+
// The GitHub Actions adapter
|
|
435
|
+
// ---------------------------------------------------------------------------
|
|
436
|
+
function sameList(a, b) {
|
|
437
|
+
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
438
|
+
}
|
|
439
|
+
function allowedInsertion(insertion) {
|
|
440
|
+
return (insertion === `, ${QUOTED_ENTRY}` ||
|
|
441
|
+
insertion === ` ${QUOTED_ENTRY}` ||
|
|
442
|
+
new RegExp(`^(\\r\\n|\\n) *- ${QUOTED_ENTRY.replace(/\*/g, "\\*")}$`).test(insertion));
|
|
443
|
+
}
|
|
444
|
+
/** A leading UTF-8 byte-order mark. YAML ignores it; the edit keeps it. */
|
|
445
|
+
const BOM = "\uFEFF";
|
|
446
|
+
/** The text the scanner reads: the file without a leading byte-order mark. */
|
|
447
|
+
function scannerText(text) {
|
|
448
|
+
return text.startsWith(BOM) ? text.slice(BOM.length) : text;
|
|
449
|
+
}
|
|
450
|
+
function classifyGithubActions(path, source) {
|
|
451
|
+
if (typeof source !== "string" || Buffer.byteLength(source, "utf-8") > MAX_DISCOVERY_FILE_BYTES) {
|
|
452
|
+
return { kind: "unreadable", path, reason: "too_large" };
|
|
453
|
+
}
|
|
454
|
+
const body = scannerText(source);
|
|
455
|
+
const bomLength = source.length - body.length;
|
|
456
|
+
const coverage = classifyEpicPullRequestTrigger(body);
|
|
457
|
+
const filters = readPullRequestBranchFilters(body);
|
|
458
|
+
const branches = filters.kind === "filters" ? filters.branches : null;
|
|
459
|
+
const ineligible = (reason) => ({ kind: "ineligible", path, reason, branches });
|
|
460
|
+
if (coverage.coverage === "covers")
|
|
461
|
+
return ineligible("already_covers");
|
|
462
|
+
if (coverage.coverage === "could_not_tell") {
|
|
463
|
+
switch (coverage.reason) {
|
|
464
|
+
case "unparseable":
|
|
465
|
+
return { kind: "unreadable", path, reason: "unparseable" };
|
|
466
|
+
case "unsupported_structure":
|
|
467
|
+
return { kind: "unreadable", path, reason: "unsupported_structure" };
|
|
468
|
+
case "path_filter":
|
|
469
|
+
return ineligible("path_filter");
|
|
470
|
+
case "types_filter":
|
|
471
|
+
return ineligible("types_filter");
|
|
472
|
+
case "indirect_trigger":
|
|
473
|
+
case "reusable_workflow_job":
|
|
474
|
+
return ineligible("indirect_trigger");
|
|
475
|
+
default:
|
|
476
|
+
return ineligible("not_plain_branch_list");
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (coverage.reason === "no_pr_trigger")
|
|
480
|
+
return ineligible("no_pull_request_trigger");
|
|
481
|
+
const lines = splitLines(body);
|
|
482
|
+
const structure = checkStructure(lines);
|
|
483
|
+
if (structure !== "ok")
|
|
484
|
+
return ineligible(structure);
|
|
485
|
+
const located = locateBranchList(body, lines);
|
|
486
|
+
if (!located.ok)
|
|
487
|
+
return ineligible(located.reason);
|
|
488
|
+
if (branches === null)
|
|
489
|
+
return ineligible("not_plain_branch_list");
|
|
490
|
+
const offset = located.offset + bomLength;
|
|
491
|
+
const edited = source.slice(0, offset) + located.insertion + source.slice(offset);
|
|
492
|
+
const edit = {
|
|
493
|
+
system: "github_actions",
|
|
494
|
+
path,
|
|
495
|
+
offset,
|
|
496
|
+
insertion: located.insertion,
|
|
497
|
+
span: { start: located.span.start + bomLength, end: located.span.end + bomLength },
|
|
498
|
+
branchesBefore: [...branches],
|
|
499
|
+
sourceSha256: sha256Hex(source),
|
|
500
|
+
patchSha256: sha256Hex(patchIdentity(path, source, offset, located.insertion)),
|
|
501
|
+
edited,
|
|
502
|
+
};
|
|
503
|
+
const valid = validateGithubActionsEdit(path, source, edited, edit);
|
|
504
|
+
if (!valid.ok)
|
|
505
|
+
return ineligible("validation_failed");
|
|
506
|
+
return { kind: "eligible", path, edit };
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Prove the edit is trigger-only. Every check is required: one file (this
|
|
510
|
+
* path), exactly the permitted insertion inside the trigger span with the
|
|
511
|
+
* surrounding bytes identical, the result still parses and now covers epic
|
|
512
|
+
* branches, the branch list is the old list plus `epic/**`, and the trigger
|
|
513
|
+
* events are unchanged. Nothing outside the insertion can differ.
|
|
514
|
+
*/
|
|
515
|
+
export function validateGithubActionsEdit(path, source, edited, edit) {
|
|
516
|
+
if (edit.path !== path)
|
|
517
|
+
return { ok: false, reason: "path_mismatch" };
|
|
518
|
+
if (edit.sourceSha256 !== sha256Hex(source))
|
|
519
|
+
return { ok: false, reason: "source_changed" };
|
|
520
|
+
if (!allowedInsertion(edit.insertion))
|
|
521
|
+
return { ok: false, reason: "insertion_not_permitted" };
|
|
522
|
+
if (edit.offset < edit.span.start || edit.offset > edit.span.end)
|
|
523
|
+
return { ok: false, reason: "outside_trigger_span" };
|
|
524
|
+
if (edited.length !== source.length + edit.insertion.length)
|
|
525
|
+
return { ok: false, reason: "length_mismatch" };
|
|
526
|
+
if (edited.slice(0, edit.offset) !== source.slice(0, edit.offset))
|
|
527
|
+
return { ok: false, reason: "prefix_changed" };
|
|
528
|
+
if (edited.slice(edit.offset, edit.offset + edit.insertion.length) !== edit.insertion)
|
|
529
|
+
return { ok: false, reason: "insertion_mismatch" };
|
|
530
|
+
if (edited.slice(edit.offset + edit.insertion.length) !== source.slice(edit.offset))
|
|
531
|
+
return { ok: false, reason: "suffix_changed" };
|
|
532
|
+
if (edit.patchSha256 !== sha256Hex(patchIdentity(path, source, edit.offset, edit.insertion)))
|
|
533
|
+
return { ok: false, reason: "patch_mismatch" };
|
|
534
|
+
if (source.startsWith(BOM) !== edited.startsWith(BOM))
|
|
535
|
+
return { ok: false, reason: "prefix_changed" };
|
|
536
|
+
const sourceBody = scannerText(source);
|
|
537
|
+
const editedBody = scannerText(edited);
|
|
538
|
+
if (classifyEpicPullRequestTrigger(editedBody).coverage !== "covers")
|
|
539
|
+
return { ok: false, reason: "does_not_cover_after_edit" };
|
|
540
|
+
const after = readPullRequestBranchFilters(editedBody);
|
|
541
|
+
if (after.kind !== "filters" || after.branches === null)
|
|
542
|
+
return { ok: false, reason: "filter_unreadable_after_edit" };
|
|
543
|
+
if (!sameList(after.branches, [...edit.branchesBefore, EPIC_BRANCH_FILTER_ENTRY]))
|
|
544
|
+
return { ok: false, reason: "filter_not_extended" };
|
|
545
|
+
const eventsBefore = readWorkflowTriggerNames(sourceBody);
|
|
546
|
+
const eventsAfter = readWorkflowTriggerNames(editedBody);
|
|
547
|
+
if (eventsBefore === null || eventsAfter === null || !sameList(eventsBefore, eventsAfter))
|
|
548
|
+
return { ok: false, reason: "triggers_changed" };
|
|
549
|
+
if (checkStructure(splitLines(editedBody)) !== "ok")
|
|
550
|
+
return { ok: false, reason: "structure_changed" };
|
|
551
|
+
return { ok: true };
|
|
552
|
+
}
|
|
553
|
+
export const GITHUB_ACTIONS_TRIGGER_ADAPTER = Object.freeze({
|
|
554
|
+
system: "github_actions",
|
|
555
|
+
displayName: "GitHub Actions",
|
|
556
|
+
classify: classifyGithubActions,
|
|
557
|
+
buildEdit: (path, source) => {
|
|
558
|
+
const c = classifyGithubActions(path, source);
|
|
559
|
+
return c.kind === "eligible" ? c.edit : null;
|
|
560
|
+
},
|
|
561
|
+
validateEdit: validateGithubActionsEdit,
|
|
562
|
+
});
|
|
563
|
+
/** Every adapter Bridge has. Only GitHub Actions today. */
|
|
564
|
+
export const CI_TRIGGER_ADAPTERS = Object.freeze([GITHUB_ACTIONS_TRIGGER_ADAPTER]);
|
|
565
|
+
// ---------------------------------------------------------------------------
|
|
566
|
+
// Selection and replay
|
|
567
|
+
// ---------------------------------------------------------------------------
|
|
568
|
+
/** Does a single-line `run:` step in this workflow equal the command exactly? */
|
|
569
|
+
function workflowRunsCommand(source, command) {
|
|
570
|
+
const want = command.trim();
|
|
571
|
+
if (want.length === 0)
|
|
572
|
+
return false;
|
|
573
|
+
for (const line of splitLines(source)) {
|
|
574
|
+
const m = /^(?:-\s+)?run:\s+(.+)$/.exec(line.trimmed);
|
|
575
|
+
if (m === null)
|
|
576
|
+
continue;
|
|
577
|
+
let value = stripTrailingComment(m[1].trim());
|
|
578
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'")))
|
|
579
|
+
value = value.slice(1, -1);
|
|
580
|
+
if (value === want)
|
|
581
|
+
return true;
|
|
582
|
+
}
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Pick exactly one edit, deterministically: an eligible workflow whose own
|
|
587
|
+
* single-line `run:` step is exactly the known test command wins; otherwise
|
|
588
|
+
* the first eligible path in code-unit order.
|
|
589
|
+
*/
|
|
590
|
+
export function selectTriggerEdit(classified, sources, testCommand) {
|
|
591
|
+
const eligible = classified
|
|
592
|
+
.filter((c) => c.kind === "eligible")
|
|
593
|
+
.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
594
|
+
if (eligible.length === 0)
|
|
595
|
+
return null;
|
|
596
|
+
if (testCommand !== null) {
|
|
597
|
+
const matching = eligible.find((c) => workflowRunsCommand(sources.get(c.path) ?? "", testCommand));
|
|
598
|
+
if (matching !== undefined)
|
|
599
|
+
return matching.edit;
|
|
600
|
+
}
|
|
601
|
+
return eligible[0].edit;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Recognize a file that already carries THIS adapter's edit (for example after
|
|
605
|
+
* the owner merged the CI pull request): remove the one inserted entry, and
|
|
606
|
+
* accept only when rebuilding the edit from that text reproduces the current
|
|
607
|
+
* file exactly. Returns the edit as it was approved, so a replay of the same
|
|
608
|
+
* answers binds the same source and patch hashes. `null` otherwise.
|
|
609
|
+
*/
|
|
610
|
+
export function recognizeAppliedEdit(path, current) {
|
|
611
|
+
if (classifyEpicPullRequestTrigger(scannerText(current)).coverage !== "covers")
|
|
612
|
+
return null;
|
|
613
|
+
const candidates = [];
|
|
614
|
+
for (const form of [`, ${QUOTED_ENTRY}`, ` ${QUOTED_ENTRY}`]) {
|
|
615
|
+
let at = current.indexOf(form);
|
|
616
|
+
while (at !== -1) {
|
|
617
|
+
candidates.push(current.slice(0, at) + current.slice(at + form.length));
|
|
618
|
+
at = current.indexOf(form, at + 1);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
const blockRe = /(\r\n|\n) *- 'epic\/\*\*'/g;
|
|
622
|
+
for (let m = blockRe.exec(current); m !== null; m = blockRe.exec(current)) {
|
|
623
|
+
candidates.push(current.slice(0, m.index) + current.slice(m.index + m[0].length));
|
|
624
|
+
}
|
|
625
|
+
for (const source of candidates) {
|
|
626
|
+
const c = classifyGithubActions(path, source);
|
|
627
|
+
if (c.kind === "eligible" && c.edit.edited === current)
|
|
628
|
+
return c.edit;
|
|
629
|
+
}
|
|
630
|
+
return null;
|
|
631
|
+
}
|