@canonical/summon-core 0.32.0 → 0.34.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 (66) hide show
  1. package/dist/esm/execute/collectAnswers.js +2 -1
  2. package/dist/esm/execute/collectAnswers.js.map +1 -1
  3. package/dist/esm/format/effects.js +2 -2
  4. package/dist/esm/prompt/ink/Wizard.js +15 -6
  5. package/dist/esm/prompt/ink/Wizard.js.map +1 -1
  6. package/dist/esm/prompt/ink/answerValidation.js +32 -0
  7. package/dist/esm/prompt/ink/answerValidation.js.map +1 -0
  8. package/dist/esm/prompt/ink/mount.js +4 -2
  9. package/dist/esm/prompt/ink/mount.js.map +1 -1
  10. package/dist/esm/prompt/ink/progressWindow.js +143 -0
  11. package/dist/esm/prompt/ink/progressWindow.js.map +1 -0
  12. package/dist/esm/prompt/ink/prompts.js +96 -21
  13. package/dist/esm/prompt/ink/prompts.js.map +1 -1
  14. package/dist/esm/prompt/ink/selectChoices.js +28 -0
  15. package/dist/esm/prompt/ink/selectChoices.js.map +1 -0
  16. package/dist/esm/prompt/ink/session.js +58 -10
  17. package/dist/esm/prompt/ink/session.js.map +1 -1
  18. package/dist/esm/prompt/inkPrompt.js +3 -3
  19. package/dist/esm/prompt/inkPrompt.js.map +1 -1
  20. package/dist/esm/run/runGeneratorTask.js +3 -1
  21. package/dist/esm/run/runGeneratorTask.js.map +1 -1
  22. package/dist/esm/testing/conformance/diffTrees.js +61 -0
  23. package/dist/esm/testing/conformance/diffTrees.js.map +1 -0
  24. package/dist/esm/testing/conformance/fixtures.js +83 -0
  25. package/dist/esm/testing/conformance/fixtures.js.map +1 -0
  26. package/dist/esm/testing/conformance/index.js +17 -0
  27. package/dist/esm/testing/conformance/index.js.map +1 -0
  28. package/dist/esm/testing/conformance/produceReference.js +47 -0
  29. package/dist/esm/testing/conformance/produceReference.js.map +1 -0
  30. package/dist/esm/testing/conformance/snapshotTree.js +35 -0
  31. package/dist/esm/testing/conformance/snapshotTree.js.map +1 -0
  32. package/dist/esm/testing/index.js +10 -0
  33. package/dist/esm/testing/index.js.map +1 -0
  34. package/dist/types/execute/collectAnswers.d.ts +2 -1
  35. package/dist/types/execute/collectAnswers.d.ts.map +1 -1
  36. package/dist/types/format/effects.d.ts +2 -2
  37. package/dist/types/prompt/ink/Wizard.d.ts.map +1 -1
  38. package/dist/types/prompt/ink/answerValidation.d.ts +31 -0
  39. package/dist/types/prompt/ink/answerValidation.d.ts.map +1 -0
  40. package/dist/types/prompt/ink/mount.d.ts.map +1 -1
  41. package/dist/types/prompt/ink/progressWindow.d.ts +48 -0
  42. package/dist/types/prompt/ink/progressWindow.d.ts.map +1 -0
  43. package/dist/types/prompt/ink/prompts.d.ts +11 -2
  44. package/dist/types/prompt/ink/prompts.d.ts.map +1 -1
  45. package/dist/types/prompt/ink/selectChoices.d.ts +42 -0
  46. package/dist/types/prompt/ink/selectChoices.d.ts.map +1 -0
  47. package/dist/types/prompt/ink/session.d.ts +36 -1
  48. package/dist/types/prompt/ink/session.d.ts.map +1 -1
  49. package/dist/types/prompt/inkPrompt.d.ts +10 -3
  50. package/dist/types/prompt/inkPrompt.d.ts.map +1 -1
  51. package/dist/types/run/runGeneratorTask.d.ts +3 -1
  52. package/dist/types/run/runGeneratorTask.d.ts.map +1 -1
  53. package/dist/types/testing/conformance/diffTrees.d.ts +38 -0
  54. package/dist/types/testing/conformance/diffTrees.d.ts.map +1 -0
  55. package/dist/types/testing/conformance/fixtures.d.ts +39 -0
  56. package/dist/types/testing/conformance/fixtures.d.ts.map +1 -0
  57. package/dist/types/testing/conformance/index.d.ts +21 -0
  58. package/dist/types/testing/conformance/index.d.ts.map +1 -0
  59. package/dist/types/testing/conformance/produceReference.d.ts +35 -0
  60. package/dist/types/testing/conformance/produceReference.d.ts.map +1 -0
  61. package/dist/types/testing/conformance/snapshotTree.d.ts +21 -0
  62. package/dist/types/testing/conformance/snapshotTree.d.ts.map +1 -0
  63. package/dist/types/testing/index.d.ts +11 -0
  64. package/dist/types/testing/index.d.ts.map +1 -0
  65. package/package.json +13 -8
  66. package/spec/generator-definition.v1.schema.json +122 -0
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/prompts.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,iBAAiB,CAAC;AAKzB,OAAO,KAAK,gBAAgB,MAAM,iCAAiC,CAAC;AAEpE,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,EACd,QAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC,KACjD,MAiBF,CAAC;AAEF,yDAAyD;AACzD,eAAO,MAAM,YAAY,GAAI,uBAG1B;IACD,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,mDAsBA,CAAC;AAEF,yCAAyC;AACzC,eAAO,MAAM,cAAc,GAAI,qBAG5B;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,4CAMA,CAAC;AAsLF,6DAA6D;AAC7D,eAAO,MAAM,YAAY,GAAI,mCAI1B;IACD,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,4CAmCA,CAAC"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/prompts.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,iBAAiB,CAAC;AAKzB,OAAO,KAAK,gBAAgB,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG5E,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,EACd,QAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC,KACjD,MAiBF,CAAC;AAEF,yDAAyD;AACzD,eAAO,MAAM,YAAY,GAAI,uBAG1B;IACD,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,mDAsBA,CAAC;AAEF,yCAAyC;AACzC,eAAO,MAAM,cAAc,GAAI,qBAG5B;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,4CAMA,CAAC;AAuTF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,6CAK1B;IACD,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,4CAsCA,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Pure classification of a `select` prompt's choices, so the Ink
3
+ * `SelectQuestion` widget can guard the two degenerate shapes that would
4
+ * otherwise HANG the wizard (C4/M6): a select with ZERO choices (nothing to
5
+ * pick — only Ctrl-C/Escape exit, a silent dead-end), and a select with EXACTLY
6
+ * one choice (a forced pick that should resolve itself rather than demand a
7
+ * keystroke).
8
+ *
9
+ * Lives as a `.ts` sibling of the JSX widgets so the branch logic is unit
10
+ * testable WITHOUT standing up an Ink render (the `.tsx` widget file is excluded
11
+ * from the vitest unit run).
12
+ */
13
+ /** One selectable option, as carried by a `select`/`multiselect` question. */
14
+ export interface SelectChoice {
15
+ readonly label: string;
16
+ readonly value: string;
17
+ }
18
+ /**
19
+ * The shape a select's choices reduce to:
20
+ *
21
+ * - `empty` — zero choices: a misconfiguration the widget surfaces as a clear
22
+ * error instead of a silent hang.
23
+ * - `single` — exactly one choice: auto-resolve it (no keystroke needed).
24
+ * - `multiple` — the normal interactive list.
25
+ */
26
+ export type SelectChoicesClassification = {
27
+ readonly kind: "empty";
28
+ } | {
29
+ readonly kind: "single";
30
+ readonly value: string;
31
+ } | {
32
+ readonly kind: "multiple";
33
+ readonly choices: readonly SelectChoice[];
34
+ };
35
+ /**
36
+ * Classify a select's choices into a {@link SelectChoicesClassification}.
37
+ *
38
+ * @param choices - The select prompt's declared or dynamically-built choices.
39
+ * @returns The degenerate-or-normal classification the widget branches on.
40
+ */
41
+ export declare function classifySelectChoices(choices: readonly SelectChoice[]): SelectChoicesClassification;
42
+ //# sourceMappingURL=selectChoices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectChoices.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/selectChoices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,2BAA2B,GACnC;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAA;CAAE,CAAC;AAE7E;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,2BAA2B,CAO7B"}
@@ -43,10 +43,13 @@ export interface WizardState {
43
43
  */
44
44
  export declare class SessionController {
45
45
  private readonly onUserCancel?;
46
+ private readonly cwd?;
46
47
  private current;
47
48
  private readonly listeners;
48
49
  private pending?;
49
50
  private executionStart;
51
+ /** The confirm gate's in-flight preview, awaited only by {@link previewSettled}. */
52
+ private previewInFlight?;
50
53
  /**
51
54
  * @param generator - The generator being run.
52
55
  * @param onUserCancel - Invoked once when the user cancels (Ctrl-C / escape).
@@ -55,8 +58,12 @@ export declare class SessionController {
55
58
  * `checkInterrupted` fires between effects) instead of only rejecting a
56
59
  * — by then non-existent — pending prompt. `abort()` is idempotent, so the
57
60
  * signal→cancel→abort path cannot loop.
61
+ * @param cwd - The write root the run will resolve relative effect paths
62
+ * against. The preview reads the SAME tree, so the gate's plan is the plan
63
+ * the run produces. Omitted falls back to the process cwd, matching a run
64
+ * whose interpreter was given no `cwd`.
58
65
  */
59
- constructor(generator: GeneratorDefinition, onUserCancel?: (() => void) | undefined);
66
+ constructor(generator: GeneratorDefinition, onUserCancel?: (() => void) | undefined, cwd?: string | undefined);
60
67
  /** Subscribe to state changes; returns an unsubscribe function. */
61
68
  subscribe: (listener: () => void) => (() => void);
62
69
  /** The current immutable snapshot (stable identity between changes). */
@@ -67,6 +74,34 @@ export declare class SessionController {
67
74
  * view resolves once the user answers (or the run is cancelled).
68
75
  */
69
76
  request(effect: PromptEffect): Promise<unknown>;
77
+ /**
78
+ * Fill the confirm gate's preview pane with the HONEST plan.
79
+ *
80
+ * `runPreview` reads the real filesystem (through a virtual write overlay, so
81
+ * a step sees what the step before it planned) and records writes without
82
+ * performing them — the gate is shown BEFORE the user consents, so it must
83
+ * not touch the disk, and it must not lie about what will happen. The mock it
84
+ * replaces answered every read with a placeholder and `Exists` with `true`,
85
+ * so the pane could promise files a run would never reach.
86
+ *
87
+ * Failure shows an EMPTY pane rather than a fictional one: the generator's
88
+ * own error belongs to the run, which reports it with its real message, and
89
+ * the decision at the gate stays the user's. A result that arrives after the
90
+ * gate is gone — the user answered or cancelled while the reads were in
91
+ * flight — is dropped, so a slow preview can never repaint a pane the wizard
92
+ * has already left.
93
+ */
94
+ private loadPreview;
95
+ /**
96
+ * Resolves once the confirm gate's preview has been applied (or dropped as
97
+ * stale). The wizard itself never awaits this — the pane repaints when the
98
+ * preview lands, which is the whole point of making it async — but a caller
99
+ * that asserts ON the pane has to synchronise with the real filesystem reads
100
+ * the preview performs, and a wall-clock delay would only be flaky.
101
+ *
102
+ * @returns A promise for the in-flight preview, already resolved when none is.
103
+ */
104
+ previewSettled(): Promise<void>;
70
105
  /** Feed effect start (kept for seam symmetry; progress rides completion). */
71
106
  reportEffectStart(_effect: Effect): void;
72
107
  /** Record a completed effect for the live progress view. */
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;AAKzB,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,WAAW,GACX,YAAY,GACZ,WAAW,GACX,UAAU,GACV,OAAO,GACP,WAAW,CAAC;AAEhB,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,mEAAmE;IACnE,QAAQ,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC;IACvC,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC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D,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAgBlC,0CAA0C;IAC1C,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IASrC;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,IAAI,IAAI;CAYf"}
@@ -31,6 +31,13 @@ export interface InkPromptOptions {
31
31
  * way (an external abort tears the render down).
32
32
  */
33
33
  readonly onCancel?: () => void;
34
+ /**
35
+ * The write root the run resolves relative effect paths against — pass the
36
+ * same value the interpreter will receive. The confirm gate's preview reads
37
+ * that tree, so the pane's plan is the plan the run produces. Omitted falls
38
+ * back to the process cwd, matching a run given no `cwd` of its own.
39
+ */
40
+ readonly cwd?: string;
34
41
  }
35
42
  /**
36
43
  * A running Ink session's seam surface: the prompt handler plus the effect
@@ -55,9 +62,9 @@ export interface InkSession {
55
62
  * dynamically imports the React UI), so picking this strategy on a fast path
56
63
  * that never prompts costs nothing and loads no React.
57
64
  *
58
- * @param generator - The generator being run (the session dry-runs it to build
59
- * the confirm gate's preview).
60
- * @param options - The abort signal.
65
+ * @param generator - The generator being run (the session previews it to build
66
+ * the confirm gate's plan).
67
+ * @param options - The abort signal, cancel callback, and preview write root.
61
68
  * @returns The {@link InkSession} the `create` verb wires into `runtime.exec`.
62
69
  */
63
70
  export default function inkPrompt(generator: GeneratorDefinition, options?: InkPromptOptions): InkSession;
@@ -1 +1 @@
1
- {"version":3,"file":"inkPrompt.d.ts","sourceRoot":"","sources":["../../../src/prompt/inkPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,mBAAmB,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9D,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,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CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,uEAAuE;IACvE,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,+EAA+E;IAC/E,QAAQ,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,wEAAwE;IACxE,QAAQ,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAWD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAAS,EAAE,mBAAmB,EAC9B,OAAO,GAAE,gBAAqB,GAC7B,UAAU,CA4BZ"}
@@ -11,7 +11,9 @@
11
11
  *
12
12
  * Moved into summon-core (from the v1 cli-core) so it sits below both the
13
13
  * summon bin and the pragma kernel — the shared seam the byte-equality
14
- * guarantee rests on. cli-core re-exports it while it is retired.
14
+ * guarantee rests on, and the one `testing/conformance/produceReference` runs.
15
+ * Both bins import it from HERE; the cli-core re-export shim is gone with that
16
+ * package.
15
17
  */
16
18
  import type { Task } from "@canonical/task";
17
19
  import { type RunTaskOptions } from "@canonical/task/node";
@@ -1 +1 @@
1
- {"version":3,"file":"runGeneratorTask.d.ts","sourceRoot":"","sources":["../../../src/run/runGeneratorTask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,cAAc,EAAW,MAAM,sBAAsB,CAAC;AAEpE,wEAAwE;AACxE,MAAM,W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CAAC;IACzD,0CAA0C;IAC1C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAC/D,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAaD;;;;;;;;;;;;GAYG;AACH,wBAA8B,gBAAgB,CAAC,CAAC,EAC9C,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EACb,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,CAAC,CAAC,CA0BZ"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Compare two generated trees and say precisely how they differ.
3
+ *
4
+ * A bare `expect(a).toEqual(b)` over two trees reports "objects differ" and
5
+ * leaves the reader to find the byte. This returns the three ways a tree can
6
+ * diverge — a path only one side wrote, and a path both wrote with different
7
+ * contents — so a conformance failure names the file that broke the seam.
8
+ */
9
+ import type { TreeSnapshot } from "./snapshotTree.js";
10
+ /** How two trees differ. Empty in all three fields means byte-identical. */
11
+ export interface TreeDiff {
12
+ /** Paths the first tree has and the second does not. */
13
+ readonly onlyInFirst: readonly string[];
14
+ /** Paths the second tree has and the first does not. */
15
+ readonly onlyInSecond: readonly string[];
16
+ /** Paths both trees have, whose contents differ. */
17
+ readonly differingContent: readonly string[];
18
+ }
19
+ /**
20
+ * Diff two snapshots.
21
+ *
22
+ * @param first - One producer's tree.
23
+ * @param second - The other producer's tree.
24
+ * @returns The three divergence sets, each sorted.
25
+ */
26
+ export declare function diffTrees(first: TreeSnapshot, second: TreeSnapshot): TreeDiff;
27
+ /** Whether a diff reports no divergence at all — the conformance condition. */
28
+ export declare function isIdentical(diff: TreeDiff): boolean;
29
+ /**
30
+ * Render a diff as an assertion message.
31
+ *
32
+ * @param diff - The divergence to describe.
33
+ * @param firstLabel - What produced the first tree (e.g. the bin's name).
34
+ * @param secondLabel - What produced the second tree.
35
+ * @returns A multi-line message, or the empty string when the trees match.
36
+ */
37
+ export declare function formatTreeDiff(diff: TreeDiff, firstLabel: string, secondLabel: string): string;
38
+ //# sourceMappingURL=diffTrees.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diffTrees.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/diffTrees.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,4EAA4E;AAC5E,MAAM,WAAW,QAAQ;IACvB,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,oDAAoD;IACpD,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,QAAQ,CAa7E;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAMnD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAaR"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The shared answer sets both binaries run their conformance cases from.
3
+ *
4
+ * DATA ONLY — this module imports no generator, by design. summon-core sits
5
+ * BELOW both bins, so reaching up for `@canonical/summon`'s `example/hello` or
6
+ * for pragma's bundled component/package/application generators would invert
7
+ * the dependency direction the whole fold rests on. A fixture therefore names
8
+ * its generator by a logical id and carries the answers; the CONSUMING package
9
+ * resolves that id to a real `GeneratorDefinition` it already owns and hands it
10
+ * to {@link produceReference}.
11
+ *
12
+ * The ids are conventional, not enforced: a consumer covers the ones it ships
13
+ * and ignores the rest, and adds its own fixtures where it has generators no
14
+ * one else does.
15
+ */
16
+ /** One conformance case: which generator, and the complete answers for it. */
17
+ export interface ConformanceFixture {
18
+ /** Human-readable case name, used in test titles. */
19
+ readonly name: string;
20
+ /** Logical generator id the consuming package resolves (e.g. `component/react`). */
21
+ readonly generator: string;
22
+ /** A COMPLETE answer set — every prompt answered, so no interaction occurs. */
23
+ readonly answers: Readonly<Record<string, unknown>>;
24
+ }
25
+ /**
26
+ * The design-system generator fixtures — the five trees pragma's `create` verbs
27
+ * and summon's `execute` must agree on byte for byte.
28
+ */
29
+ export declare const CONFORMANCE_FIXTURES: readonly ConformanceFixture[];
30
+ /**
31
+ * Look up a fixture by name.
32
+ *
33
+ * @param name - The fixture's {@link ConformanceFixture.name}.
34
+ * @returns The fixture.
35
+ * @throws If no fixture carries that name — a typo must fail loudly rather
36
+ * than silently skip a conformance case.
37
+ */
38
+ export declare function fixture(name: string): ConformanceFixture;
39
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD;AASD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,kBAAkB,EA0C7D,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAIxD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The byte-equality conformance suite: the seam's definition, plus the tools to
3
+ * assert against it.
4
+ *
5
+ * Both binaries generate the same trees from the same generators. That was a
6
+ * guarantee asserted inside ONE bin's test file, which meant the other bin
7
+ * could drift with nothing to catch it. Here it is a named suite that either
8
+ * bin runs: {@link produceReference} IS the definition (summon-core `execute` +
9
+ * `autoPrompt` + `runGeneratorTask` + the shared stamp), {@link snapshotTree}
10
+ * and {@link diffTrees} make "the same tree" a value comparison with a legible
11
+ * failure, and {@link CONFORMANCE_FIXTURES} keeps the answer sets in one place.
12
+ */
13
+ export type { TreeDiff } from "./diffTrees.js";
14
+ export { diffTrees, formatTreeDiff, isIdentical } from "./diffTrees.js";
15
+ export type { ConformanceFixture } from "./fixtures.js";
16
+ export { CONFORMANCE_FIXTURES, fixture } from "./fixtures.js";
17
+ export type { ReferenceRun } from "./produceReference.js";
18
+ export { produceReference } from "./produceReference.js";
19
+ export type { TreeSnapshot } from "./snapshotTree.js";
20
+ export { snapshotTree } from "./snapshotTree.js";
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * THE definition of the seam a conforming binary must match.
3
+ *
4
+ * A binary conforms iff, for a given generator and answer set, the tree it
5
+ * writes byte-equals the tree produced HERE: summon-core's `execute` with
6
+ * `autoPrompt`, run through `runGeneratorTask` with the shared stamp
7
+ * (`createStampOnEffectStart(createGeneratorStamp(generator))`). Every other
8
+ * path — the summon bin's Ink front-end, the pragma kernel's `create` verbs —
9
+ * is a UI over exactly this, so the reference is not "one more implementation
10
+ * to keep in sync"; it is the implementation, called without a front-end.
11
+ *
12
+ * Writing that definition down once is the point. Before this module, the
13
+ * guarantee lived only inside one bin's test file, so the OTHER bin could drift
14
+ * and nothing would notice.
15
+ */
16
+ import type GeneratorDefinition from "../../types/GeneratorDefinition.js";
17
+ import { type TreeSnapshot } from "./snapshotTree.js";
18
+ /** One reference run: a generator, the answers to feed it, and where to write. */
19
+ export interface ReferenceRun {
20
+ /** The generator definition under test — supplied by the CALLER's package. */
21
+ readonly generator: GeneratorDefinition<any>;
22
+ /** The complete answer set; every prompt must be answered (no interaction). */
23
+ readonly answers: Readonly<Record<string, unknown>>;
24
+ /** Where to generate. Defaults to a fresh temp directory. */
25
+ readonly cwd?: string;
26
+ }
27
+ /**
28
+ * Produce the reference tree for one generator + answer set.
29
+ *
30
+ * @param run - The generator, its answers, and an optional target directory.
31
+ * @returns The generated tree, snapshotted.
32
+ * @note Impure — writes files and reads them back.
33
+ */
34
+ export declare function produceReference(run: ReferenceRun): Promise<TreeSnapshot>;
35
+ //# sourceMappingURL=produceReference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"produceReference.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/produceReference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEpE,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAE9E,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAC7C,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAOD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,YAAY,GAChB,OAAO,CAAC,YAAY,CAAC,CAevB"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Read a generated directory tree into a comparable value.
3
+ *
4
+ * The conformance suite's unit of comparison. A tree is a sorted map of
5
+ * POSIX-style relative path → file contents, which makes "the same tree" an
6
+ * ordinary value equality rather than a filesystem walk each caller reinvents.
7
+ * Directory entries are not recorded: an empty directory a generator creates and
8
+ * never fills is not part of what a consumer sees, and recording it would make
9
+ * two conforming bins differ over a `mkdir` neither materialized.
10
+ */
11
+ /** A generated tree: relative path → file contents, in sorted path order. */
12
+ export type TreeSnapshot = ReadonlyMap<string, string>;
13
+ /**
14
+ * Snapshot a directory tree.
15
+ *
16
+ * @param dir - The root to walk. Every file below it is read as UTF-8.
17
+ * @returns The tree as a sorted path → contents map.
18
+ * @note Impure — reads the filesystem.
19
+ */
20
+ export declare function snapshotTree(dir: string): TreeSnapshot;
21
+ //# sourceMappingURL=snapshotTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshotTree.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/snapshotTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CActD"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `@canonical/summon-core/testing` — test-only helpers a CONSUMER runs.
3
+ *
4
+ * A separate subpath, not part of the main barrel, for two reasons: nothing on
5
+ * a production path should be able to import a temp-directory writer by
6
+ * accident, and the main barrel is the runtime contract while this is a testing
7
+ * contract that may move faster.
8
+ */
9
+ export type { ConformanceFixture, ReferenceRun, TreeDiff, TreeSnapshot, } from "./conformance/index.js";
10
+ export { CONFORMANCE_FIXTURES, diffTrees, fixture, formatTreeDiff, isIdentical, produceReference, snapshotTree, } from "./conformance/index.js";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACR,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,SAAS,EACT,OAAO,EACP,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,wBAAwB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/summon-core",
3
3
  "description": "Code generation framework: generator definitions, templates, stamps, discovery. Built on @canonical/task.",
4
- "version": "0.32.0",
4
+ "version": "0.34.0",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -9,10 +9,15 @@
9
9
  ".": {
10
10
  "types": "./dist/types/index.d.ts",
11
11
  "import": "./dist/esm/index.js"
12
+ },
13
+ "./testing": {
14
+ "types": "./dist/types/testing/index.d.ts",
15
+ "import": "./dist/esm/testing/index.js"
12
16
  }
13
17
  },
14
18
  "files": [
15
- "dist"
19
+ "dist",
20
+ "spec"
16
21
  ],
17
22
  "author": {
18
23
  "email": "webteam@canonical.com",
@@ -46,9 +51,9 @@
46
51
  },
47
52
  "devDependencies": {
48
53
  "@biomejs/biome": "2.4.9",
49
- "@canonical/biome-config": "^0.32.0",
50
- "@canonical/typescript-config": "^0.32.0",
51
- "@canonical/webarchitect": "^0.32.0",
54
+ "@canonical/biome-config": "^0.34.0",
55
+ "@canonical/typescript-config": "^0.34.0",
56
+ "@canonical/webarchitect": "^0.34.0",
52
57
  "@types/bun": "^1.3.10",
53
58
  "@types/ejs": "^3.1.5",
54
59
  "@types/node": "^24.12.0",
@@ -58,8 +63,8 @@
58
63
  "vitest": "^4.0.18"
59
64
  },
60
65
  "dependencies": {
61
- "@canonical/task": "^0.32.0",
62
- "@canonical/utils": "^0.32.0",
66
+ "@canonical/task": "^0.34.0",
67
+ "@canonical/utils": "^0.34.0",
63
68
  "chalk": "^5.6.2",
64
69
  "ejs": "^5.0.0",
65
70
  "ink": "^6.8.0",
@@ -67,5 +72,5 @@
67
72
  "ink-text-input": "^6.0.0",
68
73
  "react": "^19.2.4"
69
74
  },
70
- "gitHead": "5b279d8150e3988c68c6c2a741046bcd425624ca"
75
+ "gitHead": "e8d25fecbe6e70edfc4cb300bad65f691dbbd26e"
71
76
  }
@@ -0,0 +1,122 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://canonical.com/schemas/summon/generator-definition.v1.schema.json",
4
+ "$comment": "Owner ruling (2026-07-31), verbatim: the shared contract is not the generator definition (which arguably belongs in summon) — it is the general command types seam and the compositional logic. So THIS file is summon's own DOMAIN spec: what a generator is, in summon's terms, versioned so a change to it is visible. It does not describe, and must not be taken to describe, the contract between a CLI kernel and its commands; extracting that seam is a separate program with its own ADR. v1 is the shape summon-core ships today. A backwards-incompatible change gets a v2 file beside this one, not an edit here.",
5
+ "title": "Summon generator definition (v1)",
6
+ "description": "The DECLARATIVE projection of a GeneratorDefinition — the parts expressible as data. `generate`, and a prompt's `when`/`validate`, are functions carried by the module and cannot appear in JSON; they are documented here as code-carried so that a reader of this schema is not misled into thinking a JSON document alone is a generator.",
7
+ "type": "object",
8
+ "required": ["meta", "prompts"],
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "meta": { "$ref": "#/$defs/meta" },
12
+ "prompts": {
13
+ "description": "The questions whose answers `generate` receives, in ask order.",
14
+ "type": "array",
15
+ "items": { "$ref": "#/$defs/prompt" }
16
+ },
17
+ "generate": {
18
+ "$comment": "CODE-CARRIED, not data: a pure function `(answers) => Task<void>`. Present on every real generator; absent from any JSON projection of one.",
19
+ "description": "Declared here for completeness only — a JSON document cannot carry it.",
20
+ "type": "null"
21
+ }
22
+ },
23
+ "$defs": {
24
+ "meta": {
25
+ "title": "Generator metadata",
26
+ "description": "What discovery, help and the generated-file stamp read.",
27
+ "type": "object",
28
+ "required": ["name", "displayName", "description", "version"],
29
+ "additionalProperties": false,
30
+ "properties": {
31
+ "name": {
32
+ "description": "Generator name, used in the CLI path (e.g. `component/react`).",
33
+ "type": "string",
34
+ "minLength": 1
35
+ },
36
+ "displayName": {
37
+ "description": "The name written into generated-file stamp comments. Distinct from `name` when the stamp should not be the CLI path (e.g. `@canonical/summon-component:react`). Load-bearing for byte equality: two bins agree on a tree only if they agree on this.",
38
+ "type": "string",
39
+ "minLength": 1
40
+ },
41
+ "description": {
42
+ "description": "One-line description shown in generator listings.",
43
+ "type": "string"
44
+ },
45
+ "version": {
46
+ "description": "Semantic version of the generator. Also written into the stamp.",
47
+ "type": "string",
48
+ "minLength": 1
49
+ },
50
+ "author": {
51
+ "description": "Author name or email.",
52
+ "type": "string"
53
+ },
54
+ "help": {
55
+ "description": "Extended help text shown for `summon <topic>` and `--help`.",
56
+ "type": "string"
57
+ },
58
+ "examples": {
59
+ "description": "Usage examples shown in help; each one a common invocation.",
60
+ "type": "array",
61
+ "items": { "type": "string" }
62
+ }
63
+ }
64
+ },
65
+ "prompt": {
66
+ "title": "Prompt definition",
67
+ "description": "One question. Each prompt also becomes a CLI flag, kebab-cased from `name` (`componentPath` → `--component-path`).",
68
+ "type": "object",
69
+ "required": ["name", "message", "type"],
70
+ "additionalProperties": false,
71
+ "properties": {
72
+ "name": {
73
+ "description": "Unique identifier — the answer key and the flag name.",
74
+ "type": "string",
75
+ "minLength": 1
76
+ },
77
+ "message": {
78
+ "description": "Question text displayed to the user.",
79
+ "type": "string"
80
+ },
81
+ "type": {
82
+ "description": "Kind of input.",
83
+ "enum": ["text", "confirm", "select", "multiselect"]
84
+ },
85
+ "default": {
86
+ "$comment": "Unconstrained on purpose: the value's type follows `type` (string for text/select, boolean for confirm, array for multiselect), and pinning that here would duplicate a rule `validateAnswers` already owns."
87
+ },
88
+ "choices": {
89
+ "description": "Options for `select`/`multiselect` prompts.",
90
+ "type": "array",
91
+ "items": {
92
+ "type": "object",
93
+ "required": ["label", "value"],
94
+ "additionalProperties": false,
95
+ "properties": {
96
+ "label": { "type": "string" },
97
+ "value": { "type": "string" }
98
+ }
99
+ }
100
+ },
101
+ "when": {
102
+ "$comment": "CODE-CARRIED, not data: `(answers) => boolean`, evaluated against the answers collected so far.",
103
+ "description": "Declared here for completeness only — a JSON document cannot carry it.",
104
+ "type": "null"
105
+ },
106
+ "validate": {
107
+ "$comment": "CODE-CARRIED, not data: `(value) => boolean | string`, returning true or an error message.",
108
+ "description": "Declared here for completeness only — a JSON document cannot carry it.",
109
+ "type": "null"
110
+ },
111
+ "group": {
112
+ "description": "Group name for organizing options in `--help`. Ungrouped prompts appear under \"Options\".",
113
+ "type": "string"
114
+ },
115
+ "positional": {
116
+ "description": "Whether this prompt can be given as a positional argument. At most one per generator, and only a `text` prompt.",
117
+ "type": "boolean"
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }