caique 0.1.1 → 0.3.0
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/README.md +62 -9
- package/dist/ask.js +0 -46
- package/dist/binding.js +0 -30
- package/dist/clack.d.ts +44 -0
- package/dist/clack.js +97 -0
- package/dist/decide.js +0 -33
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -7
- package/dist/inquirer-errors.d.ts +38 -0
- package/dist/inquirer-errors.js +21 -0
- package/dist/inquirer-hooks.d.ts +86 -0
- package/dist/inquirer-hooks.js +124 -0
- package/dist/inquirer-keys.d.ts +31 -0
- package/dist/inquirer-keys.js +22 -0
- package/dist/inquirer-screen.d.ts +131 -0
- package/dist/inquirer-screen.js +122 -0
- package/dist/inquirer-theme.d.ts +58 -0
- package/dist/inquirer-theme.js +51 -0
- package/dist/inquirer.d.ts +72 -0
- package/dist/inquirer.js +207 -0
- package/dist/plugin.d.ts +81 -0
- package/dist/plugin.js +99 -0
- package/dist/raw.d.ts +3 -17
- package/dist/raw.js +7 -50
- package/dist/runtime.d.ts +31 -0
- package/dist/runtime.js +6 -0
- package/dist/schema.json +1 -0
- package/dist/spec.d.ts +23 -2
- package/dist/spec.js +1 -18
- package/dist/terminal.d.ts +8 -2
- package/dist/terminal.js +3 -33
- package/package.json +22 -2
package/dist/spec.js
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* What a prompt *is*, before anything draws one (R1).
|
|
3
|
-
*
|
|
4
|
-
* A `PromptSpec` hangs off an option, not off a call site, and that is the whole
|
|
5
|
-
* inversion: the option is the thing that exists in the manifest, in `--help`, in the MCP
|
|
6
|
-
* tool schema and on the command line, and the prompt is one more projection of it. A
|
|
7
|
-
* program written this way can be answered by a flag, by an environment variable, by a
|
|
8
|
-
* config file or by a person, and nothing in it has to know which happened.
|
|
9
|
-
*
|
|
10
|
-
* Nothing here imports a runtime, a stream or a terminal. This file is data.
|
|
11
|
-
*/
|
|
12
|
-
/** `--output-dir`, which is what a refusal has to say to be actionable. */
|
|
1
|
+
export const BUILT_IN_KINDS = new Set(['text', 'confirm', 'select', 'multiselect', 'password', 'path']);
|
|
13
2
|
export function flagOf(option) {
|
|
14
3
|
return `--${option}`;
|
|
15
4
|
}
|
|
16
|
-
/**
|
|
17
|
-
* A `select` without choices, or a `confirm` with them, is a spec that cannot be drawn.
|
|
18
|
-
* Caught here rather than in the widget, so a program with a malformed prompt fails on the
|
|
19
|
-
* first run instead of the first time someone reaches that option.
|
|
20
|
-
*/
|
|
21
5
|
export function problemWith(spec) {
|
|
22
6
|
const needsChoices = spec.kind === 'select' || spec.kind === 'multiselect';
|
|
23
7
|
if (needsChoices && (spec.choices === undefined || spec.choices.length === 0))
|
|
@@ -28,4 +12,3 @@ export function problemWith(spec) {
|
|
|
28
12
|
return 'a prompt needs a message: it is what a person is asked, and what an agent is told when it cannot be';
|
|
29
13
|
return undefined;
|
|
30
14
|
}
|
|
31
|
-
//# sourceMappingURL=spec.js.map
|
package/dist/terminal.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Io } from './ask.js';
|
|
2
|
-
|
|
2
|
+
import { type Runtime } from './runtime.js';
|
|
3
|
+
/** The stream pair a terminal Io is built over: a `Runtime`'s `stdin` and its `stdout`. */
|
|
3
4
|
export interface Streams {
|
|
4
5
|
input: NodeJS.ReadableStream & {
|
|
5
6
|
isTTY?: boolean;
|
|
@@ -8,13 +9,18 @@ export interface Streams {
|
|
|
8
9
|
isTTY?: boolean;
|
|
9
10
|
};
|
|
10
11
|
}
|
|
12
|
+
/** A runtime's two streams as the pair `createIo` takes — the mapping, written down once. */
|
|
13
|
+
export declare const streamsOf: (runtime: Runtime) => Streams;
|
|
11
14
|
/**
|
|
12
15
|
* A reader and writer over a real stream pair.
|
|
13
16
|
*
|
|
14
17
|
* The reader resolves `undefined` when the stream ends, which `ask()` reads as a
|
|
15
18
|
* cancellation — `Ctrl-D` and a closed pipe both arrive that way, and both mean nobody is
|
|
16
19
|
* going to type.
|
|
20
|
+
*
|
|
21
|
+
* With no argument it builds over the real process, read when it is called and not at
|
|
22
|
+
* import: a program that wants the terminal it was started in writes `createIo()`.
|
|
17
23
|
*/
|
|
18
|
-
export declare function createIo(streams
|
|
24
|
+
export declare function createIo(streams?: Streams): Io & {
|
|
19
25
|
close: () => void;
|
|
20
26
|
};
|
package/dist/terminal.js
CHANGED
|
@@ -1,43 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A `Reader` and `Writer` over real streams — the one file in this package that touches a
|
|
3
|
-
* terminal, and the reason `ask()` can be used by a program rather than only by a test.
|
|
4
|
-
*
|
|
5
|
-
* Everything above this is strings in and strings out. That is deliberate: the widgets, the
|
|
6
|
-
* decision and the binding are all testable without a PTY, and this is the thin layer that
|
|
7
|
-
* has to be got right once. It reads lines through `node:readline`, which handles the
|
|
8
|
-
* line editing, the backspace and the `Ctrl-D` a person expects.
|
|
9
|
-
*
|
|
10
|
-
* **Hiding a password happens here**, because this is the only layer that knows what echo
|
|
11
|
-
* is. `ask()` says which prompts are hidden; nothing above has to remember to mute anything,
|
|
12
|
-
* and a widget cannot leak a secret by writing it, since no widget writes what it read.
|
|
13
|
-
*/
|
|
14
1
|
import { createInterface } from 'node:readline';
|
|
15
|
-
import {} from './
|
|
16
|
-
|
|
2
|
+
import { processRuntime } from './runtime.js';
|
|
3
|
+
export const streamsOf = (runtime) => ({ input: runtime.stdin, output: runtime.stdout });
|
|
17
4
|
const swallow = () => true;
|
|
18
|
-
/**
|
|
19
|
-
* `readline` echoes what it reads. For a hidden answer the echo is suppressed by
|
|
20
|
-
* intercepting the interface's own output for the duration of the question — not by
|
|
21
|
-
* turning the terminal's echo off, which would leave it off if the process died mid-prompt.
|
|
22
|
-
*/
|
|
23
5
|
function mute(rl, streams) {
|
|
24
6
|
const target = rl.output ?? streams.output;
|
|
25
7
|
const original = target.write.bind(target);
|
|
26
|
-
// `readline` writes the prompt through the same stream it echoes through, so the prompt
|
|
27
|
-
// has already been written by the time this is installed: everything after it is input.
|
|
28
8
|
target.write = swallow;
|
|
29
9
|
return () => {
|
|
30
10
|
target.write = original;
|
|
31
11
|
};
|
|
32
12
|
}
|
|
33
|
-
|
|
34
|
-
* A reader and writer over a real stream pair.
|
|
35
|
-
*
|
|
36
|
-
* The reader resolves `undefined` when the stream ends, which `ask()` reads as a
|
|
37
|
-
* cancellation — `Ctrl-D` and a closed pipe both arrive that way, and both mean nobody is
|
|
38
|
-
* going to type.
|
|
39
|
-
*/
|
|
40
|
-
export function createIo(streams) {
|
|
13
|
+
export function createIo(streams = streamsOf(processRuntime())) {
|
|
41
14
|
const rl = createInterface({ input: streams.input, output: streams.output, terminal: streams.output.isTTY === true });
|
|
42
15
|
let ended = false;
|
|
43
16
|
rl.once('close', () => {
|
|
@@ -64,8 +37,6 @@ export function createIo(streams) {
|
|
|
64
37
|
}
|
|
65
38
|
finally {
|
|
66
39
|
unmute?.();
|
|
67
|
-
// The newline the person typed was swallowed with the echo; put it back so the
|
|
68
|
-
// next question does not start on the same line as the hidden answer.
|
|
69
40
|
if (hidden)
|
|
70
41
|
streams.output.write('\n');
|
|
71
42
|
}
|
|
@@ -78,4 +49,3 @@ export function createIo(streams) {
|
|
|
78
49
|
};
|
|
79
50
|
return { reader, writer, close: () => rl.close() };
|
|
80
51
|
}
|
|
81
|
-
//# sourceMappingURL=terminal.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caique",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The parrot that always answers back, and the boat that goes between ship and shore. Prompts that are flags first, so agents answer before they are asked and non-TTY callers get an error naming the flag, never a hang. Drop-in path for inquirer and clack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,16 +23,32 @@
|
|
|
23
23
|
"import": "./dist/binding.js",
|
|
24
24
|
"default": "./dist/binding.js"
|
|
25
25
|
},
|
|
26
|
+
"./clack": {
|
|
27
|
+
"types": "./dist/clack.d.ts",
|
|
28
|
+
"import": "./dist/clack.js",
|
|
29
|
+
"default": "./dist/clack.js"
|
|
30
|
+
},
|
|
26
31
|
"./decide": {
|
|
27
32
|
"types": "./dist/decide.d.ts",
|
|
28
33
|
"import": "./dist/decide.js",
|
|
29
34
|
"default": "./dist/decide.js"
|
|
30
35
|
},
|
|
36
|
+
"./inquirer": {
|
|
37
|
+
"types": "./dist/inquirer.d.ts",
|
|
38
|
+
"import": "./dist/inquirer.js",
|
|
39
|
+
"default": "./dist/inquirer.js"
|
|
40
|
+
},
|
|
41
|
+
"./plugin": {
|
|
42
|
+
"types": "./dist/plugin.d.ts",
|
|
43
|
+
"import": "./dist/plugin.js",
|
|
44
|
+
"default": "./dist/plugin.js"
|
|
45
|
+
},
|
|
31
46
|
"./raw": {
|
|
32
47
|
"types": "./dist/raw.d.ts",
|
|
33
48
|
"import": "./dist/raw.js",
|
|
34
49
|
"default": "./dist/raw.js"
|
|
35
50
|
},
|
|
51
|
+
"./schema.json": "./dist/schema.json",
|
|
36
52
|
"./spec": {
|
|
37
53
|
"types": "./dist/spec.d.ts",
|
|
38
54
|
"import": "./dist/spec.js",
|
|
@@ -50,7 +66,7 @@
|
|
|
50
66
|
"!dist/**/*.test.*"
|
|
51
67
|
],
|
|
52
68
|
"scripts": {
|
|
53
|
-
"build": "tsc -p tsconfig.build.json",
|
|
69
|
+
"build": "tsc -p tsconfig.build.json && node ../../scripts/schema-to-dist.mjs && node ../../scripts/strip-comments.mjs dist",
|
|
54
70
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
55
71
|
"test": "vitest run --passWithNoTests",
|
|
56
72
|
"coverage": "vitest run --coverage.enabled",
|
|
@@ -76,6 +92,10 @@
|
|
|
76
92
|
"agent",
|
|
77
93
|
"non-tty"
|
|
78
94
|
],
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"closeout": "^0.2.1",
|
|
97
|
+
"linegauge": "^0.3.1"
|
|
98
|
+
},
|
|
79
99
|
"devDependencies": {
|
|
80
100
|
"vitest": "^5.0.0"
|
|
81
101
|
}
|