@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
@@ -14,12 +14,95 @@
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 const MAX_PROGRESS_LINE = 72;
21
32
  /** The single-column marker inserted where a truncated middle was elided. */
22
33
  export const TRUNCATION_MARKER = "…";
34
+ /**
35
+ * The single space that separates a completed effect's description from its
36
+ * trailing duration suffix. Named because {@link describedWidthBudget} must
37
+ * reserve it, and a line that forgot it would be one column over the cap.
38
+ */
39
+ const SUFFIX_GAP = 1;
40
+ /**
41
+ * The status glyph a COMPLETED progress line opens with, rendered green by
42
+ * `Wizard.tsx`. Exported so the view and the budget cannot drift: the columns
43
+ * the glyph costs are reserved here, and a fork that changed the glyph in the
44
+ * view alone would silently reopen the overflow this reservation closes.
45
+ */
46
+ export const COMPLETED_GLYPH = "✓";
47
+ /**
48
+ * The status glyph for a run that did NOT complete — the error and cancel
49
+ * lines `Wizard.tsx` ends on. Named beside {@link COMPLETED_GLYPH} so the
50
+ * wizard's outcome marks are one vocabulary in one place rather than literals
51
+ * scattered through the view — and exported (via `@canonical/summon-core/
52
+ * format`) so the pragma CLI's render-vocabulary sync test can pin both marks
53
+ * to byte equality with its own: the two binaries narrate the same run, and a
54
+ * reader must not have to learn a second dialect for the same fact.
55
+ */
56
+ export const FAILURE_GLYPH = "✗";
57
+ /**
58
+ * The single space between {@link COMPLETED_GLYPH} and the description. Sibling
59
+ * of {@link SUFFIX_GAP}, and reserved for the same reason.
60
+ */
61
+ const GLYPH_GAP = 1;
62
+ /**
63
+ * Format a completed effect's duration as the suffix its progress line ends
64
+ * with — `(12ms)`, whole milliseconds.
65
+ *
66
+ * The spelling is deliberately IDENTICAL to the summon binary's own timed
67
+ * progress view (`ExecutionProgress.tsx`): the two binaries render the same
68
+ * run, and a reader who has seen one must not have to learn a second dialect
69
+ * for the same fact.
70
+ *
71
+ * @param durationMs - The effect's measured duration, in milliseconds.
72
+ * @returns The parenthesised suffix, e.g. `(12ms)`.
73
+ */
74
+ export function formatEffectDuration(durationMs) {
75
+ return `(${durationMs.toFixed(0)}ms)`;
76
+ }
77
+ /**
78
+ * The display columns left for the DESCRIBED middle of a progress line once
79
+ * everything rendered AROUND it is reserved out of `max`: the leading
80
+ * {@link COMPLETED_GLYPH} and its space, and the trailing duration suffix and
81
+ * the space before it.
82
+ *
83
+ * The one-row guarantee is about the WHOLE rendered row — that is the thing the
84
+ * terminal has to fit — so the description alone can no longer spend the entire
85
+ * cap: appending `(1234ms)` to a line already at {@link MAX_PROGRESS_LINE}
86
+ * would wrap, which is exactly the jitter the truncation exists to prevent. The
87
+ * glyph is reserved for the same reason and was the earlier miss: a budget that
88
+ * covered only the suffix let `Wizard.tsx` emit `MAX_PROGRESS_LINE + 2` columns
89
+ * — overflowing on precisely the boundary this helper protects.
90
+ *
91
+ * Budgeting here (rather than truncating the joined line) keeps the timing
92
+ * legible — it is the part a middle-truncation would never protect, since it
93
+ * sits at neither end of the description.
94
+ *
95
+ * @param suffix - The rendered duration suffix, from {@link formatEffectDuration}.
96
+ * @param max - The whole-ROW width cap; defaults to {@link MAX_PROGRESS_LINE}.
97
+ * @returns The columns the description may occupy, never negative.
98
+ */
99
+ export function describedWidthBudget(suffix, max = MAX_PROGRESS_LINE) {
100
+ const around = measureDisplayWidth(COMPLETED_GLYPH) +
101
+ GLYPH_GAP +
102
+ SUFFIX_GAP +
103
+ measureDisplayWidth(suffix);
104
+ return Math.max(0, max - around);
105
+ }
23
106
  /**
24
107
  * East Asian Wide / Fullwidth / emoji code-point ranges, each an inclusive
25
108
  * `[low, high]` pair. A code point inside any range is rendered by terminals in
@@ -74,18 +157,58 @@ function decodeCodePoint(char) {
74
157
  const low = char.charCodeAt(1);
75
158
  return (high - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000;
76
159
  }
160
+ /**
161
+ * An ANSI CSI escape sequence — `ESC [`, parameter and intermediate bytes, then
162
+ * a final byte. Built with `RegExp` rather than written as a literal because the
163
+ * pattern must contain a raw control character (`ESC`), which a regex literal
164
+ * may not carry.
165
+ *
166
+ * Broad on purpose: the styling `chalk` emits is all SGR (`…m`), but a captured
167
+ * frame can also carry cursor and erase sequences, and none of them occupy a
168
+ * terminal cell.
169
+ */
170
+ const ANSI_ESCAPE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;:?]*[ -/]*[@-~]`, "g");
171
+ /**
172
+ * Remove ANSI escape sequences, leaving only the characters a terminal actually
173
+ * prints.
174
+ *
175
+ * The rendered frame is styled — `Wizard.tsx` wraps the status glyph in
176
+ * `<Text color="green">` and the duration in `<Text dimColor>`, and Ink renders
177
+ * those through `chalk` — so a completed progress row reaches a reader (or a
178
+ * test) as `ESC[32m✓ESC[39m … ESC[2m(5ms)ESC[22m`. Those 19 bytes are
179
+ * instructions to the terminal, not columns in it.
180
+ *
181
+ * Whether they are present at all depends on the environment: `chalk` enables
182
+ * colour only when it believes the stream is a terminal, so the SAME frame is
183
+ * bare under a plain `vitest` run and styled when the task runs under a task
184
+ * runner that allocates a pseudo-terminal (which is how CI invokes this suite).
185
+ * Counting the escapes as columns therefore made the measured width of one
186
+ * fixed row swing between 72 and 91 — a one-row guarantee that held or failed
187
+ * on the shape of the invoking shell. Stripping first makes the measurement say
188
+ * the same thing everywhere.
189
+ *
190
+ * @param text - Possibly styled text, e.g. a captured Ink frame.
191
+ * @returns `text` with every ANSI escape sequence removed.
192
+ */
193
+ export function stripStyles(text) {
194
+ return text.replace(ANSI_ESCAPE, "");
195
+ }
77
196
  /**
78
197
  * Measure the terminal-column width of a string, summing per-code-point widths:
79
198
  * one column for most code points, two for East Asian Wide / emoji ones (see
80
199
  * {@link isWideCodePoint}). Iterating code points rather than UTF-16 code units
81
200
  * means a surrogate pair counts once, as the single glyph it renders to.
82
201
  *
83
- * @param text - The string to measure.
202
+ * Styling is discounted first ({@link stripStyles}): an escape sequence costs
203
+ * bytes but no cells, so the width of a row is the same number whether or not
204
+ * colour is enabled.
205
+ *
206
+ * @param text - The string to measure; may carry ANSI styling.
84
207
  * @returns The approximate number of terminal columns `text` occupies.
85
208
  */
86
209
  export function measureDisplayWidth(text) {
87
210
  let width = 0;
88
- for (const char of text) {
211
+ for (const char of stripStyles(text)) {
89
212
  width += isWideCodePoint(decodeCodePoint(char)) ? 2 : 1;
90
213
  }
91
214
  return width;
@@ -122,6 +245,11 @@ function collectWithinWidth(chars, budget) {
122
245
  * code points, so the one-row guarantee holds for multibyte and wide (CJK /
123
246
  * emoji) paths and a surrogate pair is never split into a lone-surrogate `�`.
124
247
  *
248
+ * `line` must be UNSTYLED text — the description `Wizard.tsx` truncates before
249
+ * handing it to Ink, which applies the colour. Cutting a line that already
250
+ * carried escape sequences could sever one mid-sequence; the styling is applied
251
+ * around the truncated text precisely so that cannot arise.
252
+ *
125
253
  * @param line - The described-effect line (e.g. `Write file: a/b/c.ts (12 bytes)`).
126
254
  * @param max - The width cap, in columns; defaults to {@link MAX_PROGRESS_LINE}.
127
255
  * @returns The line unchanged when within the cap, else its truncated form.
@@ -1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WER_KEY, GENERATOR_CANCELLED, } from "../../execute/execute.js";
16
+ /** The prompts that apply given the answers so far (respecting `when`). */
17
+ function listApplicablePrompts(generator, answers) {
18
+ return generator.prompts.filter((p) => !p.when || p.when(answers) === true);
19
+ }
16
20
  /** Count the prompts that apply given the answers so far (respecting `when`). */
17
21
  function countApplicable(generator, answers) {
18
- return generator.prompts.filter((p) => !p.when || p.when(answers) === true)
19
- .length;
22
+ return listApplicablePrompts(generator, answers).length;
23
+ }
24
+ /**
25
+ * Count the APPLICABLE prompts already answered. The answer bag can carry
26
+ * keys that are not generator prompts at all (pragma's `framework` param) or
27
+ * answers to prompts a `when` currently excludes — counting raw keys let the
28
+ * step counter exceed the total.
29
+ */
30
+ function countAnswered(generator, answers) {
31
+ return listApplicablePrompts(generator, answers).filter((p) => Object.hasOwn(answers, p.name)).length;
20
32
  }
21
33
  /**
22
34
  * The controller: a tiny observable state machine driving the Ink wizard.
@@ -43,17 +55,21 @@ export class SessionController {
43
55
  * the run produces. Omitted falls back to the process cwd, matching a run
44
56
  * whose interpreter was given no `cwd`.
45
57
  */
46
- constructor(generator, onUserCancel, cwd) {
58
+ constructor(generator, onUserCancel, cwd, initialAnswers = {}) {
47
59
  this.onUserCancel = onUserCancel;
48
60
  this.cwd = cwd;
61
+ // Seed flag/MCP-provided answers: collectAnswers never asks for them, so
62
+ // without the seed the confirm gate's preview and the step counter run
63
+ // against an answer set with those values missing.
49
64
  this.current = {
50
65
  phase: "idle",
51
66
  generator,
52
- answers: {},
67
+ answers: { ...initialAnswers },
53
68
  step: 0,
54
- total: countApplicable(generator, {}),
69
+ total: countApplicable(generator, { ...initialAnswers }),
55
70
  previewEffects: [],
56
71
  progress: [],
72
+ steps: [],
57
73
  };
58
74
  }
59
75
  /** Subscribe to state changes; returns an unsubscribe function. */
@@ -87,7 +103,7 @@ export class SessionController {
87
103
  this.previewInFlight = this.loadPreview();
88
104
  }
89
105
  else {
90
- const answered = Object.keys(this.current.answers).length;
106
+ const answered = countAnswered(this.current.generator, this.current.answers);
91
107
  this.set({
92
108
  phase: "prompting",
93
109
  activeQuestion: effect,
@@ -123,8 +139,14 @@ export class SessionController {
123
139
  catch {
124
140
  previewEffects = [];
125
141
  }
126
- if (this.current.phase !== "confirming")
142
+ // Stale once the gate is no longer both showing AND unanswered. The phase
143
+ // check alone stopped covering the second half when submitConfirm began
144
+ // deferring the executing transition on this very promise: consent clears
145
+ // `pending` immediately but flips the phase only after this settles, so a
146
+ // result landing in that window would repaint a pane already answered.
147
+ if (this.current.phase !== "confirming" || this.pending === undefined) {
127
148
  return;
149
+ }
128
150
  this.set({ previewEffects });
129
151
  }
130
152
  /**
@@ -143,16 +165,79 @@ export class SessionController {
143
165
  reportEffectStart(_effect) {
144
166
  // No-op: the live view is driven by reportEffectComplete.
145
167
  }
146
- /** Record a completed effect for the live progress view. */
147
- reportEffectComplete(effect, _duration) {
168
+ /**
169
+ * Record a completed effect — and what it cost — for the live progress view.
170
+ * The seam delivers a per-effect `duration`; it is stored, not discarded, so
171
+ * the view can say how long each step took.
172
+ */
173
+ reportEffectComplete(effect, duration) {
148
174
  const timestamp = this.executionStart > 0 ? performance.now() - this.executionStart : 0;
149
175
  this.set({
150
176
  phase: this.current.phase === "cancelled" ? "cancelled" : "executing",
151
- progress: [...this.current.progress, { effect, timestamp }],
177
+ progress: [...this.current.progress, { effect, timestamp, duration }],
152
178
  });
153
179
  }
154
180
  /** A task log line (kept for parity; not surfaced by the default view). */
155
181
  reportLog(_level, _message) { }
182
+ /** Per-step `start` timestamps, so completion can measure wall time. */
183
+ stepStarts = new Map();
184
+ /**
185
+ * Fold a host step report into the live view (see {@link StepProgress}).
186
+ *
187
+ * GATED to the executing phase, unlike {@link reportEffectComplete}: effect
188
+ * callbacks only ever arrive from the real interpreter through the seam, but
189
+ * step reports originate INSIDE the host's task composition, so every
190
+ * interpretation of it fires them — including the confirm gate's own honest
191
+ * preview, which walks the same task before the user has consented. Dropping
192
+ * reports outside `executing` keeps a previewed step from painting itself
193
+ * as work in progress — and the gate is sound only because of the pairing
194
+ * invariant {@link submitConfirm} enforces: `executing` begins strictly
195
+ * AFTER the preview walk has completed (consent is released on
196
+ * `previewSettled()`), so no pre-consent walk can still be emitting once
197
+ * reports are accepted. Testing arrival time alone could not close that —
198
+ * a report says nothing about which walk produced it.
199
+ *
200
+ * The phase gate alone is still not enough: `execute` walks `generate` once
201
+ * more on the MOCK interpreter right after consent — synchronously, to give
202
+ * the outcome summary its file list — so a full set of settled steps arrives
203
+ * (in-phase, near-zero durations) before the real drive begins. Steps run
204
+ * sequentially with per-walk-unique keys, so a `start` for a key that has
205
+ * ALREADY settled can only mean a new interpretation: the board resets and
206
+ * the real walk repaints it with real timings. This is also why the view
207
+ * renders steps in the LIVE region, never under `<Static>` — a static row
208
+ * cannot be taken back, and the mock walk's rows must be.
209
+ */
210
+ reportStep(report) {
211
+ if (this.current.phase !== "executing")
212
+ return;
213
+ let steps = [...this.current.steps];
214
+ const at = steps.findIndex((step) => step.key === report.key);
215
+ let entry;
216
+ if (report.status === "start") {
217
+ if (at >= 0 && steps[at]?.status !== "running") {
218
+ // A settled key starting again: a fresh walk. Reset the board.
219
+ steps = [];
220
+ this.stepStarts.clear();
221
+ }
222
+ this.stepStarts.set(report.key, performance.now());
223
+ entry = { key: report.key, label: report.label, status: "running" };
224
+ }
225
+ else {
226
+ const started = this.stepStarts.get(report.key);
227
+ entry = {
228
+ key: report.key,
229
+ label: report.label,
230
+ status: report.status,
231
+ duration: started === undefined ? 0 : performance.now() - started,
232
+ };
233
+ }
234
+ const target = steps.findIndex((step) => step.key === report.key);
235
+ if (target >= 0)
236
+ steps[target] = entry;
237
+ else
238
+ steps.push(entry);
239
+ this.set({ steps });
240
+ }
156
241
  /** Mark the run complete (the view flashes a completion summary). */
157
242
  markComplete() {
158
243
  if (this.current.phase === "cancelled" || this.current.phase === "error")
@@ -182,16 +267,52 @@ export class SessionController {
182
267
  listener();
183
268
  pending.resolve(value);
184
269
  }
185
- /** The user answered the confirm gate. */
270
+ /**
271
+ * The user answered the confirm gate.
272
+ *
273
+ * Consent does NOT begin execution by itself. The gate's honest preview
274
+ * ({@link loadPreview}) walks the same `generate` the run will, and it is
275
+ * async — a fast Y can land while that walk is still in flight. Entering
276
+ * `executing` at that instant re-opened the gap {@link reportStep}'s phase
277
+ * gate exists to close: the pre-consent walk's late step reports arrived
278
+ * in-phase and were accepted, and one naming a key the real walk had
279
+ * already settled hit the fresh-walk reset and cleared the board mid-run.
280
+ * Step reports carry no walk identity — they are plain closures fired from
281
+ * task continuations — so the sound closure is to ensure NO pre-consent
282
+ * walk survives into the executing phase: consent is released only once
283
+ * {@link previewSettled} resolves, which is `runPreview` COMPLETING its
284
+ * walk (loadPreview catches its failure), not merely having started it.
285
+ * The pane has usually settled long before the user answers, so the
286
+ * deferral is normally one microtask.
287
+ *
288
+ * A cancel that lands while consent waits on the preview rejects the gate
289
+ * here, with the same `GENERATOR_CANCELLED` an at-prompt cancel carries —
290
+ * {@link cancel} cannot reach it, this method already claimed the pending
291
+ * slot — so the task fails cleanly instead of hanging on a prompt that
292
+ * would otherwise never settle.
293
+ */
186
294
  submitConfirm(proceed) {
187
295
  const pending = this.pending;
188
296
  if (!pending || !pending.isConfirm)
189
297
  return;
190
298
  this.pending = undefined;
191
- if (proceed)
299
+ if (!proceed) {
300
+ this.set({ phase: "cancelled" });
301
+ pending.resolve(false);
302
+ return;
303
+ }
304
+ void this.previewSettled().then(() => {
305
+ if (this.current.phase === "cancelled") {
306
+ pending.reject(new TaskExecutionError({
307
+ code: GENERATOR_CANCELLED,
308
+ message: "Cancelled.",
309
+ }));
310
+ return;
311
+ }
192
312
  this.executionStart = performance.now();
193
- this.set({ phase: proceed ? "executing" : "cancelled" });
194
- pending.resolve(proceed);
313
+ this.set({ phase: "executing" });
314
+ pending.resolve(true);
315
+ });
195
316
  }
196
317
  /**
197
318
  * The user cancelled (Ctrl-C / escape). Two things must happen, and both are
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sour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AM;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACtB,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QACjC,OAAO,EAAE,MAAM,CACb,IAAI,kBAAkB,CAAC;YACrB,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,YAAY;SACtB,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
@@ -31,9 +31,18 @@ export default function inkPrompt(generator, options = {}) {
31
31
  let mountP;
32
32
  let mounted;
33
33
  const ensure = () => {
34
- mountP ??= import("./ink/mount.js").then((mod) => {
34
+ mountP ??= import("./ink/mount.js")
35
+ .then((mod) => {
35
36
  mounted = mod.mountPromptSession(generator, options);
36
37
  return mounted;
38
+ })
39
+ .catch((error) => {
40
+ // Do not cache a failure — a trailing catch, so BOTH a failed dynamic
41
+ // import and a throw from mountPromptSession itself (e.g. Ink render)
42
+ // reset the memo; otherwise every later prompt in the session would
43
+ // reuse the same stale rejection.
44
+ mountP = undefined;
45
+ throw error;
37
46
  });
38
47
  return mountP;
39
48
  };
@@ -49,7 +58,14 @@ export default function inkPrompt(generator, options = {}) {
49
58
  onEffectStart: (effect) => mounted?.reportEffectStart(effect),
50
59
  onEffectComplete: (effect, duration) => mounted?.reportEffectComplete(effect, duration),
51
60
  onLog: (level, message) => mounted?.reportLog(level, message),
52
- dispose: () => mounted?.dispose(),
61
+ // Steps can only originate from the running task, and the session mounts
62
+ // on the FIRST Prompt effect — which precedes execution (the confirm gate
63
+ // is itself a prompt) — so by the time a step is reported the session
64
+ // exists; the guard only covers a host reporting outside a run.
65
+ reportStep: (report) => mounted?.reportStep(report),
66
+ dispose: async () => {
67
+ await mounted?.dispose();
68
+ },
53
69
  };
54
70
  }
55
71
  //# sourceMappingURL=inkPrompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inkPrompt.js","sourceRoot":"","sources":["../../../src/prompt/inkPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAsDH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAA8B,EAC9B,UAA4B,EAAE;IAE9B,IAAI,MAA2C,CAAC;IAChD,IAAI,OAAmC,CAAC;IAExC,MAAM,MAAM,GAAG,GAA4B,EAAE;QAC3C,MAAM,KAAK,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/C,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,wEAAwE;IACxE,4EAA4E;IAC5E,uDAAuD;IACvD,MAAM,aAAa,GAAkB,KAAK,EAAE,MAAM,EAAE,EAAE;QACpD,MAAM,OAAO,GAAG,MAAM,MAAM,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,OAAO;QACL,aAAa;QACb,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC;QAC7D,gBAAgB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CACrC,OAAO,EAAE,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC;QACjD,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC;QAC7D,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE;KAClC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"inkPrompt.js","sourceRoot":"","sources":["../../../src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AAyE;QACzE,0EAA0E;QAC1E,sEAAsE;QACtE,gEAAgE;QAChE,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC;QACnD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,OAAO,EAAE,OAAO,EAAE,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -19,7 +19,7 @@ import { missingRequiredError } from "./autoPrompt.js";
19
19
  export default function mcpPrompt(params = {}) {
20
20
  return (effect) => {
21
21
  const q = effect.question;
22
- if (q.name in params)
22
+ if (Object.hasOwn(params, q.name))
23
23
  return Promise.resolve(params[q.name]);
24
24
  if (q.default !== undefined)
25
25
  return Promise.resolve(q.default);
@@ -1 +1 @@
1
- {"version":3,"file":"mcpPrompt.js","sourceRoot":"","sources":["../../../src/prompt/mcpPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAA4C,EAAE;IAE9C,OAAO,CAAC,MAAoB,EAAE,EAAE;QAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC1B,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC/D,OAAO,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"mcpPrompt.js","sourceRoot":"","sources":["../../../src/prompt/mcpPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAA4C,EAAE;IAE9C,OAAO,CAAC,MAAoB,EAAE,EAAE;QAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC1B,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1E,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC/D,OAAO,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC"}
@@ -1,50 +1,42 @@
1
- import * as path from "node:path";
2
- const COMMENT_STYLES = {
3
- ".ts": { single: "//" },
4
- ".tsx": { single: "//" },
5
- ".js": { single: "//" },
6
- ".jsx": { single: "//" },
7
- ".mjs": { single: "//" },
8
- ".cjs": { single: "//" },
9
- ".css": { blockStart: "/*", blockEnd: "*/", preferBlock: true },
10
- ".scss": { single: "//" },
11
- ".sass": { single: "//" },
12
- ".less": { single: "//" },
13
- ".html": { blockStart: "<!--", blockEnd: "-->" },
14
- ".htm": { blockStart: "<!--", blockEnd: "-->" },
15
- ".xml": { blockStart: "<!--", blockEnd: "-->" },
16
- ".svg": { blockStart: "<!--", blockEnd: "-->" },
17
- ".vue": { blockStart: "<!--", blockEnd: "-->" },
18
- ".svelte": { blockStart: "<!--", blockEnd: "-->" },
19
- ".yaml": { single: "#" },
20
- ".yml": { single: "#" },
21
- ".toml": { single: "#" },
22
- ".sh": { single: "#" },
23
- ".bash": { single: "#" },
24
- ".zsh": { single: "#" },
25
- ".py": { single: "#" },
26
- ".rb": { single: "#" },
27
- ".go": { single: "//" },
28
- ".rs": { single: "//" },
29
- ".java": { single: "//" },
30
- ".kt": { single: "//" },
31
- ".swift": { single: "//" },
32
- ".c": { single: "//" },
33
- ".cpp": { single: "//" },
34
- ".h": { single: "//" },
35
- ".php": { single: "//" },
36
- ".md": { blockStart: "<!--", blockEnd: "-->" },
37
- ".mdx": { blockStart: "{/*", blockEnd: "*/}" },
38
- ".sql": { single: "--" },
39
- ".json": {},
40
- };
1
+ import getCommentStyle from "../template/getCommentStyle.js";
41
2
  /**
42
- * Apply a stamp to file content based on file extension.
43
- * Returns the original content if the file type doesn't support comments.
3
+ * The prologue a stamp must stay BELOW: a shebang, a PHP open tag, or an XML
4
+ * declaration must remain the file's first bytes or the file stops working
5
+ * (interpreter selection, PHP emitting the comment as page text, ill-formed
6
+ * XML). Returns the offset just past the prologue (including its newline when
7
+ * present), or null when the content has no prologue.
8
+ */
9
+ function prologueEnd(content) {
10
+ if (content.startsWith("#!")) {
11
+ const newline = content.indexOf("\n");
12
+ return newline === -1 ? content.length : newline + 1;
13
+ }
14
+ if (content.startsWith("<?php")) {
15
+ // Protect the opening TOKEN, not the whole first line: a one-line
16
+ // template (`<?php echo 'hi'; ?>`) must get the stamp right after the
17
+ // tag — advancing to the newline would land it after `?>`, as page text.
18
+ const afterTag = "<?php".length;
19
+ return content.charAt(afterTag) === "\n" ? afterTag + 1 : afterTag;
20
+ }
21
+ if (content.startsWith("<?xml")) {
22
+ const close = content.indexOf("?>");
23
+ if (close !== -1) {
24
+ const after = close + 2;
25
+ return content.charAt(after) === "\n" ? after + 1 : after;
26
+ }
27
+ }
28
+ return null;
29
+ }
30
+ /**
31
+ * Apply a stamp to file content based on file extension. Uses the same
32
+ * comment-style table as {@link getCommentStyle} — one source, no drift.
33
+ * Returns the original content when the file type doesn't support comments,
34
+ * and is IDEMPOTENT: content already carrying this exact stamp line is
35
+ * returned unchanged, so driving the same WriteFile effect twice (preview
36
+ * then run, or a re-drive) cannot stack stamps.
44
37
  */
45
38
  export default function applyStamp(filePath, content, stamp) {
46
- const ext = path.extname(filePath).toLowerCase();
47
- const style = COMMENT_STYLES[ext];
39
+ const style = getCommentStyle(filePath);
48
40
  if (!style) {
49
41
  return content;
50
42
  }
@@ -59,14 +51,20 @@ export default function applyStamp(filePath, content, stamp) {
59
51
  else {
60
52
  return content;
61
53
  }
62
- // Handle shebang - place stamp after it
63
- if (content.startsWith("#!")) {
64
- const firstNewline = content.indexOf("\n");
65
- if (firstNewline !== -1) {
66
- const shebang = content.slice(0, firstNewline + 1);
67
- const rest = content.slice(firstNewline + 1);
68
- return `${shebang}${stampLine}\n\n${rest}`;
69
- }
54
+ if (content.includes(stampLine)) {
55
+ return content;
56
+ }
57
+ // A short-echo opener (`<?=`) takes an expression, not statements — there
58
+ // is no safe line to claim, so leave the file unstamped.
59
+ if (content.startsWith("<?=")) {
60
+ return content;
61
+ }
62
+ const at = prologueEnd(content);
63
+ if (at !== null) {
64
+ const head = content.slice(0, at);
65
+ const rest = content.slice(at);
66
+ const separator = head.endsWith("\n") ? "" : "\n";
67
+ return `${head}${separator}${stampLine}\n\n${rest}`;
70
68
  }
71
69
  return `${stampLine}\n\n${content}`;
72
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"applyStamp.js","sourceRoot":"","sources":["../../../src/stamp/applyStamp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,MAAM,cAAc,GAQhB;IACF,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IACvB,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IACxB,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IACvB,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IACxB,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IACxB,MAAM,EAAE,EAAE,MAAM,EAAE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,OAAO,CAAC;IACjB,CAAC;IAED,0EAA0E;IAC1E,yDAAyD;IACzD,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAClD,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,OAAO,IAAI,EAAE,CAAC;IACtD,CAAC;IAED,OAAO,GAAG,SAAS,OAAO,OAAO,EAAE,CAAC;AACtC,CAAC"}
@@ -14,7 +14,10 @@ import applyStamp from "./applyStamp.js";
14
14
  */
15
15
  export default function createStampOnEffectStart(stamp, next) {
16
16
  return (effect) => {
17
- if (effect._tag === "WriteFile") {
17
+ // A verbatim write is a CARRIED COPY (see `rawFile`): its bytes must land
18
+ // exactly as loaded, so the stamp skips it — a stamped copy would differ
19
+ // from the CopyFile it replaced and corrupt carried artifacts.
20
+ if (effect._tag === "WriteFile" && effect.verbatim !== true) {
18
21
  effect.content = applyStamp(effect.path, effect.content, stamp);
19
22
  }
20
23
  next?.(effect);