codemod 1.18.7 → 2.0.0-alpha.2

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 (89) hide show
  1. package/README.md +57 -2
  2. package/codemod +17 -30
  3. package/package.json +78 -10
  4. package/register.d.mts +11 -0
  5. package/register.mjs +60 -0
  6. package/runtime/addon.mjs +59 -0
  7. package/runtime/ast-grep.mjs +93 -0
  8. package/runtime/context.mjs +77 -0
  9. package/runtime/hooks.mjs +9 -0
  10. package/runtime/host.d.mts +120 -0
  11. package/runtime/host.mjs +390 -0
  12. package/runtime/llm.mjs +11 -0
  13. package/runtime/metrics.mjs +45 -0
  14. package/runtime/modules.mjs +19 -0
  15. package/runtime/orchestrator.mjs +657 -0
  16. package/runtime/runtime.mjs +48 -0
  17. package/runtime/workflow.mjs +135 -0
  18. package/testing/index.d.mts +203 -0
  19. package/testing/index.mjs +638 -0
  20. package/types/index.d.ts +8 -0
  21. package/types/langs/angular.d.ts +5 -0
  22. package/types/langs/c.d.ts +5 -0
  23. package/types/langs/c_sharp.d.ts +5 -0
  24. package/types/langs/cpp.d.ts +5 -0
  25. package/types/langs/css.d.ts +5 -0
  26. package/types/langs/elixir.d.ts +5 -0
  27. package/types/langs/go.d.ts +5 -0
  28. package/types/langs/html.d.ts +5 -0
  29. package/types/langs/java.d.ts +5 -0
  30. package/types/langs/javascript.d.ts +5 -0
  31. package/types/langs/json.d.ts +5 -0
  32. package/types/langs/kotlin.d.ts +5 -0
  33. package/types/langs/php.d.ts +5 -0
  34. package/types/langs/python.d.ts +5 -0
  35. package/types/langs/ruby.d.ts +5 -0
  36. package/types/langs/rust.d.ts +5 -0
  37. package/types/langs/scala.d.ts +5 -0
  38. package/types/langs/toml.d.ts +5 -0
  39. package/types/langs/tsx.d.ts +5 -0
  40. package/types/langs/typescript.d.ts +5 -0
  41. package/types/langs/xml.d.ts +5 -0
  42. package/types/langs/yaml.d.ts +5 -0
  43. package/types/llm.d.ts +6 -0
  44. package/types/llrt/abort.d.ts +69 -0
  45. package/types/llrt/assert.d.ts +39 -0
  46. package/types/llrt/async_hooks.d.ts +210 -0
  47. package/types/llrt/buffer.d.ts +1186 -0
  48. package/types/llrt/child_process.d.ts +447 -0
  49. package/types/llrt/console.d.ts +210 -0
  50. package/types/llrt/crypto.d.ts +854 -0
  51. package/types/llrt/dgram.d.ts +381 -0
  52. package/types/llrt/dns.d.ts +124 -0
  53. package/types/llrt/dom-events.d.ts +51 -0
  54. package/types/llrt/events.d.ts +245 -0
  55. package/types/llrt/exceptions.d.ts +26 -0
  56. package/types/llrt/fetch.d.ts +332 -0
  57. package/types/llrt/fs/promises.d.ts +554 -0
  58. package/types/llrt/fs.d.ts +360 -0
  59. package/types/llrt/globals.d.ts +23 -0
  60. package/types/llrt/https.d.ts +27 -0
  61. package/types/llrt/index.d.ts +33 -0
  62. package/types/llrt/module.d.ts +285 -0
  63. package/types/llrt/navigator.d.ts +9 -0
  64. package/types/llrt/net.d.ts +488 -0
  65. package/types/llrt/os.d.ts +293 -0
  66. package/types/llrt/path.d.ts +150 -0
  67. package/types/llrt/perf_hooks.d.ts +23 -0
  68. package/types/llrt/process.d.ts +502 -0
  69. package/types/llrt/stream/web.d.ts +526 -0
  70. package/types/llrt/stream.d.ts +366 -0
  71. package/types/llrt/string_decoder.d.ts +63 -0
  72. package/types/llrt/timers.d.ts +72 -0
  73. package/types/llrt/timezone.d.ts +101 -0
  74. package/types/llrt/tty.d.ts +11 -0
  75. package/types/llrt/url.d.ts +774 -0
  76. package/types/llrt/util.d.ts +240 -0
  77. package/types/llrt/zlib.d.ts +177 -0
  78. package/types/main.d.ts +5 -0
  79. package/types/metrics.d.ts +5 -0
  80. package/types/modules/ast-grep.d.ts +634 -0
  81. package/types/modules/langs.d.ts +87 -0
  82. package/types/modules/llm.d.ts +23 -0
  83. package/types/modules/metrics.d.ts +107 -0
  84. package/types/modules/runtime.d.ts +66 -0
  85. package/types/modules/workflow.d.ts +750 -0
  86. package/types/runtime.d.ts +6 -0
  87. package/types/workflow.d.ts +5 -0
  88. package/vite.d.mts +24 -0
  89. package/vite.mjs +26 -0
@@ -0,0 +1,293 @@
1
+ declare module "os" {
2
+ interface CpuInfo {
3
+ model: string;
4
+ speed: number;
5
+ /** The number of milliseconds spent by the CPU in each mode cannot be obtained at this time. */
6
+ times: {
7
+ /** The number of milliseconds the CPU has spent in user mode. */
8
+ user: number;
9
+ /** The number of milliseconds the CPU has spent in nice mode. */
10
+ nice: number;
11
+ /** The number of milliseconds the CPU has spent in sys mode. */
12
+ sys: number;
13
+ /** The number of milliseconds the CPU has spent in idle mode. */
14
+ idle: number;
15
+ /** The number of milliseconds the CPU has spent in irq mode. */
16
+ irq: number;
17
+ };
18
+ }
19
+ interface NetworkInterfaceBase {
20
+ address: string;
21
+ netmask: string;
22
+ mac: string;
23
+ internal: boolean;
24
+ cidr: string | null;
25
+ }
26
+ interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
27
+ family: "IPv4";
28
+ scopeid?: undefined;
29
+ }
30
+ interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
31
+ family: "IPv6";
32
+ scopeid: number;
33
+ }
34
+ interface UserInfo<T> {
35
+ username: T;
36
+ uid: number;
37
+ gid: number;
38
+ shell: T | null;
39
+ homedir: T;
40
+ }
41
+ type NetworkInterfaceInfo =
42
+ | NetworkInterfaceInfoIPv4
43
+ | NetworkInterfaceInfoIPv6;
44
+ /**
45
+ * Returns an estimate of the default amount of parallelism a program should use.
46
+ * Always returns a value greater than zero.
47
+ */
48
+ function availableParallelism(): number;
49
+ /**
50
+ * Returns the operating system CPU architecture for which the LLRT binary was compiled.
51
+ * Possible values are 'arm64', 'x64'. The return value is equivalent to `process.arch`.
52
+ */
53
+ function arch(): string;
54
+ /**
55
+ * Returns an array of objects containing information about each logical CPU core.
56
+ * The array will be empty if no CPU information is available, such as if the `/proc` file system is unavailable.
57
+ *
58
+ * The properties included on each object include:
59
+ *
60
+ * ```js
61
+ * [
62
+ * {
63
+ * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
64
+ * speed: 2926,
65
+ * times: {
66
+ * user: 252020,
67
+ * nice: 0,
68
+ * sys: 30340,
69
+ * idle: 1070356870,
70
+ * irq: 0,
71
+ * },
72
+ * },
73
+ * {
74
+ * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
75
+ * speed: 2926,
76
+ * times: {
77
+ * user: 306960,
78
+ * nice: 0,
79
+ * sys: 26980,
80
+ * idle: 1071569080,
81
+ * irq: 0,
82
+ * },
83
+ * },
84
+ * {
85
+ * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
86
+ * speed: 2926,
87
+ * times: {
88
+ * user: 248450,
89
+ * nice: 0,
90
+ * sys: 21750,
91
+ * idle: 1070919370,
92
+ * irq: 0,
93
+ * },
94
+ * },
95
+ * {
96
+ * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
97
+ * speed: 2926,
98
+ * times: {
99
+ * user: 256880,
100
+ * nice: 0,
101
+ * sys: 19430,
102
+ * idle: 1070905480,
103
+ * irq: 20,
104
+ * },
105
+ * },
106
+ * ]
107
+ * ```
108
+ *
109
+ * `nice` values are POSIX-only. On Windows, the `nice` values of all processors
110
+ * are always 0.
111
+ *
112
+ * `os.cpus().length` should not be used to calculate the amount of parallelism
113
+ * available to an application. Use {@link availableParallelism} for this purpose.
114
+ */
115
+ function cpus(): CpuInfo[];
116
+ const devNull: string;
117
+ /**
118
+ * Returns a string identifying the endianness of the CPU for which the Node.js
119
+ * binary was compiled.
120
+ *
121
+ * Possible values are `'BE'` for big endian and `'LE'` for little endian.
122
+ */
123
+ function endianness(): "BE" | "LE";
124
+ /**
125
+ * The operating system-specific end-of-line marker.
126
+ * * `\n` on POSIX
127
+ * * `\r\n` on Windows
128
+ */
129
+ const EOL: string;
130
+ /**
131
+ * Returns the amount of free system memory in bytes as an integer.
132
+ */
133
+ function freemem(): number;
134
+ /**
135
+ * Returns the scheduling priority for the process specified by `pid`. If `pid` is
136
+ * not provided or is `0`, the priority of the current process is returned.
137
+ * @param [pid=0] The process ID to retrieve scheduling priority for.
138
+ */
139
+ function getPriority(pid?: number): number;
140
+ /**
141
+ * Returns the string path of the current user's home directory.
142
+ *
143
+ * On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it
144
+ * uses the [effective UID](https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID) to look up the user's home directory.
145
+ *
146
+ * On Windows, it uses the `USERPROFILE` environment variable if defined.
147
+ * Otherwise it uses the path to the profile directory of the current user.
148
+ */
149
+ function homedir(): string;
150
+ /**
151
+ * Returns the host name of the operating system as a string.
152
+ */
153
+ function hostname(): string;
154
+ /**
155
+ * Returns an array containing the 1, 5, and 15 minute load averages.
156
+ *
157
+ * The load average is a measure of system activity calculated by the operating
158
+ * system and expressed as a fractional number.
159
+ *
160
+ * The load average is a Unix-specific concept. On Windows, the return value is
161
+ * always `[0, 0, 0]`.
162
+ */
163
+ function loadavg(): number[];
164
+ /**
165
+ * Returns the machine type as a string, such as `arm64`, `aarch64`, `x86_64`.
166
+ *
167
+ * On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not
168
+ * available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
169
+ */
170
+ function machine(): string;
171
+ /**
172
+ * Returns an object containing network interfaces that have been assigned a
173
+ * network address.
174
+ *
175
+ * Each key on the returned object identifies a network interface. The associated
176
+ * value is an array of objects that each describe an assigned network address.
177
+ *
178
+ * The properties available on the assigned network address object include:
179
+ *
180
+ * ```js
181
+ * {
182
+ * lo: [
183
+ * {
184
+ * address: '127.0.0.1',
185
+ * netmask: '255.0.0.0',
186
+ * family: 'IPv4',
187
+ * mac: '00:00:00:00:00:00',
188
+ * internal: true,
189
+ * cidr: '127.0.0.1/8'
190
+ * },
191
+ * {
192
+ * address: '::1',
193
+ * netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
194
+ * family: 'IPv6',
195
+ * mac: '00:00:00:00:00:00',
196
+ * scopeid: 0,
197
+ * internal: true,
198
+ * cidr: '::1/128'
199
+ * }
200
+ * ],
201
+ * eth0: [
202
+ * {
203
+ * address: '192.168.1.108',
204
+ * netmask: '255.255.255.0',
205
+ * family: 'IPv4',
206
+ * mac: '01:02:03:0a:0b:0c',
207
+ * internal: false,
208
+ * cidr: '192.168.1.108/24'
209
+ * },
210
+ * {
211
+ * address: 'fe80::a00:27ff:fe4e:66a1',
212
+ * netmask: 'ffff:ffff:ffff:ffff::',
213
+ * family: 'IPv6',
214
+ * mac: '01:02:03:0a:0b:0c',
215
+ * scopeid: 1,
216
+ * internal: false,
217
+ * cidr: 'fe80::a00:27ff:fe4e:66a1/64'
218
+ * }
219
+ * ]
220
+ * }
221
+ * ```
222
+ */
223
+ function networkInterfaces(): NodeJS.Dict<NetworkInterfaceInfo[]>;
224
+ /**
225
+ * Returns a string identifying the operating system platform for which
226
+ * the Node.js binary was compiled. The value is set at compile time.
227
+ */
228
+ function platform(): Platform;
229
+ function release(): string;
230
+ /**
231
+ * Returns the operating system's default directory for temporary files as a
232
+ * string.
233
+ */
234
+ /**
235
+ * Attempts to set the scheduling priority for the process specified by `pid`. If `pid` is not provided or is `0`, the process ID of the current process is used.
236
+ *
237
+ * The `priority` input must be an integer between `-20` (high priority) and `19` (low priority). Due to differences between Unix priority levels and Windows
238
+ * priority classes, `priority` is mapped to one of six priority constants in `os.constants.priority`. When retrieving a process priority level, this range
239
+ * mapping may cause the return value to be slightly different on Windows. To avoid
240
+ * confusion, set `priority` to one of the priority constants.
241
+ *
242
+ * On Windows, not currently supported on Windows.
243
+ *
244
+ * @param [pid=0] The process ID to set scheduling priority for.
245
+ * @param priority The scheduling priority to assign to the process.
246
+ */
247
+ function setPriority(priority: number): void;
248
+ function setPriority(pid: number, priority: number): void;
249
+ /**
250
+ * Returns the operating system release as a string.
251
+ *
252
+ * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used. See
253
+ * [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
254
+ */
255
+ function tmpdir(): string;
256
+ /**
257
+ * Returns the total amount of system memory in bytes as an integer.
258
+ */
259
+ function totalmem(): number;
260
+ /**
261
+ * Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it
262
+ * returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
263
+ *
264
+ * See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for additional information
265
+ * about the output of running [`uname(3)`](https://linux.die.net/man/3/uname) on various operating systems.
266
+ */
267
+ function type(): string;
268
+ /**
269
+ * Returns the system uptime in number of seconds.
270
+ */
271
+ function uptime(): number;
272
+ /**
273
+ * Returns a string identifying the kernel version.
274
+ *
275
+ * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used.
276
+ * See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
277
+ */
278
+ /**
279
+ * Returns information about the currently effective user. On POSIX platforms,
280
+ * this is typically a subset of the password file. The returned object includes
281
+ * the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and `gid` fields are `-1`, and `shell` is `null`.
282
+ *
283
+ * The value of `homedir` returned by `os.userInfo()` is provided by the operating
284
+ * system. This differs from the result of `os.homedir()`, which queries
285
+ * environment variables for the home directory before falling back to the
286
+ * operating system response.
287
+ *
288
+ * Throws a [`SystemError`](https://nodejs.org/docs/latest-v22.x/api/errors.html#class-systemerror) if a user has no `username` or `homedir`.
289
+ */
290
+ //function userInfo(options: { encoding: "buffer" }): UserInfo<Buffer>;
291
+ function userInfo(options?: { encoding: BufferEncoding }): UserInfo<string>;
292
+ function version(): string;
293
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * The `path` module provides utilities for working with file and directory
3
+ * paths. It can be accessed using:
4
+ *
5
+ * ```js
6
+ * import path from 'path';
7
+ * ```
8
+ */
9
+ declare module "path" {
10
+ namespace path {
11
+ /**
12
+ * A parsed path object generated by path.parse() or consumed by path.format().
13
+ */
14
+ interface ParsedPath {
15
+ /**
16
+ * The root of the path such as '/' or 'c:\'
17
+ */
18
+ root: string;
19
+ /**
20
+ * The full directory path such as '/home/user/dir' or 'c:\path\dir'
21
+ */
22
+ dir: string;
23
+ /**
24
+ * The file name including extension (if any) such as 'index.html'
25
+ */
26
+ base: string;
27
+ /**
28
+ * The file extension (if any) such as '.html'
29
+ */
30
+ ext: string;
31
+ /**
32
+ * The file name without extension (if any) such as 'index'
33
+ */
34
+ name: string;
35
+ }
36
+ interface FormatInputPathObject {
37
+ /**
38
+ * The root of the path such as '/' or 'c:\'
39
+ */
40
+ root?: string | undefined;
41
+ /**
42
+ * The full directory path such as '/home/user/dir' or 'c:\path\dir'
43
+ */
44
+ dir?: string | undefined;
45
+ /**
46
+ * The file name including extension (if any) such as 'index.html'
47
+ */
48
+ base?: string | undefined;
49
+ /**
50
+ * The file extension (if any) such as '.html'
51
+ */
52
+ ext?: string | undefined;
53
+ /**
54
+ * The file name without extension (if any) such as 'index'
55
+ */
56
+ name?: string | undefined;
57
+ }
58
+ interface PlatformPath {
59
+ /**
60
+ * Normalize a string path, reducing '..' and '.' parts.
61
+ * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
62
+ *
63
+ * @param path string path to normalize.
64
+ * @throws {TypeError} if `path` is not a string.
65
+ */
66
+ normalize(path: string): string;
67
+ /**
68
+ * Join all arguments together and normalize the resulting path.
69
+ *
70
+ * @param paths paths to join.
71
+ * @throws {TypeError} if any of the path segments is not a string.
72
+ */
73
+ join(...paths: string[]): string;
74
+ /**
75
+ * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
76
+ *
77
+ * Starting from leftmost {from} parameter, resolves {to} to an absolute path.
78
+ *
79
+ * If {to} isn't already absolute, {from} arguments are prepended in right to left order,
80
+ * until an absolute path is found. If after using all {from} paths still no absolute path is found,
81
+ * the current working directory is used as well. The resulting path is normalized,
82
+ * and trailing slashes are removed unless the path gets resolved to the root directory.
83
+ *
84
+ * @param paths A sequence of paths or path segments.
85
+ * @throws {TypeError} if any of the arguments is not a string.
86
+ */
87
+ resolve(...paths: string[]): string;
88
+ /**
89
+ * Solve the relative path from {from} to {to}. At times we have two absolute paths, and we need to derive the relative path from one to another. This method solves the problem.
90
+ *
91
+ * @param from The source path.
92
+ * @param to The destination path.
93
+ * @throws {TypeError} if any of the arguments is not a string.
94
+ */
95
+ relative(from: string, to: string): string;
96
+ /**
97
+ * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
98
+ *
99
+ * If the given {path} is a zero-length string, `false` will be returned.
100
+ *
101
+ * @param path path to test.
102
+ */
103
+ isAbsolute(path: string): boolean;
104
+ /**
105
+ * Return the directory name of a path. Similar to the Unix dirname command.
106
+ *
107
+ * @param path the path to evaluate.
108
+ */
109
+ dirname(path: string): string;
110
+ /**
111
+ * Return the last portion of a path. Similar to the Unix basename command.
112
+ * Often used to extract the file name from a fully qualified path.
113
+ *
114
+ * @param path the path to evaluate.
115
+ * @param suffix optionally, an extension to remove from the result.
116
+ */
117
+ basename(path: string, suffix?: string): string;
118
+ /**
119
+ * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
120
+ * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.
121
+ *
122
+ * @param path the path to evaluate.
123
+ */
124
+ extname(path: string): string;
125
+ /**
126
+ * The platform-specific file separator. '\\' or '/'.
127
+ */
128
+ readonly sep: "\\" | "/";
129
+ /**
130
+ * The platform-specific file delimiter. ';' or ':'.
131
+ */
132
+ readonly delimiter: ";" | ":";
133
+ /**
134
+ * Returns an object from a path string - the opposite of format().
135
+ *
136
+ * @param path path to evaluate.
137
+ * @throws {TypeError} if `path` is not a string.
138
+ */
139
+ parse(path: string): ParsedPath;
140
+ /**
141
+ * Returns a path string from an object - the opposite of parse().
142
+ *
143
+ * @param pathObject path to evaluate.
144
+ */
145
+ format(pathObject: FormatInputPathObject): string;
146
+ }
147
+ }
148
+ const path: path.PlatformPath;
149
+ export = path;
150
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This module provides an implementation of a subset of the W3C [Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for
3
+ * Node.js-specific performance measurements.
4
+ *
5
+ */
6
+ declare module "perf_hooks" {
7
+ interface Performance {
8
+ /**
9
+ * Returns the current high resolution millisecond timestamp, where 0 represents the start of the current `node` process.
10
+ * @since v8.5.0
11
+ */
12
+ now(): number;
13
+ /**
14
+ * The [`timeOrigin`](https://w3c.github.io/hr-time/#dom-performance-timeorigin) specifies the high resolution millisecond timestamp
15
+ * at which the current `node` process began, measured in Unix time.
16
+ * @since v8.5.0
17
+ */
18
+ readonly timeOrigin: number;
19
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON) */
20
+ toJSON(): { timeOrigin: number }; // TODO: llrt currently has only one field
21
+ }
22
+ var performance: Performance
23
+ }