carrick 0.3.53
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/LICENSE.md +99 -0
- package/README.md +79 -0
- package/bin/carrick.mjs +168 -0
- package/dist/channel.d.ts +16 -0
- package/dist/channel.js +37 -0
- package/dist/channel.js.map +1 -0
- package/dist/cli.d.ts +29 -0
- package/dist/cli.js +60 -0
- package/dist/cli.js.map +1 -0
- package/dist/contract.d.ts +154 -0
- package/dist/contract.js +141 -0
- package/dist/contract.js.map +1 -0
- package/dist/diagnostics.d.ts +54 -0
- package/dist/diagnostics.js +199 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/hook/post-edit.d.ts +13 -0
- package/dist/hook/post-edit.js +76 -0
- package/dist/hook/post-edit.js.map +1 -0
- package/dist/hook/session-start.d.ts +2 -0
- package/dist/hook/session-start.js +44 -0
- package/dist/hook/session-start.js.map +1 -0
- package/dist/init/identity.d.ts +20 -0
- package/dist/init/identity.js +60 -0
- package/dist/init/identity.js.map +1 -0
- package/dist/init/repos.d.ts +19 -0
- package/dist/init/repos.js +46 -0
- package/dist/init/repos.js.map +1 -0
- package/dist/init/run.d.ts +11 -0
- package/dist/init/run.js +228 -0
- package/dist/init/run.js.map +1 -0
- package/dist/init/settings.d.ts +50 -0
- package/dist/init/settings.js +138 -0
- package/dist/init/settings.js.map +1 -0
- package/dist/log.d.ts +2 -0
- package/dist/log.js +35 -0
- package/dist/log.js.map +1 -0
- package/dist/native.d.ts +48 -0
- package/dist/native.js +127 -0
- package/dist/native.js.map +1 -0
- package/dist/render.d.ts +65 -0
- package/dist/render.js +334 -0
- package/dist/render.js.map +1 -0
- package/dist/root.d.ts +30 -0
- package/dist/root.js +82 -0
- package/dist/root.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +255 -0
- package/dist/server.js.map +1 -0
- package/dist/templates.d.ts +18 -0
- package/dist/templates.js +66 -0
- package/dist/templates.js.map +1 -0
- package/package.json +72 -0
- package/plugin/.claude-plugin/plugin.json +6 -0
- package/plugin/.lsp.json +14 -0
- package/plugin/hooks/hooks.json +27 -0
- package/sidecar/dist/src/bundler.d.ts +141 -0
- package/sidecar/dist/src/bundler.js +680 -0
- package/sidecar/dist/src/capture/anchors.d.ts +61 -0
- package/sidecar/dist/src/capture/anchors.js +1132 -0
- package/sidecar/dist/src/capture/api.d.ts +378 -0
- package/sidecar/dist/src/capture/api.js +10 -0
- package/sidecar/dist/src/capture/augmentations.d.ts +20 -0
- package/sidecar/dist/src/capture/augmentations.js +60 -0
- package/sidecar/dist/src/capture/check-classify.d.ts +58 -0
- package/sidecar/dist/src/capture/check-classify.js +189 -0
- package/sidecar/dist/src/capture/check-deep.d.ts +32 -0
- package/sidecar/dist/src/capture/check-deep.js +91 -0
- package/sidecar/dist/src/capture/check-poison.d.ts +40 -0
- package/sidecar/dist/src/capture/check-poison.js +155 -0
- package/sidecar/dist/src/capture/check-probe.d.ts +70 -0
- package/sidecar/dist/src/capture/check-probe.js +147 -0
- package/sidecar/dist/src/capture/check-scrub.d.ts +31 -0
- package/sidecar/dist/src/capture/check-scrub.js +71 -0
- package/sidecar/dist/src/capture/check-workspace.d.ts +52 -0
- package/sidecar/dist/src/capture/check-workspace.js +218 -0
- package/sidecar/dist/src/capture/check.d.ts +39 -0
- package/sidecar/dist/src/capture/check.js +450 -0
- package/sidecar/dist/src/capture/deep-walk.d.ts +62 -0
- package/sidecar/dist/src/capture/deep-walk.js +243 -0
- package/sidecar/dist/src/capture/index.d.ts +36 -0
- package/sidecar/dist/src/capture/index.js +477 -0
- package/sidecar/dist/src/capture/lockfile.d.ts +48 -0
- package/sidecar/dist/src/capture/lockfile.js +490 -0
- package/sidecar/dist/src/capture/machinery.d.ts +59 -0
- package/sidecar/dist/src/capture/machinery.js +160 -0
- package/sidecar/dist/src/capture/node-builder.d.ts +37 -0
- package/sidecar/dist/src/capture/node-builder.js +123 -0
- package/sidecar/dist/src/capture/paths-rewrite.d.ts +34 -0
- package/sidecar/dist/src/capture/paths-rewrite.js +100 -0
- package/sidecar/dist/src/capture/self-check.d.ts +38 -0
- package/sidecar/dist/src/capture/self-check.js +317 -0
- package/sidecar/dist/src/capture/specifiers.d.ts +39 -0
- package/sidecar/dist/src/capture/specifiers.js +56 -0
- package/sidecar/dist/src/definition-resolver.d.ts +57 -0
- package/sidecar/dist/src/definition-resolver.js +153 -0
- package/sidecar/dist/src/index.d.ts +14 -0
- package/sidecar/dist/src/index.js +564 -0
- package/sidecar/dist/src/monorepo-builder.d.ts +129 -0
- package/sidecar/dist/src/monorepo-builder.js +584 -0
- package/sidecar/dist/src/project-loader.d.ts +130 -0
- package/sidecar/dist/src/project-loader.js +399 -0
- package/sidecar/dist/src/type-inferrer.d.ts +940 -0
- package/sidecar/dist/src/type-inferrer.js +3540 -0
- package/sidecar/dist/src/type-structural-expander.d.ts +61 -0
- package/sidecar/dist/src/type-structural-expander.js +283 -0
- package/sidecar/dist/src/type-text-canonicalizer.d.ts +40 -0
- package/sidecar/dist/src/type-text-canonicalizer.js +297 -0
- package/sidecar/dist/src/types.d.ts +669 -0
- package/sidecar/dist/src/types.js +5 -0
- package/sidecar/dist/src/validators.d.ts +2214 -0
- package/sidecar/dist/src/validators.js +336 -0
- package/sidecar/package.json +6 -0
- package/templates/carrick.json +7 -0
- package/templates/carrick.yml +45 -0
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the sidecar message protocol
|
|
3
|
+
* These types define the JSON messages exchanged between Rust and the Node.js sidecar
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The kind of type inference to perform
|
|
7
|
+
*/
|
|
8
|
+
export type InferKind = 'function_return' | 'expression' | 'call_result' | 'variable' | 'response_body' | 'request_body' | 'signature_return' | 'function_param' | 'receiver_type';
|
|
9
|
+
/**
|
|
10
|
+
* A rule for unwrapping machinery/wrapper types to extract payload types.
|
|
11
|
+
*
|
|
12
|
+
* The unwrapping logic follows these priorities:
|
|
13
|
+
* 1. Exact wrapperSymbols match extracts (gated on originModuleGlobs when present)
|
|
14
|
+
* 2. machineryIndicators only trigger unwrap if originModuleGlobs also match
|
|
15
|
+
* 3. Payload extraction: prefer generic args, then property paths
|
|
16
|
+
* 4. A rule that matches but extracts nothing never blocks later rules; an
|
|
17
|
+
* origin-verified match with no recoverable payload collapses to `unknown`
|
|
18
|
+
* only after every rule has run
|
|
19
|
+
*/
|
|
20
|
+
export interface ExtractionRule {
|
|
21
|
+
/**
|
|
22
|
+
* Exact wrapper type/symbol names to unwrap. When originModuleGlobs is
|
|
23
|
+
* also set, the symbol must originate from a matching module.
|
|
24
|
+
* Examples: ["Response", "AxiosResponse", "Promise", "Observable"]
|
|
25
|
+
*/
|
|
26
|
+
wrapperSymbols?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Method/property indicators that suggest a wrapper type.
|
|
29
|
+
* Examples: ["status", "json", "send", "header", "cookie"]
|
|
30
|
+
* Note: Only used in conjunction with originModuleGlobs to avoid false positives.
|
|
31
|
+
*/
|
|
32
|
+
machineryIndicators?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Glob patterns for module origins. Only unwrap if the symbol's declarations
|
|
35
|
+
* come from modules matching these patterns.
|
|
36
|
+
* Examples: ["express", "express/*", "@types/express/*", "axios", "axios/*"]
|
|
37
|
+
*/
|
|
38
|
+
originModuleGlobs?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Index of the generic type argument containing the payload.
|
|
41
|
+
* Defaults to 0 (first type arg).
|
|
42
|
+
* Examples:
|
|
43
|
+
* - Response<T> → index 0
|
|
44
|
+
* - Map<K, V> → index 1 for values
|
|
45
|
+
*/
|
|
46
|
+
payloadGenericIndex?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Property path to extract payload when generics aren't available.
|
|
49
|
+
* Examples: ["data"] for AxiosResponse.data, ["body"] for Response.body
|
|
50
|
+
*/
|
|
51
|
+
payloadPropertyPath?: string[];
|
|
52
|
+
/**
|
|
53
|
+
* Whether to recursively unwrap nested wrappers.
|
|
54
|
+
* Example: Promise<Response<T>> → unwrap both layers to get T
|
|
55
|
+
*/
|
|
56
|
+
unwrapRecursively?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Maximum unwrap depth when unwrapRecursively is true.
|
|
59
|
+
* Defaults to 4 to prevent infinite loops.
|
|
60
|
+
*/
|
|
61
|
+
maxDepth?: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Configuration for extracting payload types from machinery wrappers.
|
|
65
|
+
* Provided by the main Carrick process based on agent analysis.
|
|
66
|
+
*/
|
|
67
|
+
export interface ExtractionConfig {
|
|
68
|
+
rules: ExtractionRule[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A map of package names to exact pinned versions.
|
|
72
|
+
* Used to ensure deterministic typechecking across CI runs.
|
|
73
|
+
*/
|
|
74
|
+
export interface PinnedDependencySnapshot {
|
|
75
|
+
[packageName: string]: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A normalized/closed tsconfig object where all `extends` chains have been resolved.
|
|
79
|
+
* Contains only the compiler options needed for surface checking.
|
|
80
|
+
*/
|
|
81
|
+
export interface TsconfigSnapshot {
|
|
82
|
+
compilerOptions: {
|
|
83
|
+
module?: string;
|
|
84
|
+
moduleResolution?: string;
|
|
85
|
+
target?: string;
|
|
86
|
+
lib?: string[];
|
|
87
|
+
types?: string[];
|
|
88
|
+
typeRoots?: string[];
|
|
89
|
+
jsx?: string;
|
|
90
|
+
strict?: boolean;
|
|
91
|
+
esModuleInterop?: boolean;
|
|
92
|
+
skipLibCheck?: boolean;
|
|
93
|
+
declaration?: boolean;
|
|
94
|
+
declarationMap?: boolean;
|
|
95
|
+
paths?: Record<string, string[]>;
|
|
96
|
+
baseUrl?: string;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Metadata for a single repository in the synthetic monorepo.
|
|
102
|
+
*/
|
|
103
|
+
export interface RepoMetadata {
|
|
104
|
+
/** Unique name for this repo (used in @carrick/{repoName}/...) */
|
|
105
|
+
repoName: string;
|
|
106
|
+
/** Pinned dependency versions for this repo */
|
|
107
|
+
dependencies: PinnedDependencySnapshot;
|
|
108
|
+
/** Closed tsconfig snapshot for this repo */
|
|
109
|
+
tsconfig: TsconfigSnapshot;
|
|
110
|
+
/** Extraction config for unwrapping machinery types */
|
|
111
|
+
extractionConfig?: ExtractionConfig;
|
|
112
|
+
/** The emitted surface .d.ts content (after Task 2) */
|
|
113
|
+
surfaceContent?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Base fields present in all requests
|
|
117
|
+
*/
|
|
118
|
+
interface BaseRequest {
|
|
119
|
+
request_id: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Initialize the sidecar with a repository root
|
|
123
|
+
*/
|
|
124
|
+
export interface InitRequest extends BaseRequest {
|
|
125
|
+
action: 'init';
|
|
126
|
+
repo_root: string;
|
|
127
|
+
tsconfig_path?: string;
|
|
128
|
+
/** Optional tsconfig snapshot (closed/merged) - preferred over tsconfig_path */
|
|
129
|
+
tsconfig_snapshot?: TsconfigSnapshot;
|
|
130
|
+
/** Optional pinned dependencies for this repo */
|
|
131
|
+
pinned_dependencies?: PinnedDependencySnapshot;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Request to bundle explicit types from source files
|
|
135
|
+
* @deprecated Use emit_surface instead for the new architecture
|
|
136
|
+
*/
|
|
137
|
+
export interface BundleRequest extends BaseRequest {
|
|
138
|
+
action: 'bundle';
|
|
139
|
+
symbols: SymbolRequest[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Request to emit a surface .d.ts file with rewritten module specifiers
|
|
143
|
+
*/
|
|
144
|
+
export interface EmitSurfaceRequest extends BaseRequest {
|
|
145
|
+
action: 'emit_surface';
|
|
146
|
+
/** The repo name for specifier rewriting (@carrick/{repoName}/...) */
|
|
147
|
+
repo_name: string;
|
|
148
|
+
/** Payload types to include in the surface */
|
|
149
|
+
payloads: PayloadDefinition[];
|
|
150
|
+
/** Output path for the surface .d.ts file */
|
|
151
|
+
output_path: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Definition of a payload type to emit
|
|
155
|
+
*/
|
|
156
|
+
export interface PayloadDefinition {
|
|
157
|
+
/** Alias/name for this payload in the surface */
|
|
158
|
+
alias: string;
|
|
159
|
+
/** The type string (already unwrapped from machinery) */
|
|
160
|
+
type_string: string;
|
|
161
|
+
/** Optional source information */
|
|
162
|
+
source_file?: string;
|
|
163
|
+
source_location?: SourceLocation;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Request to run the v2 "tsc as serializer" capture for one service.
|
|
167
|
+
* Produces a types-only stub package (compiler-emitted declaration tree +
|
|
168
|
+
* pinned deps) instead of a flattened structural string. The full contract
|
|
169
|
+
* lives in ./capture/api.ts -- the seam between the sidecar and the v2
|
|
170
|
+
* capture bundle.
|
|
171
|
+
*/
|
|
172
|
+
export interface CaptureV2Request extends BaseRequest {
|
|
173
|
+
action: 'capture_v2';
|
|
174
|
+
/** Absolute path to the producer repo root */
|
|
175
|
+
repo_root: string;
|
|
176
|
+
/** Service name used for the @carrick/<service> stub package */
|
|
177
|
+
service_name: string;
|
|
178
|
+
/** Anchors to alias in the surface entry (symbol / handler_return / infer) */
|
|
179
|
+
anchors: import('./capture/api.js').CaptureAnchorRequest[];
|
|
180
|
+
/** Directory to write the stub package into */
|
|
181
|
+
out_dir: string;
|
|
182
|
+
/** Optional explicit tsconfig path (defaults to <repo_root>/tsconfig.json) */
|
|
183
|
+
tsconfig_path?: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Response for the capture_v2 action
|
|
187
|
+
*/
|
|
188
|
+
export interface CaptureV2Response extends BaseResponse {
|
|
189
|
+
result?: import('./capture/api.js').CaptureStubResult;
|
|
190
|
+
errors?: string[];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Request to run the v2 "tsc as judge" check for a set of matched pairs.
|
|
194
|
+
* Assembles the given capture stubs into a scratch synthetic monorepo and
|
|
195
|
+
* returns one verdict per pair. The full contract lives in ./capture/api.ts --
|
|
196
|
+
* the seam between the sidecar and the v2 capture/check bundle.
|
|
197
|
+
*/
|
|
198
|
+
export interface CheckV2Request extends BaseRequest {
|
|
199
|
+
action: 'check_v2';
|
|
200
|
+
/** Capture stub packages to assemble (one per participating service). */
|
|
201
|
+
stubs: import('./capture/api.js').CheckStubInput[];
|
|
202
|
+
/** Matched pairs to verify. */
|
|
203
|
+
pairs: import('./capture/api.js').CheckPairSpec[];
|
|
204
|
+
/** Parent dir for the scratch workspace (default: OS temp dir). */
|
|
205
|
+
workspace_root?: string;
|
|
206
|
+
/** Keep the assembled workspace on disk (default false; tests set true). */
|
|
207
|
+
keep_workspace?: boolean;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Response for the check_v2 action. Emitted as the terminal frame; the async
|
|
211
|
+
* install protocol emits `status: 'progress'` keepalive frames before it.
|
|
212
|
+
*/
|
|
213
|
+
export interface CheckV2Response extends BaseResponse {
|
|
214
|
+
result?: import('./capture/api.js').CheckResult;
|
|
215
|
+
errors?: string[];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Request to infer implicit types at specific locations
|
|
219
|
+
*/
|
|
220
|
+
export interface InferRequest extends BaseRequest {
|
|
221
|
+
action: 'infer';
|
|
222
|
+
requests: InferRequestItem[];
|
|
223
|
+
/** Agent-generated extraction config for machinery unwrapping */
|
|
224
|
+
extraction_config?: ExtractionConfig;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Request to build the synthetic monorepo workspace
|
|
228
|
+
*/
|
|
229
|
+
export interface BuildWorkspaceRequest extends BaseRequest {
|
|
230
|
+
action: 'build_workspace';
|
|
231
|
+
repos: RepoMetadata[];
|
|
232
|
+
/** Root directory for the workspace (defaults to .carrick/workspace) */
|
|
233
|
+
workspace_root?: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Request to run type compatibility checks
|
|
237
|
+
*/
|
|
238
|
+
export interface CheckCompatibilityRequest extends BaseRequest {
|
|
239
|
+
action: 'check_compatibility';
|
|
240
|
+
/** Path to the workspace root */
|
|
241
|
+
workspace_root: string;
|
|
242
|
+
/** Pairs of types to check for compatibility */
|
|
243
|
+
checks: CompatibilityCheck[];
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* A single compatibility check between two types
|
|
247
|
+
*/
|
|
248
|
+
export interface CompatibilityCheck {
|
|
249
|
+
/** Source repo name */
|
|
250
|
+
source_repo: string;
|
|
251
|
+
/** Source payload alias */
|
|
252
|
+
source_alias: string;
|
|
253
|
+
/** Target repo name */
|
|
254
|
+
target_repo: string;
|
|
255
|
+
/** Target payload alias */
|
|
256
|
+
target_alias: string;
|
|
257
|
+
/** Direction: 'source_extends_target' or 'target_extends_source' or 'bidirectional' */
|
|
258
|
+
direction: 'source_extends_target' | 'target_extends_source' | 'bidirectional';
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Health check request
|
|
262
|
+
*/
|
|
263
|
+
export interface HealthRequest extends BaseRequest {
|
|
264
|
+
action: 'health';
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Shutdown the sidecar process
|
|
268
|
+
*/
|
|
269
|
+
export interface ShutdownRequest extends BaseRequest {
|
|
270
|
+
action: 'shutdown';
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Request to resolve type definitions from a v2 capture stub package.
|
|
274
|
+
* Returns both the original declaration and the compiler-expanded form for
|
|
275
|
+
* each surface alias (design doc: `resolve_per_endpoint_definitions` is
|
|
276
|
+
* re-pointed at the surface tree, a strictly richer source than the old
|
|
277
|
+
* flattened bundle string).
|
|
278
|
+
*/
|
|
279
|
+
export interface ResolveDefinitionsRequest extends BaseRequest {
|
|
280
|
+
action: 'resolve_definitions';
|
|
281
|
+
/** Absolute path to the capture stub dir (package.json + types/ tree). */
|
|
282
|
+
stub_dir: string;
|
|
283
|
+
/** Surface type alias names to resolve */
|
|
284
|
+
aliases: string[];
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Union type for all possible sidecar requests
|
|
288
|
+
*/
|
|
289
|
+
export type SidecarRequest = InitRequest | BundleRequest | EmitSurfaceRequest | CaptureV2Request | CheckV2Request | InferRequest | BuildWorkspaceRequest | CheckCompatibilityRequest | ResolveDefinitionsRequest | HealthRequest | ShutdownRequest;
|
|
290
|
+
/**
|
|
291
|
+
* Request for a specific symbol to be bundled
|
|
292
|
+
*/
|
|
293
|
+
export interface SymbolRequest {
|
|
294
|
+
/** The name of the symbol (type, interface, class, etc.) */
|
|
295
|
+
symbol_name: string;
|
|
296
|
+
/** The source file path (relative to repo root) */
|
|
297
|
+
source_file: string;
|
|
298
|
+
/** Optional alias for the exported type */
|
|
299
|
+
alias?: string;
|
|
300
|
+
/**
|
|
301
|
+
* Wrap the bundled symbol in this many TS array levels (#248). A GraphQL SDL
|
|
302
|
+
* producer field `[Order!]!` backed by `interface Order` bundles `Order` with
|
|
303
|
+
* `array_depth: 1`, so the sidecar emits `Order[]`: the element type carries
|
|
304
|
+
* the shape, the SDL list marker carries the depth. Omitted/`0` bundles the
|
|
305
|
+
* symbol as-is (the HTTP/socket/consumer default).
|
|
306
|
+
*/
|
|
307
|
+
array_depth?: number;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Request for type inference at a specific location
|
|
311
|
+
*/
|
|
312
|
+
export interface InferRequestItem {
|
|
313
|
+
/** Path to the file (relative to repo root) */
|
|
314
|
+
file_path: string;
|
|
315
|
+
/** Line number (1-based) for context and alias generation */
|
|
316
|
+
line_number: number;
|
|
317
|
+
/** Start byte offset of the target expression (from SWC spans) */
|
|
318
|
+
span_start?: number;
|
|
319
|
+
/** End byte offset of the target expression (from SWC spans) */
|
|
320
|
+
span_end?: number;
|
|
321
|
+
/** Verbatim expression text to locate in source (from Gemini) */
|
|
322
|
+
expression_text?: string;
|
|
323
|
+
/** Line number where the expression starts (from Gemini) */
|
|
324
|
+
expression_line?: number;
|
|
325
|
+
/** The kind of inference to perform */
|
|
326
|
+
infer_kind: InferKind;
|
|
327
|
+
/** Optional alias for the inferred type */
|
|
328
|
+
alias?: string;
|
|
329
|
+
/** Target parameter name for `function_param` inference. */
|
|
330
|
+
param_name?: string;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Response status
|
|
334
|
+
*/
|
|
335
|
+
export type ResponseStatus = 'success' | 'error' | 'ready' | 'not_ready';
|
|
336
|
+
/**
|
|
337
|
+
* Base response fields
|
|
338
|
+
*/
|
|
339
|
+
interface BaseResponse {
|
|
340
|
+
request_id: string;
|
|
341
|
+
status: ResponseStatus;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Response for init action
|
|
345
|
+
*/
|
|
346
|
+
export interface InitResponse extends BaseResponse {
|
|
347
|
+
status: 'ready' | 'error';
|
|
348
|
+
init_time_ms?: number;
|
|
349
|
+
errors?: string[];
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Response for bundle action
|
|
353
|
+
* @deprecated Use EmitSurfaceResponse instead
|
|
354
|
+
*/
|
|
355
|
+
export interface BundleResponse extends BaseResponse {
|
|
356
|
+
/** The bundled .d.ts content */
|
|
357
|
+
dts_content?: string;
|
|
358
|
+
/** Manifest mapping aliases to their type strings */
|
|
359
|
+
manifest?: ManifestEntry[];
|
|
360
|
+
/** Individual symbol failures */
|
|
361
|
+
symbol_failures?: SymbolFailure[];
|
|
362
|
+
/** General errors */
|
|
363
|
+
errors?: string[];
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Response for emit_surface action
|
|
367
|
+
*/
|
|
368
|
+
export interface EmitSurfaceResponse extends BaseResponse {
|
|
369
|
+
/** Path to the emitted surface file */
|
|
370
|
+
output_path?: string;
|
|
371
|
+
/** The emitted .d.ts content */
|
|
372
|
+
surface_content?: string;
|
|
373
|
+
/** Manifest of emitted payloads */
|
|
374
|
+
manifest?: SurfaceManifestEntry[];
|
|
375
|
+
/** Errors during emission */
|
|
376
|
+
errors?: string[];
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Entry in the surface manifest
|
|
380
|
+
*/
|
|
381
|
+
export interface SurfaceManifestEntry {
|
|
382
|
+
alias: string;
|
|
383
|
+
type_string: string;
|
|
384
|
+
rewritten_imports: string[];
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Response for infer action
|
|
388
|
+
*/
|
|
389
|
+
export interface InferResponse extends BaseResponse {
|
|
390
|
+
/** Successfully inferred types */
|
|
391
|
+
inferred_types?: InferredType[];
|
|
392
|
+
/** General errors */
|
|
393
|
+
errors?: string[];
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Response for build_workspace action
|
|
397
|
+
*/
|
|
398
|
+
export interface BuildWorkspaceResponse extends BaseResponse {
|
|
399
|
+
/** Path to the created workspace */
|
|
400
|
+
workspace_path?: string;
|
|
401
|
+
/** Paths to generated stub packages */
|
|
402
|
+
stub_packages?: string[];
|
|
403
|
+
/** Path to the checker package */
|
|
404
|
+
checker_path?: string;
|
|
405
|
+
/** Errors during workspace creation */
|
|
406
|
+
errors?: string[];
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Response for check_compatibility action
|
|
410
|
+
*/
|
|
411
|
+
export interface CheckCompatibilityResponse extends BaseResponse {
|
|
412
|
+
/** Results of each compatibility check */
|
|
413
|
+
results?: CompatibilityResult[];
|
|
414
|
+
/** TypeScript compiler diagnostics */
|
|
415
|
+
diagnostics?: string[];
|
|
416
|
+
/** Errors during checking */
|
|
417
|
+
errors?: string[];
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Result of a single compatibility check
|
|
421
|
+
*/
|
|
422
|
+
export interface CompatibilityResult {
|
|
423
|
+
source_repo: string;
|
|
424
|
+
source_alias: string;
|
|
425
|
+
target_repo: string;
|
|
426
|
+
target_alias: string;
|
|
427
|
+
compatible: boolean;
|
|
428
|
+
/** Diagnostic message if not compatible */
|
|
429
|
+
diagnostic?: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Response for resolve_definitions action
|
|
433
|
+
*/
|
|
434
|
+
export interface ResolveDefinitionsResponse extends BaseResponse {
|
|
435
|
+
/** Successfully resolved definitions */
|
|
436
|
+
definitions?: ResolvedDefinitionResult[];
|
|
437
|
+
/** Errors during resolution */
|
|
438
|
+
errors?: string[];
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* A single resolved type definition
|
|
442
|
+
*/
|
|
443
|
+
export interface ResolvedDefinitionResult {
|
|
444
|
+
type_alias: string;
|
|
445
|
+
/** Original declaration text as written */
|
|
446
|
+
definition: string;
|
|
447
|
+
/** Compiler-expanded form with all types fully inlined */
|
|
448
|
+
expanded: string;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Response for health action
|
|
452
|
+
*/
|
|
453
|
+
export interface HealthResponse extends BaseResponse {
|
|
454
|
+
status: 'ready' | 'not_ready';
|
|
455
|
+
init_time_ms?: number;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Response for shutdown action
|
|
459
|
+
*/
|
|
460
|
+
export interface ShutdownResponse extends BaseResponse {
|
|
461
|
+
status: 'success';
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Error response
|
|
465
|
+
*/
|
|
466
|
+
export interface ErrorResponse extends BaseResponse {
|
|
467
|
+
status: 'error';
|
|
468
|
+
errors: string[];
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Union type for all possible sidecar responses
|
|
472
|
+
*/
|
|
473
|
+
export type SidecarResponse = InitResponse | BundleResponse | EmitSurfaceResponse | CaptureV2Response | CheckV2Response | InferResponse | BuildWorkspaceResponse | CheckCompatibilityResponse | ResolveDefinitionsResponse | HealthResponse | ShutdownResponse | ErrorResponse;
|
|
474
|
+
/**
|
|
475
|
+
* An entry in the type manifest
|
|
476
|
+
*/
|
|
477
|
+
export interface ManifestEntry {
|
|
478
|
+
/** The alias or original name of the type */
|
|
479
|
+
alias: string;
|
|
480
|
+
/** The original symbol name */
|
|
481
|
+
original_name: string;
|
|
482
|
+
/** The source file where the type was found */
|
|
483
|
+
source_file: string;
|
|
484
|
+
/** The full type definition string */
|
|
485
|
+
type_string: string;
|
|
486
|
+
/** Whether this was an explicit annotation or inferred */
|
|
487
|
+
is_explicit: boolean;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* An inferred type result
|
|
491
|
+
*/
|
|
492
|
+
export interface InferredType {
|
|
493
|
+
/** The alias for this type (generated if not provided) */
|
|
494
|
+
alias: string;
|
|
495
|
+
/** The full TypeScript type string */
|
|
496
|
+
type_string: string;
|
|
497
|
+
/** Whether the type was explicitly annotated in source */
|
|
498
|
+
is_explicit: boolean;
|
|
499
|
+
/** Source location information */
|
|
500
|
+
source_location: SourceLocation;
|
|
501
|
+
/** The kind of inference that was performed */
|
|
502
|
+
infer_kind: InferKind;
|
|
503
|
+
/** The unwrapped/extracted payload type (if different from type_string) */
|
|
504
|
+
payload_type_string?: string;
|
|
505
|
+
/**
|
|
506
|
+
* carrick#695: for `receiver_type`, the package that DECLARES the resolved
|
|
507
|
+
* type, when its declaration file sits under a `node_modules` tree. Absent
|
|
508
|
+
* for a type the workspace itself declares, and absent when the type did not
|
|
509
|
+
* resolve — the caller must not read absence as "local".
|
|
510
|
+
*/
|
|
511
|
+
declaring_package?: string;
|
|
512
|
+
/**
|
|
513
|
+
* carrick#695: for `receiver_type`, the awaited return type of the member
|
|
514
|
+
* invoked on that receiver. A fact returned alongside the receiver, never a
|
|
515
|
+
* classification on its own.
|
|
516
|
+
*/
|
|
517
|
+
member_return_type?: string;
|
|
518
|
+
/**
|
|
519
|
+
* The deterministic source symbol of the resolved type (`Payment`), derived
|
|
520
|
+
* from the ts-morph `Type`'s `getSymbol() || getAliasSymbol()` name with
|
|
521
|
+
* TS/lib globals filtered out. Lets the manifest anchor (`primary_type_symbol`)
|
|
522
|
+
* be filled without depending on the LLM. `undefined` when the resolved type
|
|
523
|
+
* has no single user-defined symbol to anchor on. For array types the anchor
|
|
524
|
+
* is the ELEMENT's symbol (`TimelineEvent` for `TimelineEvent[]`) — the array
|
|
525
|
+
* type's own symbol is the builtin `Array`, never an anchor.
|
|
526
|
+
*/
|
|
527
|
+
primary_type_symbol?: string;
|
|
528
|
+
/**
|
|
529
|
+
* Array levels the resolved type wraps around the anchor symbol (#306):
|
|
530
|
+
* `TimelineEvent[]` reports `primary_type_symbol: 'TimelineEvent'` +
|
|
531
|
+
* `array_depth: 1`. Lets `resolve_all_types` copy the use-site's array-ness
|
|
532
|
+
* onto an explicit `SymbolRequest` for the same alias, which would otherwise
|
|
533
|
+
* bundle the bare element and erase the array (array-vs-scalar scored
|
|
534
|
+
* compatible, #306). Omitted when 0 or when there is no anchor symbol.
|
|
535
|
+
*/
|
|
536
|
+
array_depth?: number;
|
|
537
|
+
/**
|
|
538
|
+
* Declaration file of `primary_type_symbol` (absolute path), when the
|
|
539
|
+
* anchor symbol has a resolvable source declaration. Lets the scanner's
|
|
540
|
+
* pub/sub two-anchor arbitration (carrick#413) re-aim a demoted explicit
|
|
541
|
+
* `SymbolRequest` at the tsc-witnessed payload type: the bundler requires
|
|
542
|
+
* the symbol to be DECLARED in the request's `source_file`, and the
|
|
543
|
+
* inference is the only party that knows where that is. Reported only by
|
|
544
|
+
* the pub/sub infer kinds (`function_param`, `expression`); other kinds
|
|
545
|
+
* omit it.
|
|
546
|
+
*/
|
|
547
|
+
primary_type_symbol_source?: string;
|
|
548
|
+
/**
|
|
549
|
+
* Why this inference carries `any`/`unknown` (carrick#376), recorded at the
|
|
550
|
+
* decision point that produced it rather than reconstructed downstream.
|
|
551
|
+
*
|
|
552
|
+
* The inferrer is the only layer that knows the difference between "the
|
|
553
|
+
* compiler resolved this to `any`" and "the recovery declined to read an
|
|
554
|
+
* unresolvable callee's argument because nothing said it was a serialiser".
|
|
555
|
+
* That difference is the whole answer to "why is this endpoint `any`", so it
|
|
556
|
+
* is recorded here and joined onto the manifest entry beside the capture
|
|
557
|
+
* surface's own findings.
|
|
558
|
+
*
|
|
559
|
+
* Sorted by `path`; absent (not empty) when the type carries no top type.
|
|
560
|
+
*/
|
|
561
|
+
any_provenance?: TypeProvenance[];
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Why a type carries `any`/`unknown` at a position, and where.
|
|
565
|
+
*
|
|
566
|
+
* Declared in the capture bundle (`./capture/api.ts`) because the capture
|
|
567
|
+
* self-check is one of the two producers; re-exported here so the rest of the
|
|
568
|
+
* sidecar reads it through the single sanctioned door rather than reaching
|
|
569
|
+
* across the bundle seam.
|
|
570
|
+
*/
|
|
571
|
+
export type TypeProvenance = import('./capture/api.js').TypeProvenance;
|
|
572
|
+
export type TypeProvenanceReason = import('./capture/api.js').TypeProvenanceReason;
|
|
573
|
+
/**
|
|
574
|
+
* Source location information for a type
|
|
575
|
+
*/
|
|
576
|
+
export interface SourceLocation {
|
|
577
|
+
/** File path relative to repo root */
|
|
578
|
+
file_path: string;
|
|
579
|
+
/** Start line (1-based) */
|
|
580
|
+
start_line: number;
|
|
581
|
+
/** End line (1-based) */
|
|
582
|
+
end_line: number;
|
|
583
|
+
/** Start column (0-based) */
|
|
584
|
+
start_column?: number;
|
|
585
|
+
/** End column (0-based) */
|
|
586
|
+
end_column?: number;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Information about a symbol that failed to resolve
|
|
590
|
+
*/
|
|
591
|
+
export interface SymbolFailure {
|
|
592
|
+
/** The symbol that failed */
|
|
593
|
+
symbol_name: string;
|
|
594
|
+
/** The source file where it was supposed to be */
|
|
595
|
+
source_file: string;
|
|
596
|
+
/** Reason for the failure */
|
|
597
|
+
reason: string;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Internal result from the bundler
|
|
601
|
+
* @deprecated Use SurfaceEmitResult instead
|
|
602
|
+
*/
|
|
603
|
+
export interface BundleResult {
|
|
604
|
+
/** Whether bundling was successful */
|
|
605
|
+
success: boolean;
|
|
606
|
+
/** The bundled .d.ts content */
|
|
607
|
+
dts_content?: string;
|
|
608
|
+
/** Manifest entries for successfully bundled types */
|
|
609
|
+
manifest?: ManifestEntry[];
|
|
610
|
+
/** Failures for individual symbols */
|
|
611
|
+
symbol_failures?: SymbolFailure[];
|
|
612
|
+
/** General error messages */
|
|
613
|
+
errors?: string[];
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Internal result from surface emission
|
|
617
|
+
*/
|
|
618
|
+
export interface SurfaceEmitResult {
|
|
619
|
+
/** Whether emission was successful */
|
|
620
|
+
success: boolean;
|
|
621
|
+
/** The emitted .d.ts content */
|
|
622
|
+
surface_content?: string;
|
|
623
|
+
/** Output path where content was written */
|
|
624
|
+
output_path?: string;
|
|
625
|
+
/** Manifest of emitted payloads */
|
|
626
|
+
manifest?: SurfaceManifestEntry[];
|
|
627
|
+
/** General error messages */
|
|
628
|
+
errors?: string[];
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Internal result from the type inferrer
|
|
632
|
+
*/
|
|
633
|
+
export interface InferResult {
|
|
634
|
+
/** Whether inference was successful */
|
|
635
|
+
success: boolean;
|
|
636
|
+
/** Successfully inferred types */
|
|
637
|
+
inferred_types?: InferredType[];
|
|
638
|
+
/** General error messages */
|
|
639
|
+
errors?: string[];
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Result from building the synthetic workspace
|
|
643
|
+
*/
|
|
644
|
+
export interface WorkspaceBuildResult {
|
|
645
|
+
/** Whether build was successful */
|
|
646
|
+
success: boolean;
|
|
647
|
+
/** Path to the workspace root */
|
|
648
|
+
workspace_path?: string;
|
|
649
|
+
/** Paths to stub packages */
|
|
650
|
+
stub_packages?: string[];
|
|
651
|
+
/** Path to the checker package */
|
|
652
|
+
checker_path?: string;
|
|
653
|
+
/** Error messages */
|
|
654
|
+
errors?: string[];
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Result from running compatibility checks
|
|
658
|
+
*/
|
|
659
|
+
export interface CompatibilityCheckResult {
|
|
660
|
+
/** Whether checks ran successfully (not whether types are compatible) */
|
|
661
|
+
success: boolean;
|
|
662
|
+
/** Individual check results */
|
|
663
|
+
results?: CompatibilityResult[];
|
|
664
|
+
/** TypeScript diagnostics */
|
|
665
|
+
diagnostics?: string[];
|
|
666
|
+
/** Error messages */
|
|
667
|
+
errors?: string[];
|
|
668
|
+
}
|
|
669
|
+
export {};
|