@hydranium/cli 1.0.0-next.27 → 1.0.0-next.270
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 +73 -204
- package/bin/hydranium-cli.js +13 -0
- package/lib/cli-version.js.map +1 -1
- package/lib/cli.js +2 -1
- package/lib/cli.js.map +1 -1
- 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 +11 -9
- package/lib/commands/ast-ground-truth-args.js.map +1 -1
- package/lib/commands/ast-ground-truth-driver.js +2 -1
- 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/generate-ast-builder.d.ts +49 -0
- package/lib/commands/generate-ast-builder.d.ts.map +1 -0
- package/lib/commands/generate-ast-builder.js +200 -0
- package/lib/commands/generate-ast-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 +11 -1
- 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 +6 -3
- package/lib/commands/generate-transfer-model-config.js.map +1 -1
- package/lib/commands/generate-transfer-model.d.ts +9 -0
- package/lib/commands/generate-transfer-model.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model.js +18 -4
- package/lib/commands/generate-transfer-model.js.map +1 -1
- package/lib/commands/harness-args.d.ts +37 -42
- package/lib/commands/harness-args.d.ts.map +1 -1
- package/lib/commands/harness-args.js +91 -27
- 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 +68 -17
- package/lib/commands/headless-harness.js.map +1 -1
- package/lib/commands/init-args.js +6 -6
- package/lib/commands/init-args.js.map +1 -1
- package/lib/commands/init-prompt.d.ts.map +1 -1
- package/lib/commands/init-templates.d.ts +8 -10
- package/lib/commands/init-templates.d.ts.map +1 -1
- package/lib/commands/init-templates.js +260 -152
- package/lib/commands/init-templates.js.map +1 -1
- package/lib/commands/init-wizard.js +4 -4
- package/lib/commands/init-wizard.js.map +1 -1
- package/lib/commands/init-workspace.d.ts +13 -3
- package/lib/commands/init-workspace.d.ts.map +1 -1
- package/lib/commands/init-workspace.js +21 -6
- package/lib/commands/init-workspace.js.map +1 -1
- package/lib/commands/init.d.ts +16 -10
- package/lib/commands/init.d.ts.map +1 -1
- package/lib/commands/init.js +17 -15
- package/lib/commands/init.js.map +1 -1
- 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 +13 -10
- 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 +22 -11
- 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.js +1 -1
- package/lib/commands/measure-memory.js.map +1 -1
- 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 +12 -10
- 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 +5 -5
- package/lib/commands/query-args.js.map +1 -1
- package/lib/commands/query.d.ts +3 -4
- package/lib/commands/query.d.ts.map +1 -1
- package/lib/commands/query.js +2 -2
- 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 +13 -10
- 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 +6 -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 +31 -6
- package/lib/commands/save.js.map +1 -1
- 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 +13 -10
- 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 +20 -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 +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -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 +6 -1
- package/lib/spawn-data-server.d.ts.map +1 -1
- package/lib/spawn-data-server.js +2 -1
- 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 +50 -39
- package/src/cli.ts +2 -1
- package/src/commands/analyze-heap.ts +4 -1
- package/src/commands/ast-ground-truth-args.ts +15 -12
- package/src/commands/ast-ground-truth-driver.ts +2 -1
- package/src/commands/ast-ground-truth.ts +1 -1
- package/src/commands/generate-ast-builder.ts +246 -0
- package/src/commands/generate-transfer-model-args.ts +11 -1
- package/src/commands/generate-transfer-model-config.ts +6 -3
- package/src/commands/generate-transfer-model.ts +27 -4
- package/src/commands/harness-args.ts +76 -31
- package/src/commands/headless-harness.ts +86 -26
- package/src/commands/init-args.ts +6 -6
- package/src/commands/init-templates.ts +270 -154
- package/src/commands/init-wizard.ts +4 -4
- package/src/commands/init-workspace.ts +31 -7
- package/src/commands/init.ts +36 -26
- package/src/commands/lint-grammar-args.ts +17 -13
- package/src/commands/lint-grammar-driver.ts +2 -1
- package/src/commands/lint-grammar.ts +1 -1
- package/src/commands/measure-memory-args.ts +27 -14
- package/src/commands/measure-memory-driver.ts +5 -3
- package/src/commands/measure-memory.ts +1 -1
- package/src/commands/model-docs-args.ts +16 -13
- 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 +5 -4
- package/src/commands/query.ts +4 -6
- package/src/commands/reflect-args.ts +17 -13
- package/src/commands/reflect-driver.ts +2 -1
- package/src/commands/reflect.ts +1 -1
- package/src/commands/save-args.ts +6 -3
- package/src/commands/save.ts +47 -10
- package/src/commands/validate-args.ts +17 -13
- 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 +28 -7
- package/src/driver-heap.ts +65 -0
- package/src/index.ts +1 -0
- package/src/log-level.ts +42 -14
- package/src/spawn-data-server.ts +14 -2
- package/src/stderr-connection-logger.ts +18 -0
- package/src/testing/echo-server.ts +11 -2
package/src/log-level.ts
CHANGED
|
@@ -7,29 +7,47 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_LOG_FILE_ENV,
|
|
12
|
+
DEFAULT_LOG_FILE_LEVEL_ENV,
|
|
13
|
+
DEFAULT_LOG_LEVEL_ENV,
|
|
14
|
+
LEVEL_ORDER,
|
|
15
|
+
parseLogLevel,
|
|
16
|
+
type LogThreshold
|
|
17
|
+
} from '@hydranium/protocol';
|
|
18
|
+
|
|
19
|
+
/** The log flags every subcommand takes, as the env {@link logEnv} hands its child. */
|
|
20
|
+
export interface LogOptions {
|
|
21
|
+
/** Threshold for the client sink; the server's log-level setting replaces it. */
|
|
22
|
+
readonly logLevel?: LogThreshold;
|
|
23
|
+
/** File the server tees its log to; `{workspace}` expands once it is known. */
|
|
24
|
+
readonly logFile?: string;
|
|
25
|
+
/** The file's own threshold, which the log-level setting does not change. */
|
|
26
|
+
readonly logFileLevel?: LogThreshold;
|
|
27
|
+
}
|
|
11
28
|
|
|
12
29
|
/**
|
|
13
|
-
* Validate a raw `--log-level` argument into a
|
|
14
|
-
* an unrecognised value so the CLI's top-level
|
|
15
|
-
* and exits non-zero (mirroring how the other
|
|
16
|
-
* for the argv-supplied value; the resolved
|
|
17
|
-
* {@link
|
|
30
|
+
* Validate a raw `--log-level` / `--log-file-level` argument into a
|
|
31
|
+
* {@link LogThreshold}. Throws on an unrecognised value so the CLI's top-level
|
|
32
|
+
* `catch` surfaces a clean error and exits non-zero (mirroring how the other
|
|
33
|
+
* option parsers fail fast). Use for the argv-supplied value; the resolved
|
|
34
|
+
* threshold is handed to {@link logEnv} to target the spawned server.
|
|
18
35
|
*/
|
|
19
|
-
export function parseLogLevelOption(raw: string): LogThreshold {
|
|
36
|
+
export function parseLogLevelOption(raw: string, flag = '--log-level'): LogThreshold {
|
|
20
37
|
const level = parseLogLevel(raw);
|
|
21
38
|
if (!level) {
|
|
22
|
-
throw new Error(`Invalid
|
|
39
|
+
throw new Error(`Invalid ${flag}: ${raw} (expected one of: ${Object.keys(LEVEL_ORDER).join(', ')})`);
|
|
23
40
|
}
|
|
24
41
|
return level;
|
|
25
42
|
}
|
|
26
43
|
|
|
27
44
|
/**
|
|
28
45
|
* Build the environment override that targets *only the spawned server's* log
|
|
29
|
-
*
|
|
30
|
-
* `
|
|
31
|
-
*
|
|
32
|
-
*
|
|
46
|
+
* configuration, or `undefined` when no log flag was given. Passed to
|
|
47
|
+
* `spawnDataServer` as `env`, it sets the same `HYDRANIUM_LOG_LEVEL` /
|
|
48
|
+
* `HYDRANIUM_LOG_FILE` / `HYDRANIUM_LOG_FILE_LEVEL` variables the server reads
|
|
49
|
+
* at startup — the CLI's own logging is unaffected, unlike ambient variables
|
|
50
|
+
* that the child would inherit alongside the parent. The server owns *how* log level
|
|
33
51
|
* works; this only routes the CLI's request onto the channel it already reads.
|
|
34
52
|
*
|
|
35
53
|
* **The variable is read by `LspLogger`'s constructor**, which is bound on the
|
|
@@ -44,6 +62,16 @@ export function parseLogLevelOption(raw: string): LogThreshold {
|
|
|
44
62
|
* not go to stdout: that is the JSON-RPC channel, so a log line there would
|
|
45
63
|
* corrupt the very request this flag was set to diagnose.
|
|
46
64
|
*/
|
|
47
|
-
export function
|
|
48
|
-
|
|
65
|
+
export function logEnv(options: LogOptions): Record<string, string> | undefined {
|
|
66
|
+
const env: Record<string, string> = {};
|
|
67
|
+
if (options.logLevel !== undefined) {
|
|
68
|
+
env[DEFAULT_LOG_LEVEL_ENV] = options.logLevel;
|
|
69
|
+
}
|
|
70
|
+
if (options.logFile !== undefined) {
|
|
71
|
+
env[DEFAULT_LOG_FILE_ENV] = options.logFile;
|
|
72
|
+
}
|
|
73
|
+
if (options.logFileLevel !== undefined) {
|
|
74
|
+
env[DEFAULT_LOG_FILE_LEVEL_ENV] = options.logFileLevel;
|
|
75
|
+
}
|
|
76
|
+
return Object.keys(env).length > 0 ? env : undefined;
|
|
49
77
|
}
|
package/src/spawn-data-server.ts
CHANGED
|
@@ -15,7 +15,14 @@ import {
|
|
|
15
15
|
type DataServerProtocol
|
|
16
16
|
} from '@hydranium/protocol/data';
|
|
17
17
|
import { type ChildProcess, spawn } from 'node:child_process';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
StreamMessageReader,
|
|
20
|
+
StreamMessageWriter,
|
|
21
|
+
createMessageConnection,
|
|
22
|
+
type Logger as ConnectionLogger,
|
|
23
|
+
type MessageConnection
|
|
24
|
+
} from 'vscode-jsonrpc/node';
|
|
25
|
+
import { STDERR_CONNECTION_LOGGER } from './stderr-connection-logger.js';
|
|
19
26
|
|
|
20
27
|
/**
|
|
21
28
|
* Options for {@link spawnDataServer}. `command` is the binary or script
|
|
@@ -49,6 +56,11 @@ export interface SpawnDataServerOptions {
|
|
|
49
56
|
* scripted use; set to `'pipe'` to capture for assertion in tests.
|
|
50
57
|
*/
|
|
51
58
|
readonly stderr?: 'inherit' | 'ignore' | 'pipe';
|
|
59
|
+
/**
|
|
60
|
+
* Where the connection to the child logs its protocol faults, such as a
|
|
61
|
+
* response that matches no request. Default: this process's stderr.
|
|
62
|
+
*/
|
|
63
|
+
readonly logger?: ConnectionLogger;
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
/**
|
|
@@ -143,7 +155,7 @@ export function spawnDataServer<TTransfer extends TransferElement, TDiagnostic e
|
|
|
143
155
|
|
|
144
156
|
const reader = new StreamMessageReader(child.stdout);
|
|
145
157
|
const writer = new StreamMessageWriter(child.stdin);
|
|
146
|
-
const connection = createMessageConnection(reader, writer);
|
|
158
|
+
const connection = createMessageConnection(reader, writer, options.logger ?? STDERR_CONNECTION_LOGGER);
|
|
147
159
|
// Consume transport error / close so a child that dies mid-stream (its stdout
|
|
148
160
|
// closing, a write landing on a torn-down stdin) is observed here rather than
|
|
149
161
|
// escaping as an unhandled error — the death is reported via `whenTerminated`.
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { Logger as ConnectionLogger } from 'vscode-jsonrpc/node';
|
|
11
|
+
|
|
12
|
+
/** Every connection line goes to stderr: stdout carries the command's output or the protocol stream. */
|
|
13
|
+
export const STDERR_CONNECTION_LOGGER: ConnectionLogger = {
|
|
14
|
+
error: message => console.error(message),
|
|
15
|
+
warn: message => console.error(message),
|
|
16
|
+
info: message => console.error(message),
|
|
17
|
+
log: message => console.error(message)
|
|
18
|
+
};
|
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
|
|
21
21
|
import { DataServer } from '@hydranium/data-server';
|
|
22
22
|
import { makeTestServices } from '@hydranium/core/testing';
|
|
23
|
+
import { describeErrorWithStack } from '@hydranium/protocol';
|
|
23
24
|
import type { AstNode, URI } from '@hydranium/langium';
|
|
24
|
-
import { StreamMessageReader, StreamMessageWriter, createMessageConnection } from 'vscode-jsonrpc/node';
|
|
25
|
+
import { StreamMessageReader, StreamMessageWriter, createMessageConnection, type ResponseMessage } from 'vscode-jsonrpc/node';
|
|
26
|
+
import { STDERR_CONNECTION_LOGGER } from '../stderr-connection-logger.js';
|
|
25
27
|
|
|
26
28
|
interface FakeRoot extends AstNode {
|
|
27
29
|
readonly $type: 'FakeRoot';
|
|
@@ -72,7 +74,14 @@ function main(): void {
|
|
|
72
74
|
}
|
|
73
75
|
};
|
|
74
76
|
|
|
75
|
-
const
|
|
77
|
+
const writer = new StreamMessageWriter(process.stdout);
|
|
78
|
+
const connection = createMessageConnection(new StreamMessageReader(process.stdin), writer, STDERR_CONNECTION_LOGGER);
|
|
79
|
+
|
|
80
|
+
if (process.argv.includes('--send-response-without-id')) {
|
|
81
|
+
// A response the parent cannot match to a request, for its connection to log.
|
|
82
|
+
const response: ResponseMessage = { jsonrpc: '2.0', id: null, result: null };
|
|
83
|
+
writer.write(response).catch((error: unknown) => STDERR_CONNECTION_LOGGER.error(describeErrorWithStack(error)));
|
|
84
|
+
}
|
|
76
85
|
|
|
77
86
|
if (process.argv.includes('--exit-on-request')) {
|
|
78
87
|
// Fail-fast fixture mode: read a full request (the reader parses the whole
|