@canonical/summon-core 0.34.0 → 0.35.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 +19 -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/mount.js +1 -1
- package/dist/esm/prompt/ink/mount.js.map +1 -1
- package/dist/esm/prompt/ink/session.js +21 -6
- package/dist/esm/prompt/ink/session.js.map +1 -1
- package/dist/esm/prompt/inkPrompt.js +10 -1
- 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 +20 -1
- package/dist/types/format/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -4
- 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/ink/mount.d.ts.map +1 -1
- package/dist/types/prompt/ink/session.d.ts +1 -1
- package/dist/types/prompt/ink/session.d.ts.map +1 -1
- package/dist/types/prompt/inkPrompt.d.ts +7 -0
- 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 +21 -8
|
@@ -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,IAAI,kBAAkB,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAC5B,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+EAA+E;AAC/E,SAAS,UAAU,CACjB,IAAY,EACZ,WAAmB,EACnB,UAA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,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].join(" ")}'?`;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/projection/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAoCH;;;;GAIG;AACH,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS;IACxC,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,MAAM,CAAC,GAAa,KAAK,CAAC,IAAI,CAAC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AM,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"}
|
|
@@ -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,
|
|
@@ -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;AAWrC;;;;;;;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,
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../../../src/prompt/ink/mount.tsx"],"names":[],"mappings":";AAW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K,EAAE,OAAO,CAAC;QACnE,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,UAAU,CAAC,YAAY,EAAE,CAAC;YAC1B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -13,10 +13,22 @@
|
|
|
13
13
|
import { TaskExecutionError, } from "@canonical/task";
|
|
14
14
|
import { runPreview } from "@canonical/task/node";
|
|
15
15
|
import { CONFIRM_ANSWER_KEY, GENERATOR_CANCELLED, } from "../../execute/execute.js";
|
|
16
|
+
/** The prompts that apply given the answers so far (respecting `when`). */
|
|
17
|
+
function listApplicablePrompts(generator, answers) {
|
|
18
|
+
return generator.prompts.filter((p) => !p.when || p.when(answers) === true);
|
|
19
|
+
}
|
|
16
20
|
/** Count the prompts that apply given the answers so far (respecting `when`). */
|
|
17
21
|
function countApplicable(generator, answers) {
|
|
18
|
-
return generator
|
|
19
|
-
|
|
22
|
+
return listApplicablePrompts(generator, answers).length;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Count the APPLICABLE prompts already answered. The answer bag can carry
|
|
26
|
+
* keys that are not generator prompts at all (pragma's `framework` param) or
|
|
27
|
+
* answers to prompts a `when` currently excludes — counting raw keys let the
|
|
28
|
+
* step counter exceed the total.
|
|
29
|
+
*/
|
|
30
|
+
function countAnswered(generator, answers) {
|
|
31
|
+
return listApplicablePrompts(generator, answers).filter((p) => Object.hasOwn(answers, p.name)).length;
|
|
20
32
|
}
|
|
21
33
|
/**
|
|
22
34
|
* The controller: a tiny observable state machine driving the Ink wizard.
|
|
@@ -43,15 +55,18 @@ export class SessionController {
|
|
|
43
55
|
* the run produces. Omitted falls back to the process cwd, matching a run
|
|
44
56
|
* whose interpreter was given no `cwd`.
|
|
45
57
|
*/
|
|
46
|
-
constructor(generator, onUserCancel, cwd) {
|
|
58
|
+
constructor(generator, onUserCancel, cwd, initialAnswers = {}) {
|
|
47
59
|
this.onUserCancel = onUserCancel;
|
|
48
60
|
this.cwd = cwd;
|
|
61
|
+
// Seed flag/MCP-provided answers: collectAnswers never asks for them, so
|
|
62
|
+
// without the seed the confirm gate's preview and the step counter run
|
|
63
|
+
// against an answer set with those values missing.
|
|
49
64
|
this.current = {
|
|
50
65
|
phase: "idle",
|
|
51
66
|
generator,
|
|
52
|
-
answers: {},
|
|
67
|
+
answers: { ...initialAnswers },
|
|
53
68
|
step: 0,
|
|
54
|
-
total: countApplicable(generator, {}),
|
|
69
|
+
total: countApplicable(generator, { ...initialAnswers }),
|
|
55
70
|
previewEffects: [],
|
|
56
71
|
progress: [],
|
|
57
72
|
};
|
|
@@ -87,7 +102,7 @@ export class SessionController {
|
|
|
87
102
|
this.previewInFlight = this.loadPreview();
|
|
88
103
|
}
|
|
89
104
|
else {
|
|
90
|
-
const answered =
|
|
105
|
+
const answered = countAnswered(this.current.generator, this.current.answers);
|
|
91
106
|
this.set({
|
|
92
107
|
phase: "prompting",
|
|
93
108
|
activeQuestion: effect,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/prompt/ink/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAIL,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAuClC,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/prompt/ink/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAIL,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,s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C;QACF,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS;YAAE,QAAQ,EAAE,CAAC;QAClD,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,0CAA0C;IAC1C,aAAa,CAAC,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"}
|
|
@@ -31,9 +31,18 @@ export default function inkPrompt(generator, options = {}) {
|
|
|
31
31
|
let mountP;
|
|
32
32
|
let mounted;
|
|
33
33
|
const ensure = () => {
|
|
34
|
-
mountP ??= import("./ink/mount.js")
|
|
34
|
+
mountP ??= import("./ink/mount.js")
|
|
35
|
+
.then((mod) => {
|
|
35
36
|
mounted = mod.mountPromptSession(generator, options);
|
|
36
37
|
return mounted;
|
|
38
|
+
})
|
|
39
|
+
.catch((error) => {
|
|
40
|
+
// Do not cache a failure — a trailing catch, so BOTH a failed dynamic
|
|
41
|
+
// import and a throw from mountPromptSession itself (e.g. Ink render)
|
|
42
|
+
// reset the memo; otherwise every later prompt in the session would
|
|
43
|
+
// reuse the same stale rejection.
|
|
44
|
+
mountP = undefined;
|
|
45
|
+
throw error;
|
|
37
46
|
});
|
|
38
47
|
return mountP;
|
|
39
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inkPrompt.js","sourceRoot":"","sources":["../../../src/prompt/inkPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"inkPrompt.js","sourceRoot":"","sources":["../../../src/prompt/inkPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA6DH;;;;;;;;;;;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;aAChC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,sEAAsE;YACtE,sEAAsE;YACtE,oEAAoE;YACpE,kCAAkC;YAClC,MAAM,GAAG,SAAS,CAAC;YACnB,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACL,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"}
|
|
@@ -19,7 +19,7 @@ import { missingRequiredError } from "./autoPrompt.js";
|
|
|
19
19
|
export default function mcpPrompt(params = {}) {
|
|
20
20
|
return (effect) => {
|
|
21
21
|
const q = effect.question;
|
|
22
|
-
if (q.name
|
|
22
|
+
if (Object.hasOwn(params, q.name))
|
|
23
23
|
return Promise.resolve(params[q.name]);
|
|
24
24
|
if (q.default !== undefined)
|
|
25
25
|
return Promise.resolve(q.default);
|
|
@@ -1 +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,
|
|
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,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1E,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"}
|