@canonical/summon-core 0.34.0 → 0.36.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/discovery/discoverGeneratorTree.js +14 -10
- package/dist/esm/discovery/discoverGeneratorTree.js.map +1 -1
- package/dist/esm/execute/collectAnswers.js +21 -16
- package/dist/esm/execute/collectAnswers.js.map +1 -1
- package/dist/esm/execute/execute.js +67 -22
- package/dist/esm/execute/execute.js.map +1 -1
- package/dist/esm/execute/index.js +1 -1
- package/dist/esm/execute/index.js.map +1 -1
- package/dist/esm/execute/validateAnswers.js +19 -5
- package/dist/esm/execute/validateAnswers.js.map +1 -1
- package/dist/esm/format/effects.js +197 -51
- package/dist/esm/format/effects.js.map +1 -1
- package/dist/esm/format/formatFlagName.js +17 -0
- package/dist/esm/format/formatFlagName.js.map +1 -0
- package/dist/esm/format/index.js +24 -1
- package/dist/esm/format/index.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/projection/answers.js +84 -0
- package/dist/esm/projection/answers.js.map +1 -0
- package/dist/esm/projection/buildOptionInfo.js +77 -0
- package/dist/esm/projection/buildOptionInfo.js.map +1 -0
- package/dist/esm/projection/commander/configureGroupedHelp.js +39 -0
- package/dist/esm/projection/commander/configureGroupedHelp.js.map +1 -0
- package/dist/esm/projection/commander/emitToProcess.js +15 -0
- package/dist/esm/projection/commander/emitToProcess.js.map +1 -0
- package/dist/esm/projection/commander/index.js +20 -0
- package/dist/esm/projection/commander/index.js.map +1 -0
- package/dist/esm/projection/commander/registerGeneratorCommands.js +222 -0
- package/dist/esm/projection/commander/registerGeneratorCommands.js.map +1 -0
- package/dist/esm/projection/decideInteraction.js +73 -0
- package/dist/esm/projection/decideInteraction.js.map +1 -0
- package/dist/esm/projection/extractAnswers.js +52 -0
- package/dist/esm/projection/extractAnswers.js.map +1 -0
- package/dist/esm/projection/groupedHelp.js +74 -0
- package/dist/esm/projection/groupedHelp.js.map +1 -0
- package/dist/esm/projection/index.js +26 -0
- package/dist/esm/projection/index.js.map +1 -0
- package/dist/esm/projection/kebab.js +18 -0
- package/dist/esm/projection/kebab.js.map +1 -0
- package/dist/esm/projection/projectGenerator.js +46 -0
- package/dist/esm/projection/projectGenerator.js.map +1 -0
- package/dist/esm/projection/types.js +16 -0
- package/dist/esm/projection/types.js.map +1 -0
- package/dist/esm/projection/usage.js +144 -0
- package/dist/esm/projection/usage.js.map +1 -0
- package/dist/esm/prompt/answerPromptWithDefaults.js +7 -5
- package/dist/esm/prompt/answerPromptWithDefaults.js.map +1 -1
- package/dist/esm/prompt/autoPrompt.js +2 -3
- package/dist/esm/prompt/autoPrompt.js.map +1 -1
- package/dist/esm/prompt/ink/Wizard.js +44 -8
- package/dist/esm/prompt/ink/Wizard.js.map +1 -1
- package/dist/esm/prompt/ink/mount.js +20 -8
- package/dist/esm/prompt/ink/mount.js.map +1 -1
- package/dist/esm/prompt/ink/progressWindow.js +131 -3
- package/dist/esm/prompt/ink/progressWindow.js.map +1 -1
- package/dist/esm/prompt/ink/session.js +135 -14
- package/dist/esm/prompt/ink/session.js.map +1 -1
- package/dist/esm/prompt/inkPrompt.js +18 -2
- package/dist/esm/prompt/inkPrompt.js.map +1 -1
- package/dist/esm/prompt/mcpPrompt.js +1 -1
- package/dist/esm/prompt/mcpPrompt.js.map +1 -1
- package/dist/esm/stamp/applyStamp.js +50 -52
- package/dist/esm/stamp/applyStamp.js.map +1 -1
- package/dist/esm/stamp/createStampOnEffectStart.js +4 -1
- package/dist/esm/stamp/createStampOnEffectStart.js.map +1 -1
- package/dist/esm/stamp/runTaskWithStamp.js +8 -9
- package/dist/esm/stamp/runTaskWithStamp.js.map +1 -1
- package/dist/esm/template/index.js +2 -0
- package/dist/esm/template/index.js.map +1 -1
- package/dist/esm/template/loadTemplate.js +43 -0
- package/dist/esm/template/loadTemplate.js.map +1 -0
- package/dist/esm/template/prependStamp.js +11 -8
- package/dist/esm/template/prependStamp.js.map +1 -1
- package/dist/esm/template/rawFile.js +25 -0
- package/dist/esm/template/rawFile.js.map +1 -0
- package/dist/esm/template/tasks/template.js +12 -3
- package/dist/esm/template/tasks/template.js.map +1 -1
- package/dist/esm/template/tasks/templateDir.js +5 -0
- package/dist/esm/template/tasks/templateDir.js.map +1 -1
- package/dist/esm/testing/conformance/fixtures.js +0 -2
- package/dist/esm/testing/conformance/fixtures.js.map +1 -1
- package/dist/esm/testing/conformance/flagizeAnswers.js +91 -0
- package/dist/esm/testing/conformance/flagizeAnswers.js.map +1 -0
- package/dist/esm/testing/conformance/index.js +1 -0
- package/dist/esm/testing/conformance/index.js.map +1 -1
- package/dist/esm/testing/index.js +1 -1
- package/dist/esm/testing/index.js.map +1 -1
- package/dist/types/discovery/discoverGeneratorTree.d.ts +3 -3
- package/dist/types/discovery/discoverGeneratorTree.d.ts.map +1 -1
- package/dist/types/execute/collectAnswers.d.ts +4 -3
- package/dist/types/execute/collectAnswers.d.ts.map +1 -1
- package/dist/types/execute/execute.d.ts +27 -1
- package/dist/types/execute/execute.d.ts.map +1 -1
- package/dist/types/execute/index.d.ts +1 -1
- package/dist/types/execute/index.d.ts.map +1 -1
- package/dist/types/execute/validateAnswers.d.ts.map +1 -1
- package/dist/types/format/effects.d.ts +61 -7
- package/dist/types/format/effects.d.ts.map +1 -1
- package/dist/types/format/formatFlagName.d.ts +14 -0
- package/dist/types/format/formatFlagName.d.ts.map +1 -0
- package/dist/types/format/index.d.ts +21 -1
- package/dist/types/format/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/projection/answers.d.ts +54 -0
- package/dist/types/projection/answers.d.ts.map +1 -0
- package/dist/types/projection/buildOptionInfo.d.ts +25 -0
- package/dist/types/projection/buildOptionInfo.d.ts.map +1 -0
- package/dist/types/projection/commander/configureGroupedHelp.d.ts +29 -0
- package/dist/types/projection/commander/configureGroupedHelp.d.ts.map +1 -0
- package/dist/types/projection/commander/emitToProcess.d.ts +10 -0
- package/dist/types/projection/commander/emitToProcess.d.ts.map +1 -0
- package/dist/types/projection/commander/index.d.ts +21 -0
- package/dist/types/projection/commander/index.d.ts.map +1 -0
- package/dist/types/projection/commander/registerGeneratorCommands.d.ts +95 -0
- package/dist/types/projection/commander/registerGeneratorCommands.d.ts.map +1 -0
- package/dist/types/projection/decideInteraction.d.ts +70 -0
- package/dist/types/projection/decideInteraction.d.ts.map +1 -0
- package/dist/types/projection/extractAnswers.d.ts +23 -0
- package/dist/types/projection/extractAnswers.d.ts.map +1 -0
- package/dist/types/projection/groupedHelp.d.ts +25 -0
- package/dist/types/projection/groupedHelp.d.ts.map +1 -0
- package/dist/types/projection/index.d.ts +29 -0
- package/dist/types/projection/index.d.ts.map +1 -0
- package/dist/types/projection/kebab.d.ts +16 -0
- package/dist/types/projection/kebab.d.ts.map +1 -0
- package/dist/types/projection/projectGenerator.d.ts +22 -0
- package/dist/types/projection/projectGenerator.d.ts.map +1 -0
- package/dist/types/projection/types.d.ts +118 -0
- package/dist/types/projection/types.d.ts.map +1 -0
- package/dist/types/projection/usage.d.ts +92 -0
- package/dist/types/projection/usage.d.ts.map +1 -0
- package/dist/types/prompt/answerPromptWithDefaults.d.ts +5 -3
- package/dist/types/prompt/answerPromptWithDefaults.d.ts.map +1 -1
- package/dist/types/prompt/autoPrompt.d.ts.map +1 -1
- package/dist/types/prompt/index.d.ts +1 -1
- package/dist/types/prompt/index.d.ts.map +1 -1
- package/dist/types/prompt/ink/Wizard.d.ts.map +1 -1
- package/dist/types/prompt/ink/mount.d.ts +3 -2
- package/dist/types/prompt/ink/mount.d.ts.map +1 -1
- package/dist/types/prompt/ink/progressWindow.d.ts +98 -2
- package/dist/types/prompt/ink/progressWindow.d.ts.map +1 -1
- package/dist/types/prompt/ink/session.d.ts +87 -4
- package/dist/types/prompt/ink/session.d.ts.map +1 -1
- package/dist/types/prompt/inkPrompt.d.ts +36 -2
- package/dist/types/prompt/inkPrompt.d.ts.map +1 -1
- package/dist/types/stamp/applyStamp.d.ts +6 -2
- package/dist/types/stamp/applyStamp.d.ts.map +1 -1
- package/dist/types/stamp/createStampOnEffectStart.d.ts.map +1 -1
- package/dist/types/stamp/runTaskWithStamp.d.ts +3 -1
- package/dist/types/stamp/runTaskWithStamp.d.ts.map +1 -1
- package/dist/types/template/index.d.ts +4 -0
- package/dist/types/template/index.d.ts.map +1 -1
- package/dist/types/template/loadTemplate.d.ts +40 -0
- package/dist/types/template/loadTemplate.d.ts.map +1 -0
- package/dist/types/template/prependStamp.d.ts +5 -2
- package/dist/types/template/prependStamp.d.ts.map +1 -1
- package/dist/types/template/rawFile.d.ts +32 -0
- package/dist/types/template/rawFile.d.ts.map +1 -0
- package/dist/types/template/tasks/template.d.ts +8 -0
- package/dist/types/template/tasks/template.d.ts.map +1 -1
- package/dist/types/template/tasks/templateDir.d.ts.map +1 -1
- package/dist/types/template/tasks/types.d.ts +2 -0
- package/dist/types/template/tasks/types.d.ts.map +1 -1
- package/dist/types/testing/conformance/fixtures.d.ts.map +1 -1
- package/dist/types/testing/conformance/flagizeAnswers.d.ts +38 -0
- package/dist/types/testing/conformance/flagizeAnswers.d.ts.map +1 -0
- package/dist/types/testing/conformance/index.d.ts +1 -0
- package/dist/types/testing/conformance/index.d.ts.map +1 -1
- package/dist/types/testing/index.d.ts +1 -1
- package/dist/types/testing/index.d.ts.map +1 -1
- package/dist/types/types/GeneratorDefinition.d.ts +10 -1
- package/dist/types/types/GeneratorDefinition.d.ts.map +1 -1
- package/dist/types/types/ReservedOption.d.ts +1 -1
- package/dist/types/types/ReservedOption.d.ts.map +1 -1
- package/package.json +22 -9
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grouped `--help` for a generator command — the PURE half of the split: the
|
|
3
|
+
* group bucketing and the rendered page, with the host's standard-flag block
|
|
4
|
+
* injected as {@link HostFlags} so each binary shows its own globals above
|
|
5
|
+
* the same generated prompt groups. The Commander installer (and its
|
|
6
|
+
* install-only-when-grouped guard) lives in the adapter seam
|
|
7
|
+
* (`projection/commander/configureGroupedHelp.ts`); this module never
|
|
8
|
+
* touches Commander, not even as types.
|
|
9
|
+
*/
|
|
10
|
+
import buildOptionInfo from "./buildOptionInfo.js";
|
|
11
|
+
/** Fixed width for the option-flags column. */
|
|
12
|
+
const TERM_WIDTH = 28;
|
|
13
|
+
/** The default group for prompts that declare none. */
|
|
14
|
+
const DEFAULT_GROUP_NAME = "Generator Options";
|
|
15
|
+
/** Collect a command's prompt options by group, in declared order. */
|
|
16
|
+
export function buildOptionGroups(prompts) {
|
|
17
|
+
const groups = new Map();
|
|
18
|
+
for (const prompt of prompts) {
|
|
19
|
+
const info = buildOptionInfo(prompt);
|
|
20
|
+
const groupName = info.group ?? DEFAULT_GROUP_NAME;
|
|
21
|
+
if (!groups.has(groupName)) {
|
|
22
|
+
groups.set(groupName, []);
|
|
23
|
+
}
|
|
24
|
+
groups.get(groupName)?.push(info);
|
|
25
|
+
}
|
|
26
|
+
return groups;
|
|
27
|
+
}
|
|
28
|
+
/** One `--help` row: flags column padded to the fixed width, then the text. */
|
|
29
|
+
function formatItem(term, description, defaultVal) {
|
|
30
|
+
const fullDesc = defaultVal
|
|
31
|
+
? `${description} (default: ${JSON.stringify(defaultVal)})`
|
|
32
|
+
: description;
|
|
33
|
+
if (description) {
|
|
34
|
+
const padding = " ".repeat(Math.max(TERM_WIDTH - term.length, 2));
|
|
35
|
+
return ` ${term}${padding}${fullDesc}`;
|
|
36
|
+
}
|
|
37
|
+
return ` ${term}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Render the grouped help text for a command: usage, description, the host's
|
|
41
|
+
* standard-flag block, then each prompt group.
|
|
42
|
+
*
|
|
43
|
+
* @param usage - The command's usage string (the adapter supplies
|
|
44
|
+
* Commander's).
|
|
45
|
+
* @param description - The command's description; `""` skips the block.
|
|
46
|
+
* @param groups - The prompt options by group (see {@link buildOptionGroups}).
|
|
47
|
+
* @param hostFlags - The host's standard-flag rows for the global block.
|
|
48
|
+
* @returns The complete help text.
|
|
49
|
+
*/
|
|
50
|
+
export function renderGroupedHelp(usage, description, groups, hostFlags) {
|
|
51
|
+
let output = "";
|
|
52
|
+
// Usage
|
|
53
|
+
output += `Usage: ${usage}\n`;
|
|
54
|
+
// Description
|
|
55
|
+
if (description) {
|
|
56
|
+
output += `\n${description}\n`;
|
|
57
|
+
}
|
|
58
|
+
// The host's standard flags (Global Options group)
|
|
59
|
+
output += "\nGlobal Options:\n";
|
|
60
|
+
for (const flag of hostFlags) {
|
|
61
|
+
output += formatItem(flag.flags, flag.description);
|
|
62
|
+
output += "\n";
|
|
63
|
+
}
|
|
64
|
+
// Grouped prompt options
|
|
65
|
+
for (const [groupName, options] of groups) {
|
|
66
|
+
output += `\n${groupName}:\n`;
|
|
67
|
+
for (const opt of options) {
|
|
68
|
+
output += formatItem(opt.flags, opt.description, opt.defaultValue);
|
|
69
|
+
output += "\n";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return output;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=groupedHelp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groupedHelp.js","sourceRoot":"","sources":["../../../src/projection/groupedHelp.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD,+CAA+C;AAC/C,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,uDAAuD;AACvD,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C,sEAAsE;AACtE,MAAM,UAAU,iBAAiB,CAC/B,OAA8B;IAE9B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC/C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,I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AAW,CAAC,CAAC;QACnD,MAAM,IAAI,IAAI,CAAC;IACjB,CAAC;IAED,yBAAyB;IACzB,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,MAAM,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,SAAS,KAAK,CAAC;QAC9B,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;YACnE,MAAM,IAAI,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@canonical/summon-core/projection` — the UI-free command-surface DATA seam.
|
|
3
|
+
*
|
|
4
|
+
* Everything a CLI derives from `GeneratorDefinition.prompts` lives here:
|
|
5
|
+
* flag shapes, answer extraction, defaults/completeness arithmetic, the
|
|
6
|
+
* usage-error structures and their parity rendering, and grouped help. Both
|
|
7
|
+
* binaries consume it — the summon bin at its root, pragma mounted under
|
|
8
|
+
* `create` — so the two surfaces cannot drift. The Commander ADAPTER — the
|
|
9
|
+
* registration path, the outcome sink, `emitToProcess` — lives beside it at
|
|
10
|
+
* `@canonical/summon-core/projection/commander`.
|
|
11
|
+
*
|
|
12
|
+
* IMPORT DISCIPLINE (pinned by `lazyGraph.test.ts`): this subpath is pure and
|
|
13
|
+
* parser-agnostic — its runtime graph reaches ZERO bare dependencies (Node
|
|
14
|
+
* built-ins only), never commander (not even as types), never react/ink/ejs/
|
|
15
|
+
* chalk/@canonical/task, and never the summon-core main barrel — so a host
|
|
16
|
+
* may import it statically on its `--help`/`__complete` fast path.
|
|
17
|
+
*/
|
|
18
|
+
export { applyDefaults, explicitAnswersComplete, hasAllRequiredAnswers, pendingPrompts, } from "./answers.js";
|
|
19
|
+
export { default as buildOptionInfo } from "./buildOptionInfo.js";
|
|
20
|
+
export { decideInteraction, missingExplicitFlags, refusalMessage, } from "./decideInteraction.js";
|
|
21
|
+
export { default as extractAnswers } from "./extractAnswers.js";
|
|
22
|
+
export { buildOptionGroups, renderGroupedHelp } from "./groupedHelp.js";
|
|
23
|
+
export { default as toKebabCase } from "./kebab.js";
|
|
24
|
+
export { default as projectGenerator } from "./projectGenerator.js";
|
|
25
|
+
export { excessPositionalError, renderUsageError, unknownSegmentError, } from "./usage.js";
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/projection/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMlE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAWpE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE kebab-case derivation for prompt names — the one function every flag
|
|
3
|
+
* name, refusal list, and validation message derives `--component-path` from
|
|
4
|
+
* `componentPath` with. It used to exist as three private copies (the summon
|
|
5
|
+
* bin's registration, `execute/validateAnswers`, `prompt/autoPrompt`); a
|
|
6
|
+
* message and a flag that disagree about the same prompt's spelling is the
|
|
7
|
+
* defect a single authoring point removes.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Convert a camelCase prompt name to its kebab-case CLI flag form.
|
|
11
|
+
*
|
|
12
|
+
* @param name - The prompt name (`withTests`, `componentPath`).
|
|
13
|
+
* @returns The kebab-case form (`with-tests`, `component-path`).
|
|
14
|
+
*/
|
|
15
|
+
export default function toKebabCase(name) {
|
|
16
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=kebab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kebab.js","sourceRoot":"","sources":["../../../src/projection/kebab.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAY;IAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project a live {@link GeneratorDefinition} onto its serializable command
|
|
3
|
+
* surface — the one image both the summon bin (at run time) and a host's
|
|
4
|
+
* codegen (at build time) derive the SAME grammar from.
|
|
5
|
+
*
|
|
6
|
+
* What survives the projection is exactly what the CLI surface reads: name,
|
|
7
|
+
* type, message, default, choices, positional, group. A `when` condition
|
|
8
|
+
* collapses to `conditional: true` (only a live wizard evaluates the
|
|
9
|
+
* predicate); `validate` is dropped entirely (enforced at execute time by
|
|
10
|
+
* `validateAnswers`, identically for every front-end).
|
|
11
|
+
*/
|
|
12
|
+
/** Project one prompt, keeping only its serializable, surface-bearing fields. */
|
|
13
|
+
function projectPrompt(prompt) {
|
|
14
|
+
return {
|
|
15
|
+
name: prompt.name,
|
|
16
|
+
type: prompt.type,
|
|
17
|
+
message: prompt.message,
|
|
18
|
+
...(prompt.default !== undefined ? { default: prompt.default } : {}),
|
|
19
|
+
...(prompt.choices !== undefined
|
|
20
|
+
? {
|
|
21
|
+
choices: prompt.choices.map((choice) => ({
|
|
22
|
+
label: choice.label,
|
|
23
|
+
value: choice.value,
|
|
24
|
+
})),
|
|
25
|
+
}
|
|
26
|
+
: {}),
|
|
27
|
+
...(prompt.positional === true ? { positional: true } : {}),
|
|
28
|
+
...(prompt.group !== undefined ? { group: prompt.group } : {}),
|
|
29
|
+
...(prompt.when !== undefined ? { conditional: true } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Project a generator onto its serializable {@link SurfaceCommand}.
|
|
34
|
+
*
|
|
35
|
+
* @param path - The command path the generator is mounted at.
|
|
36
|
+
* @param generator - The live generator definition.
|
|
37
|
+
* @returns The serializable command surface.
|
|
38
|
+
*/
|
|
39
|
+
export default function projectGenerator(path, generator) {
|
|
40
|
+
return {
|
|
41
|
+
path: [...path],
|
|
42
|
+
description: generator.meta.description,
|
|
43
|
+
prompts: generator.prompts.map(projectPrompt),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=projectGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectGenerator.js","sourceRoot":"","sources":["../../../src/projection/projectGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,iFAAiF;AACjF,SAAS,aAAa,CAAC,MAAwB;IAC7C,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS;YAC9B,CAAC,CAAC;gBACE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;oBACvC,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB,CAAC,CAAC;aACJ;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,MAAM,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,IAAuB,EACvB,SAA8B;IAE9B,OAAO;QACL,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;QACf,WAAW,EAAE,SAAS,CAAC,IAAI,CAAC,WAAW;QACvC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;KAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command-surface projection's vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* A generator's CLI surface — its command path, its flags, its positional, its
|
|
5
|
+
* grouped help — DERIVES from `GeneratorDefinition.prompts`. This module names
|
|
6
|
+
* the shapes of that derivation: a {@link ProjectedPrompt} is the serializable
|
|
7
|
+
* image of a prompt (functions dropped), a {@link SurfaceCommand} is one
|
|
8
|
+
* command of the projected tree, and {@link CommandEntry}/{@link OptionInfo}
|
|
9
|
+
* are the registration shapes both binaries consume (moved here from the
|
|
10
|
+
* summon bin, which was their only owner).
|
|
11
|
+
*
|
|
12
|
+
* Everything here is data: no functions, so a {@link SurfaceCommand} can be
|
|
13
|
+
* emitted by a build step, committed, and compared against the live generators.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/projection/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The usage-error authority, structure-first: the projection's two designed
|
|
3
|
+
* usage-error classes as STRUCTURED FACTS ({@link UsageError}), with the
|
|
4
|
+
* parity prose a pure function of them ({@link renderUsageError}). No host
|
|
5
|
+
* ever parses a message — a host reframing an error for a machine format
|
|
6
|
+
* reads the fields; a host wanting the default presentation renders them.
|
|
7
|
+
*
|
|
8
|
+
* Parser-agnostic and pure: no Commander, no process, no I/O. The adapter
|
|
9
|
+
* (`projection/commander/`) builds these from Commander state and delivers
|
|
10
|
+
* them through the host's `emit` sink.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Damerau-Levenshtein distance (insert / delete / substitute / adjacent
|
|
14
|
+
* transposition) over a flat row-major matrix — `d[i * width + j]` is the
|
|
15
|
+
* distance between `a`'s first `i` chars and `b`'s first `j` chars.
|
|
16
|
+
*/
|
|
17
|
+
function editDistance(a, b) {
|
|
18
|
+
const width = b.length + 1;
|
|
19
|
+
const d = Array.from({ length: (a.length + 1) * width }, () => 0);
|
|
20
|
+
for (let i = 0; i <= a.length; i += 1)
|
|
21
|
+
d[i * width] = i;
|
|
22
|
+
for (let j = 0; j <= b.length; j += 1)
|
|
23
|
+
d[j] = j;
|
|
24
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
25
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
26
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
27
|
+
let value = Math.min(d[(i - 1) * width + j] + 1, d[i * width + j - 1] + 1, d[(i - 1) * width + j - 1] + cost);
|
|
28
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
29
|
+
value = Math.min(value, d[(i - 2) * width + j - 2] + cost);
|
|
30
|
+
}
|
|
31
|
+
d[i * width + j] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return d[a.length * width + b.length];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The closest segment to a mistyped token: a prefix match wins outright,
|
|
38
|
+
* then the lowest normalized Damerau-Levenshtein distance at or under 0.4 —
|
|
39
|
+
* `suggestNames`' ranking MINUS its exact-match exclusion: a case-only
|
|
40
|
+
* stray (`REACT`) scores 0 on the prefix branch and IS suggested here,
|
|
41
|
+
* where pragma's bin-level suggester deliberately stays silent (its
|
|
42
|
+
* `candidateLower === queryLower` skip). Fuzzed over 200k pairs, the
|
|
43
|
+
* case-only class is the ONLY rank divergence between the two.
|
|
44
|
+
* Case-insensitive; `undefined` when nothing is close (or the token is
|
|
45
|
+
* empty).
|
|
46
|
+
*/
|
|
47
|
+
function closestSegment(query, candidates) {
|
|
48
|
+
if (query === "")
|
|
49
|
+
return undefined;
|
|
50
|
+
const queryLower = query.toLowerCase();
|
|
51
|
+
let best;
|
|
52
|
+
for (const candidate of candidates) {
|
|
53
|
+
const candidateLower = candidate.toLowerCase();
|
|
54
|
+
const score = candidateLower.startsWith(queryLower)
|
|
55
|
+
? 0
|
|
56
|
+
: editDistance(queryLower, candidateLower) /
|
|
57
|
+
Math.max(queryLower.length, candidateLower.length);
|
|
58
|
+
if (score <= 0.4 && (best === undefined || score < best.score)) {
|
|
59
|
+
best = { name: candidate, score };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return best?.name;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The designed unknown-segment error beneath a namespace. Commander's own
|
|
66
|
+
* handling is host-divergent by construction — pragma's namespaces carry an
|
|
67
|
+
* action, so its `unknownCommand` never fires and the mount used to
|
|
68
|
+
* re-implement the line, while summon got commander's `(Did you mean x?)` —
|
|
69
|
+
* so the projection owns this error in BOTH CLIs, in the same
|
|
70
|
+
* `Did you mean '<chain> <segment>'?` shape the excess-positional path
|
|
71
|
+
* already uses, suggesting the closest child segment.
|
|
72
|
+
*
|
|
73
|
+
* @param chain - The invoked namespace's full name chain, root (bin name)
|
|
74
|
+
* first — host-agnostic, so a mounted subtree suggests its real invocation
|
|
75
|
+
* (`pragma create component react`, not a truncated one).
|
|
76
|
+
* @param stray - The unrecognized segment.
|
|
77
|
+
* @param children - The namespace's child segments.
|
|
78
|
+
* @returns The structured error; {@link renderUsageError} yields the bytes.
|
|
79
|
+
*/
|
|
80
|
+
export function unknownSegmentError(chain, stray, children) {
|
|
81
|
+
const headline = `unknown command '${stray}'`;
|
|
82
|
+
const suggestion = closestSegment(stray, children);
|
|
83
|
+
return suggestion === undefined
|
|
84
|
+
? { kind: "unknown-segment", headline, chain }
|
|
85
|
+
: { kind: "unknown-segment", headline, suggestion, chain };
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The designed excess-positional error. Commander's default is a generic "too
|
|
89
|
+
* many arguments"; the projection owns this error in BOTH CLIs: the stray is
|
|
90
|
+
* named, and when an operand matches a sibling or child tree segment the
|
|
91
|
+
* corrected command is suggested (`summon component react svelte …` almost
|
|
92
|
+
* certainly meant `summon component svelte …`).
|
|
93
|
+
*
|
|
94
|
+
* The suggestion scans EVERY operand, not just the excess ones: in
|
|
95
|
+
* `summon component react svelte MyComponent` it is `svelte` — bound as the
|
|
96
|
+
* positional — that names the intended sibling, while `MyComponent` is what
|
|
97
|
+
* overflowed. First matching operand wins; a child segment beats a sibling.
|
|
98
|
+
* A sibling match slices the leaf off the chain BEFORE storing it, so
|
|
99
|
+
* `[...chain, suggestion].join(" ")` is the corrected invocation on every
|
|
100
|
+
* branch.
|
|
101
|
+
*
|
|
102
|
+
* @param chain - The invoked command's full name chain, root (bin name)
|
|
103
|
+
* first — host-agnostic (see {@link unknownSegmentError}).
|
|
104
|
+
* @param stray - The first unexpected operand.
|
|
105
|
+
* @param operands - Every operand the command received (bound + excess).
|
|
106
|
+
* @param siblings - The leaf's sibling segments (other children of its parent).
|
|
107
|
+
* @param children - The leaf's own child segments (runnable-namespace case).
|
|
108
|
+
* @returns The structured error; {@link renderUsageError} yields the bytes.
|
|
109
|
+
*/
|
|
110
|
+
export function excessPositionalError(chain, stray, operands, siblings, children) {
|
|
111
|
+
const headline = `unexpected argument "${stray}"`;
|
|
112
|
+
for (const operand of operands) {
|
|
113
|
+
if (children.has(operand)) {
|
|
114
|
+
return {
|
|
115
|
+
kind: "excess-positional",
|
|
116
|
+
headline,
|
|
117
|
+
suggestion: operand,
|
|
118
|
+
chain,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (siblings.has(operand)) {
|
|
122
|
+
return {
|
|
123
|
+
kind: "excess-positional",
|
|
124
|
+
headline,
|
|
125
|
+
suggestion: operand,
|
|
126
|
+
chain: chain.slice(0, -1),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return { kind: "excess-positional", headline, chain };
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The parity bytes of a usage error (one or two lines, no trailing newline):
|
|
134
|
+
* `error: ${headline}`, then the did-you-mean line when a segment matched —
|
|
135
|
+
* `[...chain, suggestion].join(" ")` is the corrected invocation on every
|
|
136
|
+
* builder branch.
|
|
137
|
+
*/
|
|
138
|
+
export function renderUsageError(error) {
|
|
139
|
+
const headline = `error: ${error.headline}`;
|
|
140
|
+
return error.suggestion === undefined
|
|
141
|
+
? headline
|
|
142
|
+
: `${headline}\nDid you mean '${[...error.chain, error.suggestion].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AAI,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1B,OAAO;gBACL,IAAI,EAAE,mBAAmB;gBACzB,QAAQ;gBACR,UAAU,EAAE,OAAO;gBACnB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAC1B,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,MAAM,QAAQ,GAAG,UAAU,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5C,OAAO,KAAK,CAAC,UAAU,KAAK,SAAS;QACnC,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,GAAG,QAAQ,mBAAmB,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;AACrF,CAAC"}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
* defaults-only handler the summon Ink progress view drives, and the base the
|
|
4
4
|
* seam's {@link autoPrompt} strategy layers required-missing detection on.
|
|
5
5
|
*
|
|
6
|
-
* Each prompt type yields the value a non-interactive run should assume
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Each prompt type yields the value a non-interactive run should assume,
|
|
7
|
+
* ALIGNED with the dry-run interpreter's mock so a plan and a defaults-driven
|
|
8
|
+
* run take the same branches: a confirm's default (or `false`), a select's
|
|
9
|
+
* default (or its first choice, or `""`), an empty multiselect, or a text
|
|
10
|
+
* default (or `""`).
|
|
9
11
|
*
|
|
10
12
|
* @param effect - A `Prompt` effect to resolve.
|
|
11
13
|
* @returns The default answer for the prompt's type.
|
|
@@ -14,9 +16,9 @@ export default function answerPromptWithDefaults(effect) {
|
|
|
14
16
|
const question = effect.question;
|
|
15
17
|
switch (question.type) {
|
|
16
18
|
case "confirm":
|
|
17
|
-
return Promise.resolve(question.default ??
|
|
19
|
+
return Promise.resolve(question.default ?? false);
|
|
18
20
|
case "select":
|
|
19
|
-
return Promise.resolve(question.default ?? question.choices[0]?.value);
|
|
21
|
+
return Promise.resolve(question.default ?? question.choices[0]?.value ?? "");
|
|
20
22
|
case "multiselect":
|
|
21
23
|
return Promise.resolve(question.default ?? []);
|
|
22
24
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answerPromptWithDefaults.js","sourceRoot":"","sources":["../../../src/prompt/answerPromptWithDefaults.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"answerPromptWithDefaults.js","sourceRoot":"","sources":["../../../src/prompt/answerPromptWithDefaults.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,MAAmC;IAEnC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,SAAS;YACZ,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;QACpD,KAAK,QAAQ;YACX,OAAO,OAAO,CAAC,OAAO,CACpB,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CACrD,CAAC;QACJ,KAAK,aAAa;YAChB,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QACjD;YACE,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
import { TaskExecutionError } from "@canonical/task";
|
|
14
14
|
/** The task-error code raised when a required answer is neither provided nor defaulted. */
|
|
15
15
|
export const MISSING_REQUIRED_ANSWER = "MISSING_REQUIRED_ANSWER";
|
|
16
|
-
|
|
17
|
-
const toKebab = (name) => name.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
16
|
+
import formatFlagName from "../format/formatFlagName.js";
|
|
18
17
|
/**
|
|
19
18
|
* Build the structured error for a required, unprovided answer.
|
|
20
19
|
*
|
|
@@ -26,7 +25,7 @@ export function missingRequiredError(effect, noun = "flag") {
|
|
|
26
25
|
const { name, message } = effect.question;
|
|
27
26
|
return new TaskExecutionError({
|
|
28
27
|
code: MISSING_REQUIRED_ANSWER,
|
|
29
|
-
message: `Missing required ${noun} --${
|
|
28
|
+
message: `Missing required ${noun} --${formatFlagName(name)} (${message}). Provide it non-interactively, or run interactively to be prompted.`,
|
|
30
29
|
context: { answer: name },
|
|
31
30
|
});
|
|
32
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoPrompt.js","sourceRoot":"","sources":["../../../src/prompt/autoPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAEjE,
|
|
1
|
+
{"version":3,"file":"autoPrompt.js","sourceRoot":"","sources":["../../../src/prompt/autoPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAEjE,OAAO,cAAc,MAAM,6BAA6B,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAoB,EACpB,OAA4B,MAAM;IAElC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC1C,OAAO,IAAI,kBAAkB,CAAC;QAC5B,IAAI,EAAE,uBAAuB;QAC7B,OAAO,EAAE,oBAAoB,IAAI,MAAM,cAAc,CAAC,IAAI,CAAC,KAAK,OAAO,uEAAuE;QAC9I,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;KAC1B,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,UAA6C,EAAE;IAE/C,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC1B,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,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -8,7 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
import { describeEffect } from "@canonical/task";
|
|
9
9
|
import { Box, Static, Text, useInput } from "ink";
|
|
10
10
|
import { useEffect, useState } from "react";
|
|
11
|
-
import { truncateMiddle } from "./progressWindow.js";
|
|
11
|
+
import { COMPLETED_GLYPH, describedWidthBudget, FAILURE_GLYPH, formatEffectDuration, truncateMiddle, } from "./progressWindow.js";
|
|
12
12
|
import { AnswersTable, ProgressHeader, QuestionView } from "./prompts.js";
|
|
13
13
|
import { Spinner } from "./Spinner.js";
|
|
14
14
|
/** A compact summary of the effects the confirm gate is about to apply. */
|
|
@@ -62,14 +62,46 @@ const EffectsSummary = ({ effects }) => {
|
|
|
62
62
|
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { bold: true, dimColor: true, children: "Operations:" }), rows.map((row) => (_jsxs(Box, { children: [_jsxs(Text, { dimColor: true, children: [" ", row.label.padEnd(width), " "] }), _jsx(Text, { color: "green", children: row.count })] }, row.label)))] }));
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
65
|
-
* Live progress: the file effects completed so far.
|
|
65
|
+
* Live progress: the file effects completed so far, each with what it cost.
|
|
66
66
|
*
|
|
67
67
|
* The completed lines render under Ink's `<Static>` (C7): each is printed ONCE,
|
|
68
68
|
* to the scrollback above the live region, instead of the whole history being
|
|
69
69
|
* re-rendered on every new effect — the flicker/scroll a big scaffold otherwise
|
|
70
70
|
* caused. Each line is middle-truncated so a long path stays on ONE row. Only
|
|
71
71
|
* the trailing spinner remains in the live (re-rendered) frame.
|
|
72
|
+
*
|
|
73
|
+
* The trailing `(12ms)` is the duration the seam already delivers per effect
|
|
74
|
+
* (`SessionController.reportEffectComplete`) — same spelling as the summon
|
|
75
|
+
* binary's timed view. The description is truncated against a budget that has
|
|
76
|
+
* everything rendered around it — the `✓ ` prefix as well as the suffix —
|
|
77
|
+
* reserved out of it ({@link describedWidthBudget}), so neither the glyph nor
|
|
78
|
+
* the timing can push the row past the one-line cap.
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* Live progress in the HOST's units — rendered whenever the host has reported
|
|
82
|
+
* steps ({@link SessionController.reportStep}), in place of the per-effect
|
|
83
|
+
* transcript below. One row per step: a settled row wears the shared outcome
|
|
84
|
+
* glyph and its wall time, the running one a spinner. The glyphs, the duration
|
|
85
|
+
* spelling and the one-row truncation are the transcript's own — the two views
|
|
86
|
+
* share one dialect; they differ only in what a row IS.
|
|
87
|
+
*
|
|
88
|
+
* Rendered in the LIVE region, never under `<Static>`, and that is
|
|
89
|
+
* load-bearing: `execute` walks `generate` on the mock interpreter once after
|
|
90
|
+
* consent (the outcome summary's file list), so the board fills with
|
|
91
|
+
* near-zero-duration rows once before the real drive resets and repaints it
|
|
92
|
+
* (see {@link SessionController.reportStep}) — and a static row cannot be
|
|
93
|
+
* taken back. The list is bounded by the host's own step count (one row per
|
|
94
|
+
* setup target), so the full-repaint cost `<Static>` exists to avoid does not
|
|
95
|
+
* arise.
|
|
72
96
|
*/
|
|
97
|
+
const StepRow = ({ step }) => {
|
|
98
|
+
if (step.status === "running") {
|
|
99
|
+
return (_jsx(Box, { children: _jsx(Spinner, { color: "blue", label: truncateMiddle(step.label, describedWidthBudget("")) }) }));
|
|
100
|
+
}
|
|
101
|
+
const duration = formatEffectDuration(step.duration ?? 0);
|
|
102
|
+
return (_jsxs(Text, { children: [step.status === "failed" ? (_jsx(Text, { color: "red", children: FAILURE_GLYPH })) : (_jsx(Text, { color: "green", children: COMPLETED_GLYPH })), " ", truncateMiddle(step.label, describedWidthBudget(duration)), " ", _jsx(Text, { dimColor: true, children: duration })] }));
|
|
103
|
+
};
|
|
104
|
+
const StepsProgress = ({ state }) => (_jsx(Box, { flexDirection: "column", children: state.steps.map((step) => (_jsx(StepRow, { step: step }, step.key))) }));
|
|
73
105
|
const Progress = ({ state }) => {
|
|
74
106
|
const shown = state.progress.filter((t) => t.effect._tag !== "Log" &&
|
|
75
107
|
t.effect._tag !== "Exists" &&
|
|
@@ -79,9 +111,12 @@ const Progress = ({ state }) => {
|
|
|
79
111
|
t.effect._tag !== "Prompt" &&
|
|
80
112
|
t.effect._tag !== "Parallel" &&
|
|
81
113
|
t.effect._tag !== "Race");
|
|
82
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: shown, children: (t, i) =>
|
|
83
|
-
|
|
84
|
-
|
|
114
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: shown, children: (t, i) => {
|
|
115
|
+
const duration = formatEffectDuration(t.duration);
|
|
116
|
+
return (
|
|
117
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: append-only progress; a path may repeat
|
|
118
|
+
_jsxs(Text, { children: [_jsx(Text, { color: "green", children: COMPLETED_GLYPH }), " ", truncateMiddle(describeEffect(t.effect), describedWidthBudget(duration)), " ", _jsx(Text, { dimColor: true, children: duration })] }, `${t.effect._tag}-${i}`));
|
|
119
|
+
} }), state.phase === "executing" && (_jsx(Box, { children: _jsx(Spinner, { color: "blue", label: "Generating\u2026" }) }))] }));
|
|
85
120
|
};
|
|
86
121
|
/** The wizard view — subscribes to the controller and renders its phase. */
|
|
87
122
|
export const Wizard = ({ controller }) => {
|
|
@@ -102,15 +137,16 @@ export const Wizard = ({ controller }) => {
|
|
|
102
137
|
controller.submitConfirm(false);
|
|
103
138
|
}, { isActive: state.phase === "confirming" });
|
|
104
139
|
const { generator } = state;
|
|
105
|
-
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { bold: true, color: "magenta", children: generator.meta.name }), _jsxs(Text, { dimColor: true, children: [" v", generator.meta.version] })] }), state.phase === "idle" && _jsx(Spinner, { label: "Loading\u2026" }), state.phase === "prompting" && state.activeQuestion && (_jsxs(Box, { flexDirection: "column", children: [_jsx(ProgressHeader, { current: state.step, total: state.total }), _jsx(AnswersTable, { prompts: generator.prompts, answers: state.answers }), _jsx(QuestionView, { question: state.activeQuestion.question, validate: generator.prompts.find((p) => p.name === state.activeQuestion?.question.name)?.validate, onSubmit: (value) => controller.submitAnswer(value), onCancel: () => controller.cancel() })] })), state.phase === "confirming" && (_jsxs(Box, { flexDirection: "column", children: [_jsx(AnswersTable, { prompts: generator.prompts, answers: state.answers }), _jsx(EffectsSummary, { effects: state.previewEffects }), _jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\u203A " }), _jsx(Text, { bold: true, children: "Proceed? " }), _jsx(Text, { dimColor: true, children: "(Y/n)" })] })] })), (state.phase === "executing" || state.phase === "complete") &&
|
|
140
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { bold: true, color: "magenta", children: generator.meta.name }), _jsxs(Text, { dimColor: true, children: [" v", generator.meta.version] })] }), state.phase === "idle" && _jsx(Spinner, { label: "Loading\u2026" }), state.phase === "prompting" && state.activeQuestion && (_jsxs(Box, { flexDirection: "column", children: [_jsx(ProgressHeader, { current: state.step, total: state.total }), _jsx(AnswersTable, { prompts: generator.prompts, answers: state.answers }), _jsx(QuestionView, { question: state.activeQuestion.question, validate: generator.prompts.find((p) => p.name === state.activeQuestion?.question.name)?.validate, onSubmit: (value) => controller.submitAnswer(value), onCancel: () => controller.cancel() }, state.activeQuestion.question.name)] })), state.phase === "confirming" && (_jsxs(Box, { flexDirection: "column", children: [_jsx(AnswersTable, { prompts: generator.prompts, answers: state.answers }), _jsx(EffectsSummary, { effects: state.previewEffects }), _jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\u203A " }), _jsx(Text, { bold: true, children: "Proceed? " }), _jsx(Text, { dimColor: true, children: "(Y/n)" })] })] })), (state.phase === "executing" || state.phase === "complete") &&
|
|
141
|
+
(state.steps.length > 0 ? (_jsx(StepsProgress, { state: state })) : (_jsx(Progress, { state: state }))), state.phase === "complete" && state.steps.length === 0 && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "green", children: [COMPLETED_GLYPH, " Generation complete!"] }) })), state.phase === "cancelled" &&
|
|
106
142
|
(() => {
|
|
107
143
|
// Truthful (H2): a Ctrl-C mid-execution may have written some files
|
|
108
144
|
// before the abort landed, so count the completed write-like effects
|
|
109
145
|
// the session already tracked rather than always claiming none.
|
|
110
146
|
const written = state.progress.filter((t) => ["WriteFile", "AppendFile", "Symlink", "CopyFile"].includes(t.effect._tag)).length;
|
|
111
|
-
return (_jsxs(Text, { color: "yellow", children: ["
|
|
147
|
+
return (_jsxs(Text, { color: "yellow", children: [FAILURE_GLYPH, " Cancelled.", " ", written === 0
|
|
112
148
|
? "No files were written."
|
|
113
149
|
: `${written} file(s) were written.`] }));
|
|
114
|
-
})(), state.phase === "error" && (_jsxs(Text, { color: "red", children: ["
|
|
150
|
+
})(), state.phase === "error" && (_jsxs(Text, { color: "red", children: [FAILURE_GLYPH, " Error: ", state.error?.message] }))] }));
|
|
115
151
|
};
|
|
116
152
|
//# sourceMappingURL=Wizard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wizard.js","sourceRoot":"","sources":["../../../../src/prompt/ink/Wizard.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAe,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"Wizard.js","sourceRoot":"","sources":["../../../../src/prompt/ink/Wizard.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAe,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAOvC,2EAA2E;AAC3E,MAAM,cAAc,GAAG,CAAC,EAAE,OAAO,EAAkC,EAAE,EAAE;IACrE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,QAAQ,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CAAC,CACF,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,GAAI,CAC3B,CAAC,EASH,KAAK,CAAC,KAAK,KAAK,UAAU,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CACzD,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,MAAC,IAAI,IAAC,KAAK,EAAC,OAAO,aAAE,eAAe,6BAA6B,GAC7D,CACP,EAEA,KAAK,CAAC,KAAK,KAAK,WAAW;gBAC1B,CAAC,GAAG,EAAE;oBACJ,oEAAoE;oBACpE,qEAAqE;oBACrE,gEAAgE;oBAChE,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1C,CAAC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,QAAQ,CACzD,CAAC,CAAC,MAAM,CAAC,IAAI,CACd,CACF,CAAC,MAAM,CAAC;oBACT,OAAO,CACL,MAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,aACjB,aAAa,iBAAa,GAAG,EAC7B,OAAO,KAAK,CAAC;gCACZ,CAAC,CAAC,wBAAwB;gCAC1B,CAAC,CAAC,GAAG,OAAO,wBAAwB,IACjC,CACR,CAAC;gBACJ,CAAC,CAAC,EAAE,EAEL,KAAK,CAAC,KAAK,KAAK,OAAO,IAAI,CAC1B,MAAC,IAAI,IAAC,KAAK,EAAC,KAAK,aACd,aAAa,cAAU,KAAK,CAAC,KAAK,EAAE,OAAO,IACvC,CACR,IACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -15,7 +15,7 @@ export function mountPromptSession(generator, options = {}) {
|
|
|
15
15
|
// controller.cancel(), which invokes this to abort the interpreter. `cwd` is
|
|
16
16
|
// the write root the confirm gate's preview reads against, so the pane shows
|
|
17
17
|
// the plan for the tree the run will actually write into.
|
|
18
|
-
const controller = new SessionController(generator, options.onCancel, options.cwd);
|
|
18
|
+
const controller = new SessionController(generator, options.onCancel, options.cwd, options.initialAnswers);
|
|
19
19
|
const instance = render(_jsx(Wizard, { controller: controller }), {
|
|
20
20
|
stdout: process.stderr,
|
|
21
21
|
stdin: process.stdin,
|
|
@@ -24,19 +24,31 @@ export function mountPromptSession(generator, options = {}) {
|
|
|
24
24
|
const { signal } = options;
|
|
25
25
|
const onAbort = () => controller.cancel();
|
|
26
26
|
signal?.addEventListener("abort", onAbort);
|
|
27
|
-
let
|
|
27
|
+
let disposal;
|
|
28
28
|
return {
|
|
29
29
|
answerPrompt: (effect) => controller.request(effect),
|
|
30
30
|
reportEffectStart: (effect) => controller.reportEffectStart(effect),
|
|
31
31
|
reportEffectComplete: (effect, duration) => controller.reportEffectComplete(effect, duration),
|
|
32
32
|
reportLog: (level, message) => controller.reportLog(level, message),
|
|
33
|
+
reportStep: (report) => controller.reportStep(report),
|
|
33
34
|
dispose: () => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
// MEMOIZED, not boolean-guarded: every caller — however many, however
|
|
36
|
+
// concurrent — gets THE one disposal. A guard that returned early made
|
|
37
|
+
// a second concurrent dispose() resolve BEFORE the first had flushed
|
|
38
|
+
// the final frame, which breaks the contract awaiting dispose() exists
|
|
39
|
+
// for: a caller could print into a still-mounted UI.
|
|
40
|
+
disposal ??= (async () => {
|
|
41
|
+
controller.markComplete();
|
|
42
|
+
signal?.removeEventListener("abort", onAbort);
|
|
43
|
+
// Let React COMMIT the state just reported (markComplete, and a run's
|
|
44
|
+
// last effect/step — its scheduler commits on a macrotask) before the
|
|
45
|
+
// unmount flushes the final frame. Unmounting in the same continuation
|
|
46
|
+
// flushed the previously committed tree, so the last row of a run was
|
|
47
|
+
// permanently painted as still in progress.
|
|
48
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
49
|
+
instance.unmount();
|
|
50
|
+
})();
|
|
51
|
+
return disposal;
|
|
40
52
|
},
|
|
41
53
|
};
|
|
42
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../../../src/prompt/ink/mount.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAI7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../../../src/prompt/ink/mount.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAI7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAYrC;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAA8B,EAC9B,UAA4B,EAAE;IAE9B,8DAA8D;IAC9D,6EAA6E;IAC7E,6EAA6E;IAC7E,0DAA0D;IAC1D,MAAM,UAAU,GAAG,IAAI,iBAAiB,CACtC,SAAS,EACT,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,GAAG,EACX,OAAO,CAAC,cAAc,CACvB,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAC,MAAM,IAAC,UAAU,EAAE,UAAU,GAAI,EAAE;QAC1D,MAAM,EAAE,OAAO,CAAC,MAAuC;QACvD,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,KAAK;KACnB,CAAC,CAAC;IAEH,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,OAAO,GAAG,GAAS,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;IAChD,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE3C,IAAI,QAAmC,CAAC;IACxC,OAAO;QACL,YAAY,EAAE,CAAC,MAA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