@canonical/summon-core 0.33.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) 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 +23 -17
  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 +199 -53
  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 +19 -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/mount.js +4 -2
  52. package/dist/esm/prompt/ink/mount.js.map +1 -1
  53. package/dist/esm/prompt/ink/session.js +78 -15
  54. package/dist/esm/prompt/ink/session.js.map +1 -1
  55. package/dist/esm/prompt/inkPrompt.js +13 -4
  56. package/dist/esm/prompt/inkPrompt.js.map +1 -1
  57. package/dist/esm/prompt/mcpPrompt.js +1 -1
  58. package/dist/esm/prompt/mcpPrompt.js.map +1 -1
  59. package/dist/esm/run/runGeneratorTask.js +3 -1
  60. package/dist/esm/run/runGeneratorTask.js.map +1 -1
  61. package/dist/esm/stamp/applyStamp.js +50 -52
  62. package/dist/esm/stamp/applyStamp.js.map +1 -1
  63. package/dist/esm/stamp/createStampOnEffectStart.js +4 -1
  64. package/dist/esm/stamp/createStampOnEffectStart.js.map +1 -1
  65. package/dist/esm/stamp/runTaskWithStamp.js +8 -9
  66. package/dist/esm/stamp/runTaskWithStamp.js.map +1 -1
  67. package/dist/esm/template/index.js +2 -0
  68. package/dist/esm/template/index.js.map +1 -1
  69. package/dist/esm/template/loadTemplate.js +43 -0
  70. package/dist/esm/template/loadTemplate.js.map +1 -0
  71. package/dist/esm/template/prependStamp.js +11 -8
  72. package/dist/esm/template/prependStamp.js.map +1 -1
  73. package/dist/esm/template/rawFile.js +25 -0
  74. package/dist/esm/template/rawFile.js.map +1 -0
  75. package/dist/esm/template/tasks/template.js +12 -3
  76. package/dist/esm/template/tasks/template.js.map +1 -1
  77. package/dist/esm/template/tasks/templateDir.js +5 -0
  78. package/dist/esm/template/tasks/templateDir.js.map +1 -1
  79. package/dist/esm/testing/conformance/diffTrees.js +61 -0
  80. package/dist/esm/testing/conformance/diffTrees.js.map +1 -0
  81. package/dist/esm/testing/conformance/fixtures.js +81 -0
  82. package/dist/esm/testing/conformance/fixtures.js.map +1 -0
  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 +18 -0
  86. package/dist/esm/testing/conformance/index.js.map +1 -0
  87. package/dist/esm/testing/conformance/produceReference.js +47 -0
  88. package/dist/esm/testing/conformance/produceReference.js.map +1 -0
  89. package/dist/esm/testing/conformance/snapshotTree.js +35 -0
  90. package/dist/esm/testing/conformance/snapshotTree.js.map +1 -0
  91. package/dist/esm/testing/index.js +10 -0
  92. package/dist/esm/testing/index.js.map +1 -0
  93. package/dist/types/discovery/discoverGeneratorTree.d.ts +3 -3
  94. package/dist/types/discovery/discoverGeneratorTree.d.ts.map +1 -1
  95. package/dist/types/execute/collectAnswers.d.ts +6 -4
  96. package/dist/types/execute/collectAnswers.d.ts.map +1 -1
  97. package/dist/types/execute/execute.d.ts +27 -1
  98. package/dist/types/execute/execute.d.ts.map +1 -1
  99. package/dist/types/execute/index.d.ts +1 -1
  100. package/dist/types/execute/index.d.ts.map +1 -1
  101. package/dist/types/execute/validateAnswers.d.ts.map +1 -1
  102. package/dist/types/format/effects.d.ts +63 -9
  103. package/dist/types/format/effects.d.ts.map +1 -1
  104. package/dist/types/format/formatFlagName.d.ts +14 -0
  105. package/dist/types/format/formatFlagName.d.ts.map +1 -0
  106. package/dist/types/format/index.d.ts +20 -1
  107. package/dist/types/format/index.d.ts.map +1 -1
  108. package/dist/types/index.d.ts +4 -4
  109. package/dist/types/index.d.ts.map +1 -1
  110. package/dist/types/projection/answers.d.ts +54 -0
  111. package/dist/types/projection/answers.d.ts.map +1 -0
  112. package/dist/types/projection/buildOptionInfo.d.ts +25 -0
  113. package/dist/types/projection/buildOptionInfo.d.ts.map +1 -0
  114. package/dist/types/projection/commander/configureGroupedHelp.d.ts +29 -0
  115. package/dist/types/projection/commander/configureGroupedHelp.d.ts.map +1 -0
  116. package/dist/types/projection/commander/emitToProcess.d.ts +10 -0
  117. package/dist/types/projection/commander/emitToProcess.d.ts.map +1 -0
  118. package/dist/types/projection/commander/index.d.ts +21 -0
  119. package/dist/types/projection/commander/index.d.ts.map +1 -0
  120. package/dist/types/projection/commander/registerGeneratorCommands.d.ts +95 -0
  121. package/dist/types/projection/commander/registerGeneratorCommands.d.ts.map +1 -0
  122. package/dist/types/projection/decideInteraction.d.ts +70 -0
  123. package/dist/types/projection/decideInteraction.d.ts.map +1 -0
  124. package/dist/types/projection/extractAnswers.d.ts +23 -0
  125. package/dist/types/projection/extractAnswers.d.ts.map +1 -0
  126. package/dist/types/projection/groupedHelp.d.ts +25 -0
  127. package/dist/types/projection/groupedHelp.d.ts.map +1 -0
  128. package/dist/types/projection/index.d.ts +29 -0
  129. package/dist/types/projection/index.d.ts.map +1 -0
  130. package/dist/types/projection/kebab.d.ts +16 -0
  131. package/dist/types/projection/kebab.d.ts.map +1 -0
  132. package/dist/types/projection/projectGenerator.d.ts +22 -0
  133. package/dist/types/projection/projectGenerator.d.ts.map +1 -0
  134. package/dist/types/projection/types.d.ts +118 -0
  135. package/dist/types/projection/types.d.ts.map +1 -0
  136. package/dist/types/projection/usage.d.ts +92 -0
  137. package/dist/types/projection/usage.d.ts.map +1 -0
  138. package/dist/types/prompt/answerPromptWithDefaults.d.ts +5 -3
  139. package/dist/types/prompt/answerPromptWithDefaults.d.ts.map +1 -1
  140. package/dist/types/prompt/autoPrompt.d.ts.map +1 -1
  141. package/dist/types/prompt/ink/mount.d.ts.map +1 -1
  142. package/dist/types/prompt/ink/session.d.ts +36 -1
  143. package/dist/types/prompt/ink/session.d.ts.map +1 -1
  144. package/dist/types/prompt/inkPrompt.d.ts +17 -3
  145. package/dist/types/prompt/inkPrompt.d.ts.map +1 -1
  146. package/dist/types/run/runGeneratorTask.d.ts +3 -1
  147. package/dist/types/run/runGeneratorTask.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/diffTrees.d.ts +38 -0
  167. package/dist/types/testing/conformance/diffTrees.d.ts.map +1 -0
  168. package/dist/types/testing/conformance/fixtures.d.ts +39 -0
  169. package/dist/types/testing/conformance/fixtures.d.ts.map +1 -0
  170. package/dist/types/testing/conformance/flagizeAnswers.d.ts +38 -0
  171. package/dist/types/testing/conformance/flagizeAnswers.d.ts.map +1 -0
  172. package/dist/types/testing/conformance/index.d.ts +22 -0
  173. package/dist/types/testing/conformance/index.d.ts.map +1 -0
  174. package/dist/types/testing/conformance/produceReference.d.ts +35 -0
  175. package/dist/types/testing/conformance/produceReference.d.ts.map +1 -0
  176. package/dist/types/testing/conformance/snapshotTree.d.ts +21 -0
  177. package/dist/types/testing/conformance/snapshotTree.d.ts.map +1 -0
  178. package/dist/types/testing/index.d.ts +11 -0
  179. package/dist/types/testing/index.d.ts.map +1 -0
  180. package/dist/types/types/GeneratorDefinition.d.ts +10 -1
  181. package/dist/types/types/GeneratorDefinition.d.ts.map +1 -1
  182. package/dist/types/types/ReservedOption.d.ts +1 -1
  183. package/dist/types/types/ReservedOption.d.ts.map +1 -1
  184. package/package.json +27 -9
  185. package/spec/generator-definition.v1.schema.json +122 -0
@@ -0,0 +1,22 @@
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 { flagizeAnswers } from "./flagizeAnswers.js";
18
+ export type { ReferenceRun } from "./produceReference.js";
19
+ export { produceReference } from "./produceReference.js";
20
+ export type { TreeSnapshot } from "./snapshotTree.js";
21
+ export { snapshotTree } from "./snapshotTree.js";
22
+ //# 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,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,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, flagizeAnswers, 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,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,wBAAwB,CAAC"}
@@ -11,7 +11,16 @@ export default interface GeneratorDefinition<TAnswers = Record<string, unknown>>
11
11
  meta: GeneratorMeta;
12
12
  /** Prompts to collect answers from user */
13
13
  prompts: PromptDefinition[];
14
- /** Pure function that returns a Task describing the generation */
14
+ /**
15
+ * Pure function that returns a Task describing the generation.
16
+ *
17
+ * The returned task must be RE-INTERPRETABLE: compose it from combinators
18
+ * (`sequence_`, `when`, `flatMap`, …), never from a single-use `gen()` —
19
+ * a gen() task closes over one iterator, and the runners interpret a build
20
+ * more than once (dry-run preview, undo collection with backtracking).
21
+ * `execute()` shields callers by invoking `generate` freshly per
22
+ * interpretation, but direct drivers of one build get truncated re-drives.
23
+ */
15
24
  generate: (answers: TAnswers) => Task<void>;
16
25
  }
17
26
  //# sourceMappingURL=GeneratorDefinition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GeneratorDefinition.d.ts","sourceRoot":"","sources":["../../../src/types/GeneratorDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,OAAO,WAAW,mBAAmB,CAC1C,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAElC,yCAAyC;IACzC,IAAI,EAAE,aAAa,CAAC;IACpB,2CAA2C;IAC3C,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;CAC7C"}
1
+ {"version":3,"file":"GeneratorDefinition.d.ts","sourceRoot":"","sources":["../../../src/types/GeneratorDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,OAAO,WAAW,mBAAmB,CAC1C,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAElC,yCAAyC;IACzC,IAAI,EAAE,aAAa,CAAC;IACpB,2CAA2C;IAC3C,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B;;;;;;;;;OASG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;CAC7C"}
@@ -2,6 +2,6 @@
2
2
  * Reserved option names for CLI global options.
3
3
  * Generator prompts MUST NOT use these names.
4
4
  */
5
- type ReservedOption = "help" | "version" | "dryRun" | "dry-run" | "yes" | "output" | "preview" | "generators" | "run" | "init" | "llm" | "format" | "showFiles" | "show-files" | "verbose" | "generatedStamp";
5
+ type ReservedOption = "help" | "version" | "dryRun" | "dry-run" | "yes" | "output" | "preview" | "generators" | "run" | "init" | "llm" | "format" | "showFiles" | "show-files" | "verbose" | "generatedStamp" | "generated-stamp";
6
6
  export type { ReservedOption as default };
7
7
  //# sourceMappingURL=ReservedOption.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReservedOption.d.ts","sourceRoot":"","sources":["../../../src/types/ReservedOption.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,KAAK,cAAc,GACf,MAAM,GACN,SAAS,GACT,QAAQ,GACR,SAAS,GACT,KAAK,GACL,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,KAAK,GACL,MAAM,GACN,KAAK,GACL,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,SAAS,GACT,gBAAgB,CAAC;AAErB,YAAY,EAAE,cAAc,IAAI,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"ReservedOption.d.ts","sourceRoot":"","sources":["../../../src/types/ReservedOption.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,KAAK,cAAc,GACf,MAAM,GACN,SAAS,GACT,QAAQ,GACR,SAAS,GACT,KAAK,GACL,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,KAAK,GACL,MAAM,GACN,KAAK,GACL,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,SAAS,GACT,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB,YAAY,EAAE,cAAc,IAAI,OAAO,EAAE,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.33.0",
4
+ "version": "0.35.0",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -9,10 +9,27 @@
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"
16
+ },
17
+ "./format": {
18
+ "types": "./dist/types/format/index.d.ts",
19
+ "import": "./dist/esm/format/index.js"
20
+ },
21
+ "./projection": {
22
+ "types": "./dist/types/projection/index.d.ts",
23
+ "import": "./dist/esm/projection/index.js"
24
+ },
25
+ "./projection/commander": {
26
+ "types": "./dist/types/projection/commander/index.d.ts",
27
+ "import": "./dist/esm/projection/commander/index.js"
12
28
  }
13
29
  },
14
30
  "files": [
15
- "dist"
31
+ "dist",
32
+ "spec"
16
33
  ],
17
34
  "author": {
18
35
  "email": "webteam@canonical.com",
@@ -46,26 +63,27 @@
46
63
  },
47
64
  "devDependencies": {
48
65
  "@biomejs/biome": "2.4.9",
49
- "@canonical/biome-config": "^0.33.0",
50
- "@canonical/typescript-config": "^0.33.0",
51
- "@canonical/webarchitect": "^0.33.0",
66
+ "@canonical/biome-config": "^0.35.0",
67
+ "@canonical/typescript-config": "^0.35.0",
68
+ "@canonical/webarchitect": "^0.35.0",
52
69
  "@types/bun": "^1.3.10",
53
70
  "@types/ejs": "^3.1.5",
54
- "@types/node": "^24.12.0",
71
+ "@types/node": "^26.0.0",
55
72
  "@types/react": "^19.2.14",
56
73
  "ink-testing-library": "^4.0.0",
57
74
  "typescript": "^5.9.3",
58
75
  "vitest": "^4.0.18"
59
76
  },
60
77
  "dependencies": {
61
- "@canonical/task": "^0.33.0",
62
- "@canonical/utils": "^0.33.0",
78
+ "@canonical/task": "^0.35.0",
79
+ "@canonical/utils": "^0.35.0",
63
80
  "chalk": "^5.6.2",
81
+ "commander": "^14.0.3",
64
82
  "ejs": "^5.0.0",
65
83
  "ink": "^6.8.0",
66
84
  "ink-select-input": "^6.2.0",
67
85
  "ink-text-input": "^6.0.0",
68
86
  "react": "^19.2.4"
69
87
  },
70
- "gitHead": "fca2bc4440fff2d511fc8db6686f9b19222fdbc7"
88
+ "gitHead": "5198c5399ef657959272c0e35924391573d81146"
71
89
  }
@@ -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
+ }