carrick 0.3.138 → 0.3.140
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/package.json +7 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/affected-set.d.ts +172 -0
- package/sidecar/dist/src/affected-set.js +936 -0
- package/sidecar/dist/src/capture/api.d.ts +34 -0
- package/sidecar/dist/src/capture/backfill.d.ts +37 -0
- package/sidecar/dist/src/capture/backfill.js +75 -0
- package/sidecar/dist/src/capture/index.js +419 -133
- package/sidecar/dist/src/capture/installed-package.js +36 -29
- package/sidecar/dist/src/capture/self-check.d.ts +14 -3
- package/sidecar/dist/src/capture/self-check.js +168 -30
- package/sidecar/dist/src/index.js +84 -14
- package/sidecar/dist/src/infer-cache.d.ts +0 -8
- package/sidecar/dist/src/infer-cache.js +0 -14
- package/sidecar/dist/src/library-claims.js +4 -3
- package/sidecar/dist/src/module-format.d.ts +13 -2
- package/sidecar/dist/src/module-format.js +31 -1
- package/sidecar/dist/src/origin.d.ts +10 -7
- package/sidecar/dist/src/origin.js +10 -7
- package/sidecar/dist/src/program-files.d.ts +34 -11
- package/sidecar/dist/src/program-files.js +52 -10
- package/sidecar/dist/src/project-loader.d.ts +7 -0
- package/sidecar/dist/src/project-loader.js +20 -0
- package/sidecar/dist/src/retype-deferred.d.ts +34 -0
- package/sidecar/dist/src/retype-deferred.js +326 -0
- package/sidecar/dist/src/retype-selector.d.ts +43 -0
- package/sidecar/dist/src/retype-selector.js +217 -0
- package/sidecar/dist/src/retype.d.ts +28 -3
- package/sidecar/dist/src/retype.js +106 -41
- package/sidecar/dist/src/type-inferrer.js +3 -2
- package/sidecar/dist/src/types.d.ts +113 -3
- package/sidecar/dist/src/validators.d.ts +413 -4
- package/sidecar/dist/src/validators.js +41 -1
|
@@ -358,6 +358,17 @@ export interface CaptureAliasRecord {
|
|
|
358
358
|
* type alone.
|
|
359
359
|
*/
|
|
360
360
|
absent_body_tolerated?: true;
|
|
361
|
+
/**
|
|
362
|
+
* carrick#3135: lowercase hex SHA-256 of everything the judge reads for
|
|
363
|
+
* this alias from its own stub: the alias's `export type` statement, every
|
|
364
|
+
* tree file its closure reaches, every tree file in global scope (a script,
|
|
365
|
+
* an augmentation, a reference directive), the stub's pinned externals and
|
|
366
|
+
* recorded dependency edges, and the record fields the check reads. Equal
|
|
367
|
+
* hashes on one build mean the judge reads the same input for this alias.
|
|
368
|
+
* Absent on a demoted alias, whose surface line is `unknown` by
|
|
369
|
+
* construction.
|
|
370
|
+
*/
|
|
371
|
+
surface_hash?: string;
|
|
361
372
|
}
|
|
362
373
|
/** Aggregate fidelity metric, emitted per capture (one service). */
|
|
363
374
|
export interface CaptureFidelity {
|
|
@@ -395,6 +406,20 @@ export interface CaptureStubResult {
|
|
|
395
406
|
unresolved_dependencies: string[];
|
|
396
407
|
ts_version: string;
|
|
397
408
|
errors: string[];
|
|
409
|
+
/**
|
|
410
|
+
* carrick#2041: the stub captured again with the demoted aliases the
|
|
411
|
+
* scanner holds a literal text for re-anchored on that text, written to
|
|
412
|
+
* `backfillOutDir`. Absent when no alias qualified or the second surface
|
|
413
|
+
* could not be written. The scanner keeps one of the two stubs.
|
|
414
|
+
*/
|
|
415
|
+
backfill?: CaptureBackfillResult;
|
|
416
|
+
}
|
|
417
|
+
/** The second stub of a capture with a literal backfill (carrick#2041). */
|
|
418
|
+
export interface CaptureBackfillResult {
|
|
419
|
+
/** The aliases re-anchored as literals at `anchor-backfill` origin, in anchor order. */
|
|
420
|
+
backfilled: string[];
|
|
421
|
+
/** The second stub, as a capture of the re-anchored set would answer it. */
|
|
422
|
+
result: CaptureStubResult;
|
|
398
423
|
}
|
|
399
424
|
/**
|
|
400
425
|
* The stages of a capture that it reports as it reaches them (carrick#1916),
|
|
@@ -425,6 +450,15 @@ export interface CaptureStubOptions {
|
|
|
425
450
|
* reporting. It changes nothing the capture writes.
|
|
426
451
|
*/
|
|
427
452
|
onProgress?: (phase: CapturePhase, message: string) => void;
|
|
453
|
+
/**
|
|
454
|
+
* carrick#2041: alias -> literal type text the scanner can stand behind.
|
|
455
|
+
* An alias the capture demotes that has a text here is captured a second
|
|
456
|
+
* time, in the same request, re-anchored on the text, into
|
|
457
|
+
* `backfillOutDir`.
|
|
458
|
+
*/
|
|
459
|
+
backfillTexts?: Record<string, string>;
|
|
460
|
+
/** Where the backfilled stub is written; required with `backfillTexts`. */
|
|
461
|
+
backfillOutDir?: string;
|
|
428
462
|
}
|
|
429
463
|
/** Wire protocol of a matched pair (drives the direction table). */
|
|
430
464
|
export type ProbeProtocol = 'http' | 'graphql' | 'socket' | 'pubsub';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The literal backfill (carrick#2041): which aliases a capture captures a
|
|
3
|
+
* second time, and the host that lets the second surface reuse what the first
|
|
4
|
+
* one parsed.
|
|
5
|
+
*
|
|
6
|
+
* When a capture demotes an alias (its anchor did not resolve, or its module's
|
|
7
|
+
* declaration emit was skipped) and the scanner holds a usable literal type
|
|
8
|
+
* text for it, the same capture writes a second stub with that alias anchored
|
|
9
|
+
* on the text instead (`anchor_origin: anchor-backfill`). The scanner reads
|
|
10
|
+
* both record sets and keeps the second stub only when every backfilled alias
|
|
11
|
+
* self-checked clean and no sibling degraded.
|
|
12
|
+
*/
|
|
13
|
+
import ts from 'typescript';
|
|
14
|
+
import type { CaptureAnchorRequest } from './api.js';
|
|
15
|
+
import type { ResolvedAnchor } from './anchors.js';
|
|
16
|
+
/** The anchors of the second surface, and the aliases it re-anchors. */
|
|
17
|
+
export interface BackfillPlan {
|
|
18
|
+
anchors: CaptureAnchorRequest[];
|
|
19
|
+
/** The re-anchored aliases, in anchor order. */
|
|
20
|
+
backfilled: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Every alias the first surface demoted (`failureReason` is set exactly for a
|
|
24
|
+
* demoted anchor) for which a text is held becomes a literal anchor on that
|
|
25
|
+
* text at `anchor-backfill` origin, keeping the replaced anchor's file. An
|
|
26
|
+
* anchor that is already a literal is never re-anchored: the text tier is
|
|
27
|
+
* the one it is on. `undefined` when no alias qualifies.
|
|
28
|
+
*/
|
|
29
|
+
export declare function backfillRerun(anchors: readonly CaptureAnchorRequest[], resolved: ReadonlyArray<Pick<ResolvedAnchor, 'request' | 'failureReason'>>, texts: Readonly<Record<string, string>> | undefined): BackfillPlan | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* `host` answering every file parsed once into `parsed` with the same source
|
|
32
|
+
* file, except the files `fresh` names. Programs built on such hosts under
|
|
33
|
+
* the same options share their parsed (and bound) files, as an editor's
|
|
34
|
+
* programs do: the backfill's emit reuses the first emit's files, and the two
|
|
35
|
+
* stubs' self-checks reuse the declarations of the installed packages.
|
|
36
|
+
*/
|
|
37
|
+
export declare function sharingHost(host: ts.CompilerHost, fresh: (fileName: string) => boolean, parsed?: Map<string, ts.SourceFile | undefined>): ts.CompilerHost;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The literal backfill (carrick#2041): which aliases a capture captures a
|
|
3
|
+
* second time, and the host that lets the second surface reuse what the first
|
|
4
|
+
* one parsed.
|
|
5
|
+
*
|
|
6
|
+
* When a capture demotes an alias (its anchor did not resolve, or its module's
|
|
7
|
+
* declaration emit was skipped) and the scanner holds a usable literal type
|
|
8
|
+
* text for it, the same capture writes a second stub with that alias anchored
|
|
9
|
+
* on the text instead (`anchor_origin: anchor-backfill`). The scanner reads
|
|
10
|
+
* both record sets and keeps the second stub only when every backfilled alias
|
|
11
|
+
* self-checked clean and no sibling degraded.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Every alias the first surface demoted (`failureReason` is set exactly for a
|
|
15
|
+
* demoted anchor) for which a text is held becomes a literal anchor on that
|
|
16
|
+
* text at `anchor-backfill` origin, keeping the replaced anchor's file. An
|
|
17
|
+
* anchor that is already a literal is never re-anchored: the text tier is
|
|
18
|
+
* the one it is on. `undefined` when no alias qualifies.
|
|
19
|
+
*/
|
|
20
|
+
export function backfillRerun(anchors, resolved, texts) {
|
|
21
|
+
if (!texts)
|
|
22
|
+
return undefined;
|
|
23
|
+
const backfill = new Set();
|
|
24
|
+
for (const anchor of resolved) {
|
|
25
|
+
if (anchor.failureReason === undefined || anchor.request.kind === 'literal')
|
|
26
|
+
continue;
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(texts, anchor.request.alias))
|
|
28
|
+
backfill.add(anchor.request.alias);
|
|
29
|
+
}
|
|
30
|
+
if (backfill.size === 0)
|
|
31
|
+
return undefined;
|
|
32
|
+
const backfilled = [];
|
|
33
|
+
const rerun = anchors.map((anchor) => {
|
|
34
|
+
if (!backfill.has(anchor.alias))
|
|
35
|
+
return anchor;
|
|
36
|
+
backfilled.push(anchor.alias);
|
|
37
|
+
const sourceFile = 'source_file' in anchor ? anchor.source_file : undefined;
|
|
38
|
+
return {
|
|
39
|
+
kind: 'literal',
|
|
40
|
+
alias: anchor.alias,
|
|
41
|
+
type_text: texts[anchor.alias],
|
|
42
|
+
anchor_origin: 'anchor-backfill',
|
|
43
|
+
...(sourceFile ? { source_file: sourceFile } : {}),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
return { anchors: rerun, backfilled };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `host` answering every file parsed once into `parsed` with the same source
|
|
50
|
+
* file, except the files `fresh` names. Programs built on such hosts under
|
|
51
|
+
* the same options share their parsed (and bound) files, as an editor's
|
|
52
|
+
* programs do: the backfill's emit reuses the first emit's files, and the two
|
|
53
|
+
* stubs' self-checks reuse the declarations of the installed packages.
|
|
54
|
+
*/
|
|
55
|
+
export function sharingHost(host, fresh, parsed = new Map()) {
|
|
56
|
+
const getSourceFile = host.getSourceFile.bind(host);
|
|
57
|
+
host.getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreate) => {
|
|
58
|
+
if (fresh(fileName))
|
|
59
|
+
return getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreate);
|
|
60
|
+
const key = `${fileName}\0${parseKey(languageVersionOrOptions)}`;
|
|
61
|
+
if (!shouldCreate && parsed.has(key))
|
|
62
|
+
return parsed.get(key);
|
|
63
|
+
const sourceFile = getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreate);
|
|
64
|
+
parsed.set(key, sourceFile);
|
|
65
|
+
return sourceFile;
|
|
66
|
+
};
|
|
67
|
+
return host;
|
|
68
|
+
}
|
|
69
|
+
/** What a file's parse depends on beside its text. */
|
|
70
|
+
function parseKey(languageVersionOrOptions) {
|
|
71
|
+
if (typeof languageVersionOrOptions !== 'object')
|
|
72
|
+
return String(languageVersionOrOptions);
|
|
73
|
+
const { languageVersion, impliedNodeFormat, jsDocParsingMode } = languageVersionOrOptions;
|
|
74
|
+
return `${languageVersion}:${impliedNodeFormat ?? ''}:${jsDocParsingMode ?? ''}`;
|
|
75
|
+
}
|