carrick 0.3.163 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carrick",
3
- "version": "0.3.163",
3
+ "version": "0.3.164",
4
4
  "carrickCache": {
5
5
  "cache_version": 22,
6
6
  "intent_cache_version": 2
@@ -115,11 +115,11 @@
115
115
  "zod": "^3.23.0"
116
116
  },
117
117
  "optionalDependencies": {
118
- "@carrick-tools/cli-darwin-arm64": "0.3.163",
119
- "@carrick-tools/cli-darwin-x64": "0.3.163",
120
- "@carrick-tools/cli-linux-arm64": "0.3.163",
121
- "@carrick-tools/cli-linux-x64": "0.3.163",
122
- "@carrick-tools/cli-win32-x64": "0.3.163"
118
+ "@carrick-tools/cli-darwin-arm64": "0.3.164",
119
+ "@carrick-tools/cli-darwin-x64": "0.3.164",
120
+ "@carrick-tools/cli-linux-arm64": "0.3.164",
121
+ "@carrick-tools/cli-linux-x64": "0.3.164",
122
+ "@carrick-tools/cli-win32-x64": "0.3.164"
123
123
  },
124
124
  "devDependencies": {
125
125
  "@types/node": "^24.13.3"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "carrick",
3
3
  "description": "Claude Code plugin for Carrick, which indexes TypeScript codebases across service and repository boundaries. After each edit it adds the file's routes, calls, and cross-service type mismatches to the session, and it registers Carrick's language server. It pairs with the Carrick MCP server, which lets agents search functions by intent rather than name.",
4
- "version": "0.3.163",
4
+ "version": "0.3.164",
5
5
  "author": {
6
6
  "name": "Carrick",
7
7
  "email": "hello@carrick.tools"
@@ -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
- const nodeModulesPresent = fs.existsSync(path.join(dependencyRoot, 'node_modules'));
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
- repoRoot: dependencyRoot,
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 means unresolved.
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
- let dir = path.resolve(root);
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>): Map<string, 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
- const nodeModules = path.join(path.resolve(repoRoot), 'node_modules');
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(repoRoot));
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
- /** Producer repo root; its node_modules (if any) backs resolution. */
57
- repoRoot: string;
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
- /** Producer repo root; its node_modules (if any) backs resolution. */
29
- repoRoot: string;
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 own, unless the checkout is bare or the stub
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 own, unless the checkout is bare or the stub
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 = path.join(resolution.repoRoot, 'node_modules');
29
+ const repoNodeModules = resolution.nodeModules;
30
30
  const linkPath = path.join(resolution.stubDir, 'node_modules');
31
- if (resolution.bareCheckout || !fs.existsSync(repoNodeModules) || fs.existsSync(linkPath))
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":"d1f02f1a4fc4d6ca56af32b5700a01da7d78dfcacdb1942aaf2b2151de1871ee"}
1
+ {"inputs_sha256":"187f6bf1ff8d5146be625769a05e8b46fe4007dc52427bad79e1b918c0e7573b"}
@@ -226,12 +226,12 @@ export declare const InitRequestSchema: z.ZodObject<{
226
226
  }, "strip", z.ZodTypeAny, {
227
227
  compilerOptions: {
228
228
  types?: string[] | undefined;
229
+ declaration?: boolean | undefined;
230
+ declarationMap?: boolean | undefined;
229
231
  module?: string | undefined;
230
232
  moduleResolution?: string | undefined;
231
233
  target?: string | undefined;
232
234
  skipLibCheck?: boolean | undefined;
233
- declaration?: boolean | undefined;
234
- declarationMap?: boolean | undefined;
235
235
  paths?: Record<string, string[]> | undefined;
236
236
  baseUrl?: string | undefined;
237
237
  jsx?: string | undefined;
@@ -245,12 +245,12 @@ export declare const InitRequestSchema: z.ZodObject<{
245
245
  }, {
246
246
  compilerOptions: {
247
247
  types?: string[] | undefined;
248
+ declaration?: boolean | undefined;
249
+ declarationMap?: boolean | undefined;
248
250
  module?: string | undefined;
249
251
  moduleResolution?: string | undefined;
250
252
  target?: string | undefined;
251
253
  skipLibCheck?: boolean | undefined;
252
- declaration?: boolean | undefined;
253
- declarationMap?: boolean | undefined;
254
254
  paths?: Record<string, string[]> | undefined;
255
255
  baseUrl?: string | undefined;
256
256
  jsx?: string | undefined;
@@ -273,12 +273,12 @@ export declare const InitRequestSchema: z.ZodObject<{
273
273
  tsconfig_snapshot?: {
274
274
  compilerOptions: {
275
275
  types?: string[] | undefined;
276
+ declaration?: boolean | undefined;
277
+ declarationMap?: boolean | undefined;
276
278
  module?: string | undefined;
277
279
  moduleResolution?: string | undefined;
278
280
  target?: string | undefined;
279
281
  skipLibCheck?: boolean | undefined;
280
- declaration?: boolean | undefined;
281
- declarationMap?: boolean | undefined;
282
282
  paths?: Record<string, string[]> | undefined;
283
283
  baseUrl?: string | undefined;
284
284
  jsx?: string | undefined;
@@ -301,12 +301,12 @@ export declare const InitRequestSchema: z.ZodObject<{
301
301
  tsconfig_snapshot?: {
302
302
  compilerOptions: {
303
303
  types?: string[] | undefined;
304
+ declaration?: boolean | undefined;
305
+ declarationMap?: boolean | undefined;
304
306
  module?: string | undefined;
305
307
  moduleResolution?: string | undefined;
306
308
  target?: string | undefined;
307
309
  skipLibCheck?: boolean | undefined;
308
- declaration?: boolean | undefined;
309
- declarationMap?: boolean | undefined;
310
310
  paths?: Record<string, string[]> | undefined;
311
311
  baseUrl?: string | undefined;
312
312
  jsx?: string | undefined;
@@ -4619,12 +4619,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
4619
4619
  }, "strip", z.ZodTypeAny, {
4620
4620
  compilerOptions: {
4621
4621
  types?: string[] | undefined;
4622
+ declaration?: boolean | undefined;
4623
+ declarationMap?: boolean | undefined;
4622
4624
  module?: string | undefined;
4623
4625
  moduleResolution?: string | undefined;
4624
4626
  target?: string | undefined;
4625
4627
  skipLibCheck?: boolean | undefined;
4626
- declaration?: boolean | undefined;
4627
- declarationMap?: boolean | undefined;
4628
4628
  paths?: Record<string, string[]> | undefined;
4629
4629
  baseUrl?: string | undefined;
4630
4630
  jsx?: string | undefined;
@@ -4638,12 +4638,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
4638
4638
  }, {
4639
4639
  compilerOptions: {
4640
4640
  types?: string[] | undefined;
4641
+ declaration?: boolean | undefined;
4642
+ declarationMap?: boolean | undefined;
4641
4643
  module?: string | undefined;
4642
4644
  moduleResolution?: string | undefined;
4643
4645
  target?: string | undefined;
4644
4646
  skipLibCheck?: boolean | undefined;
4645
- declaration?: boolean | undefined;
4646
- declarationMap?: boolean | undefined;
4647
4647
  paths?: Record<string, string[]> | undefined;
4648
4648
  baseUrl?: string | undefined;
4649
4649
  jsx?: string | undefined;
@@ -4666,12 +4666,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
4666
4666
  tsconfig_snapshot?: {
4667
4667
  compilerOptions: {
4668
4668
  types?: string[] | undefined;
4669
+ declaration?: boolean | undefined;
4670
+ declarationMap?: boolean | undefined;
4669
4671
  module?: string | undefined;
4670
4672
  moduleResolution?: string | undefined;
4671
4673
  target?: string | undefined;
4672
4674
  skipLibCheck?: boolean | undefined;
4673
- declaration?: boolean | undefined;
4674
- declarationMap?: boolean | undefined;
4675
4675
  paths?: Record<string, string[]> | undefined;
4676
4676
  baseUrl?: string | undefined;
4677
4677
  jsx?: string | undefined;
@@ -4694,12 +4694,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
4694
4694
  tsconfig_snapshot?: {
4695
4695
  compilerOptions: {
4696
4696
  types?: string[] | undefined;
4697
+ declaration?: boolean | undefined;
4698
+ declarationMap?: boolean | undefined;
4697
4699
  module?: string | undefined;
4698
4700
  moduleResolution?: string | undefined;
4699
4701
  target?: string | undefined;
4700
4702
  skipLibCheck?: boolean | undefined;
4701
- declaration?: boolean | undefined;
4702
- declarationMap?: boolean | undefined;
4703
4703
  paths?: Record<string, string[]> | undefined;
4704
4704
  baseUrl?: string | undefined;
4705
4705
  jsx?: string | undefined;