@kilncraft/eval 1.0.0 → 1.1.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 (3) hide show
  1. package/README.md +167 -0
  2. package/package.json +10 -10
  3. package/LICENSE +0 -21
package/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # @kilncraft/eval
2
+
3
+ Task runner and scoring helpers for Kilncraft. Define fixture tasks, run them
4
+ through an `Agent`, check expected files, and score results.
5
+
6
+ This package contains the runner and benchmark row adapters. It does not download
7
+ datasets; bring your own JSONL rows.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm i @kilncraft/eval
13
+ ```
14
+
15
+ Requires Node.js >= 24. It works with any `@kilncraft/core` `Agent` instance.
16
+
17
+ ## Task format
18
+
19
+ ```ts
20
+ import type { EvalTask } from "@kilncraft/eval";
21
+
22
+ const task: EvalTask = {
23
+ id: "fix-auth",
24
+ prompt: "Fix the failing auth test in src/auth.test.ts.",
25
+ expectedFiles: {
26
+ "src/auth.ts": "export function signIn() { /* fixed */ }",
27
+ },
28
+ tags: ["auth", "regression"],
29
+ };
30
+ ```
31
+
32
+ `expectedFiles` is a map of workspace-relative path to exact expected content.
33
+ A task without `expectedFiles` cannot be scored.
34
+
35
+ ## Run a task
36
+
37
+ ```ts
38
+ import { runEvalTask, scoreResults } from "@kilncraft/eval";
39
+ import {
40
+ Agent,
41
+ createDefaultProviderRegistry,
42
+ createDefaultToolRegistry,
43
+ PermissionEngine,
44
+ } from "@kilncraft/core";
45
+ import { createLogger } from "@kilncraft/shared";
46
+
47
+ const registry = createDefaultProviderRegistry(process.env);
48
+ const provider = registry.get("anthropic");
49
+ if (!provider) throw new Error("ANTHROPIC_API_KEY is not set");
50
+
51
+ const agent = new Agent({
52
+ cwd: "/path/to/fixture-repo",
53
+ provider,
54
+ model: "claude-sonnet-4-5",
55
+ tools: createDefaultToolRegistry(),
56
+ permissions: new PermissionEngine({
57
+ mode: "acceptEdits",
58
+ cwd: "/path/to/fixture-repo",
59
+ }),
60
+ logger: createLogger({ level: "warn" }),
61
+ askPermission: async () => "allow",
62
+ });
63
+
64
+ const result = await runEvalTask(task, agent, "/path/to/fixture-repo");
65
+ console.log(result.passed, result.failures, result.cost);
66
+ ```
67
+
68
+ `TaskResult`:
69
+
70
+ ```ts
71
+ interface TaskResult {
72
+ id: string;
73
+ passed: boolean;
74
+ failures: string[];
75
+ text: string;
76
+ cost: number;
77
+ usage: TurnResult["usage"];
78
+ }
79
+ ```
80
+
81
+ A task passes only when there is at least one scoring criterion and every
82
+ expected file exists with exactly the expected content.
83
+
84
+ ## Check files directly
85
+
86
+ ```ts
87
+ import { checkExpectedFiles } from "@kilncraft/eval";
88
+
89
+ const failures = await checkExpectedFiles(task, "/path/to/fixture-repo");
90
+ // e.g. ["src/auth.ts: content mismatch", "src/extra.ts: missing"]
91
+ ```
92
+
93
+ Expected paths are resolved with `isPathInside`; a path that escapes the eval
94
+ workspace is reported as `outside eval workspace` and is never read.
95
+
96
+ ## Score a suite
97
+
98
+ ```ts
99
+ import { scoreResults } from "@kilncraft/eval";
100
+
101
+ const summary = scoreResults(results);
102
+ console.log(summary);
103
+ // { total, passed, failed, rate, cost }
104
+ ```
105
+
106
+ `rate` is `passed / total`, or `0` for an empty suite.
107
+
108
+ ## Benchmark adapters
109
+
110
+ Adapters convert benchmark rows into `EvalTask[]`:
111
+
112
+ ```ts
113
+ import { SweBenchAdapter, TerminalBenchAdapter, parseJsonl } from "@kilncraft/eval";
114
+ import { readFile } from "node:fs/promises";
115
+
116
+ const rows = parseJsonl(await readFile("swe-bench-lite.jsonl", "utf8"));
117
+ const tasks = new SweBenchAdapter().fromRows(rows);
118
+ ```
119
+
120
+ | Adapter | Id | Expected row fields |
121
+ | ---------------------- | ---------------- | ------------------------------------------ |
122
+ | `SweBenchAdapter` | `swe-bench-lite` | `instance_id`, `repo`, `problem_statement` |
123
+ | `TerminalBenchAdapter` | `terminal-bench` | `instance_id`, `instruction` or `task` |
124
+
125
+ Rows are turned into prompts; they do not include `expectedFiles`, so a benchmark
126
+ run needs its own verification strategy (tests, patches, or custom checks).
127
+ `parseJsonl` skips malformed lines.
128
+
129
+ ## Custom adapters
130
+
131
+ ```ts
132
+ import type { BenchmarkAdapter, EvalTask } from "@kilncraft/eval";
133
+
134
+ const adapter: BenchmarkAdapter = {
135
+ id: "my-benchmark",
136
+ fromRows(rows) {
137
+ return rows.map((row, index) => ({
138
+ id: `task-${index}`,
139
+ prompt: String(row),
140
+ tags: ["my-benchmark"],
141
+ }));
142
+ },
143
+ };
144
+ ```
145
+
146
+ ## Isolation and safety
147
+
148
+ - Each eval should run against a fresh copy of the fixture repository.
149
+ - `runEvalTask` gives the agent the same tools and permissions as a normal run;
150
+ use `acceptEdits` or a custom permission callback deliberately.
151
+ - Expected files are read-only checks; the runner never writes expected content.
152
+ - Reset the workspace between tasks; the runner does not clone or clean it.
153
+
154
+ ## Development
155
+
156
+ ```sh
157
+ pnpm --filter @kilncraft/eval build
158
+ pnpm --filter @kilncraft/eval test
159
+ pnpm --filter @kilncraft/eval typecheck
160
+ ```
161
+
162
+ ## Related packages
163
+
164
+ - `@kilncraft/core` — `Agent` and `TurnResult`
165
+ - `@kilncraft/shared` — shared types
166
+ - `@kilncraft/sdk` — programmatic agent setup
167
+ - [Root README](../../README.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kilncraft/eval",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,9 +17,15 @@
17
17
  "files": [
18
18
  "dist"
19
19
  ],
20
+ "scripts": {
21
+ "build": "tsup",
22
+ "typecheck": "tsc --noEmit",
23
+ "test": "vitest run",
24
+ "clean": "rm -rf dist .turbo coverage"
25
+ },
20
26
  "dependencies": {
21
- "@kilncraft/core": "1.0.0",
22
- "@kilncraft/shared": "1.0.0"
27
+ "@kilncraft/core": "workspace:*",
28
+ "@kilncraft/shared": "workspace:*"
23
29
  },
24
30
  "devDependencies": {
25
31
  "@types/node": "26.6.6",
@@ -27,11 +33,5 @@
27
33
  "tsup": "9.0.0",
28
34
  "typescript": "5.9.3",
29
35
  "vitest": "5.1.0"
30
- },
31
- "scripts": {
32
- "build": "tsup",
33
- "typecheck": "tsc --noEmit",
34
- "test": "vitest run",
35
- "clean": "rm -rf dist .turbo coverage"
36
36
  }
37
- }
37
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Kilncraft contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.