@kilncraft/eval 0.0.0-stage → 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
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.
@@ -0,0 +1,42 @@
1
+ import { TurnResult, Agent } from '@kilncraft/core';
2
+
3
+ interface EvalTask {
4
+ id: string;
5
+ prompt: string;
6
+ expectedFiles?: Record<string, string>;
7
+ tags?: string[];
8
+ }
9
+ interface TaskResult {
10
+ id: string;
11
+ passed: boolean;
12
+ failures: string[];
13
+ text: string;
14
+ cost: number;
15
+ usage: TurnResult["usage"];
16
+ }
17
+ interface ScoreSummary {
18
+ total: number;
19
+ passed: number;
20
+ failed: number;
21
+ rate: number;
22
+ cost: number;
23
+ }
24
+ declare function checkExpectedFiles(task: EvalTask, cwd: string): Promise<string[]>;
25
+ declare function runEvalTask(task: EvalTask, agent: Agent, cwd: string): Promise<TaskResult>;
26
+ declare function scoreResults(results: TaskResult[]): ScoreSummary;
27
+ interface BenchmarkAdapter {
28
+ readonly id: string;
29
+ fromRows(rows: unknown[]): EvalTask[];
30
+ }
31
+ declare class SweBenchAdapter implements BenchmarkAdapter {
32
+ readonly id = "swe-bench-lite";
33
+ fromRows(rows: unknown[]): EvalTask[];
34
+ }
35
+ declare class TerminalBenchAdapter implements BenchmarkAdapter {
36
+ readonly id = "terminal-bench";
37
+ fromRows(rows: unknown[]): EvalTask[];
38
+ }
39
+ declare function parseJsonl(source: string): unknown[];
40
+
41
+ export { SweBenchAdapter, TerminalBenchAdapter, checkExpectedFiles, parseJsonl, runEvalTask, scoreResults };
42
+ export type { BenchmarkAdapter, EvalTask, ScoreSummary, TaskResult };
package/dist/index.js ADDED
@@ -0,0 +1,109 @@
1
+ import { readFile } from 'fs/promises';
2
+ import { resolve } from 'path';
3
+ import { isPathInside } from '@kilncraft/core';
4
+
5
+ // src/index.ts
6
+ async function checkExpectedFiles(task, cwd) {
7
+ const failures = [];
8
+ for (const [path, expected] of Object.entries(task.expectedFiles ?? {})) {
9
+ const fullPath = resolve(cwd, path);
10
+ if (!isPathInside(cwd, fullPath)) {
11
+ failures.push(`${path}: outside eval workspace`);
12
+ continue;
13
+ }
14
+ try {
15
+ const actual = await readFile(fullPath, "utf8");
16
+ if (actual !== expected) failures.push(`${path}: content mismatch`);
17
+ } catch {
18
+ failures.push(`${path}: missing`);
19
+ }
20
+ }
21
+ return failures;
22
+ }
23
+ async function runEvalTask(task, agent, cwd) {
24
+ const emptyUsage = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
25
+ const criteria = Object.keys(task.expectedFiles ?? {}).length;
26
+ if (criteria === 0) {
27
+ return {
28
+ id: task.id,
29
+ passed: false,
30
+ failures: ["no scoring criteria (expectedFiles is empty)"],
31
+ text: "",
32
+ cost: 0,
33
+ usage: emptyUsage
34
+ };
35
+ }
36
+ try {
37
+ const result = await agent.prompt(task.prompt);
38
+ const failures = await checkExpectedFiles(task, cwd);
39
+ return {
40
+ id: task.id,
41
+ passed: failures.length === 0,
42
+ failures,
43
+ text: result.text,
44
+ cost: result.cost,
45
+ usage: result.usage
46
+ };
47
+ } catch (error) {
48
+ return {
49
+ id: task.id,
50
+ passed: false,
51
+ failures: [`agent failed: ${error instanceof Error ? error.message : String(error)}`],
52
+ text: "",
53
+ cost: 0,
54
+ usage: emptyUsage
55
+ };
56
+ }
57
+ }
58
+ function scoreResults(results) {
59
+ const passed = results.filter((result) => result.passed).length;
60
+ const total = results.length;
61
+ return {
62
+ total,
63
+ passed,
64
+ failed: total - passed,
65
+ rate: total === 0 ? 0 : passed / total,
66
+ cost: results.reduce((sum, result) => sum + result.cost, 0)
67
+ };
68
+ }
69
+ var SweBenchAdapter = class {
70
+ id = "swe-bench-lite";
71
+ fromRows(rows) {
72
+ return rows.map((row, index) => {
73
+ const record = row ?? {};
74
+ return {
75
+ id: record.instance_id ?? `swe-${index}`,
76
+ prompt: `Repository: ${record.repo ?? "unknown"}
77
+
78
+ ${record.problem_statement ?? ""}`,
79
+ tags: ["swe-bench-lite"]
80
+ };
81
+ });
82
+ }
83
+ };
84
+ var TerminalBenchAdapter = class {
85
+ id = "terminal-bench";
86
+ fromRows(rows) {
87
+ return rows.map((row, index) => {
88
+ const record = row ?? {};
89
+ return {
90
+ id: record.instance_id ?? `terminal-${index}`,
91
+ prompt: record.instruction ?? record.task ?? "",
92
+ tags: ["terminal-bench"]
93
+ };
94
+ });
95
+ }
96
+ };
97
+ function parseJsonl(source) {
98
+ return source.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).flatMap((line) => {
99
+ try {
100
+ return [JSON.parse(line)];
101
+ } catch {
102
+ return [];
103
+ }
104
+ });
105
+ }
106
+
107
+ export { SweBenchAdapter, TerminalBenchAdapter, checkExpectedFiles, parseJsonl, runEvalTask, scoreResults };
108
+ //# sourceMappingUR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AA,EAA2B;AACpD,EAAA,OAAO,MAAA,CACJ,MAAM,IAAI,CAAA,CACV,IAAI,CAAC,IAAA,KAAS,KAAK,IAAA,EAAM,EACzB,MAAA,CAAO,CAAC,SAAS,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA,CAChC,OAAA,CAAQ,CAAC,IAAA,KAAS;AACjB,IAAA,IAAI;AACF,MAAA,OAAO,CAAC,IAAA,CAAK,KAAA,CAAM,IAAI,CAAY,CAAA;AAAA,IACrC,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,EAAC;AAAA,IACV;AAAA,EACF,CAAC,CAAA;AACL","file":"index.js","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { type Agent, isPathInside, type TurnResult } from \"@kilncraft/core\";\n\nexport interface EvalTask {\n id: string;\n prompt: string;\n expectedFiles?: Record<string, string>;\n tags?: string[];\n}\n\nexport interface TaskResult {\n id: string;\n passed: boolean;\n failures: string[];\n text: string;\n cost: number;\n usage: TurnResult[\"usage\"];\n}\n\nexport interface ScoreSummary {\n total: number;\n passed: number;\n failed: number;\n rate: number;\n cost: number;\n}\n\nexport async function checkExpectedFiles(task: EvalTask, cwd: string): Promise<string[]> {\n const failures: string[] = [];\n for (const [path, expected] of Object.entries(task.expectedFiles ?? {})) {\n const fullPath = resolve(cwd, path);\n if (!isPathInside(cwd, fullPath)) {\n failures.push(`${path}: outside eval workspace`);\n continue;\n }\n try {\n const actual = await readFile(fullPath, \"utf8\");\n if (actual !== expected) failures.push(`${path}: content mismatch`);\n } catch {\n failures.push(`${path}: missing`);\n }\n }\n return failures;\n}\n\nexport async function runEvalTask(task: EvalTask, agent: Agent, cwd: string): Promise<TaskResult> {\n const emptyUsage = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };\n const criteria = Object.keys(task.expectedFiles ?? {}).length;\n\n if (criteria === 0) {\n return {\n id: task.id,\n passed: false,\n failures: [\"no scoring criteria (expectedFiles is empty)\"],\n text: \"\",\n cost: 0,\n usage: emptyUsage,\n };\n }\n\n try {\n const result = await agent.prompt(task.prompt);\n const failures = await checkExpectedFiles(task, cwd);\n return {\n id: task.id,\n passed: failures.length === 0,\n failures,\n text: result.text,\n cost: result.cost,\n usage: result.usage,\n };\n } catch (error) {\n return {\n id: task.id,\n passed: false,\n failures: [`agent failed: ${error instanceof Error ? error.message : String(error)}`],\n text: \"\",\n cost: 0,\n usage: emptyUsage,\n };\n }\n}\n\nexport function scoreResults(results: TaskResult[]): ScoreSummary {\n const passed = results.filter((result) => result.passed).length;\n const total = results.length;\n return {\n total,\n passed,\n failed: total - passed,\n rate: total === 0 ? 0 : passed / total,\n cost: results.reduce((sum, result) => sum + result.cost, 0),\n };\n}\n\nexport interface BenchmarkAdapter {\n readonly id: string;\n fromRows(rows: unknown[]): EvalTask[];\n}\n\ninterface SweBenchRow {\n instance_id?: string;\n problem_statement?: string;\n repo?: string;\n}\n\nexport class SweBenchAdapter implements BenchmarkAdapter {\n readonly id = \"swe-bench-lite\";\n\n fromRows(rows: unknown[]): EvalTask[] {\n return rows.map((row, index) => {\n const record = (row ?? {}) as SweBenchRow;\n return {\n id: record.instance_id ?? `swe-${index}`,\n prompt: `Repository: ${record.repo ?? \"unknown\"}\\n\\n${record.problem_statement ?? \"\"}`,\n tags: [\"swe-bench-lite\"],\n };\n });\n }\n}\n\ninterface TerminalBenchRow {\n instance_id?: string;\n instruction?: string;\n task?: string;\n}\n\nexport class TerminalBenchAdapter implements BenchmarkAdapter {\n readonly id = \"terminal-bench\";\n\n fromRows(rows: unknown[]): EvalTask[] {\n return rows.map((row, index) => {\n const record = (row ?? {}) as TerminalBenchRow;\n return {\n id: record.instance_id ?? `terminal-${index}`,\n prompt: record.instruction ?? record.task ?? \"\",\n tags: [\"terminal-bench\"],\n };\n });\n }\n}\n\nexport function parseJsonl(source: string): unknown[] {\n return source\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n .flatMap((line) => {\n try {\n return [JSON.parse(line) as unknown];\n } catch {\n return [];\n }\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@kilncraft/eval",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "type": "module",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "dependencies": {
21
+ "@kilncraft/core": "1.0.0",
22
+ "@kilncraft/shared": "1.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "26.6.6",
26
+ "@vitest/coverage-v8": "5.1.0",
27
+ "tsup": "9.0.0",
28
+ "typescript": "5.9.3",
29
+ "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
+ }
6
37
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.