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.
- package/LICENSE +21 -0
- package/README.md +192 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +201 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/classify.d.ts +4 -0
- package/dist/core/classify.js +72 -0
- package/dist/core/classify.js.map +1 -0
- package/dist/core/model.d.ts +30 -0
- package/dist/core/model.js +27 -0
- package/dist/core/model.js.map +1 -0
- package/dist/core/prompt.d.ts +4 -0
- package/dist/core/prompt.js +43 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/score.d.ts +3 -0
- package/dist/core/score.js +37 -0
- package/dist/core/score.js.map +1 -0
- package/dist/core/stats.d.ts +99 -0
- package/dist/core/stats.js +121 -0
- package/dist/core/stats.js.map +1 -0
- package/dist/core/types.d.ts +162 -0
- package/dist/core/types.js +11 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/verify.d.ts +33 -0
- package/dist/core/verify.js +191 -0
- package/dist/core/verify.js.map +1 -0
- package/dist/drift.d.ts +87 -0
- package/dist/drift.js +105 -0
- package/dist/drift.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +33 -0
- package/dist/models.js +186 -0
- package/dist/models.js.map +1 -0
- package/dist/registry.d.ts +65 -0
- package/dist/registry.js +98 -0
- package/dist/registry.js.map +1 -0
- package/dist/report.d.ts +26 -0
- package/dist/report.js +240 -0
- package/dist/report.js.map +1 -0
- package/dist/run.d.ts +36 -0
- package/dist/run.js +188 -0
- package/dist/run.js.map +1 -0
- package/dist/surface.d.ts +95 -0
- package/dist/surface.js +281 -0
- package/dist/surface.js.map +1 -0
- package/dist/tarball.d.ts +7 -0
- package/dist/tarball.js +66 -0
- package/dist/tarball.js.map +1 -0
- package/dist/tasks.d.ts +41 -0
- package/dist/tasks.js +199 -0
- package/dist/tasks.js.map +1 -0
- package/dist/workspace.d.ts +42 -0
- package/dist/workspace.js +251 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAoB,MAAM,YAAY,CAAC;AAWhF,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE3B,SAAS,iBAAiB,CAAC,CAAU;IACnC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,CAAS,EAAE,GAAe;IACvD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IACzD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACb,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd,6EAA6E;IAC7E,4EAA4E;IAC5E,gCAAgC;IAChC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,OAAO,MAAM,MAAM,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,mBAAmB,CAAC,CAAC;IACr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AAC,EAAE,CAAC,CAAC;IACf,CAAC;SAAM,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;QACtF,GAAG,CAAC,IAAI,CACN,MAAM,CAAC,CAAC,aAAa,CAAC,MAAM,oEAAoE;YAC9F,GAAG,CAAC,CAAC,gBAAgB,CAAC,MAAM,qEAAqE,CACpG,CAAC;QACF,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,mBAAmB,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3F,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACb,IAAI,OAAO,CAAC,KAAK;QAAE,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAClE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACb,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC"}
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ModelAdapter } from "./core/model.ts";
|
|
2
|
+
export interface RunOptions {
|
|
3
|
+
/** `zod`, `zod@4`, `@tanstack/react-table@9.1.2` */
|
|
4
|
+
spec: string;
|
|
5
|
+
/** adapters for the models under test */
|
|
6
|
+
adapters: ModelAdapter[];
|
|
7
|
+
/** the model that writes the task set; defaults to the first adapter */
|
|
8
|
+
taskModel?: ModelAdapter;
|
|
9
|
+
taskCount: number;
|
|
10
|
+
tasksFile?: string;
|
|
11
|
+
limit?: number;
|
|
12
|
+
concurrency: number;
|
|
13
|
+
maxTokens?: number;
|
|
14
|
+
fresh?: boolean;
|
|
15
|
+
allowScripts?: boolean;
|
|
16
|
+
/** re-synthesize tasks even if a cached set exists */
|
|
17
|
+
noTaskCache?: boolean;
|
|
18
|
+
tscEntry?: string;
|
|
19
|
+
outDir?: string;
|
|
20
|
+
log: (line: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface RunOutcome {
|
|
23
|
+
terminal: string;
|
|
24
|
+
markdown: string;
|
|
25
|
+
json: string;
|
|
26
|
+
/** true when at least one candidate failed to compile */
|
|
27
|
+
foundSomething: boolean;
|
|
28
|
+
/** true when tasks were lost to transport errors — the run is not publishable */
|
|
29
|
+
incomplete: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Split `@scope/name@version` without mangling the scope's leading `@`. */
|
|
32
|
+
export declare function parseSpec(spec: string): {
|
|
33
|
+
name: string;
|
|
34
|
+
version?: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function run(opts: RunOptions): Promise<RunOutcome>;
|
package/dist/run.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { FatalApiError, RefusalError } from "./core/model.js";
|
|
4
|
+
import { buildUserPrompt, extractCode, GENERATION_SYSTEM } from "./core/prompt.js";
|
|
5
|
+
import { score } from "./core/score.js";
|
|
6
|
+
import { verify } from "./core/verify.js";
|
|
7
|
+
import { computeDrift, driftVerdict } from "./drift.js";
|
|
8
|
+
import { fetchPackument, readmeFor, resolveVersion } from "./registry.js";
|
|
9
|
+
import { readmeOf } from "./surface.js";
|
|
10
|
+
import { renderMarkdown, renderTerminal } from "./report.js";
|
|
11
|
+
import { loadTaskFile, synthesizeTasks } from "./tasks.js";
|
|
12
|
+
import { prepareWorkspace, resolveTsc } from "./workspace.js";
|
|
13
|
+
/** Split `@scope/name@version` without mangling the scope's leading `@`. */
|
|
14
|
+
export function parseSpec(spec) {
|
|
15
|
+
const at = spec.lastIndexOf("@");
|
|
16
|
+
if (at > 0)
|
|
17
|
+
return { name: spec.slice(0, at), version: spec.slice(at + 1) };
|
|
18
|
+
return { name: spec };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Bounded concurrency. Firing every task at once produced 14 timeouts on a
|
|
22
|
+
* 135-request run, and a lost task is worse than a slow one — it silently
|
|
23
|
+
* shrinks the denominator.
|
|
24
|
+
*/
|
|
25
|
+
async function pool(items, limit, fn) {
|
|
26
|
+
let next = 0;
|
|
27
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
28
|
+
while (next < items.length)
|
|
29
|
+
await fn(items[next++]);
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
export async function run(opts) {
|
|
33
|
+
const { log } = opts;
|
|
34
|
+
const { name, version: wanted } = parseSpec(opts.spec);
|
|
35
|
+
const packument = await fetchPackument(name);
|
|
36
|
+
const version = resolveVersion(packument, wanted);
|
|
37
|
+
const meta = packument.versions[version];
|
|
38
|
+
if (!meta)
|
|
39
|
+
throw new Error(`${name}@${version} is not on the registry`);
|
|
40
|
+
if (meta.deprecated)
|
|
41
|
+
log(`Note: ${name}@${version} is deprecated — "${meta.deprecated}"`);
|
|
42
|
+
log(`Target: ${name}@${version}`);
|
|
43
|
+
const tscEntry = resolveTsc(opts.tscEntry);
|
|
44
|
+
const ws = await prepareWorkspace({
|
|
45
|
+
packageName: name,
|
|
46
|
+
version,
|
|
47
|
+
meta,
|
|
48
|
+
fresh: opts.fresh,
|
|
49
|
+
allowScripts: opts.allowScripts,
|
|
50
|
+
tscEntry,
|
|
51
|
+
log,
|
|
52
|
+
});
|
|
53
|
+
// The drift surface costs no API call and is the thing a maintainer reads
|
|
54
|
+
// first, so it is computed even when the scored run finds nothing. A package
|
|
55
|
+
// with a single major has nothing to diff, which is not an error.
|
|
56
|
+
let drift;
|
|
57
|
+
try {
|
|
58
|
+
drift = await computeDrift(packument);
|
|
59
|
+
log(`Drift: v${drift.from.major} -> v${drift.to.major} — ${driftVerdict(drift).reason}`);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
log(`Drift: skipped (${e.message})`);
|
|
63
|
+
}
|
|
64
|
+
const taskModel = opts.taskModel ?? opts.adapters[0];
|
|
65
|
+
let taskSet;
|
|
66
|
+
if (opts.tasksFile) {
|
|
67
|
+
taskSet = await loadTaskFile(opts.tasksFile, name);
|
|
68
|
+
log(`Tasks: ${taskSet.tasks.length} from ${opts.tasksFile}`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const readme = (await readmeOf(packument, version).catch(() => "")) || readmeFor(packument, version);
|
|
72
|
+
// Plenty of packages ship a badge wall that links out to a docs site. The
|
|
73
|
+
// tasks are still written, but they lean on what the model already knows
|
|
74
|
+
// about the package rather than on anything version-accurate — and for a
|
|
75
|
+
// package the model has never seen, that is worth saying out loud.
|
|
76
|
+
if (readme.length < 1500) {
|
|
77
|
+
log(`Note: ${name}@${version} ships a ${readme.length}-character README — the tasks lean on the model's own knowledge of it`);
|
|
78
|
+
}
|
|
79
|
+
taskSet = await synthesizeTasks({
|
|
80
|
+
packageName: name,
|
|
81
|
+
version,
|
|
82
|
+
description: meta.description ?? packument.description ?? "",
|
|
83
|
+
readme,
|
|
84
|
+
count: opts.taskCount,
|
|
85
|
+
model: taskModel,
|
|
86
|
+
cache: !opts.noTaskCache,
|
|
87
|
+
log,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
let tasks = taskSet.tasks;
|
|
91
|
+
if (opts.limit && opts.limit > 0)
|
|
92
|
+
tasks = tasks.slice(0, opts.limit);
|
|
93
|
+
if (!tasks.length)
|
|
94
|
+
throw new Error("no tasks to run");
|
|
95
|
+
if (taskSet.rejected.length) {
|
|
96
|
+
log(`Tasks: ${taskSet.rejected.length} rejected (${taskSet.rejected.map((r) => r.id).join(", ")})`);
|
|
97
|
+
}
|
|
98
|
+
const promptTarget = {
|
|
99
|
+
displayName: name,
|
|
100
|
+
packageName: name,
|
|
101
|
+
docsHint: taskSet.docsHint,
|
|
102
|
+
};
|
|
103
|
+
log("");
|
|
104
|
+
// Progress goes to stderr, with the rest of the logging: --json writes the
|
|
105
|
+
// result to stdout and a progress dot in the middle of it is not JSON.
|
|
106
|
+
process.stderr.write(`Generating ${tasks.length} x ${opts.adapters.length} `);
|
|
107
|
+
const candidates = [];
|
|
108
|
+
// A refusal is an UNMEASURED task, not a failed one — the model never wrote
|
|
109
|
+
// code, so nothing about the library was tested.
|
|
110
|
+
const refusals = [];
|
|
111
|
+
// A generation error is NOT a refusal — the model never said no, the request
|
|
112
|
+
// never landed. Tracked so a truncated run cannot present itself as a whole one.
|
|
113
|
+
const lost = [];
|
|
114
|
+
const jobs = opts.adapters.flatMap((m) => tasks.map((t) => ({ m, t })));
|
|
115
|
+
await pool(jobs, opts.concurrency, async ({ m, t }) => {
|
|
116
|
+
try {
|
|
117
|
+
const raw = await m.generate({
|
|
118
|
+
system: GENERATION_SYSTEM,
|
|
119
|
+
user: buildUserPrompt(t, promptTarget),
|
|
120
|
+
maxTokens: opts.maxTokens,
|
|
121
|
+
});
|
|
122
|
+
candidates.push({ taskId: t.id, model: m.id, code: extractCode(raw) });
|
|
123
|
+
process.stderr.write(".");
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
if (e instanceof FatalApiError)
|
|
127
|
+
throw e;
|
|
128
|
+
if (e instanceof RefusalError) {
|
|
129
|
+
refusals.push({ taskId: t.id, model: m.id, attempts: e.attempts });
|
|
130
|
+
process.stderr.write("R");
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
lost.push({
|
|
134
|
+
taskId: t.id,
|
|
135
|
+
model: m.id,
|
|
136
|
+
reason: String(e.message).split("\n")[0].slice(0, 120),
|
|
137
|
+
});
|
|
138
|
+
process.stderr.write("!");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
process.stderr.write("\n");
|
|
143
|
+
if (lost.length) {
|
|
144
|
+
log("");
|
|
145
|
+
log(`INCOMPLETE RUN — ${lost.length}/${jobs.length} tasks never generated: ${[...new Set(lost.map((l) => l.taskId))].join(", ")}`);
|
|
146
|
+
log(" These are NOT refusals. The denominator shrank, so this score is over a partial set.");
|
|
147
|
+
log(" Do not publish it. Re-run when the API is healthy.");
|
|
148
|
+
}
|
|
149
|
+
if (refusals.length) {
|
|
150
|
+
log(`Refused: ${refusals.length}/${jobs.length} — ${[...new Set(refusals.map((r) => r.taskId))].join(", ")}`);
|
|
151
|
+
log(" (unmeasured, not counted as drift)");
|
|
152
|
+
}
|
|
153
|
+
// Verify sequentially — every candidate is written to the same candidate.ts.
|
|
154
|
+
process.stderr.write("Verifying ");
|
|
155
|
+
const verdicts = [];
|
|
156
|
+
for (const c of candidates) {
|
|
157
|
+
const v = await verify(c, { packageName: name, fixtureDir: ws.dir, candidateFile: ws.candidateFile }, { tscEntry });
|
|
158
|
+
verdicts.push(v);
|
|
159
|
+
process.stderr.write(v.passed ? "✓" : "✗");
|
|
160
|
+
}
|
|
161
|
+
process.stderr.write("\n");
|
|
162
|
+
const result = score(name, version, new Date().toISOString(), verdicts, refusals, [], lost);
|
|
163
|
+
const ctx = {
|
|
164
|
+
packageName: name,
|
|
165
|
+
version,
|
|
166
|
+
taskSet,
|
|
167
|
+
drift,
|
|
168
|
+
extraInstalls: ws.extraInstalls,
|
|
169
|
+
};
|
|
170
|
+
const outcome = {
|
|
171
|
+
terminal: renderTerminal(result, ctx),
|
|
172
|
+
markdown: renderMarkdown(result, ctx),
|
|
173
|
+
json: JSON.stringify({ ...result, drift, tasks, candidates }, null, 2),
|
|
174
|
+
foundSomething: verdicts.some((v) => !v.passed),
|
|
175
|
+
incomplete: lost.length > 0,
|
|
176
|
+
};
|
|
177
|
+
if (opts.outDir) {
|
|
178
|
+
const dir = path.resolve(opts.outDir);
|
|
179
|
+
await mkdir(dir, { recursive: true });
|
|
180
|
+
const base = `${name.replace(/[@/]/g, "_")}@${version}`;
|
|
181
|
+
await writeFile(path.join(dir, `${base}.md`), outcome.markdown);
|
|
182
|
+
await writeFile(path.join(dir, `${base}.json`), outcome.json);
|
|
183
|
+
log(`\nWrote ${path.join(dir, `${base}.md`)}`);
|
|
184
|
+
log(`Wrote ${path.join(dir, `${base}.json`)}`);
|
|
185
|
+
}
|
|
186
|
+
return outcome;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,eAAe,EAAgB,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAiC9D,4EAA4E;AAC5E,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,EAAE,GAAG,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CA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
|
5
|
+
* This is a port of the research sweep that ran over 7,453 packages, kept
|
|
6
|
+
* because two of its behaviours were learned the hard way and are not obvious:
|
|
7
|
+
*
|
|
8
|
+
* - the widen decision (entry file only, vs every .d.ts in the package) must
|
|
9
|
+
* be made ONCE for a pair of versions being compared. Deciding it per version
|
|
10
|
+
* made Apollo look like it had removed 560 symbols — 674 -> 133 — purely
|
|
11
|
+
* because v3's entry file triggered the widen and v4's did not.
|
|
12
|
+
* - a symbol that carried an `@deprecated` jsdoc in the OLD major produces no
|
|
13
|
+
* drift worth reporting. Deprecate-then-remove is the process working; the
|
|
14
|
+
* findings live in removals that shipped with no runway.
|
|
15
|
+
*/
|
|
16
|
+
export interface Surface {
|
|
17
|
+
/**
|
|
18
|
+
* The package's real public surface: symbols reachable from the declared type
|
|
19
|
+
* entrypoint, following `export * from "./x"` re-export chains through the
|
|
20
|
+
* files in the tarball.
|
|
21
|
+
*
|
|
22
|
+
* A barrel entrypoint that is nothing but `export * from "./core"` extracts to
|
|
23
|
+
* ZERO symbols if you only read the entry file — which is what @apollo/client
|
|
24
|
+
* v3 does. Resolving the chain is the difference between "0 exports" and the
|
|
25
|
+
* 133 a user can actually import.
|
|
26
|
+
*/
|
|
27
|
+
entryOnly: Set<string>;
|
|
28
|
+
/** symbols exported by ANY .d.ts in the package */
|
|
29
|
+
widened: Set<string>;
|
|
30
|
+
/** true when the entry alone undercounts — `export *`, or a near-empty entry */
|
|
31
|
+
needsWiden: boolean;
|
|
32
|
+
/** every .d.ts source in the package, for the @deprecated lookup */
|
|
33
|
+
sources: string[];
|
|
34
|
+
/** the type entrypoint that was found, relative to the package root */
|
|
35
|
+
entry: string;
|
|
36
|
+
/** `export *` specifiers the walk could not follow inside the tarball */
|
|
37
|
+
unresolved: string[];
|
|
38
|
+
/** the README that shipped in this version's tarball, "" if it ships none */
|
|
39
|
+
readme: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function symbolsFromSource(src: string): Set<string>;
|
|
42
|
+
/** Did `sym` carry an @deprecated jsdoc in this package? */
|
|
43
|
+
export declare function isDeprecated(sources: string[], sym: string): boolean;
|
|
44
|
+
export declare function packageFiles(p: Packument, version: string): Promise<Map<string, string>>;
|
|
45
|
+
/**
|
|
46
|
+
* The README as it shipped in THAT version's tarball.
|
|
47
|
+
*
|
|
48
|
+
* The registry only carries a README on the packument for the latest release,
|
|
49
|
+
* so scoring or diffing an older version against the top-level `readme` field
|
|
50
|
+
* describes the wrong API. Reading it out of the tarball is the only way to get
|
|
51
|
+
* the document that shipped with the code being measured.
|
|
52
|
+
*/
|
|
53
|
+
export declare function readmeOf(p: Packument, version: string): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Fetch one published version and read its exported surface.
|
|
56
|
+
*
|
|
57
|
+
* `followDeps` lets the walk cross a package boundary once. Plenty of packages
|
|
58
|
+
* are a thin wrapper over a core they depend on — `@tanstack/react-table` is
|
|
59
|
+
* `export * from "@tanstack/table-core"` plus two hooks — and without this its
|
|
60
|
+
* surface reads as 3 symbols instead of several hundred. The counts on both
|
|
61
|
+
* sides of a diff are wrong together, so the removals stay right, but "3
|
|
62
|
+
* exported symbols -> 61" is not a sentence anyone should have to interpret.
|
|
63
|
+
*/
|
|
64
|
+
export declare function surfaceOf(p: Packument, version: string, followDeps?: boolean): Promise<Surface>;
|
|
65
|
+
/**
|
|
66
|
+
* Walk the re-export chain from an entry .d.ts and collect every symbol a
|
|
67
|
+
* consumer can import from the package root.
|
|
68
|
+
*
|
|
69
|
+
* `export { a } from "./b"` needs no walking — symbolsFromSource already sees
|
|
70
|
+
* the names. Only `export * from "./b"` hides them, so only those are followed.
|
|
71
|
+
* A bare (non-relative) `export *` cannot be resolved inside one tarball; it is
|
|
72
|
+
* reported so the caller can fall back to scanning every .d.ts instead of
|
|
73
|
+
* silently under-reporting the surface.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveExports(files: Map<string, string>, entry: string, maxDepth?: number): {
|
|
76
|
+
symbols: Set<string>;
|
|
77
|
+
unresolved: string[];
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Was `sym` a VALUE in this package — a function, class, const or enum — rather
|
|
81
|
+
* than a type-only declaration?
|
|
82
|
+
*
|
|
83
|
+
* It matters for ranking. A model writes values far more often than it writes
|
|
84
|
+
* type names, so `useReactTable` disappearing is a finding and
|
|
85
|
+
* `ColumnFiltersInstance` disappearing usually is not. Declaration merging is
|
|
86
|
+
* resolved in favour of the value, which is the side a model would have
|
|
87
|
+
* written.
|
|
88
|
+
*/
|
|
89
|
+
export declare function isValueExport(sources: string[], sym: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Names nobody writes on purpose, so their removal is not a finding. A leading
|
|
92
|
+
* underscore is the convention for "internal, do not import"; `_getVisibleLeafColumns`
|
|
93
|
+
* leaving @tanstack/react-table is not something a model was ever going to write.
|
|
94
|
+
*/
|
|
95
|
+
export declare function isPublicName(s: string): boolean;
|
package/dist/surface.js
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { extractTarball, fetchTarball } from "./tarball.js";
|
|
3
|
+
import { fetchPackument, resolveVersion } from "./registry.js";
|
|
4
|
+
/** Where a package's type entrypoint might be declared, in order of authority. */
|
|
5
|
+
function typeCandidates(pkg) {
|
|
6
|
+
const out = [];
|
|
7
|
+
const push = (p) => {
|
|
8
|
+
if (typeof p === "string")
|
|
9
|
+
out.push(p.replace(/^\.\//, ""));
|
|
10
|
+
};
|
|
11
|
+
push(pkg.types);
|
|
12
|
+
push(pkg.typings);
|
|
13
|
+
const dot = pkg.exports?.["."];
|
|
14
|
+
if (dot) {
|
|
15
|
+
push(dot.types);
|
|
16
|
+
for (const k of ["import", "require", "default", "node"]) {
|
|
17
|
+
const v = dot[k];
|
|
18
|
+
if (typeof v === "string" && v.endsWith(".d.ts"))
|
|
19
|
+
push(v);
|
|
20
|
+
else if (v && typeof v === "object")
|
|
21
|
+
push(v.types ?? v.default);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Some packages only ship .d.mts/.d.cts, or bury the entry a level deeper.
|
|
25
|
+
const deep = (o, d = 0) => {
|
|
26
|
+
if (d > 3 || !o)
|
|
27
|
+
return;
|
|
28
|
+
if (typeof o === "string")
|
|
29
|
+
return push(o);
|
|
30
|
+
if (typeof o === "object")
|
|
31
|
+
for (const v of Object.values(o))
|
|
32
|
+
deep(v, d + 1);
|
|
33
|
+
};
|
|
34
|
+
deep(pkg.exports?.["."]);
|
|
35
|
+
out.push("index.d.ts", "dist/index.d.ts", "types/index.d.ts", "lib/index.d.ts", "dist/types/index.d.ts", "dist/development/index.d.ts", "dist/production/index.d.ts", "dist/node/index.d.ts", "dist/index.d.mts", "dist/index.d.cts", "index.d.mts", "types/index.d.mts", "dist/esm/index.d.ts", "build/index.d.ts");
|
|
36
|
+
return [...new Set(out.filter((p) => p && /\.d\.[cm]?ts$/.test(p)))];
|
|
37
|
+
}
|
|
38
|
+
export function symbolsFromSource(src) {
|
|
39
|
+
const out = new Set();
|
|
40
|
+
for (const m of src.matchAll(/export\s*(?:type\s*)?\{([^}]*)\}/gs)) {
|
|
41
|
+
for (let part of m[1].split(",")) {
|
|
42
|
+
part = part.trim().replace(/^type\s+/, "");
|
|
43
|
+
if (!part)
|
|
44
|
+
continue;
|
|
45
|
+
const n = part.split(/\s+as\s+/).pop().trim();
|
|
46
|
+
if (/^[A-Za-z_$][\w$]*$/.test(n))
|
|
47
|
+
out.add(n);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const m of src.matchAll(/^export\s+declare\s+(?:abstract\s+)?(?:function|const|let|var|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/gm))
|
|
51
|
+
out.add(m[1]);
|
|
52
|
+
for (const m of src.matchAll(/^export\s+(?:interface|type|enum|abstract class|class|function|const)\s+([A-Za-z_$][\w$]*)/gm))
|
|
53
|
+
out.add(m[1]);
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/** Did `sym` carry an @deprecated jsdoc in this package? */
|
|
57
|
+
export function isDeprecated(sources, sym) {
|
|
58
|
+
const decl = new RegExp(`(?:interface|type|declare\\s+(?:const|function|class|abstract\\s+class|enum)|class|function|const|enum)\\s+${sym}\\b`);
|
|
59
|
+
for (const src of sources) {
|
|
60
|
+
const lines = src.split("\n");
|
|
61
|
+
for (let i = 0; i < lines.length; i++) {
|
|
62
|
+
if (!decl.test(lines[i]))
|
|
63
|
+
continue;
|
|
64
|
+
const win = lines.slice(Math.max(0, i - 25), i).join("\n");
|
|
65
|
+
// only the jsdoc block immediately attached to this declaration counts
|
|
66
|
+
const lastClose = win.lastIndexOf("*/");
|
|
67
|
+
const seg = lastClose === -1 ? win : win.slice(win.lastIndexOf("/**", lastClose), lastClose);
|
|
68
|
+
if (/@deprecated/.test(seg))
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The published tarball's package.json, README and .d.ts files.
|
|
76
|
+
*
|
|
77
|
+
* Cached per package@version for the life of the process: a scored run needs
|
|
78
|
+
* the README and the drift diff needs the declarations, and downloading the
|
|
79
|
+
* same tarball twice for that is pure latency.
|
|
80
|
+
*/
|
|
81
|
+
const tarballCache = new Map();
|
|
82
|
+
export async function packageFiles(p, version) {
|
|
83
|
+
const key = `${p.name}@${version}`;
|
|
84
|
+
const hit = tarballCache.get(key);
|
|
85
|
+
if (hit)
|
|
86
|
+
return hit;
|
|
87
|
+
const meta = p.versions[version];
|
|
88
|
+
const url = meta?.dist?.tarball;
|
|
89
|
+
if (!url)
|
|
90
|
+
throw new Error(`${key} has no tarball on the registry`);
|
|
91
|
+
const files = extractTarball(await fetchTarball(url), (rel) => rel === "package.json" || /\.d\.[cm]?ts$/.test(rel) || /^readme(\.[a-z]+)?$/i.test(rel));
|
|
92
|
+
tarballCache.set(key, files);
|
|
93
|
+
return files;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The README as it shipped in THAT version's tarball.
|
|
97
|
+
*
|
|
98
|
+
* The registry only carries a README on the packument for the latest release,
|
|
99
|
+
* so scoring or diffing an older version against the top-level `readme` field
|
|
100
|
+
* describes the wrong API. Reading it out of the tarball is the only way to get
|
|
101
|
+
* the document that shipped with the code being measured.
|
|
102
|
+
*/
|
|
103
|
+
export async function readmeOf(p, version) {
|
|
104
|
+
const files = await packageFiles(p, version);
|
|
105
|
+
for (const [rel, src] of files)
|
|
106
|
+
if (/^readme(\.[a-z]+)?$/i.test(rel))
|
|
107
|
+
return src;
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Fetch one published version and read its exported surface.
|
|
112
|
+
*
|
|
113
|
+
* `followDeps` lets the walk cross a package boundary once. Plenty of packages
|
|
114
|
+
* are a thin wrapper over a core they depend on — `@tanstack/react-table` is
|
|
115
|
+
* `export * from "@tanstack/table-core"` plus two hooks — and without this its
|
|
116
|
+
* surface reads as 3 symbols instead of several hundred. The counts on both
|
|
117
|
+
* sides of a diff are wrong together, so the removals stay right, but "3
|
|
118
|
+
* exported symbols -> 61" is not a sentence anyone should have to interpret.
|
|
119
|
+
*/
|
|
120
|
+
export async function surfaceOf(p, version, followDeps = true) {
|
|
121
|
+
const files = await packageFiles(p, version);
|
|
122
|
+
let pkg = {};
|
|
123
|
+
try {
|
|
124
|
+
pkg = JSON.parse(files.get("package.json") ?? "{}");
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// a package.json we cannot parse just means we fall back to the guessed entries
|
|
128
|
+
}
|
|
129
|
+
const dts = [...files.entries()].filter(([rel]) => /\.d\.[cm]?ts$/.test(rel));
|
|
130
|
+
const sources = dts.map(([, src]) => src);
|
|
131
|
+
let entry = "";
|
|
132
|
+
let entrySrc = "";
|
|
133
|
+
for (const c of typeCandidates(pkg)) {
|
|
134
|
+
const src = files.get(c);
|
|
135
|
+
if (src !== undefined) {
|
|
136
|
+
entry = c;
|
|
137
|
+
entrySrc = src;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!entry) {
|
|
142
|
+
throw new Error(`${p.name}@${version} ships no TypeScript type entrypoint — there is nothing for tsc to check it against`);
|
|
143
|
+
}
|
|
144
|
+
const { symbols: entryOnly, unresolved } = resolveExports(files, entry);
|
|
145
|
+
const widened = new Set(entryOnly);
|
|
146
|
+
for (const s of sources)
|
|
147
|
+
for (const x of symbolsFromSource(s))
|
|
148
|
+
widened.add(x);
|
|
149
|
+
// Cross the package boundary once, for an `export *` that points at a
|
|
150
|
+
// dependency this package declares. Anything else stays unresolved.
|
|
151
|
+
const stillUnresolved = [];
|
|
152
|
+
if (followDeps) {
|
|
153
|
+
for (const spec of unresolved) {
|
|
154
|
+
const inherited = await surfaceOfDependency(pkg, spec).catch(() => null);
|
|
155
|
+
if (!inherited) {
|
|
156
|
+
stillUnresolved.push(spec);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
for (const x of inherited.entryOnly) {
|
|
160
|
+
entryOnly.add(x);
|
|
161
|
+
widened.add(x);
|
|
162
|
+
}
|
|
163
|
+
for (const x of inherited.widened)
|
|
164
|
+
widened.add(x);
|
|
165
|
+
sources.push(...inherited.sources);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
stillUnresolved.push(...unresolved);
|
|
170
|
+
}
|
|
171
|
+
// Only widen when the resolved surface is still not believable: an `export *`
|
|
172
|
+
// we could not follow at all, or an entry that yields almost nothing.
|
|
173
|
+
const needsWiden = entryOnly.size < 5 || stillUnresolved.length > 0;
|
|
174
|
+
let readme = "";
|
|
175
|
+
for (const [rel, src] of files) {
|
|
176
|
+
if (/^readme(\.[a-z]+)?$/i.test(rel)) {
|
|
177
|
+
readme = src;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return { entryOnly, widened, needsWiden, sources, entry, unresolved: stillUnresolved, readme };
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Read the surface of a package this one depends on, at the version the
|
|
185
|
+
* dependency range names. No semver library: an exact pin is used as-is, a
|
|
186
|
+
* caret or tilde range falls back to the highest stable release of that major,
|
|
187
|
+
* and anything else (`workspace:*`, a git url) is left unresolved.
|
|
188
|
+
*/
|
|
189
|
+
async function surfaceOfDependency(pkg, spec) {
|
|
190
|
+
const range = pkg.dependencies?.[spec] ?? pkg.peerDependencies?.[spec] ?? pkg.optionalDependencies?.[spec];
|
|
191
|
+
if (!range)
|
|
192
|
+
return null;
|
|
193
|
+
const bare = String(range).replace(/^[\^~>=<\sv]+/, "");
|
|
194
|
+
if (!/^\d/.test(bare))
|
|
195
|
+
return null;
|
|
196
|
+
const dep = await fetchPackument(spec);
|
|
197
|
+
const version = dep.versions[bare] ? bare : resolveVersion(dep, bare.split(".")[0]);
|
|
198
|
+
// followDeps=false: one hop only, so a deep dependency chain cannot turn one
|
|
199
|
+
// drift check into a package-tree crawl.
|
|
200
|
+
return surfaceOf(dep, version, false);
|
|
201
|
+
}
|
|
202
|
+
/** `export * from "spec"` / `export { a } from "spec"` — the specifier only. */
|
|
203
|
+
const REEXPORT_ALL = /export\s+\*\s+from\s*["'`]([^"'`]+)["'`]/g;
|
|
204
|
+
/**
|
|
205
|
+
* Walk the re-export chain from an entry .d.ts and collect every symbol a
|
|
206
|
+
* consumer can import from the package root.
|
|
207
|
+
*
|
|
208
|
+
* `export { a } from "./b"` needs no walking — symbolsFromSource already sees
|
|
209
|
+
* the names. Only `export * from "./b"` hides them, so only those are followed.
|
|
210
|
+
* A bare (non-relative) `export *` cannot be resolved inside one tarball; it is
|
|
211
|
+
* reported so the caller can fall back to scanning every .d.ts instead of
|
|
212
|
+
* silently under-reporting the surface.
|
|
213
|
+
*/
|
|
214
|
+
export function resolveExports(files, entry, maxDepth = 12) {
|
|
215
|
+
const symbols = new Set();
|
|
216
|
+
const unresolved = [];
|
|
217
|
+
const seen = new Set();
|
|
218
|
+
const walk = (rel, depth) => {
|
|
219
|
+
if (depth > maxDepth || seen.has(rel))
|
|
220
|
+
return;
|
|
221
|
+
seen.add(rel);
|
|
222
|
+
const src = files.get(rel);
|
|
223
|
+
if (src === undefined)
|
|
224
|
+
return;
|
|
225
|
+
for (const x of symbolsFromSource(src))
|
|
226
|
+
symbols.add(x);
|
|
227
|
+
for (const m of src.matchAll(REEXPORT_ALL)) {
|
|
228
|
+
const spec = m[1];
|
|
229
|
+
if (!spec.startsWith(".")) {
|
|
230
|
+
unresolved.push(spec);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const target = resolveRelativeDts(files, path.posix.dirname(rel), spec);
|
|
234
|
+
if (target)
|
|
235
|
+
walk(target, depth + 1);
|
|
236
|
+
else
|
|
237
|
+
unresolved.push(spec);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
walk(entry, 0);
|
|
241
|
+
return { symbols, unresolved: [...new Set(unresolved)] };
|
|
242
|
+
}
|
|
243
|
+
/** Map a relative specifier onto a .d.ts path inside the tarball. */
|
|
244
|
+
function resolveRelativeDts(files, dir, spec) {
|
|
245
|
+
const base = path.posix.normalize(path.posix.join(dir, spec)).replace(/^\.\//, "");
|
|
246
|
+
// `export * from "./core.js"` is how an ESM-correct .d.ts names its sibling.
|
|
247
|
+
const stem = base.replace(/\.(js|mjs|cjs|d\.ts|d\.mts|d\.cts)$/, "");
|
|
248
|
+
for (const c of [
|
|
249
|
+
base,
|
|
250
|
+
`${stem}.d.ts`, `${stem}.d.mts`, `${stem}.d.cts`,
|
|
251
|
+
`${stem}/index.d.ts`, `${stem}/index.d.mts`, `${stem}/index.d.cts`,
|
|
252
|
+
]) {
|
|
253
|
+
if (files.has(c))
|
|
254
|
+
return c;
|
|
255
|
+
}
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Was `sym` a VALUE in this package — a function, class, const or enum — rather
|
|
260
|
+
* than a type-only declaration?
|
|
261
|
+
*
|
|
262
|
+
* It matters for ranking. A model writes values far more often than it writes
|
|
263
|
+
* type names, so `useReactTable` disappearing is a finding and
|
|
264
|
+
* `ColumnFiltersInstance` disappearing usually is not. Declaration merging is
|
|
265
|
+
* resolved in favour of the value, which is the side a model would have
|
|
266
|
+
* written.
|
|
267
|
+
*/
|
|
268
|
+
export function isValueExport(sources, sym) {
|
|
269
|
+
const escaped = sym.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
270
|
+
const value = new RegExp(`\\b(?:declare\\s+)?(?:abstract\\s+)?(?:function|class|const|let|var|enum)\\s+${escaped}\\b`);
|
|
271
|
+
return sources.some((src) => value.test(src));
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Names nobody writes on purpose, so their removal is not a finding. A leading
|
|
275
|
+
* underscore is the convention for "internal, do not import"; `_getVisibleLeafColumns`
|
|
276
|
+
* leaving @tanstack/react-table is not something a model was ever going to write.
|
|
277
|
+
*/
|
|
278
|
+
export function isPublicName(s) {
|
|
279
|
+
return !s.startsWith("UNSAFE_") && !s.startsWith("unstable_") && !s.startsWith("_");
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=surface.js.map
|