@hydranium/cli 1.0.0-next.42 → 1.0.0-next.421
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.
- package/README.md +125 -204
- package/bin/hydranium-cli.js +13 -0
- package/heap-analysis/heap/core/load.mjs +2 -2
- package/heap-analysis/heap/langium/langium.classifier.mjs +22 -11
- package/lib/cli-version.js.map +1 -1
- package/lib/cli.js +11 -2
- package/lib/cli.js.map +1 -1
- package/lib/commands/analyze-heap-args.d.ts.map +1 -1
- package/lib/commands/analyze-heap-args.js +1 -2
- package/lib/commands/analyze-heap-args.js.map +1 -1
- package/lib/commands/analyze-heap.d.ts +3 -0
- package/lib/commands/analyze-heap.d.ts.map +1 -1
- package/lib/commands/analyze-heap.js +2 -1
- package/lib/commands/analyze-heap.js.map +1 -1
- package/lib/commands/ast-ground-truth-args.d.ts +3 -2
- package/lib/commands/ast-ground-truth-args.d.ts.map +1 -1
- package/lib/commands/ast-ground-truth-args.js +12 -10
- package/lib/commands/ast-ground-truth-args.js.map +1 -1
- package/lib/commands/ast-ground-truth-driver.js +4 -2
- package/lib/commands/ast-ground-truth-driver.js.map +1 -1
- package/lib/commands/ast-ground-truth.js +1 -1
- package/lib/commands/ast-ground-truth.js.map +1 -1
- package/lib/commands/check-skills-args.d.ts +11 -0
- package/lib/commands/check-skills-args.d.ts.map +1 -0
- package/lib/commands/check-skills-args.js +71 -0
- package/lib/commands/check-skills-args.js.map +1 -0
- package/lib/commands/client-session.d.ts +17 -0
- package/lib/commands/client-session.d.ts.map +1 -0
- package/lib/commands/client-session.js +27 -0
- package/lib/commands/client-session.js.map +1 -0
- package/lib/commands/create-args.d.ts +17 -0
- package/lib/commands/create-args.d.ts.map +1 -0
- package/lib/commands/create-args.js +53 -0
- package/lib/commands/create-args.js.map +1 -0
- package/lib/commands/create.d.ts +38 -0
- package/lib/commands/create.d.ts.map +1 -0
- package/lib/commands/create.js +43 -0
- package/lib/commands/create.js.map +1 -0
- package/lib/commands/delete-args.d.ts +17 -0
- package/lib/commands/delete-args.d.ts.map +1 -0
- package/lib/commands/delete-args.js +49 -0
- package/lib/commands/delete-args.js.map +1 -0
- package/lib/commands/delete.d.ts +30 -0
- package/lib/commands/delete.d.ts.map +1 -0
- package/lib/commands/delete.js +32 -0
- package/lib/commands/delete.js.map +1 -0
- package/lib/commands/generate-ast-builder.d.ts +1 -1
- package/lib/commands/generate-ast-builder.d.ts.map +1 -1
- package/lib/commands/generate-ast-builder.js +2 -11
- package/lib/commands/generate-ast-builder.js.map +1 -1
- package/lib/commands/generate-languages.d.ts +35 -0
- package/lib/commands/generate-languages.d.ts.map +1 -0
- package/lib/commands/generate-languages.js +105 -0
- package/lib/commands/generate-languages.js.map +1 -0
- package/lib/commands/generate-transfer-builder.d.ts +33 -0
- package/lib/commands/generate-transfer-builder.d.ts.map +1 -0
- package/lib/commands/generate-transfer-builder.js +86 -0
- package/lib/commands/generate-transfer-builder.js.map +1 -0
- package/lib/commands/generate-transfer-model-args.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model-args.js +20 -5
- package/lib/commands/generate-transfer-model-args.js.map +1 -1
- package/lib/commands/generate-transfer-model-config.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model-config.js +8 -3
- package/lib/commands/generate-transfer-model-config.js.map +1 -1
- package/lib/commands/generate-transfer-model.d.ts +41 -9
- package/lib/commands/generate-transfer-model.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model.js +225 -68
- package/lib/commands/generate-transfer-model.js.map +1 -1
- package/lib/commands/generated-module-path.d.ts +16 -0
- package/lib/commands/generated-module-path.d.ts.map +1 -0
- package/lib/commands/generated-module-path.js +21 -0
- package/lib/commands/generated-module-path.js.map +1 -0
- package/lib/commands/harness-args.d.ts +46 -43
- package/lib/commands/harness-args.d.ts.map +1 -1
- package/lib/commands/harness-args.js +170 -29
- package/lib/commands/harness-args.js.map +1 -1
- package/lib/commands/headless-harness.d.ts +37 -20
- package/lib/commands/headless-harness.d.ts.map +1 -1
- package/lib/commands/headless-harness.js +71 -19
- package/lib/commands/headless-harness.js.map +1 -1
- package/lib/commands/init-args.d.ts +5 -18
- package/lib/commands/init-args.d.ts.map +1 -1
- package/lib/commands/init-args.js +131 -35
- package/lib/commands/init-args.js.map +1 -1
- package/lib/commands/init-hosts.d.ts +24 -0
- package/lib/commands/init-hosts.d.ts.map +1 -0
- package/lib/commands/init-hosts.js +37 -0
- package/lib/commands/init-hosts.js.map +1 -0
- package/lib/commands/init-prompt.d.ts +3 -3
- package/lib/commands/init-prompt.d.ts.map +1 -1
- package/lib/commands/init-prompt.js +4 -5
- package/lib/commands/init-prompt.js.map +1 -1
- package/lib/commands/init-skills.d.ts +41 -0
- package/lib/commands/init-skills.d.ts.map +1 -0
- package/lib/commands/init-skills.js +110 -0
- package/lib/commands/init-skills.js.map +1 -0
- package/lib/commands/init-templates.d.ts +20 -14
- package/lib/commands/init-templates.d.ts.map +1 -1
- package/lib/commands/init-templates.js +3134 -763
- package/lib/commands/init-templates.js.map +1 -1
- package/lib/commands/init-wizard.d.ts +10 -0
- package/lib/commands/init-wizard.d.ts.map +1 -1
- package/lib/commands/init-wizard.js +76 -31
- package/lib/commands/init-wizard.js.map +1 -1
- package/lib/commands/init-workspace.d.ts +13 -11
- package/lib/commands/init-workspace.d.ts.map +1 -1
- package/lib/commands/init-workspace.js +21 -7
- package/lib/commands/init-workspace.js.map +1 -1
- package/lib/commands/init.d.ts +61 -24
- package/lib/commands/init.d.ts.map +1 -1
- package/lib/commands/init.js +244 -50
- package/lib/commands/init.js.map +1 -1
- package/lib/commands/kebab.d.ts +15 -0
- package/lib/commands/kebab.d.ts.map +1 -0
- package/lib/commands/kebab.js +17 -0
- package/lib/commands/kebab.js.map +1 -0
- package/lib/commands/lint-grammar-args.d.ts +3 -2
- package/lib/commands/lint-grammar-args.d.ts.map +1 -1
- package/lib/commands/lint-grammar-args.js +14 -11
- package/lib/commands/lint-grammar-args.js.map +1 -1
- package/lib/commands/lint-grammar-driver.js +2 -1
- package/lib/commands/lint-grammar-driver.js.map +1 -1
- package/lib/commands/lint-grammar-report.js.map +1 -1
- package/lib/commands/lint-grammar.js +1 -1
- package/lib/commands/lint-grammar.js.map +1 -1
- package/lib/commands/measure-memory-args.d.ts +3 -2
- package/lib/commands/measure-memory-args.d.ts.map +1 -1
- package/lib/commands/measure-memory-args.js +26 -14
- package/lib/commands/measure-memory-args.js.map +1 -1
- package/lib/commands/measure-memory-driver.js +5 -3
- package/lib/commands/measure-memory-driver.js.map +1 -1
- package/lib/commands/measure-memory.d.ts +1 -1
- package/lib/commands/measure-memory.d.ts.map +1 -1
- package/lib/commands/measure-memory.js +6 -3
- package/lib/commands/measure-memory.js.map +1 -1
- package/lib/commands/message-catalogue-args.d.ts +16 -0
- package/lib/commands/message-catalogue-args.d.ts.map +1 -0
- package/lib/commands/message-catalogue-args.js +53 -0
- package/lib/commands/message-catalogue-args.js.map +1 -0
- package/lib/commands/message-catalogue.d.ts +21 -0
- package/lib/commands/message-catalogue.d.ts.map +1 -0
- package/lib/commands/message-catalogue.js +48 -0
- package/lib/commands/message-catalogue.js.map +1 -0
- package/lib/commands/model-docs-args.d.ts +4 -3
- package/lib/commands/model-docs-args.d.ts.map +1 -1
- package/lib/commands/model-docs-args.js +13 -11
- package/lib/commands/model-docs-args.js.map +1 -1
- package/lib/commands/model-docs-driver.js +2 -1
- package/lib/commands/model-docs-driver.js.map +1 -1
- package/lib/commands/model-docs.js +1 -1
- package/lib/commands/model-docs.js.map +1 -1
- package/lib/commands/projects-args.d.ts.map +1 -1
- package/lib/commands/projects-args.js +5 -5
- package/lib/commands/projects-args.js.map +1 -1
- package/lib/commands/projects.d.ts +3 -4
- package/lib/commands/projects.d.ts.map +1 -1
- package/lib/commands/projects.js +2 -2
- package/lib/commands/projects.js.map +1 -1
- package/lib/commands/query-args.d.ts.map +1 -1
- package/lib/commands/query-args.js +6 -5
- package/lib/commands/query-args.js.map +1 -1
- package/lib/commands/query.d.ts +6 -5
- package/lib/commands/query.d.ts.map +1 -1
- package/lib/commands/query.js +5 -4
- package/lib/commands/query.js.map +1 -1
- package/lib/commands/reflect-args.d.ts +3 -2
- package/lib/commands/reflect-args.d.ts.map +1 -1
- package/lib/commands/reflect-args.js +14 -11
- package/lib/commands/reflect-args.js.map +1 -1
- package/lib/commands/reflect-driver.js +2 -1
- package/lib/commands/reflect-driver.js.map +1 -1
- package/lib/commands/reflect-report.js.map +1 -1
- package/lib/commands/reflect.js +1 -1
- package/lib/commands/reflect.js.map +1 -1
- package/lib/commands/save-args.d.ts.map +1 -1
- package/lib/commands/save-args.js +7 -4
- package/lib/commands/save-args.js.map +1 -1
- package/lib/commands/save.d.ts +8 -4
- package/lib/commands/save.d.ts.map +1 -1
- package/lib/commands/save.js +12 -23
- package/lib/commands/save.js.map +1 -1
- package/lib/commands/skills.d.ts +22 -0
- package/lib/commands/skills.d.ts.map +1 -0
- package/lib/commands/skills.js +129 -0
- package/lib/commands/skills.js.map +1 -0
- package/lib/commands/validate-args.d.ts +3 -2
- package/lib/commands/validate-args.d.ts.map +1 -1
- package/lib/commands/validate-args.js +14 -11
- package/lib/commands/validate-args.js.map +1 -1
- package/lib/commands/validate-driver.js +2 -1
- package/lib/commands/validate-driver.js.map +1 -1
- package/lib/commands/validate-report.js.map +1 -1
- package/lib/commands/validate.js +1 -1
- package/lib/commands/validate.js.map +1 -1
- package/lib/commands/watch-args.d.ts.map +1 -1
- package/lib/commands/watch-args.js +6 -4
- package/lib/commands/watch-args.js.map +1 -1
- package/lib/commands/watch.d.ts +3 -4
- package/lib/commands/watch.d.ts.map +1 -1
- package/lib/commands/watch.js +5 -2
- package/lib/commands/watch.js.map +1 -1
- package/lib/driver-heap.d.ts +52 -0
- package/lib/driver-heap.d.ts.map +1 -0
- package/lib/driver-heap.js +51 -0
- package/lib/driver-heap.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/log-level.d.ts +21 -11
- package/lib/log-level.d.ts.map +1 -1
- package/lib/log-level.js +25 -14
- package/lib/log-level.js.map +1 -1
- package/lib/spawn-data-server.d.ts +9 -4
- package/lib/spawn-data-server.d.ts.map +1 -1
- package/lib/spawn-data-server.js +5 -4
- package/lib/spawn-data-server.js.map +1 -1
- package/lib/stderr-connection-logger.d.ts +12 -0
- package/lib/stderr-connection-logger.d.ts.map +1 -0
- package/lib/stderr-connection-logger.js +16 -0
- package/lib/stderr-connection-logger.js.map +1 -0
- package/lib/testing/echo-server.js +9 -1
- package/lib/testing/echo-server.js.map +1 -1
- package/package.json +99 -41
- package/src/cli.ts +11 -2
- package/src/commands/analyze-heap-args.ts +1 -2
- package/src/commands/analyze-heap.ts +4 -1
- package/src/commands/ast-ground-truth-args.ts +16 -13
- package/src/commands/ast-ground-truth-driver.ts +4 -2
- package/src/commands/ast-ground-truth.ts +1 -1
- package/src/commands/check-skills-args.ts +70 -0
- package/src/commands/client-session.ts +33 -0
- package/src/commands/create-args.ts +68 -0
- package/src/commands/create.ts +83 -0
- package/src/commands/delete-args.ts +64 -0
- package/src/commands/delete.ts +61 -0
- package/src/commands/generate-ast-builder.ts +2 -12
- package/src/commands/generate-languages.ts +132 -0
- package/src/commands/generate-transfer-builder.ts +101 -0
- package/src/commands/generate-transfer-model-args.ts +20 -5
- package/src/commands/generate-transfer-model-config.ts +8 -3
- package/src/commands/generate-transfer-model.ts +297 -66
- package/src/commands/generated-module-path.ts +22 -0
- package/src/commands/harness-args.ts +163 -33
- package/src/commands/headless-harness.ts +89 -28
- package/src/commands/init-args.ts +135 -35
- package/src/commands/init-hosts.ts +51 -0
- package/src/commands/init-prompt.ts +5 -6
- package/src/commands/init-skills.ts +129 -0
- package/src/commands/init-templates.ts +3326 -785
- package/src/commands/init-wizard.ts +97 -32
- package/src/commands/init-workspace.ts +31 -16
- package/src/commands/init.ts +311 -65
- package/src/commands/kebab.ts +17 -0
- package/src/commands/lint-grammar-args.ts +18 -14
- package/src/commands/lint-grammar-driver.ts +2 -1
- package/src/commands/lint-grammar.ts +1 -1
- package/src/commands/measure-memory-args.ts +31 -17
- package/src/commands/measure-memory-driver.ts +5 -3
- package/src/commands/measure-memory.ts +6 -3
- package/src/commands/message-catalogue-args.ts +55 -0
- package/src/commands/message-catalogue.ts +56 -0
- package/src/commands/model-docs-args.ts +17 -14
- package/src/commands/model-docs-driver.ts +2 -1
- package/src/commands/model-docs.ts +1 -1
- package/src/commands/projects-args.ts +5 -4
- package/src/commands/projects.ts +4 -6
- package/src/commands/query-args.ts +6 -4
- package/src/commands/query.ts +9 -9
- package/src/commands/reflect-args.ts +18 -14
- package/src/commands/reflect-driver.ts +2 -1
- package/src/commands/reflect.ts +1 -1
- package/src/commands/save-args.ts +7 -3
- package/src/commands/save.ts +24 -27
- package/src/commands/skills.ts +146 -0
- package/src/commands/validate-args.ts +18 -14
- package/src/commands/validate-driver.ts +2 -1
- package/src/commands/validate.ts +1 -1
- package/src/commands/watch-args.ts +6 -3
- package/src/commands/watch.ts +7 -6
- package/src/driver-heap.ts +65 -0
- package/src/index.ts +3 -0
- package/src/log-level.ts +42 -14
- package/src/spawn-data-server.ts +17 -5
- package/src/stderr-connection-logger.ts +18 -0
- package/src/testing/echo-server.ts +11 -2
- package/templates/client/gitignore +3 -0
- package/templates/client/src/__GRAMMAR_ID__-diagram-module.ts +82 -0
- package/templates/editorconfig +15 -0
- package/templates/gitignore +1 -0
- package/templates/host-browser/esbuild.mjs +82 -0
- package/templates/host-browser/gitignore +4 -0
- package/templates/host-browser/hydranium-mark.svg +40 -0
- package/templates/host-browser/index.html +287 -0
- package/templates/host-browser/playwright.config.mts +24 -0
- package/templates/host-browser/src/data-status.ts +15 -0
- package/templates/host-browser/src/diagram-save.ts +60 -0
- package/templates/host-browser/src/diagram.ts +121 -0
- package/templates/host-browser/src/editor.ts +116 -0
- package/templates/host-browser/src/log.ts +14 -0
- package/templates/host-browser/src/monaco-editor-core-worker.d.ts +7 -0
- package/templates/host-browser/src/monaco-editor-worker.ts +10 -0
- package/templates/host-browser/src/posix-path-shim.ts +23 -0
- package/templates/host-browser/src/shown-file.ts +61 -0
- package/templates/host-browser/src/workspace.ts +5 -0
- package/templates/host-browser/tsconfig.e2e.json +16 -0
- package/templates/host-browser/tsconfig.page.json +16 -0
- package/templates/host-browser/tsconfig.worker.json +16 -0
- package/templates/host-theia-browser/esbuild.mjs +24 -0
- package/templates/host-theia-browser/gitignore +9 -0
- package/templates/host-theia-browser/playwright.config.mts +42 -0
- package/templates/host-theia-browser/start.mjs +50 -0
- package/templates/host-theia-browser/tsconfig.e2e.json +16 -0
- package/templates/host-theia-electron/esbuild.mjs +27 -0
- package/templates/host-theia-electron/gitignore +8 -0
- package/templates/host-theia-electron/playwright.config.mts +12 -0
- package/templates/host-theia-electron/start.mjs +47 -0
- package/templates/host-theia-electron/tsconfig.e2e.json +16 -0
- package/templates/host-vscode/esbuild.mjs +38 -0
- package/templates/host-vscode/gitignore +7 -0
- package/templates/host-vscode/playwright.config.mts +14 -0
- package/templates/host-vscode/src/__GRAMMAR_ID__-diagram-editor.ts +19 -0
- package/templates/host-vscode/src/show-model-command.ts +24 -0
- package/templates/host-vscode/src/webview/__GRAMMAR_ID__-diagram.ts +18 -0
- package/templates/host-vscode/src/webview/diagram.css +40 -0
- package/templates/host-vscode/start.mjs +22 -0
- package/templates/host-vscode/test/content-server.cjs +40 -0
- package/templates/host-vscode/test/install-vscode.mts +21 -0
- package/templates/host-vscode/test/virtual-documents.spec.mts +28 -0
- package/templates/host-vscode/test/vscode-version.mts +10 -0
- package/templates/host-vscode/tsconfig.e2e.json +17 -0
- package/templates/host-vscode/tsconfig.json +19 -0
- package/templates/host-vscode/tsconfig.webview.json +17 -0
- package/templates/oxlintrc.json +4 -0
- package/templates/protocol/gitignore +3 -0
- package/templates/protocol/src/__GRAMMAR_ID__-diagram-types.ts +47 -0
- package/templates/server/gitignore +6 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/create-node-operation-handler.ts +62 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/delete-operation-handler.ts +63 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/gmodel-factory.ts +144 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/state.ts +18 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/storage.ts +16 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/submission-handler.ts +24 -0
- package/templates/server/src/grammar/common.langium +12 -0
- package/templates/server/src/language-server/__GRAMMAR_ID__-semantic-tokens.ts +10 -0
- package/templates/server/src/language-server/__GRAMMAR_ID__-serializer.ts +53 -0
- package/templates/server/src/language-server/__GRAMMAR_ID__-validation.ts +30 -0
- package/templates/server/src/language-server/ast.ts +23 -0
- package/templates/server/src/node/services.ts +16 -0
- package/templates/server/test/__GRAMMAR_ID__-diagram.test.ts +403 -0
- package/templates/server/test/__GRAMMAR_ID__-semantic-tokens.test.ts +34 -0
- package/templates/server/test/tsconfig.json +4 -0
- package/templates/server/tsconfig.test.json +10 -0
- package/templates/server/vitest.config.ts +14 -0
- package/templates/theia/gitignore +3 -0
- package/templates/theia/src/browser/__GRAMMAR_ID__-diagram-frontend-module.ts +65 -0
- package/templates/theia/src/browser/__PROJECT_ID__-connection-preload-module.ts +15 -0
- package/templates/theia/src/browser/__PROJECT_ID__-data-connection.ts +15 -0
- package/templates/theia/src/browser/__PROJECT_ID__-data-port.ts +11 -0
- package/templates/theia/src/browser/__PROJECT_ID__-glsp-client-contribution.ts +13 -0
- package/templates/theia/src/browser/__PROJECT_ID__-show-model-command.ts +51 -0
- package/templates/theia/src/common/__PROJECT_ID__-glsp-contribution.ts +3 -0
- package/templates/theia/src/node/__PROJECT_ID__-connection-backend-module.ts +12 -0
- package/templates/theia/src/node/__PROJECT_ID__-data-backend-module.ts +15 -0
- package/templates/theia/src/node/__PROJECT_ID__-glsp-backend-module.ts +16 -0
- package/templates/theia/style/diagram.css +20 -0
- package/templates/theia/tsconfig.json +24 -0
- package/templates/vscode-servers/gitignore +4 -0
- package/templates/vscode-servers/tsconfig.json +19 -0
- package/templates/workspace/nodes.__EXTENSION__ +5 -0
- package/templates/workspace/references.__EXTENSION__ +2 -0
package/src/commands/query.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import { TransferDocument, type TransferElement } from '@hydranium/protocol';
|
|
11
11
|
import type { DataServerProtocol } from '@hydranium/protocol/data';
|
|
12
|
-
import {
|
|
12
|
+
import { logEnv, type LogOptions } from '../log-level.js';
|
|
13
13
|
import { withDataServer } from '../spawn-data-server.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -17,17 +17,17 @@ import { withDataServer } from '../spawn-data-server.js';
|
|
|
17
17
|
* current view of a document — invokes `getModelDocument({ uri })` on
|
|
18
18
|
* the spawned subprocess and writes the response envelope as a single
|
|
19
19
|
* JSON line. Adopters piping the output into `jq` get a complete record
|
|
20
|
-
* per invocation.
|
|
20
|
+
* per invocation. A URI the server holds no document at fails the command,
|
|
21
|
+
* since the server answers it with an envelope of the URI alone, which a
|
|
22
|
+
* script would read as a document.
|
|
21
23
|
*
|
|
22
24
|
* Test-only `__proxyForTest` bypasses the spawn for unit tests; the
|
|
23
25
|
* production CLI never passes it.
|
|
24
26
|
*/
|
|
25
|
-
export interface QueryCommandOptions {
|
|
27
|
+
export interface QueryCommandOptions extends LogOptions {
|
|
26
28
|
readonly serverCommand: string;
|
|
27
29
|
readonly serverArgs?: readonly string[];
|
|
28
30
|
readonly cwd?: string;
|
|
29
|
-
/** Log threshold for the spawned server, set on its `HYDRANIUM_LOG_LEVEL` env. */
|
|
30
|
-
readonly logLevel?: LogThreshold;
|
|
31
31
|
readonly uri: string;
|
|
32
32
|
readonly write?: (line: string) => void;
|
|
33
33
|
readonly __proxyForTest?: DataServerProtocol<TransferElement>;
|
|
@@ -39,7 +39,7 @@ export async function runQuery(options: QueryCommandOptions): Promise<void> {
|
|
|
39
39
|
if (options.__proxyForTest) {
|
|
40
40
|
// One-shot, unsubscribed read — request validation so the dumped envelope carries diagnostics.
|
|
41
41
|
const doc = await options.__proxyForTest.getModelDocument({ uri: options.uri, includeDiagnostics: true });
|
|
42
|
-
write(`${JSON.stringify(doc)}\n`);
|
|
42
|
+
write(`${JSON.stringify(TransferDocument.assertLoaded(doc))}\n`);
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -48,11 +48,11 @@ export async function runQuery(options: QueryCommandOptions): Promise<void> {
|
|
|
48
48
|
command: options.serverCommand,
|
|
49
49
|
args: options.serverArgs,
|
|
50
50
|
cwd: options.cwd,
|
|
51
|
-
env:
|
|
51
|
+
env: logEnv(options)
|
|
52
52
|
},
|
|
53
53
|
async server => {
|
|
54
54
|
const doc = await server.getModelDocument({ uri: options.uri, includeDiagnostics: true });
|
|
55
|
-
write(`${JSON.stringify(doc)}\n`);
|
|
55
|
+
write(`${JSON.stringify(TransferDocument.assertLoaded(doc))}\n`);
|
|
56
56
|
}
|
|
57
57
|
);
|
|
58
58
|
}
|
|
@@ -9,34 +9,36 @@
|
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
exitWithUsage,
|
|
12
|
+
HARNESS_VALUE_FLAGS,
|
|
12
13
|
helpRequested,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
importHelpLines,
|
|
15
|
+
LOG_VALUE_FLAGS,
|
|
16
|
+
logHelpLines,
|
|
17
|
+
logOptions,
|
|
16
18
|
parseHarnessArgs,
|
|
17
19
|
printHelp,
|
|
18
|
-
SERVICES_FLAG,
|
|
19
20
|
type UsageError
|
|
20
21
|
} from './harness-args.js';
|
|
21
22
|
import { OUT_FILE_FLAG } from './headless-harness.js';
|
|
22
23
|
import { runReflect, type ReflectCommandOptions } from './reflect.js';
|
|
23
24
|
|
|
24
|
-
const VALUE_FLAGS = [OUT_FILE_FLAG,
|
|
25
|
+
const VALUE_FLAGS = [OUT_FILE_FLAG, ...LOG_VALUE_FLAGS] as const;
|
|
25
26
|
const BOOL_FLAGS = ['--json'] as const;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Every flag `reflect` accepts, derived from the sets the parser is handed so
|
|
29
|
-
* the list cannot claim a flag the parser would reject.
|
|
30
|
-
* by the shared harness parser itself,
|
|
30
|
+
* the list cannot claim a flag the parser would reject.
|
|
31
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
32
|
+
* so they are in neither set.
|
|
31
33
|
*/
|
|
32
|
-
export const REFLECT_FLAGS: readonly string[] = [
|
|
34
|
+
export const REFLECT_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS, ...BOOL_FLAGS];
|
|
33
35
|
|
|
34
36
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
35
|
-
export const REFLECT_VALUE_FLAGS: readonly string[] = [
|
|
37
|
+
export const REFLECT_VALUE_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS];
|
|
36
38
|
|
|
37
39
|
/** The `--help` text, as data, held to {@link REFLECT_FLAGS} by a test. */
|
|
38
40
|
export const REFLECT_HELP: readonly string[] = [
|
|
39
|
-
'Usage: hydranium-cli reflect --services <module> [--json] [--out-file <file>] [--log-level <lvl>]',
|
|
41
|
+
'Usage: hydranium-cli reflect [--services <module>] [--import <specifier>]... [--json] [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
40
42
|
'',
|
|
41
43
|
"Dump a head's grammar/AST reflection — the type hierarchy, each language's",
|
|
42
44
|
'terminals and entry rule, and every cross-reference target. Read-only: no',
|
|
@@ -45,24 +47,26 @@ export const REFLECT_HELP: readonly string[] = [
|
|
|
45
47
|
'exporting a zero-arg `createServices(): { shared }` thunk. Needs @hydranium/core.',
|
|
46
48
|
'',
|
|
47
49
|
'Options:',
|
|
48
|
-
' --services <module> ESM module exporting `createServices(): { shared }` (required).',
|
|
50
|
+
' --services <module> ESM module exporting `createServices(): { shared }` (required) unless package.json sets hydranium.services.',
|
|
51
|
+
...importHelpLines(22),
|
|
49
52
|
' --json Emit the raw JSON reflection instead of the Markdown report.',
|
|
50
53
|
' --out-file <file> Write the report to this file instead of stdout. Written',
|
|
51
54
|
' only once the report exists, unlike a shell redirection,',
|
|
52
55
|
' which truncates the file before the head is even booted.',
|
|
53
|
-
|
|
56
|
+
...logHelpLines(22)
|
|
54
57
|
];
|
|
55
58
|
|
|
56
59
|
export function parseReflectArgs(args: string[], onError: UsageError = exitWithUsage): ReflectCommandOptions {
|
|
57
|
-
const { servicesModule, options } = parseHarnessArgs(args, 'reflect', VALUE_FLAGS, BOOL_FLAGS, {
|
|
60
|
+
const { servicesModule, imports, options } = parseHarnessArgs(args, 'reflect', VALUE_FLAGS, BOOL_FLAGS, {
|
|
58
61
|
requireWorkspace: false,
|
|
59
62
|
onError
|
|
60
63
|
});
|
|
61
64
|
return {
|
|
62
65
|
servicesModule,
|
|
66
|
+
imports,
|
|
63
67
|
json: options['--json'] === 'true',
|
|
64
68
|
outFile: options[OUT_FILE_FLAG],
|
|
65
|
-
|
|
69
|
+
...logOptions(options)
|
|
66
70
|
};
|
|
67
71
|
}
|
|
68
72
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* imported — only spawned.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { describeError } from '@hydranium/protocol';
|
|
19
20
|
import { emitReport, loadHeadlessContext, OUT_FILE_FLAG } from './headless-harness.js';
|
|
20
21
|
import { formatReflectionReport } from './reflect-report.js';
|
|
21
22
|
|
|
@@ -71,6 +72,6 @@ async function main(argv: string[]): Promise<number> {
|
|
|
71
72
|
main(process.argv.slice(2))
|
|
72
73
|
.then(code => process.exit(code))
|
|
73
74
|
.catch((error: unknown) => {
|
|
74
|
-
console.error(
|
|
75
|
+
console.error(describeError(error));
|
|
75
76
|
process.exit(1);
|
|
76
77
|
});
|
package/src/commands/reflect.ts
CHANGED
|
@@ -47,5 +47,5 @@ export function buildReflectDriverArgs(options: ReflectCommandOptions): string[]
|
|
|
47
47
|
* the binary language-agnostic.
|
|
48
48
|
*/
|
|
49
49
|
export function runReflect(options: ReflectCommandOptions): Promise<void> {
|
|
50
|
-
return runDriverChild([
|
|
50
|
+
return runDriverChild([DRIVER, ...buildReflectDriverArgs(options)], options);
|
|
51
51
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
assertRequired,
|
|
12
12
|
exitWithUsage,
|
|
13
13
|
helpRequested,
|
|
14
|
+
logHelpLines,
|
|
14
15
|
parseFlagOptions,
|
|
15
16
|
parseServerSpawnOptions,
|
|
16
17
|
printHelp,
|
|
@@ -36,9 +37,10 @@ export const SAVE_VALUE_FLAGS: readonly string[] = SAVE_FLAGS;
|
|
|
36
37
|
|
|
37
38
|
/** The `--help` text, as data, held to {@link SAVE_FLAGS} by a test. */
|
|
38
39
|
export const SAVE_HELP: readonly string[] = [
|
|
39
|
-
'Usage: hydranium-cli save --server "<cmd>..." --uri <uri> --content <text|@file> [--client-id <id>] [--cwd <dir>] [--log-level <level>]',
|
|
40
|
+
'Usage: hydranium-cli save --server "<cmd>..." --uri <uri> --content <text|@file> [--client-id <id>] [--cwd <dir>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
40
41
|
'',
|
|
41
42
|
'Update the document at `<uri>` with `<content>` and persist via saveModelDocument.',
|
|
43
|
+
'Fails when the file does not exist; `create` writes a new one.',
|
|
42
44
|
'Output is the post-save envelope as a single JSON line.',
|
|
43
45
|
'',
|
|
44
46
|
'Options:',
|
|
@@ -48,17 +50,19 @@ export const SAVE_HELP: readonly string[] = [
|
|
|
48
50
|
' (escape with `\\@` for literal `@`-leading content).',
|
|
49
51
|
' --client-id <id> clientId for authorship attribution. Default: hydranium-cli.',
|
|
50
52
|
' --cwd <dir> Working directory for the spawned child. Default: cwd.',
|
|
51
|
-
'
|
|
53
|
+
...logHelpLines(22, 'the spawned server')
|
|
52
54
|
];
|
|
53
55
|
|
|
54
56
|
export function parseSaveArgs(args: string[], onError: UsageError = exitWithUsage): SaveCommandOptions {
|
|
55
|
-
const { serverCommand, serverArgs, cwd, logLevel, extra } = parseServerSpawnOptions(args, 'save', onError);
|
|
57
|
+
const { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, extra } = parseServerSpawnOptions(args, 'save', onError);
|
|
56
58
|
const { uri, content, clientId } = parseFlagOptions(extra, 'save', OWN_FLAGS, onError);
|
|
57
59
|
return {
|
|
58
60
|
serverCommand,
|
|
59
61
|
serverArgs,
|
|
60
62
|
cwd,
|
|
61
63
|
logLevel,
|
|
64
|
+
logFile,
|
|
65
|
+
logFileLevel,
|
|
62
66
|
uri: assertRequired(uri, '--uri', 'save', onError),
|
|
63
67
|
content: assertRequired(content, '--content', 'save', onError),
|
|
64
68
|
clientId
|
package/src/commands/save.ts
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { TransferElement } from '@hydranium/protocol';
|
|
11
11
|
import type { DataServerProtocol } from '@hydranium/protocol/data';
|
|
12
|
-
import
|
|
13
|
-
import { logLevelEnv } from '../log-level.js';
|
|
12
|
+
import { logEnv, type LogOptions } from '../log-level.js';
|
|
14
13
|
import { withDataServer } from '../spawn-data-server.js';
|
|
14
|
+
import { withClientSession } from './client-session.js';
|
|
15
|
+
import { resolveContent } from './harness-args.js';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Options for the {@link runSave} subcommand. Updates the document at
|
|
@@ -23,13 +24,16 @@ import { withDataServer } from '../spawn-data-server.js';
|
|
|
23
24
|
*
|
|
24
25
|
* `clientId` defaults to `'hydranium-cli'` — adopters wanting a richer
|
|
25
26
|
* identity (per-user, per-script) override.
|
|
27
|
+
*
|
|
28
|
+
* The command saves as a client session under `clientId`: it registers the
|
|
29
|
+
* session, opens the document, saves, and ends the session, which leaves
|
|
30
|
+
* nothing open behind it. A missing file fails the open; `runCreate` writes a
|
|
31
|
+
* new one.
|
|
26
32
|
*/
|
|
27
|
-
export interface SaveCommandOptions {
|
|
33
|
+
export interface SaveCommandOptions extends LogOptions {
|
|
28
34
|
readonly serverCommand: string;
|
|
29
35
|
readonly serverArgs?: readonly string[];
|
|
30
36
|
readonly cwd?: string;
|
|
31
|
-
/** Log threshold for the spawned server, set on its `HYDRANIUM_LOG_LEVEL` env. */
|
|
32
|
-
readonly logLevel?: LogThreshold;
|
|
33
37
|
readonly uri: string;
|
|
34
38
|
/** Literal content text, or `@<path>` to read from a file. */
|
|
35
39
|
readonly content: string;
|
|
@@ -46,8 +50,7 @@ export async function runSave(options: SaveCommandOptions): Promise<void> {
|
|
|
46
50
|
const model = await resolveContent(options.content, options.__readFileForTest);
|
|
47
51
|
|
|
48
52
|
if (options.__proxyForTest) {
|
|
49
|
-
|
|
50
|
-
write(`${JSON.stringify(doc)}\n`);
|
|
53
|
+
write(`${JSON.stringify(await saveOpened(options.__proxyForTest, options.uri, clientId, model))}\n`);
|
|
51
54
|
return;
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -56,29 +59,23 @@ export async function runSave(options: SaveCommandOptions): Promise<void> {
|
|
|
56
59
|
command: options.serverCommand,
|
|
57
60
|
args: options.serverArgs,
|
|
58
61
|
cwd: options.cwd,
|
|
59
|
-
env:
|
|
62
|
+
env: logEnv(options)
|
|
60
63
|
},
|
|
61
64
|
async server => {
|
|
62
|
-
|
|
63
|
-
write(`${JSON.stringify(doc)}\n`);
|
|
65
|
+
write(`${JSON.stringify(await saveOpened(server, options.uri, clientId, model))}\n`);
|
|
64
66
|
}
|
|
65
67
|
);
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
if (content.startsWith('\\@')) {
|
|
81
|
-
return content.slice(1);
|
|
82
|
-
}
|
|
83
|
-
return content;
|
|
70
|
+
/** Open `uri` as the session `clientId` and save `model` to it, then end the session. */
|
|
71
|
+
function saveOpened(
|
|
72
|
+
server: Pick<DataServerProtocol<TransferElement>, 'createSession' | 'openModelDocument' | 'saveModelDocument' | 'closeSession'>,
|
|
73
|
+
uri: string,
|
|
74
|
+
clientId: string,
|
|
75
|
+
model: string
|
|
76
|
+
): Promise<unknown> {
|
|
77
|
+
return withClientSession(server, clientId, async () => {
|
|
78
|
+
await server.openModelDocument({ uri, clientId });
|
|
79
|
+
return server.saveModelDocument({ uri, clientId, model, baseVersion: 'any' });
|
|
80
|
+
});
|
|
84
81
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
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 * as fs from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import { createRequire } from 'node:module';
|
|
13
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
14
|
+
import { resolve } from 'import-meta-resolve';
|
|
15
|
+
import { parse } from 'yaml';
|
|
16
|
+
|
|
17
|
+
/** A compatibility result applies to one installed copy, not just its skill name. */
|
|
18
|
+
export interface SkillCompatibility {
|
|
19
|
+
readonly file: string;
|
|
20
|
+
readonly status: 'compatible' | 'incompatible' | 'unverified';
|
|
21
|
+
readonly detail: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const SKILL_DIRECTORIES = ['.agents/skills', '.claude/skills'] as const;
|
|
25
|
+
|
|
26
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
27
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Resolve from the adopter, never from a globally installed CLI's dependencies. */
|
|
31
|
+
export function installedPackageManifest(name: string, from: string): Record<string, unknown> | undefined {
|
|
32
|
+
const parent = path.join(path.resolve(from), 'package.json');
|
|
33
|
+
let manifest: string;
|
|
34
|
+
try {
|
|
35
|
+
manifest = createRequire(parent).resolve(`${name}/package.json`);
|
|
36
|
+
} catch {
|
|
37
|
+
try {
|
|
38
|
+
let directory = path.dirname(fileURLToPath(resolve(name, pathToFileURL(parent).href)));
|
|
39
|
+
while (true) {
|
|
40
|
+
const candidate = path.join(directory, 'package.json');
|
|
41
|
+
if (fs.existsSync(candidate)) {
|
|
42
|
+
const value: unknown = JSON.parse(fs.readFileSync(candidate, 'utf8'));
|
|
43
|
+
if (isRecord(value) && value.name === name) {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const next = path.dirname(directory);
|
|
48
|
+
if (next === directory) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
directory = next;
|
|
52
|
+
}
|
|
53
|
+
} catch {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const value: unknown = JSON.parse(fs.readFileSync(manifest, 'utf8'));
|
|
58
|
+
return isRecord(value) && value.name === name ? value : undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Missing or malformed requirements never constitute evidence of compatibility. */
|
|
62
|
+
export function checkSkill(file: string, from: string): SkillCompatibility {
|
|
63
|
+
const result = (status: SkillCompatibility['status'], detail: string): SkillCompatibility => ({ file, status, detail });
|
|
64
|
+
try {
|
|
65
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
66
|
+
const frontmatter = text.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/)?.[1];
|
|
67
|
+
const skill: unknown = frontmatter === undefined ? undefined : parse(frontmatter);
|
|
68
|
+
const metadata = isRecord(skill) ? skill.metadata : undefined;
|
|
69
|
+
if (!isRecord(metadata) || metadata['hydranium-compatibility-schema'] !== '1') {
|
|
70
|
+
return result('unverified', 'No supported Hydranium compatibility metadata.');
|
|
71
|
+
}
|
|
72
|
+
const encoded = metadata['hydranium-contracts'];
|
|
73
|
+
const contracts: unknown = typeof encoded === 'string' ? JSON.parse(encoded) : undefined;
|
|
74
|
+
if (
|
|
75
|
+
!isRecord(contracts) ||
|
|
76
|
+
Object.keys(contracts).length === 0 ||
|
|
77
|
+
Object.entries(contracts).some(
|
|
78
|
+
([name, declarations]) =>
|
|
79
|
+
!/^(@[a-z0-9._-]+\/)?[a-z0-9][a-z0-9._-]*$/.test(name) ||
|
|
80
|
+
!isRecord(declarations) ||
|
|
81
|
+
Object.keys(declarations).length === 0 ||
|
|
82
|
+
Object.entries(declarations).some(
|
|
83
|
+
([contract, revision]) => !contract.trim() || typeof revision !== 'string' || !revision.trim()
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
) {
|
|
87
|
+
return result('unverified', 'Invalid package contract requirements.');
|
|
88
|
+
}
|
|
89
|
+
const problems: string[] = [];
|
|
90
|
+
const versions: string[] = [];
|
|
91
|
+
let mismatch = false;
|
|
92
|
+
for (const [name, requiredContracts] of Object.entries(contracts)) {
|
|
93
|
+
const manifest = installedPackageManifest(name, from);
|
|
94
|
+
const version = manifest?.version;
|
|
95
|
+
const configuration = manifest?.hydranium;
|
|
96
|
+
const suppliedContracts = isRecord(configuration) ? configuration.skillContracts : undefined;
|
|
97
|
+
const contractMatches =
|
|
98
|
+
isRecord(requiredContracts) &&
|
|
99
|
+
isRecord(suppliedContracts) &&
|
|
100
|
+
Object.entries(requiredContracts).every(
|
|
101
|
+
([contract, revision]) => Object.hasOwn(suppliedContracts, contract) && suppliedContracts[contract] === revision
|
|
102
|
+
);
|
|
103
|
+
if (manifest === undefined) {
|
|
104
|
+
problems.push(`${name} is not installed; install dependencies and retry.`);
|
|
105
|
+
} else if (!contractMatches) {
|
|
106
|
+
mismatch = true;
|
|
107
|
+
problems.push(`${name} does not declare the required skill contracts.`);
|
|
108
|
+
} else {
|
|
109
|
+
versions.push(`${name}${typeof version === 'string' ? `@${version}` : ''} (declared skill contract)`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return problems.length > 0
|
|
113
|
+
? result(mismatch ? 'incompatible' : 'unverified', problems.join(' '))
|
|
114
|
+
: result('compatible', `Declared requirements satisfied by ${versions.join(', ')}.`);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
return result('unverified', error instanceof Error ? error.message : String(error));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Check every selected copy so an outdated agent-specific copy cannot hide behind a shared one. */
|
|
121
|
+
export function checkSkills(project: string, from = project, names?: readonly string[]): SkillCompatibility[] {
|
|
122
|
+
const results: SkillCompatibility[] = [];
|
|
123
|
+
const found = new Set<string>();
|
|
124
|
+
for (const directory of SKILL_DIRECTORIES) {
|
|
125
|
+
const root = path.join(project, directory);
|
|
126
|
+
if (!fs.existsSync(root)) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
for (const name of fs.readdirSync(root)) {
|
|
130
|
+
if (!(names ? names.includes(name) : name.startsWith('hydranium-'))) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
found.add(name);
|
|
134
|
+
results.push(checkSkill(path.join(root, name, 'SKILL.md'), from));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const name of names ?? []) {
|
|
138
|
+
if (!found.has(name)) {
|
|
139
|
+
results.push({ file: name, status: 'unverified', detail: 'Skill is not installed in a checked project directory.' });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (results.length === 0) {
|
|
143
|
+
results.push({ file: project, status: 'unverified', detail: 'No Hydranium project skills found.' });
|
|
144
|
+
}
|
|
145
|
+
return results;
|
|
146
|
+
}
|
|
@@ -9,34 +9,36 @@
|
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
exitWithUsage,
|
|
12
|
+
HARNESS_VALUE_FLAGS,
|
|
12
13
|
helpRequested,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
importHelpLines,
|
|
15
|
+
LOG_VALUE_FLAGS,
|
|
16
|
+
logHelpLines,
|
|
17
|
+
logOptions,
|
|
16
18
|
parseHarnessArgs,
|
|
17
19
|
printHelp,
|
|
18
|
-
SERVICES_FLAG,
|
|
19
20
|
type UsageError
|
|
20
21
|
} from './harness-args.js';
|
|
21
22
|
import { OUT_FILE_FLAG } from './headless-harness.js';
|
|
22
23
|
import { runValidate, type ValidateCommandOptions } from './validate.js';
|
|
23
24
|
|
|
24
|
-
const VALUE_FLAGS = [OUT_FILE_FLAG,
|
|
25
|
+
const VALUE_FLAGS = [OUT_FILE_FLAG, ...LOG_VALUE_FLAGS] as const;
|
|
25
26
|
const BOOL_FLAGS = ['--strict', '--json'] as const;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Every flag `validate` accepts, derived from the sets the parser is handed so
|
|
29
|
-
* the list cannot claim a flag the parser would reject.
|
|
30
|
-
* by the shared harness parser itself,
|
|
30
|
+
* the list cannot claim a flag the parser would reject.
|
|
31
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
32
|
+
* so they are in neither set.
|
|
31
33
|
*/
|
|
32
|
-
export const VALIDATE_FLAGS: readonly string[] = [
|
|
34
|
+
export const VALIDATE_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS, ...BOOL_FLAGS];
|
|
33
35
|
|
|
34
36
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
35
|
-
export const VALIDATE_VALUE_FLAGS: readonly string[] = [
|
|
37
|
+
export const VALIDATE_VALUE_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS];
|
|
36
38
|
|
|
37
39
|
/** The `--help` text, as data, held to {@link VALIDATE_FLAGS} by a test. */
|
|
38
40
|
export const VALIDATE_HELP: readonly string[] = [
|
|
39
|
-
'Usage: hydranium-cli validate --services <module> <workspace> [--strict] [--json] [--out-file <file>] [--log-level <lvl>]',
|
|
41
|
+
'Usage: hydranium-cli validate [--services <module>] [--import <specifier>]... <workspace> [--strict] [--json] [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
40
42
|
'',
|
|
41
43
|
'Build a workspace headlessly and report its validation diagnostics — a CI gate:',
|
|
42
44
|
'the process exits non-zero when any error is found. `<module>` is an ESM module',
|
|
@@ -44,7 +46,8 @@ export const VALIDATE_HELP: readonly string[] = [
|
|
|
44
46
|
'filesystem inside). Needs @hydranium/core.',
|
|
45
47
|
'',
|
|
46
48
|
'Options:',
|
|
47
|
-
' --services <module> ESM module exporting `createServices(): { shared }` (required).',
|
|
49
|
+
' --services <module> ESM module exporting `createServices(): { shared }` (required) unless package.json sets hydranium.services.',
|
|
50
|
+
...importHelpLines(22),
|
|
48
51
|
' <workspace> Workspace root (path or file URI) to validate (required).',
|
|
49
52
|
' --strict Also fail (non-zero exit) on warnings, not only errors.',
|
|
50
53
|
' --json Emit the raw JSON result instead of the human report.',
|
|
@@ -52,18 +55,19 @@ export const VALIDATE_HELP: readonly string[] = [
|
|
|
52
55
|
' still decides the exit code, and the file is written only',
|
|
53
56
|
' once the report exists, unlike a shell redirection, which',
|
|
54
57
|
' truncates the file before the workspace is even built.',
|
|
55
|
-
|
|
58
|
+
...logHelpLines(22)
|
|
56
59
|
];
|
|
57
60
|
|
|
58
61
|
export function parseValidateArgs(args: string[], onError: UsageError = exitWithUsage): ValidateCommandOptions {
|
|
59
|
-
const { servicesModule, workspace, options } = parseHarnessArgs(args, 'validate', VALUE_FLAGS, BOOL_FLAGS, { onError });
|
|
62
|
+
const { servicesModule, imports, workspace, options } = parseHarnessArgs(args, 'validate', VALUE_FLAGS, BOOL_FLAGS, { onError });
|
|
60
63
|
return {
|
|
61
64
|
servicesModule,
|
|
65
|
+
imports,
|
|
62
66
|
workspace,
|
|
63
67
|
strict: options['--strict'] === 'true',
|
|
64
68
|
json: options['--json'] === 'true',
|
|
65
69
|
outFile: options[OUT_FILE_FLAG],
|
|
66
|
-
|
|
70
|
+
...logOptions(options)
|
|
67
71
|
};
|
|
68
72
|
}
|
|
69
73
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* `--strict` also fails on warnings). Never imported — only spawned.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { describeError } from '@hydranium/protocol';
|
|
19
20
|
import { emitReport, loadHeadlessContext, OUT_FILE_FLAG } from './headless-harness.js';
|
|
20
21
|
import { formatValidationReport, validationExitCode } from './validate-report.js';
|
|
21
22
|
|
|
@@ -79,6 +80,6 @@ async function main(argv: string[]): Promise<number> {
|
|
|
79
80
|
main(process.argv.slice(2))
|
|
80
81
|
.then(code => process.exit(code))
|
|
81
82
|
.catch((error: unknown) => {
|
|
82
|
-
console.error(
|
|
83
|
+
console.error(describeError(error));
|
|
83
84
|
process.exit(1);
|
|
84
85
|
});
|
package/src/commands/validate.ts
CHANGED
|
@@ -54,5 +54,5 @@ export function buildValidateDriverArgs(options: ValidateCommandOptions): string
|
|
|
54
54
|
* The child's exit code propagates to this process so shells and CI see the gate.
|
|
55
55
|
*/
|
|
56
56
|
export function runValidate(options: ValidateCommandOptions): Promise<void> {
|
|
57
|
-
return runDriverChild([
|
|
57
|
+
return runDriverChild([DRIVER, ...buildValidateDriverArgs(options)], options);
|
|
58
58
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
assertRequired,
|
|
12
12
|
exitWithUsage,
|
|
13
13
|
helpRequested,
|
|
14
|
+
logHelpLines,
|
|
14
15
|
parseFlagOptions,
|
|
15
16
|
parseServerSpawnOptions,
|
|
16
17
|
printHelp,
|
|
@@ -35,7 +36,7 @@ export const WATCH_VALUE_FLAGS: readonly string[] = WATCH_FLAGS;
|
|
|
35
36
|
|
|
36
37
|
/** The `--help` text, as data, held to {@link WATCH_FLAGS} by a test. */
|
|
37
38
|
export const WATCH_HELP: readonly string[] = [
|
|
38
|
-
'Usage: hydranium-cli watch --server "<cmd>..." --uri <uri> [--client-id <id>] [--cwd <dir>] [--log-level <level>]',
|
|
39
|
+
'Usage: hydranium-cli watch --server "<cmd>..." --uri <uri> [--client-id <id>] [--cwd <dir>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
39
40
|
'',
|
|
40
41
|
'Subscribe to document updates at `<uri>` and print events as newline-delimited',
|
|
41
42
|
'JSON. Long-running — exits cleanly on SIGINT (Ctrl-C).',
|
|
@@ -45,18 +46,20 @@ export const WATCH_HELP: readonly string[] = [
|
|
|
45
46
|
' --uri <uri> Document URI (required).',
|
|
46
47
|
' --client-id <id> Subscriber identity. Default: hydranium-cli.',
|
|
47
48
|
' --cwd <dir> Working directory for the spawned child. Default: cwd.',
|
|
48
|
-
'
|
|
49
|
+
...logHelpLines(22, 'the spawned server')
|
|
49
50
|
];
|
|
50
51
|
|
|
51
52
|
/** Parse the argv; the abort signal is the entry point's to supply, not the command line's. */
|
|
52
53
|
export function parseWatchArgs(args: string[], onError: UsageError = exitWithUsage): WatchCommandOptions {
|
|
53
|
-
const { serverCommand, serverArgs, cwd, logLevel, extra } = parseServerSpawnOptions(args, 'watch', onError);
|
|
54
|
+
const { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, extra } = parseServerSpawnOptions(args, 'watch', onError);
|
|
54
55
|
const { uri, clientId } = parseFlagOptions(extra, 'watch', OWN_FLAGS, onError);
|
|
55
56
|
return {
|
|
56
57
|
serverCommand,
|
|
57
58
|
serverArgs,
|
|
58
59
|
cwd,
|
|
59
60
|
logLevel,
|
|
61
|
+
logFile,
|
|
62
|
+
logFileLevel,
|
|
60
63
|
uri: assertRequired(uri, '--uri', 'watch', onError),
|
|
61
64
|
clientId
|
|
62
65
|
};
|
package/src/commands/watch.ts
CHANGED
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { TransferElement } from '@hydranium/protocol';
|
|
11
11
|
import type {
|
|
12
12
|
DataClientProtocol,
|
|
13
13
|
DataServerProtocol,
|
|
14
14
|
TransferDocumentDeletedEvent,
|
|
15
15
|
TransferDocumentUpdatedEvent
|
|
16
16
|
} from '@hydranium/protocol/data';
|
|
17
|
-
import {
|
|
17
|
+
import { logEnv, type LogOptions } from '../log-level.js';
|
|
18
18
|
import { spawnDataServer } from '../spawn-data-server.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -27,12 +27,10 @@ import { spawnDataServer } from '../spawn-data-server.js';
|
|
|
27
27
|
* — production CLI wires SIGINT directly. `__handleForTest` bypasses
|
|
28
28
|
* the spawn step for unit tests.
|
|
29
29
|
*/
|
|
30
|
-
export interface WatchCommandOptions {
|
|
30
|
+
export interface WatchCommandOptions extends LogOptions {
|
|
31
31
|
readonly serverCommand: string;
|
|
32
32
|
readonly serverArgs?: readonly string[];
|
|
33
33
|
readonly cwd?: string;
|
|
34
|
-
/** Log threshold for the spawned server, set on its `HYDRANIUM_LOG_LEVEL` env. */
|
|
35
|
-
readonly logLevel?: LogThreshold;
|
|
36
34
|
readonly uri: string;
|
|
37
35
|
readonly clientId?: string;
|
|
38
36
|
readonly write?: (line: string) => void;
|
|
@@ -137,6 +135,9 @@ export async function runWatch(options: WatchCommandOptions): Promise<void> {
|
|
|
137
135
|
onDocumentSaved(): void {
|
|
138
136
|
// Persistence is out of band for the per-URI update view.
|
|
139
137
|
},
|
|
138
|
+
onDocumentDirtyChanged(): void {
|
|
139
|
+
// Out of band for the per-URI update view, as persistence is.
|
|
140
|
+
},
|
|
140
141
|
onDocumentDeleted(event: TransferDocumentDeletedEvent): void {
|
|
141
142
|
// In band, unlike the two neighbours: this is the end of the stream
|
|
142
143
|
// the view exists to show, and a consumer that never hears it waits
|
|
@@ -166,7 +167,7 @@ export async function runWatch(options: WatchCommandOptions): Promise<void> {
|
|
|
166
167
|
command: options.serverCommand,
|
|
167
168
|
args: options.serverArgs,
|
|
168
169
|
cwd: options.cwd,
|
|
169
|
-
env:
|
|
170
|
+
env: logEnv(options)
|
|
170
171
|
},
|
|
171
172
|
localClient
|
|
172
173
|
);
|