@canonical/summon-core 0.31.0 → 0.33.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 (109) hide show
  1. package/dist/esm/execute/GeneratorResult.js +13 -0
  2. package/dist/esm/execute/GeneratorResult.js.map +1 -0
  3. package/dist/esm/execute/collectAnswers.js +92 -0
  4. package/dist/esm/execute/collectAnswers.js.map +1 -0
  5. package/dist/esm/execute/execute.js +73 -0
  6. package/dist/esm/execute/execute.js.map +1 -0
  7. package/dist/esm/execute/index.js +4 -0
  8. package/dist/esm/execute/index.js.map +1 -0
  9. package/dist/esm/execute/validateAnswers.js +47 -0
  10. package/dist/esm/execute/validateAnswers.js.map +1 -0
  11. package/dist/esm/format/effects.js +581 -0
  12. package/dist/esm/format/effects.js.map +1 -0
  13. package/dist/esm/format/index.js +2 -0
  14. package/dist/esm/format/index.js.map +1 -0
  15. package/dist/esm/index.js +8 -1
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/prompt/answerPromptWithDefaults.js +26 -0
  18. package/dist/esm/prompt/answerPromptWithDefaults.js.map +1 -0
  19. package/dist/esm/prompt/autoPrompt.js +50 -0
  20. package/dist/esm/prompt/autoPrompt.js.map +1 -0
  21. package/dist/esm/prompt/index.js +12 -0
  22. package/dist/esm/prompt/index.js.map +1 -0
  23. package/dist/esm/prompt/ink/Spinner.js +18 -0
  24. package/dist/esm/prompt/ink/Spinner.js.map +1 -0
  25. package/dist/esm/prompt/ink/Wizard.js +116 -0
  26. package/dist/esm/prompt/ink/Wizard.js.map +1 -0
  27. package/dist/esm/prompt/ink/answerValidation.js +32 -0
  28. package/dist/esm/prompt/ink/answerValidation.js.map +1 -0
  29. package/dist/esm/prompt/ink/mount.js +41 -0
  30. package/dist/esm/prompt/ink/mount.js.map +1 -0
  31. package/dist/esm/prompt/ink/progressWindow.js +143 -0
  32. package/dist/esm/prompt/ink/progressWindow.js.map +1 -0
  33. package/dist/esm/prompt/ink/prompts.js +219 -0
  34. package/dist/esm/prompt/ink/prompts.js.map +1 -0
  35. package/dist/esm/prompt/ink/selectChoices.js +28 -0
  36. package/dist/esm/prompt/ink/selectChoices.js.map +1 -0
  37. package/dist/esm/prompt/ink/session.js +176 -0
  38. package/dist/esm/prompt/ink/session.js.map +1 -0
  39. package/dist/esm/prompt/inkPrompt.js +55 -0
  40. package/dist/esm/prompt/inkPrompt.js.map +1 -0
  41. package/dist/esm/prompt/mcpPrompt.js +29 -0
  42. package/dist/esm/prompt/mcpPrompt.js.map +1 -0
  43. package/dist/esm/prompt/types.js +12 -0
  44. package/dist/esm/prompt/types.js.map +1 -0
  45. package/dist/esm/run/index.js +2 -0
  46. package/dist/esm/run/index.js.map +1 -0
  47. package/dist/esm/run/runGeneratorTask.js +63 -0
  48. package/dist/esm/run/runGeneratorTask.js.map +1 -0
  49. package/dist/esm/stamp/createGeneratorStamp.js +19 -0
  50. package/dist/esm/stamp/createGeneratorStamp.js.map +1 -0
  51. package/dist/esm/stamp/createStampOnEffectStart.js +23 -0
  52. package/dist/esm/stamp/createStampOnEffectStart.js.map +1 -0
  53. package/dist/esm/stamp/index.js +2 -0
  54. package/dist/esm/stamp/index.js.map +1 -1
  55. package/dist/types/execute/GeneratorResult.d.ts +23 -0
  56. package/dist/types/execute/GeneratorResult.d.ts.map +1 -0
  57. package/dist/types/execute/collectAnswers.d.ts +52 -0
  58. package/dist/types/execute/collectAnswers.d.ts.map +1 -0
  59. package/dist/types/execute/execute.d.ts +57 -0
  60. package/dist/types/execute/execute.d.ts.map +1 -0
  61. package/dist/types/execute/index.d.ts +6 -0
  62. package/dist/types/execute/index.d.ts.map +1 -0
  63. package/dist/types/execute/validateAnswers.d.ts +23 -0
  64. package/dist/types/execute/validateAnswers.d.ts.map +1 -0
  65. package/dist/types/format/effects.d.ts +86 -0
  66. package/dist/types/format/effects.d.ts.map +1 -0
  67. package/dist/types/format/index.d.ts +2 -0
  68. package/dist/types/format/index.d.ts.map +1 -0
  69. package/dist/types/index.d.ts +8 -1
  70. package/dist/types/index.d.ts.map +1 -1
  71. package/dist/types/prompt/answerPromptWithDefaults.d.ts +17 -0
  72. package/dist/types/prompt/answerPromptWithDefaults.d.ts.map +1 -0
  73. package/dist/types/prompt/autoPrompt.d.ts +35 -0
  74. package/dist/types/prompt/autoPrompt.d.ts.map +1 -0
  75. package/dist/types/prompt/index.d.ts +14 -0
  76. package/dist/types/prompt/index.d.ts.map +1 -0
  77. package/dist/types/prompt/ink/Spinner.d.ts +11 -0
  78. package/dist/types/prompt/ink/Spinner.d.ts.map +1 -0
  79. package/dist/types/prompt/ink/Wizard.d.ts +14 -0
  80. package/dist/types/prompt/ink/Wizard.d.ts.map +1 -0
  81. package/dist/types/prompt/ink/answerValidation.d.ts +31 -0
  82. package/dist/types/prompt/ink/answerValidation.d.ts.map +1 -0
  83. package/dist/types/prompt/ink/mount.d.ts +31 -0
  84. package/dist/types/prompt/ink/mount.d.ts.map +1 -0
  85. package/dist/types/prompt/ink/progressWindow.d.ts +48 -0
  86. package/dist/types/prompt/ink/progressWindow.d.ts.map +1 -0
  87. package/dist/types/prompt/ink/prompts.d.ts +35 -0
  88. package/dist/types/prompt/ink/prompts.d.ts.map +1 -0
  89. package/dist/types/prompt/ink/selectChoices.d.ts +42 -0
  90. package/dist/types/prompt/ink/selectChoices.d.ts.map +1 -0
  91. package/dist/types/prompt/ink/session.d.ts +103 -0
  92. package/dist/types/prompt/ink/session.d.ts.map +1 -0
  93. package/dist/types/prompt/inkPrompt.d.ts +64 -0
  94. package/dist/types/prompt/inkPrompt.d.ts.map +1 -0
  95. package/dist/types/prompt/mcpPrompt.d.ts +20 -0
  96. package/dist/types/prompt/mcpPrompt.d.ts.map +1 -0
  97. package/dist/types/prompt/types.d.ts +23 -0
  98. package/dist/types/prompt/types.d.ts.map +1 -0
  99. package/dist/types/run/index.d.ts +3 -0
  100. package/dist/types/run/index.d.ts.map +1 -0
  101. package/dist/types/run/runGeneratorTask.d.ts +51 -0
  102. package/dist/types/run/runGeneratorTask.d.ts.map +1 -0
  103. package/dist/types/stamp/createGeneratorStamp.d.ts +16 -0
  104. package/dist/types/stamp/createGeneratorStamp.d.ts.map +1 -0
  105. package/dist/types/stamp/createStampOnEffectStart.d.ts +17 -0
  106. package/dist/types/stamp/createStampOnEffectStart.d.ts.map +1 -0
  107. package/dist/types/stamp/index.d.ts +2 -0
  108. package/dist/types/stamp/index.d.ts.map +1 -1
  109. package/package.json +17 -10
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Build the generated-file stamp for a generator.
3
+ *
4
+ * This is the single source of the stamp identity: every binary that stamps
5
+ * output derives its `StampConfig` here, so `pragma create X` and `summon X`
6
+ * embed the identical generator identifier — a requirement of the cross-binary
7
+ * byte-equality guarantee. The display name is preferred (summon's historical
8
+ * stamp format), falling back to the registry name.
9
+ *
10
+ * @param gen - The generator whose output is being stamped.
11
+ * @returns The stamp configuration for the seam transform.
12
+ */
13
+ export default function createGeneratorStamp(gen) {
14
+ return {
15
+ generator: gen.meta.displayName ?? gen.meta.name,
16
+ version: gen.meta.version,
17
+ };
18
+ }
19
+ //# sourceMappingURL=createGeneratorStamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGeneratorStamp.js","sourceRoot":"","sources":["../../../src/stamp/createGeneratorStamp.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,GAAwB;IAExB,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI;QAChD,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ import applyStamp from "./applyStamp.js";
2
+ /**
3
+ * Build an `onEffectStart` seam callback that prepends the generated-file
4
+ * stamp to every `WriteFile` effect's content before it executes.
5
+ *
6
+ * This is THE stamping path: every binary that stamps generated output does so
7
+ * through this one transform on the shared executor's seam, so `pragma create
8
+ * X` and `summon X` write byte-identical files.
9
+ *
10
+ * @param stamp - The stamp configuration (generator name/version).
11
+ * @param next - An optional downstream `onEffectStart` (e.g. progress UI),
12
+ * invoked after stamping.
13
+ * @returns The composed `onEffectStart` callback.
14
+ */
15
+ export default function createStampOnEffectStart(stamp, next) {
16
+ return (effect) => {
17
+ if (effect._tag === "WriteFile") {
18
+ effect.content = applyStamp(effect.path, effect.content, stamp);
19
+ }
20
+ next?.(effect);
21
+ };
22
+ }
23
+ //# sourceMappingURL=createStampOnEffectStart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStampOnEffectStart.js","sourceRoot":"","sources":["../../../src/stamp/createStampOnEffectStart.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,KAAkB,EAClB,IAA+B;IAE/B,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAC/B,MAA8B,CAAC,OAAO,GAAG,UAAU,CAClD,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,OAAO,EACd,KAAK,CACN,CAAC;QACJ,CAAC;QACD,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC"}
@@ -1,3 +1,5 @@
1
1
  export { default as applyStamp } from "./applyStamp.js";
2
+ export { default as createGeneratorStamp } from "./createGeneratorStamp.js";
3
+ export { default as createStampOnEffectStart } from "./createStampOnEffectStart.js";
2
4
  export { default as runTaskWithStamp } from "./runTaskWithStamp.js";
3
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stamp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stamp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The value {@link execute} produces.
3
+ *
4
+ * `execute` returns a `Task<GeneratorResult>`; the runner interprets it. The
5
+ * result carries what a front-end needs to render an outcome summary — the
6
+ * generator identity, the resolved answers, and a preview of the effects the
7
+ * generation performed (paths, and best-effort content for embedded-template
8
+ * generators). Progress does NOT ride a bespoke event channel: it rides the
9
+ * runner's `onEffectStart`/`onEffectComplete`/`onLog` callbacks and the task
10
+ * alphabet's own `TaskEvent` — summon-core invents no parallel event system.
11
+ */
12
+ import type { Effect } from "@canonical/task";
13
+ import type GeneratorDefinition from "../types/GeneratorDefinition.js";
14
+ /** The outcome of running a generator through {@link execute}. */
15
+ export interface GeneratorResult {
16
+ /** The generator that ran (its meta drives the outcome summary + stamp). */
17
+ readonly generator: GeneratorDefinition;
18
+ /** The resolved answers the generation ran with. */
19
+ readonly answers: Record<string, unknown>;
20
+ /** A dry-run preview of the effects the generation performed. */
21
+ readonly effects: Effect[];
22
+ }
23
+ //# sourceMappingURL=GeneratorResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeneratorResult.d.ts","sourceRoot":"","sources":["../../../src/execute/GeneratorResult.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,mBAAmB,MAAM,iCAAiC,CAAC;AAEvE,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;IACxC,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;CAC5B"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The bridge from form-first generators to the dialog-first prompting model:
3
+ * turn a static prompt-definition list into a Task that asks each question as
4
+ * an interleaved `Prompt` effect through the executor's `promptHandler` seam.
5
+ *
6
+ * One builder makes every existing generator answerable by any front-end
7
+ * handler — Ink, MCP params, or defaults — without touching the generator:
8
+ * prompts already answered (CLI flags / MCP args) are skipped, `when`
9
+ * conditions are evaluated against the answers collected so far, and each
10
+ * remaining definition maps onto the task alphabet's `PromptQuestion`.
11
+ *
12
+ * Moved into summon-core (from the v1 cli-core `promptForAnswers`) as the
13
+ * answer-collection phase of {@link execute}.
14
+ */
15
+ import { type Task } from "@canonical/task";
16
+ /**
17
+ * A prompt definition a command can ask for: the structural shape shared by
18
+ * generator prompt lists, kept free of any generator-package dependency.
19
+ */
20
+ export interface AnswerablePrompt {
21
+ /** Answer key, unique within the list. */
22
+ readonly name: string;
23
+ /** Question text displayed to the user. */
24
+ readonly message: string;
25
+ /** Prompt kind, deciding how the handler renders and parses the answer. */
26
+ readonly type: "text" | "confirm" | "select" | "multiselect";
27
+ /** Default value when the user provides no input. */
28
+ readonly default?: unknown;
29
+ /** Available options for select/multiselect prompts. */
30
+ readonly choices?: ReadonlyArray<{
31
+ readonly label: string;
32
+ readonly value: string;
33
+ }>;
34
+ /** Ask only when this predicate over the answers so far returns true. */
35
+ readonly when?: (answers: Record<string, unknown>) => boolean;
36
+ /** Text validation: true to accept, or an error message to re-ask with. */
37
+ readonly validate?: (value: string) => boolean | string;
38
+ }
39
+ /**
40
+ * Build a Task that collects answers for the given prompt definitions by
41
+ * asking each unanswered, applicable one as a `Prompt` effect.
42
+ *
43
+ * The returned task is single-use (it is `gen`-based): build a fresh one per
44
+ * run. Prompts whose `name` is already present in `partialAnswers` are not
45
+ * asked; `when` predicates observe flags and earlier answers alike.
46
+ *
47
+ * @param prompts - The prompt definitions, in asking order.
48
+ * @param partialAnswers - Answers already provided (e.g. CLI flags / MCP args).
49
+ * @returns A task yielding the complete answers record.
50
+ */
51
+ export default function collectAnswers(prompts: readonly AnswerablePrompt[], partialAnswers?: Readonly<Record<string, unknown>>): Task<Record<string, unknown>>;
52
+ //# sourceMappingURL=collectAnswers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectAnswers.d.ts","sourceRoot":"","sources":["../../../src/execute/collectAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC7D,qDAAqD;IACrD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,wDAAwD;IACxD,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,yEAAyE;IACzE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;IAC9D,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAAC;CACzD;AAuDD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,cAAc,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,GACrD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAc/B"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The summon↔pragma seam: turn a generator + a prompt strategy into a
3
+ * `Task<GeneratorResult>` — WITHOUT running it.
4
+ *
5
+ * This one function is the whole seam. Both binaries build the same task here
6
+ * and interpret it their own way: pragma's `create` verb forwards the prompt
7
+ * strategy through `runtime.exec.promptHandler` and lets the kernel interpret
8
+ * it under the node / dry-run / undo interpreters; the summon bin runs it via
9
+ * `runGeneratorTask({ promptHandler })`. Same package + same handler ⇒
10
+ * byte-identical files.
11
+ *
12
+ * Because `execute` returns a task and does NOT run it, `--dry-run` and
13
+ * `--undo` keep working unchanged through the kernel's existing interpreters
14
+ * (which mock `Prompt` effects to their defaults). The task's shape is:
15
+ *
16
+ * collectAnswers → validate → confirm gate → generate → result
17
+ *
18
+ * The confirm gate is an ordinary `confirm` Prompt effect ({@link CONFIRM_ANSWER_KEY}):
19
+ * the non-interactive strategies resolve it to its default (`true`) and the
20
+ * dry-run interpreter mocks it to `true`, so it is a no-op there; the Ink
21
+ * strategy recognises the key and renders the preview + "Proceed?" gate. It is
22
+ * the single signal that answer collection is complete — which a streaming
23
+ * per-question handler otherwise cannot know.
24
+ */
25
+ import { type Task } from "@canonical/task";
26
+ import type { PromptHandler } from "../prompt/types.js";
27
+ import type GeneratorDefinition from "../types/GeneratorDefinition.js";
28
+ import type { GeneratorResult } from "./GeneratorResult.js";
29
+ /** The reserved answer key of the confirm gate the Ink strategy recognises. */
30
+ export declare const CONFIRM_ANSWER_KEY = "__summon_proceed__";
31
+ /** Task-error code for an answer that fails its prompt's own constraints. */
32
+ export declare const GENERATOR_INVALID_ANSWER = "GENERATOR_INVALID_ANSWER";
33
+ /** Task-error code for a run cancelled at the interactive confirm gate. */
34
+ export declare const GENERATOR_CANCELLED = "GENERATOR_CANCELLED";
35
+ /** The context {@link execute} builds its task from. */
36
+ export interface ExecuteContext {
37
+ /**
38
+ * The prompt strategy the returned task is meant to be interpreted with. The
39
+ * runner (`runTask` / `runGeneratorTask`) applies it; `execute` itself never
40
+ * calls it, so the same task dry-runs and undoes unchanged.
41
+ */
42
+ readonly prompt: PromptHandler;
43
+ /** Answers already provided (CLI flags / MCP args) — asked prompts are skipped. */
44
+ readonly params: Readonly<Record<string, unknown>>;
45
+ /** Abort signal, honoured by the interpreter between effects. */
46
+ readonly signal?: AbortSignal;
47
+ }
48
+ /**
49
+ * Build the seam task for one generator run.
50
+ *
51
+ * @param generator - The generator to run.
52
+ * @param ctx - The prompt strategy, provided answers, and optional abort signal.
53
+ * @returns A task that collects+validates answers, gates on confirmation, then
54
+ * performs the generation and yields a {@link GeneratorResult}.
55
+ */
56
+ export default function execute(generator: GeneratorDefinition, ctx: ExecuteContext): Task<GeneratorResult>;
57
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/execute/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAgC,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC1E,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,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,CAyCvB"}
@@ -0,0 +1,6 @@
1
+ export type { AnswerablePrompt } from "./collectAnswers.js";
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";
4
+ export type { GeneratorResult } from "./GeneratorResult.js";
5
+ export { default as validateAnswers } from "./validateAnswers.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,GACzB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Validate resolved generator answers against each prompt's own constraints.
3
+ *
4
+ * `select` answers must be one of the declared choices, and any `validate`
5
+ * function must accept the value. Returns the first failure message, or `null`
6
+ * when every applicable answer is valid.
7
+ *
8
+ * Reuses the exact `validate` the interactive prompt already runs, so a
9
+ * flag-driven or MCP-arg run (non-interactive) rejects the same bad input a
10
+ * wizard would — e.g. an empty component path or an unknown package type. This
11
+ * is the moved v1 `executeGenerator.findInvalidAnswer`, now run inside
12
+ * {@link execute} so both interactive and non-interactive paths share it.
13
+ */
14
+ import type PromptDefinition from "../types/PromptDefinition.js";
15
+ /**
16
+ * Find the first answer that violates its prompt's constraints.
17
+ *
18
+ * @param prompts - The generator's prompt definitions.
19
+ * @param answers - The resolved answers to validate.
20
+ * @returns A human-readable message for the first invalid answer, or `null`.
21
+ */
22
+ export default function validateAnswers(prompts: readonly PromptDefinition[], answers: Record<string, unknown>): string | null;
23
+ //# sourceMappingURL=validateAnswers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateAnswers.d.ts","sourceRoot":"","sources":["../../../src/execute/validateAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC;AAMjE;;;;;;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,CAyBf"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Effect formatting utilities for CLI output.
3
+ *
4
+ * Moved into summon-core (from the v1 cli-core `formatEffects`) so both the
5
+ * summon bin and the pragma kernel share one effect-formatting surface without
6
+ * either importing the other. The pragma `create` render layer reuses these
7
+ * helpers to project a {@link GeneratorResult}; cli-core re-exports them while
8
+ * it is retired.
9
+ */
10
+ import type { Effect } from "@canonical/task";
11
+ import type GeneratorDefinition from "../types/GeneratorDefinition.js";
12
+ import type PromptDefinition from "../types/PromptDefinition.js";
13
+ /**
14
+ * Filter effects to only show user-relevant ones (not internal effects).
15
+ * @param effect - The effect to check
16
+ * @param verbose - If true, include debug logs
17
+ */
18
+ export declare const isVisibleEffect: (effect: Effect, verbose?: boolean) => boolean;
19
+ /**
20
+ * Get human-readable action label for an effect.
21
+ */
22
+ export declare const getActionLabel: (effect: Effect) => string;
23
+ /**
24
+ * Get color for action label based on effect type.
25
+ */
26
+ export declare const getActionColor: (effect: Effect) => "green" | "red" | "yellow" | "cyan" | "blue" | "magenta" | undefined;
27
+ /**
28
+ * Get the payload (description) for an effect.
29
+ */
30
+ export declare const getEffectPayload: (effect: Effect) => string;
31
+ /**
32
+ * Format a single effect as a CLI line (for non-interactive output).
33
+ */
34
+ export declare const formatEffectLine: (effect: Effect, isLast: boolean) => string;
35
+ /**
36
+ * Format file content for preview display.
37
+ * Shows line numbers and truncates long content.
38
+ *
39
+ * @param content - The file content to format
40
+ * @param maxLines - Maximum number of lines to show (default: MAX_PREVIEW_LINES)
41
+ */
42
+ export declare const formatContentPreview: (content: string, maxLines?: number) => string;
43
+ /**
44
+ * Format an effect with its content (for verbose dry-run mode).
45
+ * This is useful for LLM agents that need to see generated file contents.
46
+ *
47
+ * @param effect - The effect to format
48
+ * @param isLast - Whether this is the last effect in the list
49
+ */
50
+ export declare const formatEffectWithContent: (effect: Effect, isLast: boolean) => string;
51
+ /**
52
+ * Map file extension to markdown code fence language hint.
53
+ */
54
+ export declare const getLanguageHint: (filePath: string) => string;
55
+ /**
56
+ * Get the plain-text action label for an effect (for LLM output).
57
+ */
58
+ export declare const getLlmActionLabel: (effect: Effect) => string;
59
+ /**
60
+ * Get the path/description for an effect (plain text, for LLM output).
61
+ */
62
+ export declare const getLlmEffectPath: (effect: Effect) => string;
63
+ /**
64
+ * Build the replay command string from generator name and answers.
65
+ */
66
+ export declare const buildReplayCommand: (generatorName: string, answers: Record<string, unknown>, prompts: PromptDefinition[]) => string;
67
+ /**
68
+ * Format the full LLM output as a markdown document.
69
+ *
70
+ * Produces a clean, structured markdown document with:
71
+ * - Generator metadata as heading + blockquote
72
+ * - Answers as a table
73
+ * - Plan as a table with action, path, line count
74
+ * - File contents in fenced code blocks with language hints
75
+ * - Replay command at the end
76
+ */
77
+ export declare const formatLlmMarkdown: (generator: GeneratorDefinition, answers: Record<string, unknown>, effects: Effect[], verbose?: boolean) => string;
78
+ /**
79
+ * Build the JSON output structure for --format json.
80
+ */
81
+ export declare const formatLlmJson: (generator: GeneratorDefinition, answers: Record<string, unknown>, effects: Effect[], verbose?: boolean) => Record<string, unknown>;
82
+ /**
83
+ * Format structured markdown help output for a generator (`--help --llm`).
84
+ */
85
+ export declare const formatLlmHelp: (generator: GeneratorDefinition, commandPath: string) => string;
86
+ //# sourceMappingURL=effects.d.ts.map
@@ -0,0 +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;AAKjE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,iBAAe,KAAG,OAiCjE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,MAoC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,KACb,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,SA+B7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAwBjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,QAAQ,OAAO,KAAG,MAUlE,CAAC;AAYF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,MAAM,EACf,WAAU,MAA0B,KACnC,MAsBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,EACd,QAAQ,OAAO,KACd,MAeF,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,KAAG,MA8ClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,MAyBlD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAqBjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,eAAe,MAAM,EACrB,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,gBAAgB,EAAE,KAC1B,MA4BF,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,MA4FF,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,CA8CxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,mBAAmB,EAC9B,aAAa,MAAM,KAClB,MAkHF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { buildReplayCommand, formatContentPreview, formatEffectLine, formatEffectWithContent, formatLlmHelp, formatLlmJson, formatLlmMarkdown, getActionColor, getActionLabel, getEffectPayload, getLanguageHint, getLlmActionLabel, getLlmEffectPath, isVisibleEffect, } from "./effects.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,GAChB,MAAM,cAAc,CAAC"}
@@ -9,7 +9,14 @@
9
9
  */
10
10
  export type { AnyGenerator, ForbidReserved, GeneratorDefinition, GeneratorMeta, PromptDefinition, ReservedOption, StampConfig, } from "./types/index.js";
11
11
  export type { RunTaskWithStampOptions } from "./stamp/index.js";
12
- export { applyStamp, runTaskWithStamp, } from "./stamp/index.js";
12
+ export { applyStamp, createGeneratorStamp, createStampOnEffectStart, runTaskWithStamp, } from "./stamp/index.js";
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";
15
+ export type { ConfirmPrompt, InkPromptOptions, InkSession, MultiselectPrompt, PromptEffect, PromptHandler, PromptQuestion, SelectPrompt, TextPrompt, } from "./prompt/index.js";
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";
18
+ export type { RunGeneratorTaskOptions } from "./run/index.js";
19
+ export { runGeneratorTask } from "./run/index.js";
13
20
  export type { TemplateDirOptions, TemplateOptions, TemplatingEngine, } from "./template/index.js";
14
21
  export { ejsEngine, generateStamp, generatorComment, getCommentStyle, prependStamp, renderFile, renderString, renderStringAsync, template, templateDir, templateHelpers, withHelpers, } from "./template/index.js";
15
22
  export { default as discoverGeneratorTree } from "./discovery/discoverGeneratorTree.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,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,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"}
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,GAChB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMlD,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,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,17 @@
1
+ import type { Effect } from "@canonical/task";
2
+ /**
3
+ * Resolve a `Prompt` effect to its default without user interaction — the
4
+ * defaults-only handler the summon Ink progress view drives, and the base the
5
+ * seam's {@link autoPrompt} strategy layers required-missing detection on.
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 `""`).
10
+ *
11
+ * @param effect - A `Prompt` effect to resolve.
12
+ * @returns The default answer for the prompt's type.
13
+ */
14
+ export default function answerPromptWithDefaults(effect: Effect & {
15
+ _tag: "Prompt";
16
+ }): Promise<unknown>;
17
+ //# sourceMappingURL=answerPromptWithDefaults.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The non-interactive prompt strategy: flags/args + defaults, with a structured
3
+ * failure for a missing required answer.
4
+ *
5
+ * This is the evolved `answerPromptWithDefaults` the seam calls for `--yes`, a
6
+ * non-interactive terminal, or CI. Because {@link collectAnswers} only emits a
7
+ * `Prompt` effect for a prompt NOT already provided, this handler is reached
8
+ * only for unprovided answers: it returns the prompt's declared default, or —
9
+ * when a prompt has no default (a required, unprovided answer) — rejects with a
10
+ * structured `MISSING_REQUIRED_ANSWER` task error rather than silently
11
+ * substituting a bare `""` / first-choice value (the old exit-3 safety).
12
+ */
13
+ import { TaskExecutionError } from "@canonical/task";
14
+ import type { PromptEffect, PromptHandler } from "./types.js";
15
+ /** The task-error code raised when a required answer is neither provided nor defaulted. */
16
+ export declare const MISSING_REQUIRED_ANSWER = "MISSING_REQUIRED_ANSWER";
17
+ /**
18
+ * Build the structured error for a required, unprovided answer.
19
+ *
20
+ * @param effect - The `Prompt` effect whose answer is missing.
21
+ * @param noun - How to name the missing input in the message ("flag" / "argument").
22
+ * @returns A {@link TaskExecutionError} the interpreter routes as a task failure.
23
+ */
24
+ export declare function missingRequiredError(effect: PromptEffect, noun?: "flag" | "argument"): TaskExecutionError;
25
+ /**
26
+ * A prompt handler that resolves each unprovided prompt to its default, or
27
+ * fails with {@link missingRequiredError} when no default exists.
28
+ *
29
+ * @param _params - The already-provided answers (accepted for symmetry with the
30
+ * other strategies; {@link collectAnswers} has already filtered these out, so
31
+ * this handler only ever sees unprovided prompts).
32
+ * @returns The non-interactive {@link PromptHandler}.
33
+ */
34
+ export default function autoPrompt(_params?: Readonly<Record<string, unknown>>): PromptHandler;
35
+ //# sourceMappingURL=autoPrompt.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The prompt-strategy barrel. STATIC exports only — no JSX, no static
3
+ * `import` of `ink`/`react`. The Ink strategy ({@link inkPrompt}) reaches its
4
+ * React UI ONLY through `await import("./ink/mount.js")` on first draw, so
5
+ * importing this barrel (or summon-core's root) never loads React. The
6
+ * lazy-React guard test enforces exactly this boundary.
7
+ */
8
+ export { default as answerPromptWithDefaults } from "./answerPromptWithDefaults.js";
9
+ export { default as autoPrompt, MISSING_REQUIRED_ANSWER, missingRequiredError, } from "./autoPrompt.js";
10
+ export type { InkPromptOptions, InkSession } from "./inkPrompt.js";
11
+ export { default as inkPrompt } from "./inkPrompt.js";
12
+ export { default as mcpPrompt } from "./mcpPrompt.js";
13
+ export type { ConfirmPrompt, MultiselectPrompt, PromptEffect, PromptHandler, PromptQuestion, SelectPrompt, TextPrompt, } from "./types.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A minimal braille loading spinner. Under `prompt/ink/**` — dynamic-only.
3
+ */
4
+ export interface SpinnerProps {
5
+ /** Color of the spinner. */
6
+ color?: string;
7
+ /** Label to show next to the spinner. */
8
+ label?: string;
9
+ }
10
+ export declare const Spinner: ({ color, label }: SpinnerProps) => import("react/jsx-runtime").JSX.Element;
11
+ //# sourceMappingURL=Spinner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/Spinner.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,OAAO,GAAI,kBAA2B,YAAY,4CAgB9D,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The root Ink view — a pure projection of {@link SessionController} state.
3
+ * Under `prompt/ink/**` — dynamic-only. Ported from the summon wizard's App,
4
+ * but it OWNS no execution: the seam runs the task; this view only renders the
5
+ * prompt sequence, the preview/confirm gate, live progress, and the outcome.
6
+ */
7
+ import type { SessionController } from "./session.js";
8
+ export interface WizardProps {
9
+ /** The controller this view projects and drives. */
10
+ controller: SessionController;
11
+ }
12
+ /** The wizard view — subscribes to the controller and renders its phase. */
13
+ export declare const Wizard: ({ controller }: WizardProps) => import("react/jsx-runtime").JSX.Element;
14
+ //# sourceMappingURL=Wizard.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Pure evaluation of a prompt's `validate` for the Ink widgets, so
3
+ * select/multiselect/confirm can run it INLINE with recovery (C6/M5) exactly as
4
+ * the text widget already does — instead of only catching a bad answer
5
+ * post-collection in `validateAnswers`, which fails the whole run with no chance
6
+ * to correct it in place. This is also the mechanism a multiselect uses to
7
+ * enforce a minimum selection (C-lo3): a validator that rejects an empty array.
8
+ *
9
+ * A `.ts` sibling of the JSX widgets so the accept/reject decision is unit
10
+ * testable without an Ink render.
11
+ */
12
+ /** A prompt's own value constraint: `true` accepts, a string is the error text. */
13
+ export type ValidateFn = (value: unknown) => boolean | string;
14
+ /** The outcome of running a {@link ValidateFn}: accepted, or a message to show. */
15
+ export type ValidationResult = {
16
+ readonly ok: true;
17
+ } | {
18
+ readonly ok: false;
19
+ readonly message: string;
20
+ };
21
+ /** The fallback message when a validator rejects without its own string. */
22
+ export declare const DEFAULT_INVALID_MESSAGE = "Invalid input";
23
+ /**
24
+ * Run a prompt's optional `validate` against a candidate answer.
25
+ *
26
+ * @param validate - The prompt's validator, or `undefined` (always accepts).
27
+ * @param value - The candidate answer to check.
28
+ * @returns A {@link ValidationResult} — `ok` when accepted, else the message.
29
+ */
30
+ export declare function evaluateValidation(validate: ValidateFn | undefined, value: unknown): ValidationResult;
31
+ //# sourceMappingURL=answerValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answerValidation.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/answerValidation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mFAAmF;AACnF,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,MAAM,CAAC;AAE9D,mFAAmF;AACnF,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;CAAE,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,UAAU,GAAG,SAAS,EAChC,KAAK,EAAE,OAAO,GACb,gBAAgB,CAQlB"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The dynamic-import target that stands up the Ink render.
3
+ *
4
+ * `inkPrompt` reaches this module ONLY via `await import("./ink/mount.js")` on
5
+ * the first `Prompt` effect — this is THE boundary that keeps `ink`/`react` out
6
+ * of summon-core's static graph. It wires one {@link SessionController} to one
7
+ * persistent Ink render (on stderr, so stdout carries only the machine/plain
8
+ * result the kernel prints after the run) and returns the seam handle.
9
+ */
10
+ import type { Effect, LogLevel } from "@canonical/task";
11
+ import type GeneratorDefinition from "../../types/GeneratorDefinition.js";
12
+ import type { InkPromptOptions } from "../inkPrompt.js";
13
+ import type { PromptEffect } from "../types.js";
14
+ /** The seam handle a mounted session exposes back to {@link inkPrompt}. */
15
+ export interface MountedSession {
16
+ answerPrompt: (effect: PromptEffect) => Promise<unknown>;
17
+ reportEffectStart: (effect: Effect) => void;
18
+ reportEffectComplete: (effect: Effect, duration: number) => void;
19
+ reportLog: (level: LogLevel, message: string) => void;
20
+ dispose: () => void;
21
+ }
22
+ /**
23
+ * Mount the wizard for a generator and return its seam handle.
24
+ *
25
+ * @param generator - The generator being run.
26
+ * @param options - The abort signal.
27
+ * @returns The {@link MountedSession} the prompt handler and effect callbacks drive.
28
+ * @note Impure — renders an Ink app to stderr and reads stdin.
29
+ */
30
+ export declare function mountPromptSession(generator: GeneratorDefinition, options?: InkPromptOptions): MountedSession;
31
+ //# sourceMappingURL=mount.d.ts.map
@@ -0,0 +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,CA6BhB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Pure helpers for the wizard's live progress view (C7/M7): keep each completed
3
+ * effect on ONE line by middle-truncating long paths, so a big application
4
+ * scaffold's progress does not wrap and jitter. Paired with rendering the
5
+ * completed lines under Ink's `<Static>` in `Wizard.tsx` — which is what
6
+ * actually stops the full-history re-render on every effect (the flicker/scroll
7
+ * root) — this keeps the live frame to a bounded, single-line-per-effect window.
8
+ *
9
+ * Truncation is DISPLAY-WIDTH aware, not UTF-16-code-unit aware. It iterates
10
+ * whole Unicode code points (so a supplementary-plane character is never sliced
11
+ * between its surrogate halves into a lone-surrogate `�`), and it counts East
12
+ * Asian Wide / Fullwidth / emoji code points as two terminal columns — because
13
+ * Ink lays the line out by cell width, so a code-unit cap alone would still let
14
+ * wide glyphs overflow and wrap. {@link measureDisplayWidth} is the shared
15
+ * width approximation both concerns rely on.
16
+ *
17
+ * A `.ts` sibling of the JSX view so the string math is unit testable.
18
+ */
19
+ /** Max display columns a single progress line may occupy before it is truncated. */
20
+ export declare const MAX_PROGRESS_LINE = 72;
21
+ /** The single-column marker inserted where a truncated middle was elided. */
22
+ export declare const TRUNCATION_MARKER = "\u2026";
23
+ /**
24
+ * Measure the terminal-column width of a string, summing per-code-point widths:
25
+ * one column for most code points, two for East Asian Wide / emoji ones (see
26
+ * {@link isWideCodePoint}). Iterating code points rather than UTF-16 code units
27
+ * means a surrogate pair counts once, as the single glyph it renders to.
28
+ *
29
+ * @param text - The string to measure.
30
+ * @returns The approximate number of terminal columns `text` occupies.
31
+ */
32
+ export declare function measureDisplayWidth(text: string): number;
33
+ /**
34
+ * Middle-truncate a progress line to `max` DISPLAY columns, preserving BOTH
35
+ * ends — a described effect's verb prefix (e.g. `Write file:`) and the tail of
36
+ * its path (the most identifying part) — and eliding the middle with
37
+ * {@link TRUNCATION_MARKER}.
38
+ *
39
+ * Width is measured and cut by {@link measureDisplayWidth}, iterating whole
40
+ * code points, so the one-row guarantee holds for multibyte and wide (CJK /
41
+ * emoji) paths and a surrogate pair is never split into a lone-surrogate `�`.
42
+ *
43
+ * @param line - The described-effect line (e.g. `Write file: a/b/c.ts (12 bytes)`).
44
+ * @param max - The width cap, in columns; defaults to {@link MAX_PROGRESS_LINE}.
45
+ * @returns The line unchanged when within the cap, else its truncated form.
46
+ */
47
+ export declare function truncateMiddle(line: string, max?: number): string;
48
+ //# sourceMappingURL=progressWindow.d.ts.map