@anthropic-ai/claude-code 0.2.9 → 0.2.18

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 (103) hide show
  1. package/cli.mjs +497 -479
  2. package/package.json +3 -2
  3. package/scripts/preinstall.js +15 -0
  4. package/vendor/sdk/node_modules/@types/node/LICENSE +0 -21
  5. package/vendor/sdk/node_modules/@types/node/README.md +0 -15
  6. package/vendor/sdk/node_modules/@types/node/assert/strict.d.ts +0 -8
  7. package/vendor/sdk/node_modules/@types/node/assert.d.ts +0 -985
  8. package/vendor/sdk/node_modules/@types/node/async_hooks.d.ts +0 -522
  9. package/vendor/sdk/node_modules/@types/node/buffer.buffer.d.ts +0 -385
  10. package/vendor/sdk/node_modules/@types/node/buffer.d.ts +0 -1903
  11. package/vendor/sdk/node_modules/@types/node/child_process.d.ts +0 -1549
  12. package/vendor/sdk/node_modules/@types/node/cluster.d.ts +0 -578
  13. package/vendor/sdk/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
  14. package/vendor/sdk/node_modules/@types/node/compatibility/index.d.ts +0 -9
  15. package/vendor/sdk/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  16. package/vendor/sdk/node_modules/@types/node/compatibility/iterators.d.ts +0 -20
  17. package/vendor/sdk/node_modules/@types/node/console.d.ts +0 -452
  18. package/vendor/sdk/node_modules/@types/node/constants.d.ts +0 -19
  19. package/vendor/sdk/node_modules/@types/node/crypto.d.ts +0 -4453
  20. package/vendor/sdk/node_modules/@types/node/dgram.d.ts +0 -596
  21. package/vendor/sdk/node_modules/@types/node/diagnostics_channel.d.ts +0 -546
  22. package/vendor/sdk/node_modules/@types/node/dns/promises.d.ts +0 -475
  23. package/vendor/sdk/node_modules/@types/node/dns.d.ts +0 -853
  24. package/vendor/sdk/node_modules/@types/node/dom-events.d.ts +0 -124
  25. package/vendor/sdk/node_modules/@types/node/domain.d.ts +0 -170
  26. package/vendor/sdk/node_modules/@types/node/events.d.ts +0 -819
  27. package/vendor/sdk/node_modules/@types/node/fs/promises.d.ts +0 -1205
  28. package/vendor/sdk/node_modules/@types/node/fs.d.ts +0 -4237
  29. package/vendor/sdk/node_modules/@types/node/globals.d.ts +0 -442
  30. package/vendor/sdk/node_modules/@types/node/globals.typedarray.d.ts +0 -21
  31. package/vendor/sdk/node_modules/@types/node/http.d.ts +0 -1839
  32. package/vendor/sdk/node_modules/@types/node/http2.d.ts +0 -2517
  33. package/vendor/sdk/node_modules/@types/node/https.d.ts +0 -544
  34. package/vendor/sdk/node_modules/@types/node/index.d.ts +0 -90
  35. package/vendor/sdk/node_modules/@types/node/inspector.d.ts +0 -2775
  36. package/vendor/sdk/node_modules/@types/node/module.d.ts +0 -291
  37. package/vendor/sdk/node_modules/@types/node/net.d.ts +0 -924
  38. package/vendor/sdk/node_modules/@types/node/os.d.ts +0 -473
  39. package/vendor/sdk/node_modules/@types/node/package.json +0 -225
  40. package/vendor/sdk/node_modules/@types/node/path.d.ts +0 -191
  41. package/vendor/sdk/node_modules/@types/node/perf_hooks.d.ts +0 -753
  42. package/vendor/sdk/node_modules/@types/node/process.d.ts +0 -1553
  43. package/vendor/sdk/node_modules/@types/node/punycode.d.ts +0 -117
  44. package/vendor/sdk/node_modules/@types/node/querystring.d.ts +0 -141
  45. package/vendor/sdk/node_modules/@types/node/readline/promises.d.ts +0 -154
  46. package/vendor/sdk/node_modules/@types/node/readline.d.ts +0 -715
  47. package/vendor/sdk/node_modules/@types/node/repl.d.ts +0 -430
  48. package/vendor/sdk/node_modules/@types/node/stream/consumers.d.ts +0 -12
  49. package/vendor/sdk/node_modules/@types/node/stream/promises.d.ts +0 -90
  50. package/vendor/sdk/node_modules/@types/node/stream/web.d.ts +0 -523
  51. package/vendor/sdk/node_modules/@types/node/stream.d.ts +0 -1731
  52. package/vendor/sdk/node_modules/@types/node/string_decoder.d.ts +0 -67
  53. package/vendor/sdk/node_modules/@types/node/test.d.ts +0 -1245
  54. package/vendor/sdk/node_modules/@types/node/timers/promises.d.ts +0 -93
  55. package/vendor/sdk/node_modules/@types/node/timers.d.ts +0 -126
  56. package/vendor/sdk/node_modules/@types/node/tls.d.ts +0 -1203
  57. package/vendor/sdk/node_modules/@types/node/trace_events.d.ts +0 -171
  58. package/vendor/sdk/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -385
  59. package/vendor/sdk/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -19
  60. package/vendor/sdk/node_modules/@types/node/ts5.6/index.d.ts +0 -90
  61. package/vendor/sdk/node_modules/@types/node/tty.d.ts +0 -206
  62. package/vendor/sdk/node_modules/@types/node/url.d.ts +0 -957
  63. package/vendor/sdk/node_modules/@types/node/util.d.ts +0 -2083
  64. package/vendor/sdk/node_modules/@types/node/v8.d.ts +0 -753
  65. package/vendor/sdk/node_modules/@types/node/vm.d.ts +0 -666
  66. package/vendor/sdk/node_modules/@types/node/wasi.d.ts +0 -160
  67. package/vendor/sdk/node_modules/@types/node/worker_threads.d.ts +0 -695
  68. package/vendor/sdk/node_modules/@types/node/zlib.d.ts +0 -517
  69. package/vendor/sdk/node_modules/undici-types/README.md +0 -6
  70. package/vendor/sdk/node_modules/undici-types/agent.d.ts +0 -31
  71. package/vendor/sdk/node_modules/undici-types/api.d.ts +0 -43
  72. package/vendor/sdk/node_modules/undici-types/balanced-pool.d.ts +0 -18
  73. package/vendor/sdk/node_modules/undici-types/cache.d.ts +0 -36
  74. package/vendor/sdk/node_modules/undici-types/client.d.ts +0 -97
  75. package/vendor/sdk/node_modules/undici-types/connector.d.ts +0 -34
  76. package/vendor/sdk/node_modules/undici-types/content-type.d.ts +0 -21
  77. package/vendor/sdk/node_modules/undici-types/cookies.d.ts +0 -28
  78. package/vendor/sdk/node_modules/undici-types/diagnostics-channel.d.ts +0 -67
  79. package/vendor/sdk/node_modules/undici-types/dispatcher.d.ts +0 -241
  80. package/vendor/sdk/node_modules/undici-types/errors.d.ts +0 -128
  81. package/vendor/sdk/node_modules/undici-types/fetch.d.ts +0 -209
  82. package/vendor/sdk/node_modules/undici-types/file.d.ts +0 -39
  83. package/vendor/sdk/node_modules/undici-types/filereader.d.ts +0 -54
  84. package/vendor/sdk/node_modules/undici-types/formdata.d.ts +0 -108
  85. package/vendor/sdk/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  86. package/vendor/sdk/node_modules/undici-types/global-origin.d.ts +0 -7
  87. package/vendor/sdk/node_modules/undici-types/handlers.d.ts +0 -9
  88. package/vendor/sdk/node_modules/undici-types/header.d.ts +0 -4
  89. package/vendor/sdk/node_modules/undici-types/index.d.ts +0 -63
  90. package/vendor/sdk/node_modules/undici-types/interceptors.d.ts +0 -5
  91. package/vendor/sdk/node_modules/undici-types/mock-agent.d.ts +0 -50
  92. package/vendor/sdk/node_modules/undici-types/mock-client.d.ts +0 -25
  93. package/vendor/sdk/node_modules/undici-types/mock-errors.d.ts +0 -12
  94. package/vendor/sdk/node_modules/undici-types/mock-interceptor.d.ts +0 -93
  95. package/vendor/sdk/node_modules/undici-types/mock-pool.d.ts +0 -25
  96. package/vendor/sdk/node_modules/undici-types/package.json +0 -55
  97. package/vendor/sdk/node_modules/undici-types/patch.d.ts +0 -71
  98. package/vendor/sdk/node_modules/undici-types/pool-stats.d.ts +0 -19
  99. package/vendor/sdk/node_modules/undici-types/pool.d.ts +0 -28
  100. package/vendor/sdk/node_modules/undici-types/proxy-agent.d.ts +0 -30
  101. package/vendor/sdk/node_modules/undici-types/readable.d.ts +0 -61
  102. package/vendor/sdk/node_modules/undici-types/webidl.d.ts +0 -220
  103. package/vendor/sdk/node_modules/undici-types/websocket.d.ts +0 -131
@@ -1,715 +0,0 @@
1
- /**
2
- * The `readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time.
3
- *
4
- * To use the promise-based APIs:
5
- *
6
- * ```js
7
- * import * as readline from 'node:readline/promises';
8
- * ```
9
- *
10
- * To use the callback and sync APIs:
11
- *
12
- * ```js
13
- * import * as readline from 'node:readline';
14
- * ```
15
- *
16
- * The following simple example illustrates the basic use of the `readline` module.
17
- *
18
- * ```js
19
- * import * as readline from 'node:readline/promises';
20
- * import { stdin as input, stdout as output } from 'node:process';
21
- *
22
- * const rl = readline.createInterface({ input, output });
23
- *
24
- * const answer = await rl.question('What do you think of Node.js? ');
25
- *
26
- * console.log(`Thank you for your valuable feedback: ${answer}`);
27
- *
28
- * rl.close();
29
- * ```
30
- *
31
- * Once this code is invoked, the Node.js application will not terminate until the`readline.Interface` is closed because the interface waits for data to be
32
- * received on the `input` stream.
33
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline.js)
34
- */
35
- declare module "readline" {
36
- import { Abortable, EventEmitter } from "node:events";
37
- import * as promises from "node:readline/promises";
38
-
39
- export { promises };
40
- export interface Key {
41
- sequence?: string | undefined;
42
- name?: string | undefined;
43
- ctrl?: boolean | undefined;
44
- meta?: boolean | undefined;
45
- shift?: boolean | undefined;
46
- }
47
- /**
48
- * Instances of the `readline.Interface` class are constructed using the`readline.createInterface()` method. Every instance is associated with a
49
- * single `input` `Readable` stream and a single `output` `Writable` stream.
50
- * The `output` stream is used to print prompts for user input that arrives on,
51
- * and is read from, the `input` stream.
52
- * @since v0.1.104
53
- */
54
- export class Interface extends EventEmitter {
55
- readonly terminal: boolean;
56
- /**
57
- * The current input data being processed by node.
58
- *
59
- * This can be used when collecting input from a TTY stream to retrieve the
60
- * current value that has been processed thus far, prior to the `line` event
61
- * being emitted. Once the `line` event has been emitted, this property will
62
- * be an empty string.
63
- *
64
- * Be aware that modifying the value during the instance runtime may have
65
- * unintended consequences if `rl.cursor` is not also controlled.
66
- *
67
- * **If not using a TTY stream for input, use the `'line'` event.**
68
- *
69
- * One possible use case would be as follows:
70
- *
71
- * ```js
72
- * const values = ['lorem ipsum', 'dolor sit amet'];
73
- * const rl = readline.createInterface(process.stdin);
74
- * const showResults = debounce(() => {
75
- * console.log(
76
- * '\n',
77
- * values.filter((val) => val.startsWith(rl.line)).join(' ')
78
- * );
79
- * }, 300);
80
- * process.stdin.on('keypress', (c, k) => {
81
- * showResults();
82
- * });
83
- * ```
84
- * @since v0.1.98
85
- */
86
- readonly line: string;
87
- /**
88
- * The cursor position relative to `rl.line`.
89
- *
90
- * This will track where the current cursor lands in the input string, when
91
- * reading input from a TTY stream. The position of cursor determines the
92
- * portion of the input string that will be modified as input is processed,
93
- * as well as the column where the terminal caret will be rendered.
94
- * @since v0.1.98
95
- */
96
- readonly cursor: number;
97
- /**
98
- * NOTE: According to the documentation:
99
- *
100
- * > Instances of the `readline.Interface` class are constructed using the
101
- * > `readline.createInterface()` method.
102
- *
103
- * @see https://nodejs.org/docs/latest-v18.x/api/readline.html#readline_class_interface
104
- */
105
- protected constructor(
106
- input: NodeJS.ReadableStream,
107
- output?: NodeJS.WritableStream,
108
- completer?: Completer | AsyncCompleter,
109
- terminal?: boolean,
110
- );
111
- /**
112
- * NOTE: According to the documentation:
113
- *
114
- * > Instances of the `readline.Interface` class are constructed using the
115
- * > `readline.createInterface()` method.
116
- *
117
- * @see https://nodejs.org/docs/latest-v18.x/api/readline.html#readline_class_interface
118
- */
119
- protected constructor(options: ReadLineOptions);
120
- /**
121
- * The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`.
122
- * @since v15.3.0
123
- * @return the current prompt string
124
- */
125
- getPrompt(): string;
126
- /**
127
- * The `rl.setPrompt()` method sets the prompt that will be written to `output`whenever `rl.prompt()` is called.
128
- * @since v0.1.98
129
- */
130
- setPrompt(prompt: string): void;
131
- /**
132
- * The `rl.prompt()` method writes the `readline.Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new
133
- * location at which to provide input.
134
- *
135
- * When called, `rl.prompt()` will resume the `input` stream if it has been
136
- * paused.
137
- *
138
- * If the `readline.Interface` was created with `output` set to `null` or`undefined` the prompt is not written.
139
- * @since v0.1.98
140
- * @param preserveCursor If `true`, prevents the cursor placement from being reset to `0`.
141
- */
142
- prompt(preserveCursor?: boolean): void;
143
- /**
144
- * The `rl.question()` method displays the `query` by writing it to the `output`,
145
- * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument.
146
- *
147
- * When called, `rl.question()` will resume the `input` stream if it has been
148
- * paused.
149
- *
150
- * If the `readline.Interface` was created with `output` set to `null` or`undefined` the `query` is not written.
151
- *
152
- * The `callback` function passed to `rl.question()` does not follow the typical
153
- * pattern of accepting an `Error` object or `null` as the first argument.
154
- * The `callback` is called with the provided answer as the only argument.
155
- *
156
- * Example usage:
157
- *
158
- * ```js
159
- * rl.question('What is your favorite food? ', (answer) => {
160
- * console.log(`Oh, so your favorite food is ${answer}`);
161
- * });
162
- * ```
163
- *
164
- * Using an `AbortController` to cancel a question.
165
- *
166
- * ```js
167
- * const ac = new AbortController();
168
- * const signal = ac.signal;
169
- *
170
- * rl.question('What is your favorite food? ', { signal }, (answer) => {
171
- * console.log(`Oh, so your favorite food is ${answer}`);
172
- * });
173
- *
174
- * signal.addEventListener('abort', () => {
175
- * console.log('The food question timed out');
176
- * }, { once: true });
177
- *
178
- * setTimeout(() => ac.abort(), 10000);
179
- * ```
180
- *
181
- * If this method is invoked as it's util.promisify()ed version, it returns a
182
- * Promise that fulfills with the answer. If the question is canceled using
183
- * an `AbortController` it will reject with an `AbortError`.
184
- *
185
- * ```js
186
- * import util from 'node:util';
187
- * const question = util.promisify(rl.question).bind(rl);
188
- *
189
- * async function questionExample() {
190
- * try {
191
- * const answer = await question('What is you favorite food? ');
192
- * console.log(`Oh, so your favorite food is ${answer}`);
193
- * } catch (err) {
194
- * console.error('Question rejected', err);
195
- * }
196
- * }
197
- * questionExample();
198
- * ```
199
- * @since v0.3.3
200
- * @param query A statement or query to write to `output`, prepended to the prompt.
201
- * @param callback A callback function that is invoked with the user's input in response to the `query`.
202
- */
203
- question(query: string, callback: (answer: string) => void): void;
204
- question(query: string, options: Abortable, callback: (answer: string) => void): void;
205
- /**
206
- * The `rl.pause()` method pauses the `input` stream, allowing it to be resumed
207
- * later if necessary.
208
- *
209
- * Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `readline.Interface` instance.
210
- * @since v0.3.4
211
- */
212
- pause(): this;
213
- /**
214
- * The `rl.resume()` method resumes the `input` stream if it has been paused.
215
- * @since v0.3.4
216
- */
217
- resume(): this;
218
- /**
219
- * The `rl.close()` method closes the `readline.Interface` instance and
220
- * relinquishes control over the `input` and `output` streams. When called,
221
- * the `'close'` event will be emitted.
222
- *
223
- * Calling `rl.close()` does not immediately stop other events (including `'line'`)
224
- * from being emitted by the `readline.Interface` instance.
225
- * @since v0.1.98
226
- */
227
- close(): void;
228
- /**
229
- * The `rl.write()` method will write either `data` or a key sequence identified
230
- * by `key` to the `output`. The `key` argument is supported only if `output` is
231
- * a `TTY` text terminal. See `TTY keybindings` for a list of key
232
- * combinations.
233
- *
234
- * If `key` is specified, `data` is ignored.
235
- *
236
- * When called, `rl.write()` will resume the `input` stream if it has been
237
- * paused.
238
- *
239
- * If the `readline.Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written.
240
- *
241
- * ```js
242
- * rl.write('Delete this!');
243
- * // Simulate Ctrl+U to delete the line written previously
244
- * rl.write(null, { ctrl: true, name: 'u' });
245
- * ```
246
- *
247
- * The `rl.write()` method will write the data to the `readline` `Interface`'s`input`_as if it were provided by the user_.
248
- * @since v0.1.98
249
- */
250
- write(data: string | Buffer, key?: Key): void;
251
- write(data: undefined | null | string | Buffer, key: Key): void;
252
- /**
253
- * Returns the real position of the cursor in relation to the input
254
- * prompt + string. Long input (wrapping) strings, as well as multiple
255
- * line prompts are included in the calculations.
256
- * @since v13.5.0, v12.16.0
257
- */
258
- getCursorPos(): CursorPos;
259
- /**
260
- * events.EventEmitter
261
- * 1. close
262
- * 2. line
263
- * 3. pause
264
- * 4. resume
265
- * 5. SIGCONT
266
- * 6. SIGINT
267
- * 7. SIGTSTP
268
- * 8. history
269
- */
270
- addListener(event: string, listener: (...args: any[]) => void): this;
271
- addListener(event: "close", listener: () => void): this;
272
- addListener(event: "line", listener: (input: string) => void): this;
273
- addListener(event: "pause", listener: () => void): this;
274
- addListener(event: "resume", listener: () => void): this;
275
- addListener(event: "SIGCONT", listener: () => void): this;
276
- addListener(event: "SIGINT", listener: () => void): this;
277
- addListener(event: "SIGTSTP", listener: () => void): this;
278
- addListener(event: "history", listener: (history: string[]) => void): this;
279
- emit(event: string | symbol, ...args: any[]): boolean;
280
- emit(event: "close"): boolean;
281
- emit(event: "line", input: string): boolean;
282
- emit(event: "pause"): boolean;
283
- emit(event: "resume"): boolean;
284
- emit(event: "SIGCONT"): boolean;
285
- emit(event: "SIGINT"): boolean;
286
- emit(event: "SIGTSTP"): boolean;
287
- emit(event: "history", history: string[]): boolean;
288
- on(event: string, listener: (...args: any[]) => void): this;
289
- on(event: "close", listener: () => void): this;
290
- on(event: "line", listener: (input: string) => void): this;
291
- on(event: "pause", listener: () => void): this;
292
- on(event: "resume", listener: () => void): this;
293
- on(event: "SIGCONT", listener: () => void): this;
294
- on(event: "SIGINT", listener: () => void): this;
295
- on(event: "SIGTSTP", listener: () => void): this;
296
- on(event: "history", listener: (history: string[]) => void): this;
297
- once(event: string, listener: (...args: any[]) => void): this;
298
- once(event: "close", listener: () => void): this;
299
- once(event: "line", listener: (input: string) => void): this;
300
- once(event: "pause", listener: () => void): this;
301
- once(event: "resume", listener: () => void): this;
302
- once(event: "SIGCONT", listener: () => void): this;
303
- once(event: "SIGINT", listener: () => void): this;
304
- once(event: "SIGTSTP", listener: () => void): this;
305
- once(event: "history", listener: (history: string[]) => void): this;
306
- prependListener(event: string, listener: (...args: any[]) => void): this;
307
- prependListener(event: "close", listener: () => void): this;
308
- prependListener(event: "line", listener: (input: string) => void): this;
309
- prependListener(event: "pause", listener: () => void): this;
310
- prependListener(event: "resume", listener: () => void): this;
311
- prependListener(event: "SIGCONT", listener: () => void): this;
312
- prependListener(event: "SIGINT", listener: () => void): this;
313
- prependListener(event: "SIGTSTP", listener: () => void): this;
314
- prependListener(event: "history", listener: (history: string[]) => void): this;
315
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
316
- prependOnceListener(event: "close", listener: () => void): this;
317
- prependOnceListener(event: "line", listener: (input: string) => void): this;
318
- prependOnceListener(event: "pause", listener: () => void): this;
319
- prependOnceListener(event: "resume", listener: () => void): this;
320
- prependOnceListener(event: "SIGCONT", listener: () => void): this;
321
- prependOnceListener(event: "SIGINT", listener: () => void): this;
322
- prependOnceListener(event: "SIGTSTP", listener: () => void): this;
323
- prependOnceListener(event: "history", listener: (history: string[]) => void): this;
324
- [Symbol.asyncIterator](): NodeJS.AsyncIterator<string>;
325
- }
326
- export type ReadLine = Interface; // type forwarded for backwards compatibility
327
- export type Completer = (line: string) => CompleterResult;
328
- export type AsyncCompleter = (
329
- line: string,
330
- callback: (err?: null | Error, result?: CompleterResult) => void,
331
- ) => void;
332
- export type CompleterResult = [string[], string];
333
- export interface ReadLineOptions {
334
- /**
335
- * The [`Readable`](https://nodejs.org/docs/latest-v18.x/api/stream.html#readable-streams) stream to listen to
336
- */
337
- input: NodeJS.ReadableStream;
338
- /**
339
- * The [`Writable`](https://nodejs.org/docs/latest-v18.x/api/stream.html#writable-streams) stream to write readline data to.
340
- */
341
- output?: NodeJS.WritableStream | undefined;
342
- /**
343
- * An optional function used for Tab autocompletion.
344
- */
345
- completer?: Completer | AsyncCompleter | undefined;
346
- /**
347
- * `true` if the `input` and `output` streams should be treated like a TTY,
348
- * and have ANSI/VT100 escape codes written to it.
349
- * Default: checking `isTTY` on the `output` stream upon instantiation.
350
- */
351
- terminal?: boolean | undefined;
352
- /**
353
- * Initial list of history lines.
354
- * This option makes sense only if `terminal` is set to `true` by the user or by an internal `output` check,
355
- * otherwise the history caching mechanism is not initialized at all.
356
- * @default []
357
- */
358
- history?: string[] | undefined;
359
- /**
360
- * Maximum number of history lines retained.
361
- * To disable the history set this value to `0`.
362
- * This option makes sense only if `terminal` is set to `true` by the user or by an internal `output` check,
363
- * otherwise the history caching mechanism is not initialized at all.
364
- * @default 30
365
- */
366
- historySize?: number | undefined;
367
- /**
368
- * If `true`, when a new input line added to the history list duplicates an older one,
369
- * this removes the older line from the list.
370
- * @default false
371
- */
372
- removeHistoryDuplicates?: boolean | undefined;
373
- /**
374
- * The prompt string to use.
375
- * @default "> "
376
- */
377
- prompt?: string | undefined;
378
- /**
379
- * If the delay between `\r` and `\n` exceeds `crlfDelay` milliseconds,
380
- * both `\r` and `\n` will be treated as separate end-of-line input.
381
- * `crlfDelay` will be coerced to a number no less than `100`.
382
- * It can be set to `Infinity`, in which case
383
- * `\r` followed by `\n` will always be considered a single newline
384
- * (which may be reasonable for [reading files](https://nodejs.org/docs/latest-v18.x/api/readline.html#example-read-file-stream-line-by-line) with `\r\n` line delimiter).
385
- * @default 100
386
- */
387
- crlfDelay?: number | undefined;
388
- /**
389
- * The duration `readline` will wait for a character
390
- * (when reading an ambiguous key sequence in milliseconds
391
- * one that can both form a complete key sequence using the input read so far
392
- * and can take additional input to complete a longer key sequence).
393
- * @default 500
394
- */
395
- escapeCodeTimeout?: number | undefined;
396
- /**
397
- * The number of spaces a tab is equal to (minimum 1).
398
- * @default 8
399
- */
400
- tabSize?: number | undefined;
401
- /**
402
- * Allows closing the interface using an AbortSignal.
403
- * Aborting the signal will internally call `close` on the interface.
404
- */
405
- signal?: AbortSignal | undefined;
406
- }
407
- /**
408
- * The `readline.createInterface()` method creates a new `readline.Interface`instance.
409
- *
410
- * ```js
411
- * import readline from 'node:readline';
412
- * const rl = readline.createInterface({
413
- * input: process.stdin,
414
- * output: process.stdout
415
- * });
416
- * ```
417
- *
418
- * Once the `readline.Interface` instance is created, the most common case is to
419
- * listen for the `'line'` event:
420
- *
421
- * ```js
422
- * rl.on('line', (line) => {
423
- * console.log(`Received: ${line}`);
424
- * });
425
- * ```
426
- *
427
- * If `terminal` is `true` for this instance then the `output` stream will get
428
- * the best compatibility if it defines an `output.columns` property and emits
429
- * a `'resize'` event on the `output` if or when the columns ever change
430
- * (`process.stdout` does this automatically when it is a TTY).
431
- *
432
- * When creating a `readline.Interface` using `stdin` as input, the program
433
- * will not terminate until it receives `EOF` (Ctrl+D on
434
- * Linux/macOS, Ctrl+Z followed by Return on
435
- * Windows).
436
- * If you want your application to exit without waiting for user input, you can `unref()` the standard input stream:
437
- *
438
- * ```js
439
- * process.stdin.unref();
440
- * ```
441
- * @since v0.1.98
442
- */
443
- export function createInterface(
444
- input: NodeJS.ReadableStream,
445
- output?: NodeJS.WritableStream,
446
- completer?: Completer | AsyncCompleter,
447
- terminal?: boolean,
448
- ): Interface;
449
- export function createInterface(options: ReadLineOptions): Interface;
450
- /**
451
- * The `readline.emitKeypressEvents()` method causes the given `Readable` stream to begin emitting `'keypress'` events corresponding to received input.
452
- *
453
- * Optionally, `interface` specifies a `readline.Interface` instance for which
454
- * autocompletion is disabled when copy-pasted input is detected.
455
- *
456
- * If the `stream` is a `TTY`, then it must be in raw mode.
457
- *
458
- * This is automatically called by any readline instance on its `input` if the`input` is a terminal. Closing the `readline` instance does not stop
459
- * the `input` from emitting `'keypress'` events.
460
- *
461
- * ```js
462
- * readline.emitKeypressEvents(process.stdin);
463
- * if (process.stdin.isTTY)
464
- * process.stdin.setRawMode(true);
465
- * ```
466
- *
467
- * ## Example: Tiny CLI
468
- *
469
- * The following example illustrates the use of `readline.Interface` class to
470
- * implement a small command-line interface:
471
- *
472
- * ```js
473
- * import readline from 'node:readline';
474
- * const rl = readline.createInterface({
475
- * input: process.stdin,
476
- * output: process.stdout,
477
- * prompt: 'OHAI> '
478
- * });
479
- *
480
- * rl.prompt();
481
- *
482
- * rl.on('line', (line) => {
483
- * switch (line.trim()) {
484
- * case 'hello':
485
- * console.log('world!');
486
- * break;
487
- * default:
488
- * console.log(`Say what? I might have heard '${line.trim()}'`);
489
- * break;
490
- * }
491
- * rl.prompt();
492
- * }).on('close', () => {
493
- * console.log('Have a great day!');
494
- * process.exit(0);
495
- * });
496
- * ```
497
- *
498
- * ## Example: Read file stream line-by-Line
499
- *
500
- * A common use case for `readline` is to consume an input file one line at a
501
- * time. The easiest way to do so is leveraging the `fs.ReadStream` API as
502
- * well as a `for await...of` loop:
503
- *
504
- * ```js
505
- * import fs from 'node:fs';
506
- * import readline from 'node:readline';
507
- *
508
- * async function processLineByLine() {
509
- * const fileStream = fs.createReadStream('input.txt');
510
- *
511
- * const rl = readline.createInterface({
512
- * input: fileStream,
513
- * crlfDelay: Infinity
514
- * });
515
- * // Note: we use the crlfDelay option to recognize all instances of CR LF
516
- * // ('\r\n') in input.txt as a single line break.
517
- *
518
- * for await (const line of rl) {
519
- * // Each line in input.txt will be successively available here as `line`.
520
- * console.log(`Line from file: ${line}`);
521
- * }
522
- * }
523
- *
524
- * processLineByLine();
525
- * ```
526
- *
527
- * Alternatively, one could use the `'line'` event:
528
- *
529
- * ```js
530
- * import fs from 'node:fs';
531
- * import readline from 'node:readline';
532
- *
533
- * const rl = readline.createInterface({
534
- * input: fs.createReadStream('sample.txt'),
535
- * crlfDelay: Infinity
536
- * });
537
- *
538
- * rl.on('line', (line) => {
539
- * console.log(`Line from file: ${line}`);
540
- * });
541
- * ```
542
- *
543
- * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied:
544
- *
545
- * ```js
546
- * import { once } from 'node:events';
547
- * import { createReadStream } from 'node:fs';
548
- * import { createInterface } from 'node:readline';
549
- *
550
- * (async function processLineByLine() {
551
- * try {
552
- * const rl = createInterface({
553
- * input: createReadStream('big-file.txt'),
554
- * crlfDelay: Infinity
555
- * });
556
- *
557
- * rl.on('line', (line) => {
558
- * // Process the line.
559
- * });
560
- *
561
- * await once(rl, 'close');
562
- *
563
- * console.log('File processed.');
564
- * } catch (err) {
565
- * console.error(err);
566
- * }
567
- * })();
568
- * ```
569
- * @since v0.7.7
570
- */
571
- export function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
572
- export type Direction = -1 | 0 | 1;
573
- export interface CursorPos {
574
- rows: number;
575
- cols: number;
576
- }
577
- /**
578
- * The `readline.clearLine()` method clears current line of given `TTY` stream
579
- * in a specified direction identified by `dir`.
580
- * @since v0.7.7
581
- * @param callback Invoked once the operation completes.
582
- * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
583
- */
584
- export function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
585
- /**
586
- * The `readline.clearScreenDown()` method clears the given `TTY` stream from
587
- * the current position of the cursor down.
588
- * @since v0.7.7
589
- * @param callback Invoked once the operation completes.
590
- * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
591
- */
592
- export function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
593
- /**
594
- * The `readline.cursorTo()` method moves cursor to the specified position in a
595
- * given `TTY` `stream`.
596
- * @since v0.7.7
597
- * @param callback Invoked once the operation completes.
598
- * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
599
- */
600
- export function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
601
- /**
602
- * The `readline.moveCursor()` method moves the cursor _relative_ to its current
603
- * position in a given `TTY` `stream`.
604
- *
605
- * ## Example: Tiny CLI
606
- *
607
- * The following example illustrates the use of `readline.Interface` class to
608
- * implement a small command-line interface:
609
- *
610
- * ```js
611
- * import readline from 'node:readline';
612
- * const rl = readline.createInterface({
613
- * input: process.stdin,
614
- * output: process.stdout,
615
- * prompt: 'OHAI> '
616
- * });
617
- *
618
- * rl.prompt();
619
- *
620
- * rl.on('line', (line) => {
621
- * switch (line.trim()) {
622
- * case 'hello':
623
- * console.log('world!');
624
- * break;
625
- * default:
626
- * console.log(`Say what? I might have heard '${line.trim()}'`);
627
- * break;
628
- * }
629
- * rl.prompt();
630
- * }).on('close', () => {
631
- * console.log('Have a great day!');
632
- * process.exit(0);
633
- * });
634
- * ```
635
- *
636
- * ## Example: Read file stream line-by-Line
637
- *
638
- * A common use case for `readline` is to consume an input file one line at a
639
- * time. The easiest way to do so is leveraging the `fs.ReadStream` API as
640
- * well as a `for await...of` loop:
641
- *
642
- * ```js
643
- * import fs from 'node:fs';
644
- * import readline from 'node:readline';
645
- *
646
- * async function processLineByLine() {
647
- * const fileStream = fs.createReadStream('input.txt');
648
- *
649
- * const rl = readline.createInterface({
650
- * input: fileStream,
651
- * crlfDelay: Infinity
652
- * });
653
- * // Note: we use the crlfDelay option to recognize all instances of CR LF
654
- * // ('\r\n') in input.txt as a single line break.
655
- *
656
- * for await (const line of rl) {
657
- * // Each line in input.txt will be successively available here as `line`.
658
- * console.log(`Line from file: ${line}`);
659
- * }
660
- * }
661
- *
662
- * processLineByLine();
663
- * ```
664
- *
665
- * Alternatively, one could use the `'line'` event:
666
- *
667
- * ```js
668
- * import fs from 'node:fs';
669
- * import readline from 'node:readline';
670
- *
671
- * const rl = readline.createInterface({
672
- * input: fs.createReadStream('sample.txt'),
673
- * crlfDelay: Infinity
674
- * });
675
- *
676
- * rl.on('line', (line) => {
677
- * console.log(`Line from file: ${line}`);
678
- * });
679
- * ```
680
- *
681
- * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied:
682
- *
683
- * ```js
684
- * import { once } from 'node:events';
685
- * import { createReadStream } from 'node:fs';
686
- * import { createInterface } from 'node:readline';
687
- *
688
- * (async function processLineByLine() {
689
- * try {
690
- * const rl = createInterface({
691
- * input: createReadStream('big-file.txt'),
692
- * crlfDelay: Infinity
693
- * });
694
- *
695
- * rl.on('line', (line) => {
696
- * // Process the line.
697
- * });
698
- *
699
- * await once(rl, 'close');
700
- *
701
- * console.log('File processed.');
702
- * } catch (err) {
703
- * console.error(err);
704
- * }
705
- * })();
706
- * ```
707
- * @since v0.7.7
708
- * @param callback Invoked once the operation completes.
709
- * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
710
- */
711
- export function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
712
- }
713
- declare module "node:readline" {
714
- export * from "readline";
715
- }