sdkproof 0.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +192 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +201 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/core/classify.d.ts +4 -0
  7. package/dist/core/classify.js +72 -0
  8. package/dist/core/classify.js.map +1 -0
  9. package/dist/core/model.d.ts +30 -0
  10. package/dist/core/model.js +27 -0
  11. package/dist/core/model.js.map +1 -0
  12. package/dist/core/prompt.d.ts +4 -0
  13. package/dist/core/prompt.js +43 -0
  14. package/dist/core/prompt.js.map +1 -0
  15. package/dist/core/score.d.ts +3 -0
  16. package/dist/core/score.js +37 -0
  17. package/dist/core/score.js.map +1 -0
  18. package/dist/core/stats.d.ts +99 -0
  19. package/dist/core/stats.js +121 -0
  20. package/dist/core/stats.js.map +1 -0
  21. package/dist/core/types.d.ts +162 -0
  22. package/dist/core/types.js +11 -0
  23. package/dist/core/types.js.map +1 -0
  24. package/dist/core/verify.d.ts +33 -0
  25. package/dist/core/verify.js +191 -0
  26. package/dist/core/verify.js.map +1 -0
  27. package/dist/drift.d.ts +87 -0
  28. package/dist/drift.js +105 -0
  29. package/dist/drift.js.map +1 -0
  30. package/dist/index.d.ts +19 -0
  31. package/dist/index.js +19 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/models.d.ts +33 -0
  34. package/dist/models.js +186 -0
  35. package/dist/models.js.map +1 -0
  36. package/dist/registry.d.ts +65 -0
  37. package/dist/registry.js +98 -0
  38. package/dist/registry.js.map +1 -0
  39. package/dist/report.d.ts +26 -0
  40. package/dist/report.js +240 -0
  41. package/dist/report.js.map +1 -0
  42. package/dist/run.d.ts +36 -0
  43. package/dist/run.js +188 -0
  44. package/dist/run.js.map +1 -0
  45. package/dist/surface.d.ts +95 -0
  46. package/dist/surface.js +281 -0
  47. package/dist/surface.js.map +1 -0
  48. package/dist/tarball.d.ts +7 -0
  49. package/dist/tarball.js +66 -0
  50. package/dist/tarball.js.map +1 -0
  51. package/dist/tasks.d.ts +41 -0
  52. package/dist/tasks.js +199 -0
  53. package/dist/tasks.js.map +1 -0
  54. package/dist/workspace.d.ts +42 -0
  55. package/dist/workspace.js +251 -0
  56. package/dist/workspace.js.map +1 -0
  57. package/package.json +58 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surface.js","sourceRoot":"","sources":["../src/surface.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAoC,MAAM,eAAe,CAAC;AA2CjG,kFAAkF;AAClF,SAAS,cAAc,CAAC,GAAwB;IAC9C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,CAAC,CAAU,EAAE,EAAE;QAC1B,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC;IACF,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClB,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChB,KAAK,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC;YACzD,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACjB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,QAAQ,C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;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,OAAiB,EAAE,GAAW;IAC1D,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,IAAI,MAAM,CACtB,gFAAgF,OAAO,KAAK,CAC7F,CAAC;IACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACtF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Extract the files of a gzipped tar whose (prefix-stripped) path passes
3
+ * `keep`. npm puts everything under `package/`, which is stripped here so
4
+ * callers see the paths as they appear in the installed package.
5
+ */
6
+ export declare function extractTarball(gz: Buffer, keep: (p: string) => boolean): Map<string, string>;
7
+ export declare function fetchTarball(url: string): Promise<Buffer>;
@@ -0,0 +1,66 @@
1
+ import { gunzipSync } from "node:zlib";
2
+ /**
3
+ * Read an npm tarball in memory.
4
+ *
5
+ * The alternative was `npm pack` plus the `tar` binary, which is what the
6
+ * research sweep shelled out to. Doing it here instead keeps the published CLI
7
+ * to one dependency, works the same on Windows, and skips two subprocesses and
8
+ * a disk round-trip per package — which matters because drift mode reads two
9
+ * versions of every package it looks at.
10
+ */
11
+ const BLOCK = 512;
12
+ function readString(buf, offset, length) {
13
+ const raw = buf.subarray(offset, offset + length);
14
+ const end = raw.indexOf(0);
15
+ return raw.subarray(0, end === -1 ? raw.length : end).toString("utf8");
16
+ }
17
+ function readOctal(buf, offset, length) {
18
+ const s = readString(buf, offset, length).trim();
19
+ return s ? parseInt(s, 8) || 0 : 0;
20
+ }
21
+ /**
22
+ * Extract the files of a gzipped tar whose (prefix-stripped) path passes
23
+ * `keep`. npm puts everything under `package/`, which is stripped here so
24
+ * callers see the paths as they appear in the installed package.
25
+ */
26
+ export function extractTarball(gz, keep) {
27
+ const tar = gunzipSync(gz);
28
+ const files = new Map();
29
+ let longName = null;
30
+ for (let off = 0; off + BLOCK <= tar.length;) {
31
+ const header = tar.subarray(off, off + BLOCK);
32
+ // Two consecutive zero blocks end the archive.
33
+ if (header.every((b) => b === 0))
34
+ break;
35
+ let name = readString(header, 0, 100);
36
+ const size = readOctal(header, 124, 12);
37
+ const type = String.fromCharCode(header[156] || 0x30);
38
+ const prefix = readString(header, 345, 155);
39
+ if (prefix)
40
+ name = `${prefix}/${name}`;
41
+ if (longName !== null) {
42
+ name = longName;
43
+ longName = null;
44
+ }
45
+ const dataStart = off + BLOCK;
46
+ const dataEnd = dataStart + size;
47
+ // GNU long-name entry: the next header's real path is this entry's body.
48
+ if (type === "L") {
49
+ longName = tar.subarray(dataStart, dataEnd).toString("utf8").replace(/\0+$/, "");
50
+ }
51
+ else if (type === "0" || type === "\0") {
52
+ const rel = name.replace(/^[^/]+\//, "");
53
+ if (keep(rel))
54
+ files.set(rel, tar.subarray(dataStart, dataEnd).toString("utf8"));
55
+ }
56
+ off = dataStart + Math.ceil(size / BLOCK) * BLOCK;
57
+ }
58
+ return files;
59
+ }
60
+ export async function fetchTarball(url) {
61
+ const res = await fetch(url);
62
+ if (!res.ok)
63
+ throw new Error(`tarball fetch failed: ${res.status} ${url}`);
64
+ return Buffer.from(await res.arrayBuffer());
65
+ }
66
+ //# sourceMappingURL=tarball.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tarball.js","sourceRoot":"","sources":["../src/tarball.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;;;;GAQG;AAEH,MAAM,KAAK,GAAG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AC;IACpD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC5C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { ModelAdapter } from "./core/model.ts";
2
+ import type { Task } from "./core/types.ts";
3
+ export interface SynthesisInput {
4
+ packageName: string;
5
+ version: string;
6
+ description: string;
7
+ readme: string;
8
+ count: number;
9
+ }
10
+ export interface TaskSet {
11
+ packageName: string;
12
+ version: string;
13
+ /** the one-line steer handed to the model under test, alongside each task */
14
+ docsHint: string;
15
+ tasks: Task[];
16
+ /** tasks the model wrote that had to be dropped, and why */
17
+ rejected: {
18
+ id: string;
19
+ reason: string;
20
+ }[];
21
+ /** "synthesized" or the path a --tasks file came from */
22
+ source: string;
23
+ }
24
+ /** Does this source import from the package under test, or any subpath of it? */
25
+ export declare function importsPackage(code: string, packageName: string): boolean;
26
+ export declare function validateTasks(raw: unknown, packageName: string): {
27
+ docsHint: string;
28
+ tasks: Task[];
29
+ rejected: {
30
+ id: string;
31
+ reason: string;
32
+ }[];
33
+ };
34
+ export declare function loadTaskFile(file: string, packageName: string): Promise<TaskSet>;
35
+ export interface SynthesizeOptions extends SynthesisInput {
36
+ model: ModelAdapter;
37
+ /** reuse a cached task set for this exact package@version */
38
+ cache?: boolean;
39
+ log?: (line: string) => void;
40
+ }
41
+ export declare function synthesizeTasks(opts: SynthesizeOptions): Promise<TaskSet>;
package/dist/tasks.js ADDED
@@ -0,0 +1,199 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { cacheRoot } from "./workspace.js";
4
+ /**
5
+ * Where the tasks come from when nobody hand-wrote them.
6
+ *
7
+ * The bench's ten libraries have hand-authored task sets. For a package nobody
8
+ * has scored before, a model writes them from the package's own README at the
9
+ * version being scored — which is the only description of the library that is
10
+ * guaranteed current for that version.
11
+ *
12
+ * Two rules make the result a measurement rather than a quiz the model sets
13
+ * itself, and both are enforced below rather than merely requested:
14
+ *
15
+ * 1. a skeleton may not import from the package under test. If the skeleton
16
+ * hands over the import line, the hardest half of the drift — which symbol
17
+ * to reach for, and from which entrypoint — is answered before the model
18
+ * starts. TanStack Table v9's whole finding is that the model still writes
19
+ * `useReactTable`; a skeleton containing `import { useTable }` erases it.
20
+ * 2. neither the prompt nor the skeleton may name an export of the package.
21
+ * The task says what to build; remembering the API is the thing being
22
+ * measured.
23
+ */
24
+ const SYNTHESIS_SYSTEM = "You write evaluation tasks for a TypeScript benchmark. " +
25
+ "You respond with ONLY a single JSON array inside one ```json code block — no prose before or after.";
26
+ function buildSynthesisPrompt(input) {
27
+ return [
28
+ `Package: ${input.packageName}@${input.version}`,
29
+ input.description ? `Description: ${input.description}` : "",
30
+ "",
31
+ "README (may be truncated):",
32
+ "---",
33
+ input.readme.slice(0, 18_000),
34
+ "---",
35
+ "",
36
+ `Write exactly ${input.count} small, realistic coding tasks that a working developer would use this library for.`,
37
+ "Spread them across the library's main feature areas and across difficulty: roughly a third easy, a third medium, a third hard.",
38
+ "",
39
+ "Each task is an object with these fields:",
40
+ ' "id" kebab-case, unique, 2-4 words, describes the job',
41
+ ' "area" one lowercase word for the feature area, e.g. "queries", "auth", "streaming"',
42
+ ' "difficulty" one of "easy", "medium", "hard"',
43
+ ' "prompt" one or two sentences telling the developer what to build, and what to export',
44
+ ' "skeleton" the TypeScript file to complete',
45
+ "",
46
+ "HARD RULES — a task breaking any of these is thrown away:",
47
+ ` - The skeleton MUST NOT import from "${input.packageName}" or any of its subpaths. The solver writes its own imports.`,
48
+ ` - Neither the prompt nor the skeleton may name any export, function, class, hook, option or method of ${input.packageName}. Describe the capability instead: say "the library's typed column-definition helper", never the helper's name.`,
49
+ " - The skeleton may declare local types, local constants and the comment describing what to write. It may import from node builtins or from other libraries, but not from the package under test.",
50
+ " - The prompt must name the exported symbol the solution has to provide, and that name must be the solver's own, not the library's.",
51
+ " - Every task must be solvable in one file of under 40 lines, and must actually require the library — not something plain TypeScript could do.",
52
+ "",
53
+ `The array has ${input.count + 1} elements: one docsHint object first, then the ${input.count} tasks. The docsHint is EXTRA — it does not count as one of the ${input.count}.`,
54
+ "",
55
+ "The first element is an object of the form",
56
+ ' { "docsHint": "..." }',
57
+ `where docsHint is two or three sentences describing what ${input.packageName} is and the domain the tasks operate over (the data model, the resources, the shape of the problem).`,
58
+ "The docsHint MUST NOT name any export, method or option of the library either.",
59
+ "",
60
+ "Respond with one ```json block containing the array.",
61
+ ]
62
+ .filter(Boolean)
63
+ .join("\n");
64
+ }
65
+ function extractJson(text) {
66
+ const fenced = [...text.matchAll(/```(?:json)?[^\S\r\n]*\r?\n([\s\S]*?)```/g)].map((m) => m[1].trim());
67
+ const candidates = fenced.length ? fenced : [text.trim()];
68
+ for (const c of candidates) {
69
+ try {
70
+ return JSON.parse(c);
71
+ }
72
+ catch {
73
+ // try the next block; a model sometimes emits an explanation block first
74
+ }
75
+ }
76
+ // last resort: the outermost array in the text
77
+ const start = text.indexOf("[");
78
+ const end = text.lastIndexOf("]");
79
+ if (start >= 0 && end > start) {
80
+ try {
81
+ return JSON.parse(text.slice(start, end + 1));
82
+ }
83
+ catch {
84
+ // fall through to the throw below
85
+ }
86
+ }
87
+ throw new Error("task synthesis did not return parseable JSON");
88
+ }
89
+ const DIFFICULTIES = new Set(["easy", "medium", "hard"]);
90
+ /** Does this source import from the package under test, or any subpath of it? */
91
+ export function importsPackage(code, packageName) {
92
+ const pkg = packageName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
93
+ const spec = `["'\`]${pkg}(?:/[^"'\`]*)?["'\`]`;
94
+ return (new RegExp(`\\bfrom\\s+${spec}`).test(code) ||
95
+ new RegExp(`\\bimport\\s*\\(\\s*${spec}`).test(code) ||
96
+ new RegExp(`\\bimport\\s+${spec}`).test(code) ||
97
+ new RegExp(`\\brequire\\s*\\(\\s*${spec}`).test(code));
98
+ }
99
+ export function validateTasks(raw, packageName) {
100
+ if (!Array.isArray(raw))
101
+ throw new Error("task synthesis returned something that is not an array");
102
+ let docsHint = "";
103
+ const tasks = [];
104
+ const rejected = [];
105
+ const seen = new Set();
106
+ for (const item of raw) {
107
+ if (!item || typeof item !== "object")
108
+ continue;
109
+ const o = item;
110
+ if (typeof o.docsHint === "string" && !o.prompt) {
111
+ docsHint = o.docsHint.trim();
112
+ continue;
113
+ }
114
+ const id = String(o.id ?? "").trim();
115
+ const prompt = String(o.prompt ?? "").trim();
116
+ const skeleton = String(o.skeleton ?? "");
117
+ const reject = (reason) => rejected.push({ id: id || "(unnamed)", reason });
118
+ if (!id || !prompt) {
119
+ reject("missing id or prompt");
120
+ continue;
121
+ }
122
+ if (seen.has(id)) {
123
+ reject("duplicate id");
124
+ continue;
125
+ }
126
+ // Rule 1, enforced rather than trusted: a skeleton that imports the package
127
+ // hands over the answer to the half of the problem that carries the drift.
128
+ if (importsPackage(skeleton, packageName) || importsPackage(prompt, packageName)) {
129
+ reject(`names "${packageName}" in an import — that gives away the entrypoint`);
130
+ continue;
131
+ }
132
+ if (!/export/i.test(`${prompt}\n${skeleton}`)) {
133
+ reject("does not ask for an export, so a passing answer cannot be told from an empty file");
134
+ continue;
135
+ }
136
+ const difficulty = DIFFICULTIES.has(o.difficulty)
137
+ ? o.difficulty
138
+ : "medium";
139
+ seen.add(id);
140
+ tasks.push({
141
+ id,
142
+ area: String(o.area ?? "general").trim().toLowerCase() || "general",
143
+ difficulty,
144
+ prompt,
145
+ skeleton,
146
+ });
147
+ }
148
+ return { docsHint, tasks, rejected };
149
+ }
150
+ function taskCachePath(packageName, version) {
151
+ return path.join(cacheRoot(), "tasks", `${packageName.replace(/[@/]/g, "_")}@${version}.json`);
152
+ }
153
+ export async function loadTaskFile(file, packageName) {
154
+ const parsed = JSON.parse(await readFile(file, "utf8"));
155
+ // Accept both a bare Task[] (the bench's data/*.tasks.json shape) and a
156
+ // full TaskSet written by an earlier run.
157
+ if (Array.isArray(parsed)) {
158
+ const { docsHint, tasks, rejected } = validateTasks(parsed, packageName);
159
+ return { packageName, version: "", docsHint, tasks, rejected, source: file };
160
+ }
161
+ return { ...parsed, source: file };
162
+ }
163
+ export async function synthesizeTasks(opts) {
164
+ const log = opts.log ?? (() => { });
165
+ const cacheFile = taskCachePath(opts.packageName, opts.version);
166
+ if (opts.cache !== false) {
167
+ try {
168
+ const cached = JSON.parse(await readFile(cacheFile, "utf8"));
169
+ if (cached.tasks?.length) {
170
+ log(`Tasks: reusing ${cached.tasks.length} cached task(s) — ${cacheFile}`);
171
+ return { ...cached, source: cacheFile };
172
+ }
173
+ }
174
+ catch {
175
+ // no cache yet
176
+ }
177
+ }
178
+ log(`Tasks: writing ${opts.count} from the ${opts.packageName}@${opts.version} README`);
179
+ const raw = await opts.model.generate({
180
+ system: SYNTHESIS_SYSTEM,
181
+ user: buildSynthesisPrompt(opts),
182
+ maxTokens: 16000,
183
+ });
184
+ const { docsHint, tasks, rejected } = validateTasks(extractJson(raw), opts.packageName);
185
+ if (!tasks.length)
186
+ throw new Error("task synthesis produced no usable tasks");
187
+ const set = {
188
+ packageName: opts.packageName,
189
+ version: opts.version,
190
+ docsHint: docsHint || opts.description,
191
+ tasks,
192
+ rejected,
193
+ source: "synthesized",
194
+ };
195
+ await mkdir(path.dirname(cacheFile), { recursive: true });
196
+ await writeFile(cacheFile, JSON.stringify(set, null, 2));
197
+ return set;
198
+ }
199
+ //# sourceMappingURL=tasks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,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AAC;IACzD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { type VersionMeta } from "./registry.ts";
2
+ export declare function cacheRoot(): string;
3
+ /** The tsc JS entrypoint shipped with this package's own typescript dependency. */
4
+ export declare function resolveTsc(override?: string): string;
5
+ export interface Workspace {
6
+ /** absolute path holding node_modules, tsconfig.json and (transiently) candidate.ts */
7
+ dir: string;
8
+ packageName: string;
9
+ version: string;
10
+ /** modules that had to be installed on top of the target for it to type-check */
11
+ extraInstalls: string[];
12
+ /** `candidate.tsx` for a React-facing package, `candidate.ts` otherwise */
13
+ candidateFile: string;
14
+ /** true when the workspace was reused from cache rather than installed */
15
+ cached: boolean;
16
+ }
17
+ export interface WorkspaceOptions {
18
+ packageName: string;
19
+ version: string;
20
+ meta: VersionMeta;
21
+ /** run npm lifecycle scripts; off by default because we only type-check */
22
+ allowScripts?: boolean;
23
+ /** ignore any cached workspace and install fresh */
24
+ fresh?: boolean;
25
+ /** tsc entrypoint to probe with; defaults to this package's own typescript */
26
+ tscEntry?: string;
27
+ log?: (line: string) => void;
28
+ }
29
+ /** `@scope/name` -> `@types/scope__name`, the DefinitelyTyped convention. */
30
+ export declare function typesPackageFor(name: string): string;
31
+ /**
32
+ * Build (or reuse) a throwaway npm project with the target package installed,
33
+ * ready for candidate.ts to be dropped in and type-checked.
34
+ *
35
+ * The interesting part is the self-heal: a package's own types often need peers
36
+ * the package does not depend on, and DefinitelyTyped types for those peers on
37
+ * top. Rather than guess, the probe compiles `import * as m from "<pkg>"` and
38
+ * installs whatever tsc says it cannot find, up to twice. That is what turns
39
+ * "works for the ten libraries on the bench" into "works for a package nobody
40
+ * has scored before".
41
+ */
42
+ export declare function prepareWorkspace(opts: WorkspaceOptions): Promise<Workspace>;
@@ -0,0 +1,251 @@
1
+ import { execFile } from "node:child_process";
2
+ import { createRequire } from "node:module";
3
+ import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
+ import { existsSync } from "node:fs";
5
+ import os from "node:os";
6
+ import path from "node:path";
7
+ import { promisify } from "node:util";
8
+ import { requiredPeers } from "./registry.js";
9
+ const execFileAsync = promisify(execFile);
10
+ const require_ = createRequire(import.meta.url);
11
+ export function cacheRoot() {
12
+ return (process.env.SDKPROOF_CACHE ??
13
+ path.join(process.env.XDG_CACHE_HOME ?? path.join(os.homedir(), ".cache"), "sdkproof"));
14
+ }
15
+ /** The tsc JS entrypoint shipped with this package's own typescript dependency. */
16
+ export function resolveTsc(override) {
17
+ if (override)
18
+ return path.resolve(override);
19
+ // Resolved through package.json rather than "typescript/bin/tsc": the bin
20
+ // path is not in every typescript release's exports map, but "./package.json"
21
+ // always is.
22
+ const pkgJson = require_.resolve("typescript/package.json");
23
+ return path.join(path.dirname(pkgJson), "bin", "tsc");
24
+ }
25
+ function slug(name, version) {
26
+ return `${name.replace(/[@/]/g, "_")}@${version}`;
27
+ }
28
+ async function npm(args, cwd, allowScripts) {
29
+ await execFileAsync(process.platform === "win32" ? "npm.cmd" : "npm", [...args, "--no-audit", "--no-fund", "--loglevel=error", ...(allowScripts ? [] : ["--ignore-scripts"])], { cwd, maxBuffer: 64 * 1024 * 1024, env: { ...process.env, npm_config_update_notifier: "false" } });
30
+ }
31
+ /** `@scope/name` -> `@types/scope__name`, the DefinitelyTyped convention. */
32
+ export function typesPackageFor(name) {
33
+ return name.startsWith("@")
34
+ ? `@types/${name.slice(1).replace("/", "__")}`
35
+ : `@types/${name}`;
36
+ }
37
+ function tsconfigFor(hasReact) {
38
+ return JSON.stringify({
39
+ compilerOptions: {
40
+ target: "ES2022",
41
+ module: "NodeNext",
42
+ moduleResolution: "NodeNext",
43
+ // DOM is always on: a browser-facing package fails to resolve its own
44
+ // types without it, and the extra globals cannot turn a wrong API call
45
+ // into a right one — which is the only thing being measured.
46
+ lib: ["ES2022", "DOM", "DOM.Iterable"],
47
+ types: ["node"],
48
+ ...(hasReact ? { jsx: "react-jsx" } : {}),
49
+ strict: true,
50
+ noEmit: true,
51
+ skipLibCheck: true,
52
+ esModuleInterop: true,
53
+ allowSyntheticDefaultImports: true,
54
+ },
55
+ include: [hasReact ? "candidate.tsx" : "candidate.ts"],
56
+ }, null, 2);
57
+ }
58
+ const PROBE = "sdkproof-probe.ts";
59
+ const PROBE_TSCONFIG = "tsconfig.sdkproof-probe.json";
60
+ /**
61
+ * Build (or reuse) a throwaway npm project with the target package installed,
62
+ * ready for candidate.ts to be dropped in and type-checked.
63
+ *
64
+ * The interesting part is the self-heal: a package's own types often need peers
65
+ * the package does not depend on, and DefinitelyTyped types for those peers on
66
+ * top. Rather than guess, the probe compiles `import * as m from "<pkg>"` and
67
+ * installs whatever tsc says it cannot find, up to twice. That is what turns
68
+ * "works for the ten libraries on the bench" into "works for a package nobody
69
+ * has scored before".
70
+ */
71
+ export async function prepareWorkspace(opts) {
72
+ const { packageName, version, meta } = opts;
73
+ const log = opts.log ?? (() => { });
74
+ const dir = path.join(cacheRoot(), "workspaces", slug(packageName, version));
75
+ const marker = path.join(dir, ".sdkproof-ready.json");
76
+ if (opts.fresh)
77
+ await rm(dir, { recursive: true, force: true });
78
+ if (existsSync(marker)) {
79
+ try {
80
+ const prev = JSON.parse(await readFile(marker, "utf8"));
81
+ if (!prev.candidateFile)
82
+ throw new Error("stale marker");
83
+ log(`Workspace: reusing ${dir}`);
84
+ return { ...prev, dir, cached: true };
85
+ }
86
+ catch {
87
+ await rm(dir, { recursive: true, force: true });
88
+ }
89
+ }
90
+ await mkdir(dir, { recursive: true });
91
+ await writeFile(path.join(dir, "package.json"), JSON.stringify({ name: "sdkproof-sandbox", private: true, version: "0.0.0", type: "module" }, null, 2));
92
+ const peers = requiredPeers(meta);
93
+ const first = [`${packageName}@${version}`, "@types/node", ...peers];
94
+ log(`Installing ${first.join(" ")}${opts.allowScripts ? "" : " (lifecycle scripts off)"}`);
95
+ try {
96
+ await npm(["install", ...first], dir, Boolean(opts.allowScripts));
97
+ }
98
+ catch {
99
+ // A peer that will not co-install is not fatal — the target alone may still
100
+ // type-check, and the probe below will say so.
101
+ log(` peer install failed, retrying with the target alone`);
102
+ await npm(["install", `${packageName}@${version}`, "@types/node"], dir, Boolean(opts.allowScripts));
103
+ }
104
+ const extraInstalls = [];
105
+ const hasReact = () => existsSync(path.join(dir, "node_modules", "react", "package.json"));
106
+ await writeFile(path.join(dir, "tsconfig.json"), tsconfigFor(hasReact()));
107
+ // Peers ship untyped surprisingly often; try DefinitelyTyped for each, and
108
+ // treat a miss as normal rather than an error.
109
+ for (const peer of peers) {
110
+ if (await hasTypes(dir, peer))
111
+ continue;
112
+ const types = typesPackageFor(peer);
113
+ try {
114
+ await npm(["install", types], dir, Boolean(opts.allowScripts));
115
+ extraInstalls.push(types);
116
+ }
117
+ catch {
118
+ // no DefinitelyTyped package for this peer; the probe will report it
119
+ }
120
+ }
121
+ const tsc = opts.tscEntry ?? resolveTsc();
122
+ const probeSource = `import * as sdkproofProbe from ${JSON.stringify(packageName)};\nexport default sdkproofProbe;\n`;
123
+ await writeFile(path.join(dir, PROBE), probeSource);
124
+ // A dedicated project file rather than files-on-the-command-line: tsc 7 makes
125
+ // that combination an error (TS5112) when a tsconfig.json is present, and it
126
+ // reports the error INSTEAD of compiling — so the probe silently passed on
127
+ // every package, self-heal included, until this was caught on lodash.
128
+ await writeFile(path.join(dir, PROBE_TSCONFIG), probeTsconfig());
129
+ let probeOutput = "";
130
+ for (let round = 0; round < 3; round++) {
131
+ probeOutput = await runTsc(tsc, path.join(dir, PROBE_TSCONFIG));
132
+ // TS2307: the module is not installed at all. TS7016: it is installed but
133
+ // ships no declarations, so DefinitelyTyped is the only thing that helps —
134
+ // which is exactly what a TypeScript user would reach for. lodash is
135
+ // scorable through @types/lodash and unscorable without it.
136
+ const missing = missingModules(probeOutput);
137
+ const untyped = untypedModules(probeOutput);
138
+ const wanted = [
139
+ ...new Set([...missing.flatMap((m) => [m, typesPackageFor(m)]), ...untyped.map(typesPackageFor)]),
140
+ ].filter((w) => !extraInstalls.includes(w));
141
+ if (!wanted.length)
142
+ break;
143
+ log(` probe: installing ${wanted.join(", ")}`);
144
+ for (const w of wanted) {
145
+ try {
146
+ await npm(["install", w], dir, Boolean(opts.allowScripts));
147
+ extraInstalls.push(w);
148
+ }
149
+ catch {
150
+ // best effort: plenty of packages have no DefinitelyTyped entry
151
+ }
152
+ }
153
+ await writeFile(path.join(dir, "tsconfig.json"), tsconfigFor(hasReact()));
154
+ }
155
+ await rm(path.join(dir, PROBE), { force: true });
156
+ await rm(path.join(dir, PROBE_TSCONFIG), { force: true });
157
+ // Without type declarations there is nothing for tsc to check a candidate
158
+ // against: every answer would compile, and the package would score a perfect
159
+ // 100 for being unmeasurable. Better to stop and say so.
160
+ const untyped = new RegExp(`error TS7016: Could not find a declaration file for module '${packageName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}'`);
161
+ if (untyped.test(probeOutput)) {
162
+ throw new Error(`${packageName}@${version} ships no TypeScript declarations, and ${typesPackageFor(packageName)} ` +
163
+ `is not on npm either. There is nothing for the compiler to check an answer against, ` +
164
+ `so there is nothing to score.`);
165
+ }
166
+ if (missingModules(probeOutput).includes(packageName)) {
167
+ throw new Error(`${packageName}@${version} installed but does not resolve — tsc cannot find the module. ` +
168
+ `If it needs a build step, re-run with --allow-scripts.`);
169
+ }
170
+ const ws = {
171
+ dir,
172
+ packageName,
173
+ version,
174
+ extraInstalls,
175
+ candidateFile: hasReact() ? "candidate.tsx" : "candidate.ts",
176
+ cached: false,
177
+ };
178
+ await writeFile(marker, JSON.stringify(ws, null, 2));
179
+ return ws;
180
+ }
181
+ async function hasTypes(dir, name) {
182
+ const base = path.join(dir, "node_modules", ...name.split("/"));
183
+ try {
184
+ const pkg = JSON.parse(await readFile(path.join(base, "package.json"), "utf8"));
185
+ if (pkg.types || pkg.typings)
186
+ return true;
187
+ }
188
+ catch {
189
+ return false;
190
+ }
191
+ return existsSync(path.join(base, "index.d.ts"));
192
+ }
193
+ /**
194
+ * The module names tsc could not resolve. Only TS2307 counts: any other
195
+ * diagnostic is the package's own business, not a missing install.
196
+ */
197
+ function missingModules(out) {
198
+ return moduleNamesFrom(out, /error TS2307: Cannot find module '([^']+)'/);
199
+ }
200
+ /** Modules that resolved but ship no declarations — DefinitelyTyped candidates. */
201
+ function untypedModules(out) {
202
+ return moduleNamesFrom(out, /error TS7016: Could not find a declaration file for module '([^']+)'/);
203
+ }
204
+ function moduleNamesFrom(out, re) {
205
+ const found = new Set();
206
+ for (const line of out.split(/\r?\n/)) {
207
+ const m = re.exec(line);
208
+ if (!m)
209
+ continue;
210
+ const name = m[1];
211
+ if (name.startsWith(".") || name.startsWith("/"))
212
+ continue;
213
+ // Subpath imports resolve from the package root, so install the root.
214
+ const parts = name.split("/");
215
+ found.add(name.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0]);
216
+ }
217
+ return [...found];
218
+ }
219
+ /**
220
+ * The probe project. `strict` matters: TS7016 ("could not find a declaration
221
+ * file for module X") only fires under noImplicitAny, and that diagnostic is
222
+ * the whole untyped-package check. Without it, lodash sails through as scorable
223
+ * and would then score 100 for being unmeasurable.
224
+ */
225
+ function probeTsconfig() {
226
+ return JSON.stringify({
227
+ compilerOptions: {
228
+ target: "ES2022",
229
+ module: "NodeNext",
230
+ moduleResolution: "NodeNext",
231
+ lib: ["ES2022", "DOM", "DOM.Iterable"],
232
+ strict: true,
233
+ noEmit: true,
234
+ skipLibCheck: true,
235
+ esModuleInterop: true,
236
+ },
237
+ include: [PROBE],
238
+ }, null, 2);
239
+ }
240
+ async function runTsc(tscEntry, tsconfigPath) {
241
+ try {
242
+ const { stdout } = await execFileAsync(process.execPath, [tscEntry, "-p", tsconfigPath, "--pretty", "false"], { maxBuffer: 16 * 1024 * 1024 });
243
+ return stdout;
244
+ }
245
+ catch (err) {
246
+ // tsc exits non-zero when it reports errors; diagnostics are on stdout.
247
+ const e = err;
248
+ return (e.stdout ?? "") + (e.stderr ?? "");
249
+ }
250
+ }
251
+ //# sourceMappingURL=workspace.js.map