@diffci.com/diffci 0.3.16 → 0.3.17

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.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The repository's gate as a list of checks (2026-10-29, docs/design/pipeline-impact.md, phase 1 slice 1).
3
+ *
4
+ * WHY. On one dogfood repository 104 pushes passed whatever the agent ran locally and then failed the
5
+ * gate (`npm run check`: typecheck, lint, an architecture-boundary script, ...) after push. Agents ran the
6
+ * tests DiffCI selected, or `tsc`, and never the rest. Test selection cannot catch those failures because
7
+ * they are not tests. This module names every leaf of the gate so verification can run them.
8
+ *
9
+ * THE RULE. The gate is the `check` script, else `validate`, else the conventional typecheck, lint and
10
+ * format scripts that exist; plus every check-named script (`check*`, `lint*`, `typecheck`, `validate*`)
11
+ * a CI workflow step runs. In the dogfood repository the architecture rule behind one of the 104 failures
12
+ * runs in `validate:release`, which a deploy workflow calls and `check` does not. A gate script is expanded into leaves: `a && b` and `a ; b` parts, `npm run x`
13
+ * (with x's pre/post hooks), `run-p`/`run-s`/`npm-run-all` script lists and globs, `concurrently` with
14
+ * `npm:x` or quoted commands, and a repository runner whose every argument is a script name
15
+ * (`node scripts/run-parallel.mjs lint:a check:b`).
16
+ *
17
+ * FAILING CLOSED. A script whose body cannot be split safely (`||`, pipes, redirects, subshells, variables,
18
+ * environment assignments, unknown arguments) stays one leaf, run as `npm run <script>`, so it runs exactly
19
+ * as the gate would. Leaves that run a test runner are left to test selection. Every leaf discovered here is
20
+ * RUN; check-narrowing.ts narrows or skips some of them for a given change.
21
+ */
22
+ export type GateCheckKind = "typecheck" | "lint" | "format" | "script" | "unknown";
23
+ export interface GateCheck {
24
+ /** The script name when the leaf is a whole script, `script[n]` for the n-th part of one. */
25
+ id: string;
26
+ /** The package script the leaf belongs to. */
27
+ script: string;
28
+ /** True: run the whole script (`npm run <script>`, which also runs its hooks). False: `command` is one
29
+ * part of the script's body, run on its own. */
30
+ runsScript: boolean;
31
+ /** The leaf as written: the script body when `runsScript`, otherwise the part. A NARROWED check's
32
+ * command is the narrowed one. */
33
+ command: string;
34
+ kind: GateCheckKind;
35
+ /** RUN as written, NARROWED to the changed files (`command` rewritten), or SKIP for this change. */
36
+ decision: "RUN" | "NARROWED" | "SKIP";
37
+ reason: string;
38
+ }
39
+ export interface GateDiscovery {
40
+ /** The scripts the gate was read from, in order. Empty when the repository declares none. */
41
+ roots: string[];
42
+ checks: GateCheck[];
43
+ /** Leaves that run a test runner; test selection covers them. */
44
+ coveredByTests: string[];
45
+ }
46
+ /**
47
+ * Check-named package scripts that GitHub Actions steps run, in workflow order. Disabled jobs (`if: false`)
48
+ * and workflows that do not parse contribute nothing: these only add checks, so missing one is the
49
+ * pre-existing behaviour rather than a wrong skip.
50
+ */
51
+ export declare function workflowGateScripts(workflowTexts: readonly string[], scripts: Readonly<Record<string, string>>): string[];
52
+ export interface GateDiscoveryOptions {
53
+ /** Further gate scripts, such as `workflowGateScripts`; expanded after the package's own gate. */
54
+ workflowScripts?: readonly string[];
55
+ /** Whether the package manager runs `pre<name>`/`post<name>` scripts (npm and Yarn 1 do; pnpm does
56
+ * not by default). Default true. */
57
+ lifecycleHooks?: boolean;
58
+ }
59
+ /** Finds the gate's scripts and expands them into leaf checks. Reads nothing but `scripts`. */
60
+ export declare function discoverGateChecks(scripts: Readonly<Record<string, string>>, options?: GateDiscoveryOptions): GateDiscovery;
@@ -0,0 +1,241 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * The repository's gate as a list of checks (2026-10-29, docs/design/pipeline-impact.md, phase 1 slice 1).
4
+ *
5
+ * WHY. On one dogfood repository 104 pushes passed whatever the agent ran locally and then failed the
6
+ * gate (`npm run check`: typecheck, lint, an architecture-boundary script, ...) after push. Agents ran the
7
+ * tests DiffCI selected, or `tsc`, and never the rest. Test selection cannot catch those failures because
8
+ * they are not tests. This module names every leaf of the gate so verification can run them.
9
+ *
10
+ * THE RULE. The gate is the `check` script, else `validate`, else the conventional typecheck, lint and
11
+ * format scripts that exist; plus every check-named script (`check*`, `lint*`, `typecheck`, `validate*`)
12
+ * a CI workflow step runs. In the dogfood repository the architecture rule behind one of the 104 failures
13
+ * runs in `validate:release`, which a deploy workflow calls and `check` does not. A gate script is expanded into leaves: `a && b` and `a ; b` parts, `npm run x`
14
+ * (with x's pre/post hooks), `run-p`/`run-s`/`npm-run-all` script lists and globs, `concurrently` with
15
+ * `npm:x` or quoted commands, and a repository runner whose every argument is a script name
16
+ * (`node scripts/run-parallel.mjs lint:a check:b`).
17
+ *
18
+ * FAILING CLOSED. A script whose body cannot be split safely (`||`, pipes, redirects, subshells, variables,
19
+ * environment assignments, unknown arguments) stays one leaf, run as `npm run <script>`, so it runs exactly
20
+ * as the gate would. Leaves that run a test runner are left to test selection. Every leaf discovered here is
21
+ * RUN; check-narrowing.ts narrows or skips some of them for a given change.
22
+ */
23
+ import { parse } from "yaml";
24
+ const GATE_FALLBACK_ROOTS = ["typecheck", "type-check", "types", "tsc", "lint", "format:check", "prettier:check", "fmt:check"];
25
+ const MAX_DEPTH = 10;
26
+ /** Workflow-run scripts that are checks by name. Anything else a workflow runs (build, deploy, release,
27
+ * migrations) is never run locally on the strength of a workflow naming it. */
28
+ const CHECK_NAME = /^(?:check|checks|lint|typecheck|type-check|types|tsc|validate|format:check|prettier:check|fmt:check)(?::[\w:.-]+)?$/;
29
+ const WORKFLOW_SCRIPT = /\b(?:npm|pnpm|yarn|bun)\s+(?:run(?:-script)?\s+)?([\w:.-]+)/g;
30
+ const SCRIPT_RUN = /^(npm|pnpm|yarn|bun)\s+(?:(?:run|run-script)\s+)?([\w:.@/-]+)$/;
31
+ const NPM_BUILTINS = new Set(["test", "start", "stop", "restart"]);
32
+ const RUN_ALL = /^(?:npx\s+(?:--no-install\s+)?)?(?:run-p|run-s|npm-run-all2?)\b(.*)$/;
33
+ const CONCURRENTLY = /^(?:npx\s+(?:--no-install\s+)?)?concurrently\b(.*)$/;
34
+ const REPO_RUNNER = /^(?:node|tsx|bun)\s+(\.{0,2}\/?[\w./-]+\.(?:m?[jt]s|c[jt]s))((?:\s+[\w:.@/-]+)+)$/;
35
+ /** Shell syntax whose meaning changes when the script is split into parts or run outside its shell. */
36
+ const UNSPLITTABLE = /\|\||[|<>`$()\\]|^\s*\w+=|\s\w+=\S/;
37
+ const TEST_RUNNER = /(?:^|[\s/])(?:vitest|jest|mocha|ava|tap|playwright|cypress|karma|jasmine)(?:\s|$)|(?:node|tsx|bun|deno)(?:\s+--?[\w-]+(?:=\S+)?)*\s+--test\b|^(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test(?:\s|$)/;
38
+ function kindOf(command) {
39
+ if (/(?:^|[\s/])(?:tsc|vue-tsc|svelte-check|tsgo)(?:\s|$)/.test(command))
40
+ return "typecheck";
41
+ if (/(?:^|[\s/])prettier\b.*--(?:check|list-different)\b|(?:^|[\s/])(?:biome|dprint)\s+(?:format|check)\b/.test(command))
42
+ return "format";
43
+ if (/(?:^|[\s/])(?:eslint|biome|oxlint|stylelint|xo|standard|markdownlint(?:-cli2)?)(?:\s|$)/.test(command))
44
+ return "lint";
45
+ if (/^(?:node|tsx|ts-node|bun|deno\s+run|python3?|bash|sh)\s+\S/.test(command))
46
+ return "script";
47
+ return "unknown";
48
+ }
49
+ /** Splits on top-level `&&` and `;`. Undefined when the body needs its shell (see UNSPLITTABLE). */
50
+ function splitParts(body) {
51
+ const parts = [];
52
+ let current = "";
53
+ let quote;
54
+ for (let i = 0; i < body.length; i++) {
55
+ const char = body[i];
56
+ if (quote) {
57
+ if (char === quote)
58
+ quote = undefined;
59
+ current += char;
60
+ }
61
+ else if (char === "'" || char === "\"") {
62
+ quote = char;
63
+ current += char;
64
+ }
65
+ else if (char === ";" || (char === "&" && body[i + 1] === "&")) {
66
+ parts.push(current.trim());
67
+ current = "";
68
+ if (char === "&")
69
+ i++;
70
+ }
71
+ else {
72
+ if (char === "&")
73
+ return undefined;
74
+ current += char;
75
+ }
76
+ }
77
+ if (quote)
78
+ return undefined;
79
+ parts.push(current.trim());
80
+ const unquoted = parts.map((part) => part.replace(/"[^"]*"|'[^']*'/g, "\"\""));
81
+ // A double-quoted `$` or backtick still expands in the shell.
82
+ if (parts.some((part) => !part || /"[^"]*[$`][^"]*"/.test(part)) || unquoted.some((part) => UNSPLITTABLE.test(part)))
83
+ return undefined;
84
+ return parts;
85
+ }
86
+ function globToRegExp(pattern) {
87
+ return new RegExp(`^${pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".*").replace(/\*/g, "[^:]*")}$`);
88
+ }
89
+ /** Script names a part runs, or undefined when the part is not only a list of scripts. */
90
+ function scriptsRunBy(part, scripts) {
91
+ const direct = SCRIPT_RUN.exec(part);
92
+ if (direct) {
93
+ const [, manager, name] = direct;
94
+ if (manager === "npm" && !/\brun(?:-script)?\s/.test(part) && !NPM_BUILTINS.has(name))
95
+ return undefined;
96
+ return scripts[name] !== undefined ? [name] : undefined;
97
+ }
98
+ const runAll = RUN_ALL.exec(part);
99
+ if (runAll) {
100
+ const names = [];
101
+ for (const word of runAll[1].trim().split(/\s+/).filter(Boolean)) {
102
+ if (/^-(?:p|s|l|c|-parallel|-sequential|-serial|-print-label|-continue-on-error|-print-name|-silent)$/.test(word))
103
+ continue;
104
+ const pattern = word.replace(/^["']|["']$/g, "");
105
+ if (pattern.startsWith("-"))
106
+ return undefined;
107
+ const matched = /[*]/.test(pattern) ? Object.keys(scripts).filter((name) => globToRegExp(pattern).test(name)) : scripts[pattern] !== undefined ? [pattern] : [];
108
+ if (matched.length === 0)
109
+ return undefined;
110
+ names.push(...matched);
111
+ }
112
+ return names.length ? names : undefined;
113
+ }
114
+ const runner = REPO_RUNNER.exec(part);
115
+ if (runner) {
116
+ const names = runner[2].trim().split(/\s+/);
117
+ return names.every((name) => scripts[name] !== undefined) ? names : undefined;
118
+ }
119
+ return undefined;
120
+ }
121
+ /** `concurrently "npm:a" "eslint ."`: the quoted commands, or undefined when any argument is not one. */
122
+ function concurrentlyParts(part) {
123
+ const match = CONCURRENTLY.exec(part);
124
+ if (!match)
125
+ return undefined;
126
+ const args = match[1].trim();
127
+ const commands = [...args.matchAll(/"([^"]*)"|'([^']*)'/g)].map((m) => (m[1] ?? m[2] ?? "").trim());
128
+ const rest = args.replace(/"[^"]*"|'[^']*'/g, "").trim();
129
+ if (rest || commands.length === 0 || commands.some((command) => !command))
130
+ return undefined;
131
+ return commands.map((command) => (command.startsWith("npm:") ? `npm run ${command.slice(4)}` : command));
132
+ }
133
+ /** A leaf that only runs a test runner. A body that mixes tests with other work stays a check. */
134
+ function onlyRunsTests(command) {
135
+ const parts = splitParts(command);
136
+ return parts?.length === 1 && TEST_RUNNER.test(parts[0]);
137
+ }
138
+ /**
139
+ * Check-named package scripts that GitHub Actions steps run, in workflow order. Disabled jobs (`if: false`)
140
+ * and workflows that do not parse contribute nothing: these only add checks, so missing one is the
141
+ * pre-existing behaviour rather than a wrong skip.
142
+ */
143
+ export function workflowGateScripts(workflowTexts, scripts) {
144
+ const names = [];
145
+ for (const text of workflowTexts) {
146
+ let jobs;
147
+ try {
148
+ jobs = parse(text)?.jobs;
149
+ }
150
+ catch {
151
+ continue;
152
+ }
153
+ if (!jobs || typeof jobs !== "object")
154
+ continue;
155
+ for (const job of Object.values(jobs)) {
156
+ if (!job || typeof job !== "object")
157
+ continue;
158
+ const { steps, if: condition } = job;
159
+ if (condition === false || (typeof condition === "string" && /^\s*(?:\$\{\{\s*)?false(?:\s*\}\})?\s*$/.test(condition)))
160
+ continue;
161
+ if (!Array.isArray(steps))
162
+ continue;
163
+ for (const step of steps) {
164
+ const run = step?.run;
165
+ if (typeof run !== "string")
166
+ continue;
167
+ for (const match of run.matchAll(WORKFLOW_SCRIPT)) {
168
+ const name = match[1];
169
+ if (CHECK_NAME.test(name) && scripts[name] !== undefined && !names.includes(name))
170
+ names.push(name);
171
+ }
172
+ }
173
+ }
174
+ }
175
+ return names;
176
+ }
177
+ /** Finds the gate's scripts and expands them into leaf checks. Reads nothing but `scripts`. */
178
+ export function discoverGateChecks(scripts, options = {}) {
179
+ const hooks = options.lifecycleHooks !== false;
180
+ const packageRoots = scripts["check"] !== undefined ? ["check"]
181
+ : scripts["validate"] !== undefined ? ["validate"]
182
+ : GATE_FALLBACK_ROOTS.filter((name) => scripts[name] !== undefined);
183
+ const roots = [...packageRoots, ...(options.workflowScripts ?? []).filter((name) => scripts[name] !== undefined && !packageRoots.includes(name))];
184
+ const checks = [];
185
+ const coveredByTests = [];
186
+ const seen = new Set();
187
+ const add = (check) => {
188
+ if (seen.has(check.id))
189
+ return;
190
+ seen.add(check.id);
191
+ if (onlyRunsTests(check.command)) {
192
+ coveredByTests.push(check.id);
193
+ return;
194
+ }
195
+ checks.push({ ...check, kind: kindOf(check.command), decision: "RUN", reason: `${check.reason}; always run (not yet narrowed)` });
196
+ };
197
+ const whole = (script, reason) => add({ id: script, script, runsScript: true, command: scripts[script], reason });
198
+ const expand = (script, stack, reason) => {
199
+ if (stack.includes(script) || stack.length >= MAX_DEPTH) {
200
+ whole(script, reason);
201
+ return;
202
+ }
203
+ const body = scripts[script];
204
+ const parts = splitParts(body);
205
+ const inner = parts?.map((part) => ({ part, names: scriptsRunBy(part, scripts), concurrent: concurrentlyParts(part) }));
206
+ const reducible = inner && (inner.length > 1 || inner.some((p) => p.names || p.concurrent));
207
+ if (!reducible) {
208
+ whole(script, reason);
209
+ return;
210
+ }
211
+ const next = [...stack, script];
212
+ if (hooks && scripts[`pre${script}`] !== undefined)
213
+ expand(`pre${script}`, next, `runs before ${script}`);
214
+ inner.forEach(({ part, names, concurrent }, index) => {
215
+ if (names) {
216
+ for (const name of names)
217
+ expand(name, next, `run by ${script}`);
218
+ }
219
+ else if (concurrent) {
220
+ concurrent.forEach((command, n) => {
221
+ const named = scriptsRunBy(command, scripts);
222
+ if (named)
223
+ for (const name of named)
224
+ expand(name, next, `run by ${script}`);
225
+ else
226
+ add({ id: `${script}[${index + 1}.${n + 1}]`, script, runsScript: false, command, reason: `part of ${script}` });
227
+ });
228
+ }
229
+ else {
230
+ add({ id: `${script}[${index + 1}]`, script, runsScript: false, command: part, reason: `part of ${script}` });
231
+ }
232
+ });
233
+ if (hooks && scripts[`post${script}`] !== undefined)
234
+ expand(`post${script}`, next, `runs after ${script}`);
235
+ };
236
+ for (const root of roots) {
237
+ expand(root, [], !packageRoots.includes(root) ? `${root}, run by a CI workflow` : GATE_FALLBACK_ROOTS.includes(root) ? "a conventional gate script" : `the ${root} gate`);
238
+ }
239
+ return { roots, checks, coveredByTests };
240
+ }
241
+ //# sourceMappingURL=pipeline-steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-steps.js","sourceRoot":"","sources":["../../src/planner/pipeline-steps.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AA6B7B,MAAM,mBAAmB,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC;AAC/H,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB;+EAC+E;AAC/E,MAAM,UAAU,GAAG,qHAAqH,CAAC;AACzI,MAAM,eAAe,GAAG,8DAA8D,CAAC;AAEvF,MAAM,UAAU,GAAG,gEAAgE,CAAC;AACpF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AACnE,MAAM,OAAO,GAAG,sEAAsE,CAAC;AACvF,MAAM,YAAY,GAAG,qDAAqD,CAAC;AAC3E,MAAM,WAAW,GAAG,mFAAmF,CAAC;AACxG,uGAAuG;AACvG,MAAM,YAAY,GAAG,oCAAoC,CAAC;AAC1D,MAAM,WAAW,GAAG,+LAA+L,CAAC;AAEpN,SAAS,MAAM,CAAC,O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,CAAC;;wBACvE,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,MAAM,EAAE,EAAE,CAAC,CAAC;gBACxH,CAAC,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,IAAI,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,MAAM,EAAE,EAAE,CAAC,CAAC;YAChH,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,KAAK,IAAI,OAAO,CAAC,OAAO,MAAM,EAAE,CAAC,KAAK,SAAS;YAAE,MAAM,CAAC,OAAO,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,MAAM,EAAE,CAAC,CAAC;IAC7G,CAAC,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,wBAAwB,CAAC,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC;IAC5K,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Which paths does a repository check script read? (2026-10-29, docs/design/pipeline-impact.md, phase 1
3
+ * slice 3.)
4
+ *
5
+ * This is the inverse of the reference resolver (`src/repo/file-references.ts`): there the question is
6
+ * "which files name the changed path", here it is "which paths does this check name". Dogfood check
7
+ * scripts name what they walk: `sourceFiles(path.join(root, "src"))`, `join(root,
8
+ * "ops/cloudflare/d1-migrations")`, `readFileSync(join(root, "package.json"))`. A script that names `src`
9
+ * reads everything under `src/`; a change elsewhere cannot change its result.
10
+ *
11
+ * THE RULE. The script's closure is the script file plus every relative module it imports, transitively.
12
+ * Its reads are every string literal in the closure, and every argument on its command line, that is a
13
+ * tracked file or directory (relative to the repository root or to the module's directory), plus the
14
+ * static prefix of each template literal. The check runs when a changed path:
15
+ *
16
+ * - is in the closure (the check's own code changed);
17
+ * - is, or is under, a path the closure names; or has a basename the closure names (`"index.ts"`);
18
+ * - is package.json or a lockfile and the closure imports a package or names package.json.
19
+ *
20
+ * FAILING CLOSED. The check runs as written, for any change, when its reads cannot be bounded: it runs
21
+ * another program (child_process), walks the repository root or the working directory, uses a glob that
22
+ * starts at the root, reads a path from the environment, its closure cannot be read or is too large, or the
23
+ * command is not `node`/`tsx`/`bun` running one JavaScript or TypeScript file.
24
+ *
25
+ * RESIDUAL RISK. A path assembled from parts that never appear as literals (`["s", "rc"].join("")`) is not
26
+ * seen, as in the reference resolver. Required CI stays authoritative.
27
+ */
28
+ import type { NarrowingInput } from "./check-narrowing.js";
29
+ import type { GateCheck } from "./pipeline-steps.js";
30
+ /** RUN or SKIP for a check that runs one repository script; other checks are returned unchanged. */
31
+ export declare function decideScriptCheck(check: GateCheck, input: NarrowingInput): GateCheck;
@@ -0,0 +1,197 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Which paths does a repository check script read? (2026-10-29, docs/design/pipeline-impact.md, phase 1
4
+ * slice 3.)
5
+ *
6
+ * This is the inverse of the reference resolver (`src/repo/file-references.ts`): there the question is
7
+ * "which files name the changed path", here it is "which paths does this check name". Dogfood check
8
+ * scripts name what they walk: `sourceFiles(path.join(root, "src"))`, `join(root,
9
+ * "ops/cloudflare/d1-migrations")`, `readFileSync(join(root, "package.json"))`. A script that names `src`
10
+ * reads everything under `src/`; a change elsewhere cannot change its result.
11
+ *
12
+ * THE RULE. The script's closure is the script file plus every relative module it imports, transitively.
13
+ * Its reads are every string literal in the closure, and every argument on its command line, that is a
14
+ * tracked file or directory (relative to the repository root or to the module's directory), plus the
15
+ * static prefix of each template literal. The check runs when a changed path:
16
+ *
17
+ * - is in the closure (the check's own code changed);
18
+ * - is, or is under, a path the closure names; or has a basename the closure names (`"index.ts"`);
19
+ * - is package.json or a lockfile and the closure imports a package or names package.json.
20
+ *
21
+ * FAILING CLOSED. The check runs as written, for any change, when its reads cannot be bounded: it runs
22
+ * another program (child_process), walks the repository root or the working directory, uses a glob that
23
+ * starts at the root, reads a path from the environment, its closure cannot be read or is too large, or the
24
+ * command is not `node`/`tsx`/`bun` running one JavaScript or TypeScript file.
25
+ *
26
+ * RESIDUAL RISK. A path assembled from parts that never appear as literals (`["s", "rc"].join("")`) is not
27
+ * seen, as in the reference resolver. Required CI stays authoritative.
28
+ */
29
+ import { posix } from "node:path";
30
+ import ts from "typescript";
31
+ const MAX_CLOSURE = 400;
32
+ const LOCKFILE = /^(?:package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?)$/;
33
+ const SCRIPT_FILE = /\.(?:[cm]?js|[cm]?ts|tsx|jsx)$/;
34
+ const RESOLVE_EXTENSIONS = ["", ".js", ".mjs", ".cjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", "/index.js", "/index.mjs", "/index.ts", "/index.tsx"];
35
+ const VALUE_FLAGS = new Set(["--import", "-r", "--require", "--loader", "--experimental-loader", "--conditions", "-C", "--env-file", "--tsconfig"]);
36
+ const SPAWNS = /\bchild_process\b|\bexeca\b|\bzx\b|\bBun\.spawn|\bDeno\.Command/;
37
+ const ROOT_NAME = String.raw `(?:root|ROOT|repoRoot|REPO_ROOT|rootDir|ROOT_DIR|projectRoot|PROJECT_ROOT|repositoryRoot|REPOSITORY_ROOT|cwd|process\.cwd\(\)|["'\`]\.{0,2}\/?["'\`])`;
38
+ /** A directory walk, glob or listing that starts at the repository root or the working directory. */
39
+ const WALKS_ROOT = new RegExp(String.raw `\b(?:readdirSync|readdir|opendirSync|opendir|globSync|glob|globby|fg|fastGlob|walk\w*|list\w*|\w*[Ff]iles|scan\w*|collect\w*)\s*\(\s*${ROOT_NAME}\s*[,)]|\bcwd\s*:\s*${ROOT_NAME}|["'\`](?:\.\/)?\*\*`);
40
+ const ENV_PATH = /process\.env\.\w*(?:PATH|DIR|ROOT|FILE)\b|process\.env\[/;
41
+ /**
42
+ * String literals (and each template's static head) and module specifiers, read with the TypeScript
43
+ * parser: regular expressions, comments and templates with substitutions defeat a regex scan (one
44
+ * swallowed `path.join(root, "src")` across lines). Undefined when a `require` or `import()` takes a
45
+ * computed specifier.
46
+ */
47
+ function scanModule(path, text) {
48
+ const kind = /\.tsx$/.test(path) ? ts.ScriptKind.TSX : /\.[cm]?ts$/.test(path) ? ts.ScriptKind.TS : /\.jsx$/.test(path) ? ts.ScriptKind.JSX : ts.ScriptKind.JS;
49
+ const source = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, false, kind);
50
+ const literals = [];
51
+ const imports = [];
52
+ let computed = false;
53
+ const visit = (node) => {
54
+ if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
55
+ imports.push(node.moduleSpecifier.text);
56
+ }
57
+ else if (ts.isCallExpression(node) && (node.expression.kind === ts.SyntaxKind.ImportKeyword || (ts.isIdentifier(node.expression) && node.expression.text === "require"))) {
58
+ const [argument] = node.arguments;
59
+ if (argument && ts.isStringLiteralLike(argument))
60
+ imports.push(argument.text);
61
+ else
62
+ computed = true;
63
+ }
64
+ if (ts.isStringLiteralLike(node))
65
+ literals.push(node.text);
66
+ else if (ts.isTemplateExpression(node))
67
+ literals.push(node.head.text);
68
+ ts.forEachChild(node, visit);
69
+ };
70
+ visit(source);
71
+ return computed ? undefined : { literals, imports };
72
+ }
73
+ /** The file a `node`/`tsx`/`bun` leaf runs, and its remaining arguments. */
74
+ function scriptOf(command) {
75
+ const words = command.trim().split(/\s+/);
76
+ let index = 0;
77
+ if (words[index] === "npx") {
78
+ index++;
79
+ if (words[index] === "--no-install")
80
+ index++;
81
+ }
82
+ if (!["node", "tsx", "bun", "ts-node"].includes(words[index] ?? ""))
83
+ return undefined;
84
+ if (words[index] === "bun" && words[index + 1] === "run")
85
+ index++;
86
+ for (index++; index < words.length && words[index].startsWith("-"); index++) {
87
+ if (VALUE_FLAGS.has(words[index]))
88
+ index++;
89
+ }
90
+ const file = words[index];
91
+ if (!file || !SCRIPT_FILE.test(file) || /["'$`]/.test(command))
92
+ return undefined;
93
+ return { file: posix.normalize(file), args: words.slice(index + 1) };
94
+ }
95
+ function directories(files) {
96
+ const dirs = new Set();
97
+ for (const file of files)
98
+ for (let dir = posix.dirname(file); dir !== "." && !dirs.has(dir); dir = posix.dirname(dir))
99
+ dirs.add(dir);
100
+ return dirs;
101
+ }
102
+ /** Reads of the script's closure, or a reason they cannot be bounded. */
103
+ function collectReads(entry, args, input, files) {
104
+ const tracked = new Set(files);
105
+ const dirs = directories(files);
106
+ const reads = { closure: new Set(), paths: new Set(), basenames: new Set(), importsPackages: false };
107
+ const addLiteral = (literal, from) => {
108
+ const value = literal.replace(/\\\\/g, "/").trim();
109
+ if (!value || value.length > 300 || /[\s*?{}<>|]/.test(value.replace(/\/$/, "")))
110
+ return;
111
+ for (const base of [".", posix.dirname(from)]) {
112
+ const path = posix.normalize(posix.join(base, value)).replace(/\/$/, "");
113
+ if (path.startsWith("..") || path === ".")
114
+ continue;
115
+ if (tracked.has(path) || dirs.has(path))
116
+ reads.paths.add(path);
117
+ }
118
+ if (/^[\w@+-][\w.@+-]*\.\w+$/.test(value))
119
+ reads.basenames.add(value);
120
+ };
121
+ for (const arg of args)
122
+ addLiteral(arg, ".");
123
+ const queue = [entry];
124
+ while (queue.length) {
125
+ const module = queue.shift();
126
+ if (reads.closure.has(module))
127
+ continue;
128
+ if (reads.closure.size >= MAX_CLOSURE)
129
+ return `its import closure exceeds ${MAX_CLOSURE} files`;
130
+ const text = input.read(module);
131
+ if (text === undefined)
132
+ return `${module} could not be read`;
133
+ reads.closure.add(module);
134
+ if (SPAWNS.test(text))
135
+ return `${module} runs another program`;
136
+ if (WALKS_ROOT.test(text))
137
+ return `${module} walks the repository root`;
138
+ if (ENV_PATH.test(text))
139
+ return `${module} reads a path from the environment`;
140
+ const scanned = scanModule(module, text);
141
+ if (!scanned)
142
+ return `${module} loads a module by a computed name`;
143
+ for (const specifier of scanned.imports) {
144
+ // Path aliases (`@/lib/x`, `~/x`, `#x`) reach repository code this module cannot follow.
145
+ if (/^(?:@\/|~\/|#)/.test(specifier))
146
+ return `${module} imports ${specifier} through a path alias`;
147
+ if (specifier.startsWith(".")) {
148
+ const base = posix.normalize(posix.join(posix.dirname(module), specifier));
149
+ const resolved = RESOLVE_EXTENSIONS.map((ext) => base + ext).find((candidate) => tracked.has(candidate))
150
+ ?? (tracked.has(base.replace(/\.js$/, ".ts")) ? base.replace(/\.js$/, ".ts") : undefined);
151
+ if (resolved)
152
+ queue.push(resolved);
153
+ else
154
+ return `${module} imports ${specifier}, which is not a tracked file`;
155
+ }
156
+ else if (!specifier.startsWith("node:") && !/^(?:fs|path|os|url|util|assert|crypto|child_process|stream|events|zlib|readline|process|module|worker_threads|http|https|net|buffer|timers)(?:\/|$)/.test(specifier)) {
157
+ reads.importsPackages = true;
158
+ }
159
+ }
160
+ for (const literal of scanned.literals)
161
+ addLiteral(literal, module);
162
+ if (/__dirname|import\.meta\.(?:dirname|url)/.test(text) && posix.dirname(module) !== ".")
163
+ reads.paths.add(posix.dirname(module));
164
+ }
165
+ return reads;
166
+ }
167
+ /** RUN or SKIP for a check that runs one repository script; other checks are returned unchanged. */
168
+ export function decideScriptCheck(check, input) {
169
+ if (check.kind !== "script" || !input.files)
170
+ return check;
171
+ if (check.runsScript && input.lifecycleHooks !== false
172
+ && (input.scripts[`pre${check.script}`] !== undefined || input.scripts[`post${check.script}`] !== undefined))
173
+ return check;
174
+ const script = scriptOf(check.command);
175
+ if (!script)
176
+ return check;
177
+ const run = (reason) => ({ ...check, decision: "RUN", reason });
178
+ const reads = collectReads(script.file, script.args, input, input.files);
179
+ if (typeof reads === "string")
180
+ return run(`${reads}: runs for any change`);
181
+ for (const { path } of input.changes) {
182
+ if (reads.closure.has(path))
183
+ return run(`${path} changed, and the check runs it`);
184
+ const named = [...reads.paths].find((read) => path === read || path.startsWith(`${read}/`));
185
+ if (named)
186
+ return run(`reads ${named}, which contains ${path}`);
187
+ if (reads.basenames.has(posix.basename(path)))
188
+ return run(`names ${posix.basename(path)}`);
189
+ const base = posix.basename(path);
190
+ if ((path === "package.json" || LOCKFILE.test(base)) && (reads.importsPackages || reads.paths.has("package.json")))
191
+ return run(`${path} changed and the check imports packages`);
192
+ }
193
+ const shown = [...reads.paths].sort().slice(0, 4);
194
+ const more = reads.paths.size > shown.length ? ` and ${reads.paths.size - shown.length} more` : "";
195
+ return { ...check, decision: "SKIP", reason: `reads ${shown.length ? shown.join(", ") + more : "only its own code"}; no changed file there` };
196
+ }
197
+ //# sourceMappingURL=script-reads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-reads.js","sourceRoot":"","sources":["../../src/planner/script-reads.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,QAAQ,GAAG,sFAAsF,CAAC;AACxG,MAAM,WAAW,GAAG,gCAAgC,CAAC;AACrD,MAAM,kBAAkB,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,YA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AC,MAAM,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACnG,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,mBAAmB,yBAAyB,EAAE,CAAC;AAChJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Is a change inside a TypeScript program? (2026-10-29, docs/design/pipeline-impact.md, phase 1 slice 4.)
3
+ *
4
+ * `tsc --noEmit` and type-aware lint check a whole program, so a change anywhere in it can break a file
5
+ * that did not change, and they are never narrowed to files. But a change outside the program (docs, SQL,
6
+ * site HTML, a script no TypeScript imports) cannot change their result, and they can be skipped.
7
+ *
8
+ * THE RULE. The program is the tsconfig's root files (`files`, `include`, `exclude`, inherited through
9
+ * relative `extends`; `projectRoots` in compiled-projects.ts) plus whatever those roots import. A change is
10
+ * in the program when:
11
+ *
12
+ * - it is a root (added and deleted paths count: they enter or leave the program);
13
+ * - it is a tsconfig/jsconfig, package.json, a lockfile or any `.d.ts` (they change every file's types);
14
+ * - it is a file TypeScript can load (TypeScript, JavaScript, JSON) and some root's text names it in an
15
+ * import-like string (`"./x"`, `"@/lib/x"`, `"../data/x.json"`). TypeScript can only reach a non-root
16
+ * file through an import that names it.
17
+ *
18
+ * FAILING CLOSED. A tsconfig that cannot be read, or one that extends a package (whose `include` and
19
+ * `allowJs` are unknown) when a JavaScript file changed, counts as in the program.
20
+ */
21
+ import type { NarrowingInput } from "./check-narrowing.js";
22
+ export type ProgramMembership = {
23
+ inProgram: true;
24
+ reason: string;
25
+ } | {
26
+ inProgram: false;
27
+ reason: string;
28
+ };
29
+ /** Root file texts, read once per narrowing pass. */
30
+ export type RootTextCache = Map<string, string | undefined>;
31
+ export declare function programMembership(config: string, input: NarrowingInput, cache?: RootTextCache): ProgramMembership;
32
+ /** The tsconfig a `tsc` leaf checks, or undefined when the command is not a plain project check. */
33
+ export declare function tscProject(command: string): string | undefined;