carrick 0.3.102 → 0.3.104

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 (45) hide show
  1. package/package.json +6 -6
  2. package/plugin/.claude-plugin/plugin.json +1 -1
  3. package/sidecar/dist/src/bundler.d.ts +3 -92
  4. package/sidecar/dist/src/bundler.js +5 -265
  5. package/sidecar/dist/src/capture/anchors.js +113 -8
  6. package/sidecar/dist/src/capture/api.d.ts +6 -0
  7. package/sidecar/dist/src/capture/check-classify.js +27 -0
  8. package/sidecar/dist/src/capture/check-fields.js +19 -5
  9. package/sidecar/dist/src/capture/check-probe.d.ts +6 -1
  10. package/sidecar/dist/src/capture/check-probe.js +45 -2
  11. package/sidecar/dist/src/capture/check-workspace.d.ts +3 -0
  12. package/sidecar/dist/src/capture/check-workspace.js +13 -16
  13. package/sidecar/dist/src/capture/check.js +5 -5
  14. package/sidecar/dist/src/capture/deep-walk.js +45 -12
  15. package/sidecar/dist/src/capture/deno-project.d.ts +2 -1
  16. package/sidecar/dist/src/capture/deno-project.js +22 -18
  17. package/sidecar/dist/src/capture/guarded-fs.d.ts +76 -0
  18. package/sidecar/dist/src/capture/guarded-fs.js +182 -0
  19. package/sidecar/dist/src/capture/index.d.ts +1 -0
  20. package/sidecar/dist/src/capture/index.js +65 -27
  21. package/sidecar/dist/src/capture/outside-root.d.ts +41 -0
  22. package/sidecar/dist/src/capture/outside-root.js +101 -0
  23. package/sidecar/dist/src/capture/paths-rewrite.d.ts +8 -0
  24. package/sidecar/dist/src/capture/paths-rewrite.js +9 -7
  25. package/sidecar/dist/src/capture/repair-dangling.d.ts +11 -1
  26. package/sidecar/dist/src/capture/repair-dangling.js +15 -4
  27. package/sidecar/dist/src/capture/self-check.d.ts +3 -0
  28. package/sidecar/dist/src/capture/self-check.js +3 -3
  29. package/sidecar/dist/src/capture/service-config.d.ts +19 -0
  30. package/sidecar/dist/src/capture/service-config.js +57 -0
  31. package/sidecar/dist/src/index.d.ts +1 -1
  32. package/sidecar/dist/src/index.js +4 -115
  33. package/sidecar/dist/src/origin.d.ts +49 -8
  34. package/sidecar/dist/src/origin.js +81 -8
  35. package/sidecar/dist/src/project-loader.d.ts +10 -2
  36. package/sidecar/dist/src/project-loader.js +22 -21
  37. package/sidecar/dist/src/type-inferrer.d.ts +72 -0
  38. package/sidecar/dist/src/type-inferrer.js +248 -8
  39. package/sidecar/dist/src/type-structural-expander.d.ts +5 -1
  40. package/sidecar/dist/src/type-structural-expander.js +1 -1
  41. package/sidecar/dist/src/types.d.ts +39 -178
  42. package/sidecar/dist/src/validators.d.ts +70 -914
  43. package/sidecar/dist/src/validators.js +2 -55
  44. package/sidecar/dist/src/monorepo-builder.d.ts +0 -129
  45. package/sidecar/dist/src/monorepo-builder.js +0 -584
@@ -97,21 +97,6 @@ export interface TsconfigSnapshot {
97
97
  [key: string]: unknown;
98
98
  };
99
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
100
  /**
116
101
  * Base fields present in all requests
117
102
  */
@@ -125,6 +110,12 @@ export interface InitRequest extends BaseRequest {
125
110
  action: 'init';
126
111
  repo_root: string;
127
112
  tsconfig_path?: string;
113
+ /**
114
+ * The scanned repo's root: with no tsconfig named or in `repo_root`, the
115
+ * nearest `tsconfig.json` above `repo_root` up to this root types the
116
+ * service (carrick#1776). Without it only `repo_root` is searched.
117
+ */
118
+ scan_root?: string;
128
119
  /** Optional tsconfig snapshot (closed/merged) - preferred over tsconfig_path */
129
120
  tsconfig_snapshot?: TsconfigSnapshot;
130
121
  /** Optional pinned dependencies for this repo */
@@ -132,36 +123,11 @@ export interface InitRequest extends BaseRequest {
132
123
  }
133
124
  /**
134
125
  * Request to bundle explicit types from source files
135
- * @deprecated Use emit_surface instead for the new architecture
136
126
  */
137
127
  export interface BundleRequest extends BaseRequest {
138
128
  action: 'bundle';
139
129
  symbols: SymbolRequest[];
140
130
  }
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
131
  /**
166
132
  * Request to run the v2 "tsc as serializer" capture for one service.
167
133
  * Produces a types-only stub package (compiler-emitted declaration tree +
@@ -181,6 +147,8 @@ export interface CaptureV2Request extends BaseRequest {
181
147
  out_dir: string;
182
148
  /** Optional explicit tsconfig path (defaults to <repo_root>/tsconfig.json) */
183
149
  tsconfig_path?: string;
150
+ /** The scanned repo's root, as on `init` (carrick#1776). */
151
+ scan_root?: string;
184
152
  }
185
153
  /**
186
154
  * Response for the capture_v2 action
@@ -223,40 +191,6 @@ export interface InferRequest extends BaseRequest {
223
191
  /** Agent-generated extraction config for machinery unwrapping */
224
192
  extraction_config?: ExtractionConfig;
225
193
  }
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
194
  /**
261
195
  * Health check request
262
196
  */
@@ -524,7 +458,7 @@ export interface ListLibrarySurfaceRequest extends BaseRequest {
524
458
  /**
525
459
  * Union type for all possible sidecar requests
526
460
  */
527
- export type SidecarRequest = RetypeCheckRequest | VerifyClientSemanticsRequest | VerifyLibraryClaimsRequest | ListLibrarySurfaceRequest | InitRequest | BundleRequest | EmitSurfaceRequest | CaptureV2Request | CheckV2Request | InferRequest | BuildWorkspaceRequest | CheckCompatibilityRequest | ResolveDefinitionsRequest | HealthRequest | ShutdownRequest;
461
+ export type SidecarRequest = RetypeCheckRequest | VerifyClientSemanticsRequest | VerifyLibraryClaimsRequest | ListLibrarySurfaceRequest | InitRequest | BundleRequest | CaptureV2Request | CheckV2Request | InferRequest | ResolveDefinitionsRequest | HealthRequest | ShutdownRequest;
528
462
  /**
529
463
  * Request for a specific symbol to be bundled
530
464
  */
@@ -588,7 +522,6 @@ export interface InitResponse extends BaseResponse {
588
522
  }
589
523
  /**
590
524
  * Response for bundle action
591
- * @deprecated Use EmitSurfaceResponse instead
592
525
  */
593
526
  export interface BundleResponse extends BaseResponse {
594
527
  /** The bundled .d.ts content */
@@ -600,27 +533,6 @@ export interface BundleResponse extends BaseResponse {
600
533
  /** General errors */
601
534
  errors?: string[];
602
535
  }
603
- /**
604
- * Response for emit_surface action
605
- */
606
- export interface EmitSurfaceResponse extends BaseResponse {
607
- /** Path to the emitted surface file */
608
- output_path?: string;
609
- /** The emitted .d.ts content */
610
- surface_content?: string;
611
- /** Manifest of emitted payloads */
612
- manifest?: SurfaceManifestEntry[];
613
- /** Errors during emission */
614
- errors?: string[];
615
- }
616
- /**
617
- * Entry in the surface manifest
618
- */
619
- export interface SurfaceManifestEntry {
620
- alias: string;
621
- type_string: string;
622
- rewritten_imports: string[];
623
- }
624
536
  /**
625
537
  * Response for infer action
626
538
  */
@@ -630,42 +542,6 @@ export interface InferResponse extends BaseResponse {
630
542
  /** General errors */
631
543
  errors?: string[];
632
544
  }
633
- /**
634
- * Response for build_workspace action
635
- */
636
- export interface BuildWorkspaceResponse extends BaseResponse {
637
- /** Path to the created workspace */
638
- workspace_path?: string;
639
- /** Paths to generated stub packages */
640
- stub_packages?: string[];
641
- /** Path to the checker package */
642
- checker_path?: string;
643
- /** Errors during workspace creation */
644
- errors?: string[];
645
- }
646
- /**
647
- * Response for check_compatibility action
648
- */
649
- export interface CheckCompatibilityResponse extends BaseResponse {
650
- /** Results of each compatibility check */
651
- results?: CompatibilityResult[];
652
- /** TypeScript compiler diagnostics */
653
- diagnostics?: string[];
654
- /** Errors during checking */
655
- errors?: string[];
656
- }
657
- /**
658
- * Result of a single compatibility check
659
- */
660
- export interface CompatibilityResult {
661
- source_repo: string;
662
- source_alias: string;
663
- target_repo: string;
664
- target_alias: string;
665
- compatible: boolean;
666
- /** Diagnostic message if not compatible */
667
- diagnostic?: string;
668
- }
669
545
  /**
670
546
  * Response for resolve_definitions action
671
547
  */
@@ -838,7 +714,7 @@ export interface ListLibrarySurfaceResponse extends BaseResponse {
838
714
  /**
839
715
  * Union type for all possible sidecar responses
840
716
  */
841
- export type SidecarResponse = RetypeCheckResponse | VerifyClientSemanticsResponse | VerifyLibraryClaimsResponse | ListLibrarySurfaceResponse | InitResponse | BundleResponse | EmitSurfaceResponse | CaptureV2Response | CheckV2Response | InferResponse | BuildWorkspaceResponse | CheckCompatibilityResponse | ResolveDefinitionsResponse | HealthResponse | ShutdownResponse | ErrorResponse;
717
+ export type SidecarResponse = RetypeCheckResponse | VerifyClientSemanticsResponse | VerifyLibraryClaimsResponse | ListLibrarySurfaceResponse | InitResponse | BundleResponse | CaptureV2Response | CheckV2Response | InferResponse | ResolveDefinitionsResponse | HealthResponse | ShutdownResponse | ErrorResponse;
842
718
  /**
843
719
  * An entry in the type manifest
844
720
  */
@@ -938,6 +814,35 @@ export interface InferredType {
938
814
  * was dropped as unsound.
939
815
  */
940
816
  unwidened_type_string?: string;
817
+ /**
818
+ * carrick#1749, `call_result` only: present when the source itself states
819
+ * the type of the body it reads, AT the read: a cast of the read
820
+ * (`res.json() as Promise<T>`, a callback's `value as T`) or the annotated
821
+ * declaration it initializes (`const data: T = await res.json()`). The
822
+ * text in `type_string` is then that statement. Absent when no type is
823
+ * stated, or when the only annotation is further away than the read.
824
+ */
825
+ stated_body?: StatedBody;
826
+ }
827
+ /**
828
+ * What the source states a body read to be (carrick#1749). The scanner
829
+ * compares `root` with the type symbol the model named for the same call: a
830
+ * model symbol that is not the stated root names something other than the
831
+ * body (an element of it, or a value the caller later computed from it), and
832
+ * the source's own statement outranks it.
833
+ */
834
+ export interface StatedBody {
835
+ /**
836
+ * The name the stated type is rooted at, once `Promise<...>`, array levels,
837
+ * parentheses and `| null`/`| undefined` are peeled: `Order` for
838
+ * `Promise<Order[] | null>`, `Page` for `Page<Order>`. Absent when the root
839
+ * is not a named type (an object literal type, a union of several types).
840
+ */
841
+ root?: string;
842
+ /** Declaration file (absolute path) of `root`, when it resolves to one. */
843
+ root_source?: string;
844
+ /** Array levels peeled on the way to `root`. Omitted when 0. */
845
+ array_depth?: number;
941
846
  }
942
847
  /**
943
848
  * Why a type carries `any`/`unknown` at a position, and where.
@@ -977,7 +882,6 @@ export interface SymbolFailure {
977
882
  }
978
883
  /**
979
884
  * Internal result from the bundler
980
- * @deprecated Use SurfaceEmitResult instead
981
885
  */
982
886
  export interface BundleResult {
983
887
  /** Whether bundling was successful */
@@ -991,21 +895,6 @@ export interface BundleResult {
991
895
  /** General error messages */
992
896
  errors?: string[];
993
897
  }
994
- /**
995
- * Internal result from surface emission
996
- */
997
- export interface SurfaceEmitResult {
998
- /** Whether emission was successful */
999
- success: boolean;
1000
- /** The emitted .d.ts content */
1001
- surface_content?: string;
1002
- /** Output path where content was written */
1003
- output_path?: string;
1004
- /** Manifest of emitted payloads */
1005
- manifest?: SurfaceManifestEntry[];
1006
- /** General error messages */
1007
- errors?: string[];
1008
- }
1009
898
  /**
1010
899
  * Internal result from the type inferrer
1011
900
  */
@@ -1017,32 +906,4 @@ export interface InferResult {
1017
906
  /** General error messages */
1018
907
  errors?: string[];
1019
908
  }
1020
- /**
1021
- * Result from building the synthetic workspace
1022
- */
1023
- export interface WorkspaceBuildResult {
1024
- /** Whether build was successful */
1025
- success: boolean;
1026
- /** Path to the workspace root */
1027
- workspace_path?: string;
1028
- /** Paths to stub packages */
1029
- stub_packages?: string[];
1030
- /** Path to the checker package */
1031
- checker_path?: string;
1032
- /** Error messages */
1033
- errors?: string[];
1034
- }
1035
- /**
1036
- * Result from running compatibility checks
1037
- */
1038
- export interface CompatibilityCheckResult {
1039
- /** Whether checks ran successfully (not whether types are compatible) */
1040
- success: boolean;
1041
- /** Individual check results */
1042
- results?: CompatibilityResult[];
1043
- /** TypeScript diagnostics */
1044
- diagnostics?: string[];
1045
- /** Error messages */
1046
- errors?: string[];
1047
- }
1048
909
  export {};