carrick 0.3.105 → 0.3.107
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/hook/refresh.js +8 -1
- package/dist/hook/refresh.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/anchors.d.ts +22 -2
- package/sidecar/dist/src/capture/anchors.js +178 -34
- package/sidecar/dist/src/capture/api.d.ts +42 -1
- package/sidecar/dist/src/capture/check-classify.d.ts +9 -1
- package/sidecar/dist/src/capture/check-classify.js +15 -0
- package/sidecar/dist/src/capture/check-poison.js +4 -14
- package/sidecar/dist/src/capture/check.js +13 -1
- package/sidecar/dist/src/capture/index.js +55 -29
- package/sidecar/dist/src/capture/installed-package.d.ts +2 -0
- package/sidecar/dist/src/capture/installed-package.js +2 -1
- package/sidecar/dist/src/capture/outside-root.d.ts +19 -0
- package/sidecar/dist/src/capture/outside-root.js +39 -2
- package/sidecar/dist/src/capture/self-check.js +12 -13
- package/sidecar/dist/src/capture/service-config.d.ts +2 -0
- package/sidecar/dist/src/capture/service-config.js +1 -1
- package/sidecar/dist/src/capture/specifiers.d.ts +14 -0
- package/sidecar/dist/src/capture/specifiers.js +25 -0
- package/sidecar/dist/src/failure-path.d.ts +34 -3
- package/sidecar/dist/src/failure-path.js +59 -35
- package/sidecar/dist/src/function-line-index.d.ts +30 -0
- package/sidecar/dist/src/function-line-index.js +162 -0
- package/sidecar/dist/src/index.d.ts +5 -0
- package/sidecar/dist/src/index.js +29 -5
- package/sidecar/dist/src/line-index.d.ts +9 -0
- package/sidecar/dist/src/line-index.js +26 -0
- package/sidecar/dist/src/printed-names.d.ts +43 -0
- package/sidecar/dist/src/printed-names.js +186 -0
- package/sidecar/dist/src/progress.d.ts +22 -0
- package/sidecar/dist/src/progress.js +31 -0
- package/sidecar/dist/src/retype.js +58 -128
- package/sidecar/dist/src/type-inferrer.d.ts +124 -13
- package/sidecar/dist/src/type-inferrer.js +531 -146
- package/sidecar/dist/src/type-structural-expander.js +10 -1
- package/sidecar/dist/src/types.d.ts +37 -6
- package/sidecar/dist/src/validators.d.ts +76 -0
- package/sidecar/dist/src/validators.js +8 -0
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
import { ts } from 'ts-morph';
|
|
32
32
|
import { canonicalizeUnionsInText, foldBooleanLiterals, } from './type-text-canonicalizer.js';
|
|
33
33
|
import { isExternalOrigin } from './origin.js';
|
|
34
|
+
import { notePrintedType } from './printed-names.js';
|
|
34
35
|
/**
|
|
35
36
|
* Bound on the structural-expansion recursion. Deep enough for every realistic
|
|
36
37
|
* request/response shape; a backstop against pathological/recursive types the
|
|
@@ -385,8 +386,16 @@ function isLibraryType(type, origin) {
|
|
|
385
386
|
export function namedText(type) {
|
|
386
387
|
return canonicalizeUnionsInText(compilerText(type));
|
|
387
388
|
}
|
|
388
|
-
/**
|
|
389
|
+
/**
|
|
390
|
+
* The compiler's print, with the two fallbacks. The print writes names bare,
|
|
391
|
+
* whatever scope reads it, so it is noted for the inference (carrick#1836).
|
|
392
|
+
*/
|
|
389
393
|
function compilerText(type) {
|
|
394
|
+
const text = compilerPrint(type);
|
|
395
|
+
notePrintedType(type, undefined, text);
|
|
396
|
+
return text;
|
|
397
|
+
}
|
|
398
|
+
function compilerPrint(type) {
|
|
390
399
|
try {
|
|
391
400
|
return type.getText(undefined, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.InTypeAlias);
|
|
392
401
|
}
|
|
@@ -38,7 +38,10 @@ export interface ExtractionRule {
|
|
|
38
38
|
originModuleGlobs?: string[];
|
|
39
39
|
/**
|
|
40
40
|
* Index of the generic type argument containing the payload.
|
|
41
|
-
* Defaults to 0 (first type arg).
|
|
41
|
+
* Defaults to 0 (first type arg). It counts the parameters of the name
|
|
42
|
+
* the rule matched: a type alias named in `wrapperSymbols` is read by its
|
|
43
|
+
* own parameters, which it may order differently from the type it stands
|
|
44
|
+
* for (carrick#1843).
|
|
42
45
|
* Examples:
|
|
43
46
|
* - Response<T> → index 0
|
|
44
47
|
* - Map<K, V> → index 1 for values
|
|
@@ -780,14 +783,18 @@ export interface InferredType {
|
|
|
780
783
|
array_depth?: number;
|
|
781
784
|
/**
|
|
782
785
|
* Declaration file of `primary_type_symbol` (absolute path), when the
|
|
783
|
-
* anchor symbol has a resolvable source declaration.
|
|
784
|
-
*
|
|
786
|
+
* anchor symbol has a resolvable source declaration. Reported by every
|
|
787
|
+
* infer kind that reports the symbol (carrick#1819): it is where a reader
|
|
788
|
+
* finds the type an anchor names, and the scanner writes an anchor's home
|
|
789
|
+
* from it. The file is the one that declares the symbol the type resolves
|
|
790
|
+
* to, never a barrel that re-exports it.
|
|
791
|
+
*
|
|
792
|
+
* The scanner's pub/sub two-anchor arbitration (carrick#413) also reads it,
|
|
793
|
+
* for a borrowed-anchor request only, to re-aim a demoted explicit
|
|
785
794
|
* `SymbolRequest` at the tsc-witnessed payload type: the bundler requires
|
|
786
795
|
* the symbol to be declared in, or re-exported by, the request's
|
|
787
796
|
* `source_file`, and the inference is the only party that knows where that
|
|
788
|
-
* is.
|
|
789
|
-
* the pub/sub infer kinds (`function_param`, `expression`); other kinds
|
|
790
|
-
* omit it.
|
|
797
|
+
* is.
|
|
791
798
|
*/
|
|
792
799
|
primary_type_symbol_source?: string;
|
|
793
800
|
/**
|
|
@@ -823,6 +830,23 @@ export interface InferredType {
|
|
|
823
830
|
* stated, or when the only annotation is further away than the read.
|
|
824
831
|
*/
|
|
825
832
|
stated_body?: StatedBody;
|
|
833
|
+
/**
|
|
834
|
+
* carrick#1836: the declarations behind the names `type_string` prints that
|
|
835
|
+
* the request's file does not resolve. The printer writes names bare where
|
|
836
|
+
* no scope reads them, so this is the only record of what they meant. A
|
|
837
|
+
* name printed for two declarations is listed twice. Absent when there is
|
|
838
|
+
* nothing to list.
|
|
839
|
+
*/
|
|
840
|
+
printed_names?: PrintedName[];
|
|
841
|
+
/**
|
|
842
|
+
* carrick#1842, `call_result` only: the published `string` is the body read
|
|
843
|
+
* as raw text, by a `.text()` read of the call's response or by a call whose
|
|
844
|
+
* signature takes the literal `'text'` the source passes as its body format.
|
|
845
|
+
* Raw text states no structural contract, so the check phase reads the pair
|
|
846
|
+
* unverifiable rather than comparing `string` with the other side's body.
|
|
847
|
+
* Absent when the body is not a raw-text read.
|
|
848
|
+
*/
|
|
849
|
+
raw_text_read?: true;
|
|
826
850
|
}
|
|
827
851
|
/**
|
|
828
852
|
* What the source states a body read to be (carrick#1749). The scanner
|
|
@@ -843,6 +867,11 @@ export interface StatedBody {
|
|
|
843
867
|
root_source?: string;
|
|
844
868
|
/** Array levels peeled on the way to `root`. Omitted when 0. */
|
|
845
869
|
array_depth?: number;
|
|
870
|
+
/**
|
|
871
|
+
* Type arguments written at `root` (`Page<Order>` → 1). Omitted when 0.
|
|
872
|
+
* `root` alone does not name the body such a statement states.
|
|
873
|
+
*/
|
|
874
|
+
root_type_arguments?: number;
|
|
846
875
|
}
|
|
847
876
|
/**
|
|
848
877
|
* Why a type carries `any`/`unknown` at a position, and where.
|
|
@@ -853,6 +882,8 @@ export interface StatedBody {
|
|
|
853
882
|
* across the bundle seam.
|
|
854
883
|
*/
|
|
855
884
|
export type TypeProvenance = import('./capture/api.js').TypeProvenance;
|
|
885
|
+
/** carrick#1836: declared in the capture bundle, which reads it on a literal anchor. */
|
|
886
|
+
export type PrintedName = import('./capture/api.js').PrintedName;
|
|
856
887
|
export type TypeProvenanceReason = import('./capture/api.js').TypeProvenanceReason;
|
|
857
888
|
/**
|
|
858
889
|
* Source location information for a type
|
|
@@ -332,18 +332,44 @@ export declare const CaptureV2RequestSchema: z.ZodObject<{
|
|
|
332
332
|
type_text: z.ZodString;
|
|
333
333
|
anchor_origin: z.ZodEnum<["llm-symbol", "deterministic-infer", "anchor-backfill", "manifest-placeholder"]>;
|
|
334
334
|
source_file: z.ZodOptional<z.ZodString>;
|
|
335
|
+
printed_names: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
336
|
+
name: z.ZodString;
|
|
337
|
+
file: z.ZodString;
|
|
338
|
+
export_path: z.ZodArray<z.ZodString, "many">;
|
|
339
|
+
}, "strip", z.ZodTypeAny, {
|
|
340
|
+
name: string;
|
|
341
|
+
file: string;
|
|
342
|
+
export_path: string[];
|
|
343
|
+
}, {
|
|
344
|
+
name: string;
|
|
345
|
+
file: string;
|
|
346
|
+
export_path: string[];
|
|
347
|
+
}>, "many">>;
|
|
348
|
+
raw_text_read: z.ZodOptional<z.ZodLiteral<true>>;
|
|
335
349
|
}, "strip", z.ZodTypeAny, {
|
|
336
350
|
kind: "literal";
|
|
337
351
|
alias: string;
|
|
338
352
|
anchor_origin: "llm-symbol" | "deterministic-infer" | "anchor-backfill" | "manifest-placeholder";
|
|
339
353
|
type_text: string;
|
|
340
354
|
source_file?: string | undefined;
|
|
355
|
+
printed_names?: {
|
|
356
|
+
name: string;
|
|
357
|
+
file: string;
|
|
358
|
+
export_path: string[];
|
|
359
|
+
}[] | undefined;
|
|
360
|
+
raw_text_read?: true | undefined;
|
|
341
361
|
}, {
|
|
342
362
|
kind: "literal";
|
|
343
363
|
alias: string;
|
|
344
364
|
anchor_origin: "llm-symbol" | "deterministic-infer" | "anchor-backfill" | "manifest-placeholder";
|
|
345
365
|
type_text: string;
|
|
346
366
|
source_file?: string | undefined;
|
|
367
|
+
printed_names?: {
|
|
368
|
+
name: string;
|
|
369
|
+
file: string;
|
|
370
|
+
export_path: string[];
|
|
371
|
+
}[] | undefined;
|
|
372
|
+
raw_text_read?: true | undefined;
|
|
347
373
|
}>]>, "many">;
|
|
348
374
|
out_dir: z.ZodString;
|
|
349
375
|
tsconfig_path: z.ZodOptional<z.ZodString>;
|
|
@@ -382,6 +408,12 @@ export declare const CaptureV2RequestSchema: z.ZodObject<{
|
|
|
382
408
|
anchor_origin: "llm-symbol" | "deterministic-infer" | "anchor-backfill" | "manifest-placeholder";
|
|
383
409
|
type_text: string;
|
|
384
410
|
source_file?: string | undefined;
|
|
411
|
+
printed_names?: {
|
|
412
|
+
name: string;
|
|
413
|
+
file: string;
|
|
414
|
+
export_path: string[];
|
|
415
|
+
}[] | undefined;
|
|
416
|
+
raw_text_read?: true | undefined;
|
|
385
417
|
})[];
|
|
386
418
|
out_dir: string;
|
|
387
419
|
tsconfig_path?: string | undefined;
|
|
@@ -420,6 +452,12 @@ export declare const CaptureV2RequestSchema: z.ZodObject<{
|
|
|
420
452
|
anchor_origin: "llm-symbol" | "deterministic-infer" | "anchor-backfill" | "manifest-placeholder";
|
|
421
453
|
type_text: string;
|
|
422
454
|
source_file?: string | undefined;
|
|
455
|
+
printed_names?: {
|
|
456
|
+
name: string;
|
|
457
|
+
file: string;
|
|
458
|
+
export_path: string[];
|
|
459
|
+
}[] | undefined;
|
|
460
|
+
raw_text_read?: true | undefined;
|
|
423
461
|
})[];
|
|
424
462
|
out_dir: string;
|
|
425
463
|
tsconfig_path?: string | undefined;
|
|
@@ -2077,18 +2115,44 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
2077
2115
|
type_text: z.ZodString;
|
|
2078
2116
|
anchor_origin: z.ZodEnum<["llm-symbol", "deterministic-infer", "anchor-backfill", "manifest-placeholder"]>;
|
|
2079
2117
|
source_file: z.ZodOptional<z.ZodString>;
|
|
2118
|
+
printed_names: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2119
|
+
name: z.ZodString;
|
|
2120
|
+
file: z.ZodString;
|
|
2121
|
+
export_path: z.ZodArray<z.ZodString, "many">;
|
|
2122
|
+
}, "strip", z.ZodTypeAny, {
|
|
2123
|
+
name: string;
|
|
2124
|
+
file: string;
|
|
2125
|
+
export_path: string[];
|
|
2126
|
+
}, {
|
|
2127
|
+
name: string;
|
|
2128
|
+
file: string;
|
|
2129
|
+
export_path: string[];
|
|
2130
|
+
}>, "many">>;
|
|
2131
|
+
raw_text_read: z.ZodOptional<z.ZodLiteral<true>>;
|
|
2080
2132
|
}, "strip", z.ZodTypeAny, {
|
|
2081
2133
|
kind: "literal";
|
|
2082
2134
|
alias: string;
|
|
2083
2135
|
anchor_origin: "llm-symbol" | "deterministic-infer" | "anchor-backfill" | "manifest-placeholder";
|
|
2084
2136
|
type_text: string;
|
|
2085
2137
|
source_file?: string | undefined;
|
|
2138
|
+
printed_names?: {
|
|
2139
|
+
name: string;
|
|
2140
|
+
file: string;
|
|
2141
|
+
export_path: string[];
|
|
2142
|
+
}[] | undefined;
|
|
2143
|
+
raw_text_read?: true | undefined;
|
|
2086
2144
|
}, {
|
|
2087
2145
|
kind: "literal";
|
|
2088
2146
|
alias: string;
|
|
2089
2147
|
anchor_origin: "llm-symbol" | "deterministic-infer" | "anchor-backfill" | "manifest-placeholder";
|
|
2090
2148
|
type_text: string;
|
|
2091
2149
|
source_file?: string | undefined;
|
|
2150
|
+
printed_names?: {
|
|
2151
|
+
name: string;
|
|
2152
|
+
file: string;
|
|
2153
|
+
export_path: string[];
|
|
2154
|
+
}[] | undefined;
|
|
2155
|
+
raw_text_read?: true | undefined;
|
|
2092
2156
|
}>]>, "many">;
|
|
2093
2157
|
out_dir: z.ZodString;
|
|
2094
2158
|
tsconfig_path: z.ZodOptional<z.ZodString>;
|
|
@@ -2127,6 +2191,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
2127
2191
|
anchor_origin: "llm-symbol" | "deterministic-infer" | "anchor-backfill" | "manifest-placeholder";
|
|
2128
2192
|
type_text: string;
|
|
2129
2193
|
source_file?: string | undefined;
|
|
2194
|
+
printed_names?: {
|
|
2195
|
+
name: string;
|
|
2196
|
+
file: string;
|
|
2197
|
+
export_path: string[];
|
|
2198
|
+
}[] | undefined;
|
|
2199
|
+
raw_text_read?: true | undefined;
|
|
2130
2200
|
})[];
|
|
2131
2201
|
out_dir: string;
|
|
2132
2202
|
tsconfig_path?: string | undefined;
|
|
@@ -2165,6 +2235,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
2165
2235
|
anchor_origin: "llm-symbol" | "deterministic-infer" | "anchor-backfill" | "manifest-placeholder";
|
|
2166
2236
|
type_text: string;
|
|
2167
2237
|
source_file?: string | undefined;
|
|
2238
|
+
printed_names?: {
|
|
2239
|
+
name: string;
|
|
2240
|
+
file: string;
|
|
2241
|
+
export_path: string[];
|
|
2242
|
+
}[] | undefined;
|
|
2243
|
+
raw_text_read?: true | undefined;
|
|
2168
2244
|
})[];
|
|
2169
2245
|
out_dir: string;
|
|
2170
2246
|
tsconfig_path?: string | undefined;
|
|
@@ -184,6 +184,14 @@ const CaptureAnchorRequestSchema = z.discriminatedUnion('kind', [
|
|
|
184
184
|
type_text: z.string().min(1),
|
|
185
185
|
anchor_origin: AnchorOriginSchema,
|
|
186
186
|
source_file: z.string().min(1).optional(),
|
|
187
|
+
printed_names: z
|
|
188
|
+
.array(z.object({
|
|
189
|
+
name: z.string().min(1),
|
|
190
|
+
file: z.string().min(1),
|
|
191
|
+
export_path: z.array(z.string().min(1)).min(1),
|
|
192
|
+
}))
|
|
193
|
+
.optional(),
|
|
194
|
+
raw_text_read: z.literal(true).optional(),
|
|
187
195
|
}),
|
|
188
196
|
]);
|
|
189
197
|
export const CaptureV2RequestSchema = BaseRequestSchema.extend({
|