@hydranium/cli 1.0.0-next.30 → 1.0.0-next.301

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 (222) hide show
  1. package/README.md +75 -204
  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-ast-builder.d.ts +49 -0
  41. package/lib/commands/generate-ast-builder.d.ts.map +1 -0
  42. package/lib/commands/generate-ast-builder.js +200 -0
  43. package/lib/commands/generate-ast-builder.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 +11 -1
  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 +9 -0
  51. package/lib/commands/generate-transfer-model.d.ts.map +1 -1
  52. package/lib/commands/generate-transfer-model.js +18 -4
  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.js +6 -6
  63. package/lib/commands/init-args.js.map +1 -1
  64. package/lib/commands/init-prompt.d.ts.map +1 -1
  65. package/lib/commands/init-templates.d.ts +8 -10
  66. package/lib/commands/init-templates.d.ts.map +1 -1
  67. package/lib/commands/init-templates.js +261 -167
  68. package/lib/commands/init-templates.js.map +1 -1
  69. package/lib/commands/init-wizard.js +4 -4
  70. package/lib/commands/init-wizard.js.map +1 -1
  71. package/lib/commands/init-workspace.d.ts +13 -3
  72. package/lib/commands/init-workspace.d.ts.map +1 -1
  73. package/lib/commands/init-workspace.js +21 -6
  74. package/lib/commands/init-workspace.js.map +1 -1
  75. package/lib/commands/init.d.ts +16 -10
  76. package/lib/commands/init.d.ts.map +1 -1
  77. package/lib/commands/init.js +17 -15
  78. package/lib/commands/init.js.map +1 -1
  79. package/lib/commands/lint-grammar-args.d.ts +3 -2
  80. package/lib/commands/lint-grammar-args.d.ts.map +1 -1
  81. package/lib/commands/lint-grammar-args.js +13 -10
  82. package/lib/commands/lint-grammar-args.js.map +1 -1
  83. package/lib/commands/lint-grammar-driver.js +2 -1
  84. package/lib/commands/lint-grammar-driver.js.map +1 -1
  85. package/lib/commands/lint-grammar-report.js.map +1 -1
  86. package/lib/commands/lint-grammar.js +1 -1
  87. package/lib/commands/lint-grammar.js.map +1 -1
  88. package/lib/commands/measure-memory-args.d.ts +3 -2
  89. package/lib/commands/measure-memory-args.d.ts.map +1 -1
  90. package/lib/commands/measure-memory-args.js +22 -11
  91. package/lib/commands/measure-memory-args.js.map +1 -1
  92. package/lib/commands/measure-memory-driver.js +5 -3
  93. package/lib/commands/measure-memory-driver.js.map +1 -1
  94. package/lib/commands/measure-memory.js +1 -1
  95. package/lib/commands/measure-memory.js.map +1 -1
  96. package/lib/commands/model-docs-args.d.ts +4 -3
  97. package/lib/commands/model-docs-args.d.ts.map +1 -1
  98. package/lib/commands/model-docs-args.js +12 -10
  99. package/lib/commands/model-docs-args.js.map +1 -1
  100. package/lib/commands/model-docs-driver.js +2 -1
  101. package/lib/commands/model-docs-driver.js.map +1 -1
  102. package/lib/commands/model-docs.js +1 -1
  103. package/lib/commands/model-docs.js.map +1 -1
  104. package/lib/commands/projects-args.d.ts.map +1 -1
  105. package/lib/commands/projects-args.js +5 -5
  106. package/lib/commands/projects-args.js.map +1 -1
  107. package/lib/commands/projects.d.ts +3 -4
  108. package/lib/commands/projects.d.ts.map +1 -1
  109. package/lib/commands/projects.js +2 -2
  110. package/lib/commands/projects.js.map +1 -1
  111. package/lib/commands/query-args.d.ts.map +1 -1
  112. package/lib/commands/query-args.js +5 -5
  113. package/lib/commands/query-args.js.map +1 -1
  114. package/lib/commands/query.d.ts +3 -4
  115. package/lib/commands/query.d.ts.map +1 -1
  116. package/lib/commands/query.js +2 -2
  117. package/lib/commands/query.js.map +1 -1
  118. package/lib/commands/reflect-args.d.ts +3 -2
  119. package/lib/commands/reflect-args.d.ts.map +1 -1
  120. package/lib/commands/reflect-args.js +13 -10
  121. package/lib/commands/reflect-args.js.map +1 -1
  122. package/lib/commands/reflect-driver.js +2 -1
  123. package/lib/commands/reflect-driver.js.map +1 -1
  124. package/lib/commands/reflect-report.js.map +1 -1
  125. package/lib/commands/reflect.js +1 -1
  126. package/lib/commands/reflect.js.map +1 -1
  127. package/lib/commands/save-args.d.ts.map +1 -1
  128. package/lib/commands/save-args.js +7 -4
  129. package/lib/commands/save-args.js.map +1 -1
  130. package/lib/commands/save.d.ts +8 -4
  131. package/lib/commands/save.d.ts.map +1 -1
  132. package/lib/commands/save.js +12 -23
  133. package/lib/commands/save.js.map +1 -1
  134. package/lib/commands/validate-args.d.ts +3 -2
  135. package/lib/commands/validate-args.d.ts.map +1 -1
  136. package/lib/commands/validate-args.js +13 -10
  137. package/lib/commands/validate-args.js.map +1 -1
  138. package/lib/commands/validate-driver.js +2 -1
  139. package/lib/commands/validate-driver.js.map +1 -1
  140. package/lib/commands/validate-report.js.map +1 -1
  141. package/lib/commands/validate.js +1 -1
  142. package/lib/commands/validate.js.map +1 -1
  143. package/lib/commands/watch-args.d.ts.map +1 -1
  144. package/lib/commands/watch-args.js +6 -4
  145. package/lib/commands/watch-args.js.map +1 -1
  146. package/lib/commands/watch.d.ts +3 -4
  147. package/lib/commands/watch.d.ts.map +1 -1
  148. package/lib/commands/watch.js +20 -2
  149. package/lib/commands/watch.js.map +1 -1
  150. package/lib/driver-heap.d.ts +52 -0
  151. package/lib/driver-heap.d.ts.map +1 -0
  152. package/lib/driver-heap.js +51 -0
  153. package/lib/driver-heap.js.map +1 -0
  154. package/lib/index.d.ts +3 -0
  155. package/lib/index.d.ts.map +1 -1
  156. package/lib/index.js +3 -0
  157. package/lib/index.js.map +1 -1
  158. package/lib/log-level.d.ts +21 -11
  159. package/lib/log-level.d.ts.map +1 -1
  160. package/lib/log-level.js +25 -14
  161. package/lib/log-level.js.map +1 -1
  162. package/lib/spawn-data-server.d.ts +9 -4
  163. package/lib/spawn-data-server.d.ts.map +1 -1
  164. package/lib/spawn-data-server.js +5 -4
  165. package/lib/spawn-data-server.js.map +1 -1
  166. package/lib/stderr-connection-logger.d.ts +12 -0
  167. package/lib/stderr-connection-logger.d.ts.map +1 -0
  168. package/lib/stderr-connection-logger.js +16 -0
  169. package/lib/stderr-connection-logger.js.map +1 -0
  170. package/lib/testing/echo-server.js +9 -1
  171. package/lib/testing/echo-server.js.map +1 -1
  172. package/package.json +50 -39
  173. package/src/cli.ts +7 -2
  174. package/src/commands/analyze-heap.ts +4 -1
  175. package/src/commands/ast-ground-truth-args.ts +15 -12
  176. package/src/commands/ast-ground-truth-driver.ts +2 -1
  177. package/src/commands/ast-ground-truth.ts +1 -1
  178. package/src/commands/client-session.ts +33 -0
  179. package/src/commands/create-args.ts +68 -0
  180. package/src/commands/create.ts +83 -0
  181. package/src/commands/delete-args.ts +64 -0
  182. package/src/commands/delete.ts +61 -0
  183. package/src/commands/generate-ast-builder.ts +246 -0
  184. package/src/commands/generate-transfer-model-args.ts +11 -1
  185. package/src/commands/generate-transfer-model-config.ts +6 -3
  186. package/src/commands/generate-transfer-model.ts +27 -4
  187. package/src/commands/harness-args.ts +99 -31
  188. package/src/commands/headless-harness.ts +86 -26
  189. package/src/commands/init-args.ts +6 -6
  190. package/src/commands/init-templates.ts +272 -169
  191. package/src/commands/init-wizard.ts +4 -4
  192. package/src/commands/init-workspace.ts +31 -7
  193. package/src/commands/init.ts +36 -26
  194. package/src/commands/lint-grammar-args.ts +17 -13
  195. package/src/commands/lint-grammar-driver.ts +2 -1
  196. package/src/commands/lint-grammar.ts +1 -1
  197. package/src/commands/measure-memory-args.ts +27 -14
  198. package/src/commands/measure-memory-driver.ts +5 -3
  199. package/src/commands/measure-memory.ts +1 -1
  200. package/src/commands/model-docs-args.ts +16 -13
  201. package/src/commands/model-docs-driver.ts +2 -1
  202. package/src/commands/model-docs.ts +1 -1
  203. package/src/commands/projects-args.ts +5 -4
  204. package/src/commands/projects.ts +4 -6
  205. package/src/commands/query-args.ts +5 -4
  206. package/src/commands/query.ts +4 -6
  207. package/src/commands/reflect-args.ts +17 -13
  208. package/src/commands/reflect-driver.ts +2 -1
  209. package/src/commands/reflect.ts +1 -1
  210. package/src/commands/save-args.ts +7 -3
  211. package/src/commands/save.ts +24 -27
  212. package/src/commands/validate-args.ts +17 -13
  213. package/src/commands/validate-driver.ts +2 -1
  214. package/src/commands/validate.ts +1 -1
  215. package/src/commands/watch-args.ts +6 -3
  216. package/src/commands/watch.ts +28 -7
  217. package/src/driver-heap.ts +65 -0
  218. package/src/index.ts +3 -0
  219. package/src/log-level.ts +42 -14
  220. package/src/spawn-data-server.ts +17 -5
  221. package/src/stderr-connection-logger.ts +18 -0
  222. package/src/testing/echo-server.ts +11 -2
package/package.json CHANGED
@@ -1,34 +1,46 @@
1
1
  {
2
2
  "name": "@hydranium/cli",
3
- "version": "1.0.0-next.30",
3
+ "version": "1.0.0-next.301",
4
4
  "description": "Build-time codegen tools + data-server subcommands for the hydranium framework.",
5
5
  "keywords": [
6
+ "cli",
7
+ "codegen",
6
8
  "hydranium",
7
9
  "langium",
8
10
  "language-server",
9
- "lsp",
10
- "cli",
11
- "codegen"
11
+ "lsp"
12
12
  ],
13
13
  "homepage": "https://github.com/eclipse-emfcloud/hydranium/tree/main/packages/cli",
14
14
  "bugs": {
15
15
  "url": "https://github.com/eclipse-emfcloud/hydranium/issues"
16
16
  },
17
+ "license": "MIT",
18
+ "author": {
19
+ "name": "Hydranium Team"
20
+ },
17
21
  "repository": {
18
22
  "type": "git",
19
23
  "url": "https://github.com/eclipse-emfcloud/hydranium.git",
20
24
  "directory": "packages/cli"
21
25
  },
22
- "license": "MIT",
23
- "author": {
24
- "name": "Hydranium Team"
26
+ "bin": {
27
+ "hydranium-cli": "bin/hydranium-cli.js"
25
28
  },
29
+ "files": [
30
+ "bin",
31
+ "lib",
32
+ "src",
33
+ "heap-analysis",
34
+ "!lib/**/*.tsbuildinfo"
35
+ ],
36
+ "type": "module",
26
37
  "sideEffects": [
27
38
  "./lib/cli.js",
28
39
  "./lib/commands/*-driver.js",
29
40
  "./lib/testing/echo-server.js"
30
41
  ],
31
- "type": "module",
42
+ "main": "lib/index.js",
43
+ "types": "lib/index.d.ts",
32
44
  "exports": {
33
45
  ".": {
34
46
  "types": "./lib/index.d.ts",
@@ -39,21 +51,13 @@
39
51
  "default": "./lib/cli.js"
40
52
  }
41
53
  },
42
- "main": "lib/index.js",
43
- "types": "lib/index.d.ts",
44
- "bin": {
45
- "hydranium-cli": "lib/cli.js"
54
+ "publishConfig": {
55
+ "access": "public"
46
56
  },
47
- "files": [
48
- "lib",
49
- "src",
50
- "heap-analysis",
51
- "!lib/**/*.tsbuildinfo"
52
- ],
53
57
  "scripts": {
54
- "build": "tsc -b && node -e \"require('node:fs').chmodSync('lib/cli.js',0o755)\"",
58
+ "build": "tsc -b",
55
59
  "clean": "rimraf lib tsconfig.tsbuildinfo",
56
- "lint": "eslint src test --max-warnings 0",
60
+ "lint": "oxlint --format stylish --config ../../oxlint.config.cjs src test --max-warnings 0",
57
61
  "prepack": "node -e \"const m=require('./package.json'),fs=require('node:fs');const missing=[m.main,...Object.values(m.bin||{})].filter(entry=>entry&&!fs.existsSync(entry));if(missing.length){console.error('prepack '+m.name+': not built ('+missing.join(', ')+' missing). Run the build before packing: a files entry that matches nothing is skipped silently, so the tarball would ship src only.');process.exit(1);}\"",
58
62
  "test": "npm run typecheck:test && vitest run",
59
63
  "typecheck:test": "tsc --noEmit -p tsconfig.test.json",
@@ -65,23 +69,33 @@
65
69
  "ts-morph": "^25.0.0"
66
70
  },
67
71
  "devDependencies": {
68
- "@hydranium/core": "1.0.0-next.30",
69
- "@hydranium/data-server": "1.0.0-next.30",
70
- "@hydranium/langium": "1.0.0-next.30",
71
- "@hydranium/protocol": "1.0.0-next.30",
72
+ "@eclipse-glsp/graph": "2.7.0",
73
+ "@eclipse-glsp/server": "2.7.0",
74
+ "@hydranium/core": "1.0.0-next.301",
75
+ "@hydranium/data-server": "1.0.0-next.301",
76
+ "@hydranium/glsp-server": "1.0.0-next.301",
77
+ "@hydranium/langium": "1.0.0-next.301",
78
+ "@hydranium/protocol": "1.0.0-next.301",
79
+ "@types/node": "^22.0.0",
80
+ "inversify": "6.2.2",
81
+ "langium": "4.3.1",
82
+ "langium-cli": "4.3.0",
83
+ "reflect-metadata": "0.2.2",
72
84
  "rimraf": "^5.0.0",
73
- "typescript": "^5.8.0",
74
- "vscode-jsonrpc": "9.0.1",
75
- "vscode-languageserver": "~10.0.1"
85
+ "typescript": "^7.0.2",
86
+ "vitest": "^4.0.0",
87
+ "vscode-jsonrpc": "9.0.0",
88
+ "vscode-languageserver": "10.0.1",
89
+ "vscode-languageserver-protocol": "3.18.1"
76
90
  },
77
91
  "peerDependencies": {
78
- "@hydranium/core": "1.0.0-next.30",
79
- "@hydranium/data-server": "1.0.0-next.30",
80
- "@hydranium/langium": "1.0.0-next.30",
81
- "@hydranium/protocol": "1.0.0-next.30",
92
+ "@hydranium/core": "1.0.0-next.301",
93
+ "@hydranium/data-server": "1.0.0-next.301",
94
+ "@hydranium/langium": "1.0.0-next.301",
95
+ "@hydranium/protocol": "1.0.0-next.301",
82
96
  "@memlab/core": "^2.0.3",
83
97
  "@memlab/heap-analysis": "^2.0.3",
84
- "vscode-jsonrpc": "9.0.1"
98
+ "vscode-jsonrpc": "^9.0.0"
85
99
  },
86
100
  "peerDependenciesMeta": {
87
101
  "@memlab/core": {
@@ -94,13 +108,10 @@
94
108
  "engines": {
95
109
  "node": ">=22.13"
96
110
  },
97
- "publishConfig": {
98
- "access": "public"
99
- },
100
- "//build": "The chmod is load-bearing, not cruft. npm sets a bin's executable bit through bin-links' fixBin, but ONLY when it first creates the link — and `tsc` never sets it, so after `npm run clean` (which deletes lib/) a rebuild leaves lib/cli.js at 0644 and the node_modules/.bin/hydranium-cli symlink resolves to a non-executable target. Every example's `generate` step then dies with `sh: hydranium-cli: Permission denied`, surfacing as an opaque npm error code 127 during `turbo run build`. npm rebuild, npm rebuild @hydranium/cli AND a full npm install all fail to restore it, because npm will not revisit an existing workspace symlink; only a from-scratch `rm -rf node_modules` install does. Written as `node -e` rather than `chmod +x` so it stays portable — on Windows npm generates .cmd/.ps1 shims where the bit is irrelevant and chmodSync is harmless. The example packages' bins need no such step: their tests spawn them via process.execPath, never through the shim.",
101
- "//exports": "Two keys, and the SHORT list is the point: `files` ships the whole compiled tree, so without a map every `lib/commands/*.js`, every internal helper and `lib/testing/echo-server.js` is deep-importable the moment this publishes, and semver then applies to all of it. `.` is the library barrel (the data-server subcommands an adopter calls as functions). `./lib/cli.js` is the BINARY ARTEFACT, and it is declared because a consumer that spawns the CLI resolves it BY SPECIFIER — `createRequire(import.meta.url).resolve('@hydranium/cli/lib/cli.js')` — to get the path npx would run; `bin` gives a shim on PATH, not a path, so dropping this key breaks that resolution and the failure surfaces as \"hydranium-cli is not built\", naming the wrong cause. It is declared in the `/lib/` spelling ONLY: that spelling already resolves under both of this repo's module resolvers, so the twin rule (which exists so a BARE subpath is reachable from node10) has nothing to add here and a bare twin would only be a second name for one artefact. `heap-analysis/` needs no key even though `files` ships it — `analyze-heap` reaches the analyzer through a `new URL(..., import.meta.url)` file URL, which `exports` does not gate, and the package's own tests reach it relatively. `./testing` is deliberately absent: `echo-server` is a spawnable stdio fixture, not a reusable export.",
111
+ "//devDependencies": "Every package an `init` scaffold declares, other than this one, is declared here, whether or not `src` uses it: the scaffold-compiles test compiles and runs scaffolds inside this package, so their imports and tools resolve through these declarations. `check:init-provenance` holds this list and its versions to the scaffold's manifest.",
112
+ "//exports": "Two keys, and the SHORT list is the point: `files` ships the whole compiled tree, so without a map every `lib/commands/*.js`, every internal helper and `lib/testing/echo-server.js` is deep-importable the moment this publishes, and semver then applies to all of it. `.` is the library barrel (the data-server subcommands an adopter calls as functions). `./lib/cli.js` is the BINARY ARTEFACT, and it is declared because a consumer that spawns the CLI resolves it BY SPECIFIER — `createRequire(import.meta.url).resolve('@hydranium/cli/lib/cli.js')` — to get the path npx would run; `bin` gives a shim on PATH, not a path, so dropping this key breaks that resolution and the failure surfaces as \"hydranium-cli is not built\", naming the wrong cause. `heap-analysis/` needs no key even though `files` ships it — `analyze-heap` reaches the analyzer through a `new URL(..., import.meta.url)` file URL, which `exports` does not gate, and the package's own tests reach it relatively. `./testing` is deliberately absent: `echo-server` is a spawnable stdio fixture, not a reusable export.",
102
113
  "//memlab": "@memlab/core and @memlab/heap-analysis are OPTIONAL PEER dependencies, not optionalDependencies, and the distinction is the whole point: npm installs optionalDependencies BY DEFAULT, both memlab packages pin puppeteer exactly, and puppeteer's postinstall downloads a Chrome binary — so every adopter of this CLI paid ~86 MB and a browser download for the one subcommand almost none of them run, and the download can fail and be walked past as a warning. An optional peer is not auto-installed, so `analyze-heap` documents `npm install @memlab/core @memlab/heap-analysis` as the opt-in and every other subcommand is unaffected. Taken pre-publish deliberately: after publish the install shape is what adopters already have.",
103
- "//peerDependencies": "`vscode-jsonrpc` is EXACT rather than a range, because it is one link of an atomic chain with no independently movable link: `vscode-languageserver-protocol` depends on it at exactly 9.0.1, so any other value an adopter supplies is a SECOND physical copy rather than an upgrade. This wire stack breaks on copy identity rather than on structure — `ParameterStructures.auto` is a singleton compared by `===` in connection.js, so a request type built by one copy and sent over a connection owned by the other throws `Unknown parameter structure auto`. A caret or union range was rejected because npm then resolves a `vscode-jsonrpc@8.2.0` tree SILENTLY, with no diagnostic at all, and the failure surfaces only later at server init. Exact does not fail the install either — npm downgrades an unsatisfiable peer to a warning — but it is a NAMED ERESOLVE warning printing the required version beside the found one, and a hard error for anyone installing with `--strict-peer-deps`. It does NOT prevent a NESTED copy — `@eclipse-glsp/*` carries its own exact `vscode-jsonrpc@8.2.0` dependency and root `overrides` do not ship — so a consumer of the GLSP head must pin the chain in its own manifest.",
104
- "//prepack": "The publish guard, and it deliberately is NOT a `prepare`: npm runs a workspace `prepare` BEFORE the root `postinstall` that applies patches/vscode-jsonrpc+9.0.1.patch, so building there fails on a cold clone and npm rolls the entire install back. `prepack` runs only when a tarball is made (`npm pack`, `npm publish`) and never on install, so it cannot break the install it has no business touching. It FAILS rather than rebuilds, because the rebuild is exactly the part that ordering defeats. What it defends against: `files` lists `lib`, `lib` is gitignored, and a `files` entry matching nothing is skipped SILENTLY — so `npm publish` from an unbuilt tree emits a tarball of `src` and nothing else, with no error.",
114
+ "//peerDependencies": "`vscode-jsonrpc` takes a caret, so the framework shares the transport the LSP connection resolves, which an `init` scaffold pins: each `vscode-languageserver-protocol` release pins its transport exactly, so an exact peer would name a copy a fresh install rarely holds. The caret excludes 8.x, so a tree whose top holds GLSP's copy fails the peer with a named ERESOLVE warning, an error under `--strict-peer-deps`, rather than resolving silently. No peer reaches a NESTED copy, such as GLSP's or one the LSP packages nest. The wire compares message types and `ResponseError`s by copy identity, so the framework sends typed messages by method name and recognises errors with `isResponseError` rather than `instanceof`.",
115
+ "//prepack": "The publish guard, a `prepack` rather than a `prepare`: `prepack` runs only when a tarball is made (`npm pack`, `npm publish`) and never on install, so it cannot break the install it has no business touching. What it defends against: `files` lists `lib`, `lib` is gitignored, and a `files` entry matching nothing is skipped SILENTLY — so `npm publish` from an unbuilt tree emits a tarball of `src` and nothing else, with no error.",
105
116
  "//sideEffects": "The listed modules RUN on load rather than exporting anything: `cli.js` is the `bin`, each `*-driver.js` is spawned as its own process and calls `main(process.argv)` at top level, and `echo-server.js` starts a server. Their whole purpose is the effect, so a bundler must never treat them as prunable. Everything else here is library code with no module-level state beyond `new URL(..., import.meta.url)` constants."
106
117
  }
package/src/cli.ts CHANGED
@@ -9,9 +9,12 @@
9
9
  ********************************************************************************/
10
10
 
11
11
  import { Command } from 'commander';
12
+ import { describeError } from '@hydranium/protocol';
12
13
  import { readCliVersion } from './cli-version.js';
13
14
  import { runAnalyzeHeapCommand } from './commands/analyze-heap-args.js';
14
15
  import { runAstGroundTruthCommand } from './commands/ast-ground-truth-args.js';
16
+ import { runCreateCommand } from './commands/create-args.js';
17
+ import { runDeleteCommand } from './commands/delete-args.js';
15
18
  import { runGenerateTransferModelCommand } from './commands/generate-transfer-model-args.js';
16
19
  import { runInitCommand } from './commands/init-args.js';
17
20
  import { InitWizardCancelled } from './commands/init-prompt.js';
@@ -44,6 +47,8 @@ const COMMANDS: Record<string, { readonly summary: string; readonly run: (args:
44
47
  summary: "Tally a workspace's live-model $types (analyze-heap --validate input).",
45
48
  run: runAstGroundTruthCommand
46
49
  },
50
+ create: { summary: 'Create a new document and its file via a data-server subprocess.', run: runCreateCommand },
51
+ delete: { summary: 'Delete a document, its file included, via a data-server subprocess.', run: runDeleteCommand },
47
52
  'generate-transfer-model': {
48
53
  summary: 'Generate a transfer-model TypeScript file from a Langium AST.',
49
54
  run: runGenerateTransferModelCommand
@@ -55,7 +60,7 @@ const COMMANDS: Record<string, { readonly summary: string; readonly run: (args:
55
60
  projects: { summary: 'List projects exposed by a data-server subprocess.', run: runProjectsCommand },
56
61
  query: { summary: 'Print the data-server document envelope for a URI.', run: runQueryCommand },
57
62
  reflect: { summary: "Dump a head's grammar/AST reflection (types, terminals, refs).", run: runReflectCommand },
58
- save: { summary: 'Update + persist a document via a data-server subprocess.', run: runSaveCommand },
63
+ save: { summary: 'Update + persist an existing document via a data-server subprocess.', run: runSaveCommand },
59
64
  validate: { summary: 'Validate a workspace headlessly; non-zero exit on errors (CI gate).', run: runValidateCommand },
60
65
  watch: { summary: 'Subscribe to data-server document updates; print events as NDJSON.', run: runWatchCommand }
61
66
  };
@@ -134,6 +139,6 @@ main(process.argv.slice(2)).catch(err => {
134
139
  if (err instanceof InitWizardCancelled) {
135
140
  process.exit(130);
136
141
  }
137
- console.error(err instanceof Error ? err.message : String(err));
142
+ console.error(describeError(err));
138
143
  process.exit(1);
139
144
  });
@@ -8,6 +8,7 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  import { fileURLToPath } from 'node:url';
11
+ import { driverHeapArgs, type HeapReading } from '../driver-heap.js';
11
12
  import { spawnNodeChild } from './headless-harness.js';
12
13
 
13
14
  /**
@@ -41,6 +42,8 @@ export interface AnalyzeHeapDeps {
41
42
  readonly __spawnForTest?: (execArgs: string[]) => Promise<number>;
42
43
  /** Override the memlab-availability check. */
43
44
  readonly __memlabInstalledForTest?: () => boolean;
45
+ /** Decide the heap ceiling from a stated cgroup reading rather than the machine's. */
46
+ readonly __heapReadingForTest?: HeapReading;
44
47
  }
45
48
 
46
49
  /**
@@ -69,7 +72,7 @@ export async function runAnalyzeHeap(args: string[], deps: AnalyzeHeapDeps = {})
69
72
  return;
70
73
  }
71
74
  const spawnChild = deps.__spawnForTest ?? spawnNodeChild;
72
- const code = await spawnChild(['--max-old-space-size=8192', ANALYZER, ...args]);
75
+ const code = await spawnChild([...driverHeapArgs(deps.__heapReadingForTest), ANALYZER, ...args]);
73
76
  if (code) {
74
77
  process.exitCode = code;
75
78
  }
@@ -10,32 +10,34 @@
10
10
  import { runAstGroundTruth, type AstGroundTruthCommandOptions } from './ast-ground-truth.js';
11
11
  import {
12
12
  exitWithUsage,
13
+ HARNESS_VALUE_FLAGS,
13
14
  helpRequested,
14
- LOG_LEVEL_FLAG,
15
- logLevelHelpLine,
16
- logLevelOption,
15
+ importHelpLines,
16
+ LOG_VALUE_FLAGS,
17
+ logHelpLines,
18
+ logOptions,
17
19
  parseHarnessArgs,
18
20
  printHelp,
19
- SERVICES_FLAG,
20
21
  type UsageError
21
22
  } from './harness-args.js';
22
23
  import { OUT_FILE_FLAG } from './headless-harness.js';
23
24
 
24
- const VALUE_FLAGS = [OUT_FILE_FLAG, LOG_LEVEL_FLAG] as const;
25
+ const VALUE_FLAGS = [OUT_FILE_FLAG, ...LOG_VALUE_FLAGS] as const;
25
26
 
26
27
  /**
27
28
  * Every flag `ast-ground-truth` accepts, derived from the sets the parser is
28
- * handed so the list cannot claim a flag the parser would reject. `--services`
29
- * is consumed by the shared harness parser itself, so it is in neither set.
29
+ * handed so the list cannot claim a flag the parser would reject.
30
+ * {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
31
+ * so they are in neither set.
30
32
  */
31
- export const AST_GROUND_TRUTH_FLAGS: readonly string[] = [SERVICES_FLAG, ...VALUE_FLAGS];
33
+ export const AST_GROUND_TRUTH_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS];
32
34
 
33
35
  /** The subset that takes a value, so `--help` in a value position reads as data. */
34
36
  export const AST_GROUND_TRUTH_VALUE_FLAGS: readonly string[] = AST_GROUND_TRUTH_FLAGS;
35
37
 
36
38
  /** The `--help` text, as data, held to {@link AST_GROUND_TRUTH_FLAGS} by a test. */
37
39
  export const AST_GROUND_TRUTH_HELP: readonly string[] = [
38
- 'Usage: hydranium-cli ast-ground-truth --services <module> <workspace> [--out-file <file>] [--log-level <lvl>]',
40
+ 'Usage: hydranium-cli ast-ground-truth --services <module> [--import <specifier>]... <workspace> [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
39
41
  '',
40
42
  "Tally a workspace's live-model AST nodes by `$type` — the ground truth that",
41
43
  '`analyze-heap --validate <gt.json>` checks a heap snapshot against. `<module>`',
@@ -44,14 +46,15 @@ export const AST_GROUND_TRUTH_HELP: readonly string[] = [
44
46
  '',
45
47
  'Options:',
46
48
  ' --services <module> ESM module exporting `createServices(): { shared }` (required).',
49
+ ...importHelpLines(22),
47
50
  ' <workspace> Workspace root (path or file URI) to build (required).',
48
51
  ' --out-file <file> Write the JSON to this file instead of stdout.',
49
- logLevelHelpLine(22)
52
+ ...logHelpLines(22)
50
53
  ];
51
54
 
52
55
  export function parseAstGroundTruthArgs(args: string[], onError: UsageError = exitWithUsage): AstGroundTruthCommandOptions {
53
- const { servicesModule, workspace, options } = parseHarnessArgs(args, 'ast-ground-truth', VALUE_FLAGS, [], { onError });
54
- return { servicesModule, workspace, outFile: options[OUT_FILE_FLAG], logLevel: logLevelOption(options[LOG_LEVEL_FLAG]) };
56
+ const { servicesModule, imports, workspace, options } = parseHarnessArgs(args, 'ast-ground-truth', VALUE_FLAGS, [], { onError });
57
+ return { servicesModule, imports, workspace, outFile: options[OUT_FILE_FLAG], ...logOptions(options) };
55
58
  }
56
59
 
57
60
  export function runAstGroundTruthCommand(args: string[]): Promise<void> {
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  import * as fs from 'node:fs';
19
+ import { describeError } from '@hydranium/protocol';
19
20
  import { loadHeadlessContext, OUT_FILE_FLAG } from './headless-harness.js';
20
21
 
21
22
  interface DriverArgs {
@@ -76,6 +77,6 @@ async function main(argv: string[]): Promise<void> {
76
77
  main(process.argv.slice(2))
77
78
  .then(() => process.exit(0))
78
79
  .catch((error: unknown) => {
79
- console.error(error instanceof Error ? error.message : String(error));
80
+ console.error(describeError(error));
80
81
  process.exit(1);
81
82
  });
@@ -45,5 +45,5 @@ export function buildGroundTruthDriverArgs(options: AstGroundTruthCommandOptions
45
45
  * `--out-file`). No `--expose-gc` needed — this walks the AST, it does not weigh it.
46
46
  */
47
47
  export function runAstGroundTruth(options: AstGroundTruthCommandOptions): Promise<void> {
48
- return runDriverChild(['--max-old-space-size=8192', DRIVER, ...buildGroundTruthDriverArgs(options)], options);
48
+ return runDriverChild([DRIVER, ...buildGroundTruthDriverArgs(options)], options);
49
49
  }
@@ -0,0 +1,33 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+
10
+ import type { TransferElement } from '@hydranium/protocol';
11
+ import type { DataServerProtocol } from '@hydranium/protocol/data';
12
+
13
+ /**
14
+ * Run `fn` as the client session `clientId`, and end the session whether `fn`
15
+ * succeeded or not, which closes whatever it left open. An end that fails
16
+ * after a failed `fn` is swallowed: `fn`'s error is the one the user needs.
17
+ */
18
+ export async function withClientSession<T>(
19
+ server: Pick<DataServerProtocol<TransferElement>, 'createSession' | 'closeSession'>,
20
+ clientId: string,
21
+ fn: () => Promise<T>
22
+ ): Promise<T> {
23
+ await server.createSession({ clientId, label: 'hydranium-cli' });
24
+ let result: T;
25
+ try {
26
+ result = await fn();
27
+ } catch (error: unknown) {
28
+ await server.closeSession({ clientId }).catch(() => undefined);
29
+ throw error;
30
+ }
31
+ await server.closeSession({ clientId });
32
+ return result;
33
+ }
@@ -0,0 +1,68 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+
10
+ import {
11
+ assertRequired,
12
+ exitWithUsage,
13
+ helpRequested,
14
+ logHelpLines,
15
+ parseFlagOptions,
16
+ parseServerSpawnOptions,
17
+ printHelp,
18
+ SERVER_SPAWN_VALUE_FLAGS,
19
+ type UsageError
20
+ } from './harness-args.js';
21
+ import { type CreateCommandOptions, runCreate } from './create.js';
22
+
23
+ const OWN_FLAGS = ['--uri', '--content', '--client-id'] as const;
24
+
25
+ /** Every flag `create` accepts, each of which takes a value. */
26
+ export const CREATE_FLAGS: readonly string[] = [...SERVER_SPAWN_VALUE_FLAGS, ...OWN_FLAGS];
27
+
28
+ /** The `--help` text, as data, held to {@link CREATE_FLAGS} by a test. */
29
+ export const CREATE_HELP: readonly string[] = [
30
+ 'Usage: hydranium-cli create --server "<cmd>..." --uri <uri> --content <text|@file> [--client-id <id>] [--cwd <dir>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
31
+ '',
32
+ 'Create the document at `<uri>` with `<content>` via createModelDocument, and persist it',
33
+ 'as given. Fails when the file exists or a client has it open.',
34
+ 'Output is the post-save envelope as a single JSON line.',
35
+ '',
36
+ 'Options:',
37
+ ' --server "<cmd>" Command-line for the data-server subprocess (required).',
38
+ ' --uri <uri> Document URI (required).',
39
+ ' --content <text> Content to write (required). Prefix `@` to read from a file',
40
+ ' (escape with `\\@` for literal `@`-leading content).',
41
+ ' --client-id <id> clientId for authorship attribution. Default: hydranium-cli.',
42
+ ' --cwd <dir> Working directory for the spawned child. Default: cwd.',
43
+ ...logHelpLines(22, 'the spawned server')
44
+ ];
45
+
46
+ export function parseCreateArgs(args: string[], onError: UsageError = exitWithUsage): CreateCommandOptions {
47
+ const { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, extra } = parseServerSpawnOptions(args, 'create', onError);
48
+ const { uri, content, clientId } = parseFlagOptions(extra, 'create', OWN_FLAGS, onError);
49
+ return {
50
+ serverCommand,
51
+ serverArgs,
52
+ cwd,
53
+ logLevel,
54
+ logFile,
55
+ logFileLevel,
56
+ uri: assertRequired(uri, '--uri', 'create', onError),
57
+ content: assertRequired(content, '--content', 'create', onError),
58
+ clientId
59
+ };
60
+ }
61
+
62
+ export function runCreateCommand(args: string[]): Promise<void> {
63
+ if (helpRequested(args, CREATE_FLAGS)) {
64
+ printHelp(CREATE_HELP);
65
+ return Promise.resolve();
66
+ }
67
+ return runCreate(parseCreateArgs(args));
68
+ }
@@ -0,0 +1,83 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+
10
+ import type { TransferElement } from '@hydranium/protocol';
11
+ import type { DataServerProtocol } from '@hydranium/protocol/data';
12
+ import { logEnv, type LogOptions } from '../log-level.js';
13
+ import { withDataServer } from '../spawn-data-server.js';
14
+ import { withClientSession } from './client-session.js';
15
+ import { resolveContent } from './harness-args.js';
16
+
17
+ /**
18
+ * Options for the {@link runCreate} subcommand. Creates the document at `uri`
19
+ * with `content` (literal text or `@<path>` for a file reference) via the
20
+ * data-server's `createModelDocument` RPC, and persists that text as it is.
21
+ * Fails when the file exists or a client has it open. Writes the post-save
22
+ * envelope as a single JSON line, as `save` does.
23
+ *
24
+ * `clientId` defaults to `'hydranium-cli'`. The command creates as a client
25
+ * session under it: it registers the session, creates the document, persists
26
+ * it, since a created document reaches disk only with a save, and ends the
27
+ * session.
28
+ */
29
+ export interface CreateCommandOptions extends LogOptions {
30
+ readonly serverCommand: string;
31
+ readonly serverArgs?: readonly string[];
32
+ readonly cwd?: string;
33
+ readonly uri: string;
34
+ /** Literal content text, or `@<path>` to read from a file. */
35
+ readonly content: string;
36
+ readonly clientId?: string;
37
+ readonly write?: (line: string) => void;
38
+ readonly __proxyForTest?: DataServerProtocol<TransferElement>;
39
+ /** Test-only: override the file-reader so unit tests can stub `@<path>` expansion. */
40
+ readonly __readFileForTest?: (path: string) => Promise<string>;
41
+ }
42
+
43
+ export async function runCreate(options: CreateCommandOptions): Promise<void> {
44
+ const write = options.write ?? ((line: string) => process.stdout.write(line));
45
+ const clientId = options.clientId ?? 'hydranium-cli';
46
+ const text = await resolveContent(options.content, options.__readFileForTest);
47
+
48
+ if (options.__proxyForTest) {
49
+ write(`${JSON.stringify(await createPersisted(options.__proxyForTest, options.uri, clientId, text))}\n`);
50
+ return;
51
+ }
52
+
53
+ await withDataServer(
54
+ {
55
+ command: options.serverCommand,
56
+ args: options.serverArgs,
57
+ cwd: options.cwd,
58
+ env: logEnv(options)
59
+ },
60
+ async server => {
61
+ write(`${JSON.stringify(await createPersisted(server, options.uri, clientId, text))}\n`);
62
+ }
63
+ );
64
+ }
65
+
66
+ /**
67
+ * Create `uri` with `text` as the session `clientId` and persist it, then end
68
+ * the session. The persist is gated on the version the create made, so a
69
+ * write that landed before the create's answer or after it, another client's
70
+ * or an integrity repair, fails the command with a conflict and nothing
71
+ * persists.
72
+ */
73
+ function createPersisted(
74
+ server: Pick<DataServerProtocol<TransferElement>, 'createSession' | 'createModelDocument' | 'persistModelDocument' | 'closeSession'>,
75
+ uri: string,
76
+ clientId: string,
77
+ text: string
78
+ ): Promise<unknown> {
79
+ return withClientSession(server, clientId, async () => {
80
+ const created = await server.createModelDocument({ uri, clientId, text });
81
+ return server.persistModelDocument({ uri, clientId, baseVersion: created.created.version });
82
+ });
83
+ }
@@ -0,0 +1,64 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+
10
+ import {
11
+ assertRequired,
12
+ exitWithUsage,
13
+ helpRequested,
14
+ logHelpLines,
15
+ parseFlagOptions,
16
+ parseServerSpawnOptions,
17
+ printHelp,
18
+ SERVER_SPAWN_VALUE_FLAGS,
19
+ type UsageError
20
+ } from './harness-args.js';
21
+ import { type DeleteCommandOptions, runDelete } from './delete.js';
22
+
23
+ const OWN_FLAGS = ['--uri', '--client-id'] as const;
24
+
25
+ /** Every flag `delete` accepts, each of which takes a value. */
26
+ export const DELETE_FLAGS: readonly string[] = [...SERVER_SPAWN_VALUE_FLAGS, ...OWN_FLAGS];
27
+
28
+ /** The `--help` text, as data, held to {@link DELETE_FLAGS} by a test. */
29
+ export const DELETE_HELP: readonly string[] = [
30
+ 'Usage: hydranium-cli delete --server "<cmd>..." --uri <uri> [--client-id <id>] [--cwd <dir>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
31
+ '',
32
+ 'Delete the document at `<uri>`, its file and then the document, via deleteModelDocument,',
33
+ 'whatever text it holds. Prints nothing.',
34
+ '',
35
+ 'Options:',
36
+ ' --server "<cmd>" Command-line for the data-server subprocess (required).',
37
+ ' --uri <uri> Document URI (required).',
38
+ ' --client-id <id> clientId the deletion is attributed to. Default: hydranium-cli.',
39
+ ' --cwd <dir> Working directory for the spawned child. Default: cwd.',
40
+ ...logHelpLines(22, 'the spawned server')
41
+ ];
42
+
43
+ export function parseDeleteArgs(args: string[], onError: UsageError = exitWithUsage): DeleteCommandOptions {
44
+ const { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, extra } = parseServerSpawnOptions(args, 'delete', onError);
45
+ const { uri, clientId } = parseFlagOptions(extra, 'delete', OWN_FLAGS, onError);
46
+ return {
47
+ serverCommand,
48
+ serverArgs,
49
+ cwd,
50
+ logLevel,
51
+ logFile,
52
+ logFileLevel,
53
+ uri: assertRequired(uri, '--uri', 'delete', onError),
54
+ clientId
55
+ };
56
+ }
57
+
58
+ export function runDeleteCommand(args: string[]): Promise<void> {
59
+ if (helpRequested(args, DELETE_FLAGS)) {
60
+ printHelp(DELETE_HELP);
61
+ return Promise.resolve();
62
+ }
63
+ return runDelete(parseDeleteArgs(args));
64
+ }
@@ -0,0 +1,61 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+
10
+ import type { TransferElement } from '@hydranium/protocol';
11
+ import type { DataServerProtocol } from '@hydranium/protocol/data';
12
+ import { logEnv, type LogOptions } from '../log-level.js';
13
+ import { withDataServer } from '../spawn-data-server.js';
14
+ import { withClientSession } from './client-session.js';
15
+
16
+ /**
17
+ * Options for the {@link runDelete} subcommand. Deletes the document at `uri`,
18
+ * its file and then the document, via the data-server's `deleteModelDocument`
19
+ * RPC, whatever text it holds. Prints nothing; a failed delete rejects.
20
+ *
21
+ * `clientId` defaults to `'hydranium-cli'`. The command deletes as a client
22
+ * session under it: it registers the session, opens the document, deletes it,
23
+ * and ends the session.
24
+ */
25
+ export interface DeleteCommandOptions extends LogOptions {
26
+ readonly serverCommand: string;
27
+ readonly serverArgs?: readonly string[];
28
+ readonly cwd?: string;
29
+ readonly uri: string;
30
+ readonly clientId?: string;
31
+ readonly __proxyForTest?: DataServerProtocol<TransferElement>;
32
+ }
33
+
34
+ export async function runDelete(options: DeleteCommandOptions): Promise<void> {
35
+ const clientId = options.clientId ?? 'hydranium-cli';
36
+ if (options.__proxyForTest) {
37
+ await deleteOpened(options.__proxyForTest, options.uri, clientId);
38
+ return;
39
+ }
40
+ await withDataServer(
41
+ {
42
+ command: options.serverCommand,
43
+ args: options.serverArgs,
44
+ cwd: options.cwd,
45
+ env: logEnv(options)
46
+ },
47
+ server => deleteOpened(server, options.uri, clientId)
48
+ );
49
+ }
50
+
51
+ /** Open `uri` as the session `clientId` and delete it, then end the session. */
52
+ function deleteOpened(
53
+ server: Pick<DataServerProtocol<TransferElement>, 'createSession' | 'openModelDocument' | 'deleteModelDocument' | 'closeSession'>,
54
+ uri: string,
55
+ clientId: string
56
+ ): Promise<void> {
57
+ return withClientSession(server, clientId, async () => {
58
+ await server.openModelDocument({ uri, clientId });
59
+ await server.deleteModelDocument({ uri, clientId, baseVersion: 'any' });
60
+ });
61
+ }