@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
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* the single signal that answer collection is complete — which a streaming
|
|
23
23
|
* per-question handler otherwise cannot know.
|
|
24
24
|
*/
|
|
25
|
-
import { type Task } from "@canonical/task";
|
|
25
|
+
import { type Task, TaskExecutionError } from "@canonical/task";
|
|
26
26
|
import type { PromptHandler } from "../prompt/types.js";
|
|
27
27
|
import type GeneratorDefinition from "../types/GeneratorDefinition.js";
|
|
28
28
|
import type { GeneratorResult } from "./GeneratorResult.js";
|
|
@@ -32,6 +32,32 @@ export declare const CONFIRM_ANSWER_KEY = "__summon_proceed__";
|
|
|
32
32
|
export declare const GENERATOR_INVALID_ANSWER = "GENERATOR_INVALID_ANSWER";
|
|
33
33
|
/** Task-error code for a run cancelled at the interactive confirm gate. */
|
|
34
34
|
export declare const GENERATOR_CANCELLED = "GENERATOR_CANCELLED";
|
|
35
|
+
/**
|
|
36
|
+
* Build the typed error a generator's `generate` throws for a CROSS-answer
|
|
37
|
+
* constraint no single prompt's `validate` can see — two answers only valid
|
|
38
|
+
* together. No shipped generator declares one today (application/react's
|
|
39
|
+
* former ssr+router guard is gone with its prompts); the `guarded` fixture
|
|
40
|
+
* in cli/summon's interaction tests shows the shape. It carries the same
|
|
41
|
+
* {@link GENERATOR_INVALID_ANSWER} code the validation failure inside
|
|
42
|
+
* {@link execute} raises, so a host routes it down its existing invalid-input
|
|
43
|
+
* pathway — pragma maps the code to `INVALID_INPUT` (exit 2), the summon bin
|
|
44
|
+
* prints the bare message (exit 2 in a batch mode, the App's error phase in a
|
|
45
|
+
* wizard) — instead of collapsing it into an internal error with a stack.
|
|
46
|
+
*
|
|
47
|
+
* @param message - The human-readable constraint, naming REGISTERED flag
|
|
48
|
+
* spellings (what a user can actually type).
|
|
49
|
+
* @returns The typed error for `generate` to `throw`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function invalidAnswersError(message: string): TaskExecutionError;
|
|
52
|
+
/**
|
|
53
|
+
* True when a thrown value is a generator-raised invalid answer — matched by
|
|
54
|
+
* the {@link GENERATOR_INVALID_ANSWER} code, never by class identity, so the
|
|
55
|
+
* check survives a duplicate module instance across build outputs.
|
|
56
|
+
*
|
|
57
|
+
* @param error - The caught value.
|
|
58
|
+
* @returns Whether the value is an {@link invalidAnswersError} throw.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isInvalidAnswersError(error: unknown): error is Error;
|
|
35
61
|
/** The context {@link execute} builds its task from. */
|
|
36
62
|
export interface ExecuteContext {
|
|
37
63
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/execute/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/execute/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAML,KAAK,IAAI,EACT,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,mBAAmB,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,6EAA6E;AAC7E,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAEvE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAKpE;AAED,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,mFAAmF;IACnF,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,iEAAiE;IACjE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,SAAS,EAAE,mBAAmB,EAC9B,GAAG,EAAE,cAAc,GAClB,IAAI,CAAC,eAAe,CAAC,CAsDvB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { AnswerablePrompt } from "./collectAnswers.js";
|
|
2
2
|
export { default as collectAnswers } from "./collectAnswers.js";
|
|
3
|
-
export { CONFIRM_ANSWER_KEY, default as execute, type ExecuteContext, GENERATOR_CANCELLED, GENERATOR_INVALID_ANSWER, } from "./execute.js";
|
|
3
|
+
export { CONFIRM_ANSWER_KEY, default as execute, type ExecuteContext, GENERATOR_CANCELLED, GENERATOR_INVALID_ANSWER, invalidAnswersError, isInvalidAnswersError, } from "./execute.js";
|
|
4
4
|
export type { GeneratorResult } from "./GeneratorResult.js";
|
|
5
5
|
export { default as validateAnswers } from "./validateAnswers.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execute/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACL,kBAAkB,EAClB,OAAO,IAAI,OAAO,EAClB,KAAK,cAAc,EACnB,mBAAmB,EACnB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execute/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACL,kBAAkB,EAClB,OAAO,IAAI,OAAO,EAClB,KAAK,cAAc,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateAnswers.d.ts","sourceRoot":"","sources":["../../../src/execute/validateAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"validateAnswers.d.ts","sourceRoot":"","sources":["../../../src/execute/validateAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,GAAG,IAAI,CA+Cf"}
|
|
@@ -16,6 +16,55 @@ import type PromptDefinition from "../types/PromptDefinition.js";
|
|
|
16
16
|
* @param verbose - If true, include debug logs
|
|
17
17
|
*/
|
|
18
18
|
export declare const isVisibleEffect: (effect: Effect, verbose?: boolean) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The rows a plan shows: the user-relevant effects, each directory named once.
|
|
21
|
+
*
|
|
22
|
+
* The visibility filter and the `MakeDir` de-duplication are ONE rule with
|
|
23
|
+
* several readers — the summon bin's dry-run, the `--llm` / `--format json`
|
|
24
|
+
* projections below, and the pragma kernel's CLI and MCP previews — and each
|
|
25
|
+
* reader used to carry its own copy of the two steps. A generator that ensures
|
|
26
|
+
* its output directory before every file plans that directory once per file,
|
|
27
|
+
* so the de-duplication is what makes a plan a list of artifacts rather than a
|
|
28
|
+
* list of mkdir calls.
|
|
29
|
+
*
|
|
30
|
+
* @param effects - The effects a run would apply, in order.
|
|
31
|
+
* @param verbose - If true, debug logs stay in the plan.
|
|
32
|
+
* @returns The visible effects, first occurrence of each directory kept.
|
|
33
|
+
*/
|
|
34
|
+
export declare const visiblePlanEffects: (effects: readonly Effect[], verbose?: boolean) => Effect[];
|
|
35
|
+
/**
|
|
36
|
+
* The colour decision a row is rendered under, carried as DATA.
|
|
37
|
+
*
|
|
38
|
+
* {@link formatEffectLine} used to call `chalk` directly, which meant whether a
|
|
39
|
+
* row carried ANSI was decided by chalk's environment detection at the moment
|
|
40
|
+
* of the call. Two of its callers cannot live with that: pragma's CLI preview
|
|
41
|
+
* gates colour on `process.stdout.isTTY` AND chalk's level (so a piped run
|
|
42
|
+
* under `FORCE_COLOR` — which nx exports to every test task — must stay plain
|
|
43
|
+
* while chalk alone would colour it), and the MCP plan payload is structured
|
|
44
|
+
* data read by a model, which must be plain whatever the editor that spawned
|
|
45
|
+
* the server put in the environment.
|
|
46
|
+
*
|
|
47
|
+
* So the decision arrives as an argument. Stripping escapes afterwards would
|
|
48
|
+
* work too and would be wrong: it puts the rule in a second place.
|
|
49
|
+
*/
|
|
50
|
+
export interface EffectStyle {
|
|
51
|
+
/** Whether this style emits ANSI at all. */
|
|
52
|
+
readonly enabled: boolean;
|
|
53
|
+
/** De-emphasize a connector or indent. */
|
|
54
|
+
dim(text: string): string;
|
|
55
|
+
/** Tint an action label, or pass it through when the effect has no colour. */
|
|
56
|
+
paint(color: EffectColor | undefined, text: string): string;
|
|
57
|
+
}
|
|
58
|
+
/** The colours {@link getActionColor} may ask for. */
|
|
59
|
+
export type EffectColor = "green" | "red" | "yellow" | "cyan" | "blue" | "magenta";
|
|
60
|
+
/**
|
|
61
|
+
* Build an {@link EffectStyle} for a known colour decision.
|
|
62
|
+
*
|
|
63
|
+
* @param enabled - True to colour through chalk; false for the identity
|
|
64
|
+
* styler, which emits no escape under any environment.
|
|
65
|
+
* @returns A style whose functions colour, or pass through, accordingly.
|
|
66
|
+
*/
|
|
67
|
+
export declare const effectStyleFor: (enabled: boolean) => EffectStyle;
|
|
19
68
|
/**
|
|
20
69
|
* Get human-readable action label for an effect.
|
|
21
70
|
*/
|
|
@@ -23,15 +72,23 @@ export declare const getActionLabel: (effect: Effect) => string;
|
|
|
23
72
|
/**
|
|
24
73
|
* Get color for action label based on effect type.
|
|
25
74
|
*/
|
|
26
|
-
export declare const getActionColor: (effect: Effect) =>
|
|
75
|
+
export declare const getActionColor: (effect: Effect) => EffectColor | undefined;
|
|
27
76
|
/**
|
|
28
77
|
* Get the payload (description) for an effect.
|
|
29
78
|
*/
|
|
30
79
|
export declare const getEffectPayload: (effect: Effect) => string;
|
|
31
80
|
/**
|
|
32
81
|
* Format a single effect as a CLI line (for non-interactive output).
|
|
82
|
+
*
|
|
83
|
+
* @param effect - The effect to name.
|
|
84
|
+
* @param isLast - True for the final row, which closes the tree connector.
|
|
85
|
+
* @param style - The colour decision. Defaults to chalk's ambient one, which
|
|
86
|
+
* is what the summon bin has always rendered under; a host with its own gate
|
|
87
|
+
* passes {@link effectStyleFor} so the row cannot disagree with the rest of
|
|
88
|
+
* that host's output.
|
|
89
|
+
* @returns The rendered row.
|
|
33
90
|
*/
|
|
34
|
-
export declare const formatEffectLine: (effect: Effect, isLast: boolean) => string;
|
|
91
|
+
export declare const formatEffectLine: (effect: Effect, isLast: boolean, style?: EffectStyle) => string;
|
|
35
92
|
/**
|
|
36
93
|
* Format file content for preview display.
|
|
37
94
|
* Shows line numbers and truncates long content.
|
|
@@ -39,7 +96,7 @@ export declare const formatEffectLine: (effect: Effect, isLast: boolean) => stri
|
|
|
39
96
|
* @param content - The file content to format
|
|
40
97
|
* @param maxLines - Maximum number of lines to show (default: MAX_PREVIEW_LINES)
|
|
41
98
|
*/
|
|
42
|
-
export declare const formatContentPreview: (content: string, maxLines?: number) => string;
|
|
99
|
+
export declare const formatContentPreview: (content: string, maxLines?: number, style?: EffectStyle) => string;
|
|
43
100
|
/**
|
|
44
101
|
* Format an effect with its content (for verbose dry-run mode).
|
|
45
102
|
* This is useful for LLM agents that need to see generated file contents.
|
|
@@ -47,7 +104,7 @@ export declare const formatContentPreview: (content: string, maxLines?: number)
|
|
|
47
104
|
* @param effect - The effect to format
|
|
48
105
|
* @param isLast - Whether this is the last effect in the list
|
|
49
106
|
*/
|
|
50
|
-
export declare const formatEffectWithContent: (effect: Effect, isLast: boolean) => string;
|
|
107
|
+
export declare const formatEffectWithContent: (effect: Effect, isLast: boolean, style?: EffectStyle) => string;
|
|
51
108
|
/**
|
|
52
109
|
* Map file extension to markdown code fence language hint.
|
|
53
110
|
*/
|
|
@@ -60,9 +117,6 @@ export declare const getLlmActionLabel: (effect: Effect) => string;
|
|
|
60
117
|
* Get the path/description for an effect (plain text, for LLM output).
|
|
61
118
|
*/
|
|
62
119
|
export declare const getLlmEffectPath: (effect: Effect) => string;
|
|
63
|
-
/**
|
|
64
|
-
* Build the replay command string from generator name and answers.
|
|
65
|
-
*/
|
|
66
120
|
export declare const buildReplayCommand: (generatorName: string, answers: Record<string, unknown>, prompts: PromptDefinition[]) => string;
|
|
67
121
|
/**
|
|
68
122
|
* Format the full LLM output as a markdown document.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../../src/format/effects.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,mBAAmB,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../../src/format/effects.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,mBAAmB,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC;AAMjE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,iBAAe,KAAG,OA2CjE,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,SAAS,MAAM,EAAE,EAC1B,iBAAe,KACd,MAAM,EAUR,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,0CAA0C;IAC1C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7D;AAED,sDAAsD;AACtD,MAAM,MAAM,WAAW,GACnB,OAAO,GACP,KAAK,GACL,QAAQ,GACR,MAAM,GACN,MAAM,GACN,SAAS,CAAC;AASd;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,OAAO,KAAG,WAOjD,CAAC;AAWF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,MAsD/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,WAAW,GAAG,SA8C7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAwCjD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,EACd,QAAQ,OAAO,EACf,QAAO,WAAkC,KACxC,MASF,CAAC;AAYF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,MAAM,EACf,WAAU,MAA0B,EACpC,QAAO,WAAkC,KACxC,MAsBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,EACd,QAAQ,OAAO,EACf,QAAO,WAAkC,KACxC,MAmBF,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,KAAG,MA8ClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,MAyClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAoCjD,CAAC;AAeF,eAAO,MAAM,kBAAkB,GAC7B,eAAe,MAAM,EACrB,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,gBAAgB,EAAE,KAC1B,MA0BF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAC5B,WAAW,mBAAmB,EAC9B,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,MAAM,EAAE,EACjB,iBAAe,KACd,MAkFF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,mBAAmB,EAC9B,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,MAAM,EAAE,EACjB,iBAAe,KACd,MAAM,CAAC,MAAM,EAAE,OAAO,CAqCxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,mBAAmB,EAC9B,aAAa,MAAM,KAClB,MAkHF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kebab-case CLI flag form of a camelCase prompt name — a named seam
|
|
3
|
+
* over the projection's {@link toKebabCase}, the SINGLE algorithm every
|
|
4
|
+
* user-facing surface uses. Error messages, `--llm` help, and replay
|
|
5
|
+
* commands must all name the same flag the CLI actually registers
|
|
6
|
+
* (`buildOptionInfo` derives registration from the same function), or an
|
|
7
|
+
* error tells the user to pass a flag that does not exist: a private
|
|
8
|
+
* reimplementation here split on `([a-z])([A-Z])` while registration split
|
|
9
|
+
* on `([a-z0-9])([A-Z])`, so `es2015Style` registered as `--es2015-style`
|
|
10
|
+
* but validation and help said `--es2015style`. Delegating — not copying —
|
|
11
|
+
* is what keeps the two surfaces from disagreeing again.
|
|
12
|
+
*/
|
|
13
|
+
export default function formatFlagName(promptName: string): string;
|
|
14
|
+
//# sourceMappingURL=formatFlagName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatFlagName.d.ts","sourceRoot":"","sources":["../../../src/format/formatFlagName.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEjE"}
|
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The effect-formatting seam, served as its own export subpath.
|
|
3
|
+
*
|
|
4
|
+
* `@canonical/summon-core/format` exists so a host can reach the plan rules —
|
|
5
|
+
* {@link visiblePlanEffects}, {@link formatEffectLine} and friends — WITHOUT
|
|
6
|
+
* loading summon-core proper: the barrel pulls the generator runtime and, with
|
|
7
|
+
* it, React, which the pragma CLI keeps off its `--help` / `__complete` fast
|
|
8
|
+
* paths. This module's runtime graph is `chalk` and Node built-ins, so a host
|
|
9
|
+
* pays for the plan rules and nothing else — whether it imports them eagerly,
|
|
10
|
+
* as the summon bin does, or behind a dynamic `import()` at render time, as
|
|
11
|
+
* the pragma kernel does to keep its own fast paths free of this package
|
|
12
|
+
* altogether.
|
|
13
|
+
*
|
|
14
|
+
* One surface, two bins: the summon bin renders its dry-run through these, and
|
|
15
|
+
* so now does the pragma kernel — the reason the rules live here rather than
|
|
16
|
+
* in either host.
|
|
17
|
+
*/
|
|
18
|
+
export type { EffectColor, EffectStyle } from "./effects.js";
|
|
19
|
+
export { buildReplayCommand, effectStyleFor, formatContentPreview, formatEffectLine, formatEffectWithContent, formatLlmHelp, formatLlmJson, formatLlmMarkdown, getActionColor, getActionLabel, getEffectPayload, getLanguageHint, getLlmActionLabel, getLlmEffectPath, isVisibleEffect, visiblePlanEffects, } from "./effects.js";
|
|
20
|
+
export { default as formatFlagName } from "./formatFlagName.js";
|
|
2
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/format/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/format/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,14 +11,14 @@ export type { AnyGenerator, ForbidReserved, GeneratorDefinition, GeneratorMeta,
|
|
|
11
11
|
export type { RunTaskWithStampOptions } from "./stamp/index.js";
|
|
12
12
|
export { applyStamp, createGeneratorStamp, createStampOnEffectStart, runTaskWithStamp, } from "./stamp/index.js";
|
|
13
13
|
export type { AnswerablePrompt, ExecuteContext, GeneratorResult, } from "./execute/index.js";
|
|
14
|
-
export { CONFIRM_ANSWER_KEY, collectAnswers, execute, GENERATOR_CANCELLED, GENERATOR_INVALID_ANSWER, validateAnswers, } from "./execute/index.js";
|
|
14
|
+
export { CONFIRM_ANSWER_KEY, collectAnswers, execute, GENERATOR_CANCELLED, GENERATOR_INVALID_ANSWER, invalidAnswersError, isInvalidAnswersError, validateAnswers, } from "./execute/index.js";
|
|
15
15
|
export type { ConfirmPrompt, InkPromptOptions, InkSession, MultiselectPrompt, PromptEffect, PromptHandler, PromptQuestion, SelectPrompt, TextPrompt, } from "./prompt/index.js";
|
|
16
16
|
export { answerPromptWithDefaults, autoPrompt, inkPrompt, MISSING_REQUIRED_ANSWER, mcpPrompt, missingRequiredError, } from "./prompt/index.js";
|
|
17
|
-
export { buildReplayCommand, formatContentPreview, formatEffectLine, formatEffectWithContent, formatLlmHelp, formatLlmJson, formatLlmMarkdown, getActionColor, getActionLabel, getEffectPayload, getLanguageHint, getLlmActionLabel, getLlmEffectPath, isVisibleEffect, } from "./format/index.js";
|
|
17
|
+
export { buildReplayCommand, effectStyleFor, formatContentPreview, formatEffectLine, formatEffectWithContent, formatLlmHelp, formatLlmJson, formatLlmMarkdown, getActionColor, getActionLabel, getEffectPayload, getLanguageHint, getLlmActionLabel, getLlmEffectPath, isVisibleEffect, visiblePlanEffects, } from "./format/index.js";
|
|
18
18
|
export type { RunGeneratorTaskOptions } from "./run/index.js";
|
|
19
19
|
export { runGeneratorTask } from "./run/index.js";
|
|
20
|
-
export type { TemplateDirOptions, TemplateOptions, TemplatingEngine, } from "./template/index.js";
|
|
21
|
-
export { ejsEngine, generateStamp, generatorComment, getCommentStyle, prependStamp, renderFile, renderString, renderStringAsync, template, templateDir, templateHelpers, withHelpers, } from "./template/index.js";
|
|
20
|
+
export type { LoadedTemplate, RawFileOptions, TemplateDirOptions, TemplateOptions, TemplatingEngine, } from "./template/index.js";
|
|
21
|
+
export { ejsEngine, generateStamp, generatorComment, getCommentStyle, loadTemplate, loadTemplateSync, prependStamp, rawFile, renderFile, renderString, renderStringAsync, template, templateDir, templateHelpers, withHelpers, } from "./template/index.js";
|
|
22
22
|
export { default as discoverGeneratorTree } from "./discovery/discoverGeneratorTree.js";
|
|
23
23
|
export { generatorCache } from "./discovery/generatorCache.js";
|
|
24
24
|
export type { GeneratorNode, GeneratorOrigin } from "./discovery/types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,YAAY,EACV,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAO5B,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,SAAS,EACT,uBAAuB,EACvB,SAAS,EACT,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,YAAY,EACV,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAO5B,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,SAAS,EACT,uBAAuB,EACvB,SAAS,EACT,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMlD,YAAY,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,eAAe,EACf,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answer-set arithmetic over a command's prompts: apply defaults, decide
|
|
3
|
+
* completeness, and derive the wizard's asking list. `applyDefaults` and
|
|
4
|
+
* `hasAllRequiredAnswers` are moved verbatim from the summon bin;
|
|
5
|
+
* `explicitAnswersComplete` and `pendingPrompts` are the two derived facts the
|
|
6
|
+
* shared interaction decision and the wizards stand on.
|
|
7
|
+
*
|
|
8
|
+
* `pendingPrompts` is the wizard-script parity anchor: BOTH products' wizards
|
|
9
|
+
* ask exactly this list (declared order, explicitly-answered prompts skipped,
|
|
10
|
+
* conditional prompts included — their `when` is evaluated live by the wizard).
|
|
11
|
+
*/
|
|
12
|
+
import type { PromptLike } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Check if all required prompts have answers.
|
|
15
|
+
*
|
|
16
|
+
* A prompt is required when it is unconditional and has no default; the check
|
|
17
|
+
* passes when every such prompt is present in `answers`.
|
|
18
|
+
*
|
|
19
|
+
* @param prompts - The command's prompts (live or projected).
|
|
20
|
+
* @param answers - The answer set to check (typically defaults already applied).
|
|
21
|
+
* @returns True when no required prompt is missing.
|
|
22
|
+
*/
|
|
23
|
+
export declare function hasAllRequiredAnswers(prompts: readonly PromptLike[], answers: Record<string, unknown>): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Apply defaults for prompts that don't have answers.
|
|
26
|
+
*
|
|
27
|
+
* @param prompts - The command's prompts (live or projected).
|
|
28
|
+
* @param answers - The provided answers (never mutated).
|
|
29
|
+
* @returns A new answer set with declared defaults filled in.
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyDefaults(prompts: readonly PromptLike[], answers: Record<string, unknown>): Record<string, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the EXPLICIT answers alone fully determine a run: every
|
|
34
|
+
* unconditional prompt is explicitly answered (defaults do not count).
|
|
35
|
+
* Conditional prompts are skipped — whether they even apply is a live-wizard
|
|
36
|
+
* question, and every input they could depend on is already pinned.
|
|
37
|
+
*
|
|
38
|
+
* @param prompts - The command's prompts (live or projected).
|
|
39
|
+
* @param explicit - The explicitly provided answers (no defaults).
|
|
40
|
+
* @returns True when nothing would need to be asked or defaulted.
|
|
41
|
+
*/
|
|
42
|
+
export declare function explicitAnswersComplete(prompts: readonly PromptLike[], explicit: Readonly<Record<string, unknown>>): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The prompts a wizard must still ask, in declared order: every prompt not
|
|
45
|
+
* explicitly answered. Conditional prompts are INCLUDED — the live wizard
|
|
46
|
+
* evaluates their `when` against the answers collected so far and skips the
|
|
47
|
+
* inapplicable ones itself.
|
|
48
|
+
*
|
|
49
|
+
* @param prompts - The command's prompts (live or projected).
|
|
50
|
+
* @param explicit - The explicitly provided answers (no defaults).
|
|
51
|
+
* @returns The asking list, a subsequence of `prompts`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function pendingPrompts<P extends PromptLike>(prompts: readonly P[], explicit: Readonly<Record<string, unknown>>): P[];
|
|
54
|
+
//# sourceMappingURL=answers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answers.d.ts","sourceRoot":"","sources":["../../../src/projection/answers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAO7C;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAQT;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,OAAO,CAMT;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EACjD,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,CAAC,EAAE,CAEL"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive the Commander option for one prompt — the single flag-shape authority
|
|
3
|
+
* both binaries register from (moved verbatim from the summon bin's
|
|
4
|
+
* registration layer).
|
|
5
|
+
*
|
|
6
|
+
* The shapes: a default-`true` confirm registers ONLY its `--no-<kebab>` form
|
|
7
|
+
* (the positive state is the default and needs no flag); a default-`false`
|
|
8
|
+
* confirm registers the positive `--<kebab>`; a select takes `<value>` with its
|
|
9
|
+
* choices listed in the description; a multiselect takes a comma-separated
|
|
10
|
+
* `<values>`; text takes `<value>`.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: defaults are deliberately NOT passed to Commander (`defaultValue` stays
|
|
13
|
+
* unset). Defaults are applied by `applyDefaults()` after answer extraction, so
|
|
14
|
+
* the surface can distinguish "user didn't provide" from "user provided the
|
|
15
|
+
* default value" — which is what keeps explicit answers explicit.
|
|
16
|
+
*/
|
|
17
|
+
import type { OptionInfo, PromptLike } from "./types.js";
|
|
18
|
+
/**
|
|
19
|
+
* Build the Commander option metadata for a prompt.
|
|
20
|
+
*
|
|
21
|
+
* @param prompt - The prompt (live or projected).
|
|
22
|
+
* @returns The option's flags, help text, group and name mapping.
|
|
23
|
+
*/
|
|
24
|
+
export default function buildOptionInfo(prompt: PromptLike): OptionInfo;
|
|
25
|
+
//# sourceMappingURL=buildOptionInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildOptionInfo.d.ts","sourceRoot":"","sources":["../../../src/projection/buildOptionInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAqDtE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The grouped-help INSTALLER — the Commander half of the split: reads the
|
|
3
|
+
* command's usage and description through Commander's help formatter and
|
|
4
|
+
* hands them to the data seam's pure {@link renderGroupedHelp}.
|
|
5
|
+
*
|
|
6
|
+
* Module-internal to the adapter (exported for its tests, never on the
|
|
7
|
+
* subpath index): both hosts reach it only through
|
|
8
|
+
* `registerGeneratorCommands`.
|
|
9
|
+
*/
|
|
10
|
+
import type { Command } from "commander";
|
|
11
|
+
import { renderGroupedHelp } from "../groupedHelp.js";
|
|
12
|
+
import type { HostFlags, PromptLike } from "../types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Configure custom help with grouped options for a command. Under the default
|
|
15
|
+
* presentation, a command whose prompts declare no groups (and collapse to at
|
|
16
|
+
* most one) keeps Commander's default help; a host renderer installs
|
|
17
|
+
* UNCONDITIONALLY — the host chose one help style for every leaf, and leaving
|
|
18
|
+
* its ungrouped generators on Commander's default would reintroduce exactly
|
|
19
|
+
* the inconsistency it supplied the renderer to remove.
|
|
20
|
+
*
|
|
21
|
+
* @param cmd - The command to configure.
|
|
22
|
+
* @param prompts - The command's prompts (live or projected).
|
|
23
|
+
* @param hostFlags - The host's standard-flag rows for the global block.
|
|
24
|
+
* @param renderHelp - The host's own presentation, when it supplies one
|
|
25
|
+
* (see `CommanderHost.renderHelp`); omitted means `renderGroupedHelp`.
|
|
26
|
+
* @note Impure — installs a `configureHelp` override on the command.
|
|
27
|
+
*/
|
|
28
|
+
export default function configureGroupedHelp(cmd: Command, prompts: readonly PromptLike[], hostFlags: HostFlags, renderHelp?: typeof renderGroupedHelp): void;
|
|
29
|
+
//# sourceMappingURL=configureGroupedHelp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureGroupedHelp.d.ts","sourceRoot":"","sources":["../../../../src/projection/commander/configureGroupedHelp.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,SAAS,EAAE,SAAS,EACpB,UAAU,CAAC,EAAE,OAAO,iBAAiB,GACpC,IAAI,CAsBN"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default {@link MountOutcome} presentation both bins share — the ONLY
|
|
3
|
+
* process-touching export in either projection seam: the parity bytes on
|
|
4
|
+
* stderr, the outcome's code on `process.exitCode`.
|
|
5
|
+
*
|
|
6
|
+
* @note Impure — writes stderr, sets the process exit code.
|
|
7
|
+
*/
|
|
8
|
+
import type { MountOutcome } from "./registerGeneratorCommands.js";
|
|
9
|
+
export default function emitToProcess(outcome: MountOutcome): void;
|
|
10
|
+
//# sourceMappingURL=emitToProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitToProcess.d.ts","sourceRoot":"","sources":["../../../../src/projection/commander/emitToProcess.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAOjE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@canonical/summon-core/projection/commander` — the Commander ADAPTER seam.
|
|
3
|
+
*
|
|
4
|
+
* The one registration path both binaries mount their generator grammar
|
|
5
|
+
* through. Everything Commander-shaped lives here; the parser-agnostic data
|
|
6
|
+
* half stays in `@canonical/summon-core/projection`. Every designed
|
|
7
|
+
* non-action outcome (the two usage errors, the bare-namespace help) is
|
|
8
|
+
* delivered to the host's required `emit` sink as a `MountOutcome` — the
|
|
9
|
+
* adapter decides the bytes and the exit code, the host effects them, and
|
|
10
|
+
* `emitToProcess` is the one shared default effect.
|
|
11
|
+
*
|
|
12
|
+
* IMPORT DISCIPLINE (pinned by `lazyGraph.test.ts`): this subpath's runtime
|
|
13
|
+
* graph reaches only `commander` and Node built-ins — never react/ink/ejs/
|
|
14
|
+
* chalk/@canonical/task, and never a summon-core module outside
|
|
15
|
+
* `src/projection/` — so a host may import it statically on its
|
|
16
|
+
* `--help`/`__complete` fast path.
|
|
17
|
+
*/
|
|
18
|
+
export { default as emitToProcess } from "./emitToProcess.js";
|
|
19
|
+
export type { CommanderHost, MountOutcome, } from "./registerGeneratorCommands.js";
|
|
20
|
+
export { default as registerGeneratorCommands } from "./registerGeneratorCommands.js";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/projection/commander/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,aAAa,EACb,YAAY,GACb,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register a command barrel onto a Commander program — the ONE registration
|
|
3
|
+
* path both binaries mount the generator tree through. The projection owns
|
|
4
|
+
* everything derivable from the prompts: the command spec (`name
|
|
5
|
+
* [kebab-positional]`), the prompt-derived options, the grouped help, the
|
|
6
|
+
* usage line, and the namespace parents. The HOST owns everything host-shaped
|
|
7
|
+
* — its standard flags, its action body, its outcome effects, and
|
|
8
|
+
* (optionally) its namespace behavior — injected through
|
|
9
|
+
* {@link CommanderHost}.
|
|
10
|
+
*
|
|
11
|
+
* Every designed non-action outcome (the two usage errors, the bare-namespace
|
|
12
|
+
* help) is DECIDED here — content and exit code, the parity facts — and
|
|
13
|
+
* DELIVERED to the host's required `emit` sink as a {@link MountOutcome}.
|
|
14
|
+
* Not one write to `process.stderr` or `process.exitCode` happens in this
|
|
15
|
+
* module; the canonical effect both bins share is
|
|
16
|
+
* {@link import("./emitToProcess.js").default}.
|
|
17
|
+
*
|
|
18
|
+
* @note Impure — mutates the Commander program.
|
|
19
|
+
*/
|
|
20
|
+
import type { Command } from "commander";
|
|
21
|
+
import type GeneratorDefinition from "../../types/GeneratorDefinition.js";
|
|
22
|
+
import type { renderGroupedHelp } from "../groupedHelp.js";
|
|
23
|
+
import type { CommandEntry, HostFlags, SurfaceGenerator } from "../types.js";
|
|
24
|
+
import { type UsageError } from "../usage.js";
|
|
25
|
+
/**
|
|
26
|
+
* Every designed non-action outcome of the registered tree. The library
|
|
27
|
+
* DECIDES the content and the exit code (the parity facts); the host
|
|
28
|
+
* EFFECTS them. The exit codes are literals on purpose: a shipped bin
|
|
29
|
+
* applies them verbatim (`emitToProcess`), an in-process host maps them
|
|
30
|
+
* into its own result — neither re-encodes the parity fact.
|
|
31
|
+
*/
|
|
32
|
+
export type MountOutcome = {
|
|
33
|
+
readonly kind: "usage-error";
|
|
34
|
+
readonly error: UsageError;
|
|
35
|
+
readonly exitCode: 2;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "namespace-help";
|
|
38
|
+
readonly help: string;
|
|
39
|
+
readonly exitCode: 1;
|
|
40
|
+
};
|
|
41
|
+
/** The host seam: what a binary contributes to each registered command. */
|
|
42
|
+
export interface CommanderHost<G extends SurfaceGenerator = GeneratorDefinition> {
|
|
43
|
+
/** Register the host's standard flags on a leaf command. */
|
|
44
|
+
readonly registerFlags: (cmd: Command) => void;
|
|
45
|
+
/** The same flags as `--help` rows for the grouped-help global block. */
|
|
46
|
+
readonly helpFlags: HostFlags;
|
|
47
|
+
/**
|
|
48
|
+
* The leaf action. Receives the barrel entry, the positional's value when
|
|
49
|
+
* one was given, and Commander's parsed options.
|
|
50
|
+
*/
|
|
51
|
+
readonly action: (entry: CommandEntry<G>, positionalValue: string | undefined, options: Record<string, unknown>) => Promise<void>;
|
|
52
|
+
/** Optional hook run on every namespace (non-runnable) command created. */
|
|
53
|
+
readonly onNamespace?: (cmd: Command, entry: CommandEntry<G>) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Render a leaf's grouped help. Defaults to `renderGroupedHelp` — the
|
|
56
|
+
* shared presentation summon uses; a host with its own help style supplies
|
|
57
|
+
* an alternative implementation of the same function. Optional, unlike
|
|
58
|
+
* `emit`: Commander's `configureHelp` takes exactly one formatter, so an
|
|
59
|
+
* omitted member cannot double-write — it just means the default.
|
|
60
|
+
*/
|
|
61
|
+
readonly renderHelp?: typeof renderGroupedHelp;
|
|
62
|
+
/**
|
|
63
|
+
* REQUIRED. The ONE process seam. A host wanting the default presentation
|
|
64
|
+
* passes `emitToProcess`; a host reframing an outcome builds its own bytes
|
|
65
|
+
* from `outcome.error` and applies `outcome.exitCode`.
|
|
66
|
+
*/
|
|
67
|
+
readonly emit: (outcome: MountOutcome) => void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Normalize Commander's action calling convention: the positional value is the
|
|
71
|
+
* first argument only when the command spec declared one, and it counts only
|
|
72
|
+
* when actually given (a non-empty string).
|
|
73
|
+
*
|
|
74
|
+
* Module-internal to the adapter (exported for its tests, never on the
|
|
75
|
+
* subpath index): both hosts reach it only through
|
|
76
|
+
* {@link registerGeneratorCommands}.
|
|
77
|
+
*
|
|
78
|
+
* @param actionArgs - Commander's raw action arguments.
|
|
79
|
+
* @param hasPositional - Whether the command spec declared a positional.
|
|
80
|
+
* @returns The positional's value (if given) and the parsed options.
|
|
81
|
+
*/
|
|
82
|
+
export declare function splitGeneratorActionArgs(actionArgs: readonly unknown[], hasPositional: boolean): {
|
|
83
|
+
positionalValue: string | undefined;
|
|
84
|
+
options: Record<string, unknown>;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Register all commands from a command barrel onto a Commander program.
|
|
88
|
+
*
|
|
89
|
+
* @param rootCmd - The program (or parent command) to register onto.
|
|
90
|
+
* @param barrel - The flattened command entries, parents before children.
|
|
91
|
+
* @param host - The host seam (flags, action, namespace hook, emit sink).
|
|
92
|
+
* @note Impure — mutates the Commander program.
|
|
93
|
+
*/
|
|
94
|
+
export default function registerGeneratorCommands<G extends SurfaceGenerator>(rootCmd: Command, barrel: readonly CommandEntry<G>[], host: CommanderHost<G>): void;
|
|
95
|
+
//# sourceMappingURL=registerGeneratorCommands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerGeneratorCommands.d.ts","sourceRoot":"","sources":["../../../../src/projection/commander/registerGeneratorCommands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAE1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EAET,gBAAgB,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAGrB;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GACpB;IACE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;CACtB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;CACtB,CAAC;AAEN,2EAA2E;AAC3E,MAAM,WAAW,aAAa,CAC5B,CAAC,SAAS,gBAAgB,GAAG,mBAAmB;IAEhD,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,CACf,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EACtB,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACtE;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,iBAAiB,CAAC;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;CAChD;AA2CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,SAAS,OAAO,EAAE,EAC9B,aAAa,EAAE,OAAO,GACrB;IACD,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAQA;AAwGD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,gBAAgB,EAC1E,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,EAClC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GACrB,IAAI,CAyEN"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE interaction decision (R2). Both products call this — the summon bin
|
|
3
|
+
* and pragma's `create` — so a given (flags, TTY, answers) state produces the
|
|
4
|
+
* same mode in either binary. The normative table lives in
|
|
5
|
+
* the cross-CLI matrix, which executes this module's decision; the exhaustive 32-cell
|
|
6
|
+
* test in `decideInteraction.test.ts` pins every row.
|
|
7
|
+
*
|
|
8
|
+
* Precedence: `--dry-run` > `--undo` > the rest. The batch modes ignore TTY —
|
|
9
|
+
* a dry-run or undo is a batch render wherever it runs. Then `--yes` means
|
|
10
|
+
* run-with-defaults; a TTY gets the wizard (which asks only `pendingPrompts`);
|
|
11
|
+
* a non-TTY with a fully-explicit answer set is a legitimate scripted run; and
|
|
12
|
+
* a non-TTY mutation with incomplete input REFUSES — exit 2 with recovery —
|
|
13
|
+
* rather than silently scaffolding from defaults.
|
|
14
|
+
*/
|
|
15
|
+
import type { PromptLike } from "./types.js";
|
|
16
|
+
/** The five interaction modes a CLI invocation resolves to. */
|
|
17
|
+
export type InteractionMode = "batch-dry-run" | "batch-undo" | "run" | "wizard" | "refuse";
|
|
18
|
+
/** The five inputs the decision reads — nothing else may influence it. */
|
|
19
|
+
export interface InteractionInput {
|
|
20
|
+
/** `--dry-run` (or a mode that implies it). */
|
|
21
|
+
readonly dryRun: boolean;
|
|
22
|
+
/** `--undo`. */
|
|
23
|
+
readonly undo: boolean;
|
|
24
|
+
/** `--yes` (or a mode that implies it). */
|
|
25
|
+
readonly yes: boolean;
|
|
26
|
+
/** The HOST's TTY fact (each host's definition is stated in the contract). */
|
|
27
|
+
readonly isTTY: boolean;
|
|
28
|
+
/** `explicitAnswersComplete(prompts, explicit)` — defaults do not count. */
|
|
29
|
+
readonly explicitComplete: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** The decision: the mode, with `refusal` set iff the mode is `refuse`. */
|
|
32
|
+
export interface InteractionDecision {
|
|
33
|
+
readonly mode: InteractionMode;
|
|
34
|
+
readonly refusal?: true;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Decide the interaction mode for one invocation.
|
|
38
|
+
*
|
|
39
|
+
* @param input - The five decision inputs.
|
|
40
|
+
* @returns The mode (and the `refusal` marker on row 6).
|
|
41
|
+
*/
|
|
42
|
+
export declare function decideInteraction(input: InteractionInput): InteractionDecision;
|
|
43
|
+
/**
|
|
44
|
+
* The PRIMARY registered long-form flag of each unconditional prompt absent
|
|
45
|
+
* from the explicit answers, in declared order — the `Missing:` list of the
|
|
46
|
+
* refusal message. Every token is derived through {@link buildOptionInfo},
|
|
47
|
+
* the single flag-shape authority both binaries register from, so every
|
|
48
|
+
* listed token is one the command actually answers to: a default-`true`
|
|
49
|
+
* confirm is listed as its only registered form `--no-<kebab>` (kebab-casing
|
|
50
|
+
* the prompt NAME advertised `--<kebab>`, a flag neither host registers —
|
|
51
|
+
* following the refusal's own instruction then exited 2), everything else as
|
|
52
|
+
* `--<kebab>`.
|
|
53
|
+
*
|
|
54
|
+
* @param prompts - The command's prompts (live or projected).
|
|
55
|
+
* @param explicit - The explicitly provided answers (no defaults).
|
|
56
|
+
* @returns Registered long-form flag tokens (`--` included).
|
|
57
|
+
*/
|
|
58
|
+
export declare function missingExplicitFlags(prompts: readonly PromptLike[], explicit: Readonly<Record<string, unknown>>): string[];
|
|
59
|
+
/**
|
|
60
|
+
* The refusal message — authored ONCE here, written verbatim by BOTH CLIs
|
|
61
|
+
* (stderr, exit 2). The tokens are rendered VERBATIM — they arrive as full
|
|
62
|
+
* registered flags (see {@link missingExplicitFlags}); re-prefixing here
|
|
63
|
+
* would double the dashes.
|
|
64
|
+
*
|
|
65
|
+
* @param missingFlags - The missing flag tokens (see
|
|
66
|
+
* {@link missingExplicitFlags}).
|
|
67
|
+
* @returns The complete refusal message.
|
|
68
|
+
*/
|
|
69
|
+
export declare function refusalMessage(missingFlags: readonly string[]): string;
|
|
70
|
+
//# sourceMappingURL=decideInteraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decideInteraction.d.ts","sourceRoot":"","sources":["../../../src/projection/decideInteraction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GACvB,eAAe,GACf,YAAY,GACZ,KAAK,GACL,QAAQ,GACR,QAAQ,CAAC;AAEb,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,gBAAgB;IAChB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,GACtB,mBAAmB,CAOrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,MAAM,EAAE,CAQV;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAMtE"}
|