aontu 0.56.0 → 0.58.0
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 +2 -2
- package/dist/agentsmd.js +1 -1
- package/dist/alias.d.ts +3 -0
- package/dist/alias.js +59 -0
- package/dist/alias.js.map +1 -0
- package/dist/aontu.d.ts +5 -2
- package/dist/aontu.js +11 -3
- package/dist/aontu.js.map +1 -1
- package/dist/cli.d.ts +8 -2
- package/dist/cli.js +564 -21
- package/dist/cli.js.map +1 -1
- package/dist/ctx.d.ts +2 -0
- package/dist/ctx.js +1 -0
- package/dist/ctx.js.map +1 -1
- package/dist/escape.d.ts +5 -0
- package/dist/escape.js +455 -0
- package/dist/escape.js.map +1 -0
- package/dist/format.d.ts +9 -0
- package/dist/format.js +550 -55
- package/dist/format.js.map +1 -1
- package/dist/hints.js +74 -9
- package/dist/hints.js.map +1 -1
- package/dist/lang.js +374 -58
- package/dist/lang.js.map +1 -1
- package/dist/lower.d.ts +20 -0
- package/dist/lower.js +575 -0
- package/dist/lower.js.map +1 -0
- package/dist/lsp.d.ts +1 -1
- package/dist/lsp.js +4 -4
- package/dist/lsp.js.map +1 -1
- package/dist/mcp-server.js +2 -2
- package/dist/mcp-server.js.map +1 -1
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +40 -3
- package/dist/mcp.js.map +1 -1
- package/dist/mod-tool.js +8 -7
- package/dist/mod-tool.js.map +1 -1
- package/dist/mod.js +6 -6
- package/dist/mod.js.map +1 -1
- package/dist/render.d.ts +53 -0
- package/dist/render.js +542 -0
- package/dist/render.js.map +1 -0
- package/dist/sigdecl.js +1 -1
- package/dist/sigdecl.js.map +1 -1
- package/dist/std.d.ts +2 -0
- package/dist/std.js +498 -2
- package/dist/std.js.map +1 -1
- package/dist/template.d.ts +5 -0
- package/dist/template.js +257 -0
- package/dist/template.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/unify.js +43 -0
- package/dist/unify.js.map +1 -1
- package/dist/val/AggFuncVal.d.ts +1 -1
- package/dist/val/AggFuncVal.js +10 -21
- package/dist/val/AggFuncVal.js.map +1 -1
- package/dist/val/BagVal.js +1 -1
- package/dist/val/BagVal.js.map +1 -1
- package/dist/val/ConstraintVal.js +1 -1
- package/dist/val/EachFuncVal.d.ts +1 -1
- package/dist/val/EachFuncVal.js +9 -15
- package/dist/val/EachFuncVal.js.map +1 -1
- package/dist/val/EmitFuncVal.d.ts +42 -0
- package/dist/val/EmitFuncVal.js +531 -0
- package/dist/val/EmitFuncVal.js.map +1 -0
- package/dist/val/FilterFuncVal.js +9 -6
- package/dist/val/FilterFuncVal.js.map +1 -1
- package/dist/val/FormFuncVal.d.ts +14 -0
- package/dist/val/FormFuncVal.js +55 -0
- package/dist/val/FormFuncVal.js.map +1 -0
- package/dist/val/FuncBaseVal.d.ts +1 -0
- package/dist/val/FuncBaseVal.js +16 -0
- package/dist/val/FuncBaseVal.js.map +1 -1
- package/dist/val/MapVal.d.ts +2 -1
- package/dist/val/MapVal.js +2 -1
- package/dist/val/MapVal.js.map +1 -1
- package/dist/val/PackFuncVal.d.ts +1 -1
- package/dist/val/PackFuncVal.js +23 -20
- package/dist/val/PackFuncVal.js.map +1 -1
- package/dist/val/PlaceVal.d.ts +3 -1
- package/dist/val/PlaceVal.js +9 -6
- package/dist/val/PlaceVal.js.map +1 -1
- package/dist/val/RefVal.d.ts +3 -0
- package/dist/val/RefVal.js +156 -17
- package/dist/val/RefVal.js.map +1 -1
- package/dist/val/StrFuncVal.d.ts +32 -0
- package/dist/val/StrFuncVal.js +292 -0
- package/dist/val/StrFuncVal.js.map +1 -0
- package/dist/val/Val.d.ts +7 -1
- package/dist/val/Val.js +12 -1
- package/dist/val/Val.js.map +1 -1
- package/dist/val/members.d.ts +9 -0
- package/dist/val/members.js +52 -0
- package/dist/val/members.js.map +1 -0
- package/grammar/aontu.abnf +4 -3
- package/grammar/aontu.gbnf +4 -3
- package/grammar/aontu.lark +4 -3
- package/grammar/aontu.tmLanguage.json +1 -1
- package/package.json +1 -1
- package/skill/SKILL.md +4 -4
- package/skill/error-codes.md +1 -1
- package/skill/examples.md +1 -1
- package/skill/grammar-card.md +1 -1
- package/src/agentsmd.ts +1 -1
- package/src/alias.ts +112 -0
- package/src/aontu.ts +20 -2
- package/src/cli.ts +630 -23
- package/src/ctx.ts +13 -0
- package/src/escape.ts +371 -0
- package/src/format.ts +648 -56
- package/src/hints.ts +94 -9
- package/src/lang.ts +430 -63
- package/src/lower.ts +636 -0
- package/src/lsp.ts +4 -4
- package/src/mcp-server.ts +3 -2
- package/src/mcp.ts +43 -4
- package/src/mod-tool.ts +9 -8
- package/src/mod.ts +6 -6
- package/src/render.ts +727 -0
- package/src/sigdecl.ts +1 -1
- package/src/std.ts +506 -1
- package/src/template.ts +291 -0
- package/src/unify.ts +47 -0
- package/src/val/AggFuncVal.ts +10 -21
- package/src/val/BagVal.ts +1 -1
- package/src/val/ConstraintVal.ts +1 -1
- package/src/val/EachFuncVal.ts +9 -19
- package/src/val/EmitFuncVal.ts +738 -0
- package/src/val/FilterFuncVal.ts +12 -7
- package/src/val/FormFuncVal.ts +119 -0
- package/src/val/FuncBaseVal.ts +18 -0
- package/src/val/MapVal.ts +3 -2
- package/src/val/PackFuncVal.ts +24 -22
- package/src/val/PlaceVal.ts +9 -6
- package/src/val/RefVal.ts +167 -18
- package/src/val/StrFuncVal.ts +334 -0
- package/src/val/Val.ts +42 -1
- package/src/val/members.ts +86 -0
package/dist/cli.js
CHANGED
|
@@ -13,6 +13,8 @@ exports.runRelations = runRelations;
|
|
|
13
13
|
exports.runReaches = runReaches;
|
|
14
14
|
exports.runView = runView;
|
|
15
15
|
exports.runJsonSchema = runJsonSchema;
|
|
16
|
+
exports.runRender = runRender;
|
|
17
|
+
exports.runTemplate = runTemplate;
|
|
16
18
|
exports.runMod = runMod;
|
|
17
19
|
exports.runHash = runHash;
|
|
18
20
|
exports.runGet = runGet;
|
|
@@ -39,7 +41,11 @@ const node_path_1 = require("node:path");
|
|
|
39
41
|
const node_os_1 = require("node:os");
|
|
40
42
|
const node_readline_1 = require("node:readline");
|
|
41
43
|
const aontu_1 = require("./aontu");
|
|
44
|
+
const template_1 = require("./template");
|
|
45
|
+
const mcp_1 = require("./mcp");
|
|
42
46
|
const report_sarif_1 = require("./report-sarif");
|
|
47
|
+
const lsp_server_1 = require("./lsp-server");
|
|
48
|
+
const mcp_server_1 = require("./mcp-server");
|
|
43
49
|
const jsonschema_1 = require("./jsonschema");
|
|
44
50
|
const mod_tool_1 = require("./mod-tool");
|
|
45
51
|
const mod_1 = require("./mod");
|
|
@@ -59,15 +65,21 @@ const HELP = `Usage: aontu [options] [file]
|
|
|
59
65
|
aontu view <kind> [options] <file>...
|
|
60
66
|
aontu view --views <path> [--check] [options] <file>
|
|
61
67
|
aontu jsonschema [--at <path>] [--strict] [options] <file>
|
|
68
|
+
aontu render [--at <path>] [--profile <file>]... [--unit <path>]
|
|
69
|
+
[--stdout | --out <dir> | --check <dir> | --coverage]
|
|
70
|
+
[--coverage-at <path>] [--strict] <file>
|
|
71
|
+
aontu template [--resugar] [--check] [--marker <token>] <file>
|
|
62
72
|
aontu hash [options] <file>
|
|
63
73
|
aontu mod tidy|verify|vendor|manifest [options] [dir]
|
|
64
74
|
aontu get <path> [options] <file>
|
|
65
75
|
aontu why <path> [options] <file>
|
|
66
76
|
aontu set <path>=<value>... --entry <file> --overlay <file>
|
|
67
77
|
aontu agentsmd [--write <AGENTS.md>] <file>
|
|
68
|
-
aontu fmt [-w|-l|--check|-d] <file>...
|
|
78
|
+
aontu fmt [-w|-l|--check|-d|--lint] <file>...
|
|
79
|
+
aontu lsp
|
|
80
|
+
aontu mcp [--root <dir>]
|
|
69
81
|
|
|
70
|
-
Evaluate an
|
|
82
|
+
Evaluate an aontu source file and print the result as JSON.
|
|
71
83
|
With no file on an interactive terminal, start a REPL.
|
|
72
84
|
With no file and piped input, read the source from stdin.
|
|
73
85
|
|
|
@@ -99,10 +111,10 @@ Mod options:
|
|
|
99
111
|
|
|
100
112
|
Mod subcommands:
|
|
101
113
|
tidy Resolve the module closure by minimum version selection and
|
|
102
|
-
rewrite mod-lock.aon in canonical form
|
|
103
|
-
verify Check every locked module still means what
|
|
114
|
+
rewrite aontu_meta/mod-lock.aon in canonical form
|
|
115
|
+
verify Check every locked module still means what the lockfile
|
|
104
116
|
pins, and change nothing (the CI gate; tidy rewrites)
|
|
105
|
-
vendor Materialise the locked closure into
|
|
117
|
+
vendor Materialise the locked closure into aontu_meta/vendor/
|
|
106
118
|
manifest Print the OCI artifact a publish would push, gated on the
|
|
107
119
|
breaking check against --against
|
|
108
120
|
|
|
@@ -249,6 +261,51 @@ View exit codes: 0 rendered, 1 --check mismatch or lossy under
|
|
|
249
261
|
--strict, 2 usage or --max-rows exceeded, 4 the document does not stand
|
|
250
262
|
up on its own, or a relation, root or path that names nothing.
|
|
251
263
|
|
|
264
|
+
Render options:
|
|
265
|
+
--at <path> Render the value at this path ($.a.b); the root by
|
|
266
|
+
default
|
|
267
|
+
--profile <file> A profile document, profile: {lang, ...}, vetted
|
|
268
|
+
against aontu:profile; repeatable, one per language
|
|
269
|
+
--unit <path> Render only the unit with this path
|
|
270
|
+
--stdout One unit's bytes and nothing else (with --unit when
|
|
271
|
+
the instance has several)
|
|
272
|
+
--out <dir> Write every unit below dir, or nothing; never deletes
|
|
273
|
+
--check <dir> Compare every unit with dir/<path>; drift is listed
|
|
274
|
+
--coverage Report what the render read and what it did not:
|
|
275
|
+
model paths no output consumed, and rendered
|
|
276
|
+
declarations no rule produced. Writes nothing
|
|
277
|
+
--coverage-at <p> Measure coverage under this path only, instead of
|
|
278
|
+
the document root
|
|
279
|
+
--strict Refuse the opaque escapes (a text declaration, a raw
|
|
280
|
+
block)
|
|
281
|
+
--format <f> text (default) or json, the whole report; json
|
|
282
|
+
carries the dispatch trace, one entry per emitted
|
|
283
|
+
piece
|
|
284
|
+
|
|
285
|
+
Render exit codes: 0 rendered, 1 lossy under --strict or drift under
|
|
286
|
+
--check, 2 usage or I/O (a refused unit path included), 4 the document
|
|
287
|
+
does not stand up or the instance is not aontu:code.
|
|
288
|
+
|
|
289
|
+
A render entry file whose extension is not .aon is a TEMPLATE: a
|
|
290
|
+
generator in the target's own syntax, whose marker lines carry aontu
|
|
291
|
+
and whose other lines are output. It is desugared before it is
|
|
292
|
+
evaluated, and --marker names the marker for a language the table does
|
|
293
|
+
not know.
|
|
294
|
+
|
|
295
|
+
Template options:
|
|
296
|
+
--resugar The file is the canonical aontu; print the template
|
|
297
|
+
form instead of reading one
|
|
298
|
+
--check Desugar and resugar, and exit 1 if the file is not
|
|
299
|
+
what the round trip answers
|
|
300
|
+
--marker <t> The marker, when the extension does not name it
|
|
301
|
+
(default //-, and #- --- /*- by extension)
|
|
302
|
+
|
|
303
|
+
The template verb prints the canonical aontu form of a generator
|
|
304
|
+
written in the target's own syntax: a marked line is aontu source, and
|
|
305
|
+
every other line is a line of output.
|
|
306
|
+
|
|
307
|
+
Template exit codes: 0 written, 1 --check drift, 2 usage or I/O.
|
|
308
|
+
|
|
252
309
|
Set options:
|
|
253
310
|
--entry <file> The document the change is checked against
|
|
254
311
|
--overlay <file> The file the change is appended to (created if
|
|
@@ -283,12 +340,25 @@ Fmt options:
|
|
|
283
340
|
--check Like --list, and exit 1 when any would: the CI gate
|
|
284
341
|
-d, --diff Print a unified diff for each file whose form would
|
|
285
342
|
change
|
|
343
|
+
--lint Report the style findings, key case and repeated
|
|
344
|
+
shapes, on standard error, and print nothing else
|
|
345
|
+
--strict With --lint, and exit 1 when there is a finding
|
|
286
346
|
|
|
287
347
|
The fmt verb prints one document in the agreed form; with no file it
|
|
288
348
|
reads standard input. Several files need one of the options above.
|
|
289
349
|
|
|
290
|
-
Fmt exit codes: 0 formatted or clean, 1 a --check file would change
|
|
291
|
-
2 usage, 4 a document does not parse.
|
|
350
|
+
Fmt exit codes: 0 formatted or clean, 1 a --check file would change or
|
|
351
|
+
a --strict finding, 2 usage, 4 a document does not parse.
|
|
352
|
+
|
|
353
|
+
The lsp verb runs the language server over standard input and output
|
|
354
|
+
(LSP: JSON-RPC with Content-Length framing) until the client exits;
|
|
355
|
+
editors launch it with no arguments. The standalone aontu-lsp binary
|
|
356
|
+
runs the same server.
|
|
357
|
+
|
|
358
|
+
The mcp verb runs the Model Context Protocol server over standard
|
|
359
|
+
input and output (newline-delimited JSON-RPC), confined below --root
|
|
360
|
+
when one is given. It is part of the npm build, as the standalone
|
|
361
|
+
aontu-mcp binary is.
|
|
292
362
|
|
|
293
363
|
REPL commands:
|
|
294
364
|
:help Show REPL help
|
|
@@ -592,7 +662,7 @@ function runRepl(initialMode, jsonl, trust) {
|
|
|
592
662
|
prompt: jsonl ? '' : 'aontu> ',
|
|
593
663
|
});
|
|
594
664
|
if (!jsonl) {
|
|
595
|
-
process.stdout.write(`
|
|
665
|
+
process.stdout.write(`aontu v${version()} REPL — :help for commands, :quit to exit\n`);
|
|
596
666
|
}
|
|
597
667
|
rl.prompt();
|
|
598
668
|
rl.on('line', (line) => {
|
|
@@ -1666,6 +1736,14 @@ function runMod(argv) {
|
|
|
1666
1736
|
process.stderr.write(`aontu: mod needs tidy, verify, vendor or manifest\n${MOD_HELP}\n`);
|
|
1667
1737
|
return 2;
|
|
1668
1738
|
}
|
|
1739
|
+
// THE OLD LAYOUT IS NAMED, NOT READ. The lockfile and the vendored
|
|
1740
|
+
// closure moved under aontu_meta/; a project that still carries them
|
|
1741
|
+
// at its root would otherwise look untouched by any of these verbs,
|
|
1742
|
+
// which is the one silence worth breaking.
|
|
1743
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(dir, 'aon_vendor')) || (0, node_fs_1.existsSync)((0, node_path_1.join)(dir, 'mod-lock.aon'))) {
|
|
1744
|
+
process.stderr.write('aontu: aon_vendor/ and mod-lock.aon now live under aontu_meta/: ' +
|
|
1745
|
+
'move them, or run aontu mod tidy and aontu mod vendor\n');
|
|
1746
|
+
}
|
|
1669
1747
|
// `--against` gates a manifest and means nothing to the other two;
|
|
1670
1748
|
// accepting it there would say it had been honoured.
|
|
1671
1749
|
if (null != against && 'manifest' !== sub) {
|
|
@@ -2407,6 +2485,403 @@ function runJsonSchema(argv) {
|
|
|
2407
2485
|
strict && 'lossy' === report.verdict ? 1 : 0;
|
|
2408
2486
|
}
|
|
2409
2487
|
// ---------------------------------------------------------------------
|
|
2488
|
+
// THE RENDER VERB (docs/design/RENDER.0.md D8): evaluate a document,
|
|
2489
|
+
// vet the value at --at against aontu:code, fold code.units into bytes,
|
|
2490
|
+
// and put them where the flag says -- one unit on stdout, every unit
|
|
2491
|
+
// below --out (all or nothing), or compared against --check. Exit codes
|
|
2492
|
+
// mirror jsonschema's: 0 ok; 1 lossy under --strict or drift under
|
|
2493
|
+
// --check; 2 usage or I/O, a refused unit path included; 4 the
|
|
2494
|
+
// document does not stand up or the instance is not aontu:code.
|
|
2495
|
+
const RENDER_HELP = 'aontu render [--at <path>] [--profile <file>]... [--unit <path>] ' +
|
|
2496
|
+
'[--stdout | --out <dir> | --check <dir> | --coverage] ' +
|
|
2497
|
+
'[--coverage-at <path>] [--strict] [--marker <token>] <file> (try --help)';
|
|
2498
|
+
function runRender(argv) {
|
|
2499
|
+
const trusted = takeTrust(argv);
|
|
2500
|
+
if (null == trusted) {
|
|
2501
|
+
return 2;
|
|
2502
|
+
}
|
|
2503
|
+
argv = trusted.argv;
|
|
2504
|
+
const trust = trusted.trust;
|
|
2505
|
+
const files = [];
|
|
2506
|
+
const profileFiles = [];
|
|
2507
|
+
let format = 'text';
|
|
2508
|
+
let at = undefined;
|
|
2509
|
+
let unit = undefined;
|
|
2510
|
+
let out = undefined;
|
|
2511
|
+
let check = undefined;
|
|
2512
|
+
let toStdout = false;
|
|
2513
|
+
let strict = false;
|
|
2514
|
+
let coverage = false;
|
|
2515
|
+
let coverageAt = undefined;
|
|
2516
|
+
let marker = undefined;
|
|
2517
|
+
for (let i = 0; i < argv.length; i++) {
|
|
2518
|
+
const arg = argv[i];
|
|
2519
|
+
if ('-h' === arg || '--help' === arg) {
|
|
2520
|
+
process.stdout.write(HELP);
|
|
2521
|
+
return 0;
|
|
2522
|
+
}
|
|
2523
|
+
if ('--format' === arg) {
|
|
2524
|
+
const f = argv[++i];
|
|
2525
|
+
if ('text' !== f && 'json' !== f) {
|
|
2526
|
+
process.stderr.write('aontu: --format needs text or json\n');
|
|
2527
|
+
return 2;
|
|
2528
|
+
}
|
|
2529
|
+
format = f;
|
|
2530
|
+
}
|
|
2531
|
+
else if ('--at' === arg) {
|
|
2532
|
+
at = argv[++i];
|
|
2533
|
+
if (null == at) {
|
|
2534
|
+
process.stderr.write('aontu: --at needs a path\n');
|
|
2535
|
+
return 2;
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
else if ('--unit' === arg) {
|
|
2539
|
+
unit = argv[++i];
|
|
2540
|
+
if (null == unit) {
|
|
2541
|
+
process.stderr.write('aontu: --unit needs a unit path\n');
|
|
2542
|
+
return 2;
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
else if ('--profile' === arg) {
|
|
2546
|
+
const pf = argv[++i];
|
|
2547
|
+
if (null == pf) {
|
|
2548
|
+
process.stderr.write('aontu: --profile needs a file\n');
|
|
2549
|
+
return 2;
|
|
2550
|
+
}
|
|
2551
|
+
profileFiles.push(pf);
|
|
2552
|
+
}
|
|
2553
|
+
else if ('--out' === arg) {
|
|
2554
|
+
out = argv[++i];
|
|
2555
|
+
if (null == out) {
|
|
2556
|
+
process.stderr.write('aontu: --out needs a directory\n');
|
|
2557
|
+
return 2;
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
else if ('--check' === arg) {
|
|
2561
|
+
check = argv[++i];
|
|
2562
|
+
if (null == check) {
|
|
2563
|
+
process.stderr.write('aontu: --check needs a directory\n');
|
|
2564
|
+
return 2;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
else if ('--stdout' === arg) {
|
|
2568
|
+
toStdout = true;
|
|
2569
|
+
}
|
|
2570
|
+
else if ('--coverage' === arg) {
|
|
2571
|
+
coverage = true;
|
|
2572
|
+
}
|
|
2573
|
+
else if ('--marker' === arg) {
|
|
2574
|
+
marker = argv[++i];
|
|
2575
|
+
if (null == marker) {
|
|
2576
|
+
process.stderr.write('aontu: --marker needs a token\n');
|
|
2577
|
+
return 2;
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
else if ('--coverage-at' === arg) {
|
|
2581
|
+
coverageAt = argv[++i];
|
|
2582
|
+
if (null == coverageAt) {
|
|
2583
|
+
process.stderr.write('aontu: --coverage-at needs a path\n');
|
|
2584
|
+
return 2;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
else if ('--strict' === arg) {
|
|
2588
|
+
strict = true;
|
|
2589
|
+
}
|
|
2590
|
+
else if (arg.startsWith('-')) {
|
|
2591
|
+
process.stderr.write(`aontu: unknown render option ${arg} (try --help)\n`);
|
|
2592
|
+
return 2;
|
|
2593
|
+
}
|
|
2594
|
+
else {
|
|
2595
|
+
files.push(arg);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
if (1 !== files.length) {
|
|
2599
|
+
process.stderr.write(`aontu: render needs one file\n${RENDER_HELP}\n`);
|
|
2600
|
+
return 2;
|
|
2601
|
+
}
|
|
2602
|
+
const modes = [toStdout, undefined !== out, undefined !== check, coverage]
|
|
2603
|
+
.filter((on) => on).length;
|
|
2604
|
+
if (1 < modes) {
|
|
2605
|
+
process.stderr.write('aontu: render takes one of --stdout, --out, --check or --coverage\n');
|
|
2606
|
+
return 2;
|
|
2607
|
+
}
|
|
2608
|
+
// A NARROWER MEASURE NEEDS SOMETHING TO NARROW. `--coverage-at`
|
|
2609
|
+
// without `--coverage` asks for a report the run does not compute,
|
|
2610
|
+
// and answering silently would be the wrong half of the request.
|
|
2611
|
+
if (undefined !== coverageAt && !coverage) {
|
|
2612
|
+
process.stderr.write('aontu: --coverage-at needs --coverage\n');
|
|
2613
|
+
return 2;
|
|
2614
|
+
}
|
|
2615
|
+
let src;
|
|
2616
|
+
try {
|
|
2617
|
+
src = (0, node_fs_1.readFileSync)(files[0], 'utf8');
|
|
2618
|
+
}
|
|
2619
|
+
catch (err) {
|
|
2620
|
+
process.stderr.write(`aontu: cannot read ${err.path}: ${err.message}\n`);
|
|
2621
|
+
return 2;
|
|
2622
|
+
}
|
|
2623
|
+
// THE ENTRY MAY BE A TEMPLATE (TEMPLATE.0.md; P8), and its EXTENSION
|
|
2624
|
+
// decides, as an include's extension decides what the include is
|
|
2625
|
+
// (ADR-012): a generator is a file in the target's own syntax, so it
|
|
2626
|
+
// carries the target's extension and never `.aon`. Desugared here
|
|
2627
|
+
// rather than anywhere deeper, because a template is an entry
|
|
2628
|
+
// spelling and not a value: an include is still aontu.
|
|
2629
|
+
if (!files[0].endsWith('.aon')) {
|
|
2630
|
+
src = (0, template_1.desugarTemplate)(src, marker ?? (0, template_1.markerFor)(files[0]));
|
|
2631
|
+
}
|
|
2632
|
+
// THE PROFILES (D5): each --profile file is a document whose root is
|
|
2633
|
+
// `profile: {lang, ...}`, evaluated under the verb's trust and vetted
|
|
2634
|
+
// against aontu:profile as a settled value before the fold reads it
|
|
2635
|
+
// (renderProfile, which also fills the defaults). Two files claiming
|
|
2636
|
+
// one lang is a usage error: the fold could not choose.
|
|
2637
|
+
const profiles = [];
|
|
2638
|
+
const langs = new Map();
|
|
2639
|
+
for (const pf of profileFiles) {
|
|
2640
|
+
let text;
|
|
2641
|
+
try {
|
|
2642
|
+
text = (0, node_fs_1.readFileSync)(pf, 'utf8');
|
|
2643
|
+
}
|
|
2644
|
+
catch (err) {
|
|
2645
|
+
process.stderr.write(`aontu: cannot read ${err.path}: ${err.message}\n`);
|
|
2646
|
+
return 2;
|
|
2647
|
+
}
|
|
2648
|
+
const loaded = (0, aontu_1.renderProfile)(text, { path: (0, node_path_1.resolve)(pf), ...verbOpts(trust, entryRootOf(pf)) });
|
|
2649
|
+
if (undefined !== loaded.errors) {
|
|
2650
|
+
process.stderr.write(loaded.errors.map(renderFinding).join('\n') + '\n');
|
|
2651
|
+
return 4;
|
|
2652
|
+
}
|
|
2653
|
+
const profile = loaded.profile;
|
|
2654
|
+
const prev = langs.get(profile.lang);
|
|
2655
|
+
if (undefined !== prev) {
|
|
2656
|
+
process.stderr.write(`aontu: two profiles claim ${profile.lang}: ${prev} and ${pf}\n`);
|
|
2657
|
+
return 2;
|
|
2658
|
+
}
|
|
2659
|
+
langs.set(profile.lang, pf);
|
|
2660
|
+
profiles.push(profile);
|
|
2661
|
+
}
|
|
2662
|
+
const report = (0, aontu_1.render)(src, {
|
|
2663
|
+
at, unit, strict, profiles, path: files[0],
|
|
2664
|
+
coverage, coverageAt,
|
|
2665
|
+
// THE JSON REPORT CARRIES THE TRACE (D9), which is what the shape
|
|
2666
|
+
// there has always said; a text run computes it only when the
|
|
2667
|
+
// coverage report needs it.
|
|
2668
|
+
trace: 'json' === format,
|
|
2669
|
+
...verbOpts(trust, entryRootOf(files[0])),
|
|
2670
|
+
});
|
|
2671
|
+
if ('json' === format) {
|
|
2672
|
+
process.stdout.write((0, aontu_1.exactJSON)({
|
|
2673
|
+
aontu: { version: version(), verb: 'render' },
|
|
2674
|
+
verdict: report.verdict,
|
|
2675
|
+
units: report.units,
|
|
2676
|
+
lossy: report.lossy,
|
|
2677
|
+
...(null == report.errors ? {} : { errors: report.errors }),
|
|
2678
|
+
...(null == report.trace ? {} : { trace: report.trace }),
|
|
2679
|
+
...(null == report.coverage ? {} : { coverage: report.coverage }),
|
|
2680
|
+
}, 2) + '\n');
|
|
2681
|
+
return renderExit(report, 0);
|
|
2682
|
+
}
|
|
2683
|
+
if ('error' === report.verdict) {
|
|
2684
|
+
process.stderr.write(report.errors.map(renderFinding).join('\n') + '\n');
|
|
2685
|
+
return renderExit(report, 0);
|
|
2686
|
+
}
|
|
2687
|
+
let drift = 0;
|
|
2688
|
+
if (toStdout) {
|
|
2689
|
+
// ONE UNIT'S BYTES AND NOTHING ELSE, so the output can be piped
|
|
2690
|
+
// into a formatter or a file.
|
|
2691
|
+
if (1 !== report.units.length) {
|
|
2692
|
+
process.stderr.write('aontu: --stdout needs exactly one unit, and the instance has ' +
|
|
2693
|
+
`${report.units.length}; --unit names one\n`);
|
|
2694
|
+
return 2;
|
|
2695
|
+
}
|
|
2696
|
+
process.stdout.write(report.units[0].text);
|
|
2697
|
+
}
|
|
2698
|
+
else if (undefined !== out) {
|
|
2699
|
+
// EVERY UNIT BELOW <dir>, OR NOTHING: every unit rendered first
|
|
2700
|
+
// (the report above), and no file touched unless all did. The
|
|
2701
|
+
// directory is realpath-confined; a unit path is already a relative
|
|
2702
|
+
// descent (render_path refuses the rest), and the check here is
|
|
2703
|
+
// against the symlink inside it. render never deletes.
|
|
2704
|
+
for (const u of report.units) {
|
|
2705
|
+
if ((0, mcp_1.outsideRoot)(out, (0, node_path_1.resolve)(out, u.path))) {
|
|
2706
|
+
process.stderr.write(`aontu: ${u.path} escapes ${out}\n`);
|
|
2707
|
+
return 2;
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
for (const u of report.units) {
|
|
2711
|
+
const full = (0, node_path_1.resolve)(out, u.path);
|
|
2712
|
+
try {
|
|
2713
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(full), { recursive: true });
|
|
2714
|
+
(0, node_fs_1.writeFileSync)(full, u.text, 'utf8');
|
|
2715
|
+
}
|
|
2716
|
+
catch (err) {
|
|
2717
|
+
process.stderr.write(`aontu: cannot write ${u.path}: ${err.message}\n`);
|
|
2718
|
+
return 2;
|
|
2719
|
+
}
|
|
2720
|
+
process.stderr.write(`wrote ${u.path}\n`);
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
else if (undefined !== check) {
|
|
2724
|
+
// RENDER AND COMPARE: a unit whose bytes differ from the file at
|
|
2725
|
+
// <dir>/<path>, or whose file is absent, is drift, listed by path.
|
|
2726
|
+
// The CI form.
|
|
2727
|
+
for (const u of report.units) {
|
|
2728
|
+
let have = undefined;
|
|
2729
|
+
try {
|
|
2730
|
+
have = (0, node_fs_1.readFileSync)((0, node_path_1.resolve)(check, u.path), 'utf8');
|
|
2731
|
+
}
|
|
2732
|
+
catch {
|
|
2733
|
+
// Absent is drift, reported below.
|
|
2734
|
+
}
|
|
2735
|
+
if (undefined === have) {
|
|
2736
|
+
drift++;
|
|
2737
|
+
process.stderr.write(`aontu: ${u.path} is missing from ${check}\n`);
|
|
2738
|
+
}
|
|
2739
|
+
else if (have !== u.text) {
|
|
2740
|
+
drift++;
|
|
2741
|
+
process.stderr.write(`aontu: ${u.path} differs from the rendered unit\n`);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
else if (coverage) {
|
|
2746
|
+
// THE COVERAGE REPORT (P7), one line per finding and a count at
|
|
2747
|
+
// the end: dead model first, then the declarations no rule
|
|
2748
|
+
// produced. A clean report is the count line alone.
|
|
2749
|
+
const cov = report.coverage;
|
|
2750
|
+
for (const d of cov.dead) {
|
|
2751
|
+
process.stdout.write(`dead: ${d}\n`);
|
|
2752
|
+
}
|
|
2753
|
+
for (const u of cov.unruled) {
|
|
2754
|
+
process.stdout.write(`unruled: ${u.unit} ${u.path}\n`);
|
|
2755
|
+
}
|
|
2756
|
+
process.stdout.write(`coverage: ${cov.read.length} path(s) read, ${cov.dead.length} ` +
|
|
2757
|
+
`no output consumed, ${cov.unruled.length} declaration(s) ` +
|
|
2758
|
+
'no rule produced\n');
|
|
2759
|
+
}
|
|
2760
|
+
else {
|
|
2761
|
+
// THE SUMMARY: one line per unit -- its path, its language and its
|
|
2762
|
+
// size -- since several units have no one text to print.
|
|
2763
|
+
for (const u of report.units) {
|
|
2764
|
+
process.stdout.write(`${u.path}\t${u.lang}\t${u.text.length} bytes\n`);
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
for (const l of report.lossy) {
|
|
2768
|
+
process.stderr.write(`lossy: ${l.unit} ${l.path} tier ${l.tier} ${l.construct}: ${l.reason}\n`);
|
|
2769
|
+
}
|
|
2770
|
+
return renderExit(report, drift);
|
|
2771
|
+
}
|
|
2772
|
+
// D8's exit table over a report: a refused unit path is usage (2), a
|
|
2773
|
+
// strict refusal is lossy (1), any other error is the document's (4);
|
|
2774
|
+
// drift under --check is 1.
|
|
2775
|
+
function renderExit(report, drift) {
|
|
2776
|
+
if ('error' === report.verdict) {
|
|
2777
|
+
const errors = report.errors;
|
|
2778
|
+
if (errors.every((f) => 'render_path' === f.code)) {
|
|
2779
|
+
return 2;
|
|
2780
|
+
}
|
|
2781
|
+
if (errors.every((f) => 'render_strict' === f.code)) {
|
|
2782
|
+
return 1;
|
|
2783
|
+
}
|
|
2784
|
+
return 4;
|
|
2785
|
+
}
|
|
2786
|
+
return 0 < drift ? 1 : 0;
|
|
2787
|
+
}
|
|
2788
|
+
// ---------------------------------------------------------------------
|
|
2789
|
+
// THE TEMPLATE SURFACE (docs/design/TEMPLATE.0.md; RENDER.0.md P8): the
|
|
2790
|
+
// two transforms and the round trip between them. `render` reads a
|
|
2791
|
+
// template directly, by its extension; this verb is for seeing the
|
|
2792
|
+
// canonical form, for writing one by hand and sugaring it, and for the
|
|
2793
|
+
// check that keeps a committed template and its meaning in agreement.
|
|
2794
|
+
const TEMPLATE_HELP = 'aontu template [--resugar] [--check] [--marker <token>] <file> (try --help)';
|
|
2795
|
+
function runTemplate(argv) {
|
|
2796
|
+
const files = [];
|
|
2797
|
+
let resugar = false;
|
|
2798
|
+
let check = false;
|
|
2799
|
+
let marker = undefined;
|
|
2800
|
+
for (let i = 0; i < argv.length; i++) {
|
|
2801
|
+
const arg = argv[i];
|
|
2802
|
+
if ('-h' === arg || '--help' === arg) {
|
|
2803
|
+
process.stdout.write(HELP);
|
|
2804
|
+
return 0;
|
|
2805
|
+
}
|
|
2806
|
+
else if ('--resugar' === arg) {
|
|
2807
|
+
resugar = true;
|
|
2808
|
+
}
|
|
2809
|
+
else if ('--check' === arg) {
|
|
2810
|
+
check = true;
|
|
2811
|
+
}
|
|
2812
|
+
else if ('--marker' === arg) {
|
|
2813
|
+
marker = argv[++i];
|
|
2814
|
+
if (null == marker) {
|
|
2815
|
+
process.stderr.write('aontu: --marker needs a token\n');
|
|
2816
|
+
return 2;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
else if (arg.startsWith('-')) {
|
|
2820
|
+
process.stderr.write(`aontu: unknown template option ${arg} (try --help)\n`);
|
|
2821
|
+
return 2;
|
|
2822
|
+
}
|
|
2823
|
+
else {
|
|
2824
|
+
files.push(arg);
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
if (1 !== files.length) {
|
|
2828
|
+
process.stderr.write(`aontu: template needs one file\n${TEMPLATE_HELP}\n`);
|
|
2829
|
+
return 2;
|
|
2830
|
+
}
|
|
2831
|
+
// THE TWO ARE DIRECTIONS, NOT MODES THAT COMPOSE: `--check` reads a
|
|
2832
|
+
// template and asks whether the round trip answers it back, and
|
|
2833
|
+
// `--resugar` reads the canonical form instead. A run cannot be both
|
|
2834
|
+
// at once, because the file is one thing or the other.
|
|
2835
|
+
if (resugar && check) {
|
|
2836
|
+
process.stderr.write('aontu: template takes one of --resugar or --check\n');
|
|
2837
|
+
return 2;
|
|
2838
|
+
}
|
|
2839
|
+
let src;
|
|
2840
|
+
try {
|
|
2841
|
+
src = (0, node_fs_1.readFileSync)(files[0], 'utf8');
|
|
2842
|
+
}
|
|
2843
|
+
catch (err) {
|
|
2844
|
+
process.stderr.write(`aontu: cannot read ${err.path}: ${err.message}\n`);
|
|
2845
|
+
return 2;
|
|
2846
|
+
}
|
|
2847
|
+
const mark = marker ?? (0, template_1.markerFor)(files[0]);
|
|
2848
|
+
if (check) {
|
|
2849
|
+
// THE ROUND TRIP IS THE CHECK (D6): the file held to the spelling
|
|
2850
|
+
// the two transforms answer. What that names is a marker line the
|
|
2851
|
+
// transform would not have written -- one without its space, or one
|
|
2852
|
+
// whose aontu is indented after the marker rather than before it,
|
|
2853
|
+
// since the marker keeps its own indentation. It does NOT name a
|
|
2854
|
+
// changed body line: a template's whitespace is output, so a
|
|
2855
|
+
// trimmed trailing space is still a valid template and it is
|
|
2856
|
+
// `render --check` against the committed files that catches it.
|
|
2857
|
+
// The first line that differs is the report, since a whole diff of
|
|
2858
|
+
// a generator is the file again.
|
|
2859
|
+
const back = (0, template_1.resugarTemplate)((0, template_1.desugarTemplate)(src, mark), mark);
|
|
2860
|
+
if (back === src) {
|
|
2861
|
+
return 0;
|
|
2862
|
+
}
|
|
2863
|
+
const want = back.split('\n');
|
|
2864
|
+
const have = src.split('\n');
|
|
2865
|
+
let n = 0;
|
|
2866
|
+
while (n < want.length && n < have.length && want[n] === have[n]) {
|
|
2867
|
+
n++;
|
|
2868
|
+
}
|
|
2869
|
+
// THE TWO ARE THE SAME LENGTH, always: each transform maps one
|
|
2870
|
+
// line to one line and applies the same trailing-newline rule, so
|
|
2871
|
+
// `back` has as many lines as `src`. The loop above therefore stops
|
|
2872
|
+
// at a real difference rather than by running out of either -- an
|
|
2873
|
+
// equal prefix all the way to the end IS `back === src`, which
|
|
2874
|
+
// returned above. So both indexes are in range here.
|
|
2875
|
+
process.stderr.write(`aontu: ${files[0]}:${n + 1} is not what the round trip answers\n` +
|
|
2876
|
+
` have: ${JSON.stringify(have[n])}\n` +
|
|
2877
|
+
` want: ${JSON.stringify(want[n])}\n`);
|
|
2878
|
+
return 1;
|
|
2879
|
+
}
|
|
2880
|
+
process.stdout.write(resugar ?
|
|
2881
|
+
(0, template_1.resugarTemplate)(src, mark) : (0, template_1.desugarTemplate)(src, mark));
|
|
2882
|
+
return 0;
|
|
2883
|
+
}
|
|
2884
|
+
// ---------------------------------------------------------------------
|
|
2410
2885
|
// The canon-hash (G6 phase 1): the pin an agent, a lockfile or a
|
|
2411
2886
|
// registry stores for "this module, this meaning". The hash covers the
|
|
2412
2887
|
// module evaluated STANDALONE -- its own include closure resolved and
|
|
@@ -2934,10 +3409,12 @@ function runAgentsMd(argv) {
|
|
|
2934
3409
|
// tradition of gofmt. The verb prints, lists, checks, diffs or rewrites;
|
|
2935
3410
|
// the form itself is the library's (ts/src/format.ts), and the two
|
|
2936
3411
|
// ports agree on it row by row in test/spec/fmt.tsv.
|
|
2937
|
-
const FMT_HELP = 'aontu fmt [-w|-l|--check|-d] <file>... (try --help)';
|
|
3412
|
+
const FMT_HELP = 'aontu fmt [-w|-l|--check|-d|--lint] <file>... (try --help)';
|
|
2938
3413
|
function runFmt(argv) {
|
|
2939
3414
|
const files = [];
|
|
2940
|
-
const flags = {
|
|
3415
|
+
const flags = {
|
|
3416
|
+
write: false, list: false, check: false, diff: false, lint: false, strict: false,
|
|
3417
|
+
};
|
|
2941
3418
|
for (const arg of argv) {
|
|
2942
3419
|
if ('-h' === arg || '--help' === arg) {
|
|
2943
3420
|
process.stdout.write(HELP);
|
|
@@ -2955,6 +3432,13 @@ function runFmt(argv) {
|
|
|
2955
3432
|
else if ('-d' === arg || '--diff' === arg) {
|
|
2956
3433
|
flags.diff = true;
|
|
2957
3434
|
}
|
|
3435
|
+
else if ('--lint' === arg) {
|
|
3436
|
+
flags.lint = true;
|
|
3437
|
+
}
|
|
3438
|
+
else if ('--strict' === arg) {
|
|
3439
|
+
flags.lint = true;
|
|
3440
|
+
flags.strict = true;
|
|
3441
|
+
}
|
|
2958
3442
|
else if (arg.startsWith('-')) {
|
|
2959
3443
|
process.stderr.write(`aontu: unknown fmt option ${arg} (try --help)\n`);
|
|
2960
3444
|
return 2;
|
|
@@ -2983,11 +3467,27 @@ function runFmt(argv) {
|
|
|
2983
3467
|
// says what to do with each.
|
|
2984
3468
|
if (1 < files.length && !fmtQuiet(flags)) {
|
|
2985
3469
|
process.stderr.write(`aontu: fmt prints one file; with ${files.length}, say --write, ` +
|
|
2986
|
-
`--list, --check or --
|
|
3470
|
+
`--list, --check, --diff or --lint\n${FMT_HELP}\n`);
|
|
2987
3471
|
return 2;
|
|
2988
3472
|
}
|
|
2989
3473
|
let worst = 0;
|
|
2990
3474
|
for (const file of files) {
|
|
3475
|
+
// FMT FORMATS AONTU SOURCE, AND THE EXTENSION SAYS WHAT A FILE IS
|
|
3476
|
+
// (ADR-012's rule, and the one `render` reads a template by).
|
|
3477
|
+
// A TEMPLATE FILE IS NOT AONTU (docs/design/TEMPLATE.0.md; P8):
|
|
3478
|
+
// its marker lines are fragments of a document and its other lines
|
|
3479
|
+
// are the target's, so there is nothing here to format that would
|
|
3480
|
+
// not also rewrite the output. Refused rather than attempted, and
|
|
3481
|
+
// refused BY NAME rather than by a parse failure, because a `#-`
|
|
3482
|
+
// template parses: `#` opens a comment, so every marker line
|
|
3483
|
+
// vanishes and what is left is read as a document that was never
|
|
3484
|
+
// written. The verb answered `0` over one, having understood none
|
|
3485
|
+
// of it.
|
|
3486
|
+
if (!/[.](aon|aontu)$/.test(file)) {
|
|
3487
|
+
process.stderr.write(`aontu: ${file} is not aontu source (.aon, .aontu); a generator ` +
|
|
3488
|
+
'written in the target\'s own syntax is aontu template\'s\n');
|
|
3489
|
+
return 2;
|
|
3490
|
+
}
|
|
2991
3491
|
let src;
|
|
2992
3492
|
try {
|
|
2993
3493
|
src = (0, node_fs_1.readFileSync)(file, 'utf8');
|
|
@@ -3000,27 +3500,33 @@ function runFmt(argv) {
|
|
|
3000
3500
|
}
|
|
3001
3501
|
return worst;
|
|
3002
3502
|
}
|
|
3003
|
-
// An option that says what to do with a file
|
|
3004
|
-
//
|
|
3503
|
+
// An option that says what to do with a file, in place of printing
|
|
3504
|
+
// it: what to do when its form would change, or the lint.
|
|
3005
3505
|
function fmtQuiet(flags) {
|
|
3006
|
-
return flags.write || flags.list || flags.check || flags.diff;
|
|
3506
|
+
return flags.write || flags.list || flags.check || flags.diff || flags.lint;
|
|
3007
3507
|
}
|
|
3008
3508
|
// One document: 0 printed, clean or done; 1 a --check that would
|
|
3009
|
-
// change; 2 a file that cannot be written; 4 a
|
|
3010
|
-
// format, with the finding that says why.
|
|
3509
|
+
// change, or a --strict finding; 2 a file that cannot be written; 4 a
|
|
3510
|
+
// document that does not format, with the finding that says why. The
|
|
3511
|
+
// style findings go to standard error, one line each, in the shape
|
|
3512
|
+
// every linter prints: `file:line:col: rule: message`.
|
|
3011
3513
|
function fmtOne(name, src, flags) {
|
|
3012
|
-
const report = (0, format_1.format)(src, { path: name });
|
|
3514
|
+
const report = (0, format_1.format)(src, { path: name, lint: flags.lint });
|
|
3013
3515
|
if ('error' === report.verdict) {
|
|
3014
3516
|
process.stderr.write(`aontu: ${name} was not formatted\n` +
|
|
3015
3517
|
report.errors.map(renderFinding).join('\n') + '\n');
|
|
3016
3518
|
return 4;
|
|
3017
3519
|
}
|
|
3520
|
+
for (const f of report.findings) {
|
|
3521
|
+
process.stderr.write(`${name}:${f.line}:${f.col}: ${f.rule}: ${f.message}\n`);
|
|
3522
|
+
}
|
|
3523
|
+
const strict = flags.strict && 0 < report.findings.length ? 1 : 0;
|
|
3018
3524
|
if (!fmtQuiet(flags)) {
|
|
3019
3525
|
process.stdout.write(report.text);
|
|
3020
3526
|
return 0;
|
|
3021
3527
|
}
|
|
3022
3528
|
if (!report.changed) {
|
|
3023
|
-
return
|
|
3529
|
+
return strict;
|
|
3024
3530
|
}
|
|
3025
3531
|
if (flags.list || flags.check) {
|
|
3026
3532
|
process.stdout.write(name + '\n');
|
|
@@ -3037,7 +3543,31 @@ function fmtOne(name, src, flags) {
|
|
|
3037
3543
|
return 2;
|
|
3038
3544
|
}
|
|
3039
3545
|
}
|
|
3040
|
-
return flags.check ? 1 :
|
|
3546
|
+
return flags.check ? 1 : strict;
|
|
3547
|
+
}
|
|
3548
|
+
// The real pair takes the process's own stdin and stdout, which no
|
|
3549
|
+
// in-process test can lend it; the executable-entry tests in
|
|
3550
|
+
// cli.test.ts run each through a child process instead, so these two
|
|
3551
|
+
// lines are excluded from the in-process count, as the stdio wiring
|
|
3552
|
+
// of lsp-server.ts is.
|
|
3553
|
+
/* node:coverage ignore next 4 */
|
|
3554
|
+
const SERVERS = {
|
|
3555
|
+
lsp: () => void (0, lsp_server_1.main)(),
|
|
3556
|
+
mcp: (argv) => void (0, mcp_server_1.main)(undefined, undefined, undefined, undefined, argv),
|
|
3557
|
+
};
|
|
3558
|
+
// undefined: the server took the process; a number: an answer the CLI
|
|
3559
|
+
// gives itself, --help or a usage error.
|
|
3560
|
+
function runLsp(argv, servers) {
|
|
3561
|
+
for (const arg of argv) {
|
|
3562
|
+
if ('-h' === arg || '--help' === arg) {
|
|
3563
|
+
process.stdout.write(HELP);
|
|
3564
|
+
return 0;
|
|
3565
|
+
}
|
|
3566
|
+
process.stderr.write(`aontu: lsp takes no arguments (try --help)\n`);
|
|
3567
|
+
return 2;
|
|
3568
|
+
}
|
|
3569
|
+
servers.lsp();
|
|
3570
|
+
return undefined;
|
|
3041
3571
|
}
|
|
3042
3572
|
function finish(code) {
|
|
3043
3573
|
process.exitCode = code;
|
|
@@ -3059,7 +3589,7 @@ function parseTrustArg(value) {
|
|
|
3059
3589
|
}
|
|
3060
3590
|
return undefined;
|
|
3061
3591
|
}
|
|
3062
|
-
function main(argv) {
|
|
3592
|
+
function main(argv, servers = SERVERS) {
|
|
3063
3593
|
// COLOUR OFF WHEN THE DESTINATION IS NOT A TERMINAL. Error frames
|
|
3064
3594
|
// hardcoded their ANSI escapes, so a piped report and a `--jsonl`
|
|
3065
3595
|
// answer carried terminal control codes into whatever read them (the
|
|
@@ -3107,6 +3637,13 @@ function main(argv) {
|
|
|
3107
3637
|
if ('fmt' === argv[2]) {
|
|
3108
3638
|
return void Promise.resolve(runFmt(argv.slice(3))).then(finish);
|
|
3109
3639
|
}
|
|
3640
|
+
if ('lsp' === argv[2]) {
|
|
3641
|
+
const code = runLsp(argv.slice(3), servers);
|
|
3642
|
+
return undefined === code ? undefined : finish(code);
|
|
3643
|
+
}
|
|
3644
|
+
if ('mcp' === argv[2]) {
|
|
3645
|
+
return servers.mcp(argv.slice(3));
|
|
3646
|
+
}
|
|
3110
3647
|
if ('set' === argv[2]) {
|
|
3111
3648
|
return finish(runSet(argv.slice(3)));
|
|
3112
3649
|
}
|
|
@@ -3128,6 +3665,12 @@ function main(argv) {
|
|
|
3128
3665
|
if ('jsonschema' === argv[2]) {
|
|
3129
3666
|
return finish(runJsonSchema(argv.slice(3)));
|
|
3130
3667
|
}
|
|
3668
|
+
if ('render' === argv[2]) {
|
|
3669
|
+
return finish(runRender(argv.slice(3)));
|
|
3670
|
+
}
|
|
3671
|
+
if ('template' === argv[2]) {
|
|
3672
|
+
return finish(runTemplate(argv.slice(3)));
|
|
3673
|
+
}
|
|
3131
3674
|
if ('reaches' === argv[2]) {
|
|
3132
3675
|
return finish(runReaches(argv.slice(3)));
|
|
3133
3676
|
}
|
|
@@ -3225,5 +3768,5 @@ function main(argv) {
|
|
|
3225
3768
|
else {
|
|
3226
3769
|
runStdin(mode, trust).then((code) => finish(code));
|
|
3227
3770
|
}
|
|
3228
|
-
} /* node:coverage ignore next
|
|
3771
|
+
} /* node:coverage ignore next 18 */
|
|
3229
3772
|
//# sourceMappingURL=cli.js.map
|