@skill-test/sdk 0.1.1 → 0.2.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/dist/runner.d.ts +20 -0
- package/dist/runner.js +57 -2
- package/package.json +7 -1
package/dist/runner.d.ts
CHANGED
|
@@ -21,6 +21,26 @@ export interface RunOptions {
|
|
|
21
21
|
/** Working directory for the subprocess. */
|
|
22
22
|
cwd?: string;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* The optional platform package that carries the prebuilt binary for this host,
|
|
26
|
+
* e.g. `@skill-test/cli-linux-x64`. One is published per supported target and
|
|
27
|
+
* declared in `optionalDependencies`; the package manager installs only the one
|
|
28
|
+
* matching the host's `os`/`cpu`, so this name resolves to an installed package
|
|
29
|
+
* on exactly the supported platforms.
|
|
30
|
+
*/
|
|
31
|
+
export declare function platformPackage(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Absolute path to the binary bundled in the matching platform package, or
|
|
34
|
+
* `undefined` when none is installed — a source/dev checkout (the package links
|
|
35
|
+
* but ships no binary), or a platform with no published package. Callers fall
|
|
36
|
+
* back to `$SKILLTEST_BIN`/`PATH`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function bundledBin(): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Resolve the binary to run, most explicit first: an explicit `bin`, then
|
|
41
|
+
* `$SKILLTEST_BIN`, then the bundled platform binary, then `skilltest` on PATH.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveBin(bin: string | undefined): string;
|
|
24
44
|
/**
|
|
25
45
|
* Run one or more test cases and return the parsed {@link Report}. A failing
|
|
26
46
|
* eval is reported in `report.passed`, not thrown; only bad input
|
package/dist/runner.js
CHANGED
|
@@ -6,12 +6,67 @@
|
|
|
6
6
|
* against the transcript.
|
|
7
7
|
*/
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
|
+
import { constants, accessSync, chmodSync, existsSync } from "node:fs";
|
|
10
|
+
import { createRequire } from "node:module";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
9
12
|
import { SkilltestError, SkilltestProviderError, SkilltestUsageError } from "./errors.js";
|
|
10
13
|
/** Environment variables supplying defaults for the binary and provider. */
|
|
11
14
|
export const ENV_BIN = "SKILLTEST_BIN";
|
|
12
15
|
export const ENV_PROVIDER = "SKILLTEST_PROVIDER";
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
/**
|
|
18
|
+
* The optional platform package that carries the prebuilt binary for this host,
|
|
19
|
+
* e.g. `@skill-test/cli-linux-x64`. One is published per supported target and
|
|
20
|
+
* declared in `optionalDependencies`; the package manager installs only the one
|
|
21
|
+
* matching the host's `os`/`cpu`, so this name resolves to an installed package
|
|
22
|
+
* on exactly the supported platforms.
|
|
23
|
+
*/
|
|
24
|
+
export function platformPackage() {
|
|
25
|
+
return `@skill-test/cli-${process.platform}-${process.arch}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Absolute path to the binary bundled in the matching platform package, or
|
|
29
|
+
* `undefined` when none is installed — a source/dev checkout (the package links
|
|
30
|
+
* but ships no binary), or a platform with no published package. Callers fall
|
|
31
|
+
* back to `$SKILLTEST_BIN`/`PATH`.
|
|
32
|
+
*/
|
|
33
|
+
export function bundledBin() {
|
|
34
|
+
try {
|
|
35
|
+
const pkgJson = require.resolve(`${platformPackage()}/package.json`);
|
|
36
|
+
const exe = process.platform === "win32" ? "skilltest.exe" : "skilltest";
|
|
37
|
+
const bin = join(dirname(pkgJson), "bin", exe);
|
|
38
|
+
if (!existsSync(bin))
|
|
39
|
+
return undefined;
|
|
40
|
+
ensureExecutable(bin);
|
|
41
|
+
return bin;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Some packers (pnpm pack) drop the executable bit; restore it best-effort. The
|
|
48
|
+
// platform packages publish via `npm` (which preserves +x), so this only matters
|
|
49
|
+
// as a fallback — and a read-only install keeps the packed mode regardless.
|
|
50
|
+
function ensureExecutable(bin) {
|
|
51
|
+
try {
|
|
52
|
+
accessSync(bin, constants.X_OK);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
try {
|
|
56
|
+
chmodSync(bin, 0o755);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// best effort; if it is not executable and not chmod-able, the spawn fails
|
|
60
|
+
// with a clear EACCES that points at $SKILLTEST_BIN.
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the binary to run, most explicit first: an explicit `bin`, then
|
|
66
|
+
* `$SKILLTEST_BIN`, then the bundled platform binary, then `skilltest` on PATH.
|
|
67
|
+
*/
|
|
68
|
+
export function resolveBin(bin) {
|
|
69
|
+
return bin ?? process.env[ENV_BIN] ?? bundledBin() ?? "skilltest";
|
|
15
70
|
}
|
|
16
71
|
function resolveProvider(provider) {
|
|
17
72
|
const value = provider ?? process.env[ENV_PROVIDER];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skill-test/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript SDK for the skilltest CLI: run AI-skill tests and natural-language evals from TypeScript, with a typed report contract generated from the CLI's JSON Schemas.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,6 +23,12 @@
|
|
|
23
23
|
"files": [
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
|
+
"optionalDependencies": {
|
|
27
|
+
"@skill-test/cli-linux-x64": "0.1.1",
|
|
28
|
+
"@skill-test/cli-linux-arm64": "0.1.1",
|
|
29
|
+
"@skill-test/cli-darwin-x64": "0.1.1",
|
|
30
|
+
"@skill-test/cli-darwin-arm64": "0.1.1"
|
|
31
|
+
},
|
|
26
32
|
"devDependencies": {
|
|
27
33
|
"@types/node": "^22.7.5",
|
|
28
34
|
"json-schema-to-typescript": "^15.0.4",
|