carrick 0.3.153 → 0.3.155

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 (159) hide show
  1. package/bin/carrick.mjs +26 -4
  2. package/dist/cli.d.ts +6 -0
  3. package/dist/cli.js +1 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/contract.d.ts +37 -3
  6. package/dist/contract.js +8 -0
  7. package/dist/contract.js.map +1 -1
  8. package/dist/facts/diff.d.ts +27 -0
  9. package/dist/facts/diff.js +134 -0
  10. package/dist/facts/diff.js.map +1 -0
  11. package/dist/facts/enabled.d.ts +2 -0
  12. package/dist/facts/enabled.js +9 -0
  13. package/dist/facts/enabled.js.map +1 -0
  14. package/dist/facts/fetch.d.ts +48 -0
  15. package/dist/facts/fetch.js +235 -0
  16. package/dist/facts/fetch.js.map +1 -0
  17. package/dist/facts/files.d.ts +21 -0
  18. package/dist/facts/files.js +58 -0
  19. package/dist/facts/files.js.map +1 -0
  20. package/dist/facts/lines.d.ts +70 -0
  21. package/dist/facts/lines.js +335 -0
  22. package/dist/facts/lines.js.map +1 -0
  23. package/dist/facts/match.d.ts +91 -0
  24. package/dist/facts/match.js +1122 -0
  25. package/dist/facts/match.js.map +1 -0
  26. package/dist/facts/peers.d.ts +48 -0
  27. package/dist/facts/peers.js +143 -0
  28. package/dist/facts/peers.js.map +1 -0
  29. package/dist/facts/refresh-run.d.ts +2 -0
  30. package/dist/facts/refresh-run.js +18 -0
  31. package/dist/facts/refresh-run.js.map +1 -0
  32. package/dist/facts/rules/packages.d.ts +16 -0
  33. package/dist/facts/rules/packages.js +157 -0
  34. package/dist/facts/rules/packages.js.map +1 -0
  35. package/dist/facts/rules/same-name.d.ts +28 -0
  36. package/dist/facts/rules/same-name.js +131 -0
  37. package/dist/facts/rules/same-name.js.map +1 -0
  38. package/dist/facts/store.d.ts +119 -0
  39. package/dist/facts/store.js +341 -0
  40. package/dist/facts/store.js.map +1 -0
  41. package/dist/git-remote.d.ts +6 -0
  42. package/dist/git-remote.js +37 -0
  43. package/dist/git-remote.js.map +1 -0
  44. package/dist/hook/apply-patch.d.ts +23 -0
  45. package/dist/hook/apply-patch.js +92 -0
  46. package/dist/hook/apply-patch.js.map +1 -1
  47. package/dist/hook/bash-targets.d.ts +8 -0
  48. package/dist/hook/bash-targets.js +23 -11
  49. package/dist/hook/bash-targets.js.map +1 -1
  50. package/dist/hook/edit-flow.d.ts +29 -2
  51. package/dist/hook/edit-flow.js +80 -29
  52. package/dist/hook/edit-flow.js.map +1 -1
  53. package/dist/hook/late.d.ts +29 -0
  54. package/dist/hook/late.js +121 -26
  55. package/dist/hook/late.js.map +1 -1
  56. package/dist/hook/post-bash.js +45 -22
  57. package/dist/hook/post-bash.js.map +1 -1
  58. package/dist/hook/post-edit.d.ts +16 -1
  59. package/dist/hook/post-edit.js +177 -13
  60. package/dist/hook/post-edit.js.map +1 -1
  61. package/dist/hook/post-read.js +8 -12
  62. package/dist/hook/post-read.js.map +1 -1
  63. package/dist/hook/post-search.d.ts +2 -0
  64. package/dist/hook/post-search.js +25 -0
  65. package/dist/hook/post-search.js.map +1 -0
  66. package/dist/hook/probe.d.ts +18 -3
  67. package/dist/hook/probe.js +30 -6
  68. package/dist/hook/probe.js.map +1 -1
  69. package/dist/hook/rechecks.d.ts +66 -11
  70. package/dist/hook/rechecks.js +115 -29
  71. package/dist/hook/rechecks.js.map +1 -1
  72. package/dist/hook/refresh.d.ts +9 -0
  73. package/dist/hook/refresh.js +10 -0
  74. package/dist/hook/refresh.js.map +1 -1
  75. package/dist/hook/reuse.d.ts +16 -2
  76. package/dist/hook/reuse.js +49 -6
  77. package/dist/hook/reuse.js.map +1 -1
  78. package/dist/hook/session-key.d.ts +12 -0
  79. package/dist/hook/session-key.js +30 -0
  80. package/dist/hook/session-key.js.map +1 -0
  81. package/dist/hook/session-start.js +14 -7
  82. package/dist/hook/session-start.js.map +1 -1
  83. package/dist/hook/stop-wait.d.ts +2 -9
  84. package/dist/hook/stop-wait.js +96 -113
  85. package/dist/hook/stop-wait.js.map +1 -1
  86. package/dist/hook/stop.js +13 -8
  87. package/dist/hook/stop.js.map +1 -1
  88. package/dist/hook/subagent-stop.d.ts +2 -0
  89. package/dist/hook/subagent-stop.js +45 -0
  90. package/dist/hook/subagent-stop.js.map +1 -0
  91. package/dist/hook/timings.d.ts +72 -0
  92. package/dist/hook/timings.js +175 -0
  93. package/dist/hook/timings.js.map +1 -0
  94. package/dist/hook/user-prompt.js +17 -13
  95. package/dist/hook/user-prompt.js.map +1 -1
  96. package/dist/hook/worktree.d.ts +11 -0
  97. package/dist/hook/worktree.js +27 -1
  98. package/dist/hook/worktree.js.map +1 -1
  99. package/dist/init/repo-copies.d.ts +6 -0
  100. package/dist/init/repo-copies.js +7 -3
  101. package/dist/init/repo-copies.js.map +1 -1
  102. package/dist/init/repos.d.ts +2 -2
  103. package/dist/init/repos.js +1 -34
  104. package/dist/init/repos.js.map +1 -1
  105. package/dist/init/settings.js +25 -13
  106. package/dist/init/settings.js.map +1 -1
  107. package/dist/render.d.ts +8 -33
  108. package/dist/render.js +42 -120
  109. package/dist/render.js.map +1 -1
  110. package/package.json +6 -6
  111. package/plugin/.claude-plugin/plugin.json +1 -1
  112. package/plugin/hooks/hooks.json +44 -3
  113. package/scripts/install-scanned-deps.sh +25 -2
  114. package/sidecar/dist/src/capture/anchors.d.ts +12 -1
  115. package/sidecar/dist/src/capture/anchors.js +28 -47
  116. package/sidecar/dist/src/capture/api.d.ts +41 -1
  117. package/sidecar/dist/src/capture/augmentations.d.ts +2 -0
  118. package/sidecar/dist/src/capture/augmentations.js +1 -1
  119. package/sidecar/dist/src/capture/check-classify.d.ts +12 -1
  120. package/sidecar/dist/src/capture/check-classify.js +43 -0
  121. package/sidecar/dist/src/capture/check-deep.d.ts +44 -1
  122. package/sidecar/dist/src/capture/check-deep.js +161 -2
  123. package/sidecar/dist/src/capture/check.js +23 -2
  124. package/sidecar/dist/src/capture/checkout.d.ts +9 -3
  125. package/sidecar/dist/src/capture/checkout.js +12 -5
  126. package/sidecar/dist/src/capture/deep-walk.d.ts +25 -0
  127. package/sidecar/dist/src/capture/deep-walk.js +41 -0
  128. package/sidecar/dist/src/capture/deno-project.d.ts +22 -0
  129. package/sidecar/dist/src/capture/deno-project.js +48 -1
  130. package/sidecar/dist/src/capture/index.d.ts +3 -1
  131. package/sidecar/dist/src/capture/index.js +14 -4
  132. package/sidecar/dist/src/capture/machinery.d.ts +8 -53
  133. package/sidecar/dist/src/capture/machinery.js +10 -157
  134. package/sidecar/dist/src/capture/node-builder.d.ts +6 -0
  135. package/sidecar/dist/src/capture/self-check.d.ts +7 -0
  136. package/sidecar/dist/src/capture/self-check.js +44 -1
  137. package/sidecar/dist/src/capture/site-node.d.ts +166 -0
  138. package/sidecar/dist/src/capture/site-node.js +570 -0
  139. package/sidecar/dist/src/capture/tool-env.d.ts +12 -0
  140. package/sidecar/dist/src/capture/tool-env.js +26 -0
  141. package/sidecar/dist/src/default-library.d.ts +39 -0
  142. package/sidecar/dist/src/default-library.js +132 -0
  143. package/sidecar/dist/src/definition-resolver.js +2 -0
  144. package/sidecar/dist/src/index.js +1 -1
  145. package/sidecar/dist/src/library-claims.d.ts +2 -0
  146. package/sidecar/dist/src/library-claims.js +387 -37
  147. package/sidecar/dist/src/node-index.d.ts +2 -0
  148. package/sidecar/dist/src/node-index.js +5 -1
  149. package/sidecar/dist/src/position-rows.d.ts +78 -7
  150. package/sidecar/dist/src/position-rows.js +343 -18
  151. package/sidecar/dist/src/project-loader.d.ts +3 -3
  152. package/sidecar/dist/src/project-loader.js +18 -9
  153. package/sidecar/dist/src/retype.d.ts +13 -0
  154. package/sidecar/dist/src/retype.js +126 -0
  155. package/sidecar/dist/src/type-inferrer.d.ts +47 -145
  156. package/sidecar/dist/src/type-inferrer.js +102 -529
  157. package/sidecar/dist/src/types.d.ts +64 -2
  158. package/sidecar/dist/src/validators.d.ts +806 -142
  159. package/sidecar/dist/src/validators.js +12 -1
@@ -0,0 +1,132 @@
1
+ /**
2
+ * The TypeScript default library (`lib.*.d.ts`) every ts-morph project reads
3
+ * (carrick#3509).
4
+ *
5
+ * Without `libFolderPath`, ts-morph serves its own copy of these files from
6
+ * memory, and that copy is minified: comments are stripped and declarations
7
+ * run together, so every member of `lib.dom.d.ts` sits on its line 3. A row's
8
+ * `decl_line` for a library member, and the declarations a verified op names,
9
+ * then point at one line for every member, and a label verified for one
10
+ * member (`BroadcastChannel.addEventListener`) is matched by every other
11
+ * (`Body.json`, `Crypto.randomUUID`).
12
+ *
13
+ * Every project here reads the compiler's own files instead, at the folder
14
+ * ts-morph's copy is at (`/node_modules/typescript/lib`), so the files keep
15
+ * the names they always had (`resolved_file`, `lib:<name>`) and only their
16
+ * text changes. The texts come from the `typescript` package beside the
17
+ * sidecar; the surface lister bundle carries them inlined
18
+ * (`lister/build.mjs`), as it carried ts-morph's copy before.
19
+ */
20
+ import { Project } from 'ts-morph';
21
+ import * as fs from 'node:fs';
22
+ import * as path from 'node:path';
23
+ import ts from 'typescript';
24
+ import { sidecarCompilerOptions } from './capture/index.js';
25
+ /** Where every project reads the default library from: ts-morph's own folder name for it. */
26
+ export const DEFAULT_LIBRARY_FOLDER = '/node_modules/typescript/lib';
27
+ /**
28
+ * The bundle's inlined texts, by file name. `lister/build.mjs` defines this
29
+ * one reference (an esbuild define is inlined at every reference, so there is
30
+ * exactly one); the unbundled sidecar has no such global and reads the files
31
+ * from disk.
32
+ */
33
+ const BUNDLED = globalThis
34
+ .__CARRICK_DEFAULT_LIBRARY__;
35
+ let texts;
36
+ /** Every `lib.*.d.ts` the compiler ships, by file name. */
37
+ export function defaultLibraryTexts() {
38
+ if (texts)
39
+ return texts;
40
+ if (BUNDLED !== undefined) {
41
+ texts = new Map(Object.entries(BUNDLED));
42
+ return texts;
43
+ }
44
+ const folder = path.dirname(ts.getDefaultLibFilePath({}));
45
+ texts = new Map(fs
46
+ .readdirSync(folder)
47
+ .filter((name) => /^lib(\..+)?\.d\.ts$/.test(name))
48
+ .sort()
49
+ .map((name) => [name, fs.readFileSync(path.join(folder, name), 'utf8')]));
50
+ return texts;
51
+ }
52
+ function libraryFileOf(p) {
53
+ const normal = p.split(path.sep).join('/');
54
+ if (path.posix.dirname(normal) !== DEFAULT_LIBRARY_FOLDER)
55
+ return undefined;
56
+ return path.posix.basename(normal);
57
+ }
58
+ function isLibraryFolder(p) {
59
+ return p.split(path.sep).join('/').replace(/\/+$/, '') === DEFAULT_LIBRARY_FOLDER;
60
+ }
61
+ /**
62
+ * `inner` (the real file system when none is given) with the default
63
+ * library's folder answered from {@link defaultLibraryTexts}. Every other
64
+ * path goes to `inner` unchanged.
65
+ */
66
+ export function withDefaultLibrary(inner) {
67
+ const base = inner ??
68
+ new Project({
69
+ compilerOptions: sidecarCompilerOptions({}),
70
+ skipAddingFilesFromTsConfig: true,
71
+ skipFileDependencyResolution: true,
72
+ skipLoadingLibFiles: true,
73
+ }).getFileSystem();
74
+ const missing = (p) => Object.assign(new Error(`ENOENT: no such file or directory, open '${p}'`), { code: 'ENOENT' });
75
+ const read = (p) => {
76
+ const name = libraryFileOf(p);
77
+ return name === undefined ? undefined : defaultLibraryTexts().get(name);
78
+ };
79
+ const isLibraryPath = (p) => libraryFileOf(p) !== undefined || isLibraryFolder(p);
80
+ return new Proxy(base, {
81
+ get(target, prop, receiver) {
82
+ const value = Reflect.get(target, prop, receiver);
83
+ if (typeof value !== 'function')
84
+ return value;
85
+ const fn = value.bind(target);
86
+ switch (prop) {
87
+ case 'readFileSync':
88
+ return (p, e) => {
89
+ if (!isLibraryPath(p))
90
+ return fn(p, e);
91
+ const text = read(p);
92
+ if (text === undefined)
93
+ throw missing(p);
94
+ return text;
95
+ };
96
+ case 'readFile':
97
+ return async (p, e) => {
98
+ if (!isLibraryPath(p))
99
+ return fn(p, e);
100
+ const text = read(p);
101
+ if (text === undefined)
102
+ throw missing(p);
103
+ return text;
104
+ };
105
+ case 'fileExistsSync':
106
+ return (p) => (isLibraryPath(p) ? read(p) !== undefined : fn(p));
107
+ case 'fileExists':
108
+ return async (p) => (isLibraryPath(p) ? read(p) !== undefined : fn(p));
109
+ case 'directoryExistsSync':
110
+ return (p) => isLibraryFolder(p) || (libraryFileOf(p) === undefined && fn(p));
111
+ case 'directoryExists':
112
+ return async (p) => isLibraryFolder(p) || (libraryFileOf(p) === undefined && (await fn(p)));
113
+ case 'readDirSync':
114
+ return (p) => isLibraryFolder(p)
115
+ ? [...defaultLibraryTexts().keys()].map((name) => ({ name, isFile: true, isDirectory: false, isSymlink: false }))
116
+ : fn(p);
117
+ case 'realpathSync':
118
+ return (p) => (isLibraryPath(p) ? p : fn(p));
119
+ default:
120
+ return fn;
121
+ }
122
+ },
123
+ });
124
+ }
125
+ /**
126
+ * The options every ts-morph project in the sidecar is built with, over
127
+ * `fileSystem` (the real file system when none is given): the default library
128
+ * read from the compiler's own files.
129
+ */
130
+ export function defaultLibraryOptions(fileSystem) {
131
+ return { libFolderPath: DEFAULT_LIBRARY_FOLDER, fileSystem: withDefaultLibrary(fileSystem) };
132
+ }
@@ -36,6 +36,7 @@ import * as path from 'node:path';
36
36
  import * as fs from 'node:fs';
37
37
  import { Project, Node } from 'ts-morph';
38
38
  import { sidecarCompilerOptions } from './capture/index.js';
39
+ import { defaultLibraryOptions } from './default-library.js';
39
40
  import { expandTypeStructural, } from './type-structural-expander.js';
40
41
  export class DefinitionResolver {
41
42
  /**
@@ -58,6 +59,7 @@ export class DefinitionResolver {
58
59
  }
59
60
  try {
60
61
  const stubProject = new Project({
62
+ ...defaultLibraryOptions(),
61
63
  compilerOptions: sidecarCompilerOptions({
62
64
  target: 99, // ESNext
63
65
  module: 99, // ESNext
@@ -670,7 +670,7 @@ function handleListLibrarySurface(request) {
670
670
  const { claimsVerifier } = projectComponents();
671
671
  const fromDir = path.resolve(projectLoader.getRepoRoot(), request.from_dir);
672
672
  log(`Listing the declared surface of ${request.packages.length} specifier(s) from ${fromDir}`);
673
- const { surfaces, surface_sha256 } = claimsVerifier.listSurface(fromDir, request.packages, request.max_entries ?? SURFACE_MAX_ENTRIES, request.exports ?? {}, { handlers: request.handlers, types: request.types, resultCandidates: request.result_candidates, maxHandlerMembers: request.max_handler_members });
673
+ const { surfaces, surface_sha256 } = claimsVerifier.listSurface(fromDir, request.packages, request.max_entries ?? SURFACE_MAX_ENTRIES, request.exports ?? {}, { handlers: request.handlers, types: request.types, resultCandidates: request.result_candidates, maxHandlerMembers: request.max_handler_members, foreignMakerBudget: request.foreign_maker_budget });
674
674
  return { request_id: request.request_id, status: 'success', surfaces, surface_sha256 };
675
675
  }
676
676
  catch (err) {
@@ -234,6 +234,8 @@ export interface SurfaceOptions {
234
234
  resultCandidates?: boolean;
235
235
  /** Handler-parameter members the whole call may list (default `HANDLER_LISTING_BUDGET`, carrick#3016). */
236
236
  maxHandlerMembers?: number;
237
+ /** Estimated member makers of foreign values past which they list none (default `FOREIGN_MAKER_BUDGET`, carrick#3745). */
238
+ foreignMakerBudget?: number;
237
239
  }
238
240
  /** The name a service imports a package by: `@types/scope__name` is `@scope/name`, `@types/name` is `name`. */
239
241
  export declare function importedNameOf(installed: string): string;