@canonical/summon 0.1.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 (45) hide show
  1. package/README.md +439 -0
  2. package/generators/example/hello/index.ts +132 -0
  3. package/generators/example/hello/templates/README.md.ejs +20 -0
  4. package/generators/example/hello/templates/index.ts.ejs +9 -0
  5. package/generators/example/webapp/index.ts +509 -0
  6. package/generators/example/webapp/templates/ARCHITECTURE.md.ejs +180 -0
  7. package/generators/example/webapp/templates/App.tsx.ejs +86 -0
  8. package/generators/example/webapp/templates/README.md.ejs +154 -0
  9. package/generators/example/webapp/templates/app.test.ts.ejs +63 -0
  10. package/generators/example/webapp/templates/app.ts.ejs +132 -0
  11. package/generators/example/webapp/templates/feature.ts.ejs +264 -0
  12. package/generators/example/webapp/templates/index.html.ejs +20 -0
  13. package/generators/example/webapp/templates/main.tsx.ejs +43 -0
  14. package/generators/example/webapp/templates/styles.css.ejs +135 -0
  15. package/generators/init/index.ts +124 -0
  16. package/generators/init/templates/generator.ts.ejs +85 -0
  17. package/generators/init/templates/template-index.ts.ejs +9 -0
  18. package/generators/init/templates/template-test.ts.ejs +8 -0
  19. package/package.json +64 -0
  20. package/src/__tests__/combinators.test.ts +895 -0
  21. package/src/__tests__/dry-run.test.ts +927 -0
  22. package/src/__tests__/effect.test.ts +816 -0
  23. package/src/__tests__/interpreter.test.ts +673 -0
  24. package/src/__tests__/primitives.test.ts +970 -0
  25. package/src/__tests__/task.test.ts +929 -0
  26. package/src/__tests__/template.test.ts +666 -0
  27. package/src/cli-format.ts +165 -0
  28. package/src/cli-types.ts +53 -0
  29. package/src/cli.tsx +1322 -0
  30. package/src/combinators.ts +294 -0
  31. package/src/completion.ts +488 -0
  32. package/src/components/App.tsx +960 -0
  33. package/src/components/ExecutionProgress.tsx +205 -0
  34. package/src/components/FileTreePreview.tsx +97 -0
  35. package/src/components/PromptSequence.tsx +483 -0
  36. package/src/components/Spinner.tsx +36 -0
  37. package/src/components/index.ts +16 -0
  38. package/src/dry-run.ts +434 -0
  39. package/src/effect.ts +224 -0
  40. package/src/index.ts +266 -0
  41. package/src/interpreter.ts +463 -0
  42. package/src/primitives.ts +442 -0
  43. package/src/task.ts +245 -0
  44. package/src/template.ts +537 -0
  45. package/src/types.ts +453 -0
package/src/index.ts ADDED
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Summon - A Monadic Task-Centric Code Generator Framework
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ // =============================================================================
8
+ // Core Types
9
+ // =============================================================================
10
+
11
+ export type {
12
+ // Generator types
13
+ AnyGenerator,
14
+ ConfirmPrompt,
15
+ // Result types
16
+ DryRunResult,
17
+ Effect,
18
+ ExecResult,
19
+ GeneratorDefinition,
20
+ GeneratorMeta,
21
+ LogLevel,
22
+ MultiselectPrompt,
23
+ PromptDefinition,
24
+ // Prompt types
25
+ PromptQuestion,
26
+ PromptQuestionBase,
27
+ SelectPrompt,
28
+ // Task and Effect types
29
+ Task,
30
+ TaskError,
31
+ // Event types
32
+ TaskEvent,
33
+ TextPrompt,
34
+ TraceResult,
35
+ TraceSpan,
36
+ } from "./types.js";
37
+
38
+ // =============================================================================
39
+ // Task Monad
40
+ // =============================================================================
41
+
42
+ export {
43
+ ap,
44
+ effect,
45
+ fail,
46
+ failWith,
47
+ // Monad operations
48
+ flatMap,
49
+ hasEffects,
50
+ isFailed,
51
+ // Utilities
52
+ isPure,
53
+ map,
54
+ mapError,
55
+ of,
56
+ // Core constructors
57
+ pure,
58
+ recover,
59
+ // Fluent builder
60
+ TaskBuilder,
61
+ task,
62
+ } from "./task.js";
63
+
64
+ // =============================================================================
65
+ // Effects
66
+ // =============================================================================
67
+
68
+ export {
69
+ // File system effects
70
+ appendFileEffect,
71
+ copyDirectoryEffect,
72
+ copyFileEffect,
73
+ deleteDirectoryEffect,
74
+ deleteFileEffect,
75
+ // Utilities
76
+ describeEffect,
77
+ // Process effects
78
+ execEffect,
79
+ existsEffect,
80
+ getAffectedPaths,
81
+ globEffect,
82
+ isWriteEffect,
83
+ // Logging effects
84
+ logEffect,
85
+ makeDirEffect,
86
+ // Concurrency effects
87
+ parallelEffect,
88
+ // Prompt effects
89
+ promptEffect,
90
+ raceEffect,
91
+ // Context effects
92
+ readContextEffect,
93
+ readFileEffect,
94
+ writeContextEffect,
95
+ writeFileEffect,
96
+ } from "./effect.js";
97
+
98
+ // =============================================================================
99
+ // Primitives
100
+ // =============================================================================
101
+
102
+ export type { SortFileLinesOptions } from "./primitives.js";
103
+ export {
104
+ // File system primitives
105
+ appendFile,
106
+ copyDirectory,
107
+ copyFile,
108
+ debug,
109
+ deleteDirectory,
110
+ deleteFile,
111
+ error,
112
+ // Process primitives
113
+ exec,
114
+ execSimple,
115
+ exists,
116
+ // Context primitives
117
+ getContext,
118
+ glob,
119
+ info,
120
+ // Logging primitives
121
+ log,
122
+ mkdir,
123
+ // Pure primitives
124
+ noop,
125
+ // Prompt primitives
126
+ prompt,
127
+ promptConfirm,
128
+ promptMultiselect,
129
+ promptSelect,
130
+ promptText,
131
+ readFile,
132
+ setContext,
133
+ // File transformation primitives
134
+ sortFileLines,
135
+ succeed,
136
+ warn,
137
+ withContext,
138
+ writeFile,
139
+ } from "./primitives.js";
140
+
141
+ // =============================================================================
142
+ // Combinators
143
+ // =============================================================================
144
+
145
+ export {
146
+ attempt,
147
+ // Resource management
148
+ bracket,
149
+ delay,
150
+ ensure,
151
+ fold,
152
+ ifElse,
153
+ ifElseM,
154
+ optional,
155
+ orElse,
156
+ // Parallelism
157
+ parallel,
158
+ parallelN,
159
+ race,
160
+ // Error handling
161
+ retry,
162
+ retryWithBackoff,
163
+ // Sequencing
164
+ sequence,
165
+ sequence_,
166
+ // Utilities
167
+ tap,
168
+ tapError,
169
+ timeout,
170
+ traverse,
171
+ traverse_,
172
+ unless,
173
+ // Conditionals
174
+ when,
175
+ whenM,
176
+ zip,
177
+ zip3,
178
+ } from "./combinators.js";
179
+
180
+ // =============================================================================
181
+ // Interpreter
182
+ // =============================================================================
183
+
184
+ export type { RunTaskOptions, StampConfig } from "./interpreter.js";
185
+ export {
186
+ executeEffect,
187
+ run,
188
+ runTask,
189
+ TaskExecutionError,
190
+ } from "./interpreter.js";
191
+
192
+ // =============================================================================
193
+ // Dry-Run
194
+ // =============================================================================
195
+
196
+ export {
197
+ // Test utilities
198
+ assertEffects,
199
+ assertFileWrites,
200
+ collectEffects,
201
+ countEffects,
202
+ dryRun,
203
+ dryRunWith,
204
+ expectTask,
205
+ filterEffects,
206
+ getAffectedFiles,
207
+ getFileWrites,
208
+ mockEffect,
209
+ } from "./dry-run.js";
210
+
211
+ // =============================================================================
212
+ // Templates
213
+ // =============================================================================
214
+
215
+ export type {
216
+ StampOptions,
217
+ TemplateDirOptions,
218
+ TemplateOptions,
219
+ TemplatingEngine,
220
+ } from "./template.js";
221
+ export {
222
+ // Templating engine
223
+ ejsEngine,
224
+ // Stamp utilities
225
+ generateStamp,
226
+ // Metadata
227
+ generatorComment,
228
+ generatorHtmlComment,
229
+ prependStamp,
230
+ renderFile,
231
+ // Template rendering
232
+ renderString,
233
+ renderStringAsync,
234
+ // Template tasks
235
+ template,
236
+ templateDir,
237
+ // Helpers
238
+ templateHelpers,
239
+ withHelpers,
240
+ } from "./template.js";
241
+
242
+ // =============================================================================
243
+ // Components (for custom CLI implementations)
244
+ // =============================================================================
245
+
246
+ export type {
247
+ AppProps,
248
+ AppState,
249
+ ExecutionProgressProps,
250
+ FileTreePreviewProps,
251
+ PromptSequenceProps,
252
+ SpinnerProps,
253
+ } from "./components/index.js";
254
+ export {
255
+ App,
256
+ ExecutionProgress,
257
+ FileTreePreview,
258
+ PromptSequence,
259
+ Spinner,
260
+ } from "./components/index.js";
261
+
262
+ // =============================================================================
263
+ // CLI Types (for generator authors)
264
+ // =============================================================================
265
+
266
+ export type { ForbidReserved, ReservedOption } from "./cli-types.js";