@canonical/summon-core 0.34.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dist/esm/discovery/discoverGeneratorTree.js +14 -10
  2. package/dist/esm/discovery/discoverGeneratorTree.js.map +1 -1
  3. package/dist/esm/execute/collectAnswers.js +21 -16
  4. package/dist/esm/execute/collectAnswers.js.map +1 -1
  5. package/dist/esm/execute/execute.js +67 -22
  6. package/dist/esm/execute/execute.js.map +1 -1
  7. package/dist/esm/execute/index.js +1 -1
  8. package/dist/esm/execute/index.js.map +1 -1
  9. package/dist/esm/execute/validateAnswers.js +19 -5
  10. package/dist/esm/execute/validateAnswers.js.map +1 -1
  11. package/dist/esm/format/effects.js +197 -51
  12. package/dist/esm/format/effects.js.map +1 -1
  13. package/dist/esm/format/formatFlagName.js +17 -0
  14. package/dist/esm/format/formatFlagName.js.map +1 -0
  15. package/dist/esm/format/index.js +24 -1
  16. package/dist/esm/format/index.js.map +1 -1
  17. package/dist/esm/index.js +3 -3
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/projection/answers.js +84 -0
  20. package/dist/esm/projection/answers.js.map +1 -0
  21. package/dist/esm/projection/buildOptionInfo.js +77 -0
  22. package/dist/esm/projection/buildOptionInfo.js.map +1 -0
  23. package/dist/esm/projection/commander/configureGroupedHelp.js +39 -0
  24. package/dist/esm/projection/commander/configureGroupedHelp.js.map +1 -0
  25. package/dist/esm/projection/commander/emitToProcess.js +15 -0
  26. package/dist/esm/projection/commander/emitToProcess.js.map +1 -0
  27. package/dist/esm/projection/commander/index.js +20 -0
  28. package/dist/esm/projection/commander/index.js.map +1 -0
  29. package/dist/esm/projection/commander/registerGeneratorCommands.js +222 -0
  30. package/dist/esm/projection/commander/registerGeneratorCommands.js.map +1 -0
  31. package/dist/esm/projection/decideInteraction.js +73 -0
  32. package/dist/esm/projection/decideInteraction.js.map +1 -0
  33. package/dist/esm/projection/extractAnswers.js +52 -0
  34. package/dist/esm/projection/extractAnswers.js.map +1 -0
  35. package/dist/esm/projection/groupedHelp.js +74 -0
  36. package/dist/esm/projection/groupedHelp.js.map +1 -0
  37. package/dist/esm/projection/index.js +26 -0
  38. package/dist/esm/projection/index.js.map +1 -0
  39. package/dist/esm/projection/kebab.js +18 -0
  40. package/dist/esm/projection/kebab.js.map +1 -0
  41. package/dist/esm/projection/projectGenerator.js +46 -0
  42. package/dist/esm/projection/projectGenerator.js.map +1 -0
  43. package/dist/esm/projection/types.js +16 -0
  44. package/dist/esm/projection/types.js.map +1 -0
  45. package/dist/esm/projection/usage.js +144 -0
  46. package/dist/esm/projection/usage.js.map +1 -0
  47. package/dist/esm/prompt/answerPromptWithDefaults.js +7 -5
  48. package/dist/esm/prompt/answerPromptWithDefaults.js.map +1 -1
  49. package/dist/esm/prompt/autoPrompt.js +2 -3
  50. package/dist/esm/prompt/autoPrompt.js.map +1 -1
  51. package/dist/esm/prompt/ink/Wizard.js +44 -8
  52. package/dist/esm/prompt/ink/Wizard.js.map +1 -1
  53. package/dist/esm/prompt/ink/mount.js +20 -8
  54. package/dist/esm/prompt/ink/mount.js.map +1 -1
  55. package/dist/esm/prompt/ink/progressWindow.js +131 -3
  56. package/dist/esm/prompt/ink/progressWindow.js.map +1 -1
  57. package/dist/esm/prompt/ink/session.js +135 -14
  58. package/dist/esm/prompt/ink/session.js.map +1 -1
  59. package/dist/esm/prompt/inkPrompt.js +18 -2
  60. package/dist/esm/prompt/inkPrompt.js.map +1 -1
  61. package/dist/esm/prompt/mcpPrompt.js +1 -1
  62. package/dist/esm/prompt/mcpPrompt.js.map +1 -1
  63. package/dist/esm/stamp/applyStamp.js +50 -52
  64. package/dist/esm/stamp/applyStamp.js.map +1 -1
  65. package/dist/esm/stamp/createStampOnEffectStart.js +4 -1
  66. package/dist/esm/stamp/createStampOnEffectStart.js.map +1 -1
  67. package/dist/esm/stamp/runTaskWithStamp.js +8 -9
  68. package/dist/esm/stamp/runTaskWithStamp.js.map +1 -1
  69. package/dist/esm/template/index.js +2 -0
  70. package/dist/esm/template/index.js.map +1 -1
  71. package/dist/esm/template/loadTemplate.js +43 -0
  72. package/dist/esm/template/loadTemplate.js.map +1 -0
  73. package/dist/esm/template/prependStamp.js +11 -8
  74. package/dist/esm/template/prependStamp.js.map +1 -1
  75. package/dist/esm/template/rawFile.js +25 -0
  76. package/dist/esm/template/rawFile.js.map +1 -0
  77. package/dist/esm/template/tasks/template.js +12 -3
  78. package/dist/esm/template/tasks/template.js.map +1 -1
  79. package/dist/esm/template/tasks/templateDir.js +5 -0
  80. package/dist/esm/template/tasks/templateDir.js.map +1 -1
  81. package/dist/esm/testing/conformance/fixtures.js +0 -2
  82. package/dist/esm/testing/conformance/fixtures.js.map +1 -1
  83. package/dist/esm/testing/conformance/flagizeAnswers.js +91 -0
  84. package/dist/esm/testing/conformance/flagizeAnswers.js.map +1 -0
  85. package/dist/esm/testing/conformance/index.js +1 -0
  86. package/dist/esm/testing/conformance/index.js.map +1 -1
  87. package/dist/esm/testing/index.js +1 -1
  88. package/dist/esm/testing/index.js.map +1 -1
  89. package/dist/types/discovery/discoverGeneratorTree.d.ts +3 -3
  90. package/dist/types/discovery/discoverGeneratorTree.d.ts.map +1 -1
  91. package/dist/types/execute/collectAnswers.d.ts +4 -3
  92. package/dist/types/execute/collectAnswers.d.ts.map +1 -1
  93. package/dist/types/execute/execute.d.ts +27 -1
  94. package/dist/types/execute/execute.d.ts.map +1 -1
  95. package/dist/types/execute/index.d.ts +1 -1
  96. package/dist/types/execute/index.d.ts.map +1 -1
  97. package/dist/types/execute/validateAnswers.d.ts.map +1 -1
  98. package/dist/types/format/effects.d.ts +61 -7
  99. package/dist/types/format/effects.d.ts.map +1 -1
  100. package/dist/types/format/formatFlagName.d.ts +14 -0
  101. package/dist/types/format/formatFlagName.d.ts.map +1 -0
  102. package/dist/types/format/index.d.ts +21 -1
  103. package/dist/types/format/index.d.ts.map +1 -1
  104. package/dist/types/index.d.ts +5 -5
  105. package/dist/types/index.d.ts.map +1 -1
  106. package/dist/types/projection/answers.d.ts +54 -0
  107. package/dist/types/projection/answers.d.ts.map +1 -0
  108. package/dist/types/projection/buildOptionInfo.d.ts +25 -0
  109. package/dist/types/projection/buildOptionInfo.d.ts.map +1 -0
  110. package/dist/types/projection/commander/configureGroupedHelp.d.ts +29 -0
  111. package/dist/types/projection/commander/configureGroupedHelp.d.ts.map +1 -0
  112. package/dist/types/projection/commander/emitToProcess.d.ts +10 -0
  113. package/dist/types/projection/commander/emitToProcess.d.ts.map +1 -0
  114. package/dist/types/projection/commander/index.d.ts +21 -0
  115. package/dist/types/projection/commander/index.d.ts.map +1 -0
  116. package/dist/types/projection/commander/registerGeneratorCommands.d.ts +95 -0
  117. package/dist/types/projection/commander/registerGeneratorCommands.d.ts.map +1 -0
  118. package/dist/types/projection/decideInteraction.d.ts +70 -0
  119. package/dist/types/projection/decideInteraction.d.ts.map +1 -0
  120. package/dist/types/projection/extractAnswers.d.ts +23 -0
  121. package/dist/types/projection/extractAnswers.d.ts.map +1 -0
  122. package/dist/types/projection/groupedHelp.d.ts +25 -0
  123. package/dist/types/projection/groupedHelp.d.ts.map +1 -0
  124. package/dist/types/projection/index.d.ts +29 -0
  125. package/dist/types/projection/index.d.ts.map +1 -0
  126. package/dist/types/projection/kebab.d.ts +16 -0
  127. package/dist/types/projection/kebab.d.ts.map +1 -0
  128. package/dist/types/projection/projectGenerator.d.ts +22 -0
  129. package/dist/types/projection/projectGenerator.d.ts.map +1 -0
  130. package/dist/types/projection/types.d.ts +118 -0
  131. package/dist/types/projection/types.d.ts.map +1 -0
  132. package/dist/types/projection/usage.d.ts +92 -0
  133. package/dist/types/projection/usage.d.ts.map +1 -0
  134. package/dist/types/prompt/answerPromptWithDefaults.d.ts +5 -3
  135. package/dist/types/prompt/answerPromptWithDefaults.d.ts.map +1 -1
  136. package/dist/types/prompt/autoPrompt.d.ts.map +1 -1
  137. package/dist/types/prompt/index.d.ts +1 -1
  138. package/dist/types/prompt/index.d.ts.map +1 -1
  139. package/dist/types/prompt/ink/Wizard.d.ts.map +1 -1
  140. package/dist/types/prompt/ink/mount.d.ts +3 -2
  141. package/dist/types/prompt/ink/mount.d.ts.map +1 -1
  142. package/dist/types/prompt/ink/progressWindow.d.ts +98 -2
  143. package/dist/types/prompt/ink/progressWindow.d.ts.map +1 -1
  144. package/dist/types/prompt/ink/session.d.ts +87 -4
  145. package/dist/types/prompt/ink/session.d.ts.map +1 -1
  146. package/dist/types/prompt/inkPrompt.d.ts +36 -2
  147. package/dist/types/prompt/inkPrompt.d.ts.map +1 -1
  148. package/dist/types/stamp/applyStamp.d.ts +6 -2
  149. package/dist/types/stamp/applyStamp.d.ts.map +1 -1
  150. package/dist/types/stamp/createStampOnEffectStart.d.ts.map +1 -1
  151. package/dist/types/stamp/runTaskWithStamp.d.ts +3 -1
  152. package/dist/types/stamp/runTaskWithStamp.d.ts.map +1 -1
  153. package/dist/types/template/index.d.ts +4 -0
  154. package/dist/types/template/index.d.ts.map +1 -1
  155. package/dist/types/template/loadTemplate.d.ts +40 -0
  156. package/dist/types/template/loadTemplate.d.ts.map +1 -0
  157. package/dist/types/template/prependStamp.d.ts +5 -2
  158. package/dist/types/template/prependStamp.d.ts.map +1 -1
  159. package/dist/types/template/rawFile.d.ts +32 -0
  160. package/dist/types/template/rawFile.d.ts.map +1 -0
  161. package/dist/types/template/tasks/template.d.ts +8 -0
  162. package/dist/types/template/tasks/template.d.ts.map +1 -1
  163. package/dist/types/template/tasks/templateDir.d.ts.map +1 -1
  164. package/dist/types/template/tasks/types.d.ts +2 -0
  165. package/dist/types/template/tasks/types.d.ts.map +1 -1
  166. package/dist/types/testing/conformance/fixtures.d.ts.map +1 -1
  167. package/dist/types/testing/conformance/flagizeAnswers.d.ts +38 -0
  168. package/dist/types/testing/conformance/flagizeAnswers.d.ts.map +1 -0
  169. package/dist/types/testing/conformance/index.d.ts +1 -0
  170. package/dist/types/testing/conformance/index.d.ts.map +1 -1
  171. package/dist/types/testing/index.d.ts +1 -1
  172. package/dist/types/testing/index.d.ts.map +1 -1
  173. package/dist/types/types/GeneratorDefinition.d.ts +10 -1
  174. package/dist/types/types/GeneratorDefinition.d.ts.map +1 -1
  175. package/dist/types/types/ReservedOption.d.ts +1 -1
  176. package/dist/types/types/ReservedOption.d.ts.map +1 -1
  177. package/package.json +22 -9
@@ -0,0 +1,29 @@
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 type { InteractionDecision, InteractionInput, InteractionMode, } from "./decideInteraction.js";
21
+ export { decideInteraction, missingExplicitFlags, refusalMessage, } from "./decideInteraction.js";
22
+ export { default as extractAnswers } from "./extractAnswers.js";
23
+ export { buildOptionGroups, renderGroupedHelp } from "./groupedHelp.js";
24
+ export { default as toKebabCase } from "./kebab.js";
25
+ export { default as projectGenerator } from "./projectGenerator.js";
26
+ export type { CommandEntry, HostFlags, OptionInfo, ProjectedPrompt, PromptLike, SurfaceCommand, SurfaceGenerator, } from "./types.js";
27
+ export type { UsageError, UsageKind } from "./usage.js";
28
+ export { excessPositionalError, renderUsageError, unknownSegmentError, } from "./usage.js";
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","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;AAClE,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,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;AACpE,YAAY,EACV,YAAY,EACZ,SAAS,EACT,UAAU,EACV,eAAe,EACf,UAAU,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,16 @@
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: string): string;
16
+ //# sourceMappingURL=kebab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kebab.d.ts","sourceRoot":"","sources":["../../../src/projection/kebab.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -0,0 +1,22 @@
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
+ import type GeneratorDefinition from "../types/GeneratorDefinition.js";
13
+ import type { SurfaceCommand } from "./types.js";
14
+ /**
15
+ * Project a generator onto its serializable {@link SurfaceCommand}.
16
+ *
17
+ * @param path - The command path the generator is mounted at.
18
+ * @param generator - The live generator definition.
19
+ * @returns The serializable command surface.
20
+ */
21
+ export default function projectGenerator(path: readonly string[], generator: GeneratorDefinition): SurfaceCommand;
22
+ //# sourceMappingURL=projectGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectGenerator.d.ts","sourceRoot":"","sources":["../../../src/projection/projectGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,mBAAmB,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,YAAY,CAAC;AAuBlE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,SAAS,EAAE,mBAAmB,GAC7B,cAAc,CAMhB"}
@@ -0,0 +1,118 @@
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
+ import type GeneratorDefinition from "../types/GeneratorDefinition.js";
16
+ /**
17
+ * The serializable image of a {@link import("../types/PromptDefinition.js").default}:
18
+ * everything the CLI surface derives from, and nothing it cannot serialize.
19
+ * `validate` is dropped (enforced at execute time by `validateAnswers`);
20
+ * a `when` condition collapses to `conditional: true` (its predicate is
21
+ * evaluated only by a live wizard).
22
+ */
23
+ export interface ProjectedPrompt {
24
+ /** Unique identifier, used as answer key and CLI flag name. */
25
+ readonly name: string;
26
+ /** Prompt kind, deciding flag shape and answer parsing. */
27
+ readonly type: "text" | "confirm" | "select" | "multiselect";
28
+ /** Question text displayed to the user (and used as flag help). */
29
+ readonly message: string;
30
+ /** Default value if the user provides no input. */
31
+ readonly default?: unknown;
32
+ /** Choices for select/multiselect prompts. */
33
+ readonly choices?: ReadonlyArray<{
34
+ readonly label: string;
35
+ readonly value: string;
36
+ }>;
37
+ /** True when the prompt can be provided as the command's one positional. */
38
+ readonly positional?: boolean;
39
+ /** Group name for organizing options in `--help` output. */
40
+ readonly group?: string;
41
+ /** True when the live prompt carries a `when` condition (wizard-evaluated). */
42
+ readonly conditional?: boolean;
43
+ }
44
+ /**
45
+ * A prompt as the projection's helpers accept it: either a live
46
+ * `PromptDefinition` (whose `when`/`validate` are functions) or a
47
+ * {@link ProjectedPrompt} (where `when` collapsed to `conditional`). The
48
+ * helpers read only the projected fields plus the presence of `when`.
49
+ */
50
+ export type PromptLike = ProjectedPrompt & {
51
+ readonly when?: unknown;
52
+ readonly validate?: unknown;
53
+ };
54
+ /** One command of the projected generator tree, fully serializable. */
55
+ export interface SurfaceCommand {
56
+ /** Path segments to this command (e.g. `["component", "react"]`). */
57
+ readonly path: readonly string[];
58
+ /** The generator's `meta.description`. */
59
+ readonly description: string;
60
+ /** The projected prompts, in declared (asking) order. */
61
+ readonly prompts: readonly ProjectedPrompt[];
62
+ }
63
+ /**
64
+ * What the registration path actually READS of a runnable entry: a
65
+ * description and the prompt list. A live {@link GeneratorDefinition}
66
+ * satisfies it directly. A build-time {@link SurfaceCommand} does NOT — it
67
+ * carries a top-level `description` where this needs `meta.description`,
68
+ * and its readonly `path` belongs to {@link CommandEntry} (which owns a
69
+ * mutable one) — so a host mounting the projected tree without loading a
70
+ * single generator wraps each surface command in a small adapter
71
+ * (`{ meta: { description: surface.description }, prompts: surface.prompts }`).
72
+ */
73
+ export interface SurfaceGenerator {
74
+ readonly meta: {
75
+ readonly description: string;
76
+ };
77
+ readonly prompts: readonly PromptLike[];
78
+ }
79
+ /**
80
+ * A flattened representation of a command to register.
81
+ * Separates command discovery from registration.
82
+ *
83
+ * Generic over the runnable payload: the summon bin carries live
84
+ * {@link GeneratorDefinition}s (the default), a build-time host carries
85
+ * projected {@link SurfaceGenerator}s.
86
+ */
87
+ export interface CommandEntry<G extends SurfaceGenerator = GeneratorDefinition> {
88
+ /** Path segments to this command (e.g., ["component", "react"]) */
89
+ path: string[];
90
+ /** The generator definition if this is a runnable command */
91
+ generator?: G;
92
+ /** Description for namespace-only commands */
93
+ description?: string;
94
+ }
95
+ /**
96
+ * Option metadata built from a prompt definition for Commander.
97
+ */
98
+ export interface OptionInfo {
99
+ flags: string;
100
+ description: string;
101
+ defaultValue?: string;
102
+ group?: string;
103
+ /** The original camelCase prompt name */
104
+ promptName: string;
105
+ /** The kebab-case flag name (without --) */
106
+ kebabName: string;
107
+ }
108
+ /**
109
+ * A host's standard per-generator flag list, injected into grouped help: each
110
+ * entry is a `--help` row (`flags` column + description). The projection never
111
+ * hard-codes a host's flags — summon's nine and pragma's mutation trio are
112
+ * both just data handed in here.
113
+ */
114
+ export type HostFlags = ReadonlyArray<{
115
+ readonly flags: string;
116
+ readonly description: string;
117
+ }>;
118
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/projection/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,mBAAmB,MAAM,iCAAiC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC7D,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;QAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,CAAC,CAAC;IACH,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY,CAC3B,CAAC,SAAS,gBAAgB,GAAG,mBAAmB;IAEhD,mEAAmE;IACnE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,6DAA6D;IAC7D,SAAS,CAAC,EAAE,CAAC,CAAC;IACd,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC,CAAC"}
@@ -0,0 +1,92 @@
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
+ /** The projection's two designed usage-error classes. */
13
+ export type UsageKind = "unknown-segment" | "excess-positional";
14
+ /**
15
+ * The structured facts of one designed usage error — the PRIMARY form.
16
+ * No `stray` field: the offending token is already embedded in `headline`
17
+ * (per-kind quotes included) and nothing reads it — pragma's reframer
18
+ * consumes only `suggestion` and `chain`, and the renderer needs only
19
+ * `headline`. A field with zero consumers is cut.
20
+ */
21
+ export interface UsageError {
22
+ readonly kind: UsageKind;
23
+ /**
24
+ * Single-line problem clause, prefix-free: `unknown command 'reakt'`,
25
+ * `unexpected argument "Extra"`. Exactly the envelope `message` pragma
26
+ * used to reconstruct by string surgery.
27
+ */
28
+ readonly headline: string;
29
+ /**
30
+ * The matched segment, when one matched — per-kind: for `unknown-segment`
31
+ * the candidate that RANKED closest to the stray (fuzzy, substitutable for
32
+ * it); for `excess-positional` the first OPERAND — bound or excess,
33
+ * possibly the stray itself — that exactly names a sibling or child
34
+ * segment (structural, not a substitution).
35
+ */
36
+ readonly suggestion?: string;
37
+ /**
38
+ * The invocation chain the suggestion completes, bin name first:
39
+ * `[...chain, suggestion].join(" ")` IS the corrected invocation the
40
+ * rendered did-you-mean line names.
41
+ */
42
+ readonly chain: readonly string[];
43
+ }
44
+ /**
45
+ * The designed unknown-segment error beneath a namespace. Commander's own
46
+ * handling is host-divergent by construction — pragma's namespaces carry an
47
+ * action, so its `unknownCommand` never fires and the mount used to
48
+ * re-implement the line, while summon got commander's `(Did you mean x?)` —
49
+ * so the projection owns this error in BOTH CLIs, in the same
50
+ * `Did you mean '<chain> <segment>'?` shape the excess-positional path
51
+ * already uses, suggesting the closest child segment.
52
+ *
53
+ * @param chain - The invoked namespace's full name chain, root (bin name)
54
+ * first — host-agnostic, so a mounted subtree suggests its real invocation
55
+ * (`pragma create component react`, not a truncated one).
56
+ * @param stray - The unrecognized segment.
57
+ * @param children - The namespace's child segments.
58
+ * @returns The structured error; {@link renderUsageError} yields the bytes.
59
+ */
60
+ export declare function unknownSegmentError(chain: readonly string[], stray: string, children: readonly string[]): UsageError;
61
+ /**
62
+ * The designed excess-positional error. Commander's default is a generic "too
63
+ * many arguments"; the projection owns this error in BOTH CLIs: the stray is
64
+ * named, and when an operand matches a sibling or child tree segment the
65
+ * corrected command is suggested (`summon component react svelte …` almost
66
+ * certainly meant `summon component svelte …`).
67
+ *
68
+ * The suggestion scans EVERY operand, not just the excess ones: in
69
+ * `summon component react svelte MyComponent` it is `svelte` — bound as the
70
+ * positional — that names the intended sibling, while `MyComponent` is what
71
+ * overflowed. First matching operand wins; a child segment beats a sibling.
72
+ * A sibling match slices the leaf off the chain BEFORE storing it, so
73
+ * `[...chain, suggestion].join(" ")` is the corrected invocation on every
74
+ * branch.
75
+ *
76
+ * @param chain - The invoked command's full name chain, root (bin name)
77
+ * first — host-agnostic (see {@link unknownSegmentError}).
78
+ * @param stray - The first unexpected operand.
79
+ * @param operands - Every operand the command received (bound + excess).
80
+ * @param siblings - The leaf's sibling segments (other children of its parent).
81
+ * @param children - The leaf's own child segments (runnable-namespace case).
82
+ * @returns The structured error; {@link renderUsageError} yields the bytes.
83
+ */
84
+ export declare function excessPositionalError(chain: readonly string[], stray: string, operands: readonly string[], siblings: ReadonlySet<string>, children: ReadonlySet<string>): UsageError;
85
+ /**
86
+ * The parity bytes of a usage error (one or two lines, no trailing newline):
87
+ * `error: ${headline}`, then the did-you-mean line when a segment matched —
88
+ * `[...chain, suggestion].join(" ")` is the corrected invocation on every
89
+ * builder branch.
90
+ */
91
+ export declare function renderUsageError(error: UsageError): string;
92
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/projection/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,yDAAyD;AACzD,MAAM,MAAM,SAAS,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AA4DD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,UAAU,CAMZ;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAC5B,UAAU,CAqBZ;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAK1D"}
@@ -4,9 +4,11 @@ import type { Effect } from "@canonical/task";
4
4
  * defaults-only handler the summon Ink progress view drives, and the base the
5
5
  * seam's {@link autoPrompt} strategy layers required-missing detection on.
6
6
  *
7
- * Each prompt type yields the value a non-interactive run should assume: a
8
- * confirm's default (or `true`), a select's default (or its first choice), an
9
- * empty multiselect, or a text default (or `""`).
7
+ * Each prompt type yields the value a non-interactive run should assume,
8
+ * ALIGNED with the dry-run interpreter's mock so a plan and a defaults-driven
9
+ * run take the same branches: a confirm's default (or `false`), a select's
10
+ * default (or its first choice, or `""`), an empty multiselect, or a text
11
+ * default (or `""`).
10
12
  *
11
13
  * @param effect - A `Prompt` effect to resolve.
12
14
  * @returns The default answer for the prompt's type.
@@ -1 +1 @@
1
- {"version":3,"file":"answerPromptWithDefaults.d.ts","sourceRoot":"","sources":["../../../src/prompt/answerPromptWithDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClC,OAAO,CAAC,OAAO,CAAC,CAYlB"}
1
+ {"version":3,"file":"answerPromptWithDefaults.d.ts","sourceRoot":"","sources":["../../../src/prompt/answerPromptWithDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClC,OAAO,CAAC,OAAO,CAAC,CAclB"}
@@ -1 +1 @@
1
- {"version":3,"file":"autoPrompt.d.ts","sourceRoot":"","sources":["../../../src/prompt/autoPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9D,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAMjE;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,IAAI,GAAE,MAAM,GAAG,UAAmB,GACjC,kBAAkB,CAOpB;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,GAC9C,aAAa,CAMf"}
1
+ {"version":3,"file":"autoPrompt.d.ts","sourceRoot":"","sources":["../../../src/prompt/autoPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9D,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAIjE;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,IAAI,GAAE,MAAM,GAAG,UAAmB,GACjC,kBAAkB,CAOpB;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,GAC9C,aAAa,CAMf"}
@@ -7,7 +7,7 @@
7
7
  */
8
8
  export { default as answerPromptWithDefaults } from "./answerPromptWithDefaults.js";
9
9
  export { default as autoPrompt, MISSING_REQUIRED_ANSWER, missingRequiredError, } from "./autoPrompt.js";
10
- export type { InkPromptOptions, InkSession } from "./inkPrompt.js";
10
+ export type { InkPromptOptions, InkSession, StepReport } from "./inkPrompt.js";
11
11
  export { default as inkPrompt } from "./inkPrompt.js";
12
12
  export { default as mcpPrompt } from "./mcpPrompt.js";
13
13
  export type { ConfirmPrompt, MultiselectPrompt, PromptEffect, PromptHandler, PromptQuestion, SelectPrompt, TextPrompt, } from "./types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prompt/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EACL,OAAO,IAAI,UAAU,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prompt/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EACL,OAAO,IAAI,UAAU,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Wizard.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/Wizard.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,cAAc,CAAC;AA+GnE,MAAM,WAAW,WAAW;IAC1B,oDAAoD;IACpD,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,GAAI,gBAAgB,WAAW,4CAsGjD,CAAC"}
1
+ {"version":3,"file":"Wizard.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/Wizard.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,cAAc,CAAC;AA+KtB,MAAM,WAAW,WAAW;IAC1B,oDAAoD;IACpD,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,GAAI,gBAAgB,WAAW,4CAmIjD,CAAC"}
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import type { Effect, LogLevel } from "@canonical/task";
11
11
  import type GeneratorDefinition from "../../types/GeneratorDefinition.js";
12
- import type { InkPromptOptions } from "../inkPrompt.js";
12
+ import type { InkPromptOptions, StepReport } from "../inkPrompt.js";
13
13
  import type { PromptEffect } from "../types.js";
14
14
  /** The seam handle a mounted session exposes back to {@link inkPrompt}. */
15
15
  export interface MountedSession {
@@ -17,7 +17,8 @@ export interface MountedSession {
17
17
  reportEffectStart: (effect: Effect) => void;
18
18
  reportEffectComplete: (effect: Effect, duration: number) => void;
19
19
  reportLog: (level: LogLevel, message: string) => void;
20
- dispose: () => void;
20
+ reportStep: (report: StepReport) => void;
21
+ dispose: () => Promise<void>;
21
22
  }
22
23
  /**
23
24
  * Mount the wizard for a generator and return its seam handle.
@@ -1 +1 @@
1
- {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/mount.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,oBAAoB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,mBAAmB,EAC9B,OAAO,GAAE,gBAAqB,GAC7B,cAAc,CAmChB"}
1
+ {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/mount.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,oBAAoB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,mBAAmB,EAC9B,OAAO,GAAE,gBAAqB,GAC7B,cAAc,CAiDhB"}
@@ -14,19 +14,110 @@
14
14
  * wide glyphs overflow and wrap. {@link measureDisplayWidth} is the shared
15
15
  * width approximation both concerns rely on.
16
16
  *
17
+ * Width is also STYLE-invariant: SGR escape sequences (the bytes `chalk` emits
18
+ * for `<Text color="green">`) occupy no cells, so {@link stripStyles} removes
19
+ * them before anything is counted. Whether the process happens to have colour
20
+ * enabled therefore cannot change how wide a row measures — see that helper for
21
+ * why that mattered.
22
+ *
17
23
  * A `.ts` sibling of the JSX view so the string math is unit testable.
18
24
  */
19
- /** Max display columns a single progress line may occupy before it is truncated. */
25
+ /**
26
+ * Max display columns a single RENDERED progress line may occupy — status
27
+ * glyph, description and duration suffix together. Everything but the
28
+ * description is fixed, so {@link describedWidthBudget} spends what is left of
29
+ * this cap on the description alone.
30
+ */
20
31
  export declare const MAX_PROGRESS_LINE = 72;
21
32
  /** The single-column marker inserted where a truncated middle was elided. */
22
33
  export declare const TRUNCATION_MARKER = "\u2026";
34
+ /**
35
+ * The status glyph a COMPLETED progress line opens with, rendered green by
36
+ * `Wizard.tsx`. Exported so the view and the budget cannot drift: the columns
37
+ * the glyph costs are reserved here, and a fork that changed the glyph in the
38
+ * view alone would silently reopen the overflow this reservation closes.
39
+ */
40
+ export declare const COMPLETED_GLYPH = "\u2713";
41
+ /**
42
+ * The status glyph for a run that did NOT complete — the error and cancel
43
+ * lines `Wizard.tsx` ends on. Named beside {@link COMPLETED_GLYPH} so the
44
+ * wizard's outcome marks are one vocabulary in one place rather than literals
45
+ * scattered through the view — and exported (via `@canonical/summon-core/
46
+ * format`) so the pragma CLI's render-vocabulary sync test can pin both marks
47
+ * to byte equality with its own: the two binaries narrate the same run, and a
48
+ * reader must not have to learn a second dialect for the same fact.
49
+ */
50
+ export declare const FAILURE_GLYPH = "\u2717";
51
+ /**
52
+ * Format a completed effect's duration as the suffix its progress line ends
53
+ * with — `(12ms)`, whole milliseconds.
54
+ *
55
+ * The spelling is deliberately IDENTICAL to the summon binary's own timed
56
+ * progress view (`ExecutionProgress.tsx`): the two binaries render the same
57
+ * run, and a reader who has seen one must not have to learn a second dialect
58
+ * for the same fact.
59
+ *
60
+ * @param durationMs - The effect's measured duration, in milliseconds.
61
+ * @returns The parenthesised suffix, e.g. `(12ms)`.
62
+ */
63
+ export declare function formatEffectDuration(durationMs: number): string;
64
+ /**
65
+ * The display columns left for the DESCRIBED middle of a progress line once
66
+ * everything rendered AROUND it is reserved out of `max`: the leading
67
+ * {@link COMPLETED_GLYPH} and its space, and the trailing duration suffix and
68
+ * the space before it.
69
+ *
70
+ * The one-row guarantee is about the WHOLE rendered row — that is the thing the
71
+ * terminal has to fit — so the description alone can no longer spend the entire
72
+ * cap: appending `(1234ms)` to a line already at {@link MAX_PROGRESS_LINE}
73
+ * would wrap, which is exactly the jitter the truncation exists to prevent. The
74
+ * glyph is reserved for the same reason and was the earlier miss: a budget that
75
+ * covered only the suffix let `Wizard.tsx` emit `MAX_PROGRESS_LINE + 2` columns
76
+ * — overflowing on precisely the boundary this helper protects.
77
+ *
78
+ * Budgeting here (rather than truncating the joined line) keeps the timing
79
+ * legible — it is the part a middle-truncation would never protect, since it
80
+ * sits at neither end of the description.
81
+ *
82
+ * @param suffix - The rendered duration suffix, from {@link formatEffectDuration}.
83
+ * @param max - The whole-ROW width cap; defaults to {@link MAX_PROGRESS_LINE}.
84
+ * @returns The columns the description may occupy, never negative.
85
+ */
86
+ export declare function describedWidthBudget(suffix: string, max?: number): number;
87
+ /**
88
+ * Remove ANSI escape sequences, leaving only the characters a terminal actually
89
+ * prints.
90
+ *
91
+ * The rendered frame is styled — `Wizard.tsx` wraps the status glyph in
92
+ * `<Text color="green">` and the duration in `<Text dimColor>`, and Ink renders
93
+ * those through `chalk` — so a completed progress row reaches a reader (or a
94
+ * test) as `ESC[32m✓ESC[39m … ESC[2m(5ms)ESC[22m`. Those 19 bytes are
95
+ * instructions to the terminal, not columns in it.
96
+ *
97
+ * Whether they are present at all depends on the environment: `chalk` enables
98
+ * colour only when it believes the stream is a terminal, so the SAME frame is
99
+ * bare under a plain `vitest` run and styled when the task runs under a task
100
+ * runner that allocates a pseudo-terminal (which is how CI invokes this suite).
101
+ * Counting the escapes as columns therefore made the measured width of one
102
+ * fixed row swing between 72 and 91 — a one-row guarantee that held or failed
103
+ * on the shape of the invoking shell. Stripping first makes the measurement say
104
+ * the same thing everywhere.
105
+ *
106
+ * @param text - Possibly styled text, e.g. a captured Ink frame.
107
+ * @returns `text` with every ANSI escape sequence removed.
108
+ */
109
+ export declare function stripStyles(text: string): string;
23
110
  /**
24
111
  * Measure the terminal-column width of a string, summing per-code-point widths:
25
112
  * one column for most code points, two for East Asian Wide / emoji ones (see
26
113
  * {@link isWideCodePoint}). Iterating code points rather than UTF-16 code units
27
114
  * means a surrogate pair counts once, as the single glyph it renders to.
28
115
  *
29
- * @param text - The string to measure.
116
+ * Styling is discounted first ({@link stripStyles}): an escape sequence costs
117
+ * bytes but no cells, so the width of a row is the same number whether or not
118
+ * colour is enabled.
119
+ *
120
+ * @param text - The string to measure; may carry ANSI styling.
30
121
  * @returns The approximate number of terminal columns `text` occupies.
31
122
  */
32
123
  export declare function measureDisplayWidth(text: string): number;
@@ -40,6 +131,11 @@ export declare function measureDisplayWidth(text: string): number;
40
131
  * code points, so the one-row guarantee holds for multibyte and wide (CJK /
41
132
  * emoji) paths and a surrogate pair is never split into a lone-surrogate `�`.
42
133
  *
134
+ * `line` must be UNSTYLED text — the description `Wizard.tsx` truncates before
135
+ * handing it to Ink, which applies the colour. Cutting a line that already
136
+ * carried escape sequences could sever one mid-sequence; the styling is applied
137
+ * around the truncated text precisely so that cannot arise.
138
+ *
43
139
  * @param line - The described-effect line (e.g. `Write file: a/b/c.ts (12 bytes)`).
44
140
  * @param max - The width cap, in columns; defaults to {@link MAX_PROGRESS_LINE}.
45
141
  * @returns The line unchanged when within the cap, else its truncated form.
@@ -1 +1 @@
1
- {"version":3,"file":"progressWindow.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/progressWindow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,WAAM,CAAC;AAyDrC;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAwBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,MAA0B,GAC9B,MAAM,CAYR"}
1
+ {"version":3,"file":"progressWindow.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/progressWindow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,WAAM,CAAC;AASrC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,WAAM,CAAC;AAEnC;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,WAAM,CAAC;AAQjC;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,GAAG,GAAE,MAA0B,GAC9B,MAAM,CAOR;AAwED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAwBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,MAA0B,GAC9B,MAAM,CAYR"}