carrick 0.3.162 → 0.3.164
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/held/early.js +62 -3
- package/dist/held/early.js.map +1 -1
- package/dist/held/runtime.js +29 -1
- package/dist/held/runtime.js.map +1 -1
- package/dist/init/task-skills.d.ts +1 -1
- package/dist/init/task-skills.js +1 -0
- package/dist/init/task-skills.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/check-probe.d.ts +9 -4
- package/sidecar/dist/src/capture/check-probe.js +11 -5
- package/sidecar/dist/src/capture/index.js +12 -15
- package/sidecar/dist/src/capture/installed-root.d.ts +17 -0
- package/sidecar/dist/src/capture/installed-root.js +39 -0
- package/sidecar/dist/src/capture/lockfile.d.ts +1 -1
- package/sidecar/dist/src/capture/lockfile.js +9 -3
- package/sidecar/dist/src/capture/self-check.d.ts +2 -2
- package/sidecar/dist/src/capture/stub-resolution.d.ts +3 -3
- package/sidecar/dist/src/capture/stub-resolution.js +3 -3
- package/sidecar/dist/src/engine-stamp.json +1 -1
- package/sidecar/dist/src/type-inferrer.d.ts +76 -0
- package/sidecar/dist/src/type-inferrer.js +267 -5
- package/sidecar/dist/src/validators.d.ts +16 -16
- package/templates/skills/carrick-audit.md +97 -0
- package/templates/skills/carrick-census.md +73 -87
|
@@ -32,6 +32,7 @@ import * as fs from 'node:fs';
|
|
|
32
32
|
import * as path from 'node:path';
|
|
33
33
|
import { entryRelativeSpecifier, resolveAnchor, resolveSourceFile } from './anchors.js';
|
|
34
34
|
import { findAugmentationFiles } from './augmentations.js';
|
|
35
|
+
import { ancestorsWithin, nearestNodeModules } from './installed-root.js';
|
|
35
36
|
import { installedVersions, lockfileVersions } from './lockfile.js';
|
|
36
37
|
import { installedResolutionEdges, RESOLUTION_FILE } from './resolution-edges.js';
|
|
37
38
|
import { rewriteEmittedSpecifiers } from './paths-rewrite.js';
|
|
@@ -485,10 +486,13 @@ export function captureStub(opts) {
|
|
|
485
486
|
}
|
|
486
487
|
// ---- What the checkout installs (shared by both stubs) ----
|
|
487
488
|
const dependencyRoot = deno?.config.workspaceRoot ?? repoRoot;
|
|
488
|
-
|
|
489
|
+
// The install is the nearest `node_modules` up to the scan root: a hoisted
|
|
490
|
+
// root install is the install of its subfolder services.
|
|
491
|
+
const installedModules = nearestNodeModules(dependencyRoot, opts.scanRoot);
|
|
492
|
+
const nodeModulesPresent = installedModules !== undefined;
|
|
489
493
|
const declared = deno || !nodeModulesPresent
|
|
490
494
|
? { unresolved: [], runtimeDeclared: 0, runtimeResolved: 0 }
|
|
491
|
-
: declaredDependencyResolution(dependencyRoot);
|
|
495
|
+
: declaredDependencyResolution(dependencyRoot, opts.scanRoot);
|
|
492
496
|
const unresolvedDependencies = declared.unresolved;
|
|
493
497
|
// Bare: no node_modules, or every declared runtime dependency dangles (a
|
|
494
498
|
// missing pnpm store). One missing package, or missing devDependencies,
|
|
@@ -542,7 +546,7 @@ export function captureStub(opts) {
|
|
|
542
546
|
surfaces: [{ surfaceAbsPath: written.surfaceAbsPath, resolved: written.resolved }],
|
|
543
547
|
pinned: written.pinned,
|
|
544
548
|
bareCheckout,
|
|
545
|
-
|
|
549
|
+
nodeModules: installedModules,
|
|
546
550
|
compilerHost,
|
|
547
551
|
outsideSources: written.outsideSources,
|
|
548
552
|
});
|
|
@@ -770,7 +774,7 @@ function writeStub(surface, stubDir, ctx) {
|
|
|
770
774
|
// remains the bare-checkout fallback. Both paths pin only
|
|
771
775
|
// the directly-referenced externals; what those depend on is recorded
|
|
772
776
|
// from the installed tree below (RESOLUTION_FILE).
|
|
773
|
-
const installed = installedVersions(ctx.repoRoot, externalSpecs);
|
|
777
|
+
const installed = installedVersions(ctx.repoRoot, externalSpecs, ctx.labelRoot);
|
|
774
778
|
const lockVersions = lockfileVersions(ctx.repoRoot);
|
|
775
779
|
for (const name of Object.keys(deno?.pinned ?? {}))
|
|
776
780
|
externalSpecs.add(name);
|
|
@@ -954,13 +958,14 @@ function finishStub(written, aliases, args) {
|
|
|
954
958
|
const UNRESOLVED_DEPENDENCIES_NAMED = 5;
|
|
955
959
|
/**
|
|
956
960
|
* How `root/package.json` dependencies resolve from `root`: no
|
|
957
|
-
* `node_modules/<name>` in `root` or any parent directory
|
|
961
|
+
* `node_modules/<name>` in `root` or any parent directory up to the scan root
|
|
962
|
+
* means unresolved.
|
|
958
963
|
* `existsSync` follows links, so a pnpm link into a missing store reads as
|
|
959
964
|
* unresolved (carrick#2999). `unresolved` is the first few names across
|
|
960
965
|
* dependencies and devDependencies, sorted; the runtime counts cover
|
|
961
966
|
* `dependencies` only. Declared names only, one stat per ancestor.
|
|
962
967
|
*/
|
|
963
|
-
function declaredDependencyResolution(root) {
|
|
968
|
+
function declaredDependencyResolution(root, scanRoot) {
|
|
964
969
|
const none = { unresolved: [], runtimeDeclared: 0, runtimeResolved: 0 };
|
|
965
970
|
let manifest;
|
|
966
971
|
try {
|
|
@@ -976,15 +981,7 @@ function declaredDependencyResolution(root) {
|
|
|
976
981
|
return group !== null && typeof group === 'object' ? Object.keys(group) : [];
|
|
977
982
|
};
|
|
978
983
|
const resolves = (name) => {
|
|
979
|
-
|
|
980
|
-
for (;;) {
|
|
981
|
-
if (fs.existsSync(path.join(dir, 'node_modules', name)))
|
|
982
|
-
return true;
|
|
983
|
-
const parent = path.dirname(dir);
|
|
984
|
-
if (parent === dir)
|
|
985
|
-
return false;
|
|
986
|
-
dir = parent;
|
|
987
|
-
}
|
|
984
|
+
return ancestorsWithin(root, scanRoot).some((dir) => fs.existsSync(path.join(dir, 'node_modules', name)));
|
|
988
985
|
};
|
|
989
986
|
const runtime = new Set(names('dependencies'));
|
|
990
987
|
const all = new Set([...runtime, ...names('devDependencies')]);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a service's dependencies are installed: the nearest `node_modules`
|
|
3
|
+
* directory at or above the service, and no further than the scan root. The
|
|
4
|
+
* rule of `ancestors_within` in the pre-flight (`src/preflight.rs`): a
|
|
5
|
+
* workspace whose install is hoisted to the repository root installs its
|
|
6
|
+
* subfolder services, and an install above the scan root is not theirs.
|
|
7
|
+
*
|
|
8
|
+
* Seam: node builtins only, like the rest of this directory.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* `serviceRoot` and each parent up to and including `scanRoot`, nearest first.
|
|
12
|
+
* Only `serviceRoot` when there is no scan root or the service is not inside
|
|
13
|
+
* it. Containment is decided on real paths; the walk climbs the path as given.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ancestorsWithin(serviceRoot: string, scanRoot?: string): string[];
|
|
16
|
+
/** The nearest `node_modules` directory for the service, or undefined for none. */
|
|
17
|
+
export declare function nearestNodeModules(serviceRoot: string, scanRoot?: string): string | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a service's dependencies are installed: the nearest `node_modules`
|
|
3
|
+
* directory at or above the service, and no further than the scan root. The
|
|
4
|
+
* rule of `ancestors_within` in the pre-flight (`src/preflight.rs`): a
|
|
5
|
+
* workspace whose install is hoisted to the repository root installs its
|
|
6
|
+
* subfolder services, and an install above the scan root is not theirs.
|
|
7
|
+
*
|
|
8
|
+
* Seam: node builtins only, like the rest of this directory.
|
|
9
|
+
*/
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import { realPath } from './service-config.js';
|
|
13
|
+
/**
|
|
14
|
+
* `serviceRoot` and each parent up to and including `scanRoot`, nearest first.
|
|
15
|
+
* Only `serviceRoot` when there is no scan root or the service is not inside
|
|
16
|
+
* it. Containment is decided on real paths; the walk climbs the path as given.
|
|
17
|
+
*/
|
|
18
|
+
export function ancestorsWithin(serviceRoot, scanRoot) {
|
|
19
|
+
const start = path.resolve(serviceRoot);
|
|
20
|
+
if (scanRoot === undefined)
|
|
21
|
+
return [start];
|
|
22
|
+
const fromBound = path.relative(realPath(scanRoot), realPath(start));
|
|
23
|
+
if (fromBound.startsWith('..') || path.isAbsolute(fromBound))
|
|
24
|
+
return [start];
|
|
25
|
+
const levels = fromBound === '' ? 0 : fromBound.split(path.sep).length;
|
|
26
|
+
const dirs = [start];
|
|
27
|
+
for (let level = 0; level < levels; level++)
|
|
28
|
+
dirs.push(path.dirname(dirs[dirs.length - 1]));
|
|
29
|
+
return dirs;
|
|
30
|
+
}
|
|
31
|
+
/** The nearest `node_modules` directory for the service, or undefined for none. */
|
|
32
|
+
export function nearestNodeModules(serviceRoot, scanRoot) {
|
|
33
|
+
for (const dir of ancestorsWithin(serviceRoot, scanRoot)) {
|
|
34
|
+
const candidate = path.join(dir, 'node_modules');
|
|
35
|
+
if (fs.existsSync(candidate))
|
|
36
|
+
return candidate;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
@@ -46,7 +46,7 @@ export declare function isPublishedSemver(version: string): boolean;
|
|
|
46
46
|
* repo entirely (npm/yarn link to a dev checkout) are skipped — the
|
|
47
47
|
* external stays unpinned unless the lockfile supplies a version.
|
|
48
48
|
*/
|
|
49
|
-
export declare function installedVersions(repoRoot: string, names: Iterable<string
|
|
49
|
+
export declare function installedVersions(repoRoot: string, names: Iterable<string>, scanRoot?: string): Map<string, string>;
|
|
50
50
|
/**
|
|
51
51
|
* Resolve exact versions for the repo. Walks up from repoRoot so monorepo
|
|
52
52
|
* members with a hoisted root lockfile still pin (nearest lockfile wins;
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import * as fs from 'node:fs';
|
|
23
23
|
import * as path from 'node:path';
|
|
24
|
+
import { nearestNodeModules } from './installed-root.js';
|
|
24
25
|
/** package-lock.json (v2/v3 `packages` map, v1 `dependencies` fallback). */
|
|
25
26
|
function npmLockfileVersions(lockPath) {
|
|
26
27
|
const versions = new Map();
|
|
@@ -426,12 +427,17 @@ function bunLockfileVersions(lockPath) {
|
|
|
426
427
|
* repo entirely (npm/yarn link to a dev checkout) are skipped — the
|
|
427
428
|
* external stays unpinned unless the lockfile supplies a version.
|
|
428
429
|
*/
|
|
429
|
-
export function installedVersions(repoRoot, names) {
|
|
430
|
+
export function installedVersions(repoRoot, names, scanRoot) {
|
|
430
431
|
const versions = new Map();
|
|
431
|
-
|
|
432
|
+
// The install is the nearest `node_modules` up to the scan root, so a
|
|
433
|
+
// package a hoisted root install holds is read from there, and a link in it
|
|
434
|
+
// is held to the scan root, not to the service folder.
|
|
435
|
+
const nodeModules = nearestNodeModules(repoRoot, scanRoot);
|
|
436
|
+
if (!nodeModules)
|
|
437
|
+
return versions;
|
|
432
438
|
let realRepoRoot;
|
|
433
439
|
try {
|
|
434
|
-
realRepoRoot = fs.realpathSync(path.resolve(
|
|
440
|
+
realRepoRoot = fs.realpathSync(path.resolve(path.dirname(nodeModules)));
|
|
435
441
|
}
|
|
436
442
|
catch {
|
|
437
443
|
return versions;
|
|
@@ -53,8 +53,8 @@ export interface SelfCheckArgs {
|
|
|
53
53
|
surfaces: SelfCheckSurface[];
|
|
54
54
|
pinned: Record<string, string>;
|
|
55
55
|
bareCheckout: boolean;
|
|
56
|
-
/**
|
|
57
|
-
|
|
56
|
+
/** The producer's installed packages (its nearest `node_modules`), if any. */
|
|
57
|
+
nodeModules: string | undefined;
|
|
58
58
|
compilerHost?: (options: ts.CompilerOptions) => ts.CompilerHost;
|
|
59
59
|
/**
|
|
60
60
|
* Absolute stub path of each declaration emitted for a source outside the
|
|
@@ -25,8 +25,8 @@ export interface StubResolution {
|
|
|
25
25
|
guard: WriteGuard;
|
|
26
26
|
stubDir: string;
|
|
27
27
|
bareCheckout: boolean;
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/** The producer's installed packages (its nearest `node_modules`), if any. */
|
|
29
|
+
nodeModules: string | undefined;
|
|
30
30
|
compilerHost?: (options: ts.CompilerOptions) => ts.CompilerHost;
|
|
31
31
|
/**
|
|
32
32
|
* Absolute stub path of each declaration emitted for a source outside the
|
|
@@ -38,7 +38,7 @@ export interface StubResolution {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Point the stub at the producer's installed packages: a `node_modules` link
|
|
41
|
-
* in the stub to the producer's
|
|
41
|
+
* in the stub to the producer's nearest one, unless the checkout is bare or the stub
|
|
42
42
|
* already has one. Returns what removes the link again.
|
|
43
43
|
*/
|
|
44
44
|
export declare function linkInstalledPackages(resolution: StubResolution): () => void;
|
|
@@ -22,13 +22,13 @@ import * as fs from 'node:fs';
|
|
|
22
22
|
import * as path from 'node:path';
|
|
23
23
|
/**
|
|
24
24
|
* Point the stub at the producer's installed packages: a `node_modules` link
|
|
25
|
-
* in the stub to the producer's
|
|
25
|
+
* in the stub to the producer's nearest one, unless the checkout is bare or the stub
|
|
26
26
|
* already has one. Returns what removes the link again.
|
|
27
27
|
*/
|
|
28
28
|
export function linkInstalledPackages(resolution) {
|
|
29
|
-
const repoNodeModules =
|
|
29
|
+
const repoNodeModules = resolution.nodeModules;
|
|
30
30
|
const linkPath = path.join(resolution.stubDir, 'node_modules');
|
|
31
|
-
if (resolution.bareCheckout || !
|
|
31
|
+
if (resolution.bareCheckout || !repoNodeModules || fs.existsSync(linkPath))
|
|
32
32
|
return () => { };
|
|
33
33
|
resolution.guard.symlink(repoNodeModules, linkPath, 'dir');
|
|
34
34
|
// unlinkSync, not rmSync: the link target is a directory and rmSync
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs_sha256":"
|
|
1
|
+
{"inputs_sha256":"187f6bf1ff8d5146be625769a05e8b46fe4007dc52427bad79e1b918c0e7573b"}
|
|
@@ -96,6 +96,12 @@ export declare class TypeInferrer {
|
|
|
96
96
|
* named one. The open-parameter check (carrick#4201) reads it.
|
|
97
97
|
*/
|
|
98
98
|
private readonly printedTypes;
|
|
99
|
+
/**
|
|
100
|
+
* The type the source states for a call result whose text is that
|
|
101
|
+
* statement (a cast, an annotation, a narrowing). The consumer floor
|
|
102
|
+
* (carrick#4513 P1) reads it beside the printed type.
|
|
103
|
+
*/
|
|
104
|
+
private readonly statedTypes;
|
|
99
105
|
private readonly unwidenedLimits;
|
|
100
106
|
private readonly now;
|
|
101
107
|
/**
|
|
@@ -255,6 +261,24 @@ export declare class TypeInferrer {
|
|
|
255
261
|
* (`enclosingTypeParameterIn` starts from the anchor's parent).
|
|
256
262
|
*/
|
|
257
263
|
private withoutOpenTypeParameter;
|
|
264
|
+
/**
|
|
265
|
+
* What a consumer's call result is when it is no body (carrick#4513 P1),
|
|
266
|
+
* read after `await` (`Promise` and other thenables peeled):
|
|
267
|
+
* - a bare type parameter, other than a polymorphic `this`: only the
|
|
268
|
+
* callers of whatever declares it set it, a library class's own `T`
|
|
269
|
+
* included;
|
|
270
|
+
* - a union member, nullish ones aside, that is an instance of a generic
|
|
271
|
+
* class an installed package declares (a result, future or page class
|
|
272
|
+
* around the body). JSON never builds a class instance, so the class is
|
|
273
|
+
* the library's carrier of the body, and its declaration prints its own
|
|
274
|
+
* parameters open. A class without type parameters (an SDK's data
|
|
275
|
+
* class) and a TypeScript lib type (`ArrayBuffer`, `Date`) are kept.
|
|
276
|
+
*/
|
|
277
|
+
private consumerFloorOf;
|
|
278
|
+
/** The name of the generic class an installed package declares that `type` is an instance of. */
|
|
279
|
+
private genericLibraryClassOf;
|
|
280
|
+
/** The decided answer for a call result that is a generic library class instance (carrick#4513 P1). */
|
|
281
|
+
private libraryClassAbstain;
|
|
258
282
|
/**
|
|
259
283
|
* The name of a type parameter `type` holds that a declaration around
|
|
260
284
|
* `node`, or `node` itself, declares. A function or class read at itself is
|
|
@@ -403,6 +427,31 @@ export declare class TypeInferrer {
|
|
|
403
427
|
* no success body and the row abstains.
|
|
404
428
|
*/
|
|
405
429
|
private responseOfDeclaredHandler;
|
|
430
|
+
/**
|
|
431
|
+
* The decided answer of a declared handler none of whose replies carries a
|
|
432
|
+
* success body, or `undefined` when one might (reply-status T2a).
|
|
433
|
+
*
|
|
434
|
+
* Every branch of what the handler returns (`responseReturnedExpressions`,
|
|
435
|
+
* conditionals split; a returned call whose callbacks' returns are already
|
|
436
|
+
* listed, such as `.match(ok, err)`, is a container and not judged itself)
|
|
437
|
+
* must be a reply that states an error or redirect status
|
|
438
|
+
* (`replyStatus`, chain read), or a reply stating a success status that
|
|
439
|
+
* carries no body: no first argument, `null`, `undefined`, or an init
|
|
440
|
+
* object (`statesResponseInit`). A branch counts as a reply only when it
|
|
441
|
+
* is the located send, makes the same call as the located send (callee
|
|
442
|
+
* root and member, so `reply.status(400).send(x)` matches
|
|
443
|
+
* `reply.status(410).send(y)`), or types as framework machinery: a status
|
|
444
|
+
* read off an argument of any other call (`clip(rows, 404)`) is no reply's
|
|
445
|
+
* status. A status no source states (`new Response(null)`, `next()`) or a
|
|
446
|
+
* computed one keeps the row undecided.
|
|
447
|
+
*/
|
|
448
|
+
private noSuccessPayloadOf;
|
|
449
|
+
/**
|
|
450
|
+
* What a send calls, as two sends of one reply API share it: `new` and the
|
|
451
|
+
* constructor's text, or the root of the callee chain and the member
|
|
452
|
+
* called (`reply.status(400).send` -> `reply…send`), or the callee's text.
|
|
453
|
+
*/
|
|
454
|
+
private sendCalleeKey;
|
|
406
455
|
/**
|
|
407
456
|
* The call inside one of `returned` that the located expression is, or is
|
|
408
457
|
* an argument of: the send a located payload was handed to. `undefined`
|
|
@@ -664,7 +713,34 @@ export declare class TypeInferrer {
|
|
|
664
713
|
* holds nothing the call binds.
|
|
665
714
|
*/
|
|
666
715
|
private callResultAtThroughCall;
|
|
716
|
+
/**
|
|
717
|
+
* The type of `call` as the call `through_call` names instantiates the
|
|
718
|
+
* wrapper it is made in (carrick#4375): `typeAtThroughCall`, with no
|
|
719
|
+
* answer recorded. A request that names no call, or a call that binds
|
|
720
|
+
* nothing the type holds, reads the call's own type.
|
|
721
|
+
*/
|
|
722
|
+
private callTypeAsCallerBinds;
|
|
723
|
+
/**
|
|
724
|
+
* A call's result as the caller reads it. A request made below a wrapper
|
|
725
|
+
* (`through_call` names the call that reaches the wrapper) is read at the
|
|
726
|
+
* call it names, where the caller states what it reads, in two cases:
|
|
727
|
+
*
|
|
728
|
+
* - the read below finds only transport (a decided `machinery_envelope`,
|
|
729
|
+
* or the response object itself, stated by nothing): the wrapper hands
|
|
730
|
+
* the transport on, and the body is read off it by its caller;
|
|
731
|
+
* - the caller chooses a raw text body: a text read of the value, or a
|
|
732
|
+
* text format passed at the call (carrick#4513). A raw text body has no
|
|
733
|
+
* JSON shape, so the mark is read at the deciding call whichever call
|
|
734
|
+
* the type came from.
|
|
735
|
+
*
|
|
736
|
+
* A read below the wrapper that finds a body keeps it.
|
|
737
|
+
*/
|
|
667
738
|
private inferCallResult;
|
|
739
|
+
/** The read states nothing but transport: a decided envelope, or the response object unstated. */
|
|
740
|
+
private readIsOnlyTransport;
|
|
741
|
+
/** The raw-text mark the deciding call states, added to a read that did not carry it. */
|
|
742
|
+
private markedAtDecidingCall;
|
|
743
|
+
private inferCallResultBelowWrapper;
|
|
668
744
|
/**
|
|
669
745
|
* The terminal of a call's def-use walk is a zero-argument `.text()` read of
|
|
670
746
|
* the call's own result (carrick#1842): on its binding (`res.text()`,
|