self-bench 0.3.0 → 0.3.2
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/.dockerignore +10 -0
- package/Dockerfile +37 -0
- package/Dockerfile.sandbox +24 -0
- package/README.md +34 -26
- package/biome.json +18 -0
- package/bun.lock +1182 -0
- package/compose.yaml +85 -0
- package/dist/agent-smoke-main.js +1 -1
- package/dist/build-metadata.d.ts +2 -0
- package/dist/build-metadata.d.ts.map +1 -0
- package/dist/build-metadata.js +2 -0
- package/dist/build-metadata.js.map +1 -0
- package/dist/cli.js +18 -8
- package/dist/cli.js.map +1 -1
- package/dist/eval-main.js +1 -1
- package/dist/reaudit-main.js +1 -1
- package/dist/repair-main.js +1 -1
- package/dist/validate-main.js +1 -1
- package/docs/evaluations.md +67 -0
- package/docs/operations.md +178 -0
- package/docs/task-construction.md +94 -0
- package/package.json +28 -15
- package/scripts/verify-package.ts +57 -0
- package/scripts/write-build-metadata.ts +27 -0
- package/src/activities.ts +1236 -0
- package/src/agent-smoke-main.ts +63 -0
- package/src/agent-smoke.ts +132 -0
- package/src/api-main.ts +12 -0
- package/src/api.ts +239 -0
- package/src/artifacts.ts +361 -0
- package/src/audit.ts +106 -0
- package/src/build-metadata.ts +3 -0
- package/src/cli.ts +350 -0
- package/src/codex-review.ts +220 -0
- package/src/config.ts +117 -0
- package/src/contracts.ts +209 -0
- package/src/coupling.ts +259 -0
- package/src/docker-executor.ts +115 -0
- package/src/eval-main.ts +92 -0
- package/src/evaluate.ts +293 -0
- package/src/github.ts +26 -0
- package/src/harbor-results.ts +142 -0
- package/src/harbor-task.ts +528 -0
- package/src/hash.ts +5 -0
- package/src/modal-auth.ts +11 -0
- package/src/modal-executor.ts +176 -0
- package/src/parallel.ts +24 -0
- package/src/process.ts +165 -0
- package/src/provenance.ts +458 -0
- package/src/reaudit-main.ts +192 -0
- package/src/repair-main.ts +203 -0
- package/src/repair.ts +55 -0
- package/src/run-wait.ts +40 -0
- package/src/sandbox-author.ts +19 -0
- package/src/sandbox-repair.ts +160 -0
- package/src/sandbox-review.ts +17 -0
- package/src/sandbox-validation-repair.ts +174 -0
- package/src/sandbox.ts +51 -0
- package/src/subscription-auth.ts +67 -0
- package/src/temporal.ts +23 -0
- package/src/validate-main.ts +171 -0
- package/src/validation-repair.ts +94 -0
- package/src/worker-main.ts +32 -0
- package/src/workflow.ts +519 -0
- package/tsconfig.build.json +13 -0
- package/tsconfig.json +21 -0
package/package.json
CHANGED
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "self-bench",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Turn completed repository changes into durable, private Harbor evaluations",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/mupt-ai/self-bench.git"
|
|
9
9
|
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"registry": "https://registry.npmjs.org/"
|
|
13
|
+
},
|
|
10
14
|
"type": "module",
|
|
11
15
|
"bin": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"self-bench": "dist/cli.js",
|
|
17
|
+
"self-bench-agent-smoke": "dist/agent-smoke-main.js",
|
|
18
|
+
"self-bench-eval": "dist/eval-main.js",
|
|
19
|
+
"self-bench-reaudit": "dist/reaudit-main.js",
|
|
20
|
+
"self-bench-repair": "dist/repair-main.js",
|
|
21
|
+
"self-bench-validate": "dist/validate-main.js"
|
|
18
22
|
},
|
|
19
23
|
"files": [
|
|
20
24
|
"dist",
|
|
21
|
-
"src
|
|
22
|
-
"
|
|
25
|
+
"src",
|
|
26
|
+
"docs",
|
|
27
|
+
"compose.yaml",
|
|
28
|
+
"Dockerfile",
|
|
29
|
+
"Dockerfile.sandbox",
|
|
30
|
+
"bun.lock",
|
|
31
|
+
"scripts",
|
|
32
|
+
"biome.json",
|
|
33
|
+
"tsconfig.json",
|
|
34
|
+
"tsconfig.build.json",
|
|
35
|
+
".dockerignore"
|
|
23
36
|
],
|
|
24
37
|
"engines": {
|
|
25
38
|
"node": ">=22"
|
|
@@ -29,21 +42,21 @@
|
|
|
29
42
|
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
30
43
|
"cli": "bun run src/cli.ts",
|
|
31
44
|
"build:review": "vite build --config review/vite.config.ts",
|
|
32
|
-
"build:server": "tsc -p tsconfig.build.json && bun build src/sandbox-author.ts --target=node --outfile=dist/sandbox-author.bundle.js && bun build src/sandbox-review.ts --target=node --outfile=dist/sandbox-review.bundle.js && bun build src/sandbox-repair.ts --target=node --outfile=dist/sandbox-repair.bundle.js && bun build src/sandbox-validation-repair.ts --target=node --outfile=dist/sandbox-validation-repair.bundle.js",
|
|
45
|
+
"build:server": "tsc -p tsconfig.build.json && bun build src/sandbox-author.ts --target=node --outfile=dist/sandbox-author.bundle.js && bun build src/sandbox-review.ts --target=node --outfile=dist/sandbox-review.bundle.js && bun build src/sandbox-repair.ts --target=node --outfile=dist/sandbox-repair.bundle.js && bun build src/sandbox-validation-repair.ts --target=node --outfile=dist/sandbox-validation-repair.bundle.js && bun run build:metadata",
|
|
46
|
+
"build:metadata": "bun scripts/write-build-metadata.ts",
|
|
47
|
+
"prepack": "bun run build",
|
|
48
|
+
"prepublishOnly": "bun run validate",
|
|
49
|
+
"verify:package": "bun scripts/verify-package.ts",
|
|
33
50
|
"check": "biome check . && tsc --noEmit -p tsconfig.json && bun run typecheck:review",
|
|
34
51
|
"dev:api": "tsx src/api-main.ts",
|
|
35
52
|
"dev:review": "vite --config review/vite.config.ts",
|
|
36
53
|
"dev:worker": "tsx src/worker-main.ts",
|
|
37
54
|
"format": "biome format --write .",
|
|
38
|
-
"prepack": "bun run build",
|
|
39
55
|
"start:api": "node dist/api-main.js",
|
|
40
56
|
"start:worker": "node dist/worker-main.js",
|
|
41
57
|
"test": "bun test tests review/src",
|
|
42
58
|
"typecheck:review": "tsc --noEmit -p review/tsconfig.json",
|
|
43
|
-
"validate": "bun run check && bun run test && bun run build"
|
|
44
|
-
},
|
|
45
|
-
"publishConfig": {
|
|
46
|
-
"access": "public"
|
|
59
|
+
"validate": "bun run check && bun run test && bun run build && bun run verify:package"
|
|
47
60
|
},
|
|
48
61
|
"dependencies": {
|
|
49
62
|
"@google-cloud/storage": "^7.17.0",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
const root = resolve(import.meta.dir, "..");
|
|
6
|
+
const temporary = await mkdtemp(join(tmpdir(), "self-bench-package-"));
|
|
7
|
+
async function run(command: string, args: string[], cwd = root): Promise<string> {
|
|
8
|
+
const child = Bun.spawn([command, ...args], {
|
|
9
|
+
cwd,
|
|
10
|
+
stdout: "pipe",
|
|
11
|
+
stderr: "pipe",
|
|
12
|
+
});
|
|
13
|
+
const [exitCode, stdout, stderr] = await Promise.all([
|
|
14
|
+
child.exited,
|
|
15
|
+
new Response(child.stdout).text(),
|
|
16
|
+
new Response(child.stderr).text(),
|
|
17
|
+
]);
|
|
18
|
+
if (exitCode !== 0) {
|
|
19
|
+
throw new Error(`${command} ${args.join(" ")} failed:\n${stderr || stdout}`);
|
|
20
|
+
}
|
|
21
|
+
return stdout;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
await run("bun", ["pm", "pack", "--destination", temporary]);
|
|
26
|
+
const tarballs = (await Array.fromAsync(new Bun.Glob("*.tgz").scan({ cwd: temporary }))).map(
|
|
27
|
+
(name) => join(temporary, name),
|
|
28
|
+
);
|
|
29
|
+
const tarball = tarballs[0] ?? (() => {
|
|
30
|
+
throw new Error("bun pm pack did not create a tarball");
|
|
31
|
+
})();
|
|
32
|
+
const packageJson = JSON.parse(await readFile(join(root, "package.json"), "utf8")) as {
|
|
33
|
+
name: string;
|
|
34
|
+
version: string;
|
|
35
|
+
};
|
|
36
|
+
const installRoot = join(temporary, "install");
|
|
37
|
+
await run("mkdir", ["-p", installRoot]);
|
|
38
|
+
await run("bun", ["init", "--yes"], installRoot);
|
|
39
|
+
await run("bun", ["add", "--no-save", tarball], installRoot);
|
|
40
|
+
const executable = join(installRoot, "node_modules", ".bin", "self-bench");
|
|
41
|
+
const help = await run(executable, ["--help"], installRoot);
|
|
42
|
+
if (!help.includes("self-bench up")) {
|
|
43
|
+
throw new Error("installed self-bench did not print the expected CLI help");
|
|
44
|
+
}
|
|
45
|
+
for (const asset of ["compose.yaml", "Dockerfile", "Dockerfile.sandbox", "src/skills/selfbench/SKILL.md"]) {
|
|
46
|
+
await readFile(join(installRoot, "node_modules", packageJson.name, asset));
|
|
47
|
+
}
|
|
48
|
+
const installedPackage = JSON.parse(
|
|
49
|
+
await readFile(join(installRoot, "node_modules", packageJson.name, "package.json"), "utf8"),
|
|
50
|
+
) as { name: string; version: string };
|
|
51
|
+
if (installedPackage.name !== packageJson.name || installedPackage.version !== packageJson.version) {
|
|
52
|
+
throw new Error("installed package metadata does not match the workspace package");
|
|
53
|
+
}
|
|
54
|
+
console.log(`verified ${installedPackage.name}@${installedPackage.version}`);
|
|
55
|
+
} finally {
|
|
56
|
+
await rm(temporary, { recursive: true, force: true });
|
|
57
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
|
|
5
|
+
const execFileAsync = promisify(execFile);
|
|
6
|
+
const root = new URL("../", import.meta.url);
|
|
7
|
+
const output = new URL("../dist/build-metadata.js", import.meta.url);
|
|
8
|
+
const configuredCommit = process.env.SELFBENCH_BUILD_COMMIT;
|
|
9
|
+
|
|
10
|
+
let commit = configuredCommit;
|
|
11
|
+
if (!commit) {
|
|
12
|
+
try {
|
|
13
|
+
const result = await execFileAsync("git", ["rev-parse", "HEAD"], { cwd: root });
|
|
14
|
+
commit = result.stdout.trim();
|
|
15
|
+
} catch {
|
|
16
|
+
commit = "0".repeat(40);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (!/^[0-9a-f]{40}$/i.test(commit)) {
|
|
20
|
+
throw new Error("SELFBENCH_BUILD_COMMIT must be a full commit SHA");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
await mkdir(new URL("../dist/", import.meta.url), { recursive: true });
|
|
24
|
+
await writeFile(
|
|
25
|
+
output,
|
|
26
|
+
`// Generated during the build.\nexport const buildCommit = ${JSON.stringify(commit.toLowerCase())};\n`,
|
|
27
|
+
);
|