@hydranium/cli 1.0.0-next.31 → 1.0.0-next.312

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 (252) hide show
  1. package/README.md +79 -205
  2. package/bin/hydranium-cli.js +13 -0
  3. package/heap-analysis/heap/core/load.mjs +2 -2
  4. package/lib/cli-version.js.map +1 -1
  5. package/lib/cli.js +7 -2
  6. package/lib/cli.js.map +1 -1
  7. package/lib/commands/analyze-heap-args.js.map +1 -1
  8. package/lib/commands/analyze-heap.d.ts +3 -0
  9. package/lib/commands/analyze-heap.d.ts.map +1 -1
  10. package/lib/commands/analyze-heap.js +2 -1
  11. package/lib/commands/analyze-heap.js.map +1 -1
  12. package/lib/commands/ast-ground-truth-args.d.ts +3 -2
  13. package/lib/commands/ast-ground-truth-args.d.ts.map +1 -1
  14. package/lib/commands/ast-ground-truth-args.js +11 -9
  15. package/lib/commands/ast-ground-truth-args.js.map +1 -1
  16. package/lib/commands/ast-ground-truth-driver.js +2 -1
  17. package/lib/commands/ast-ground-truth-driver.js.map +1 -1
  18. package/lib/commands/ast-ground-truth.js +1 -1
  19. package/lib/commands/ast-ground-truth.js.map +1 -1
  20. package/lib/commands/client-session.d.ts +17 -0
  21. package/lib/commands/client-session.d.ts.map +1 -0
  22. package/lib/commands/client-session.js +27 -0
  23. package/lib/commands/client-session.js.map +1 -0
  24. package/lib/commands/create-args.d.ts +17 -0
  25. package/lib/commands/create-args.d.ts.map +1 -0
  26. package/lib/commands/create-args.js +53 -0
  27. package/lib/commands/create-args.js.map +1 -0
  28. package/lib/commands/create.d.ts +38 -0
  29. package/lib/commands/create.d.ts.map +1 -0
  30. package/lib/commands/create.js +43 -0
  31. package/lib/commands/create.js.map +1 -0
  32. package/lib/commands/delete-args.d.ts +17 -0
  33. package/lib/commands/delete-args.d.ts.map +1 -0
  34. package/lib/commands/delete-args.js +49 -0
  35. package/lib/commands/delete-args.js.map +1 -0
  36. package/lib/commands/delete.d.ts +30 -0
  37. package/lib/commands/delete.d.ts.map +1 -0
  38. package/lib/commands/delete.js +32 -0
  39. package/lib/commands/delete.js.map +1 -0
  40. package/lib/commands/generate-languages.d.ts +35 -0
  41. package/lib/commands/generate-languages.d.ts.map +1 -0
  42. package/lib/commands/generate-languages.js +105 -0
  43. package/lib/commands/generate-languages.js.map +1 -0
  44. package/lib/commands/generate-transfer-model-args.d.ts.map +1 -1
  45. package/lib/commands/generate-transfer-model-args.js +7 -0
  46. package/lib/commands/generate-transfer-model-args.js.map +1 -1
  47. package/lib/commands/generate-transfer-model-config.d.ts.map +1 -1
  48. package/lib/commands/generate-transfer-model-config.js +6 -3
  49. package/lib/commands/generate-transfer-model-config.js.map +1 -1
  50. package/lib/commands/generate-transfer-model.d.ts +15 -1
  51. package/lib/commands/generate-transfer-model.d.ts.map +1 -1
  52. package/lib/commands/generate-transfer-model.js +46 -8
  53. package/lib/commands/generate-transfer-model.js.map +1 -1
  54. package/lib/commands/harness-args.d.ts +44 -42
  55. package/lib/commands/harness-args.d.ts.map +1 -1
  56. package/lib/commands/harness-args.js +109 -27
  57. package/lib/commands/harness-args.js.map +1 -1
  58. package/lib/commands/headless-harness.d.ts +37 -20
  59. package/lib/commands/headless-harness.d.ts.map +1 -1
  60. package/lib/commands/headless-harness.js +68 -17
  61. package/lib/commands/headless-harness.js.map +1 -1
  62. package/lib/commands/init-args.d.ts.map +1 -1
  63. package/lib/commands/init-args.js +32 -27
  64. package/lib/commands/init-args.js.map +1 -1
  65. package/lib/commands/init-prompt.d.ts +3 -3
  66. package/lib/commands/init-prompt.d.ts.map +1 -1
  67. package/lib/commands/init-prompt.js +4 -5
  68. package/lib/commands/init-prompt.js.map +1 -1
  69. package/lib/commands/init-templates.d.ts +18 -14
  70. package/lib/commands/init-templates.d.ts.map +1 -1
  71. package/lib/commands/init-templates.js +732 -677
  72. package/lib/commands/init-templates.js.map +1 -1
  73. package/lib/commands/init-wizard.d.ts.map +1 -1
  74. package/lib/commands/init-wizard.js +17 -27
  75. package/lib/commands/init-wizard.js.map +1 -1
  76. package/lib/commands/init-workspace.d.ts +13 -11
  77. package/lib/commands/init-workspace.d.ts.map +1 -1
  78. package/lib/commands/init-workspace.js +21 -7
  79. package/lib/commands/init-workspace.js.map +1 -1
  80. package/lib/commands/init.d.ts +45 -19
  81. package/lib/commands/init.d.ts.map +1 -1
  82. package/lib/commands/init.js +80 -43
  83. package/lib/commands/init.js.map +1 -1
  84. package/lib/commands/kebab.d.ts +15 -0
  85. package/lib/commands/kebab.d.ts.map +1 -0
  86. package/lib/commands/kebab.js +17 -0
  87. package/lib/commands/kebab.js.map +1 -0
  88. package/lib/commands/lint-grammar-args.d.ts +3 -2
  89. package/lib/commands/lint-grammar-args.d.ts.map +1 -1
  90. package/lib/commands/lint-grammar-args.js +13 -10
  91. package/lib/commands/lint-grammar-args.js.map +1 -1
  92. package/lib/commands/lint-grammar-driver.js +2 -1
  93. package/lib/commands/lint-grammar-driver.js.map +1 -1
  94. package/lib/commands/lint-grammar-report.js.map +1 -1
  95. package/lib/commands/lint-grammar.js +1 -1
  96. package/lib/commands/lint-grammar.js.map +1 -1
  97. package/lib/commands/measure-memory-args.d.ts +3 -2
  98. package/lib/commands/measure-memory-args.d.ts.map +1 -1
  99. package/lib/commands/measure-memory-args.js +22 -11
  100. package/lib/commands/measure-memory-args.js.map +1 -1
  101. package/lib/commands/measure-memory-driver.js +5 -3
  102. package/lib/commands/measure-memory-driver.js.map +1 -1
  103. package/lib/commands/measure-memory.js +1 -1
  104. package/lib/commands/measure-memory.js.map +1 -1
  105. package/lib/commands/model-docs-args.d.ts +4 -3
  106. package/lib/commands/model-docs-args.d.ts.map +1 -1
  107. package/lib/commands/model-docs-args.js +12 -10
  108. package/lib/commands/model-docs-args.js.map +1 -1
  109. package/lib/commands/model-docs-driver.js +2 -1
  110. package/lib/commands/model-docs-driver.js.map +1 -1
  111. package/lib/commands/model-docs.js +1 -1
  112. package/lib/commands/model-docs.js.map +1 -1
  113. package/lib/commands/projects-args.d.ts.map +1 -1
  114. package/lib/commands/projects-args.js +5 -5
  115. package/lib/commands/projects-args.js.map +1 -1
  116. package/lib/commands/projects.d.ts +3 -4
  117. package/lib/commands/projects.d.ts.map +1 -1
  118. package/lib/commands/projects.js +2 -2
  119. package/lib/commands/projects.js.map +1 -1
  120. package/lib/commands/query-args.d.ts.map +1 -1
  121. package/lib/commands/query-args.js +5 -5
  122. package/lib/commands/query-args.js.map +1 -1
  123. package/lib/commands/query.d.ts +3 -4
  124. package/lib/commands/query.d.ts.map +1 -1
  125. package/lib/commands/query.js +2 -2
  126. package/lib/commands/query.js.map +1 -1
  127. package/lib/commands/reflect-args.d.ts +3 -2
  128. package/lib/commands/reflect-args.d.ts.map +1 -1
  129. package/lib/commands/reflect-args.js +13 -10
  130. package/lib/commands/reflect-args.js.map +1 -1
  131. package/lib/commands/reflect-driver.js +2 -1
  132. package/lib/commands/reflect-driver.js.map +1 -1
  133. package/lib/commands/reflect-report.js.map +1 -1
  134. package/lib/commands/reflect.js +1 -1
  135. package/lib/commands/reflect.js.map +1 -1
  136. package/lib/commands/save-args.d.ts.map +1 -1
  137. package/lib/commands/save-args.js +7 -4
  138. package/lib/commands/save-args.js.map +1 -1
  139. package/lib/commands/save.d.ts +8 -4
  140. package/lib/commands/save.d.ts.map +1 -1
  141. package/lib/commands/save.js +12 -23
  142. package/lib/commands/save.js.map +1 -1
  143. package/lib/commands/validate-args.d.ts +3 -2
  144. package/lib/commands/validate-args.d.ts.map +1 -1
  145. package/lib/commands/validate-args.js +13 -10
  146. package/lib/commands/validate-args.js.map +1 -1
  147. package/lib/commands/validate-driver.js +2 -1
  148. package/lib/commands/validate-driver.js.map +1 -1
  149. package/lib/commands/validate-report.js.map +1 -1
  150. package/lib/commands/validate.js +1 -1
  151. package/lib/commands/validate.js.map +1 -1
  152. package/lib/commands/watch-args.d.ts.map +1 -1
  153. package/lib/commands/watch-args.js +6 -4
  154. package/lib/commands/watch-args.js.map +1 -1
  155. package/lib/commands/watch.d.ts +3 -4
  156. package/lib/commands/watch.d.ts.map +1 -1
  157. package/lib/commands/watch.js +20 -2
  158. package/lib/commands/watch.js.map +1 -1
  159. package/lib/driver-heap.d.ts +52 -0
  160. package/lib/driver-heap.d.ts.map +1 -0
  161. package/lib/driver-heap.js +51 -0
  162. package/lib/driver-heap.js.map +1 -0
  163. package/lib/index.d.ts +2 -0
  164. package/lib/index.d.ts.map +1 -1
  165. package/lib/index.js +2 -0
  166. package/lib/index.js.map +1 -1
  167. package/lib/log-level.d.ts +21 -11
  168. package/lib/log-level.d.ts.map +1 -1
  169. package/lib/log-level.js +25 -14
  170. package/lib/log-level.js.map +1 -1
  171. package/lib/spawn-data-server.d.ts +9 -4
  172. package/lib/spawn-data-server.d.ts.map +1 -1
  173. package/lib/spawn-data-server.js +5 -4
  174. package/lib/spawn-data-server.js.map +1 -1
  175. package/lib/stderr-connection-logger.d.ts +12 -0
  176. package/lib/stderr-connection-logger.d.ts.map +1 -0
  177. package/lib/stderr-connection-logger.js +16 -0
  178. package/lib/stderr-connection-logger.js.map +1 -0
  179. package/lib/testing/echo-server.js +9 -1
  180. package/lib/testing/echo-server.js.map +1 -1
  181. package/package.json +52 -39
  182. package/src/cli.ts +7 -2
  183. package/src/commands/analyze-heap.ts +4 -1
  184. package/src/commands/ast-ground-truth-args.ts +15 -12
  185. package/src/commands/ast-ground-truth-driver.ts +2 -1
  186. package/src/commands/ast-ground-truth.ts +1 -1
  187. package/src/commands/client-session.ts +33 -0
  188. package/src/commands/create-args.ts +68 -0
  189. package/src/commands/create.ts +83 -0
  190. package/src/commands/delete-args.ts +64 -0
  191. package/src/commands/delete.ts +61 -0
  192. package/src/commands/generate-languages.ts +132 -0
  193. package/src/commands/generate-transfer-model-args.ts +7 -0
  194. package/src/commands/generate-transfer-model-config.ts +6 -3
  195. package/src/commands/generate-transfer-model.ts +56 -8
  196. package/src/commands/harness-args.ts +99 -31
  197. package/src/commands/headless-harness.ts +86 -26
  198. package/src/commands/init-args.ts +32 -27
  199. package/src/commands/init-prompt.ts +5 -6
  200. package/src/commands/init-templates.ts +790 -696
  201. package/src/commands/init-wizard.ts +17 -27
  202. package/src/commands/init-workspace.ts +31 -16
  203. package/src/commands/init.ts +126 -58
  204. package/src/commands/kebab.ts +17 -0
  205. package/src/commands/lint-grammar-args.ts +17 -13
  206. package/src/commands/lint-grammar-driver.ts +2 -1
  207. package/src/commands/lint-grammar.ts +1 -1
  208. package/src/commands/measure-memory-args.ts +27 -14
  209. package/src/commands/measure-memory-driver.ts +5 -3
  210. package/src/commands/measure-memory.ts +1 -1
  211. package/src/commands/model-docs-args.ts +16 -13
  212. package/src/commands/model-docs-driver.ts +2 -1
  213. package/src/commands/model-docs.ts +1 -1
  214. package/src/commands/projects-args.ts +5 -4
  215. package/src/commands/projects.ts +4 -6
  216. package/src/commands/query-args.ts +5 -4
  217. package/src/commands/query.ts +4 -6
  218. package/src/commands/reflect-args.ts +17 -13
  219. package/src/commands/reflect-driver.ts +2 -1
  220. package/src/commands/reflect.ts +1 -1
  221. package/src/commands/save-args.ts +7 -3
  222. package/src/commands/save.ts +24 -27
  223. package/src/commands/validate-args.ts +17 -13
  224. package/src/commands/validate-driver.ts +2 -1
  225. package/src/commands/validate.ts +1 -1
  226. package/src/commands/watch-args.ts +6 -3
  227. package/src/commands/watch.ts +28 -7
  228. package/src/driver-heap.ts +65 -0
  229. package/src/index.ts +2 -0
  230. package/src/log-level.ts +42 -14
  231. package/src/spawn-data-server.ts +17 -5
  232. package/src/stderr-connection-logger.ts +18 -0
  233. package/src/testing/echo-server.ts +11 -2
  234. package/templates/gitignore +1 -0
  235. package/templates/protocol/gitignore +3 -0
  236. package/templates/protocol/src/__GRAMMAR_ID__-diagram-types.ts +41 -0
  237. package/templates/server/gitignore +6 -0
  238. package/templates/server/src/glsp/__GRAMMAR_ID__/create-node-operation-handler.ts +62 -0
  239. package/templates/server/src/glsp/__GRAMMAR_ID__/gmodel-factory.ts +60 -0
  240. package/templates/server/src/glsp/__GRAMMAR_ID__/state.ts +18 -0
  241. package/templates/server/src/glsp/__GRAMMAR_ID__/storage.ts +16 -0
  242. package/templates/server/src/glsp/__GRAMMAR_ID__/submission-handler.ts +24 -0
  243. package/templates/server/src/grammar/common.langium +12 -0
  244. package/templates/server/src/language-server/__GRAMMAR_ID__-serializer.ts +53 -0
  245. package/templates/server/src/language-server/ast.ts +23 -0
  246. package/templates/server/src/node/services.ts +16 -0
  247. package/templates/server/test/__GRAMMAR_ID__-diagram.test.ts +112 -0
  248. package/templates/server/test/tsconfig.json +4 -0
  249. package/templates/server/tsconfig.test.json +10 -0
  250. package/templates/server/vitest.config.ts +14 -0
  251. package/templates/workspace/nodes.__EXTENSION__ +5 -0
  252. package/templates/workspace/references.__EXTENSION__ +2 -0
@@ -137,8 +137,8 @@ export function parseInitArgs(args: string[], onError: UsageError = exitWithUsag
137
137
  scoped().diagram = true;
138
138
  break;
139
139
  case '--heads': {
140
- // Validated in `resolveInitComposition`, which owns the rule that
141
- // `lsp` is mandatory; the cast only gets the strings that far.
140
+ // Validated in `resolveInitComposition`; the cast only gets the
141
+ // strings that far.
142
142
  heads = next().split(',') as InitHead[];
143
143
  break;
144
144
  }
@@ -185,41 +185,46 @@ export const INIT_HELP: readonly string[] = [
185
185
  ' ( --grammar <Name> [--extensions <list>]',
186
186
  ' [--language-id <id>] [--diagram] )...',
187
187
  '',
188
- 'Scaffold a new Hydranium language project end-to-end: a starter grammar per',
189
- '--grammar, the `create<Name>Services` DI wiring, an LSP + data-server launch,',
190
- 'langium-config, package.json, and build scripts. Does NOT run `npm install` or',
191
- '`langium generate` — those are printed as next steps. Refuses a non-empty',
192
- 'directory without --force.',
188
+ 'Scaffold a new Hydranium language project end-to-end: two packages and a',
189
+ 'starter workspace, each in its own directory. server/ holds a starter grammar',
190
+ 'per --grammar, the `create<Name>Services` DI wiring, a launch of every head',
191
+ 'and build scripts; protocol/ holds what the server and its clients both',
192
+ 'import; workspace/ holds two starter model files per grammar. A standalone',
193
+ 'project also gets a root manifest naming the two packages as npm workspaces.',
194
+ 'Does NOT run `npm install` or `langium generate` — those are printed as next',
195
+ 'steps. Refuses a non-empty directory without --force.',
193
196
  '',
194
197
  'Run it with no --name on a terminal to be prompted instead. The wizard echoes',
195
198
  'the command it composed before running it, so every answer is reproducible as',
196
199
  'flags. Without a terminal a missing --name stays an error, so CI never hangs.',
197
200
  '',
198
201
  'Project options (position-free):',
199
- ' <target-dir> Directory to scaffold into (required).',
202
+ ' <target-dir> The project directory to scaffold into (required).',
200
203
  ' --name <Name> PascalCase PROJECT name; drives the services and the',
201
204
  ' Langium projectName, i.e. the shared generated symbols',
202
205
  ' (<Name>AstReflection, <Name>GeneratedSharedModule) (required).',
203
- ' --heads <list> Comma-separated protocol heads: lsp, data, glsp.',
204
- ' `lsp` is mandatory — it owns the workspace, the build',
205
- ' pipeline and the shared tier the others read through.',
206
- ' The emitted dependencies, main.ts and module bindings',
207
- ' all follow this set. Default: lsp,data.',
206
+ ' --heads <list> Comma-separated protocol heads: lsp, data, glsp, any',
207
+ ' non-empty set. Without lsp, main.ts serves the socket',
208
+ ' heads from a workspace path it is given and prints',
209
+ ' their ports. The emitted dependencies, main.ts and',
210
+ ' module bindings all follow this set. Default: lsp,data.',
208
211
  ' --force Scaffold into a non-empty directory anyway.',
209
- ' --monorepo Scaffold a member of the surrounding npm workspace:',
210
- ' tsconfig extends the root config that actually carries',
211
- ' compilerOptions, .gitignore is left to the root, and the',
212
- ' scripts address the package by --prefix. Errors when no',
213
- ' ancestor declares `workspaces`. Never writes outside the',
214
- ' target — the root `workspaces` entry is printed, not added.',
215
- ' --scope <@scope> npm scope for the package name, e.g. @acme. Not inferred:',
212
+ ' --monorepo Scaffold the packages as members of the surrounding npm',
213
+ ' workspace, with no root of their own: each tsconfig',
214
+ ' extends the root config that actually carries',
215
+ ' compilerOptions, and the scripts address the server by',
216
+ ' --prefix. Errors when no ancestor declares `workspaces`.',
217
+ ' Never writes outside the target — the root `workspaces`',
218
+ ' entries and dependency pins are printed, not added.',
219
+ ' --scope <@scope> npm scope for the package names, e.g. @acme. Not inferred:',
216
220
  ' a root manifest is usually named for the repo, not the',
217
221
  ' scope. The wizard offers the siblings’ scope as a default.',
218
- ' --public Omit "private": true, so the package can be published.',
219
- ' The scaffold emits it by default, because the manifest',
220
- ' it also emits declares license "UNLICENSED": a package',
221
- ' granting no rights on a public registry contradicts',
222
- ' itself. Pass this once the project has picked a licence.',
222
+ ' --public Omit "private": true from the server and protocol',
223
+ ' packages, so they can be published together. The',
224
+ ' scaffold emits it by default, because the manifests',
225
+ ' also declare license "UNLICENSED": a package granting',
226
+ ' no rights on a public registry contradicts itself. Pass',
227
+ ' this once the project has picked a licence.',
223
228
  '',
224
229
  'Grammar options — each applies to the PRECEDING --grammar:',
225
230
  ' --grammar <Name> PascalCase GRAMMAR name; drives the `grammar X` declaration',
@@ -233,8 +238,8 @@ export const INIT_HELP: readonly string[] = [
233
238
  ' (default: <project-id>-<grammar-id>).',
234
239
  ' --diagram Scaffold a GLSP diagram for that grammar. Requires',
235
240
  ' `glsp` in --heads. Derived when there is exactly one',
236
- ' grammar; required when there are several, because a',
237
- ' diagram type binds exactly one grammar.',
241
+ ' grammar; required when there are several, because the',
242
+ ' scaffolded diagram is typed over one grammar’s model.',
238
243
  '',
239
244
  'Example — three grammars, one with a differing extension, three heads:',
240
245
  ' hydranium-cli init ./order-flow --name OrderFlow --heads lsp,data,glsp \\',
@@ -66,7 +66,7 @@ export interface PromptPort {
66
66
  readonly choices: ReadonlyArray<PromptChoice<Value>>;
67
67
  readonly initialValue?: Value;
68
68
  }) => Promise<Value>;
69
- /** Ask for any number of several choices, including none. */
69
+ /** Ask for at least one of several choices. */
70
70
  readonly multiselect: <Value extends string>(options: {
71
71
  readonly message: string;
72
72
  readonly choices: ReadonlyArray<PromptChoice<Value>>;
@@ -78,8 +78,9 @@ export interface PromptPort {
78
78
  readonly outro: (message: string) => void;
79
79
  }
80
80
 
81
- /** The optional heads, as a checkbox list. `lsp` is not offered — see `askHeads`. */
82
- export const OPTIONAL_HEAD_CHOICES: ReadonlyArray<PromptChoice<Exclude<InitHead, 'lsp'>>> = [
81
+ /** The heads, as a checkbox list. */
82
+ export const HEAD_CHOICES: ReadonlyArray<PromptChoice<InitHead>> = [
83
+ { value: 'lsp', label: 'lsp', hint: 'text editing in an LSP client' },
83
84
  { value: 'data', label: 'data', hint: 'typed JSON-RPC for forms, trees and code-gen' },
84
85
  { value: 'glsp', label: 'glsp', hint: 'graphical editing; adds a scaffolded diagram' }
85
86
  ];
@@ -138,9 +139,7 @@ export async function createClackPrompt(): Promise<PromptPort> {
138
139
  message: options.message,
139
140
  options: toOptions(options.choices),
140
141
  initialValues: options.initialValues ? [...options.initialValues] : [],
141
- // Legal and meaningful: an `lsp`-only project is a plain LSP
142
- // server, so an empty selection must not be rejected.
143
- required: false
142
+ required: true
144
143
  })
145
144
  ),
146
145
  confirm: async options => unwrap(await clack.confirm({ message: options.message, initialValue: options.initialValue })),