carrick 0.3.153 → 0.3.155
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/bin/carrick.mjs +26 -4
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/contract.d.ts +37 -3
- package/dist/contract.js +8 -0
- package/dist/contract.js.map +1 -1
- package/dist/facts/diff.d.ts +27 -0
- package/dist/facts/diff.js +134 -0
- package/dist/facts/diff.js.map +1 -0
- package/dist/facts/enabled.d.ts +2 -0
- package/dist/facts/enabled.js +9 -0
- package/dist/facts/enabled.js.map +1 -0
- package/dist/facts/fetch.d.ts +48 -0
- package/dist/facts/fetch.js +235 -0
- package/dist/facts/fetch.js.map +1 -0
- package/dist/facts/files.d.ts +21 -0
- package/dist/facts/files.js +58 -0
- package/dist/facts/files.js.map +1 -0
- package/dist/facts/lines.d.ts +70 -0
- package/dist/facts/lines.js +335 -0
- package/dist/facts/lines.js.map +1 -0
- package/dist/facts/match.d.ts +91 -0
- package/dist/facts/match.js +1122 -0
- package/dist/facts/match.js.map +1 -0
- package/dist/facts/peers.d.ts +48 -0
- package/dist/facts/peers.js +143 -0
- package/dist/facts/peers.js.map +1 -0
- package/dist/facts/refresh-run.d.ts +2 -0
- package/dist/facts/refresh-run.js +18 -0
- package/dist/facts/refresh-run.js.map +1 -0
- package/dist/facts/rules/packages.d.ts +16 -0
- package/dist/facts/rules/packages.js +157 -0
- package/dist/facts/rules/packages.js.map +1 -0
- package/dist/facts/rules/same-name.d.ts +28 -0
- package/dist/facts/rules/same-name.js +131 -0
- package/dist/facts/rules/same-name.js.map +1 -0
- package/dist/facts/store.d.ts +119 -0
- package/dist/facts/store.js +341 -0
- package/dist/facts/store.js.map +1 -0
- package/dist/git-remote.d.ts +6 -0
- package/dist/git-remote.js +37 -0
- package/dist/git-remote.js.map +1 -0
- package/dist/hook/apply-patch.d.ts +23 -0
- package/dist/hook/apply-patch.js +92 -0
- package/dist/hook/apply-patch.js.map +1 -1
- package/dist/hook/bash-targets.d.ts +8 -0
- package/dist/hook/bash-targets.js +23 -11
- package/dist/hook/bash-targets.js.map +1 -1
- package/dist/hook/edit-flow.d.ts +29 -2
- package/dist/hook/edit-flow.js +80 -29
- package/dist/hook/edit-flow.js.map +1 -1
- package/dist/hook/late.d.ts +29 -0
- package/dist/hook/late.js +121 -26
- package/dist/hook/late.js.map +1 -1
- package/dist/hook/post-bash.js +45 -22
- package/dist/hook/post-bash.js.map +1 -1
- package/dist/hook/post-edit.d.ts +16 -1
- package/dist/hook/post-edit.js +177 -13
- package/dist/hook/post-edit.js.map +1 -1
- package/dist/hook/post-read.js +8 -12
- package/dist/hook/post-read.js.map +1 -1
- package/dist/hook/post-search.d.ts +2 -0
- package/dist/hook/post-search.js +25 -0
- package/dist/hook/post-search.js.map +1 -0
- package/dist/hook/probe.d.ts +18 -3
- package/dist/hook/probe.js +30 -6
- package/dist/hook/probe.js.map +1 -1
- package/dist/hook/rechecks.d.ts +66 -11
- package/dist/hook/rechecks.js +115 -29
- package/dist/hook/rechecks.js.map +1 -1
- package/dist/hook/refresh.d.ts +9 -0
- package/dist/hook/refresh.js +10 -0
- package/dist/hook/refresh.js.map +1 -1
- package/dist/hook/reuse.d.ts +16 -2
- package/dist/hook/reuse.js +49 -6
- package/dist/hook/reuse.js.map +1 -1
- package/dist/hook/session-key.d.ts +12 -0
- package/dist/hook/session-key.js +30 -0
- package/dist/hook/session-key.js.map +1 -0
- package/dist/hook/session-start.js +14 -7
- package/dist/hook/session-start.js.map +1 -1
- package/dist/hook/stop-wait.d.ts +2 -9
- package/dist/hook/stop-wait.js +96 -113
- package/dist/hook/stop-wait.js.map +1 -1
- package/dist/hook/stop.js +13 -8
- package/dist/hook/stop.js.map +1 -1
- package/dist/hook/subagent-stop.d.ts +2 -0
- package/dist/hook/subagent-stop.js +45 -0
- package/dist/hook/subagent-stop.js.map +1 -0
- package/dist/hook/timings.d.ts +72 -0
- package/dist/hook/timings.js +175 -0
- package/dist/hook/timings.js.map +1 -0
- package/dist/hook/user-prompt.js +17 -13
- package/dist/hook/user-prompt.js.map +1 -1
- package/dist/hook/worktree.d.ts +11 -0
- package/dist/hook/worktree.js +27 -1
- package/dist/hook/worktree.js.map +1 -1
- package/dist/init/repo-copies.d.ts +6 -0
- package/dist/init/repo-copies.js +7 -3
- package/dist/init/repo-copies.js.map +1 -1
- package/dist/init/repos.d.ts +2 -2
- package/dist/init/repos.js +1 -34
- package/dist/init/repos.js.map +1 -1
- package/dist/init/settings.js +25 -13
- package/dist/init/settings.js.map +1 -1
- package/dist/render.d.ts +8 -33
- package/dist/render.js +42 -120
- package/dist/render.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/hooks/hooks.json +44 -3
- package/scripts/install-scanned-deps.sh +25 -2
- package/sidecar/dist/src/capture/anchors.d.ts +12 -1
- package/sidecar/dist/src/capture/anchors.js +28 -47
- package/sidecar/dist/src/capture/api.d.ts +41 -1
- package/sidecar/dist/src/capture/augmentations.d.ts +2 -0
- package/sidecar/dist/src/capture/augmentations.js +1 -1
- package/sidecar/dist/src/capture/check-classify.d.ts +12 -1
- package/sidecar/dist/src/capture/check-classify.js +43 -0
- package/sidecar/dist/src/capture/check-deep.d.ts +44 -1
- package/sidecar/dist/src/capture/check-deep.js +161 -2
- package/sidecar/dist/src/capture/check.js +23 -2
- package/sidecar/dist/src/capture/checkout.d.ts +9 -3
- package/sidecar/dist/src/capture/checkout.js +12 -5
- package/sidecar/dist/src/capture/deep-walk.d.ts +25 -0
- package/sidecar/dist/src/capture/deep-walk.js +41 -0
- package/sidecar/dist/src/capture/deno-project.d.ts +22 -0
- package/sidecar/dist/src/capture/deno-project.js +48 -1
- package/sidecar/dist/src/capture/index.d.ts +3 -1
- package/sidecar/dist/src/capture/index.js +14 -4
- package/sidecar/dist/src/capture/machinery.d.ts +8 -53
- package/sidecar/dist/src/capture/machinery.js +10 -157
- package/sidecar/dist/src/capture/node-builder.d.ts +6 -0
- package/sidecar/dist/src/capture/self-check.d.ts +7 -0
- package/sidecar/dist/src/capture/self-check.js +44 -1
- package/sidecar/dist/src/capture/site-node.d.ts +166 -0
- package/sidecar/dist/src/capture/site-node.js +570 -0
- package/sidecar/dist/src/capture/tool-env.d.ts +12 -0
- package/sidecar/dist/src/capture/tool-env.js +26 -0
- package/sidecar/dist/src/default-library.d.ts +39 -0
- package/sidecar/dist/src/default-library.js +132 -0
- package/sidecar/dist/src/definition-resolver.js +2 -0
- package/sidecar/dist/src/index.js +1 -1
- package/sidecar/dist/src/library-claims.d.ts +2 -0
- package/sidecar/dist/src/library-claims.js +387 -37
- package/sidecar/dist/src/node-index.d.ts +2 -0
- package/sidecar/dist/src/node-index.js +5 -1
- package/sidecar/dist/src/position-rows.d.ts +78 -7
- package/sidecar/dist/src/position-rows.js +343 -18
- package/sidecar/dist/src/project-loader.d.ts +3 -3
- package/sidecar/dist/src/project-loader.js +18 -9
- package/sidecar/dist/src/retype.d.ts +13 -0
- package/sidecar/dist/src/retype.js +126 -0
- package/sidecar/dist/src/type-inferrer.d.ts +47 -145
- package/sidecar/dist/src/type-inferrer.js +102 -529
- package/sidecar/dist/src/types.d.ts +64 -2
- package/sidecar/dist/src/validators.d.ts +806 -142
- package/sidecar/dist/src/validators.js +12 -1
|
@@ -74,6 +74,19 @@ export declare class Retyper {
|
|
|
74
74
|
* type is stated by the returned plan.
|
|
75
75
|
*/
|
|
76
76
|
private beforeRewrite;
|
|
77
|
+
/**
|
|
78
|
+
* Why the call does not state the response when the type argument the
|
|
79
|
+
* retype would state there (its first, written or inferred) holds a type
|
|
80
|
+
* parameter of a declaration the call sits in (carrick#3897), or
|
|
81
|
+
* `undefined`. `return send<T>(url)` inside `read<T>(): Promise<T>` is a
|
|
82
|
+
* pass-through: the call site cannot bind `T`, and the response is read
|
|
83
|
+
* where `read` is called. Stating the producer's type there only makes the
|
|
84
|
+
* compiler compare it with the open `T` ("'T' could be instantiated with an
|
|
85
|
+
* arbitrary type"), which no reader of the response wrote. An enclosing
|
|
86
|
+
* parameter in any other type argument (a generated client's mode flag)
|
|
87
|
+
* leaves the response stated, and the call is judged.
|
|
88
|
+
*/
|
|
89
|
+
private unboundTypeParameterReason;
|
|
77
90
|
/**
|
|
78
91
|
* The rewrite that states the producer's UNWIDENED return (carrick#1516),
|
|
79
92
|
* when the item carries one that can be stated at this call.
|
|
@@ -201,11 +201,34 @@ export class Retyper {
|
|
|
201
201
|
// value escapes to are invisible and an "agrees" would claim them.
|
|
202
202
|
return escape;
|
|
203
203
|
}
|
|
204
|
+
const unbound = this.unboundTypeParameterReason(call);
|
|
205
|
+
if (unbound)
|
|
206
|
+
return unbound;
|
|
204
207
|
const plan = this.plan(call);
|
|
205
208
|
if (typeof plan === 'string')
|
|
206
209
|
return plan;
|
|
207
210
|
return { sourceFile, call, plan };
|
|
208
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Why the call does not state the response when the type argument the
|
|
214
|
+
* retype would state there (its first, written or inferred) holds a type
|
|
215
|
+
* parameter of a declaration the call sits in (carrick#3897), or
|
|
216
|
+
* `undefined`. `return send<T>(url)` inside `read<T>(): Promise<T>` is a
|
|
217
|
+
* pass-through: the call site cannot bind `T`, and the response is read
|
|
218
|
+
* where `read` is called. Stating the producer's type there only makes the
|
|
219
|
+
* compiler compare it with the open `T` ("'T' could be instantiated with an
|
|
220
|
+
* arbitrary type"), which no reader of the response wrote. An enclosing
|
|
221
|
+
* parameter in any other type argument (a generated client's mode flag)
|
|
222
|
+
* leaves the response stated, and the call is judged.
|
|
223
|
+
*/
|
|
224
|
+
unboundTypeParameterReason(call) {
|
|
225
|
+
const checker = this.project.getTypeChecker().compilerObject;
|
|
226
|
+
const signature = checker.getResolvedSignature(call.compilerNode);
|
|
227
|
+
const stated = signature && checker.getTypeArgumentsForResolvedSignature(signature)?.[0];
|
|
228
|
+
return stated
|
|
229
|
+
? unboundReason(checker, "the call's type argument", stated, call.compilerNode)
|
|
230
|
+
: undefined;
|
|
231
|
+
}
|
|
209
232
|
/**
|
|
210
233
|
* The rewrite that states the producer's UNWIDENED return (carrick#1516),
|
|
211
234
|
* when the item carries one that can be stated at this call.
|
|
@@ -282,6 +305,11 @@ export class Retyper {
|
|
|
282
305
|
const reads = bodyReadsOf(call, (read) => this.inferrer.isPlatformBodyRead(read, JSON_READ, 'undeclared_reads'));
|
|
283
306
|
if (typeof reads === 'string')
|
|
284
307
|
return reads;
|
|
308
|
+
for (const read of reads) {
|
|
309
|
+
const unbound = bodyReadUnboundReason(read);
|
|
310
|
+
if (unbound)
|
|
311
|
+
return unbound;
|
|
312
|
+
}
|
|
285
313
|
if (reads.length > 0) {
|
|
286
314
|
const edits = reads.map(bodyReadEdit);
|
|
287
315
|
return (producer, wire) => (useWire) => {
|
|
@@ -493,6 +521,104 @@ function abstain(item, reason) {
|
|
|
493
521
|
function runFailed(outcome) {
|
|
494
522
|
return { ...outcome, run_failed: true };
|
|
495
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* The abstention for a response whose type holds a type parameter of a
|
|
526
|
+
* declaration it sits in (carrick#3897), or `undefined`. The one place the
|
|
527
|
+
* sentence is built, for a call's result and for a body read alike.
|
|
528
|
+
*/
|
|
529
|
+
function unboundReason(checker, what, type, at) {
|
|
530
|
+
const name = enclosingTypeParameterIn(checker, type, at);
|
|
531
|
+
if (name === undefined)
|
|
532
|
+
return undefined;
|
|
533
|
+
return (`${what} ('${checker.typeToString(type)}') uses the enclosing declaration's type ` +
|
|
534
|
+
`parameter '${name}', so the call does not state the response and its readers ` +
|
|
535
|
+
`are that declaration's callers`);
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* {@link unboundReason} for a body read (carrick#3897): the type a cast on
|
|
539
|
+
* it states, or else the type the place it flows into expects
|
|
540
|
+
* (`return res.json()` inside `read<T>(): Promise<T>`). The retype states
|
|
541
|
+
* the producer's type at either, so a type parameter there is the same
|
|
542
|
+
* pass-through as a call's result.
|
|
543
|
+
*/
|
|
544
|
+
function bodyReadUnboundReason(read) {
|
|
545
|
+
const checker = read.getProject().getTypeChecker().compilerObject;
|
|
546
|
+
let top = read;
|
|
547
|
+
for (let parent = top.getParent(); parent; parent = top.getParent()) {
|
|
548
|
+
if (Node.isAsExpression(parent)) {
|
|
549
|
+
const cast = parent.getTypeNodeOrThrow();
|
|
550
|
+
return unboundReason(checker, 'the type the body read is cast to', cast.getType().compilerType, read.compilerNode);
|
|
551
|
+
}
|
|
552
|
+
if (!Node.isAwaitExpression(parent) && !Node.isParenthesizedExpression(parent))
|
|
553
|
+
break;
|
|
554
|
+
top = parent;
|
|
555
|
+
}
|
|
556
|
+
const expected = checker.getContextualType(top.compilerNode);
|
|
557
|
+
return expected
|
|
558
|
+
? unboundReason(checker, 'the type the body read flows into', expected, read.compilerNode)
|
|
559
|
+
: undefined;
|
|
560
|
+
}
|
|
561
|
+
/** How deep {@link enclosingTypeParameterIn} reads into a type. */
|
|
562
|
+
const TYPE_PARAMETER_DEPTH = 4;
|
|
563
|
+
/**
|
|
564
|
+
* The name of a type parameter in `type` that a declaration enclosing `at`
|
|
565
|
+
* declares (a function, a method, a class), or `undefined`. Reads union and
|
|
566
|
+
* intersection members, type arguments, indexed accesses, conditional
|
|
567
|
+
* branches and the properties of an anonymous object type, to a fixed depth.
|
|
568
|
+
* A polymorphic `this` is not one: a call can hold it without passing a
|
|
569
|
+
* response through.
|
|
570
|
+
*/
|
|
571
|
+
function enclosingTypeParameterIn(checker, type, at) {
|
|
572
|
+
const seen = new Set();
|
|
573
|
+
const encloses = (declaring) => {
|
|
574
|
+
for (let node = at.parent; node; node = node.parent) {
|
|
575
|
+
if (node === declaring)
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
return false;
|
|
579
|
+
};
|
|
580
|
+
const visit = (current, depth) => {
|
|
581
|
+
if (depth > TYPE_PARAMETER_DEPTH || seen.has(current))
|
|
582
|
+
return undefined;
|
|
583
|
+
seen.add(current);
|
|
584
|
+
if (current.flags & ts.TypeFlags.TypeParameter) {
|
|
585
|
+
if (current.isThisType)
|
|
586
|
+
return undefined;
|
|
587
|
+
const declared = current.symbol?.declarations?.some((decl) => ts.isTypeParameterDeclaration(decl) && encloses(decl.parent));
|
|
588
|
+
if (declared)
|
|
589
|
+
return current.symbol.getName();
|
|
590
|
+
}
|
|
591
|
+
const parts = [...(current.aliasTypeArguments ?? [])];
|
|
592
|
+
if (current.isUnionOrIntersection())
|
|
593
|
+
parts.push(...current.types);
|
|
594
|
+
if (current.flags & ts.TypeFlags.IndexedAccess) {
|
|
595
|
+
const access = current;
|
|
596
|
+
parts.push(access.objectType, access.indexType);
|
|
597
|
+
}
|
|
598
|
+
if (current.flags & ts.TypeFlags.Conditional) {
|
|
599
|
+
const conditional = current;
|
|
600
|
+
parts.push(conditional.checkType, conditional.extendsType);
|
|
601
|
+
}
|
|
602
|
+
if (current.flags & ts.TypeFlags.Object) {
|
|
603
|
+
const flags = current.objectFlags;
|
|
604
|
+
if (flags & ts.ObjectFlags.Reference) {
|
|
605
|
+
parts.push(...checker.getTypeArguments(current));
|
|
606
|
+
}
|
|
607
|
+
if (flags & ts.ObjectFlags.Anonymous) {
|
|
608
|
+
for (const property of current.getProperties()) {
|
|
609
|
+
parts.push(checker.getTypeOfSymbolAtLocation(property, at));
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
for (const part of parts) {
|
|
614
|
+
const found = visit(part, depth + 1);
|
|
615
|
+
if (found !== undefined)
|
|
616
|
+
return found;
|
|
617
|
+
}
|
|
618
|
+
return undefined;
|
|
619
|
+
};
|
|
620
|
+
return visit(type, 0);
|
|
621
|
+
}
|
|
496
622
|
function asLocator(item) {
|
|
497
623
|
return {
|
|
498
624
|
file_path: item.file_path,
|
|
@@ -20,40 +20,6 @@
|
|
|
20
20
|
import { Project, SourceFile, type CallExpression } from 'ts-morph';
|
|
21
21
|
import type { InferRequestItem, InferResult, ModelSymbol, ExtractionConfig } from './types.js';
|
|
22
22
|
import { type LabelledMembers } from './library-claims.js';
|
|
23
|
-
/**
|
|
24
|
-
* Strongly-discriminating member names of HTTP transport machinery — the
|
|
25
|
-
* fetch/DOM `Response` & `Request`, a Node `http.ServerResponse`, a framework
|
|
26
|
-
* reply object. A type declared in a lib or installed-dependency origin that carries
|
|
27
|
-
* a subset of these is framework machinery, never a user contract: the
|
|
28
|
-
* PRODUCER-side structural mirror of the consumer `machineryIndicators`
|
|
29
|
-
* (ExtractionConfig), used to reject a wrapper envelope whose response field is
|
|
30
|
-
* a raw `Response` (carrick#371) instead of emitting it as a comparable type.
|
|
31
|
-
*
|
|
32
|
-
* Framework-agnostic by construction: no framework NAME appears here, only the
|
|
33
|
-
* shared HTTP-message surface. The names are deliberately the ones no
|
|
34
|
-
* JSON payload ever carries (`ok`, `redirected`, `bodyUsed`, `arrayBuffer`,
|
|
35
|
-
* `writeHead`, ...), so the origin gate + `MACHINERY_INDICATOR_THRESHOLD` never
|
|
36
|
-
* fire on real data. Kept in lockstep with the capture-seam mirror
|
|
37
|
-
* `capture/machinery.ts` (the seam forbids sharing a module across it, same as
|
|
38
|
-
* `BUILTIN_ANCHOR_SYMBOLS` mirrors `socket_io.rs`). Exported so a drift-guard
|
|
39
|
-
* test (`machinery-indicator-mirror.test.ts`) asserts the two sets stay equal.
|
|
40
|
-
*/
|
|
41
|
-
export declare const MACHINERY_MEMBER_INDICATORS: Set<string>;
|
|
42
|
-
/**
|
|
43
|
-
* `text` is `string`, alone or beside `null` and `undefined` in either order:
|
|
44
|
-
* the only payload a raw-text read publishes (carrick#1842).
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* Source text with every plain string literal written in double quotes:
|
|
48
|
-
* `'/a'`, `"/a"` and an interpolation-free `` `/a` `` are one value, so text
|
|
49
|
-
* that differs only in its quotes compares equal (carrick#2056).
|
|
50
|
-
*
|
|
51
|
-
* The text is read left to right, pairing quotes the way the scanner does,
|
|
52
|
-
* so a template's closing backtick never pairs with the next template's
|
|
53
|
-
* opening one. A literal holding a quote, a backslash or an interpolation is
|
|
54
|
-
* copied as it is, and so is an unterminated one with everything after it.
|
|
55
|
-
*/
|
|
56
|
-
export declare function canonicalStringQuotes(text: string): string;
|
|
57
23
|
/**
|
|
58
24
|
* Options for TypeInferrer construction
|
|
59
25
|
*/
|
|
@@ -509,6 +475,18 @@ export declare class TypeInferrer {
|
|
|
509
475
|
*/
|
|
510
476
|
private withArgumentReads;
|
|
511
477
|
private addArgumentReads;
|
|
478
|
+
/** A call the service's labels name a body send; a labelled setter is not one (carrick#2472 C2). */
|
|
479
|
+
private isLabelledSend;
|
|
480
|
+
/**
|
|
481
|
+
* carrick#4081: a line-only row at a registration whose handler returns
|
|
482
|
+
* nothing. Its body is what the handler sends: every labelled send it makes
|
|
483
|
+
* as a statement, error and redirect sends dropped, the success bodies
|
|
484
|
+
* joined, as `inferFromResponseSites` reads them from a located send. Only
|
|
485
|
+
* labelled sends count; an unlabelled one leaves the row unread. A reply
|
|
486
|
+
* parameter that states its payload answers first (`withStatedReply`), so
|
|
487
|
+
* this yields to it.
|
|
488
|
+
*/
|
|
489
|
+
private labelledSendBodies;
|
|
512
490
|
/**
|
|
513
491
|
* The response sends `func` makes as statements (`res.status(409).json(e);`),
|
|
514
492
|
* for a handler that sends through a parameter and returns nothing. Only the
|
|
@@ -713,6 +691,20 @@ export declare class TypeInferrer {
|
|
|
713
691
|
* `{ ok: true } | { ok: false; reason: string }` result read as `sent.ok`.
|
|
714
692
|
*/
|
|
715
693
|
private projectionReadsGenericPayload;
|
|
694
|
+
/**
|
|
695
|
+
* True when the call answers a ONE-ARGUMENT result envelope: a union whose
|
|
696
|
+
* branches say whether the call worked and one of which holds the single
|
|
697
|
+
* type argument as a member (`{ success: true; data: T } | { success: false;
|
|
698
|
+
* error: string }`), carrick#3741. carrick#1376 needs two arguments to tell
|
|
699
|
+
* the success side from the failure side; with one there is nothing to tell
|
|
700
|
+
* apart, and the envelope is the client's bookkeeping around `T`.
|
|
701
|
+
*
|
|
702
|
+
* A site that reads only such an envelope's own members (its status, its
|
|
703
|
+
* error) reads no payload, so the envelope is not a response contract. A
|
|
704
|
+
* union with no type argument (`{ ok: true } | { ok: false; reason: string }`)
|
|
705
|
+
* is not an envelope here and keeps its declared answer (carrick#1375).
|
|
706
|
+
*/
|
|
707
|
+
private isOneArgumentEnvelope;
|
|
716
708
|
/**
|
|
717
709
|
* The payload a RESULT CARRIER carries, or `undefined` when `type` is not
|
|
718
710
|
* one or its success side cannot be told from its failure side
|
|
@@ -1147,72 +1139,37 @@ export declare class TypeInferrer {
|
|
|
1147
1139
|
* envelope `{ response: Response; error?: undefined } | { ...; error: Error }`
|
|
1148
1140
|
* was captured as the response contract. Machinery is never a comparable
|
|
1149
1141
|
* contract, so a response path that resolves here abstains (honest `unknown`)
|
|
1150
|
-
* rather than emit a concrete-but-false type.
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
* 1. the type itself is machinery (`typeIsFrameworkMachinery`);
|
|
1154
|
-
* 2. a union/intersection member is machinery (the envelope union);
|
|
1155
|
-
* 3. a DIRECT property's type is machinery, ONE level of descent only
|
|
1156
|
-
* (`{ response: Response; error }`).
|
|
1157
|
-
*
|
|
1158
|
-
* DELIBERATELY NOT DETECTED — listed so this comment never overstates the
|
|
1159
|
-
* guarantee (an overstated safety comment is what bit sibling PR #442). Each is
|
|
1160
|
-
* a non-regression: it leaves the pre-existing verdict unchanged and never
|
|
1161
|
-
* manufactures a new wrong one, tracked as a follow-up:
|
|
1162
|
-
* - machinery nested deeper than one property level (a property whose type
|
|
1163
|
-
* is itself a nested object wrapping the machinery);
|
|
1164
|
-
* - a property typed `Promise<Response>` (the property type is NOT awaited /
|
|
1165
|
-
* Promise-unwrapped before the machinery check);
|
|
1166
|
-
* - an array element type: `Response[]` is not descended to its element;
|
|
1167
|
-
* - `interface X extends Response` declared in USER source — the origin gate
|
|
1168
|
-
* is lib/installed-dependency only, so a user-declared subtype reads as a real
|
|
1169
|
-
* contract, not machinery;
|
|
1170
|
-
* - a function / call-signature return type: the response paths that call
|
|
1171
|
-
* this resolve a handler's RETURN (an envelope/object), never a function
|
|
1172
|
-
* value, so no call-signature descent happens here. The capture-seam
|
|
1173
|
-
* mirror `capture/machinery.ts` DOES descend call signatures — that is
|
|
1174
|
-
* where the wrapper-FUNCTION type the Infer fallback resolves is caught.
|
|
1175
|
-
*
|
|
1176
|
-
* The origin gate in `typeIsFrameworkMachinery` keeps a user object whose
|
|
1177
|
-
* fields merely share a member name from tripping.
|
|
1142
|
+
* rather than emit a concrete-but-false type. The capture asks the same
|
|
1143
|
+
* question of the same function (`capture/site-node.ts`, carrick#3500), which
|
|
1144
|
+
* states what it detects and what it does not.
|
|
1178
1145
|
*/
|
|
1179
1146
|
private typeIsOrContainsResponseMachinery;
|
|
1180
|
-
private typeIsOrContainsMachinery;
|
|
1181
|
-
/**
|
|
1182
|
-
* True when `type` itself is an HTTP-machinery type: it structurally carries
|
|
1183
|
-
* at least `MACHINERY_INDICATOR_THRESHOLD` of the strongly-discriminating
|
|
1184
|
-
* `MACHINERY_MEMBER_INDICATORS`, AND its symbol is declared in a lib
|
|
1185
|
-
* (`lib.dom.d.ts`, ...) or installed-dependency origin. Both gates are required —
|
|
1186
|
-
* the indicator subset alone essentially never matches a JSON payload, and
|
|
1187
|
-
* the origin gate makes certain a user's own local type sharing those member
|
|
1188
|
-
* names is never mistaken for framework machinery (the advisor's guard).
|
|
1189
|
-
*/
|
|
1190
1147
|
/**
|
|
1191
1148
|
* Blueprint row N8: true when `type` is framework machinery by where it is
|
|
1192
1149
|
* declared, never by its name. Either it passes the structural test
|
|
1193
|
-
* (`
|
|
1194
|
-
* library or an installed package), or an installed
|
|
1195
|
-
* labels a server framework declares it
|
|
1196
|
-
* covers app and router instances that
|
|
1197
|
-
* service's own `Context` or `Router` is neither.
|
|
1150
|
+
* (`isFrameworkMachinery` in `capture/site-node.ts`: the transport's
|
|
1151
|
+
* members, declared by a library or an installed package), or an installed
|
|
1152
|
+
* package the store labels a server framework declares it
|
|
1153
|
+
* (`frameworkPackages`), which also covers app and router instances that
|
|
1154
|
+
* carry no reply members. A service's own `Context` or `Router` is neither.
|
|
1198
1155
|
*/
|
|
1199
1156
|
private isFrameworkMachinery;
|
|
1200
1157
|
private typeIsFrameworkMachinery;
|
|
1158
|
+
private checker;
|
|
1201
1159
|
/**
|
|
1202
|
-
*
|
|
1203
|
-
* `MACHINERY_MEMBER_INDICATORS` (own + apparent). Deduplicates by name (own and
|
|
1204
|
-
* apparent property lists overlap) and early-returns the moment the threshold
|
|
1205
|
-
* is reached — the callers only need the boolean, never the full count.
|
|
1206
|
-
*/
|
|
1207
|
-
private hasMachineryIndicatorThreshold;
|
|
1208
|
-
/**
|
|
1209
|
-
* True when the symbol is declared in a runtime/library origin
|
|
1160
|
+
* Whether a declaration's file is a runtime/library origin
|
|
1210
1161
|
* (`isExternalOrigin`): a TypeScript lib, an installed dependency however
|
|
1211
1162
|
* the program resolved it, or the runtime declarations Carrick materialises
|
|
1212
1163
|
* under `.carrick/deno/` — framework/runtime machinery, not user source.
|
|
1164
|
+
* The program is read per call: the project adds source files lazily and
|
|
1165
|
+
* rebuilds it.
|
|
1166
|
+
*/
|
|
1167
|
+
private readonly declaredOutside;
|
|
1168
|
+
/**
|
|
1169
|
+
* True when the symbol is declared in a runtime/library origin
|
|
1170
|
+
* (`declaredOutside`), itself or through the import alias it stands for.
|
|
1213
1171
|
* Works on a bare checkout: the DOM `Response`/`Request` resolve from the
|
|
1214
|
-
* bundled `lib.dom.d.ts` even with no installed dependencies.
|
|
1215
|
-
* read per call: the project adds source files lazily and rebuilds it.
|
|
1172
|
+
* bundled `lib.dom.d.ts` even with no installed dependencies.
|
|
1216
1173
|
*/
|
|
1217
1174
|
private symbolIsLibOrExternalOrigin;
|
|
1218
1175
|
/**
|
|
@@ -2669,70 +2626,15 @@ export declare class TypeInferrer {
|
|
|
2669
2626
|
*/
|
|
2670
2627
|
private standardSchemaType;
|
|
2671
2628
|
/**
|
|
2672
|
-
* Find a node by matching expression text near a target line
|
|
2673
|
-
*
|
|
2674
|
-
*
|
|
2675
|
-
* 1. Get all descendant nodes within [lineNumber - searchRadius, lineNumber + searchRadius]
|
|
2676
|
-
* 2. Normalize whitespace for comparison
|
|
2677
|
-
* 3. Try exact match first (after normalization), prefer closest to target line
|
|
2678
|
-
* 4. Fall back to substring match (LLM text in node text, or vice versa)
|
|
2679
|
-
* 5. Return smallest matching node closest to target line
|
|
2629
|
+
* Find a node by matching expression text near a target line: the shared
|
|
2630
|
+
* locator (`nodeByLocatorText`, carrick#3500) over every node that starts
|
|
2631
|
+
* within `searchRadius` lines of it, the one the capture runs too.
|
|
2680
2632
|
*/
|
|
2681
2633
|
private findNodeByText;
|
|
2682
2634
|
/**
|
|
2683
2635
|
* Find a CallExpression by matching expression text near a target line.
|
|
2684
2636
|
*/
|
|
2685
2637
|
private findCallExpressionByText;
|
|
2686
|
-
/**
|
|
2687
|
-
* Shared text-matching logic for node resolution.
|
|
2688
|
-
* Normalizes whitespace once per candidate, then tries exact match,
|
|
2689
|
-
* then substring match (preferring containing matches).
|
|
2690
|
-
*/
|
|
2691
|
-
private matchByText;
|
|
2692
|
-
/**
|
|
2693
|
-
* The text a locator opens with before an elision, or `undefined` when the
|
|
2694
|
-
* locator has none. An elision is `...` followed only by closing brackets
|
|
2695
|
-
* (`{ a: x, ... }`); `...rest` is a spread and source text. An opening too
|
|
2696
|
-
* short to tell nodes apart is judged by the caller.
|
|
2697
|
-
*/
|
|
2698
|
-
private elidedLocatorOpening;
|
|
2699
|
-
/**
|
|
2700
|
-
* What a locator's text names, read off its own parse (carrick#2056):
|
|
2701
|
-
*
|
|
2702
|
-
* - `texts`: the normalized text of the expression it names and of each
|
|
2703
|
-
* wrapper it carries around it (`return`, a `const x =` binding, a label,
|
|
2704
|
-
* `await`, parentheses, a cast, `satisfies`, `!`). A node strictly inside
|
|
2705
|
-
* that expression is not among them;
|
|
2706
|
-
* - `rootKind` and `rootStart`: the innermost of those, its kind, and where
|
|
2707
|
-
* its text starts in the locator.
|
|
2708
|
-
*
|
|
2709
|
-
* `null` when the text does not parse as one expression or one statement:
|
|
2710
|
-
* there is no structure to read, and the caller keeps its text rule.
|
|
2711
|
-
*/
|
|
2712
|
-
private locatorNames;
|
|
2713
|
-
/**
|
|
2714
|
-
* Pick the best match from a set of candidate nodes:
|
|
2715
|
-
* smallest range, then closest to target line.
|
|
2716
|
-
*/
|
|
2717
|
-
private pickBestMatch;
|
|
2718
|
-
/**
|
|
2719
|
-
* Normalize whitespace for text comparison:
|
|
2720
|
-
* collapse runs of whitespace into single spaces, trim.
|
|
2721
|
-
*
|
|
2722
|
-
* Also strips trailing commas before `}` `)` `]`: multi-line source
|
|
2723
|
-
* literals carry them but the LLM's single-line locator print does not,
|
|
2724
|
-
* and that one comma used to defeat exact AND containment matching for
|
|
2725
|
-
* the payload and every enclosing node (#335). Applied symmetrically to
|
|
2726
|
-
* node text and target, so both sides compare equal.
|
|
2727
|
-
*
|
|
2728
|
-
* Also strips the space left AFTER `(` `[` `{` by the collapse: a
|
|
2729
|
-
* multi-line call whose arguments start on the next line normalizes to
|
|
2730
|
-
* `f( x)` while the LLM's compact print is `f(x)`, and that one space
|
|
2731
|
-
* defeated exact matching for the call and every enclosing node — the
|
|
2732
|
-
* opening-delimiter mirror of the #335 trailing comma (#336). Symmetric
|
|
2733
|
-
* for the same reason.
|
|
2734
|
-
*/
|
|
2735
|
-
private normalizeWhitespace;
|
|
2736
2638
|
/**
|
|
2737
2639
|
* Format a human-readable location string for error messages.
|
|
2738
2640
|
*/
|