inquirer-ai 0.2.1

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 (81) hide show
  1. package/dist/agent.d.ts +7 -0
  2. package/dist/agent.d.ts.map +1 -0
  3. package/dist/agent.js +143 -0
  4. package/dist/agent.js.map +1 -0
  5. package/dist/choice.d.ts +18 -0
  6. package/dist/choice.d.ts.map +1 -0
  7. package/dist/choice.js +29 -0
  8. package/dist/choice.js.map +1 -0
  9. package/dist/errors.d.ts +16 -0
  10. package/dist/errors.d.ts.map +1 -0
  11. package/dist/errors.js +31 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/index.d.ts +43 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +66 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/mode.d.ts +2 -0
  18. package/dist/mode.d.ts.map +1 -0
  19. package/dist/mode.js +10 -0
  20. package/dist/mode.js.map +1 -0
  21. package/dist/prompts/autocomplete.d.ts +13 -0
  22. package/dist/prompts/autocomplete.d.ts.map +1 -0
  23. package/dist/prompts/autocomplete.js +29 -0
  24. package/dist/prompts/autocomplete.js.map +1 -0
  25. package/dist/prompts/base.d.ts +27 -0
  26. package/dist/prompts/base.d.ts.map +1 -0
  27. package/dist/prompts/base.js +107 -0
  28. package/dist/prompts/base.js.map +1 -0
  29. package/dist/prompts/checkbox.d.ts +22 -0
  30. package/dist/prompts/checkbox.d.ts.map +1 -0
  31. package/dist/prompts/checkbox.js +168 -0
  32. package/dist/prompts/checkbox.js.map +1 -0
  33. package/dist/prompts/confirm.d.ts +12 -0
  34. package/dist/prompts/confirm.d.ts.map +1 -0
  35. package/dist/prompts/confirm.js +40 -0
  36. package/dist/prompts/confirm.js.map +1 -0
  37. package/dist/prompts/editor.d.ts +13 -0
  38. package/dist/prompts/editor.d.ts.map +1 -0
  39. package/dist/prompts/editor.js +54 -0
  40. package/dist/prompts/editor.js.map +1 -0
  41. package/dist/prompts/expand.d.ts +19 -0
  42. package/dist/prompts/expand.d.ts.map +1 -0
  43. package/dist/prompts/expand.js +72 -0
  44. package/dist/prompts/expand.js.map +1 -0
  45. package/dist/prompts/number.d.ts +17 -0
  46. package/dist/prompts/number.d.ts.map +1 -0
  47. package/dist/prompts/number.js +73 -0
  48. package/dist/prompts/number.js.map +1 -0
  49. package/dist/prompts/password.d.ts +14 -0
  50. package/dist/prompts/password.d.ts.map +1 -0
  51. package/dist/prompts/password.js +30 -0
  52. package/dist/prompts/password.js.map +1 -0
  53. package/dist/prompts/path.d.ts +13 -0
  54. package/dist/prompts/path.d.ts.map +1 -0
  55. package/dist/prompts/path.js +29 -0
  56. package/dist/prompts/path.js.map +1 -0
  57. package/dist/prompts/rawlist.d.ts +15 -0
  58. package/dist/prompts/rawlist.d.ts.map +1 -0
  59. package/dist/prompts/rawlist.js +55 -0
  60. package/dist/prompts/rawlist.js.map +1 -0
  61. package/dist/prompts/search.d.ts +17 -0
  62. package/dist/prompts/search.d.ts.map +1 -0
  63. package/dist/prompts/search.js +85 -0
  64. package/dist/prompts/search.js.map +1 -0
  65. package/dist/prompts/select.d.ts +22 -0
  66. package/dist/prompts/select.d.ts.map +1 -0
  67. package/dist/prompts/select.js +137 -0
  68. package/dist/prompts/select.js.map +1 -0
  69. package/dist/prompts/text.d.ts +10 -0
  70. package/dist/prompts/text.d.ts.map +1 -0
  71. package/dist/prompts/text.js +21 -0
  72. package/dist/prompts/text.js.map +1 -0
  73. package/dist/terminal.d.ts +21 -0
  74. package/dist/terminal.d.ts.map +1 -0
  75. package/dist/terminal.js +155 -0
  76. package/dist/terminal.js.map +1 -0
  77. package/dist/theme.d.ts +22 -0
  78. package/dist/theme.d.ts.map +1 -0
  79. package/dist/theme.js +32 -0
  80. package/dist/theme.js.map +1 -0
  81. package/package.json +54 -0
@@ -0,0 +1,7 @@
1
+ export declare function resetAgent(): void;
2
+ export declare function agentSend(payload: Record<string, unknown>): Promise<void>;
3
+ export declare function agentSendValidationError(message: string): void;
4
+ export declare function agentSendError(message: string): void;
5
+ export declare function getHandshakeAck(): Record<string, unknown> | null;
6
+ export declare function agentReceive(): Promise<unknown>;
7
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAaA,wBAAgB,UAAU,IAAI,IAAI,CAajC;AAoFD,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEpD;AAED,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAEhE;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CA4BrD"}
package/dist/agent.js ADDED
@@ -0,0 +1,143 @@
1
+ import * as fs from "node:fs";
2
+ import * as readline from "node:readline";
3
+ const VERSION = "0.2.0";
4
+ let handshakeSent = false;
5
+ let handshakeAck = null;
6
+ let rl = null;
7
+ let lineBuffer = [];
8
+ let waiters = [];
9
+ let closed = false;
10
+ let agentStep = 0;
11
+ export function resetAgent() {
12
+ handshakeSent = false;
13
+ handshakeAck = null;
14
+ agentStep = 0;
15
+ outputStream = null;
16
+ if (rl) {
17
+ rl.removeAllListeners();
18
+ rl.close();
19
+ rl = null;
20
+ }
21
+ lineBuffer = [];
22
+ waiters = [];
23
+ closed = false;
24
+ }
25
+ function getOutputStream() {
26
+ const fdOut = process.env.INQUIRER_AI_FD_OUT;
27
+ if (fdOut) {
28
+ return fs.createWriteStream("", { fd: parseInt(fdOut, 10) });
29
+ }
30
+ return process.stdout;
31
+ }
32
+ function getInputStream() {
33
+ const fdIn = process.env.INQUIRER_AI_FD_IN;
34
+ if (fdIn) {
35
+ return fs.createReadStream("", { fd: parseInt(fdIn, 10) });
36
+ }
37
+ return process.stdin;
38
+ }
39
+ let outputStream = null;
40
+ function getOutput() {
41
+ if (!outputStream) {
42
+ outputStream = getOutputStream();
43
+ }
44
+ return outputStream;
45
+ }
46
+ function ensureRL() {
47
+ if (rl)
48
+ return;
49
+ closed = false;
50
+ rl = readline.createInterface({
51
+ input: getInputStream(),
52
+ terminal: false,
53
+ });
54
+ rl.on("line", (line) => {
55
+ const waiter = waiters.shift();
56
+ if (waiter) {
57
+ waiter(line);
58
+ }
59
+ else {
60
+ lineBuffer.push(line);
61
+ }
62
+ });
63
+ rl.on("close", () => {
64
+ closed = true;
65
+ for (let waiter = waiters.shift(); waiter; waiter = waiters.shift()) {
66
+ waiter(null);
67
+ }
68
+ });
69
+ }
70
+ function writeLine(data) {
71
+ getOutput().write(`${JSON.stringify(data)}\n`);
72
+ }
73
+ function sendHandshake() {
74
+ if (handshakeSent)
75
+ return;
76
+ handshakeSent = true;
77
+ const meta = {
78
+ kind: "handshake",
79
+ protocol: "inquirer-ai",
80
+ version: VERSION,
81
+ format: "jsonl",
82
+ interaction: "sequential",
83
+ total: null,
84
+ description: "Interactive prompt protocol. Prompts are sent one at a time — " +
85
+ "read one JSON line from stdout, respond with one JSON line on stdin, " +
86
+ "then wait for the next prompt. Do NOT send all answers at once. " +
87
+ "Use a named pipe (mkfifo) or line-buffered I/O for bidirectional communication.",
88
+ example_response: { answer: "<value>" },
89
+ };
90
+ writeLine(meta);
91
+ }
92
+ function readLine() {
93
+ ensureRL();
94
+ const buffered = lineBuffer.shift();
95
+ if (buffered !== undefined)
96
+ return Promise.resolve(buffered);
97
+ if (closed)
98
+ return Promise.resolve(null);
99
+ return new Promise((resolve) => {
100
+ waiters.push(resolve);
101
+ });
102
+ }
103
+ export async function agentSend(payload) {
104
+ if (!handshakeSent) {
105
+ sendHandshake();
106
+ }
107
+ agentStep++;
108
+ writeLine({ kind: "prompt", step: agentStep, total: null, ...payload });
109
+ }
110
+ export function agentSendValidationError(message) {
111
+ writeLine({ kind: "validation_error", message });
112
+ }
113
+ export function agentSendError(message) {
114
+ writeLine({ kind: "error", message });
115
+ }
116
+ export function getHandshakeAck() {
117
+ return handshakeAck;
118
+ }
119
+ export async function agentReceive() {
120
+ while (true) {
121
+ const line = await readLine();
122
+ if (line === null) {
123
+ throw new Error('No response received (stdin closed). Expected JSON like: {"answer": "<value>"}');
124
+ }
125
+ let resp;
126
+ try {
127
+ resp = JSON.parse(line);
128
+ }
129
+ catch {
130
+ throw new Error(`Invalid JSON response: ${line.trim()}. Expected JSON like: {"answer": "<value>"}`);
131
+ }
132
+ if (resp.kind === "handshake_ack") {
133
+ handshakeAck = resp;
134
+ continue;
135
+ }
136
+ if (typeof resp !== "object" || resp === null || !("answer" in resp)) {
137
+ throw new Error(`Response must be a JSON object with an "answer" key, ` +
138
+ `e.g. {"answer": "<value>"}. Got: ${line.trim()}`);
139
+ }
140
+ return resp.answer;
141
+ }
142
+ }
143
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE1C,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,IAAI,aAAa,GAAG,KAAK,CAAC;AAC1B,IAAI,YAAY,GAAmC,IAAI,CAAC;AACxD,IAAI,EAAE,GAA8B,IAAI,CAAC;AACzC,IAAI,UAAU,GAAa,EAAE,CAAC;AAC9B,IAAI,OAAO,GAAyC,EAAE,CAAC;AACvD,IAAI,MAAM,GAAG,KAAK,CAAC;AACnB,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB,MAAM,UAAU,UAAU;IACxB,aAAa,GAAG,KAAK,CAAC;IACtB,YAAY,GAAG,IAAI,CAAC;IACpB,SAAS,GAAG,CAAC,CAAC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CAAC;YACP,MAAM,IAAI,KAAK,CACb,0BAA0B,IAAI,CAAC,IAAI,EAAE,6CAA6C,CACnF,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YAClC,YAAY,GAAG,IAAI,CAAC;YACpB,SAAS;QACX,CAAC;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,KAAK,CACb,uDAAuD;gBACrD,oCAAoC,IAAI,CAAC,IAAI,EAAE,EAAE,CACpD,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface Choice<V = unknown> {
2
+ name: string;
3
+ value: V;
4
+ disabled?: boolean | string;
5
+ short?: string;
6
+ description?: string;
7
+ }
8
+ export interface Separator {
9
+ type: "separator";
10
+ text: string;
11
+ }
12
+ export type ChoiceItem<V = unknown> = Choice<V> | Separator;
13
+ export type RawChoice<V = unknown> = string | Choice<V> | Separator;
14
+ export declare function isSeparator(item: ChoiceItem): item is Separator;
15
+ export declare function createSeparator(text?: string): Separator;
16
+ export declare function parseChoice<V = unknown>(raw: RawChoice<V>): ChoiceItem<V>;
17
+ export declare function choiceToDict(item: ChoiceItem): Record<string, unknown>;
18
+ //# sourceMappingURL=choice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choice.d.ts","sourceRoot":"","sources":["../src/choice.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM,CAAC,CAAC,GAAG,OAAO;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAC5D,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAEpE,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,IAAI,SAAS,CAE/D;AAED,wBAAgB,eAAe,CAAC,IAAI,SAAa,GAAG,SAAS,CAE5D;AAED,wBAAgB,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAQzE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAStE"}
package/dist/choice.js ADDED
@@ -0,0 +1,29 @@
1
+ export function isSeparator(item) {
2
+ return "type" in item && item.type === "separator";
3
+ }
4
+ export function createSeparator(text = "────────") {
5
+ return { type: "separator", text };
6
+ }
7
+ export function parseChoice(raw) {
8
+ if (typeof raw === "string") {
9
+ return { name: raw, value: raw };
10
+ }
11
+ if ("type" in raw && raw.type === "separator") {
12
+ return raw;
13
+ }
14
+ return raw;
15
+ }
16
+ export function choiceToDict(item) {
17
+ if (isSeparator(item)) {
18
+ return { type: "separator", text: item.text };
19
+ }
20
+ const d = { name: item.name, value: item.value };
21
+ if (item.disabled)
22
+ d.disabled = item.disabled;
23
+ if (item.short != null)
24
+ d.short = item.short;
25
+ if (item.description != null)
26
+ d.description = item.description;
27
+ return d;
28
+ }
29
+ //# sourceMappingURL=choice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choice.js","sourceRoot":"","sources":["../src/choice.ts"],"names":[],"m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or(message: string);
3
+ }
4
+ export declare class ValidationError extends InquirerAIError {
5
+ constructor(message: string);
6
+ }
7
+ export declare class InvalidChoiceError extends ValidationError {
8
+ constructor(message: string);
9
+ }
10
+ export declare class PromptAbortedError extends InquirerAIError {
11
+ constructor(message: string);
12
+ }
13
+ export declare class EditorError extends InquirerAIError {
14
+ constructor(message: string);
15
+ }
16
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,eAAgB,SAAQ,eAAe;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,eAAe;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,eAAe;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,WAAY,SAAQ,eAAe;gBAClC,OAAO,EAAE,MAAM;CAI5B"}
package/dist/errors.js ADDED
@@ -0,0 +1,31 @@
1
+ export class InquirerAIError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = "InquirerAIError";
5
+ }
6
+ }
7
+ export class ValidationError extends InquirerAIError {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "ValidationError";
11
+ }
12
+ }
13
+ export class InvalidChoiceError extends ValidationError {
14
+ constructor(message) {
15
+ super(message);
16
+ this.name = "InvalidChoiceError";
17
+ }
18
+ }
19
+ export class PromptAbortedError extends InquirerAIError {
20
+ constructor(message) {
21
+ super(message);
22
+ this.name = "PromptAbortedError";
23
+ }
24
+ }
25
+ export class EditorError extends InquirerAIError {
26
+ constructor(message) {
27
+ super(message);
28
+ this.name = "EditorError";
29
+ }
30
+ }
31
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,eAAe;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,eAAe;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ export { agentSendError, agentSendValidationError, getHandshakeAck, resetAgent } from "./agent.js";
2
+ export { type Choice, type ChoiceItem, createSeparator, type RawChoice, type Separator } from "./choice.js";
3
+ export { EditorError, InquirerAIError, InvalidChoiceError, PromptAbortedError, ValidationError, } from "./errors.js";
4
+ export { isAgentMode } from "./mode.js";
5
+ export { type AutocompleteConfig, AutocompletePrompt } from "./prompts/autocomplete.js";
6
+ export type { FilterFn, TransformerFn, ValidateFn } from "./prompts/base.js";
7
+ export { type CheckboxConfig, CheckboxPrompt } from "./prompts/checkbox.js";
8
+ export { type ConfirmConfig, ConfirmPrompt } from "./prompts/confirm.js";
9
+ export { type EditorConfig, EditorPrompt } from "./prompts/editor.js";
10
+ export { type ExpandChoice, type ExpandConfig, ExpandPrompt } from "./prompts/expand.js";
11
+ export { type NumberConfig, NumberPrompt } from "./prompts/number.js";
12
+ export { type PasswordConfig, PasswordPrompt } from "./prompts/password.js";
13
+ export { type PathConfig, PathPrompt } from "./prompts/path.js";
14
+ export { type RawlistConfig, RawlistPrompt } from "./prompts/rawlist.js";
15
+ export { type SearchConfig, SearchPrompt } from "./prompts/search.js";
16
+ export { type SelectConfig, SelectPrompt } from "./prompts/select.js";
17
+ export { type TextConfig, TextPrompt } from "./prompts/text.js";
18
+ export { getTheme, setTheme, type Theme } from "./theme.js";
19
+ import { type AutocompleteConfig } from "./prompts/autocomplete.js";
20
+ import { type CheckboxConfig } from "./prompts/checkbox.js";
21
+ import { type ConfirmConfig } from "./prompts/confirm.js";
22
+ import { type EditorConfig } from "./prompts/editor.js";
23
+ import { type ExpandConfig } from "./prompts/expand.js";
24
+ import { type NumberConfig } from "./prompts/number.js";
25
+ import { type PasswordConfig } from "./prompts/password.js";
26
+ import { type PathConfig } from "./prompts/path.js";
27
+ import { type RawlistConfig } from "./prompts/rawlist.js";
28
+ import { type SearchConfig } from "./prompts/search.js";
29
+ import { type SelectConfig } from "./prompts/select.js";
30
+ import { type TextConfig } from "./prompts/text.js";
31
+ export declare function text(config: TextConfig): Promise<string>;
32
+ export declare function confirm(config: ConfirmConfig): Promise<boolean>;
33
+ export declare function select<V = unknown>(config: SelectConfig<V>): Promise<V>;
34
+ export declare function checkbox<V = unknown>(config: CheckboxConfig<V>): Promise<V[]>;
35
+ export declare function password(config: PasswordConfig): Promise<string>;
36
+ export declare function number(config: NumberConfig): Promise<number>;
37
+ export declare function editor(config: EditorConfig): Promise<string>;
38
+ export declare function search(config: SearchConfig): Promise<unknown>;
39
+ export declare function rawlist(config: RawlistConfig): Promise<unknown>;
40
+ export declare function expand(config: ExpandConfig): Promise<unknown>;
41
+ export declare function path(config: PathConfig): Promise<string>;
42
+ export declare function autocomplete(config: Autocomple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7E;AAED,wBAAsB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAEnF;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtE;AAED,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAElE;AAED,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAElE;AAED,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnE;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAErE;AAED,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnE;AAED,wBAAsB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9D;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9E"}
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ export { agentSendError, agentSendValidationError, getHandshakeAck, resetAgent } from "./agent.js";
2
+ export { createSeparator } from "./choice.js";
3
+ export { EditorError, InquirerAIError, InvalidChoiceError, PromptAbortedError, ValidationError, } from "./errors.js";
4
+ export { isAgentMode } from "./mode.js";
5
+ export { AutocompletePrompt } from "./prompts/autocomplete.js";
6
+ export { CheckboxPrompt } from "./prompts/checkbox.js";
7
+ export { ConfirmPrompt } from "./prompts/confirm.js";
8
+ export { EditorPrompt } from "./prompts/editor.js";
9
+ export { ExpandPrompt } from "./prompts/expand.js";
10
+ export { NumberPrompt } from "./prompts/number.js";
11
+ export { PasswordPrompt } from "./prompts/password.js";
12
+ export { PathPrompt } from "./prompts/path.js";
13
+ export { RawlistPrompt } from "./prompts/rawlist.js";
14
+ export { SearchPrompt } from "./prompts/search.js";
15
+ export { SelectPrompt } from "./prompts/select.js";
16
+ export { TextPrompt } from "./prompts/text.js";
17
+ export { getTheme, setTheme } from "./theme.js";
18
+ import { AutocompletePrompt } from "./prompts/autocomplete.js";
19
+ import { CheckboxPrompt } from "./prompts/checkbox.js";
20
+ import { ConfirmPrompt } from "./prompts/confirm.js";
21
+ import { EditorPrompt } from "./prompts/editor.js";
22
+ import { ExpandPrompt } from "./prompts/expand.js";
23
+ import { NumberPrompt } from "./prompts/number.js";
24
+ import { PasswordPrompt } from "./prompts/password.js";
25
+ import { PathPrompt } from "./prompts/path.js";
26
+ import { RawlistPrompt } from "./prompts/rawlist.js";
27
+ import { SearchPrompt } from "./prompts/search.js";
28
+ import { SelectPrompt } from "./prompts/select.js";
29
+ import { TextPrompt } from "./prompts/text.js";
30
+ export async function text(config) {
31
+ return new TextPrompt(config).execute();
32
+ }
33
+ export async function confirm(config) {
34
+ return new ConfirmPrompt(config).execute();
35
+ }
36
+ export async function select(config) {
37
+ return new SelectPrompt(config).execute();
38
+ }
39
+ export async function checkbox(config) {
40
+ return new CheckboxPrompt(config).execute();
41
+ }
42
+ export async function password(config) {
43
+ return new PasswordPrompt(config).execute();
44
+ }
45
+ export async function number(config) {
46
+ return new NumberPrompt(config).execute();
47
+ }
48
+ export async function editor(config) {
49
+ return new EditorPrompt(config).execute();
50
+ }
51
+ export async function search(config) {
52
+ return new SearchPrompt(config).execute();
53
+ }
54
+ export async function rawlist(config) {
55
+ return new RawlistPrompt(config).execute();
56
+ }
57
+ export async function expand(config) {
58
+ return new ExpandPrompt(config).execute();
59
+ }
60
+ export async function path(config) {
61
+ return new PathPrompt(config).execute();
62
+ }
63
+ export async function autocomplete(config) {
64
+ return new AutocompletePrompt(config).execute();
65
+ }
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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B;IAC/C,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,MAAoB;IAC/C,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,MAAqB;IACjD,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,MAAoB;IAC/C,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,MAAkB;IAC3C,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAC1C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAA0B;IAC3D,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAClD,CAAC"}
package/dist/mode.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function isAgentMode(): boolean;
2
+ //# sourceMappingURL=mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../src/mode.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,IAAI,OAAO,CAKrC"}
package/dist/mode.js ADDED
@@ -0,0 +1,10 @@
1
+ import * as tty from "node:tty";
2
+ export function isAgentMode() {
3
+ const env = (process.env.INQUIRER_AI_MODE ?? "").toLowerCase();
4
+ if (env === "agent")
5
+ return true;
6
+ if (env === "human")
7
+ return false;
8
+ return !tty.isatty(0);
9
+ }
10
+ //# sourceMappingURL=mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.js","sourceRoot":"","sources":["../src/mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,MAAM,UAAU,WAAW;IACzB,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,IAAI,GAAG,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IACjC,IAAI,GAAG,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAClC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type BaseConfig, BasePrompt } from "./base.js";
2
+ export interface AutocompleteConfig extends BaseConfig<string> {
3
+ choices: string[];
4
+ }
5
+ export declare class AutocompletePrompt extends BasePrompt<string> {
6
+ private choices;
7
+ constructor(config: AutocompleteConfig);
8
+ get promptType(): string;
9
+ protected validateAnswer(value: unknown): string;
10
+ protected toAgentDict(): Record<string, unknown>;
11
+ protected executeTerminal(): Promise<string>;
12
+ }
13
+ //# sourceMappingURL=autocomplete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../src/prompts/autocomplete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,WAAW,kBAAmB,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC5D,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,qBAAa,kBAAmB,SAAQ,UAAU,CAAC,MAAM,CAAC;IACxD,OAAO,CAAC,OAAO,CAAW;gBAEd,MAAM,EAAE,kBAAkB;IAKtC,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;cAK7B,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;cAIzC,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;CAOnD"}
@@ -0,0 +1,29 @@
1
+ import { formatQuestion, readLine } from "../terminal.js";
2
+ import { BasePrompt } from "./base.js";
3
+ export class AutocompletePrompt extends BasePrompt {
4
+ choices;
5
+ constructor(config) {
6
+ super(config);
7
+ this.choices = config.choices;
8
+ }
9
+ get promptType() {
10
+ return "autocomplete";
11
+ }
12
+ validateAnswer(value) {
13
+ if (value == null)
14
+ return this.defaultValue ?? "";
15
+ return String(value);
16
+ }
17
+ toAgentDict() {
18
+ return { ...super.toAgentDict(), choices: this.choices };
19
+ }
20
+ async executeTerminal() {
21
+ const suffix = this.defaultValue != null ? ` (${this.defaultValue})` : "";
22
+ const prompt = formatQuestion(this.message, suffix);
23
+ const result = await readLine(prompt);
24
+ if (!result && this.defaultValue != null)
25
+ return this.defaultValue;
26
+ return result;
27
+ }
28
+ }
29
+ //# sourceMappingURL=autocomplete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete.js","sourceRoot":"","sources":["../../src/prompts/autocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAmB,UAAU,EAAE,MAAM,WAAW,CAAC;AAMxD,MAAM,OAAO,kBAAmB,SAAQ,UAAkB;IAChD,OAAO,CAAW;IAE1B,YAAY,MAA0B;QACpC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,cAAc,CAAC;IACxB,CAAC;IAES,cAAc,CAAC,KAAc;QACrC,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;QAClD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAEkB,WAAW;QAC5B,OAAO,EAAE,GAAG,KAAK,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IAC3D,CAAC;IAES,KAAK,CAAC,eAAe;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1E,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC,YAAY,CAAC;QACnE,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ export type ValidateFn<T> = (value: T) => boolean | string | null | undefined;
2
+ export type FilterFn<T> = (value: T) => T;
3
+ export type TransformerFn<T> = (value: T) => string;
4
+ export interface BaseConfig<T> {
5
+ message: string;
6
+ default?: T | null;
7
+ validate?: ValidateFn<T>;
8
+ filter?: FilterFn<T>;
9
+ transformer?: TransformerFn<T>;
10
+ }
11
+ export declare abstract class BasePrompt<T> {
12
+ protected message: string;
13
+ protected defaultValue: T | null;
14
+ protected validateFn?: ValidateFn<T>;
15
+ protected filterFn?: FilterFn<T>;
16
+ protected transformerFn?: TransformerFn<T>;
17
+ constructor(config: BaseConfig<T>);
18
+ abstract get promptType(): string;
19
+ protected abstract executeTerminal(): Promise<T>;
20
+ protected abstract validateAnswer(value: unknown): T;
21
+ protected formatAnswer(value: T): string;
22
+ protected toAgentDict(): Record<string, unknown>;
23
+ protected executeAgent(): Promise<T>;
24
+ protected runUserValidation(value: T): string | null;
25
+ execute(): Promise<T>;
26
+ }
27
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/prompts/base.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CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;cAQhC,YAAY,IAAI,OAAO,CAAC,CAAC,CAAC;IAyB1C,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,GAAG,IAAI;IAQ9C,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC;CA0C5B"}
@@ -0,0 +1,107 @@
1
+ import { agentReceive, agentSend, agentSendValidationError } from "../agent.js";
2
+ import { PromptAbortedError, ValidationError } from "../errors.js";
3
+ import { isAgentMode } from "../mode.js";
4
+ import { formatError, formatSuccess } from "../terminal.js";
5
+ const MAX_AGENT_RETRIES = 3;
6
+ export class BasePrompt {
7
+ message;
8
+ defaultValue;
9
+ validateFn;
10
+ filterFn;
11
+ transformerFn;
12
+ constructor(config) {
13
+ this.message = config.message;
14
+ this.defaultValue = config.default ?? null;
15
+ this.validateFn = config.validate;
16
+ this.filterFn = config.filter;
17
+ this.transformerFn = config.transformer;
18
+ }
19
+ formatAnswer(value) {
20
+ return String(value);
21
+ }
22
+ toAgentDict() {
23
+ return {
24
+ type: this.promptType,
25
+ message: this.message,
26
+ default: this.defaultValue,
27
+ };
28
+ }
29
+ async executeAgent() {
30
+ for (let attempt = 0; attempt <= MAX_AGENT_RETRIES; attempt++) {
31
+ await agentSend(this.toAgentDict());
32
+ let answer;
33
+ try {
34
+ answer = await agentReceive();
35
+ }
36
+ catch (err) {
37
+ const msg = err instanceof Error ? err.message : String(err);
38
+ if (msg.includes("stdin closed"))
39
+ throw new PromptAbortedError(msg);
40
+ throw new ValidationError(msg);
41
+ }
42
+ try {
43
+ return this.validateAnswer(answer);
44
+ }
45
+ catch (err) {
46
+ if (err instanceof ValidationError && attempt < MAX_AGENT_RETRIES) {
47
+ agentSendValidationError(err.message);
48
+ continue;
49
+ }
50
+ throw err;
51
+ }
52
+ }
53
+ // Should not reach here, but satisfy TypeScript
54
+ throw new ValidationError("Maximum validation retries exceeded");
55
+ }
56
+ runUserValidation(value) {
57
+ if (!this.validateFn)
58
+ return null;
59
+ const result = this.validateFn(value);
60
+ if (result === true || result === null || result === undefined)
61
+ return null;
62
+ if (typeof result === "string")
63
+ return result;
64
+ return "Validation failed";
65
+ }
66
+ async execute() {
67
+ const agent = isAgentMode();
68
+ let userValidationRetries = 0;
69
+ while (true) {
70
+ let result;
71
+ try {
72
+ result = agent ? await this.executeAgent() : await this.executeTerminal();
73
+ }
74
+ catch (err) {
75
+ if (err instanceof PromptAbortedError)
76
+ throw err;
77
+ if (err instanceof ValidationError)
78
+ throw err;
79
+ throw new PromptAbortedError("Prompt aborted (stdin closed)");
80
+ }
81
+ if (this.filterFn) {
82
+ result = this.filterFn(result);
83
+ }
84
+ const error = this.runUserValidation(result);
85
+ if (error) {
86
+ if (agent) {
87
+ userValidationRetries++;
88
+ if (userValidationRetries > MAX_AGENT_RETRIES) {
89
+ throw new ValidationError(error);
90
+ }
91
+ agentSendValidationError(error);
92
+ continue;
93
+ }
94
+ process.stderr.write(`${formatError(error)}\n`);
95
+ continue;
96
+ }
97
+ if (!agent) {
98
+ const display = this.transformerFn
99
+ ? this.transformerFn(result)
100
+ : this.formatAnswer(result);
101
+ process.stderr.write(`${formatSuccess(this.message, display)}\n`);
102
+ }
103
+ return result;
104
+ }
105
+ }
106
+ }
107
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/prompts/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE5D,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAc5B,MAAM,OAAgB,UAAU;IACpB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