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.
Files changed (33) hide show
  1. package/package.json +7 -6
  2. package/plugin/.claude-plugin/plugin.json +1 -1
  3. package/sidecar/dist/src/affected-set.d.ts +172 -0
  4. package/sidecar/dist/src/affected-set.js +936 -0
  5. package/sidecar/dist/src/capture/api.d.ts +34 -0
  6. package/sidecar/dist/src/capture/backfill.d.ts +37 -0
  7. package/sidecar/dist/src/capture/backfill.js +75 -0
  8. package/sidecar/dist/src/capture/index.js +419 -133
  9. package/sidecar/dist/src/capture/installed-package.js +36 -29
  10. package/sidecar/dist/src/capture/self-check.d.ts +14 -3
  11. package/sidecar/dist/src/capture/self-check.js +168 -30
  12. package/sidecar/dist/src/index.js +84 -14
  13. package/sidecar/dist/src/infer-cache.d.ts +0 -8
  14. package/sidecar/dist/src/infer-cache.js +0 -14
  15. package/sidecar/dist/src/library-claims.js +4 -3
  16. package/sidecar/dist/src/module-format.d.ts +13 -2
  17. package/sidecar/dist/src/module-format.js +31 -1
  18. package/sidecar/dist/src/origin.d.ts +10 -7
  19. package/sidecar/dist/src/origin.js +10 -7
  20. package/sidecar/dist/src/program-files.d.ts +34 -11
  21. package/sidecar/dist/src/program-files.js +52 -10
  22. package/sidecar/dist/src/project-loader.d.ts +7 -0
  23. package/sidecar/dist/src/project-loader.js +20 -0
  24. package/sidecar/dist/src/retype-deferred.d.ts +34 -0
  25. package/sidecar/dist/src/retype-deferred.js +326 -0
  26. package/sidecar/dist/src/retype-selector.d.ts +43 -0
  27. package/sidecar/dist/src/retype-selector.js +217 -0
  28. package/sidecar/dist/src/retype.d.ts +28 -3
  29. package/sidecar/dist/src/retype.js +106 -41
  30. package/sidecar/dist/src/type-inferrer.js +3 -2
  31. package/sidecar/dist/src/types.d.ts +113 -3
  32. package/sidecar/dist/src/validators.d.ts +413 -4
  33. package/sidecar/dist/src/validators.js +41 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carrick",
3
- "version": "0.3.138",
3
+ "version": "0.3.140",
4
4
  "carrickCache": {
5
5
  "cache_version": 22,
6
6
  "intent_cache_version": 2
@@ -106,6 +106,7 @@
106
106
  "dependencies": {
107
107
  "@clack/core": "1.5.1",
108
108
  "@clack/prompts": "1.8.1",
109
+ "@ts-morph/common": "0.29.0",
109
110
  "picocolors": "1.1.1",
110
111
  "pnpm": "10.34.5",
111
112
  "ts-morph": "28.0.0",
@@ -114,11 +115,11 @@
114
115
  "zod": "^3.23.0"
115
116
  },
116
117
  "optionalDependencies": {
117
- "@carrick-tools/cli-darwin-arm64": "0.3.138",
118
- "@carrick-tools/cli-darwin-x64": "0.3.138",
119
- "@carrick-tools/cli-linux-arm64": "0.3.138",
120
- "@carrick-tools/cli-linux-x64": "0.3.138",
121
- "@carrick-tools/cli-win32-x64": "0.3.138"
118
+ "@carrick-tools/cli-darwin-arm64": "0.3.140",
119
+ "@carrick-tools/cli-darwin-x64": "0.3.140",
120
+ "@carrick-tools/cli-linux-arm64": "0.3.140",
121
+ "@carrick-tools/cli-linux-x64": "0.3.140",
122
+ "@carrick-tools/cli-win32-x64": "0.3.140"
122
123
  },
123
124
  "devDependencies": {
124
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.138",
4
+ "version": "0.3.140",
5
5
  "author": {
6
6
  "name": "Carrick",
7
7
  "email": "hello@carrick.tools"
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Which files an edit can reach (carrick#2881, carrick#3100).
3
+ *
4
+ * A PR check re-types only the aliases its change can reach. This module says
5
+ * where: the changed files, and every file whose types read a declaration the
6
+ * edit changed, followed name by name rather than file by file, so a barrel
7
+ * (`index.ts` with `export *`) does not turn one changed export into every
8
+ * importer of the package.
9
+ *
10
+ * The walk:
11
+ * - In a changed file, a top-level name is changed when the text of a
12
+ * statement declaring it changed, or when a statement declaring it mentions
13
+ * a changed name of the same file (so `type Dto = z.infer<typeof schema>`
14
+ * changes with `schema`). A statement that declares nothing (an expression
15
+ * statement, which can add an expando member to a function) changes every
16
+ * name it mentions when it changes or mentions a changed name. In a
17
+ * CommonJS file, a changed statement that mentions `module` or `exports`
18
+ * changes the whole module.
19
+ * - An importing file is reached when one of its imports resolves, through
20
+ * every re-export (the compiler's own alias resolution), to a changed
21
+ * declaration. A namespace import reads every export of its module, and so
22
+ * does a dynamic `import()`, `require()` or `import('m').T`, read as a
23
+ * binding of the statement that holds it. Its names that
24
+ * mention the reached imports change in turn, and the walk goes on to their
25
+ * importers. A name whose declaration mentions no changed name stops the walk
26
+ * there, whatever its printed type says.
27
+ * - An added or deleted file is an empty module (`export {};`) on its missing
28
+ * side. It changes every name of the file, and its importers are reached
29
+ * through the graph. Its export names are not matched against importers
30
+ * elsewhere in the repo: nothing imports a name from a file it did not
31
+ * resolve to. What it can change is where an import is looked up, so every
32
+ * import records the stem it was looked up at (a relative specifier's path,
33
+ * and the repo file it resolved to, without extension and trailing
34
+ * `/index`), and an added or deleted file whose own stem matches reaches
35
+ * that import's file.
36
+ * - A global declaration or a module augmentation (`declare global`, `declare
37
+ * module 'x'`) is read by files that never import it (a value returned by
38
+ * the augmented package carries it), so a change to one, or to a name one
39
+ * mentions, is returned in `augmented`: the caller widens it to every file
40
+ * of the programs that hold it, as TypeScript's own scope for an
41
+ * augmentation does. So is any change to a script (a file with no import or
42
+ * export, all of it global). A file that is not TypeScript or JavaScript
43
+ * source, or an installed package's file, reaches every file. An import that
44
+ * resolves to an augmented interface reads the augmentation by its own name
45
+ * (`AUGMENTATION`), so an unchanged augmentation stops nothing.
46
+ * - An export added or removed in a file that exists on both sides (an export
47
+ * list, or a new exported declaration) reaches every file importing that
48
+ * name from anywhere, and the statements of every file holding a namespace
49
+ * or dynamic import that read it.
50
+ *
51
+ * Dependencies run from a file to the declarations it names; the compiler
52
+ * never types a file from the files that import it, so nothing is followed the
53
+ * other way. One assumption: an installed package's declarations do not import
54
+ * the workspace's own sources (only a workspace package could, and its files
55
+ * are read at their real path, outside `node_modules`).
56
+ *
57
+ * The graph is read from a program's own checker, once per program, and keyed
58
+ * by path relative to a root. `serialiseGraph` writes it without statement
59
+ * texts; `reach` walks that form, so a caller needs no program.
60
+ */
61
+ import { ts } from 'ts-morph';
62
+ import type { SerialGraph } from './types.js';
63
+ /** A top-level declaration a file's import reads: `name` `*` is the whole file. */
64
+ export interface Origin {
65
+ file: string;
66
+ name: string;
67
+ }
68
+ /** The top-level statements of one file, read from its text alone. */
69
+ export interface Shape {
70
+ /** Each top-level name, with the texts of the statements declaring it, in order. */
71
+ declared: Map<string, string[]>;
72
+ /** Each top-level name, with the identifiers its statements mention. */
73
+ refs: Map<string, Set<string>>;
74
+ /** Statements that declare nothing: where each starts, its text and the identifiers it mentions. */
75
+ loose: Array<{
76
+ pos: number;
77
+ text: string;
78
+ refs: Set<string>;
79
+ }>;
80
+ /** The names importers can import from it. */
81
+ exports: Set<string>;
82
+ /**
83
+ * Each name an export list or `export default x` gives a local: an importer
84
+ * of the name resolves to the local's declaration, so pointing the name at
85
+ * another local moves it as adding it would.
86
+ */
87
+ exportTargets: Map<string, string>;
88
+ /** It is a script: all of it is global, and a change reaches every file. */
89
+ global: boolean;
90
+ }
91
+ /** One file of the graph: its shape and where each of its imports leads. */
92
+ interface FileNode {
93
+ shape: Shape;
94
+ /** Each import binding, by local name: the declarations it resolves to. */
95
+ bindings: Map<string, Origin[]>;
96
+ /** Each named import binding, by local name: the name it imports. */
97
+ importedNames: Map<string, string>;
98
+ /**
99
+ * The bindings that read every export of a module: a namespace import, an
100
+ * `import x = require()`, and each dynamic `import()`, `require()` or
101
+ * `import('m').T`, bound under a name no identifier can spell and mentioned
102
+ * by the statement that holds it.
103
+ */
104
+ wholeLocals: Set<string>;
105
+ /** Where each import was looked up: an added or deleted file at that stem changes what it resolves to. */
106
+ stems: StemEntry[];
107
+ }
108
+ /** One import specifier of a file, and the stems it was looked up at. */
109
+ export interface StemEntry {
110
+ /** The stems: the relative specifier's path, and the repo file it resolved to. */
111
+ stems: string[];
112
+ /** The repo file it resolved to, when it resolved to one. */
113
+ target?: string;
114
+ /** The bindings the specifier introduces. */
115
+ locals: string[];
116
+ }
117
+ /** The import graph of one program. */
118
+ export interface ImportGraph {
119
+ nodes: Map<string, FileNode>;
120
+ /** Each file, with the files whose imports resolve into it. */
121
+ importers: Map<string, Set<string>>;
122
+ }
123
+ /** What an edit changed in one file: its text before and after. */
124
+ export interface FileChange {
125
+ file: string;
126
+ before: string;
127
+ after: string;
128
+ }
129
+ /** `a/b.d.ts`, `a/b.js` and `a/b/index.ts` all look up as `a/b`. */
130
+ export declare function stemOf(file: string): string;
131
+ /** The top-level names one statement declares. */
132
+ export declare function declaredNames(statement: ts.Statement): string[];
133
+ /** A file's shape from its text. */
134
+ export declare function shapeOf(file: string, text: string): Shape;
135
+ /** The names of `shape` that read any of `seeds`, the seeds included. */
136
+ export declare function closeOver(shape: Shape, seeds: Iterable<string>): Set<string>;
137
+ /**
138
+ * The import graph of `program`'s own (not installed) files, keyed by path
139
+ * relative to `root`.
140
+ */
141
+ export declare function importGraphOf(program: ts.Program, root: string): ImportGraph;
142
+ /**
143
+ * One graph from the graphs of several programs. A file two programs hold
144
+ * keeps every binding either read, and is a script when either reads it as
145
+ * one: reaching more is the safe side.
146
+ */
147
+ export declare function mergeGraphs(graphs: ImportGraph[]): ImportGraph;
148
+ /** What an edit reaches: the files, whether an export was added or removed, and the files holding an augmentation. */
149
+ export type Reached = {
150
+ files: Set<string>;
151
+ exportsMoved: boolean;
152
+ augmented: Set<string>;
153
+ } | 'all';
154
+ /**
155
+ * The files `changes` can reach in the program `graph` was read from, or
156
+ * `'all'` when a change reaches every file. Read the graph from the program
157
+ * as it was before the change. A file that is added or deleted has `''` on its
158
+ * missing side.
159
+ */
160
+ export declare function affectedFiles(graph: ImportGraph, changes: FileChange[]): Reached;
161
+ export declare function serialiseGraph(graph: ImportGraph): SerialGraph;
162
+ /** The graph `serialiseGraph` wrote. Throws on an index outside the string table. */
163
+ export declare function graphFromSerial(serial: SerialGraph): ImportGraph;
164
+ /** What `reach` answers. */
165
+ export interface ReachResult {
166
+ reached: string[] | 'all';
167
+ augmented: string[];
168
+ exports_moved: boolean;
169
+ }
170
+ /** `affectedFiles` over a serialised graph, with the answer sorted. */
171
+ export declare function reach(serial: SerialGraph, changes: FileChange[]): ReachResult;
172
+ export {};