@canonical/summon-core 0.31.0 → 0.33.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/dist/esm/execute/GeneratorResult.js +13 -0
- package/dist/esm/execute/GeneratorResult.js.map +1 -0
- package/dist/esm/execute/collectAnswers.js +92 -0
- package/dist/esm/execute/collectAnswers.js.map +1 -0
- package/dist/esm/execute/execute.js +73 -0
- package/dist/esm/execute/execute.js.map +1 -0
- package/dist/esm/execute/index.js +4 -0
- package/dist/esm/execute/index.js.map +1 -0
- package/dist/esm/execute/validateAnswers.js +47 -0
- package/dist/esm/execute/validateAnswers.js.map +1 -0
- package/dist/esm/format/effects.js +581 -0
- package/dist/esm/format/effects.js.map +1 -0
- package/dist/esm/format/index.js +2 -0
- package/dist/esm/format/index.js.map +1 -0
- package/dist/esm/index.js +8 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/prompt/answerPromptWithDefaults.js +26 -0
- package/dist/esm/prompt/answerPromptWithDefaults.js.map +1 -0
- package/dist/esm/prompt/autoPrompt.js +50 -0
- package/dist/esm/prompt/autoPrompt.js.map +1 -0
- package/dist/esm/prompt/index.js +12 -0
- package/dist/esm/prompt/index.js.map +1 -0
- package/dist/esm/prompt/ink/Spinner.js +18 -0
- package/dist/esm/prompt/ink/Spinner.js.map +1 -0
- package/dist/esm/prompt/ink/Wizard.js +116 -0
- package/dist/esm/prompt/ink/Wizard.js.map +1 -0
- package/dist/esm/prompt/ink/answerValidation.js +32 -0
- package/dist/esm/prompt/ink/answerValidation.js.map +1 -0
- package/dist/esm/prompt/ink/mount.js +41 -0
- package/dist/esm/prompt/ink/mount.js.map +1 -0
- package/dist/esm/prompt/ink/progressWindow.js +143 -0
- package/dist/esm/prompt/ink/progressWindow.js.map +1 -0
- package/dist/esm/prompt/ink/prompts.js +219 -0
- package/dist/esm/prompt/ink/prompts.js.map +1 -0
- package/dist/esm/prompt/ink/selectChoices.js +28 -0
- package/dist/esm/prompt/ink/selectChoices.js.map +1 -0
- package/dist/esm/prompt/ink/session.js +176 -0
- package/dist/esm/prompt/ink/session.js.map +1 -0
- package/dist/esm/prompt/inkPrompt.js +55 -0
- package/dist/esm/prompt/inkPrompt.js.map +1 -0
- package/dist/esm/prompt/mcpPrompt.js +29 -0
- package/dist/esm/prompt/mcpPrompt.js.map +1 -0
- package/dist/esm/prompt/types.js +12 -0
- package/dist/esm/prompt/types.js.map +1 -0
- package/dist/esm/run/index.js +2 -0
- package/dist/esm/run/index.js.map +1 -0
- package/dist/esm/run/runGeneratorTask.js +63 -0
- package/dist/esm/run/runGeneratorTask.js.map +1 -0
- package/dist/esm/stamp/createGeneratorStamp.js +19 -0
- package/dist/esm/stamp/createGeneratorStamp.js.map +1 -0
- package/dist/esm/stamp/createStampOnEffectStart.js +23 -0
- package/dist/esm/stamp/createStampOnEffectStart.js.map +1 -0
- package/dist/esm/stamp/index.js +2 -0
- package/dist/esm/stamp/index.js.map +1 -1
- package/dist/types/execute/GeneratorResult.d.ts +23 -0
- package/dist/types/execute/GeneratorResult.d.ts.map +1 -0
- package/dist/types/execute/collectAnswers.d.ts +52 -0
- package/dist/types/execute/collectAnswers.d.ts.map +1 -0
- package/dist/types/execute/execute.d.ts +57 -0
- package/dist/types/execute/execute.d.ts.map +1 -0
- package/dist/types/execute/index.d.ts +6 -0
- package/dist/types/execute/index.d.ts.map +1 -0
- package/dist/types/execute/validateAnswers.d.ts +23 -0
- package/dist/types/execute/validateAnswers.d.ts.map +1 -0
- package/dist/types/format/effects.d.ts +86 -0
- package/dist/types/format/effects.d.ts.map +1 -0
- package/dist/types/format/index.d.ts +2 -0
- package/dist/types/format/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/prompt/answerPromptWithDefaults.d.ts +17 -0
- package/dist/types/prompt/answerPromptWithDefaults.d.ts.map +1 -0
- package/dist/types/prompt/autoPrompt.d.ts +35 -0
- package/dist/types/prompt/autoPrompt.d.ts.map +1 -0
- package/dist/types/prompt/index.d.ts +14 -0
- package/dist/types/prompt/index.d.ts.map +1 -0
- package/dist/types/prompt/ink/Spinner.d.ts +11 -0
- package/dist/types/prompt/ink/Spinner.d.ts.map +1 -0
- package/dist/types/prompt/ink/Wizard.d.ts +14 -0
- package/dist/types/prompt/ink/Wizard.d.ts.map +1 -0
- package/dist/types/prompt/ink/answerValidation.d.ts +31 -0
- package/dist/types/prompt/ink/answerValidation.d.ts.map +1 -0
- package/dist/types/prompt/ink/mount.d.ts +31 -0
- package/dist/types/prompt/ink/mount.d.ts.map +1 -0
- package/dist/types/prompt/ink/progressWindow.d.ts +48 -0
- package/dist/types/prompt/ink/progressWindow.d.ts.map +1 -0
- package/dist/types/prompt/ink/prompts.d.ts +35 -0
- package/dist/types/prompt/ink/prompts.d.ts.map +1 -0
- package/dist/types/prompt/ink/selectChoices.d.ts +42 -0
- package/dist/types/prompt/ink/selectChoices.d.ts.map +1 -0
- package/dist/types/prompt/ink/session.d.ts +103 -0
- package/dist/types/prompt/ink/session.d.ts.map +1 -0
- package/dist/types/prompt/inkPrompt.d.ts +64 -0
- package/dist/types/prompt/inkPrompt.d.ts.map +1 -0
- package/dist/types/prompt/mcpPrompt.d.ts +20 -0
- package/dist/types/prompt/mcpPrompt.d.ts.map +1 -0
- package/dist/types/prompt/types.d.ts +23 -0
- package/dist/types/prompt/types.d.ts.map +1 -0
- package/dist/types/run/index.d.ts +3 -0
- package/dist/types/run/index.d.ts.map +1 -0
- package/dist/types/run/runGeneratorTask.d.ts +51 -0
- package/dist/types/run/runGeneratorTask.d.ts.map +1 -0
- package/dist/types/stamp/createGeneratorStamp.d.ts +16 -0
- package/dist/types/stamp/createGeneratorStamp.d.ts.map +1 -0
- package/dist/types/stamp/createStampOnEffectStart.d.ts +17 -0
- package/dist/types/stamp/createStampOnEffectStart.d.ts.map +1 -0
- package/dist/types/stamp/index.d.ts +2 -0
- package/dist/types/stamp/index.d.ts.map +1 -1
- package/package.json +17 -10
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text, useInput } from "ink";
|
|
3
|
+
import SelectInput from "ink-select-input";
|
|
4
|
+
import TextInput from "ink-text-input";
|
|
5
|
+
import { useCallback, useEffect, useState } from "react";
|
|
6
|
+
import { evaluateValidation } from "./answerValidation.js";
|
|
7
|
+
import { classifySelectChoices } from "./selectChoices.js";
|
|
8
|
+
/** Format an answer value for the completed-answers table. */
|
|
9
|
+
export const formatAnswerValue = (value, prompt) => {
|
|
10
|
+
if (value === undefined || value === null)
|
|
11
|
+
return "";
|
|
12
|
+
if (prompt.type === "confirm")
|
|
13
|
+
return value ? "Yes" : "No";
|
|
14
|
+
if (prompt.type === "select" && prompt.choices) {
|
|
15
|
+
const choice = prompt.choices.find((c) => c.value === value);
|
|
16
|
+
return choice?.label ?? String(value);
|
|
17
|
+
}
|
|
18
|
+
if (prompt.type === "multiselect" && Array.isArray(value)) {
|
|
19
|
+
if (value.length === 0)
|
|
20
|
+
return "None";
|
|
21
|
+
if (prompt.choices) {
|
|
22
|
+
return value
|
|
23
|
+
.map((v) => prompt.choices?.find((c) => c.value === v)?.label ?? v)
|
|
24
|
+
.join(", ");
|
|
25
|
+
}
|
|
26
|
+
return value.join(", ");
|
|
27
|
+
}
|
|
28
|
+
return String(value);
|
|
29
|
+
};
|
|
30
|
+
/** The completed-answers table (aligned, borderless). */
|
|
31
|
+
export const AnswersTable = ({ prompts, answers, }) => {
|
|
32
|
+
const active = prompts.filter((p) => {
|
|
33
|
+
if (p.when && p.when(answers) !== true)
|
|
34
|
+
return false;
|
|
35
|
+
return p.name in answers;
|
|
36
|
+
});
|
|
37
|
+
if (active.length === 0)
|
|
38
|
+
return null;
|
|
39
|
+
const width = Math.max(...active.map((p) => p.message.length));
|
|
40
|
+
return (_jsx(Box, { flexDirection: "column", marginBottom: 1, children: active.map((prompt) => (_jsxs(Box, { children: [_jsx(Text, { color: "green", children: "\u2714 " }), _jsx(Text, { dimColor: true, children: prompt.message.padEnd(width) }), _jsx(Text, { dimColor: true, children: " " }), _jsx(Text, { color: "cyan", children: formatAnswerValue(answers[prompt.name], prompt) })] }, prompt.name))) }));
|
|
41
|
+
};
|
|
42
|
+
/** The "Step N of M" progress header. */
|
|
43
|
+
export const ProgressHeader = ({ current, total, }) => (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { dimColor: true, children: ["Step ", current, " of ", total] }) }));
|
|
44
|
+
const TextQuestion = ({ question, onSubmit, onCancel, }) => {
|
|
45
|
+
const [value, setValue] = useState(String(question.default ?? ""));
|
|
46
|
+
const [error, setError] = useState(null);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
setValue(String(question.default ?? ""));
|
|
49
|
+
setError(null);
|
|
50
|
+
}, [question.default]);
|
|
51
|
+
const handleSubmit = useCallback((val) => {
|
|
52
|
+
if (question.validate) {
|
|
53
|
+
const result = question.validate(val);
|
|
54
|
+
if (result !== true) {
|
|
55
|
+
setError(typeof result === "string" ? result : "Invalid input");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
onSubmit(val);
|
|
60
|
+
}, [question, onSubmit]);
|
|
61
|
+
useInput((_input, key) => {
|
|
62
|
+
if (key.escape)
|
|
63
|
+
onCancel();
|
|
64
|
+
});
|
|
65
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\u203A " }), _jsx(Text, { bold: true, children: question.message })] }), _jsx(Box, { marginLeft: 2, children: _jsx(TextInput, { value: value, onChange: setValue, onSubmit: handleSubmit }) }), error && (_jsx(Box, { marginLeft: 2, children: _jsxs(Text, { color: "red", children: ["\u2718 ", error] }) }))] }));
|
|
66
|
+
};
|
|
67
|
+
const ConfirmQuestion = ({ question, validate, onSubmit, onCancel, }) => {
|
|
68
|
+
const defaultValue = Boolean(question.default);
|
|
69
|
+
const [error, setError] = useState(null);
|
|
70
|
+
const submit = (value) => {
|
|
71
|
+
const result = evaluateValidation(validate, value);
|
|
72
|
+
if (!result.ok) {
|
|
73
|
+
setError(result.message);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
onSubmit(value);
|
|
77
|
+
};
|
|
78
|
+
useInput((input, key) => {
|
|
79
|
+
if (input.toLowerCase() === "y")
|
|
80
|
+
submit(true);
|
|
81
|
+
else if (input.toLowerCase() === "n")
|
|
82
|
+
submit(false);
|
|
83
|
+
else if (key.return)
|
|
84
|
+
submit(defaultValue);
|
|
85
|
+
else if (key.escape)
|
|
86
|
+
onCancel();
|
|
87
|
+
});
|
|
88
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\u203A " }), _jsxs(Text, { bold: true, children: [question.message, " "] }), _jsxs(Text, { dimColor: true, children: ["(", defaultValue ? "Y/n" : "y/N", ")"] })] }), error && (_jsx(Box, { marginLeft: 2, children: _jsxs(Text, { color: "red", children: ["\u2718 ", error] }) }))] }));
|
|
89
|
+
};
|
|
90
|
+
const SelectQuestion = ({ question, validate, onSubmit, onCancel, }) => {
|
|
91
|
+
const [error, setError] = useState(null);
|
|
92
|
+
const classification = classifySelectChoices(question.choices);
|
|
93
|
+
const submit = useCallback((value) => {
|
|
94
|
+
const result = evaluateValidation(validate, value);
|
|
95
|
+
if (!result.ok) {
|
|
96
|
+
setError(result.message);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
onSubmit(value);
|
|
100
|
+
}, [validate, onSubmit]);
|
|
101
|
+
// A single forced choice resolves itself — no keystroke, no hang (C4). It
|
|
102
|
+
// submits DIRECTLY (not through the inline-validate gate, which exists for
|
|
103
|
+
// interactive recovery that a one-option list cannot offer); a self-
|
|
104
|
+
// contradicting generator is still caught by run-level `validateAnswers`. A
|
|
105
|
+
// second submit from a stray re-render is a no-op (the controller has already
|
|
106
|
+
// cleared the pending prompt).
|
|
107
|
+
const single = classification.kind === "single" ? classification.value : null;
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (single !== null)
|
|
110
|
+
onSubmit(single);
|
|
111
|
+
}, [single, onSubmit]);
|
|
112
|
+
useInput((_input, key) => {
|
|
113
|
+
if (key.escape)
|
|
114
|
+
onCancel();
|
|
115
|
+
});
|
|
116
|
+
// Zero choices would render an empty list only Ctrl-C/Escape could leave —
|
|
117
|
+
// surface it as a clear error instead of a silent dead-end (C4).
|
|
118
|
+
if (classification.kind === "empty") {
|
|
119
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\u203A " }), _jsx(Text, { bold: true, children: question.message })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: "\u2718 No options are available to choose from. Press Escape or Ctrl-C to exit." }) })] }));
|
|
120
|
+
}
|
|
121
|
+
// The single choice is auto-resolving (above); render only the question line.
|
|
122
|
+
if (classification.kind === "single") {
|
|
123
|
+
return (_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\u203A " }), _jsx(Text, { bold: true, children: question.message })] }));
|
|
124
|
+
}
|
|
125
|
+
const items = classification.choices.map((c) => ({
|
|
126
|
+
label: c.label,
|
|
127
|
+
value: c.value,
|
|
128
|
+
}));
|
|
129
|
+
const initialIndex = question.default
|
|
130
|
+
? items.findIndex((i) => i.value === question.default)
|
|
131
|
+
: 0;
|
|
132
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\u203A " }), _jsx(Text, { bold: true, children: question.message }), _jsx(Text, { dimColor: true, children: " (\u2191\u2193 to select, enter to confirm)" })] }), _jsx(Box, { marginLeft: 2, children: _jsx(SelectInput, { items: items, initialIndex: initialIndex >= 0 ? initialIndex : 0, onSelect: (item) => submit(item.value) }) }), error && (_jsx(Box, { marginLeft: 2, children: _jsxs(Text, { color: "red", children: ["\u2718 ", error] }) }))] }));
|
|
133
|
+
};
|
|
134
|
+
const MultiselectQuestion = ({ question, validate, onSubmit, onCancel, }) => {
|
|
135
|
+
const choices = question.choices;
|
|
136
|
+
const classification = classifySelectChoices(choices);
|
|
137
|
+
const [selected, setSelected] = useState(new Set(question.default));
|
|
138
|
+
const [highlighted, setHighlighted] = useState(0);
|
|
139
|
+
const [error, setError] = useState(null);
|
|
140
|
+
useInput((input, key) => {
|
|
141
|
+
if (key.escape) {
|
|
142
|
+
onCancel();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Zero choices is a dead-end (nothing to toggle; Enter could only ever fail
|
|
146
|
+
// a min-selection validator). The render below surfaces a clear error, so
|
|
147
|
+
// here we swallow every key but Escape — a stray Enter must not submit `[]`.
|
|
148
|
+
if (classification.kind === "empty")
|
|
149
|
+
return;
|
|
150
|
+
if (key.upArrow) {
|
|
151
|
+
setHighlighted((p) => (p > 0 ? p - 1 : choices.length - 1));
|
|
152
|
+
}
|
|
153
|
+
else if (key.downArrow) {
|
|
154
|
+
setHighlighted((p) => (p < choices.length - 1 ? p + 1 : 0));
|
|
155
|
+
}
|
|
156
|
+
else if (input === " ") {
|
|
157
|
+
const choice = choices.at(highlighted);
|
|
158
|
+
if (choice) {
|
|
159
|
+
setSelected((prev) => {
|
|
160
|
+
const next = new Set(prev);
|
|
161
|
+
if (next.has(choice.value))
|
|
162
|
+
next.delete(choice.value);
|
|
163
|
+
else
|
|
164
|
+
next.add(choice.value);
|
|
165
|
+
return next;
|
|
166
|
+
});
|
|
167
|
+
// A fresh toggle changes the selection, so any stale min-selection
|
|
168
|
+
// error (C-lo3) no longer applies — clear it rather than let the ✘
|
|
169
|
+
// linger over a now-valid choice.
|
|
170
|
+
setError(null);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (key.return) {
|
|
174
|
+
// Run the prompt's own validator INLINE (C6) — this is also how a
|
|
175
|
+
// multiselect enforces a minimum selection (C-lo3): a validator that
|
|
176
|
+
// rejects an empty array re-asks in place instead of submitting `[]`.
|
|
177
|
+
const values = [...selected];
|
|
178
|
+
const result = evaluateValidation(validate, values);
|
|
179
|
+
if (!result.ok) {
|
|
180
|
+
setError(result.message);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
onSubmit(values);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
// Zero choices would render an empty toggle list only Escape/Ctrl-C could
|
|
187
|
+
// leave — and, with the min-selection validator (C-lo3), an Enter that can
|
|
188
|
+
// only ever fail. Surface a clear error instead of that silent dead-end,
|
|
189
|
+
// mirroring the select guard (C4).
|
|
190
|
+
if (classification.kind === "empty") {
|
|
191
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\u203A " }), _jsx(Text, { bold: true, children: question.message })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: "\u2718 No options are available to choose from. Press Escape or Ctrl-C to exit." }) })] }));
|
|
192
|
+
}
|
|
193
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\u203A " }), _jsx(Text, { bold: true, children: question.message }), _jsx(Text, { dimColor: true, children: " (space to toggle, enter to confirm)" })] }), _jsx(Box, { marginLeft: 2, flexDirection: "column", children: choices.map((choice, i) => {
|
|
194
|
+
const isHi = i === highlighted;
|
|
195
|
+
const isSel = selected.has(choice.value);
|
|
196
|
+
return (_jsxs(Box, { children: [_jsx(Text, { color: isHi ? "magenta" : undefined, children: isHi ? "› " : " " }), _jsx(Text, { color: isSel ? "green" : "gray", children: isSel ? "◉ " : "○ " }), _jsx(Text, { color: isSel ? undefined : "gray", children: choice.label })] }, choice.value));
|
|
197
|
+
}) }), error && (_jsx(Box, { marginLeft: 2, children: _jsxs(Text, { color: "red", children: ["\u2718 ", error] }) }))] }));
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Render the widget for a single {@link PromptQuestion}.
|
|
201
|
+
*
|
|
202
|
+
* `validate` is the prompt definition's own constraint (looked up by the wizard
|
|
203
|
+
* from `generator.prompts`), threaded into the non-text widgets so they run it
|
|
204
|
+
* INLINE with recovery (C6) — the `text` widget already validates via its own
|
|
205
|
+
* question field.
|
|
206
|
+
*/
|
|
207
|
+
export const QuestionView = ({ question, validate, onSubmit, onCancel, }) => {
|
|
208
|
+
switch (question.type) {
|
|
209
|
+
case "text":
|
|
210
|
+
return (_jsx(TextQuestion, { question: question, onSubmit: onSubmit, onCancel: onCancel }));
|
|
211
|
+
case "confirm":
|
|
212
|
+
return (_jsx(ConfirmQuestion, { question: question, validate: validate, onSubmit: onSubmit, onCancel: onCancel }));
|
|
213
|
+
case "select":
|
|
214
|
+
return (_jsx(SelectQuestion, { question: question, validate: validate, onSubmit: onSubmit, onCancel: onCancel }));
|
|
215
|
+
case "multiselect":
|
|
216
|
+
return (_jsx(MultiselectQuestion, { question: question, validate: validate, onSubmit: onSubmit, onCancel: onCancel }));
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../../src/prompt/ink/prompts.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAmB,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAAc,EACd,MAAkD,EAC1C,EAAE;IACV,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAA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,EAClB,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,CACL,KAAC,cAAc,IACb,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;QACJ,KAAK,aAAa;YAChB,OAAO,CACL,KAAC,mBAAmB,IAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;IACN,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure classification of a `select` prompt's choices, so the Ink
|
|
3
|
+
* `SelectQuestion` widget can guard the two degenerate shapes that would
|
|
4
|
+
* otherwise HANG the wizard (C4/M6): a select with ZERO choices (nothing to
|
|
5
|
+
* pick — only Ctrl-C/Escape exit, a silent dead-end), and a select with EXACTLY
|
|
6
|
+
* one choice (a forced pick that should resolve itself rather than demand a
|
|
7
|
+
* keystroke).
|
|
8
|
+
*
|
|
9
|
+
* Lives as a `.ts` sibling of the JSX widgets so the branch logic is unit
|
|
10
|
+
* testable WITHOUT standing up an Ink render (the `.tsx` widget file is excluded
|
|
11
|
+
* from the vitest unit run).
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Classify a select's choices into a {@link SelectChoicesClassification}.
|
|
15
|
+
*
|
|
16
|
+
* @param choices - The select prompt's declared or dynamically-built choices.
|
|
17
|
+
* @returns The degenerate-or-normal classification the widget branches on.
|
|
18
|
+
*/
|
|
19
|
+
export function classifySelectChoices(choices) {
|
|
20
|
+
if (choices.length === 0)
|
|
21
|
+
return { kind: "empty" };
|
|
22
|
+
const only = choices.at(0);
|
|
23
|
+
if (choices.length === 1 && only !== undefined) {
|
|
24
|
+
return { kind: "single", value: only.value };
|
|
25
|
+
}
|
|
26
|
+
return { kind: "multiple", choices };
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=selectChoices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectChoices.js","sourceRoot":"","sources":["../../../../src/prompt/ink/selectChoices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqBH;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAgC;IAEhC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACnD,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Ink wizard's controller — plain TypeScript, NO React.
|
|
3
|
+
*
|
|
4
|
+
* It sits between the seam (which drives the task and calls it per `Prompt`
|
|
5
|
+
* effect + per completed effect) and the React `<Wizard>` view (which
|
|
6
|
+
* subscribes to it). This split keeps the answer/preview/progress state machine
|
|
7
|
+
* out of React and lets the view be a pure projection of controller state.
|
|
8
|
+
*
|
|
9
|
+
* Lives under `prompt/ink/**`, so it is only ever reached through the dynamic
|
|
10
|
+
* `import("./mount.js")` boundary — it never lands in summon-core's static
|
|
11
|
+
* graph, even though it carries no JSX itself.
|
|
12
|
+
*/
|
|
13
|
+
import { dryRun, TaskExecutionError, } from "@canonical/task";
|
|
14
|
+
import { CONFIRM_ANSWER_KEY, GENERATOR_CANCELLED, } from "../../execute/execute.js";
|
|
15
|
+
/** Count the prompts that apply given the answers so far (respecting `when`). */
|
|
16
|
+
function countApplicable(generator, answers) {
|
|
17
|
+
return generator.prompts.filter((p) => !p.when || p.when(answers) === true)
|
|
18
|
+
.length;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The controller: a tiny observable state machine driving the Ink wizard.
|
|
22
|
+
*/
|
|
23
|
+
export class SessionController {
|
|
24
|
+
onUserCancel;
|
|
25
|
+
current;
|
|
26
|
+
listeners = new Set();
|
|
27
|
+
pending;
|
|
28
|
+
executionStart = 0;
|
|
29
|
+
/**
|
|
30
|
+
* @param generator - The generator being run.
|
|
31
|
+
* @param onUserCancel - Invoked once when the user cancels (Ctrl-C / escape).
|
|
32
|
+
* The seam wires this to the run's `AbortController.abort()`, so a Ctrl-C
|
|
33
|
+
* DURING execution actually interrupts the interpreter (its
|
|
34
|
+
* `checkInterrupted` fires between effects) instead of only rejecting a
|
|
35
|
+
* — by then non-existent — pending prompt. `abort()` is idempotent, so the
|
|
36
|
+
* signal→cancel→abort path cannot loop.
|
|
37
|
+
*/
|
|
38
|
+
constructor(generator, onUserCancel) {
|
|
39
|
+
this.onUserCancel = onUserCancel;
|
|
40
|
+
this.current = {
|
|
41
|
+
phase: "idle",
|
|
42
|
+
generator,
|
|
43
|
+
answers: {},
|
|
44
|
+
step: 0,
|
|
45
|
+
total: countApplicable(generator, {}),
|
|
46
|
+
previewEffects: [],
|
|
47
|
+
progress: [],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Subscribe to state changes; returns an unsubscribe function. */
|
|
51
|
+
subscribe = (listener) => {
|
|
52
|
+
this.listeners.add(listener);
|
|
53
|
+
return () => {
|
|
54
|
+
this.listeners.delete(listener);
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/** The current immutable snapshot (stable identity between changes). */
|
|
58
|
+
getSnapshot = () => this.current;
|
|
59
|
+
set(next) {
|
|
60
|
+
this.current = { ...this.current, ...next };
|
|
61
|
+
for (const listener of this.listeners)
|
|
62
|
+
listener();
|
|
63
|
+
}
|
|
64
|
+
// ---- seam → controller ---------------------------------------------------
|
|
65
|
+
/**
|
|
66
|
+
* A `Prompt` effect arrived from the running task. Returns a promise the
|
|
67
|
+
* view resolves once the user answers (or the run is cancelled).
|
|
68
|
+
*/
|
|
69
|
+
request(effect) {
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
const isConfirm = effect.question.name === CONFIRM_ANSWER_KEY;
|
|
72
|
+
this.pending = { effect, isConfirm, resolve, reject };
|
|
73
|
+
if (isConfirm) {
|
|
74
|
+
let previewEffects = [];
|
|
75
|
+
try {
|
|
76
|
+
previewEffects = dryRun(this.current.generator.generate(this.current.answers)).effects;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
previewEffects = [];
|
|
80
|
+
}
|
|
81
|
+
this.set({ phase: "confirming", previewEffects });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const answered = Object.keys(this.current.answers).length;
|
|
85
|
+
this.set({
|
|
86
|
+
phase: "prompting",
|
|
87
|
+
activeQuestion: effect,
|
|
88
|
+
step: answered + 1,
|
|
89
|
+
total: countApplicable(this.current.generator, this.current.answers),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/** Feed effect start (kept for seam symmetry; progress rides completion). */
|
|
95
|
+
reportEffectStart(_effect) {
|
|
96
|
+
// No-op: the live view is driven by reportEffectComplete.
|
|
97
|
+
}
|
|
98
|
+
/** Record a completed effect for the live progress view. */
|
|
99
|
+
reportEffectComplete(effect, _duration) {
|
|
100
|
+
const timestamp = this.executionStart > 0 ? performance.now() - this.executionStart : 0;
|
|
101
|
+
this.set({
|
|
102
|
+
phase: this.current.phase === "cancelled" ? "cancelled" : "executing",
|
|
103
|
+
progress: [...this.current.progress, { effect, timestamp }],
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** A task log line (kept for parity; not surfaced by the default view). */
|
|
107
|
+
reportLog(_level, _message) { }
|
|
108
|
+
/** Mark the run complete (the view flashes a completion summary). */
|
|
109
|
+
markComplete() {
|
|
110
|
+
if (this.current.phase === "cancelled" || this.current.phase === "error")
|
|
111
|
+
return;
|
|
112
|
+
this.set({ phase: "complete" });
|
|
113
|
+
}
|
|
114
|
+
/** Mark the run failed. */
|
|
115
|
+
markError(error) {
|
|
116
|
+
this.set({ phase: "error", error });
|
|
117
|
+
}
|
|
118
|
+
// ---- view → controller ---------------------------------------------------
|
|
119
|
+
/** The user answered the active (non-confirm) prompt. */
|
|
120
|
+
submitAnswer(value) {
|
|
121
|
+
const pending = this.pending;
|
|
122
|
+
if (!pending || pending.isConfirm)
|
|
123
|
+
return;
|
|
124
|
+
this.pending = undefined;
|
|
125
|
+
this.current = {
|
|
126
|
+
...this.current,
|
|
127
|
+
answers: {
|
|
128
|
+
...this.current.answers,
|
|
129
|
+
[pending.effect.question.name]: value,
|
|
130
|
+
},
|
|
131
|
+
activeQuestion: undefined,
|
|
132
|
+
};
|
|
133
|
+
for (const listener of this.listeners)
|
|
134
|
+
listener();
|
|
135
|
+
pending.resolve(value);
|
|
136
|
+
}
|
|
137
|
+
/** The user answered the confirm gate. */
|
|
138
|
+
submitConfirm(proceed) {
|
|
139
|
+
const pending = this.pending;
|
|
140
|
+
if (!pending || !pending.isConfirm)
|
|
141
|
+
return;
|
|
142
|
+
this.pending = undefined;
|
|
143
|
+
if (proceed)
|
|
144
|
+
this.executionStart = performance.now();
|
|
145
|
+
this.set({ phase: proceed ? "executing" : "cancelled" });
|
|
146
|
+
pending.resolve(proceed);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The user cancelled (Ctrl-C / escape). Two things must happen, and both are
|
|
150
|
+
* safe to run whether or not a prompt is pending:
|
|
151
|
+
*
|
|
152
|
+
* 1. (H2) Abort the run via `onUserCancel` — a Ctrl-C mid-execution has no
|
|
153
|
+
* pending prompt to reject, so the abort is what actually stops the
|
|
154
|
+
* interpreter (its `checkInterrupted` throws `TASK_INTERRUPTED`).
|
|
155
|
+
* 2. (H1) Reject any pending prompt with a `TaskExecutionError` carrying
|
|
156
|
+
* `GENERATOR_CANCELLED` — NOT a bare `Error`. The interpreter only
|
|
157
|
+
* preserves a thrown error's `.code` for a `TaskExecutionError`; a bare
|
|
158
|
+
* Error flattens to `INTERNAL`, which the CLI boundary renders as a scary
|
|
159
|
+
* "please report this issue" (exit 1). Carrying the code routes an
|
|
160
|
+
* at-prompt cancel through the same clean "Cancelled." (exit 0) path as
|
|
161
|
+
* declining the confirm gate. The reject fails the current `Prompt` effect
|
|
162
|
+
* before the drive loop reaches its next `checkInterrupted`, so it wins
|
|
163
|
+
* deterministically over the concurrent abort.
|
|
164
|
+
*/
|
|
165
|
+
cancel() {
|
|
166
|
+
const pending = this.pending;
|
|
167
|
+
this.pending = undefined;
|
|
168
|
+
this.onUserCancel?.();
|
|
169
|
+
this.set({ phase: "cancelled" });
|
|
170
|
+
pending?.reject(new TaskExecutionError({
|
|
171
|
+
code: GENERATOR_CANCELLED,
|
|
172
|
+
message: "Cancelled.",
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/prompt/ink/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,MAAM,EAIN,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAuClC,iFAAiF;AACjF,SAAS,eAAe,CACtB,SAA8B,EAC9B,OAAgC;IAEhC,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,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OAAgB;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS;YAAE,OAAO;QAC3C,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,OAAO;YAAE,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACrD,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACtB,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QACjC,OAAO,EAAE,MAAM,CACb,IAAI,kBAAkB,CAAC;YACrB,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,YAAY;SACtB,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The interactive Ink prompt strategy — the embedded #819 wizard, seam-backed.
|
|
3
|
+
*
|
|
4
|
+
* CRITICAL (lazy-React discipline): this module's STATIC import graph contains
|
|
5
|
+
* NO JSX and NO `import` of `ink`/`react`. The entire React UI lives under
|
|
6
|
+
* `./ink/**` and is reached ONLY through `await import("./ink/mount.js")` on the
|
|
7
|
+
* first `Prompt` effect. So importing summon-core — or building the pragma
|
|
8
|
+
* command tree, or running `create --yes` (which picks {@link autoPrompt}) —
|
|
9
|
+
* never loads React. The lazy-React guard test enforces this boundary.
|
|
10
|
+
*
|
|
11
|
+
* The session is SESSION-backed, not per-question: one persistent Ink render is
|
|
12
|
+
* stood up on the first prompt and torn down on completion or abort, so it
|
|
13
|
+
* preserves the step-N-of-M header, the live answers table, and the
|
|
14
|
+
* preview/confirm gate across the whole run. The runner feeds it two streams —
|
|
15
|
+
* `Prompt` effects (via `promptHandler`) and effect progress (via
|
|
16
|
+
* `onEffectStart`/`onEffectComplete`/`onLog`) — and it renders both.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Build the interactive Ink session for a generator.
|
|
20
|
+
*
|
|
21
|
+
* The Ink render is not created until the first `Prompt` effect arrives (which
|
|
22
|
+
* dynamically imports the React UI), so picking this strategy on a fast path
|
|
23
|
+
* that never prompts costs nothing and loads no React.
|
|
24
|
+
*
|
|
25
|
+
* @param generator - The generator being run (the session dry-runs it to build
|
|
26
|
+
* the confirm gate's preview).
|
|
27
|
+
* @param options - The abort signal.
|
|
28
|
+
* @returns The {@link InkSession} the `create` verb wires into `runtime.exec`.
|
|
29
|
+
*/
|
|
30
|
+
export default function inkPrompt(generator, options = {}) {
|
|
31
|
+
let mountP;
|
|
32
|
+
let mounted;
|
|
33
|
+
const ensure = () => {
|
|
34
|
+
mountP ??= import("./ink/mount.js").then((mod) => {
|
|
35
|
+
mounted = mod.mountPromptSession(generator, options);
|
|
36
|
+
return mounted;
|
|
37
|
+
});
|
|
38
|
+
return mountP;
|
|
39
|
+
};
|
|
40
|
+
// Cancellation propagates by REJECTION: controller.cancel() rejects the
|
|
41
|
+
// pending answer promise, so a declined/aborted run fails the task straight
|
|
42
|
+
// through here — no separate interrupted flag to read.
|
|
43
|
+
const promptHandler = async (effect) => {
|
|
44
|
+
const session = await ensure();
|
|
45
|
+
return session.answerPrompt(effect);
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
promptHandler,
|
|
49
|
+
onEffectStart: (effect) => mounted?.reportEffectStart(effect),
|
|
50
|
+
onEffectComplete: (effect, duration) => mounted?.reportEffectComplete(effect, duration),
|
|
51
|
+
onLog: (level, message) => mounted?.reportLog(level, message),
|
|
52
|
+
dispose: () => mounted?.dispose(),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=inkPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inkPrompt.js","sourceRoot":"","sources":["../../../src/prompt/inkPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA+CH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAA8B,EAC9B,UAA4B,EAAE;IAE9B,IAAI,MAA2C,CAAC;IAChD,IAAI,OAAmC,CAAC;IAExC,MAAM,MAAM,GAAG,GAA4B,EAAE;QAC3C,MAAM,KAAK,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/C,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,wEAAwE;IACxE,4EAA4E;IAC5E,uDAAuD;IACvD,MAAM,aAAa,GAAkB,KAAK,EAAE,MAAM,EAAE,EAAE;QACpD,MAAM,OAAO,GAAG,MAAM,MAAM,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,OAAO;QACL,aAAa;QACb,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC;QAC7D,gBAAgB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CACrC,OAAO,EAAE,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC;QACjD,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC;QAC7D,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP prompt strategy: resolve every answer from the tool arguments or the
|
|
3
|
+
* prompt's default, and fail structurally otherwise — never block on stdin.
|
|
4
|
+
*
|
|
5
|
+
* An MCP tool call carries all inputs up front as arguments; there is no
|
|
6
|
+
* interactive channel. This handler resolves each `Prompt` effect from the
|
|
7
|
+
* provided `params` (defensively — {@link collectAnswers} already skips provided
|
|
8
|
+
* answers), then the prompt's declared default, and otherwise rejects with a
|
|
9
|
+
* structured `MISSING_REQUIRED_ANSWER` task error. It is synchronous-resolving
|
|
10
|
+
* by construction, so a mutating tool can never hang waiting for input.
|
|
11
|
+
*/
|
|
12
|
+
import { missingRequiredError } from "./autoPrompt.js";
|
|
13
|
+
/**
|
|
14
|
+
* A prompt handler that resolves answers from MCP tool args or defaults.
|
|
15
|
+
*
|
|
16
|
+
* @param params - The tool arguments (already coerced to the answer shape).
|
|
17
|
+
* @returns The MCP {@link PromptHandler} — params-or-default-or-error, never a hang.
|
|
18
|
+
*/
|
|
19
|
+
export default function mcpPrompt(params = {}) {
|
|
20
|
+
return (effect) => {
|
|
21
|
+
const q = effect.question;
|
|
22
|
+
if (q.name in params)
|
|
23
|
+
return Promise.resolve(params[q.name]);
|
|
24
|
+
if (q.default !== undefined)
|
|
25
|
+
return Promise.resolve(q.default);
|
|
26
|
+
return Promise.reject(missingRequiredError(effect, "argument"));
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=mcpPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpPrompt.js","sourceRoot":"","sources":["../../../src/prompt/mcpPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAA4C,EAAE;IAE9C,OAAO,CAAC,MAAoB,EAAE,EAAE;QAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC1B,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC/D,OAAO,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prompt-handling seam types.
|
|
3
|
+
*
|
|
4
|
+
* A {@link PromptHandler} is exactly the shape the task interpreter's
|
|
5
|
+
* `promptHandler` option expects — it receives the whole `Prompt` effect (whose
|
|
6
|
+
* `.question` carries name/message/type/default/choices/validate) and resolves
|
|
7
|
+
* the answer. Every front-end (Ink wizard, MCP args, non-interactive defaults)
|
|
8
|
+
* is one implementation of this single function type, injected into the runner;
|
|
9
|
+
* summon-core never owns a UI toolkit.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/prompt/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/run/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single, UI-free execution point for running a generator or setup Task
|
|
3
|
+
* for real.
|
|
4
|
+
*
|
|
5
|
+
* Every binary — pragma's kernel, summon's Ink TUI — runs its tasks through
|
|
6
|
+
* here. Interactivity is injected as a `promptHandler`, so this core never
|
|
7
|
+
* imports a UI toolkit; the terminal front-ends own that. Centralising
|
|
8
|
+
* execution here gives every command the same working-directory semantics and
|
|
9
|
+
* a single seam where cross-cutting behavior (progress, interception) can be
|
|
10
|
+
* added without touching the callers.
|
|
11
|
+
*
|
|
12
|
+
* Moved into summon-core (from the v1 cli-core) so it sits below both the
|
|
13
|
+
* summon bin and the pragma kernel — the shared seam the byte-equality
|
|
14
|
+
* guarantee rests on. cli-core re-exports it while it is retired.
|
|
15
|
+
*/
|
|
16
|
+
import { runTask } from "@canonical/task/node";
|
|
17
|
+
/**
|
|
18
|
+
* The tail of the queue serialising runs that request a working directory.
|
|
19
|
+
* `process.cwd()` is process-global state, so two concurrent runs with
|
|
20
|
+
* different `cwd` values would race — one could execute its effects in the
|
|
21
|
+
* other's directory, or restore the wrong one. Chaining every cwd-requesting
|
|
22
|
+
* run onto this promise makes them run one at a time; a failed run must not
|
|
23
|
+
* poison the queue, so the stored tail swallows the rejection (the caller
|
|
24
|
+
* still receives it).
|
|
25
|
+
*/
|
|
26
|
+
let cwdQueue = Promise.resolve();
|
|
27
|
+
/**
|
|
28
|
+
* Run a Task for real in the given working directory and return its value.
|
|
29
|
+
*
|
|
30
|
+
* Runs that request a `cwd` are serialised against each other, so concurrent
|
|
31
|
+
* callers cannot interleave `chdir` calls; runs without a `cwd` execute
|
|
32
|
+
* immediately in whatever the current process directory is.
|
|
33
|
+
*
|
|
34
|
+
* @typeParam A - The task's result type.
|
|
35
|
+
* @param task - A freshly-built task to run.
|
|
36
|
+
* @param options - Working directory and injected handlers.
|
|
37
|
+
* @returns The task's value.
|
|
38
|
+
* @note Impure — performs the task's effects and may `chdir`.
|
|
39
|
+
*/
|
|
40
|
+
export default async function runGeneratorTask(task, options = {}) {
|
|
41
|
+
const { cwd, ...runOptions } = options;
|
|
42
|
+
if (cwd === undefined) {
|
|
43
|
+
return runTask(task, runOptions);
|
|
44
|
+
}
|
|
45
|
+
const run = cwdQueue.then(async () => {
|
|
46
|
+
const previousCwd = process.cwd();
|
|
47
|
+
const shouldChdir = cwd !== previousCwd;
|
|
48
|
+
if (shouldChdir) {
|
|
49
|
+
process.chdir(cwd);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
return await runTask(task, runOptions);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
if (shouldChdir) {
|
|
56
|
+
process.chdir(previousCwd);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
cwdQueue = run.then(() => undefined, () => undefined);
|
|
61
|
+
return run;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=runGeneratorTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runGeneratorTask.js","sourceRoot":"","sources":["../../../src/run/runGeneratorTask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAuB,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAsBpE;;;;;;;;GAQG;AACH,IAAI,QAAQ,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAC5C,IAAa,EACb,UAAmC,EAAE;IAErC,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;QACnC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,GAAG,KAAK,WAAW,CAAC;QACxC,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACzC,CAAC;gBAAS,CAAC;YACT,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,QAAQ,GAAG,GAAG,CAAC,IAAI,CACjB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC"}
|