@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.
@@ -1,6 +1,7 @@
1
1
  import { execFileSync } from "node:child_process";
2
2
  import { resolve } from "node:path";
3
3
  import { observe } from "./observe.js";
4
+ import { plannedChecks } from "./gate-checks.js";
4
5
  import { executableSelection } from "./verify.js";
5
6
  import { captureWorkingTreeSnapshot } from "./working-tree.js";
6
7
  function changedPaths(repoPath, snapshot) {
@@ -50,6 +51,8 @@ export async function agentSelection(repoInput) {
50
51
  }
51
52
  }
52
53
  const ready = unchanged && (!before.changed || Boolean(command));
54
+ const planned = ready && before.changed ? plannedChecks(repoPath, { baseSha: before.baseSha, headSha: before.commitSha }) : [];
55
+ const checks = planned.filter((check) => check.decision !== "SKIP");
53
56
  return {
54
57
  schema: "diffci.agent-selection.v1", scope: "working-tree",
55
58
  status: ready ? "planned" : "blocked", tests_executed: false,
@@ -61,6 +64,9 @@ export async function agentSelection(repoInput) {
61
64
  command: ready ? command : undefined,
62
65
  // Run these one after another when present: the joined command exceeds the shell's limit.
63
66
  ...(ready && commands.length > 1 ? { commands } : {}),
67
+ // The rest of the repository's gate (lint, typecheck, check scripts), to run before the tests.
68
+ checks,
69
+ skipped_checks: planned.filter((check) => check.decision === "SKIP").map(({ id, reason }) => ({ id, reason })),
64
70
  reason: unchanged ? reason : "working tree changed during analysis; reanalyze",
65
71
  fallback_reasons: result?.fallbackReasons ?? [],
66
72
  analysis_status: observation?.status ?? "not_needed",
@@ -83,8 +89,12 @@ export function selectionInstruction(plan) {
83
89
  const scope = plan.selection === "selected"
84
90
  ? `DiffCI selected ${plan.tests_selected} of ${plan.tests_available} test files`
85
91
  : `DiffCI requires the full suite (${plan.reason})`;
86
- const run = plan.commands && plan.commands.length > 1
87
- ? `Run these commands in order, exactly as given:\n${plan.commands.join("\n")}`
88
- : `Run exactly:\n${plan.command}`;
89
- return `${scope}. ${run}\nDo not substitute your own test files or the full suite.`;
92
+ const testCommands = plan.commands && plan.commands.length > 1 ? plan.commands : [plan.command];
93
+ const all = [...plan.checks.map((check) => check.command), ...testCommands];
94
+ const skipped = plan.skipped_checks?.length ? ` ${plan.skipped_checks.length} other gate check(s) are not affected by this change.` : "";
95
+ const gate = plan.checks.length ? ` The repository's gate also runs ${plan.checks.length} check(s) (${plan.checks.map((check) => check.id).join(", ")}); run them first.${skipped}` : skipped;
96
+ const run = all.length > 1
97
+ ? `Run these commands in order, exactly as given:\n${all.join("\n")}`
98
+ : `Run exactly:\n${all[0]}`;
99
+ return `${scope}.${gate} ${run}\nDo not substitute your own test files, checks or the full suite.`;
90
100
  }
@@ -340,6 +340,8 @@ async function runVerifyCommand(flags, env) {
340
340
  tailBytes: numberFlag(flags, "tail-bytes") ?? 12_000,
341
341
  redactPaths: flags["redact-paths"] === true,
342
342
  baselineOnFailure: flags["baseline-on-failure"] === true || env.DIFFCI_BASELINE_ON_FAILURE === "1",
343
+ // Gate checks are for before push; in CI the repository's own check jobs already run them.
344
+ skipChecks: flags["no-checks"] === true || env.DIFFCI_CHECKS === "0" || (Boolean(env.CI) && env.CI !== "false" && flags.checks !== true),
343
345
  };
344
346
  const report = changed
345
347
  ? await verifyChanged(common)
@@ -923,7 +925,8 @@ Usage:
923
925
  diffci init [--repo <path>] [--workflow] [--verification-workflow] [--install] [--hook] [--force]
924
926
  diffci mcp
925
927
  diffci verify [--changed | --base <sha> --head <sha>] [--policy enforce] [--repo <path>] [--out <file>] [--json]
926
- [--redact-paths] [--timeout-ms <ms>] [--baseline-on-failure] [--share-usage] [--no-send]
928
+ [--redact-paths] [--timeout-ms <ms>] [--baseline-on-failure] [--no-checks | --checks]
929
+ [--share-usage] [--no-send]
927
930
  diffci telemetry [--mode off|anonymous|installations] [--internal-usage]
928
931
  diffci check [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
929
932
  [--redact-paths] [--json] [--quiet] [--fail-on-error] [--timeout-ms <ms>] [--share-usage]
@@ -954,6 +957,8 @@ when verification fails (git push --no-verify skips it; DIFFCI_HOOK_STRICT=1 als
954
957
  mcp runs the stdio MCP server for native agent integrations.
955
958
  verify --changed snapshots staged, unstaged, and non-ignored untracked changes, runs the minimum
956
959
  executable verification (or full fallback), and exits zero only when that exact snapshot passes.
960
+ verify first runs the rest of the repository's gate (the check script's lint, typecheck and check-script
961
+ leaves) and stops at the first failure; --no-checks skips them, and they are skipped in CI unless --checks.
957
962
  verify without --changed resolves the CI event range (or HEAD^..HEAD locally), requires a clean checkout,
958
963
  and exits zero only when the analyzed head is the commit that actually passed verification.
959
964
  check analyzes the change, runs inferred full and selected commands, and shows measured savings.
@@ -0,0 +1,120 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { narrowGateChecks } from "@diffci.com/core/planner/check-narrowing";
5
+ import { discoverGateChecks, workflowGateScripts } from "@diffci.com/core/planner/pipeline-steps";
6
+ import { measureCommand } from "./verify-savings.js";
7
+ function workflowTexts(repoPath) {
8
+ const dir = join(repoPath, ".github", "workflows");
9
+ if (!existsSync(dir))
10
+ return [];
11
+ return readdirSync(dir).filter((name) => /\.ya?ml$/.test(name)).sort().flatMap((name) => {
12
+ try {
13
+ return [readFileSync(join(dir, name), "utf8")];
14
+ }
15
+ catch {
16
+ return [];
17
+ }
18
+ });
19
+ }
20
+ function packageManager(repoPath, declared) {
21
+ const name = typeof declared === "string" ? declared.split("@")[0] : undefined;
22
+ if (name === "pnpm" || name === "yarn" || name === "bun")
23
+ return name;
24
+ if (existsSync(join(repoPath, "pnpm-lock.yaml")))
25
+ return "pnpm";
26
+ if (existsSync(join(repoPath, "yarn.lock")))
27
+ return "yarn";
28
+ if (existsSync(join(repoPath, "bun.lock")) || existsSync(join(repoPath, "bun.lockb")))
29
+ return "bun";
30
+ return "npm";
31
+ }
32
+ function git(repoPath, args) {
33
+ return execFileSync("git", args, { cwd: repoPath, encoding: "utf8", windowsHide: true, maxBuffer: 64 * 1024 * 1024 });
34
+ }
35
+ /** Renames count as a deletion plus an addition: a deleted path can break an import elsewhere. */
36
+ function changedPaths(repoPath, change) {
37
+ const fields = git(repoPath, ["diff", "--name-status", "--no-renames", "-z", change.baseSha, change.headSha]).split("\0").filter(Boolean);
38
+ const changes = [];
39
+ for (let i = 0; i + 1 < fields.length; i += 2) {
40
+ const status = fields[i];
41
+ changes.push({ path: fields[i + 1], status: status === "A" ? "added" : status === "D" ? "deleted" : "modified" });
42
+ }
43
+ return changes;
44
+ }
45
+ function readRepositoryFile(repoPath, path) {
46
+ try {
47
+ return readFileSync(join(repoPath, path), "utf8");
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ }
53
+ /**
54
+ * The checks the repository's gate runs besides its tests (2026-10-29, docs/design/pipeline-impact.md).
55
+ * Agents ran the tests DiffCI selected and then failed `npm run check` after push; these are the rest of
56
+ * the gate. With a change, per-file lint and format checks are narrowed to its files or skipped
57
+ * (check-narrowing.ts); if the change cannot be read, every check runs. No package.json, or one that
58
+ * cannot be read, has none.
59
+ */
60
+ export function plannedChecks(repoPath, change) {
61
+ const path = join(repoPath, "package.json");
62
+ if (!existsSync(path))
63
+ return [];
64
+ let pkg;
65
+ try {
66
+ pkg = JSON.parse(readFileSync(path, "utf8"));
67
+ }
68
+ catch {
69
+ return [];
70
+ }
71
+ if (!pkg.scripts || typeof pkg.scripts !== "object")
72
+ return [];
73
+ const scripts = Object.fromEntries(Object.entries(pkg.scripts).filter((entry) => typeof entry[1] === "string"));
74
+ const manager = packageManager(repoPath, pkg.packageManager);
75
+ const lifecycleHooks = manager !== "pnpm";
76
+ let { checks } = discoverGateChecks(scripts, { lifecycleHooks, workflowScripts: workflowGateScripts(workflowTexts(repoPath), scripts) });
77
+ if (change) {
78
+ try {
79
+ const changes = changedPaths(repoPath, change);
80
+ const files = git(repoPath, ["ls-files", "-z"]).split("\0").filter(Boolean);
81
+ checks = narrowGateChecks(checks, { scripts, changes, files, lifecycleHooks, read: (file) => readRepositoryFile(repoPath, file) });
82
+ }
83
+ catch { /* The change could not be read: every check runs as discovered. */ }
84
+ }
85
+ return checks.map((check) => ({
86
+ id: check.id,
87
+ kind: check.kind,
88
+ decision: check.decision,
89
+ command: check.runsScript
90
+ ? `${manager} run ${check.script}`
91
+ : /^(?:npm|pnpm|yarn|bun|npx|node)\s/.test(check.command) ? check.command : `npx --no-install ${check.command}`,
92
+ reason: check.reason,
93
+ }));
94
+ }
95
+ /** Runs checks in order and stops at the first failure, as the gate's `&&` chain would. SKIP checks
96
+ * are recorded as skipped and not run. */
97
+ export function runChecks(checks, options) {
98
+ const started = Date.now();
99
+ const results = [];
100
+ let failure;
101
+ for (const check of checks) {
102
+ if (check.decision === "SKIP") {
103
+ results.push({ ...check, status: "skipped" });
104
+ continue;
105
+ }
106
+ const remaining = options.timeoutMs - (Date.now() - started);
107
+ if (failure || remaining <= 0) {
108
+ results.push({ ...check, status: "not_run" });
109
+ continue;
110
+ }
111
+ const measurement = measureCommand(check.command, { ...options, timeoutMs: remaining });
112
+ const status = measurement.timedOut ? "timed_out" : measurement.exitCode === 0 && measurement.signal === null ? "passed" : "failed";
113
+ const result = { ...check, status, exit_code: measurement.exitCode, wall_ms: measurement.wallMs };
114
+ results.push(result);
115
+ if (status !== "passed")
116
+ failure = { check: result, measurement };
117
+ }
118
+ const outOfTime = !failure && results.some((result) => result.status === "not_run");
119
+ return { results, failure, outOfTime, wallMs: Date.now() - started };
120
+ }
@@ -5,6 +5,7 @@ import { batchCommand, measureCommands } from "./command-batches.js";
5
5
  import { compareWithBaseline } from "./failure-baseline.js";
6
6
  import { collectEnforcementContext, evaluateEnforcement } from "./enforce-policy.js";
7
7
  import { inferFullCommand, inferSelectedCommand } from "./full-command.js";
8
+ import { plannedChecks, runChecks } from "./gate-checks.js";
8
9
  import { makeGitRunner, observe } from "./observe.js";
9
10
  import { captureWorkingTreeSnapshot } from "./working-tree.js";
10
11
  export const VERIFICATION_SCHEMA = "diffci.verification.v1";
@@ -110,7 +111,17 @@ async function executeWithPolicy(options, scope, before, observation, enforcemen
110
111
  const inferred = inferFullCommand(options.repoPath);
111
112
  return blocked(before, scope, `no executable verification command is available: ${inferred.reason}`, analysis, counts, boundRange);
112
113
  }
113
- const execution = measureCommands(commands, { cwd: options.repoPath, timeoutMs: options.timeoutMs, tailBytes: options.tailBytes });
114
+ // The gate's other checks run first and stop at the first failure, as `npm run check && npm test` would:
115
+ // these are the failures agents met only after push (docs/design/pipeline-impact.md).
116
+ const checkBase = scope === "commit-range" ? range?.baseSha : before.baseSha;
117
+ const checkHead = scope === "commit-range" ? range?.headSha : before.commitSha;
118
+ const planned = options.skipChecks ? [] : plannedChecks(options.repoPath, checkBase && checkHead ? { baseSha: checkBase, headSha: checkHead } : undefined);
119
+ const checkRun = options.skipChecks ? undefined : runChecks(planned, { cwd: options.repoPath, timeoutMs: options.timeoutMs, tailBytes: options.tailBytes });
120
+ const checks = checkRun?.results.length ? checkRun.results : undefined;
121
+ const failedCheck = checkRun?.failure?.check;
122
+ const execution = checkRun?.failure
123
+ ? checkRun.failure.measurement
124
+ : measureCommands(commands, { cwd: options.repoPath, timeoutMs: Math.max(options.timeoutMs - (checkRun?.wallMs ?? 0), 0), tailBytes: options.tailBytes });
114
125
  let after;
115
126
  try {
116
127
  after = captureWorkingTreeSnapshot(options.repoPath);
@@ -123,20 +134,23 @@ async function executeWithPolicy(options, scope, before, observation, enforcemen
123
134
  command,
124
135
  ...(commands.length > 1 ? { commands } : {}),
125
136
  execution,
137
+ ...(checks ? { checks } : {}),
126
138
  };
127
139
  }
128
140
  const unchanged = before.baseSha === after.baseSha && before.treeSha === after.treeSha;
129
- const succeeded = execution.exitCode === 0 && !execution.timedOut;
141
+ const succeeded = !failedCheck && execution.exitCode === 0 && !execution.timedOut;
130
142
  const verification = !unchanged ? "blocked" : succeeded ? "passed" : "failed";
131
143
  const finalReason = !unchanged
132
144
  ? "the working tree changed while verification was running; rerun DiffCI for the new snapshot"
133
145
  : succeeded
134
- ? reason
135
- : execution.timedOut
136
- ? `verification timed out after ${options.timeoutMs}ms`
137
- : `verification command failed with exit code ${String(execution.exitCode)}`;
146
+ ? checks ? `${reason}; ${checkSummary(checks)}` : reason
147
+ : failedCheck
148
+ ? `gate check ${failedCheck.id} ${failedCheck.status === "timed_out" ? "timed out" : `failed with exit code ${String(failedCheck.exit_code)}`}; tests were not run (${failedCheck.command})`
149
+ : execution.timedOut
150
+ ? `verification timed out after ${options.timeoutMs}ms`
151
+ : `verification command failed with exit code ${String(execution.exitCode)}`;
138
152
  const baselineSha = scope === "commit-range" ? range?.baseSha : before.baseSha;
139
- const failureBaseline = verification === "failed" && !execution.timedOut && options.baselineOnFailure && baselineSha
153
+ const failureBaseline = verification === "failed" && !failedCheck && !execution.timedOut && options.baselineOnFailure && baselineSha
140
154
  ? compareWithBaseline({ repoPath: options.repoPath, baseSha: baselineSha, headSha: scope === "commit-range" ? before.baseSha : before.commitSha, commands, headFailures: execution.failingTests ?? [], timeoutMs: options.timeoutMs })
141
155
  : undefined;
142
156
  const baselineNote = failureBaseline && failureBaseline.status !== "unknown"
@@ -156,6 +170,7 @@ async function executeWithPolicy(options, scope, before, observation, enforcemen
156
170
  command,
157
171
  ...(commands.length > 1 ? { commands } : {}),
158
172
  execution,
173
+ ...(checks ? { checks } : {}),
159
174
  snapshot: {
160
175
  ...baseReport(before, scope, boundRange).snapshot,
161
176
  after_base_sha: after.baseSha,
@@ -260,6 +275,12 @@ async function verifyCommitRange(options) {
260
275
  rmSync(temporaryDirectory, { recursive: true, force: true });
261
276
  }
262
277
  }
278
+ function checkSummary(checks) {
279
+ const ran = checks.filter((check) => check.status === "passed").length;
280
+ const narrowed = checks.filter((check) => check.status === "passed" && check.decision === "NARROWED").length;
281
+ const skipped = checks.length - ran;
282
+ return `ran ${ran} gate check(s) first${narrowed ? ` (${narrowed} narrowed to changed files)` : ""}${skipped ? `, skipped ${skipped} the change does not affect` : ""}`;
283
+ }
263
284
  export function verificationExitCode(report) {
264
285
  if (report.verification === "passed")
265
286
  return 0;
@@ -278,6 +299,8 @@ export function formatVerificationSummary(report) {
278
299
  ];
279
300
  if (report.commit_range)
280
301
  lines.splice(2, 0, ` range: ${report.commit_range.base_sha.slice(0, 12)}..${report.commit_range.head_sha.slice(0, 12)}`);
302
+ if (report.checks)
303
+ lines.push(` checks: ${report.checks.map((check) => `${check.id} ${check.status}`).join(", ")}`);
281
304
  if (report.command)
282
305
  lines.push(` command: ${report.command}`);
283
306
  if (report.enforcement) {
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Narrowing gate checks to a change (2026-10-29, docs/design/pipeline-impact.md, phase 1 slice 2).
3
+ *
4
+ * A per-file linter or formatter (`eslint "src/**\/*.ts"`, `prettier --check .`) judges each file on its
5
+ * own, so after a change it only needs the changed files it would have covered. When none of them is
6
+ * covered, it can be skipped.
7
+ *
8
+ * THE RULES, each failing toward running more:
9
+ *
10
+ * - Only `eslint` and `prettier --check` leaves whose every flag is known are touched. Anything else
11
+ * keeps its decision.
12
+ * - A change to the tool's configuration, an ignore file, a file the configuration names by a relative
13
+ * path, `package.json` or a lockfile runs the whole check.
14
+ * - ESLint rules that read other files make lint whole-program: type-aware parsing (`project`,
15
+ * `projectService`, `*TypeChecked` configs), import-plugin rules, boundary plugins, and any nested
16
+ * ESLint configuration (only the root one is read). Whole-program lint runs as written whenever a code
17
+ * file changed and is skipped only when none did. Lint that is only type-aware is skipped when no
18
+ * changed file is in the TypeScript program or the lint target (type-program.ts, slice 4).
19
+ * - `tsc` runs as written unless no changed file is in the project it checks (slice 4).
20
+ * - A deleted code file can break an import in a file that remains: ESLint then runs as written.
21
+ * - `--max-warnings` with a narrowed file list could fail on "file ignored" warnings for files the full
22
+ * run never lints, so it is never narrowed; it can still be skipped.
23
+ * - Paths that need shell quoting, or more than MAX_FILES files, run the whole check.
24
+ *
25
+ * RESIDUAL RISK. A shareable config that enables cross-file rules without any of the names above (a
26
+ * company preset wrapping eslint-plugin-import) is treated as per-file. Required CI stays authoritative.
27
+ */
28
+ import type { GateCheck } from "./pipeline-steps.js";
29
+ export interface ChangedPath {
30
+ path: string;
31
+ status: "added" | "modified" | "deleted";
32
+ }
33
+ export interface NarrowingInput {
34
+ scripts: Readonly<Record<string, string>>;
35
+ changes: readonly ChangedPath[];
36
+ /** Repository-relative read of the checked-out content; undefined when absent. */
37
+ read: (path: string) => string | undefined;
38
+ /** Every tracked path, for finding nested configuration. Without it nested configs are not looked for. */
39
+ files?: readonly string[];
40
+ /** As in GateDiscoveryOptions: whether `npm run x` also runs `prex`/`postx`. Default true. */
41
+ lifecycleHooks?: boolean;
42
+ }
43
+ /** Narrows or skips each lint and format check, and runs or skips each repository-script check
44
+ * (script-reads.ts), for this change; other checks are returned unchanged. */
45
+ export declare function narrowGateChecks(checks: readonly GateCheck[], input: NarrowingInput): GateCheck[];
@@ -0,0 +1,252 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Narrowing gate checks to a change (2026-10-29, docs/design/pipeline-impact.md, phase 1 slice 2).
4
+ *
5
+ * A per-file linter or formatter (`eslint "src/**\/*.ts"`, `prettier --check .`) judges each file on its
6
+ * own, so after a change it only needs the changed files it would have covered. When none of them is
7
+ * covered, it can be skipped.
8
+ *
9
+ * THE RULES, each failing toward running more:
10
+ *
11
+ * - Only `eslint` and `prettier --check` leaves whose every flag is known are touched. Anything else
12
+ * keeps its decision.
13
+ * - A change to the tool's configuration, an ignore file, a file the configuration names by a relative
14
+ * path, `package.json` or a lockfile runs the whole check.
15
+ * - ESLint rules that read other files make lint whole-program: type-aware parsing (`project`,
16
+ * `projectService`, `*TypeChecked` configs), import-plugin rules, boundary plugins, and any nested
17
+ * ESLint configuration (only the root one is read). Whole-program lint runs as written whenever a code
18
+ * file changed and is skipped only when none did. Lint that is only type-aware is skipped when no
19
+ * changed file is in the TypeScript program or the lint target (type-program.ts, slice 4).
20
+ * - `tsc` runs as written unless no changed file is in the project it checks (slice 4).
21
+ * - A deleted code file can break an import in a file that remains: ESLint then runs as written.
22
+ * - `--max-warnings` with a narrowed file list could fail on "file ignored" warnings for files the full
23
+ * run never lints, so it is never narrowed; it can still be skipped.
24
+ * - Paths that need shell quoting, or more than MAX_FILES files, run the whole check.
25
+ *
26
+ * RESIDUAL RISK. A shareable config that enables cross-file rules without any of the names above (a
27
+ * company preset wrapping eslint-plugin-import) is treated as per-file. Required CI stays authoritative.
28
+ */
29
+ import { posix } from "node:path";
30
+ import { decideScriptCheck } from "./script-reads.js";
31
+ import { programMembership, tscProject } from "./type-program.js";
32
+ const MAX_FILES = 100;
33
+ const MAX_COMMAND = 6000;
34
+ const SAFE_PATH = /^[\w./@+-]+$/;
35
+ const CODE = /\.(?:[cm]?[jt]sx?|vue|svelte|astro|json5?|d\.ts)$/;
36
+ const LOCKFILE = /^(?:package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?)$/;
37
+ const ESLINT_CONFIG = /^(?:eslint\.config\.[cm]?[jt]s|\.eslintrc(?:\.(?:js|cjs|json|ya?ml))?|\.eslintignore)$/;
38
+ const PRETTIER_CONFIG = /^(?:\.prettierrc(?:\.(?:json5?|ya?ml|toml|[cm]?[jt]s))?|prettier\.config\.[cm]?[jt]s|\.prettierignore|\.editorconfig)$/;
39
+ const ESLINT_EXTENSIONS = ["js", "mjs", "cjs", "jsx", "ts", "tsx", "mts", "cts"];
40
+ const PRETTIER_EXTENSIONS = [...ESLINT_EXTENSIONS, "json", "json5", "css", "scss", "less", "md", "mdx", "yaml", "yml", "html", "vue", "graphql", "gql", "hbs", "handlebars"];
41
+ /** Configuration text that turns on rules reading files other than the one being linted: type-aware
42
+ * parsing reads the TypeScript program; import and boundary rules read whatever is imported. */
43
+ const TYPE_AWARE = /\bproject(?:Service)?\s*:|TypeChecked|type-checked/;
44
+ const IMPORT_RULES = /\bimport(?:-x)?\/|eslint-plugin-import|import-x|plugin:import|airbnb|boundaries|no-cycle/;
45
+ const TOOLS = {
46
+ eslint: {
47
+ name: "eslint",
48
+ valueFlags: new Set(["--cache-strategy", "--cache-location", "--max-warnings", "--ext", "-c", "--config", "-f", "--format", "--ignore-path", "-o", "--output-file"]),
49
+ booleanFlags: new Set(["--cache", "--quiet", "--fix", "--color", "--no-color", "--no-warn-ignored", "--no-error-on-unmatched-pattern", "--report-unused-disable-directives", "--pass-on-no-patterns"]),
50
+ configs: ESLINT_CONFIG,
51
+ extensions: ESLINT_EXTENSIONS,
52
+ },
53
+ prettier: {
54
+ name: "prettier",
55
+ valueFlags: new Set(["--config", "--ignore-path", "--log-level", "--cache-location", "--cache-strategy", "--end-of-line"]),
56
+ booleanFlags: new Set(["--check", "-c", "--list-different", "-l", "--cache", "--ignore-unknown", "-u", "--no-error-on-unmatched-pattern"]),
57
+ configs: PRETTIER_CONFIG,
58
+ extensions: PRETTIER_EXTENSIONS,
59
+ },
60
+ };
61
+ function words(command) {
62
+ const out = [];
63
+ for (const match of command.trim().matchAll(/"([^"]*)"|'([^']*)'|(\S+)/g)) {
64
+ if (match[3] !== undefined && /["']/.test(match[3]))
65
+ return undefined;
66
+ out.push(match[0]);
67
+ }
68
+ return out;
69
+ }
70
+ const unquote = (word) => word.replace(/^(["'])(.*)\1$/, "$2");
71
+ function parseCommand(command) {
72
+ const all = words(command);
73
+ if (!all)
74
+ return undefined;
75
+ let index = 0;
76
+ if (all[index] === "npx") {
77
+ index++;
78
+ if (all[index] === "--no-install")
79
+ index++;
80
+ }
81
+ const name = all[index];
82
+ if (name !== "eslint" && name !== "prettier")
83
+ return undefined;
84
+ const tool = TOOLS[name];
85
+ const prefix = all.slice(0, ++index);
86
+ const values = new Map();
87
+ const targets = [];
88
+ for (; index < all.length; index++) {
89
+ const word = all[index];
90
+ if (word.startsWith("-")) {
91
+ if (targets.length)
92
+ return undefined;
93
+ const [flag, inline] = word.includes("=") ? [word.slice(0, word.indexOf("=")), word.slice(word.indexOf("=") + 1)] : [word, undefined];
94
+ if (tool.booleanFlags.has(flag)) {
95
+ prefix.push(word);
96
+ continue;
97
+ }
98
+ if (!tool.valueFlags.has(flag))
99
+ return undefined;
100
+ const value = inline ?? all[++index];
101
+ if (value === undefined)
102
+ return undefined;
103
+ values.set(flag, unquote(value));
104
+ prefix.push(...(inline === undefined ? [word, value] : [word]));
105
+ continue;
106
+ }
107
+ targets.push(unquote(word));
108
+ }
109
+ if (targets.length === 0 || targets.some((target) => target.startsWith("!")))
110
+ return undefined;
111
+ if (tool.name === "prettier" && !["--check", "-c", "--list-different", "-l"].some((flag) => prefix.includes(flag)))
112
+ return undefined;
113
+ return { tool, prefix, targets, values };
114
+ }
115
+ function expandBraces(pattern) {
116
+ const match = /\{([^{}]*)\}/.exec(pattern);
117
+ if (!match)
118
+ return [pattern];
119
+ return match[1].split(",").flatMap((alternative) => expandBraces(pattern.slice(0, match.index) + alternative + pattern.slice(match.index + match[0].length)));
120
+ }
121
+ function globMatches(pattern, path) {
122
+ return expandBraces(pattern.replace(/^\.\//, "")).some((p) => {
123
+ const source = p.replace(/[.+^$()|[\]\\]/g, "\\$&")
124
+ .replace(/\*\*\//g, "\0A").replace(/\*\*/g, "\0B").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]")
125
+ .replace(/\0A/g, "(?:.*/)?").replace(/\0B/g, ".*");
126
+ return new RegExp(`^${source}$`).test(path);
127
+ });
128
+ }
129
+ function covers(target, path, extensions) {
130
+ if (/[*?{[]/.test(target))
131
+ return globMatches(target, path);
132
+ const normalized = posix.normalize(target).replace(/\/$/, "");
133
+ if (normalized === path)
134
+ return true;
135
+ const inside = normalized === "." || path.startsWith(`${normalized}/`);
136
+ return inside && extensions.includes(posix.extname(path).slice(1));
137
+ }
138
+ /** Root configuration files of the tool that exist, and the paths each one names relatively. */
139
+ function configReferences(tool, input, explicit) {
140
+ const candidates = explicit ? [posix.normalize(explicit)] : tool.name === "eslint"
141
+ ? ["eslint.config.js", "eslint.config.mjs", "eslint.config.cjs", "eslint.config.ts", "eslint.config.mts", "eslint.config.cts", ".eslintrc.js", ".eslintrc.cjs", ".eslintrc.json", ".eslintrc.yaml", ".eslintrc.yml", ".eslintrc"]
142
+ : [];
143
+ const texts = [];
144
+ const referenced = [];
145
+ for (const path of candidates) {
146
+ const text = input.read(path);
147
+ if (text === undefined)
148
+ continue;
149
+ texts.push(text);
150
+ for (const match of text.matchAll(/["'`](\.{1,2}\/[^"'`\s]+)["'`]/g)) {
151
+ const ref = posix.normalize(posix.join(posix.dirname(path), match[1]));
152
+ // A local plugin's entry file imports its siblings, so its whole directory counts.
153
+ referenced.push(ref, ...(posix.extname(ref) && posix.dirname(ref) !== "." ? [posix.dirname(ref)] : []));
154
+ }
155
+ }
156
+ if (tool.name === "eslint") {
157
+ const manifest = input.read("package.json");
158
+ try {
159
+ const embedded = manifest === undefined ? undefined : JSON.parse(manifest).eslintConfig;
160
+ if (embedded !== undefined)
161
+ texts.push(JSON.stringify(embedded));
162
+ }
163
+ catch { /* package.json changes already run the whole check */ }
164
+ }
165
+ return { texts, referenced };
166
+ }
167
+ function hasHooks(check, input) {
168
+ return check.runsScript && input.lifecycleHooks !== false
169
+ && (input.scripts[`pre${check.script}`] !== undefined || input.scripts[`post${check.script}`] !== undefined);
170
+ }
171
+ /** `tsc` checks a whole program: it runs as written unless no changed file is in that program. */
172
+ function decideTypecheck(check, input, cache) {
173
+ if (!input.files || hasHooks(check, input))
174
+ return check;
175
+ const project = tscProject(check.command);
176
+ if (!project)
177
+ return check;
178
+ const membership = programMembership(project, input, cache);
179
+ return { ...check, decision: membership.inProgram ? "RUN" : "SKIP", reason: membership.reason };
180
+ }
181
+ function decide(check, input, cache) {
182
+ if (check.kind !== "lint" && check.kind !== "format")
183
+ return check;
184
+ if (hasHooks(check, input))
185
+ return check;
186
+ const parsed = parseCommand(check.command);
187
+ if (!parsed)
188
+ return check;
189
+ const { tool, prefix, targets, values } = parsed;
190
+ const run = (reason) => ({ ...check, decision: "RUN", reason });
191
+ const skip = (reason) => ({ ...check, decision: "SKIP", reason });
192
+ const explicitConfig = values.get("-c") ?? values.get("--config");
193
+ const ignorePath = values.get("--ignore-path");
194
+ const { texts, referenced } = configReferences(tool, input, explicitConfig);
195
+ const configChange = input.changes.find(({ path }) => {
196
+ const base = posix.basename(path);
197
+ return tool.configs.test(base) || LOCKFILE.test(base) || path === "package.json"
198
+ || path === explicitConfig || path === ignorePath || (tool.name === "eslint" && base === ".gitignore")
199
+ || referenced.some((ref) => path === ref || path.startsWith(`${ref}/`) || path.startsWith(`${ref}.`));
200
+ });
201
+ if (configChange)
202
+ return run(`${configChange.path} changed: runs the whole ${tool.name} check`);
203
+ const extensions = tool.name === "eslint" && values.has("--ext")
204
+ ? [...ESLINT_EXTENSIONS, ...values.get("--ext").split(",").map((ext) => ext.replace(/^\./, ""))]
205
+ : tool.extensions;
206
+ if (tool.name === "eslint") {
207
+ const nested = input.files?.find((path) => path.includes("/") && ESLINT_CONFIG.test(posix.basename(path)) && !posix.basename(path).endsWith("ignore"));
208
+ const importRules = texts.some((text) => IMPORT_RULES.test(text));
209
+ const typeAware = texts.some((text) => TYPE_AWARE.test(text));
210
+ if (!nested && texts.length > 0 && !importRules && typeAware && input.files) {
211
+ // Type-aware rules read the TypeScript program (slice 4): outside it, and outside the lint target,
212
+ // a change cannot alter the result. `project: "x.json"` names the program; otherwise the root one.
213
+ const named = [...new Set(texts.flatMap((text) => [...text.matchAll(/\bproject\s*:\s*["']([^"']+\.json)["']/g)].map((m) => posix.normalize(m[1]))))];
214
+ const membership = named.length > 1 ? undefined : programMembership(named[0] ?? "tsconfig.json", input, cache);
215
+ const linted = input.changes.find(({ path, status }) => status !== "deleted" && targets.some((target) => covers(target, path, extensions)));
216
+ if (membership && !membership.inProgram && !linted)
217
+ return skip(`type-aware ESLint rules, but ${membership.reason}`);
218
+ return run(`type-aware ESLint rules lint the whole target: ${membership?.reason ?? "several projects are named"}`);
219
+ }
220
+ const crossFile = nested !== undefined || texts.length === 0 || importRules || typeAware;
221
+ if (crossFile) {
222
+ const why = nested ? `nested ESLint config ${nested}` : texts.length === 0 ? "no root ESLint config found" : "type-aware or cross-file ESLint rules";
223
+ const code = input.changes.find(({ path }) => CODE.test(path));
224
+ return code ? run(`${why}: lints the whole target because ${code.path} changed`) : skip(`${why}, but no code file changed`);
225
+ }
226
+ const deleted = input.changes.find(({ path, status }) => status === "deleted" && CODE.test(path));
227
+ if (deleted)
228
+ return run(`${deleted.path} was deleted: an import of it may break in a file that remains`);
229
+ }
230
+ const files = input.changes.filter(({ path, status }) => status !== "deleted" && targets.some((target) => covers(target, path, extensions))).map(({ path }) => path);
231
+ if (files.length === 0)
232
+ return skip(`no changed file is in ${targets.join(" ")}`);
233
+ if (tool.name === "eslint" && values.has("--max-warnings"))
234
+ return run("--max-warnings: a narrowed file list could warn about files the full run ignores");
235
+ if (files.length > MAX_FILES || files.some((path) => !SAFE_PATH.test(path)))
236
+ return run(`${files.length} changed file(s) in the target; runs the whole check`);
237
+ const command = [...prefix, ...files].join(" ");
238
+ if (command.length > MAX_COMMAND)
239
+ return run("the narrowed command would be too long; runs the whole check");
240
+ return { ...check, runsScript: false, command, decision: "NARROWED", reason: `${files.length} changed file(s) in ${targets.join(" ")}` };
241
+ }
242
+ /** Narrows or skips each lint and format check, and runs or skips each repository-script check
243
+ * (script-reads.ts), for this change; other checks are returned unchanged. */
244
+ export function narrowGateChecks(checks, input) {
245
+ // A whole-script leaf's command is the script body, so the same parse applies; a RUN keeps running the
246
+ // script as written.
247
+ const cache = new Map();
248
+ return checks.map((check) => check.kind === "script" ? decideScriptCheck(check, input)
249
+ : check.kind === "typecheck" ? decideTypecheck(check, input, cache)
250
+ : decide(check, input, cache));
251
+ }
252
+ //# sourceMappingURL=check-narrowing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-narrowing.js","sourceRoot":"","sources":["../../src/planner/check-narrowing.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,KAAK,EA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