@kilncraft/eval 1.0.0 → 1.1.1
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.
- package/README.md +167 -0
- package/package.json +3 -3
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.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@kilncraft/core": "1.
|
|
22
|
-
"@kilncraft/shared": "1.
|
|
21
|
+
"@kilncraft/core": "1.1.1",
|
|
22
|
+
"@kilncraft/shared": "1.1.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "26.6.6",
|