vigiles 41.1.0 → 41.3.0

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,86 @@
1
+ import { type Reach, type Unresolved } from "./test-reach.js";
2
+ /** Why one harness file was selected. */
3
+ export type SelectionReason = {
4
+ readonly kind: "self";
5
+ } | {
6
+ readonly kind: "run-all";
7
+ readonly trigger: string;
8
+ } | {
9
+ readonly kind: "folder";
10
+ readonly changed: string;
11
+ } | {
12
+ readonly kind: "import";
13
+ readonly changed: string;
14
+ } | {
15
+ readonly kind: "reads";
16
+ readonly changed: string;
17
+ readonly call: string;
18
+ };
19
+ export interface SelectedFile {
20
+ readonly file: string;
21
+ readonly reason: SelectionReason;
22
+ }
23
+ export interface Selection {
24
+ readonly selected: readonly SelectedFile[];
25
+ readonly skipped: readonly string[];
26
+ /**
27
+ * Skipped files that make an effect call whose path could not be evaluated
28
+ * (a function parameter, a command read from a file), with the first such
29
+ * call. Not selected for it — measured, doing so ran most files on every
30
+ * change — but always NAMED, so the gap is in the output, not hidden.
31
+ */
32
+ readonly unresolved: readonly {
33
+ readonly file: string;
34
+ readonly at: Unresolved;
35
+ }[];
36
+ }
37
+ /**
38
+ * Files whose change can alter any harness's outcome, relative to the run's
39
+ * cwd. The CI workflow folder is added from {@link ChangedSince}, because it
40
+ * sits at the git root, which need not be the cwd.
41
+ */
42
+ export declare const DEFAULT_RUN_ALL_ON: readonly string[];
43
+ export interface SelectInput {
44
+ /** Harness files, POSIX, cwd-relative. */
45
+ readonly files: readonly string[];
46
+ /** Changed files, POSIX, cwd-relative. */
47
+ readonly changed: readonly string[];
48
+ /** Globs (cwd-relative) whose change selects every file. */
49
+ readonly runAllOn: readonly string[];
50
+ /** What a harness file reaches (`./test-reach.ts`); asked only when the cheaper rules missed. */
51
+ readonly reach: (file: string) => Reach;
52
+ }
53
+ /** Pure: decide which files run, and why. Order of `files` is kept. */
54
+ export declare function selectTests(input: SelectInput): Selection;
55
+ /** One line per selected file, then the tally — or the explicit zero line. */
56
+ export declare function formatSelection(sel: Selection, ref: string, since: ChangedSince): string;
57
+ /** A ref the user named, or why it cannot be used. */
58
+ export type ParsedRef = {
59
+ readonly kind: "ok";
60
+ readonly ref: string;
61
+ } | {
62
+ readonly kind: "error";
63
+ readonly message: string;
64
+ };
65
+ /**
66
+ * Refuse an empty ref, and one starting with `-`: it reaches `git` as an
67
+ * argument, where it would be read as an OPTION.
68
+ */
69
+ export declare function parseChangedRef(raw: string): ParsedRef;
70
+ export interface ChangedSince {
71
+ /** Changed files, POSIX, relative to the cwd. */
72
+ readonly files: readonly string[];
73
+ /** The commit compared against. */
74
+ readonly base: string;
75
+ /** How `base` was found: the merge-base, or the ref itself in a shallow clone. */
76
+ readonly via: "merge-base" | "ref";
77
+ /** The CI workflow folder as a glob, relative to the cwd — a run-all trigger. */
78
+ readonly workflowsGlob: string;
79
+ }
80
+ export type ChangedResult = ({
81
+ readonly kind: "ok";
82
+ } & ChangedSince) | {
83
+ readonly kind: "error";
84
+ readonly message: string;
85
+ };
86
+ //# sourceMappingURL=test-selection.d.ts.map
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_RUN_ALL_ON = void 0;
4
+ exports.selectTests = selectTests;
5
+ exports.formatSelection = formatSelection;
6
+ exports.parseChangedRef = parseChangedRef;
7
+ /**
8
+ * `vigiles test --changed=<ref>` — run only the harness files a change can reach.
9
+ *
10
+ * A harness file is SELECTED when any of these holds, checked in this order and
11
+ * reported with the first that matched:
12
+ *
13
+ * 1. `self` — the harness file itself changed.
14
+ * 2. `run-all` — a file every harness depends on changed (`package.json`, a
15
+ * lockfile, `.vigilesrc.json`, a CI workflow, or a glob listed in
16
+ * `.vigilesrc.json` `test.runAllOn`). Every file is selected.
17
+ * 3. `folder` — a changed file sits in the harness's own directory or below it.
18
+ * 4. `import` — a changed file is in the harness's static import closure
19
+ * (relative specifiers only, resolved, followed transitively;
20
+ * a build output read as its source — `./test-reach.ts`).
21
+ * 5. `reads` — a changed file is one an effect call in that closure runs,
22
+ * reads or copies, wherever it lives.
23
+ *
24
+ * 🔴 WHY THE FOLDER RULE, AND WHY IT COMES BEFORE IMPORTS. The common harness
25
+ * shape spawns the script it tests (`spawnSync("node", ["hook.mjs"])`) or reads
26
+ * a fixture beside it. Neither is an import, so an import-graph selector cannot
27
+ * see it: measured on Vitest 5.1 (`--changed`, `related`) and Jest 30.5
28
+ * (`--findRelatedTests`), editing a spawned script reported "no affected tests"
29
+ * and exited 0 — a green run that tested nothing. Build systems that get this
30
+ * right (Bazel `data`, Nx `inputs`, Pants `dependencies`) make the author
31
+ * DECLARE such inputs. Colocation is the declaration harness authors already
32
+ * write: the hook and its harness share a folder. So a harness owns its folder,
33
+ * and the import closure adds what lives elsewhere (a shared helper).
34
+ *
35
+ * What it does NOT see, said plainly: a file an effect call reaches through a
36
+ * path nothing is known about (a helper's parameter, a command read from a
37
+ * file). Selecting such harnesses on every change was measured on a consumer
38
+ * repository of 155 harnesses: 114 ran on an average narrowed change instead
39
+ * of 19, which is no selection at all. So they are not selected for it, and the
40
+ * output NAMES them (`Selection.unresolved`); `test.runAllOn` covers a known
41
+ * input, and the full run on the default branch runs every file.
42
+ *
43
+ * Paths here are POSIX and relative to the run's cwd; a path outside it starts
44
+ * with `../` and never matches a folder. Pure: the git diff and the file reads
45
+ * arrive through `src/host/changed-files.io.ts`.
46
+ */
47
+ const node_path_1 = require("node:path");
48
+ const minimatch_1 = require("minimatch");
49
+ const test_reach_js_1 = require("./test-reach.js");
50
+ /**
51
+ * Files whose change can alter any harness's outcome, relative to the run's
52
+ * cwd. The CI workflow folder is added from {@link ChangedSince}, because it
53
+ * sits at the git root, which need not be the cwd.
54
+ */
55
+ exports.DEFAULT_RUN_ALL_ON = [
56
+ "package.json",
57
+ "package-lock.json",
58
+ "npm-shrinkwrap.json",
59
+ "yarn.lock",
60
+ "pnpm-lock.yaml",
61
+ "bun.lock",
62
+ "bun.lockb",
63
+ ".vigilesrc.json",
64
+ ];
65
+ /** Pure: decide which files run, and why. Order of `files` is kept. */
66
+ function selectTests(input) {
67
+ const trigger = input.changed.find((c) => input.runAllOn.some((g) => (0, minimatch_1.minimatch)(c, g, { dot: true })));
68
+ if (trigger !== undefined)
69
+ return runAll(input.files, trigger);
70
+ const decided = input.files.map((file) => ({
71
+ file,
72
+ ...decide(file, input),
73
+ }));
74
+ return {
75
+ selected: decided.flatMap(({ file, reason }) => reason === undefined ? [] : [{ file, reason }]),
76
+ skipped: decided.flatMap((d) => (d.reason ? [] : [d.file])),
77
+ unresolved: decided.flatMap(({ file, reason, unknown }) => reason === undefined && unknown !== undefined
78
+ ? [{ file, at: unknown }]
79
+ : []),
80
+ };
81
+ }
82
+ function runAll(files, trigger) {
83
+ const reason = { kind: "run-all", trigger };
84
+ return {
85
+ selected: files.map((file) => ({ file, reason })),
86
+ skipped: [],
87
+ unresolved: [],
88
+ };
89
+ }
90
+ /**
91
+ * Why `file` runs, or why not: the first unresolved effect call of a skipped
92
+ * file rides along, so its reach is computed once.
93
+ */
94
+ function decide(file, input) {
95
+ if (input.changed.includes(file))
96
+ return { reason: { kind: "self" } };
97
+ const dir = (0, node_path_1.dirname)(file);
98
+ const inFolder = input.changed.find((c) => isUnder(c, dir));
99
+ if (inFolder !== undefined)
100
+ return { reason: { kind: "folder", changed: inFolder } };
101
+ const r = input.reach(file);
102
+ return { reason: reachReason(r, input.changed), unknown: r.unresolved[0] };
103
+ }
104
+ function reachReason(r, changed) {
105
+ const hit = changed
106
+ .map((c) => ({ changed: c, hit: (0, test_reach_js_1.reachMatch)(r, c) }))
107
+ .find((h) => h.hit !== undefined);
108
+ if (hit?.hit === undefined)
109
+ return undefined;
110
+ return hit.hit.kind === "reads"
111
+ ? { kind: "reads", changed: hit.changed, call: hit.hit.call }
112
+ : { kind: "import", changed: hit.changed };
113
+ }
114
+ /** Is `path` in `dir` or below it? A `../` path is outside every folder. */
115
+ function isUnder(path, dir) {
116
+ if (path.startsWith("../"))
117
+ return false;
118
+ return dir === "." || path.startsWith(`${dir}/`);
119
+ }
120
+ /** One line per selected file, then the tally — or the explicit zero line. */
121
+ function formatSelection(sel, ref, since) {
122
+ const total = String(sel.selected.length + sel.skipped.length);
123
+ const how = since.via === "merge-base"
124
+ ? `merge-base of ${ref} and HEAD`
125
+ : `${ref} itself — no merge-base in this clone`;
126
+ const head = `--changed=${ref}: ${String(since.files.length)} changed file(s) since ${since.base.slice(0, 12)} (${how}).`;
127
+ const gap = unresolvedLine(sel);
128
+ if (sel.selected.length === 0) {
129
+ return (`${head}\n0 of ${total} test file(s) selected: no changed file is a harness, ` +
130
+ `in a harness's folder, import closure or effect calls, or a run-all trigger.\n` +
131
+ `Nothing ran; ${String(sel.skipped.length)} skipped. Run without --changed to run them all.${gap}`);
132
+ }
133
+ const lines = sel.selected.map((s) => ` ▸ ${s.file} — ${describeReason(s.reason)}`);
134
+ return (`${head}\nSelected ${String(sel.selected.length)} of ${total} test file(s); ` +
135
+ `${String(sel.skipped.length)} skipped:\n${lines.join("\n")}${gap}`);
136
+ }
137
+ /** The skipped files whose effect calls could not be evaluated — said, never hidden. */
138
+ function unresolvedLine(sel) {
139
+ const first = sel.unresolved[0];
140
+ if (first === undefined)
141
+ return "";
142
+ const { call, file, line } = first.at;
143
+ return (`\n⚠ ${String(sel.unresolved.length)} skipped file(s) also make an effect call whose path ` +
144
+ `cannot be evaluated (first: ${first.file} — ${call}() at ${file}:${String(line)}). ` +
145
+ `A change they read that way is not seen; the full run (no --changed) covers them.`);
146
+ }
147
+ function describeReason(r) {
148
+ switch (r.kind) {
149
+ case "self":
150
+ return "self: the file changed";
151
+ case "run-all":
152
+ return `run-all: ${r.trigger} changed`;
153
+ case "folder":
154
+ return `folder: ${r.changed} changed`;
155
+ case "import":
156
+ return `import: ${r.changed} changed`;
157
+ case "reads":
158
+ return `reads: ${r.changed} changed (${r.call})`;
159
+ }
160
+ }
161
+ /**
162
+ * Refuse an empty ref, and one starting with `-`: it reaches `git` as an
163
+ * argument, where it would be read as an OPTION.
164
+ */
165
+ function parseChangedRef(raw) {
166
+ if (raw === "")
167
+ return { kind: "error", message: "--changed= needs a git ref" };
168
+ if (raw.startsWith("-")) {
169
+ return {
170
+ kind: "error",
171
+ message: `--changed=${raw}: a ref cannot start with "-"`,
172
+ };
173
+ }
174
+ return { kind: "ok", ref: raw };
175
+ }
176
+ //# sourceMappingURL=test-selection.js.map
@@ -121,10 +121,23 @@ function applyHookWrites(file, outcome, root) {
121
121
  }
122
122
  }
123
123
  /**
124
- * Gather a gate's DECLARED context providers (the trusted-host I/O step). Runs
125
- * each declared read-only command via execSync in the hook's cwd; a provider
126
- * that can't resolve yields its default (never throws). The pure registry +
127
- * decision logic live in core/hook-providers.ts — this only injects the real IO.
124
+ * Longest a single provider command may run before it is killed and yields the
125
+ * same default as a failed one. 10 s: the repo's own precedent for a one-shot
126
+ * probe subprocess is 10_000 ms (`src/cli-main.ts`, the `--version` check), the
127
+ * slowest legitimate provider is a `git status` on a large tree (a second or
128
+ * two), and it must stay well under the harness's own hook timeout so a hung
129
+ * provider is reported as a default rather than as a dead hook. Not
130
+ * configurable by design (no new key); a provider needing more is not a fact.
131
+ */
132
+ const PROVIDER_TIMEOUT_MS = 10_000;
133
+ /**
134
+ * Build a gate's DECLARED context (`e.ctx`) — LAZILY. Each declared read-only
135
+ * command runs via execSync in the hook's cwd only when the hook READS its key,
136
+ * at most once per call, bounded by {@link PROVIDER_TIMEOUT_MS}; a provider that
137
+ * can't resolve or times out yields its default (never throws). The pure
138
+ * registry + resolver live in core/hook-providers.ts — this only injects the
139
+ * real IO. Loading `.vigiles/providers/` files stays eager (async import), but
140
+ * only when a `provider()` ref is declared.
128
141
  */
129
142
  async function gatherHookContext(program, file, root) {
130
143
  const needs = (0, hook_program_js_1.hookNeeds)(program);
@@ -135,10 +148,11 @@ async function gatherHookContext(program, file, root) {
135
148
  const registry = hasRef ? await loadProviderRegistry(root) : {};
136
149
  const { execSync } = require("node:child_process");
137
150
  const { isCI } = require("ci-info");
138
- return (0, hook_providers_js_1.gatherContext)(needs, {
151
+ return (0, hook_providers_js_1.lazyContext)(needs, {
139
152
  exec: (command) => execSync(command, {
140
153
  encoding: "utf-8",
141
154
  stdio: ["ignore", "pipe", "ignore"],
155
+ timeout: PROVIDER_TIMEOUT_MS,
142
156
  }),
143
157
  cwd: root,
144
158
  platform: process.platform,
package/dist/hook.d.ts CHANGED
@@ -50,7 +50,7 @@
50
50
  * strong default and is NEVER an unbypassable wall. See `docs/compiled-hooks.md`.
51
51
  */
52
52
  export { experimental_defineHook, experimental_defineFileGate, experimental_definePromptGate, experimental_defineStopGate, tools, allow, deny, ask, commandView, pathView, gateAction, hookMode, experimental_defineInject, inject, experimental_defineReact, run, notice, nothing, responseView, decideProgram, decideFileGate, decidePromptGate, decideStopGate, runInject, runReact, runHookProgram, decisionExitCode, dispatchKind, hookRouting, hookNeeds, injectionOf, outcomeWrites, matchesTool, invalidToolPatterns, compileHookProgram, checkHookImports, stampHook, verifyHookStamp, HookCompileError, } from "./core/hook-program.js";
53
- export type { Decision, HookMode, GateAction, CommandView, PathView, ResponseView, BashToolEvent, FileToolEvent, PromptEvent, StopEvent, ReactEvent, SessionEvent, HookProgram, FileGateHook, PromptGateHook, StopGateHook, InjectHook, ReactHook, AnyHook, DispatchKind, Injection, Reaction, RunReaction, CompiledHookProgram, CompileHookOptions, RawHookEvent, HookProgramOutcome, } from "./core/hook-program.js";
53
+ export type { Decision, HookMode, GateAction, CommandView, PathView, ResponseView, BashToolEvent, FileToolEvent, PromptEvent, StopEvent, ReactEvent, BashReactEvent, ToolReactEvent, SessionEvent, HookProgram, FileGateHook, PromptGateHook, StopGateHook, InjectHook, ReactHook, AnyHook, DispatchKind, Injection, Reaction, RunReaction, CompiledHookProgram, CompileHookOptions, RawHookEvent, HookProgramOutcome, } from "./core/hook-program.js";
54
54
  export { provide, dangerously, defineProvider, provider, } from "./core/hook-providers.js";
55
55
  export { state, record, stateFact, isValidStateKey, isStateNeed, isStateWrite, admissibleWrites, durationSeconds, HookStateError, } from "./core/hook-state.js";
56
56
  export type { StateFact, StateEntry, StateNeed, StateWrite, Duration, } from "./core/hook-state.js";
@@ -0,0 +1,23 @@
1
+ import type { ChangedResult } from "../core/test-selection.js";
2
+ import { type BaseDecision, type BaseFacts } from "../core/changed-base.js";
3
+ import { type SourceHost } from "../core/test-reach.js";
4
+ /** Reads for the import closure, from disk. */
5
+ export declare const nodeSourceHost: SourceHost;
6
+ /**
7
+ * Files changed between `ref`'s merge-base with HEAD and the WORKING TREE:
8
+ * committed, staged, unstaged, and untracked (not ignored). Renames count as
9
+ * both paths. With no merge-base (a shallow clone, such as a CI checkout of a
10
+ * pull request's merge commit), the ref itself is the base — for a merge commit
11
+ * that is exactly the pull request's change, and elsewhere it can only add
12
+ * files, never drop one. Paths come back relative to the REAL cwd.
13
+ */
14
+ export declare function changedSince(cwd: string, ref: string): ChangedResult;
15
+ /** Where this run is: the CI provider and event, and the local default branch. */
16
+ export declare function readBaseFacts(cwd: string, env: Readonly<NodeJS.ProcessEnv>): BaseFacts;
17
+ /**
18
+ * Make a decided base present: a shallow CI checkout does not carry the pull
19
+ * request's base commit, so it is fetched from origin. A base that is still
20
+ * missing turns the decision into "everything runs", with the reason.
21
+ */
22
+ export declare function ensureBase(cwd: string, d: BaseDecision): BaseDecision;
23
+ //# sourceMappingURL=changed-files.io.d.ts.map
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.nodeSourceHost = void 0;
7
+ exports.changedSince = changedSince;
8
+ exports.readBaseFacts = readBaseFacts;
9
+ exports.ensureBase = ensureBase;
10
+ /**
11
+ * The machine side of `vigiles test --changed=<ref>`: what git says changed,
12
+ * and the file reads the import closure needs. The decision is pure and lives
13
+ * in `src/core/test-selection.ts`.
14
+ */
15
+ const typescript_1 = __importDefault(require("typescript"));
16
+ const node_child_process_1 = require("node:child_process");
17
+ const node_fs_1 = require("node:fs");
18
+ const node_path_1 = require("node:path");
19
+ const changed_base_js_1 = require("../core/changed-base.js");
20
+ const test_reach_js_1 = require("../core/test-reach.js");
21
+ /** Reads for the import closure, from disk. */
22
+ exports.nodeSourceHost = {
23
+ read: (path) => {
24
+ try {
25
+ return (0, node_fs_1.readFileSync)(path, "utf-8");
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ },
31
+ // Total: tsc's resolver probes `<main>/index.ts`, a path THROUGH a file when
32
+ // `main` is a file. Node 20 throws ENOTDIR there despite `throwIfNoEntry`
33
+ // (newer Node swallows it), and a throw here killed `test --changed`.
34
+ isFile: (path) => {
35
+ try {
36
+ return (0, node_fs_1.statSync)(path, { throwIfNoEntry: false })?.isFile() === true;
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ },
42
+ realpath: (path) => {
43
+ try {
44
+ return (0, node_fs_1.realpathSync)(path);
45
+ }
46
+ catch {
47
+ return path;
48
+ }
49
+ },
50
+ // tsc's own walk, so a tsconfig's `include`/`exclude` mean what tsc means.
51
+ readDirectory: (...args) => typescript_1.default.sys.readDirectory(...args),
52
+ };
53
+ function git(cwd, args) {
54
+ try {
55
+ return (0, node_child_process_1.execFileSync)("git", args, {
56
+ cwd,
57
+ encoding: "utf-8",
58
+ stdio: ["ignore", "pipe", "pipe"],
59
+ });
60
+ }
61
+ catch {
62
+ return undefined;
63
+ }
64
+ }
65
+ /** `ref` as a commit, its merge-base with HEAD when the clone has one. */
66
+ function baseOf(cwd, ref) {
67
+ const commit = git(cwd, [
68
+ "rev-parse",
69
+ "--verify",
70
+ "--quiet",
71
+ `${ref}^{commit}`,
72
+ ])?.trim();
73
+ if (commit === undefined)
74
+ return undefined;
75
+ const mergeBase = git(cwd, ["merge-base", commit, "HEAD"])?.trim();
76
+ return mergeBase === undefined
77
+ ? { base: commit, via: "ref" }
78
+ : { base: mergeBase, via: "merge-base" };
79
+ }
80
+ /** Root-relative paths: the diff to the working tree, plus untracked files. */
81
+ function changedPaths(root, base) {
82
+ const diff = git(root, ["diff", "--name-only", "--no-renames", "-z", base]);
83
+ if (diff === undefined)
84
+ return undefined;
85
+ const untracked = git(root, ["ls-files", "--others", "--exclude-standard", "-z"]) ?? "";
86
+ return [...new Set([...diff.split("\0"), ...untracked.split("\0")])].filter((p) => p !== "");
87
+ }
88
+ /**
89
+ * Files changed between `ref`'s merge-base with HEAD and the WORKING TREE:
90
+ * committed, staged, unstaged, and untracked (not ignored). Renames count as
91
+ * both paths. With no merge-base (a shallow clone, such as a CI checkout of a
92
+ * pull request's merge commit), the ref itself is the base — for a merge commit
93
+ * that is exactly the pull request's change, and elsewhere it can only add
94
+ * files, never drop one. Paths come back relative to the REAL cwd.
95
+ */
96
+ function changedSince(cwd, ref) {
97
+ const root = git(cwd, ["rev-parse", "--show-toplevel"])?.trim();
98
+ if (root === undefined) {
99
+ return {
100
+ kind: "error",
101
+ message: `--changed=${ref}: ${cwd} is not inside a git repository`,
102
+ };
103
+ }
104
+ const found = baseOf(cwd, ref);
105
+ if (found === undefined) {
106
+ const hint = `In a shallow clone, fetch it first (git fetch origin ${ref}).`;
107
+ return { kind: "error", message: `--changed=${ref}: unknown ref. ${hint}` };
108
+ }
109
+ const paths = changedPaths(root, found.base);
110
+ if (paths === undefined) {
111
+ return {
112
+ kind: "error",
113
+ message: `--changed=${ref}: git diff against ${found.base} failed`,
114
+ };
115
+ }
116
+ const real = (0, node_fs_1.realpathSync)(cwd);
117
+ const rel = (p) => (0, test_reach_js_1.posixRelative)(real, (0, node_path_1.join)(root, p));
118
+ return {
119
+ kind: "ok",
120
+ ...found,
121
+ files: paths.map(rel).sort(),
122
+ workflowsGlob: `${rel(".github/workflows")}/**`,
123
+ };
124
+ }
125
+ // ---------------------------------------------------------------------------
126
+ // Bare `--changed`: the facts `decideBase` needs, and the fetch it may ask for
127
+ // ---------------------------------------------------------------------------
128
+ function readEvent(path) {
129
+ if (path === undefined)
130
+ return undefined;
131
+ try {
132
+ const payload = JSON.parse((0, node_fs_1.readFileSync)(path, "utf-8"));
133
+ return payload;
134
+ }
135
+ catch {
136
+ return undefined;
137
+ }
138
+ }
139
+ function ciFacts(env) {
140
+ if (env["GITHUB_ACTIONS"] === "true") {
141
+ return {
142
+ provider: "github",
143
+ event: env["GITHUB_EVENT_NAME"],
144
+ prBase: (0, changed_base_js_1.prBaseFromEvent)(readEvent(env["GITHUB_EVENT_PATH"])),
145
+ baseRef: env["GITHUB_BASE_REF"],
146
+ };
147
+ }
148
+ const ci = env["CI"];
149
+ const onCi = ci !== undefined && ci !== "" && ci !== "false" && ci !== "0";
150
+ return onCi ? { provider: "other" } : { provider: "none" };
151
+ }
152
+ function hasCommit(cwd, ref) {
153
+ return (git(cwd, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]) !==
154
+ undefined);
155
+ }
156
+ const DEFAULT_BRANCHES = ["origin/HEAD", "origin/main", "origin/master"];
157
+ /** Where this run is: the CI provider and event, and the local default branch. */
158
+ function readBaseFacts(cwd, env) {
159
+ return {
160
+ ci: ciFacts(env),
161
+ defaultBranch: DEFAULT_BRANCHES.find((b) => hasCommit(cwd, b)),
162
+ };
163
+ }
164
+ /**
165
+ * Make a decided base present: a shallow CI checkout does not carry the pull
166
+ * request's base commit, so it is fetched from origin. A base that is still
167
+ * missing turns the decision into "everything runs", with the reason.
168
+ */
169
+ function ensureBase(cwd, d) {
170
+ if (d.kind === "all" || hasCommit(cwd, d.ref))
171
+ return d;
172
+ if (d.fetch !== undefined)
173
+ git(cwd, ["fetch", "--no-tags", "--depth=1", "origin", d.fetch]);
174
+ return hasCommit(cwd, d.ref)
175
+ ? d
176
+ : {
177
+ kind: "all",
178
+ why: `${d.why}: not in this clone and could not be fetched, so every file runs`,
179
+ };
180
+ }
181
+ //# sourceMappingURL=changed-files.io.js.map
@@ -3270,6 +3270,25 @@
3270
3270
  },
3271
3271
  "additionalProperties": false
3272
3272
  },
3273
+ "test": {
3274
+ "type": "object",
3275
+ "properties": {
3276
+ "runAllOn": {
3277
+ "anyOf": [
3278
+ {
3279
+ "type": "string"
3280
+ },
3281
+ {
3282
+ "type": "array",
3283
+ "items": {
3284
+ "type": "string"
3285
+ }
3286
+ }
3287
+ ]
3288
+ }
3289
+ },
3290
+ "additionalProperties": false
3291
+ },
3273
3292
  "nudge": {
3274
3293
  "type": "string",
3275
3294
  "const": "dismissed"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigiles",
3
- "version": "41.1.0",
3
+ "version": "41.3.0",
4
4
  "description": "Audit, test and measure the harness your AI agent runs on — grade your CLAUDE.md / AGENTS.md, skills, subagents and hooks, run them against a scripted model, and measure whether they actually fire.",
5
5
  "keywords": [
6
6
  "claude-code",