@lelouchhe/agent-evals 0.1.1 → 0.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.
Files changed (79) hide show
  1. package/README.md +27 -18
  2. package/dist/checkers/file/index.js +181 -13
  3. package/dist/checkers/judge/index.d.ts +1 -1
  4. package/dist/checkers/judge/index.js +243 -31
  5. package/dist/checkers/judge/prompt.d.ts +4 -3
  6. package/dist/checkers/judge/prompt.js +22 -3
  7. package/dist/cli.js +171 -35
  8. package/dist/engine/authoring.js +108 -13
  9. package/dist/engine/check-runner.js +18 -3
  10. package/dist/engine/check-sandbox.js +9 -6
  11. package/dist/engine/config.d.ts +31 -2
  12. package/dist/engine/config.js +16 -10
  13. package/dist/engine/env-source.js +82 -14
  14. package/dist/engine/files.d.ts +2 -5
  15. package/dist/engine/files.js +4 -6
  16. package/dist/engine/mocks.js +72 -46
  17. package/dist/engine/params.d.ts +2 -0
  18. package/dist/engine/params.js +10 -0
  19. package/dist/engine/registry.d.ts +11 -0
  20. package/dist/engine/report.js +43 -8
  21. package/dist/engine/results.d.ts +7 -0
  22. package/dist/engine/results.js +9 -6
  23. package/dist/engine/run.d.ts +4 -1
  24. package/dist/engine/run.js +171 -28
  25. package/dist/engine/skills.js +12 -5
  26. package/dist/engine/view.d.ts +1 -1
  27. package/dist/engine/view.js +125 -10
  28. package/dist/engine/workspace.d.ts +7 -0
  29. package/dist/engine/workspace.js +37 -27
  30. package/dist/index.d.ts +4 -4
  31. package/dist/index.js +2 -2
  32. package/dist/platform/index.d.ts +31 -0
  33. package/dist/platform/index.js +88 -0
  34. package/dist/platform/linux/index.d.ts +2 -0
  35. package/dist/platform/linux/index.js +40 -0
  36. package/dist/platform/linux/launch.d.ts +8 -0
  37. package/dist/platform/linux/launch.js +25 -0
  38. package/dist/platform/linux/policy.d.ts +46 -0
  39. package/dist/platform/linux/policy.js +388 -0
  40. package/dist/platform/linux/supervise.d.ts +8 -0
  41. package/dist/platform/linux/supervise.js +124 -0
  42. package/dist/platform/macos/index.d.ts +2 -0
  43. package/dist/platform/macos/index.js +59 -0
  44. package/dist/platform/macos/launch.d.ts +2 -8
  45. package/dist/platform/macos/launch.js +5 -3
  46. package/dist/platform/macos/policy.d.ts +3 -21
  47. package/dist/platform/macos/policy.js +5 -2
  48. package/dist/platform/macos/supervise.d.ts +3 -25
  49. package/dist/platform/posix-forwarder-client.mjs +129 -0
  50. package/dist/platform/posix-forwarder.sh +9 -0
  51. package/dist/platform/posix-helpers.d.ts +22 -0
  52. package/dist/platform/posix-helpers.js +97 -0
  53. package/dist/platform/types.d.ts +118 -0
  54. package/dist/platform/types.js +1 -0
  55. package/dist/platform/windows/forwarder-client.mjs +165 -0
  56. package/dist/platform/windows/forwarder.cmd +3 -0
  57. package/dist/platform/windows/forwarder.ps1 +2 -0
  58. package/dist/platform/windows/forwarder.sh +2 -0
  59. package/dist/platform/windows/index.d.ts +2 -0
  60. package/dist/platform/windows/index.js +225 -0
  61. package/dist/platform/windows/launch.d.ts +3 -0
  62. package/dist/platform/windows/launch.js +30 -0
  63. package/dist/platform/windows/policy.d.ts +17 -0
  64. package/dist/platform/windows/policy.js +155 -0
  65. package/dist/platform/windows/setup.ps1 +112 -0
  66. package/dist/platform/windows/supervise.d.ts +2 -0
  67. package/dist/platform/windows/supervise.js +142 -0
  68. package/dist/platform/windows/win-sandbox.exe +0 -0
  69. package/dist/runners/acp/commands.js +2 -3
  70. package/dist/runners/acp/environment.d.ts +1 -7
  71. package/dist/runners/acp/environment.js +18 -48
  72. package/dist/runners/acp/index.js +5 -1
  73. package/dist/runners/acp/session.d.ts +1 -1
  74. package/dist/runners/pi/index.js +2 -2
  75. package/dist/runners/pi/session.d.ts +1 -1
  76. package/dist/runners/pi/session.js +27 -44
  77. package/dist/runners/pi/supervisor.js +1 -0
  78. package/package.json +5 -3
  79. package/dist/engine/forwarder.sh +0 -61
package/README.md CHANGED
@@ -5,19 +5,19 @@
5
5
 
6
6
  A toolkit for evaluating AI agent systems on the real CLI and harness layer.
7
7
 
8
- Requirements: macOS with `sandbox-exec` and Node.js 24+. The package declares `os: darwin`, so npm refuses to install it on another platform; the CLI is published as `@lelouchhe/agent-evals`, and a run additionally needs an invocation `.env` and prepared harness directories, per [Setup](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md). Version 0.1.1 is the first published state — the toolkit, not a finished instrument; [Roadmap](https://github.com/LelouchHe/agent-evals/blob/main/docs/roadmap.md) lists what is still open.
8
+ Requirements: Node.js 24+ on macOS (`sandbox-exec`), Linux, WSL2 (`bubblewrap` / `bwrap` with unprivileged user namespaces), or native Windows (`win-sandbox.exe`; WSL1 is not supported). See [Platforms](https://github.com/LelouchHe/agent-evals/blob/main/docs/platforms.md) for backend details and [Setup](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md) for `.env` and harness directories. [Roadmap](https://github.com/LelouchHe/agent-evals/blob/main/docs/roadmap.md) lists what is still open.
9
9
 
10
10
  > **Status: pre-1.0.** Breaking changes ship in a minor release until 1.0.
11
11
 
12
12
  ## Why Agent Evals
13
13
 
14
14
  - **Evaluate the whole agent system, not a bare model API.** Outcomes depend on the model _plus_ its harness, skills, instructions and tool loop. One generic [ACP runner](https://github.com/LelouchHe/agent-evals/blob/main/docs/configuration.md#acp-runner-type-acp) drives unmodified [Pi](https://github.com/LelouchHe/agent-evals/blob/main/examples/agents/pi.yml), [Claude Code](https://github.com/LelouchHe/agent-evals/blob/main/examples/agents/claude.yml) and [GitHub Copilot CLI](https://github.com/LelouchHe/agent-evals/blob/main/examples/agents/copilot.yml) side by side, so changing a skill, instruction, flag or harness is a controlled experiment.
15
- - **Host-native OS sandboxing, not Linux containers.** Each run executes on the host under macOS Seatbelt in its own run root with a private `HOME` and workspace ([layout](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md#how-isolated-harness-homes-work)). Host toolchains and platform behavior stay real, while operator dotfiles, login keychains, rubrics and check-time acceptance tests stay unreachable to the agent.
15
+ - **Host-native OS sandboxing, not Linux containers.** Each run executes on the host under macOS Seatbelt, Linux `bubblewrap`, or Windows sandbox users (`win-sandbox.exe`) in its own run root with a private `HOME` and workspace ([layout](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md#how-isolated-harness-homes-work)). Host toolchains and platform behavior stay real, while operator dotfiles, login keychains, rubrics and check-time acceptance tests stay unreachable to the agent.
16
16
  - **Three evidence sources, deterministic first.** Checks read workspace side effects (`file`, sandboxed `shell`), host-recorded calls to [mocked commands](https://github.com/LelouchHe/agent-evals/blob/main/docs/mocks.md) (`mock`) and the run's trace (`trace`), with an LLM `judge` only where qualitative judgment is needed. A `noop` baseline runner catches checks that pass without an agent.
17
17
 
18
18
  ## What a Case Looks Like
19
19
 
20
- A case is one YAML file: a task, a prepared environment, and the checks that judge what the run left behind. Abridged from the [worked example](https://github.com/LelouchHe/agent-evals/blob/main/examples/cases/deploy-runbook/case.yml):
20
+ A case is one YAML file: a task, a prepared environment, and the checks that judge what the run left behind. Abridged from the [worked example](https://github.com/LelouchHe/agent-evals/blob/main/examples/cases/deploy-runbook-posix/case.yml):
21
21
 
22
22
  ```yaml
23
23
  input: Our deploy failed. Read deploy.log, confirm the release state with `deployctl status`, then write the cause and the commands to fix it into diagnosis.md.
@@ -71,32 +71,39 @@ npm install -g @lelouchhe/agent-evals # or: npx @lelouchhe/agent-evals
71
71
  agent-evals --help
72
72
  ```
73
73
 
74
- Running a case is macOS-only and needs an invocation `.env` plus a prepared harness directory ([Setup](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md)). The worked example below runs from a checkout, because its fixtures and agent files live in the repository.
74
+ > **Note on the bundled Windows binary:** Published npm packages include a small prebuilt Windows helper (`dist/platform/windows/win-sandbox.exe`, ~400 KB), compiled from [`native/win-sandbox/`](https://github.com/LelouchHe/agent-evals/tree/main/native/win-sandbox) in CI with npm provenance so native Windows installs work without Rust. It is **only used on native Windows** (`win32`) and is never executed on macOS or Linux.
75
75
 
76
- Follow [Setup](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md) once to configure `.env` and prepare the harness directories you want to run, then inspect and run the worked example ([`examples/cases/deploy-runbook`](https://github.com/LelouchHe/agent-evals/blob/main/examples/cases/deploy-runbook/case.yml) — seven named cases across Pi, Claude Code, Copilot CLI and `noop`, exercising project skills, every `mocks.shell` action, hidden check-time `shell` acceptance scripts and all five checkers):
76
+ Running a case supports macOS, Linux, WSL2, and native Windows ([Platforms](https://github.com/LelouchHe/agent-evals/blob/main/docs/platforms.md)) and needs an invocation `.env` plus a prepared harness directory ([Setup](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md)). On native Windows, run `agent-evals setup sandbox` once from an Administrator prompt before your first evaluation. The worked example below runs from a checkout, because its fixtures and agent files live in the repository.
77
+
78
+ Follow [Setup](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md) once to configure `.env` and prepare the harness directories you want to run, then inspect and run the worked example ([`examples/cases/deploy-runbook-posix`](https://github.com/LelouchHe/agent-evals/blob/main/examples/cases/deploy-runbook-posix/case.yml) — seven named cases across Pi, Claude Code, Copilot CLI and `noop`, exercising project skills, `~/` HOME placement, every `mocks.shell` action, hidden check-time `shell` acceptance scripts and all five checkers):
77
79
 
78
80
  ```sh
79
81
  npm ci
80
82
  cp .env.example .env # fill in harness paths and keys (see docs/setup.md)
81
- npm run eval -- view examples/cases/deploy-runbook/case.yml --case pi-with-skill
83
+ npm run eval -- view examples/cases/deploy-runbook-posix/case.yml --case pi-with-skill
82
84
  npm run eval -- config examples/agents/pi.yml
83
- npm run eval -- run examples/cases/deploy-runbook/case.yml --case pi-with-skill
85
+ npm run eval -- run examples/cases/deploy-runbook-posix/case.yml --case pi-with-skill
86
+ npm run eval -- run examples/cases/deploy-runbook-posix/case.yml --reps 3 --jobs 3 --retain on-failure --results-dir /tmp/deploy-runbook
84
87
  npm run eval -- report --matrix /tmp/deploy-runbook # after a sweep: one row per check
85
88
  ```
86
89
 
87
- [`deploy-runbook-native`](https://github.com/LelouchHe/agent-evals/blob/main/examples/cases/deploy-runbook-native/case.yml) runs the same task through the native Pi runner using an installed `pi` CLI and provider key alone.
90
+ Additional examples showcase other angles of the toolkit:
91
+
92
+ - [`deploy-runbook-windows`](https://github.com/LelouchHe/agent-evals/blob/main/examples/cases/deploy-runbook-windows/case.yml) runs the same ACP evaluation natively on Windows with PowerShell checks, `.cmd` mocks, and `~/` HOME placement.
93
+ - [`deploy-runbook-native-pi`](https://github.com/LelouchHe/agent-evals/blob/main/examples/cases/deploy-runbook-native-pi/case.yml) runs the same task through the native Pi runner using an installed `pi` CLI and provider key alone, with `judge` inheriting the case's runner.
88
94
 
89
95
  ## Documentation
90
96
 
91
- | Document | Question it answers |
92
- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
93
- | [Setup](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md) | How do I install the CLI, configure `.env`, and prepare Pi, Claude Code and Copilot? |
94
- | [Writing Cases](https://github.com/LelouchHe/agent-evals/blob/main/docs/cases.md) | How should tasks, fixtures, baselines and assertions be designed? |
95
- | [Configuration Reference](https://github.com/LelouchHe/agent-evals/blob/main/docs/configuration.md) | How do YAML files, placeholders, runners, checkers and result records work? |
96
- | [Mocks](https://github.com/LelouchHe/agent-evals/blob/main/docs/mocks.md) | How do I substitute or spy on shell commands, and what does `mocks.json` contain? |
97
- | [Extensions](https://github.com/LelouchHe/agent-evals/blob/main/docs/extensions.md) | How do I write and load a custom runner or checker? |
98
- | [Architecture](https://github.com/LelouchHe/agent-evals/blob/main/docs/architecture.md) | How do the modules cooperate, and what runtime/development limits apply today? |
99
- | [Roadmap](https://github.com/LelouchHe/agent-evals/blob/main/docs/roadmap.md) | What is planned next (M6 sandbox config, M7 MCP mocks), and where are past archives? |
97
+ | Document | Question it answers |
98
+ | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
99
+ | [Setup](https://github.com/LelouchHe/agent-evals/blob/main/docs/setup.md) | How do I install the CLI, configure `.env`, and prepare Pi, Claude Code and Copilot? |
100
+ | [Writing Cases](https://github.com/LelouchHe/agent-evals/blob/main/docs/cases.md) | How should tasks, fixtures, baselines and assertions be designed? |
101
+ | [Configuration Reference](https://github.com/LelouchHe/agent-evals/blob/main/docs/configuration.md) | How do YAML files, placeholders, runners, checkers and result records work? |
102
+ | [Mocks](https://github.com/LelouchHe/agent-evals/blob/main/docs/mocks.md) | How do I substitute or spy on shell commands, and what does `mocks.json` contain? |
103
+ | [Extensions](https://github.com/LelouchHe/agent-evals/blob/main/docs/extensions.md) | How do I write and load a custom runner or checker? |
104
+ | [Platforms](https://github.com/LelouchHe/agent-evals/blob/main/docs/platforms.md) | Which host OSes are supported (macOS, Linux, WSL2, native Windows) and how each sandbox works? |
105
+ | [Architecture](https://github.com/LelouchHe/agent-evals/blob/main/docs/architecture.md) | How do the modules cooperate, and what runtime/development limits apply today? |
106
+ | [Roadmap](https://github.com/LelouchHe/agent-evals/blob/main/docs/roadmap.md) | What is planned next (M6 sandbox config, M7 MCP mocks), and where are past archives? |
100
107
 
101
108
  Delivered milestone records (`M1`–`M5`) are preserved under [`docs/archive/`](https://github.com/LelouchHe/agent-evals/blob/main/docs/archive/).
102
109
 
@@ -111,7 +118,9 @@ Serialize checkout build/test/eval commands because `npm run build` replaces `di
111
118
 
112
119
  ## Releasing
113
120
 
114
- [CI](https://github.com/LelouchHe/agent-evals/blob/main/.github/workflows/ci.yml) runs the gate on macOS for every pull request and push to `main`. A release is a tag: push `vX.Y.Z` matching `package.json`'s version, and [publish](https://github.com/LelouchHe/agent-evals/blob/main/.github/workflows/publish.yml) re-runs that gate on macOS, publishes `@lelouchhe/agent-evals` to npm with provenance, and creates the GitHub release. The workflow needs the `NPM_TOKEN` repository secret: an npm token with publish rights for the `@lelouchhe` scope. A scoped package defaults to restricted, so the publish command passes `--access public`.
121
+ [CI](https://github.com/LelouchHe/agent-evals/blob/main/.github/workflows/ci.yml) runs the deterministic `check` gate on macOS, Linux, and Windows for every pull request and push to `main`. It also defines an optional 3-OS live ACP `smoke` job (`pi-acp` running `deploy-runbook-posix` on macOS/Linux and `deploy-runbook-windows` on Windows): set the `OPENCODE_API_KEY` repository secret (`gh secret set OPENCODE_API_KEY`) to enable it on CI / `workflow_dispatch`, and remove the secret (`gh secret remove OPENCODE_API_KEY`) when you want `smoke` skipped automatically.
122
+
123
+ A release is a tag: push `vX.Y.Z` matching `package.json`'s version, and [publish](https://github.com/LelouchHe/agent-evals/blob/main/.github/workflows/publish.yml) re-runs that gate, publishes `@lelouchhe/agent-evals` to npm with provenance, and creates the GitHub release. The workflow needs the `NPM_TOKEN` repository secret: an npm token with publish rights for the `@lelouchhe` scope. A scoped package defaults to restricted, so the publish command passes `--access public`.
115
124
 
116
125
  ## License
117
126
 
@@ -1,18 +1,18 @@
1
+ import { lstat, readdir, stat } from "node:fs/promises";
2
+ import { join, posix } from "node:path";
1
3
  import { z } from "zod";
2
- import { patternListSchema, runRelativePathSchema } from "../../engine/params.js";
4
+ import { patternListSchema, runFilePathSchema } from "../../engine/params.js";
3
5
  import { truncate } from "../../engine/truncate.js";
4
6
  import { searches } from "../../engine/regex.js";
5
- import { isMissing, readRunFile, readRunTree, runPathExists, } from "../../engine/workspace.js";
7
+ import { WorkspacePathError, assertRunRoot, isMissing, readRunFile, readRunTree, resolveWorkspacePath, runPathExists, } from "../../engine/workspace.js";
6
8
  import { ConfigError, errorMessage } from "../../engine/config.js";
7
- /** A workspace path, or `~/…` for a file in the run HOME. `~/` alone names HOME, not a file. */
8
- const filePathSchema = runRelativePathSchema.superRefine((value, context) => {
9
- if (value === "~/" || value === "~/.") {
10
- context.addIssue({ code: "custom", message: "must name a file or directory inside HOME, not HOME itself" });
11
- }
12
- });
9
+ const GLOB_META = /[*?[\]{}]/u;
10
+ function isGlob(path) {
11
+ return GLOB_META.test(path);
12
+ }
13
13
  const fileCheckParamsSchema = z
14
14
  .strictObject({
15
- path: filePathSchema,
15
+ path: runFilePathSchema,
16
16
  exists: z.boolean().optional(),
17
17
  changed: z.boolean().optional(),
18
18
  matches: patternListSchema.optional(),
@@ -28,6 +28,13 @@ const fileCheckParamsSchema = z
28
28
  message: "needs at least one of exists, changed, matches, or notMatches",
29
29
  });
30
30
  }
31
+ if (isGlob(params.path) && params.changed !== undefined) {
32
+ context.addIssue({
33
+ code: "custom",
34
+ path: ["changed"],
35
+ message: "changed does not support glob patterns; name a specific file or directory",
36
+ });
37
+ }
31
38
  })
32
39
  .transform((params) => ({
33
40
  path: params.path,
@@ -56,6 +63,13 @@ class FileChecker {
56
63
  const params = this.#params;
57
64
  const target = this.#target(context);
58
65
  const results = [];
66
+ const declared = [
67
+ ...params.matches.map((pattern) => ({ kind: "matches", pattern })),
68
+ ...params.notMatches.map((pattern) => ({ kind: "notMatches", pattern })),
69
+ ];
70
+ if (isGlob(params.path)) {
71
+ return this.#checkGlob(target, declared, context.signal);
72
+ }
59
73
  if (params.exists !== undefined) {
60
74
  const expected = params.exists;
61
75
  results.push(await condition(`${params.path} ${expected ? "exists" : "does not exist"}`, async () => {
@@ -69,15 +83,88 @@ class FileChecker {
69
83
  if (params.changed !== undefined) {
70
84
  results.push(await this.#changed(context, params.changed));
71
85
  }
72
- const declared = [
73
- ...params.matches.map((pattern) => ({ kind: "matches", pattern })),
74
- ...params.notMatches.map((pattern) => ({ kind: "notMatches", pattern })),
75
- ];
76
86
  if (declared.length > 0) {
77
87
  results.push(...(await this.#patterns(context, declared)));
78
88
  }
79
89
  return results;
80
90
  };
91
+ async #checkGlob(target, declared, signal) {
92
+ const params = this.#params;
93
+ const results = [];
94
+ let matched;
95
+ let globError;
96
+ try {
97
+ matched = await resolveGlobMatches(target.root, target.relative, signal);
98
+ }
99
+ catch (error) {
100
+ globError = errorMessage(error);
101
+ }
102
+ const prefix = params.path.startsWith("~/") ? "~/" : "";
103
+ if (params.exists !== undefined) {
104
+ const expected = params.exists;
105
+ const subject = `${params.path} ${expected ? "exists" : "does not exist"}`;
106
+ if (globError !== undefined || matched === undefined) {
107
+ results.push(errorResult(subject, globError ?? "glob resolution failed"));
108
+ }
109
+ else {
110
+ const found = matched.all.length > 0;
111
+ const reason = found
112
+ ? `matched ${matched.all.length} path(s), e.g. ${prefix}${matched.all[0]}`
113
+ : `no paths matched ${params.path}`;
114
+ results.push({ ...(found === expected ? pass : fail)(reason), subject });
115
+ }
116
+ }
117
+ if (declared.length === 0) {
118
+ return results;
119
+ }
120
+ if (globError !== undefined || matched === undefined) {
121
+ for (const { kind, pattern } of declared) {
122
+ results.push(errorResult(`${params.path} ${kind === "matches" ? "matches" : "does not match"} ${display(pattern)}`, globError ?? "glob resolution failed"));
123
+ }
124
+ return results;
125
+ }
126
+ if (matched.files.length === 0) {
127
+ for (const { kind, pattern } of declared) {
128
+ const subject = `${params.path} ${kind === "matches" ? "matches" : "does not match"} ${display(pattern)}`;
129
+ results.push({ ...fail(`no files matched ${params.path}`), subject });
130
+ }
131
+ return results;
132
+ }
133
+ // Stream matched files one at a time so aggregate memory stays bounded by one file.
134
+ const hits = new Array(declared.length).fill(undefined);
135
+ let readError;
136
+ try {
137
+ for (const rel of matched.files) {
138
+ if (signal.aborted) {
139
+ throw new Error("check cancelled");
140
+ }
141
+ const text = (await readRunFile(target.root, rel)).toString("utf8");
142
+ const displayPath = `${prefix}${rel}`;
143
+ for (const [index, { pattern }] of declared.entries()) {
144
+ if (hits[index] !== undefined)
145
+ continue;
146
+ const found = pattern.regex ? searches(pattern.source, text) : text.includes(pattern.source);
147
+ if (found)
148
+ hits[index] = displayPath;
149
+ }
150
+ }
151
+ }
152
+ catch (error) {
153
+ readError = errorMessage(error);
154
+ }
155
+ for (const [index, { kind, pattern }] of declared.entries()) {
156
+ const subject = `${params.path} ${kind === "matches" ? "matches" : "does not match"} ${display(pattern)}`;
157
+ if (readError !== undefined) {
158
+ results.push(errorResult(subject, readError));
159
+ continue;
160
+ }
161
+ const hit = hits[index];
162
+ const found = hit !== undefined;
163
+ const reason = found ? `pattern found in ${hit}` : `pattern not found in ${matched.files.length} matched file(s)`;
164
+ results.push({ ...(found === (kind === "matches") ? pass : fail)(reason), subject });
165
+ }
166
+ return results;
167
+ }
81
168
  async #changed(context, expected) {
82
169
  const { path } = this.#params;
83
170
  const target = this.#target(context);
@@ -129,6 +216,87 @@ class FileChecker {
129
216
  : { root: context.workspace, baseline: context.baseline, relative: path };
130
217
  }
131
218
  }
219
+ async function resolveGlobMatches(root, pattern, signal) {
220
+ await assertRunRoot(root);
221
+ const normalized = pattern.replaceAll("\\", "/").replace(/^(?:\.\/)+/u, "");
222
+ const segments = normalized.split("/");
223
+ const staticSegments = [];
224
+ for (const segment of segments) {
225
+ if (isGlob(segment))
226
+ break;
227
+ staticSegments.push(segment);
228
+ }
229
+ const baseDir = staticSegments.length === 0 ? "." : staticSegments.join("/");
230
+ const startAbs = baseDir === "." ? root.path : await resolveWorkspacePath(root, baseDir);
231
+ let startStats;
232
+ try {
233
+ startStats = await lstat(startAbs);
234
+ }
235
+ catch (error) {
236
+ if (isMissing(error))
237
+ return { all: [], files: [] };
238
+ throw new WorkspacePathError(`could not inspect ${baseDir}: ${errorMessage(error)}`);
239
+ }
240
+ if (!startStats.isDirectory()) {
241
+ return { all: [], files: [] };
242
+ }
243
+ const all = [];
244
+ const files = [];
245
+ const visit = async (dirAbs, relPrefix) => {
246
+ if (signal.aborted) {
247
+ throw new Error("check cancelled");
248
+ }
249
+ const names = (await readdir(dirAbs)).sort();
250
+ for (const name of names) {
251
+ if (signal.aborted) {
252
+ throw new Error("check cancelled");
253
+ }
254
+ const childAbs = join(dirAbs, name);
255
+ const relative = relPrefix === "" ? name : `${relPrefix}/${name}`;
256
+ let info;
257
+ try {
258
+ info = await lstat(childAbs);
259
+ }
260
+ catch (error) {
261
+ if (isMissing(error))
262
+ continue;
263
+ throw new WorkspacePathError(`could not inspect ${relative}: ${errorMessage(error)}`);
264
+ }
265
+ if (posix.matchesGlob(relative, normalized)) {
266
+ if (info.isFile()) {
267
+ all.push(relative);
268
+ files.push(relative);
269
+ }
270
+ else if (info.isDirectory()) {
271
+ all.push(relative);
272
+ }
273
+ else if (info.isSymbolicLink()) {
274
+ // Validate symlinks with the exact-path rules: escaping/broken links and special targets error.
275
+ const resolved = await resolveWorkspacePath(root, relative);
276
+ const targetInfo = await stat(resolved);
277
+ if (targetInfo.isFile()) {
278
+ all.push(relative);
279
+ files.push(relative);
280
+ }
281
+ else if (targetInfo.isDirectory()) {
282
+ all.push(relative);
283
+ }
284
+ else {
285
+ throw new WorkspacePathError(`not a regular file or directory: ${relative}`);
286
+ }
287
+ }
288
+ else {
289
+ throw new WorkspacePathError(`not a regular file or directory: ${relative}`);
290
+ }
291
+ }
292
+ if (info.isDirectory()) {
293
+ await visit(childAbs, relative);
294
+ }
295
+ }
296
+ };
297
+ await visit(startAbs, baseDir === "." ? "" : baseDir);
298
+ return { all, files };
299
+ }
132
300
  /**
133
301
  * Every path that differs, sorted; the root is `""`, so a replaced path is one change.
134
302
  * Files are compared one pair at a time, so peak memory follows the check's per-file
@@ -4,7 +4,7 @@ import type { CheckerDefinition } from "../../engine/registry.js";
4
4
  declare const judgeParamsSchema: z.ZodObject<{
5
5
  runner: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodTransform<ImplementationRecord, Record<string, unknown>>>>;
6
6
  rubric: z.ZodArray<z.ZodString>;
7
- file: z.ZodOptional<z.ZodString>;
7
+ files: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
8
  trace: z.ZodOptional<z.ZodLiteral<true>>;
9
9
  }, z.core.$strict>;
10
10
  type JudgeParams = z.output<typeof judgeParamsSchema>;