@hydranium/cli 1.0.0-next.212 → 1.0.0-next.214

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 (42) hide show
  1. package/README.md +8 -0
  2. package/lib/commands/ast-ground-truth-args.d.ts +3 -2
  3. package/lib/commands/ast-ground-truth-args.d.ts.map +1 -1
  4. package/lib/commands/ast-ground-truth-args.js +9 -7
  5. package/lib/commands/ast-ground-truth-args.js.map +1 -1
  6. package/lib/commands/harness-args.d.ts +18 -7
  7. package/lib/commands/harness-args.d.ts.map +1 -1
  8. package/lib/commands/harness-args.js +31 -13
  9. package/lib/commands/harness-args.js.map +1 -1
  10. package/lib/commands/headless-harness.d.ts +5 -2
  11. package/lib/commands/headless-harness.d.ts.map +1 -1
  12. package/lib/commands/headless-harness.js +50 -7
  13. package/lib/commands/headless-harness.js.map +1 -1
  14. package/lib/commands/lint-grammar-args.d.ts +3 -2
  15. package/lib/commands/lint-grammar-args.d.ts.map +1 -1
  16. package/lib/commands/lint-grammar-args.js +10 -7
  17. package/lib/commands/lint-grammar-args.js.map +1 -1
  18. package/lib/commands/measure-memory-args.d.ts +3 -2
  19. package/lib/commands/measure-memory-args.d.ts.map +1 -1
  20. package/lib/commands/measure-memory-args.js +10 -7
  21. package/lib/commands/measure-memory-args.js.map +1 -1
  22. package/lib/commands/model-docs-args.d.ts +4 -3
  23. package/lib/commands/model-docs-args.d.ts.map +1 -1
  24. package/lib/commands/model-docs-args.js +10 -8
  25. package/lib/commands/model-docs-args.js.map +1 -1
  26. package/lib/commands/reflect-args.d.ts +3 -2
  27. package/lib/commands/reflect-args.d.ts.map +1 -1
  28. package/lib/commands/reflect-args.js +10 -7
  29. package/lib/commands/reflect-args.js.map +1 -1
  30. package/lib/commands/validate-args.d.ts +3 -2
  31. package/lib/commands/validate-args.d.ts.map +1 -1
  32. package/lib/commands/validate-args.js +10 -7
  33. package/lib/commands/validate-args.js.map +1 -1
  34. package/package.json +9 -9
  35. package/src/commands/ast-ground-truth-args.ts +10 -7
  36. package/src/commands/harness-args.ts +36 -14
  37. package/src/commands/headless-harness.ts +54 -7
  38. package/src/commands/lint-grammar-args.ts +11 -7
  39. package/src/commands/measure-memory-args.ts +11 -7
  40. package/src/commands/model-docs-args.ts +11 -8
  41. package/src/commands/reflect-args.ts +11 -7
  42. package/src/commands/validate-args.ts +11 -7
@@ -9,13 +9,14 @@
9
9
 
10
10
  import {
11
11
  exitWithUsage,
12
+ HARNESS_VALUE_FLAGS,
12
13
  helpRequested,
14
+ importHelpLines,
13
15
  LOG_VALUE_FLAGS,
14
16
  logHelpLines,
15
17
  logOptions,
16
18
  parseHarnessArgs,
17
19
  printHelp,
18
- SERVICES_FLAG,
19
20
  type UsageError
20
21
  } from './harness-args.js';
21
22
  import { runLintGrammar, type LintGrammarCommandOptions } from './lint-grammar.js';
@@ -26,17 +27,18 @@ const REPEATABLE_VALUE_FLAGS = ['--name-property'] as const;
26
27
 
27
28
  /**
28
29
  * Every flag `lint-grammar` accepts, derived from the sets the parser is handed
29
- * so the list cannot claim a flag the parser would reject. `--services` is
30
- * consumed by the shared harness parser itself, so it is in neither set.
30
+ * so 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 LINT_GRAMMAR_FLAGS: readonly string[] = [SERVICES_FLAG, ...REPEATABLE_VALUE_FLAGS, ...VALUE_FLAGS, ...BOOL_FLAGS];
34
+ export const LINT_GRAMMAR_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...REPEATABLE_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 LINT_GRAMMAR_VALUE_FLAGS: readonly string[] = [SERVICES_FLAG, ...REPEATABLE_VALUE_FLAGS, ...VALUE_FLAGS];
37
+ export const LINT_GRAMMAR_VALUE_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...REPEATABLE_VALUE_FLAGS, ...VALUE_FLAGS];
36
38
 
37
39
  /** The `--help` text, as data, held to {@link LINT_GRAMMAR_FLAGS} by a test. */
38
40
  export const LINT_GRAMMAR_HELP: readonly string[] = [
39
- 'Usage: hydranium-cli lint-grammar --services <module> [--name-property <p>]... [--strict] [--json] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
41
+ 'Usage: hydranium-cli lint-grammar --services <module> [--import <specifier>]... [--name-property <p>]... [--strict] [--json] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
40
42
  '',
41
43
  "Check a head's grammar against the framework's conventions — a CI gate: the",
42
44
  'process exits non-zero when a violation is found. Read-only: no workspace is',
@@ -48,6 +50,7 @@ export const LINT_GRAMMAR_HELP: readonly string[] = [
48
50
  '',
49
51
  'Options:',
50
52
  ' --services <module> ESM module exporting `createServices(): { shared }` (required).',
53
+ ...importHelpLines(23),
51
54
  ' --name-property <p> Property that satisfies the nameability convention',
52
55
  ' (repeatable). Default: name.',
53
56
  ' --strict Also fail (non-zero exit) on warnings, not only errors.',
@@ -56,13 +59,14 @@ export const LINT_GRAMMAR_HELP: readonly string[] = [
56
59
  ];
57
60
 
58
61
  export function parseLintGrammarArgs(args: string[], onError: UsageError = exitWithUsage): LintGrammarCommandOptions {
59
- const { servicesModule, options, values } = parseHarnessArgs(args, 'lint-grammar', VALUE_FLAGS, BOOL_FLAGS, {
62
+ const { servicesModule, imports, options, values } = parseHarnessArgs(args, 'lint-grammar', VALUE_FLAGS, BOOL_FLAGS, {
60
63
  requireWorkspace: false,
61
64
  repeatableValueFlags: REPEATABLE_VALUE_FLAGS,
62
65
  onError
63
66
  });
64
67
  return {
65
68
  servicesModule,
69
+ imports,
66
70
  nameProperties: values['--name-property'],
67
71
  strict: options['--strict'] === 'true',
68
72
  json: options['--json'] === 'true',
@@ -9,7 +9,9 @@
9
9
 
10
10
  import {
11
11
  exitWithUsage,
12
+ HARNESS_VALUE_FLAGS,
12
13
  helpRequested,
14
+ importHelpLines,
13
15
  LOG_FILE_FLAG,
14
16
  LOG_VALUE_FLAGS,
15
17
  logHelpLines,
@@ -17,7 +19,6 @@ import {
17
19
  numericOption,
18
20
  parseHarnessArgs,
19
21
  printHelp,
20
- SERVICES_FLAG,
21
22
  type UsageError
22
23
  } from './harness-args.js';
23
24
  import { parseProfileDimensions, runMeasureMemory, type MeasureMemoryCommandOptions } from './measure-memory.js';
@@ -36,17 +37,18 @@ const BOOL_FLAGS = ['--snapshot', '--json'] as const;
36
37
 
37
38
  /**
38
39
  * Every flag `measure-memory` accepts, derived from the sets the parser is
39
- * handed so the list cannot claim a flag the parser would reject. `--services`
40
- * is consumed by the shared harness parser itself, so it is in neither set.
40
+ * handed so the list cannot claim a flag the parser would reject.
41
+ * {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
42
+ * so they are in neither set.
41
43
  */
42
- export const MEASURE_MEMORY_FLAGS: readonly string[] = [SERVICES_FLAG, ...VALUE_FLAGS, ...BOOL_FLAGS];
44
+ export const MEASURE_MEMORY_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS, ...BOOL_FLAGS];
43
45
 
44
46
  /** The subset that takes a value, so `--help` in a value position reads as data. */
45
- export const MEASURE_MEMORY_VALUE_FLAGS: readonly string[] = [SERVICES_FLAG, ...VALUE_FLAGS];
47
+ export const MEASURE_MEMORY_VALUE_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS];
46
48
 
47
49
  /** The `--help` text, as data, held to {@link MEASURE_MEMORY_FLAGS} by a test. */
48
50
  export const MEASURE_MEMORY_HELP: readonly string[] = [
49
- 'Usage: hydranium-cli measure-memory --services <module> <workspace> [options]',
51
+ 'Usage: hydranium-cli measure-memory --services <module> [--import <specifier>]... <workspace> [options]',
50
52
  '',
51
53
  'Measure model-store memory for a workspace. `<module>` is an ESM module that',
52
54
  'exports a zero-arg `createServices(): { shared }` thunk (the head wires its own',
@@ -55,6 +57,7 @@ export const MEASURE_MEMORY_HELP: readonly string[] = [
55
57
  '',
56
58
  'Options:',
57
59
  ' --services <module> ESM module exporting `createServices(): { shared }` (required).',
60
+ ...importHelpLines(22),
58
61
  ' <workspace> Workspace root (path or file URI) to build (required).',
59
62
  ' --edits <N> Rebuild-churn cycles to probe for retention. Default: 0 (skip).',
60
63
  ' --edit-docs <N> Documents to churn per cycle. Default: 25.',
@@ -100,7 +103,7 @@ function validatedProfile(csv: string | undefined, onError: UsageError): string
100
103
  }
101
104
 
102
105
  export function parseMeasureMemoryArgs(args: string[], onError: UsageError = exitWithUsage): MeasureMemoryCommandOptions {
103
- const { servicesModule, workspace, options } = parseHarnessArgs(args, 'measure-memory', VALUE_FLAGS, BOOL_FLAGS, { onError });
106
+ const { servicesModule, imports, workspace, options } = parseHarnessArgs(args, 'measure-memory', VALUE_FLAGS, BOOL_FLAGS, { onError });
104
107
  // The profiling session points the log at its own `server.log`, which would
105
108
  // replace the requested file without a word.
106
109
  if (options['--profile'] !== undefined && options[LOG_FILE_FLAG] !== undefined) {
@@ -108,6 +111,7 @@ export function parseMeasureMemoryArgs(args: string[], onError: UsageError = exi
108
111
  }
109
112
  return {
110
113
  servicesModule,
114
+ imports,
111
115
  workspace,
112
116
  editCycles: numericOption(options['--edits'], '--edits', onError),
113
117
  editDocs: numericOption(options['--edit-docs'], '--edit-docs', onError),
@@ -9,13 +9,14 @@
9
9
 
10
10
  import {
11
11
  exitWithUsage,
12
+ HARNESS_VALUE_FLAGS,
12
13
  helpRequested,
14
+ importHelpLines,
13
15
  LOG_VALUE_FLAGS,
14
16
  logHelpLines,
15
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';
@@ -24,18 +25,19 @@ import { runModelDocs, type ModelDocsCommandOptions } from './model-docs.js';
24
25
  const VALUE_FLAGS = [OUT_FILE_FLAG, ...LOG_VALUE_FLAGS] as const;
25
26
 
26
27
  /**
27
- * Every flag `model-docs` accepts, derived from the sets the parser is handed so
28
- * the list cannot claim a flag the parser would reject. `--services` is consumed
29
- * by the shared harness parser itself, so it is in neither set.
28
+ * Every flag `model-docs` accepts, derived from the sets the parser is handed
29
+ * 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 MODEL_DOCS_FLAGS: readonly string[] = [SERVICES_FLAG, ...VALUE_FLAGS];
33
+ export const MODEL_DOCS_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 MODEL_DOCS_VALUE_FLAGS: readonly string[] = MODEL_DOCS_FLAGS;
35
37
 
36
38
  /** The `--help` text, as data, held to {@link MODEL_DOCS_FLAGS} by a test. */
37
39
  export const MODEL_DOCS_HELP: readonly string[] = [
38
- 'Usage: hydranium-cli model-docs --services <module> [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
40
+ 'Usage: hydranium-cli model-docs --services <module> [--import <specifier>]... [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
39
41
  '',
40
42
  'Generate a navigable Markdown reference of every AST node type — a type index,',
41
43
  'cross-linked super/sub types, a reverse "referenced by" index, and a per-language',
@@ -46,6 +48,7 @@ export const MODEL_DOCS_HELP: readonly string[] = [
46
48
  '',
47
49
  'Options:',
48
50
  ' --services <module> ESM module exporting `createServices(): { shared }` (required).',
51
+ ...importHelpLines(22),
49
52
  ' --out-file <file> Write the Markdown to this file instead of stdout. Written',
50
53
  ' only once the report exists, unlike a shell redirection,',
51
54
  ' which truncates the file before the head is even booted.',
@@ -53,11 +56,11 @@ export const MODEL_DOCS_HELP: readonly string[] = [
53
56
  ];
54
57
 
55
58
  export function parseModelDocsArgs(args: string[], onError: UsageError = exitWithUsage): ModelDocsCommandOptions {
56
- const { servicesModule, options } = parseHarnessArgs(args, 'model-docs', VALUE_FLAGS, [], {
59
+ const { servicesModule, imports, options } = parseHarnessArgs(args, 'model-docs', VALUE_FLAGS, [], {
57
60
  requireWorkspace: false,
58
61
  onError
59
62
  });
60
- return { servicesModule, outFile: options[OUT_FILE_FLAG], ...logOptions(options) };
63
+ return { servicesModule, imports, outFile: options[OUT_FILE_FLAG], ...logOptions(options) };
61
64
  }
62
65
 
63
66
  export function runModelDocsCommand(args: string[]): Promise<void> {
@@ -9,13 +9,14 @@
9
9
 
10
10
  import {
11
11
  exitWithUsage,
12
+ HARNESS_VALUE_FLAGS,
12
13
  helpRequested,
14
+ importHelpLines,
13
15
  LOG_VALUE_FLAGS,
14
16
  logHelpLines,
15
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';
@@ -26,17 +27,18 @@ 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. `--services` is consumed
30
- * by the shared harness parser itself, so it is in neither set.
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[] = [SERVICES_FLAG, ...VALUE_FLAGS, ...BOOL_FLAGS];
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[] = [SERVICES_FLAG, ...VALUE_FLAGS];
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>] [--log-file <file>] [--log-file-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',
@@ -46,6 +48,7 @@ export const REFLECT_HELP: readonly string[] = [
46
48
  '',
47
49
  'Options:',
48
50
  ' --services <module> ESM module exporting `createServices(): { shared }` (required).',
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,',
@@ -54,12 +57,13 @@ export const REFLECT_HELP: readonly string[] = [
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)
@@ -9,13 +9,14 @@
9
9
 
10
10
  import {
11
11
  exitWithUsage,
12
+ HARNESS_VALUE_FLAGS,
12
13
  helpRequested,
14
+ importHelpLines,
13
15
  LOG_VALUE_FLAGS,
14
16
  logHelpLines,
15
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';
@@ -26,17 +27,18 @@ 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. `--services` is consumed
30
- * by the shared harness parser itself, so it is in neither set.
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[] = [SERVICES_FLAG, ...VALUE_FLAGS, ...BOOL_FLAGS];
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[] = [SERVICES_FLAG, ...VALUE_FLAGS];
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>] [--log-file <file>] [--log-file-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',
@@ -45,6 +47,7 @@ export const VALIDATE_HELP: readonly string[] = [
45
47
  '',
46
48
  'Options:',
47
49
  ' --services <module> ESM module exporting `createServices(): { shared }` (required).',
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.',
@@ -56,9 +59,10 @@ export const VALIDATE_HELP: readonly string[] = [
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',