multi-agents-cli 1.1.73 → 1.1.75
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/lib/steps.js +3 -2
- package/lib/ui.js +30 -18
- package/package.json +1 -1
package/lib/steps.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
const BACK = Symbol('BACK');
|
|
6
6
|
const CONTINUE = Symbol('CONTINUE');
|
|
7
|
-
const RESTART
|
|
7
|
+
const RESTART = Symbol('RESTART');
|
|
8
|
+
const SHOW_LIST = Symbol('SHOW_LIST');
|
|
8
9
|
|
|
9
10
|
// ── Step machine ──────────────────────────────────────────────────────────────
|
|
10
11
|
|
|
@@ -132,4 +133,4 @@ const runQuestions = async (stepDefs, machine) => {
|
|
|
132
133
|
|
|
133
134
|
// ── Exports ───────────────────────────────────────────────────────────────────
|
|
134
135
|
|
|
135
|
-
module.exports = { StepMachine, BACK, CONTINUE, RESTART, runQuestions };
|
|
136
|
+
module.exports = { StepMachine, BACK, CONTINUE, RESTART, SHOW_LIST, runQuestions };
|
package/lib/ui.js
CHANGED
|
@@ -120,7 +120,7 @@ const stepHeader = (stepIndex, totalSteps) => {
|
|
|
120
120
|
|
|
121
121
|
// ── Step selection helpers ────────────────────────────────────────────────────
|
|
122
122
|
|
|
123
|
-
const { BACK, RESTART } = require('./steps');
|
|
123
|
+
const { BACK, RESTART, SHOW_LIST } = require('./steps');
|
|
124
124
|
const { validateCombination, resolveFramework } = require('./validate');
|
|
125
125
|
const { BLOCKS } = require('./data-config');
|
|
126
126
|
|
|
@@ -129,9 +129,13 @@ const NONE_LABEL = '→ None of these - I\'ll specify my own';
|
|
|
129
129
|
// ── Free-text handler (shared by selectRequired + selectOptional) ────────────
|
|
130
130
|
|
|
131
131
|
const handleFreeText = async (prompt, items, stepMachine, stepIndex, context, isOptional, block = null) => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
let typed = '';
|
|
133
|
+
while (!typed) {
|
|
134
|
+
const _res = await prompts({ type: 'text', name: 'value', message: block ? `Type a ${block} framework:` : 'Type your own value:' }, { onCancel: () => process.exit(0) });
|
|
135
|
+
typed = (_res.value || '').trim();
|
|
136
|
+
if (!typed && isOptional) return null;
|
|
137
|
+
if (!typed) console.log(dim(' Please enter a value.'));
|
|
138
|
+
}
|
|
135
139
|
|
|
136
140
|
console.log(dim(' Verifying...'));
|
|
137
141
|
const resolved = await resolveFramework(typed, block);
|
|
@@ -154,7 +158,7 @@ const handleFreeText = async (prompt, items, stepMachine, stepIndex, context, is
|
|
|
154
158
|
{ label: `→ Type a different value` },
|
|
155
159
|
{ label: `→ Choose from the ${block} list` },
|
|
156
160
|
]);
|
|
157
|
-
if (choice === 1) return
|
|
161
|
+
if (choice === 1) return SHOW_LIST;
|
|
158
162
|
return handleFreeText(prompt, items, stepMachine, stepIndex, context, isOptional, block);
|
|
159
163
|
}
|
|
160
164
|
|
|
@@ -170,14 +174,17 @@ const handleFreeText = async (prompt, items, stepMachine, stepIndex, context, is
|
|
|
170
174
|
return typed;
|
|
171
175
|
}
|
|
172
176
|
|
|
173
|
-
// unverified - risk block
|
|
177
|
+
// unverified - show options first, risk block only if user insists
|
|
174
178
|
console.log('');
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
`→
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (
|
|
179
|
+
const unverifiedChoice = await arrowSelect(`"${typed}" couldn't be verified.`, [
|
|
180
|
+
{ label: `→ Type a different value` },
|
|
181
|
+
{ label: `→ Choose from the ${block || 'available'} list` },
|
|
182
|
+
{ label: `→ Proceed with "${typed}" - I accept the risks` },
|
|
183
|
+
]);
|
|
184
|
+
if (unverifiedChoice === 0) return handleFreeText(prompt, items, stepMachine, stepIndex, context, isOptional, block);
|
|
185
|
+
if (unverifiedChoice === 1) return SHOW_LIST;
|
|
186
|
+
|
|
187
|
+
// Proceed with risks - show consequence block
|
|
181
188
|
console.log('');
|
|
182
189
|
console.log(` ${yellow('⚠ Proceeding with an unverified framework may result in:')}`);
|
|
183
190
|
console.log(dim(' · Agent spending excessive tokens resolving unknown setup'));
|
|
@@ -193,9 +200,7 @@ const handleFreeText = async (prompt, items, stepMachine, stepIndex, context, is
|
|
|
193
200
|
|
|
194
201
|
const check = validateCombination(typed, context);
|
|
195
202
|
if (!check.valid) {
|
|
196
|
-
console.log(`
|
|
197
|
-
${yellow('⚠')} ${check.reason}
|
|
198
|
-
`);
|
|
203
|
+
console.log(`\n ${yellow('⚠')} ${check.reason}\n`);
|
|
199
204
|
const opts = [
|
|
200
205
|
'→ Continue - I understand the tradeoff',
|
|
201
206
|
...check.alternatives.map(a => `→ ${a}`),
|
|
@@ -206,7 +211,6 @@ const handleFreeText = async (prompt, items, stepMachine, stepIndex, context, is
|
|
|
206
211
|
if (choice === opts.length - 1) return handleFreeText(prompt, items, stepMachine, stepIndex, context, isOptional, block);
|
|
207
212
|
return check.alternatives[choice - 1];
|
|
208
213
|
}
|
|
209
|
-
|
|
210
214
|
console.log(dim(' Custom value - the agent will handle compatibility at runtime.'));
|
|
211
215
|
return typed;
|
|
212
216
|
};
|
|
@@ -218,7 +222,11 @@ const selectRequired = async (prompt, items, stepMachine, stepIndex, context = {
|
|
|
218
222
|
|
|
219
223
|
const idx = await arrowSelect(prompt, allItems.map(i => ({ label: typeof i === 'string' ? i : i.label })));
|
|
220
224
|
|
|
221
|
-
if (block !== null && idx === items.length)
|
|
225
|
+
if (block !== null && idx === items.length) {
|
|
226
|
+
const ftResult = await handleFreeText(prompt, items, stepMachine, stepIndex, context, false, block);
|
|
227
|
+
if (ftResult === SHOW_LIST) return selectRequired(prompt, items, stepMachine, stepIndex, context, block);
|
|
228
|
+
return ftResult;
|
|
229
|
+
}
|
|
222
230
|
|
|
223
231
|
const navStart = block !== null ? items.length + 1 : items.length;
|
|
224
232
|
if (idx >= navStart) {
|
|
@@ -244,7 +252,11 @@ const selectOptional = async (prompt, items, stepMachine, stepIndex, context = {
|
|
|
244
252
|
if (idx === items.length) return null; // skip
|
|
245
253
|
|
|
246
254
|
const noneIdx = block !== null ? items.length + 1 : -1;
|
|
247
|
-
if (block !== null && idx === noneIdx)
|
|
255
|
+
if (block !== null && idx === noneIdx) {
|
|
256
|
+
const ftResult = await handleFreeText(prompt, items, stepMachine, stepIndex, context, true, block);
|
|
257
|
+
if (ftResult === SHOW_LIST) return selectOptional(prompt, items, stepMachine, stepIndex, context, block);
|
|
258
|
+
return ftResult;
|
|
259
|
+
}
|
|
248
260
|
|
|
249
261
|
const navStart = block !== null ? items.length + 2 : items.length + 1;
|
|
250
262
|
if (idx >= navStart) {
|
package/package.json
CHANGED