aontu 0.52.1 → 0.53.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 +88 -0
- package/bin/aontu-mcp.js +4 -0
- package/dist/agentsmd.d.ts +16 -0
- package/dist/agentsmd.js +107 -0
- package/dist/agentsmd.js.map +1 -0
- package/dist/aontu.d.ts +14 -3
- package/dist/aontu.js +96 -4
- package/dist/aontu.js.map +1 -1
- package/dist/cli.d.ts +44 -1
- package/dist/cli.js +2401 -44
- package/dist/cli.js.map +1 -1
- package/dist/ctx.d.ts +13 -0
- package/dist/ctx.js +43 -0
- package/dist/ctx.js.map +1 -1
- package/dist/diff.d.ts +22 -0
- package/dist/diff.js +141 -0
- package/dist/diff.js.map +1 -0
- package/dist/err.d.ts +3 -1
- package/dist/err.js +38 -7
- package/dist/err.js.map +1 -1
- package/dist/graph.d.ts +16 -0
- package/dist/graph.js +73 -0
- package/dist/graph.js.map +1 -0
- package/dist/hcanon.d.ts +3 -0
- package/dist/hcanon.js +146 -0
- package/dist/hcanon.js.map +1 -0
- package/dist/hints.js +167 -4
- package/dist/hints.js.map +1 -1
- package/dist/jsonschema.d.ts +20 -0
- package/dist/jsonschema.js +391 -0
- package/dist/jsonschema.js.map +1 -0
- package/dist/lang.js +512 -69
- package/dist/lang.js.map +1 -1
- package/dist/lsp.d.ts +9 -2
- package/dist/lsp.js +262 -47
- package/dist/lsp.js.map +1 -1
- package/dist/mcp-server.d.ts +20 -0
- package/dist/mcp-server.js +147 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/mcp.d.ts +42 -0
- package/dist/mcp.js +814 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mod-tool.d.ts +58 -0
- package/dist/mod-tool.js +498 -0
- package/dist/mod-tool.js.map +1 -0
- package/dist/mod.d.ts +31 -0
- package/dist/mod.js +250 -0
- package/dist/mod.js.map +1 -0
- package/dist/patch.d.ts +44 -0
- package/dist/patch.js +506 -0
- package/dist/patch.js.map +1 -0
- package/dist/provenance.d.ts +40 -0
- package/dist/provenance.js +335 -0
- package/dist/provenance.js.map +1 -0
- package/dist/query.d.ts +27 -0
- package/dist/query.js +294 -0
- package/dist/query.js.map +1 -0
- package/dist/reach.d.ts +14 -0
- package/dist/reach.js +140 -0
- package/dist/reach.js.map +1 -0
- package/dist/relation.d.ts +19 -0
- package/dist/relation.js +305 -0
- package/dist/relation.js.map +1 -0
- package/dist/report-sarif.d.ts +14 -0
- package/dist/report-sarif.js +102 -0
- package/dist/report-sarif.js.map +1 -0
- package/dist/site.d.ts +4 -0
- package/dist/site.js +31 -0
- package/dist/site.js.map +1 -1
- package/dist/std.d.ts +1 -0
- package/dist/std.js +73 -0
- package/dist/std.js.map +1 -0
- package/dist/subsume.d.ts +39 -0
- package/dist/subsume.js +526 -0
- package/dist/subsume.js.map +1 -0
- package/dist/trim.d.ts +19 -0
- package/dist/trim.js +155 -0
- package/dist/trim.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.d.ts +17 -1
- package/dist/type.js.map +1 -1
- package/dist/unify.d.ts +2 -1
- package/dist/unify.js +253 -36
- package/dist/unify.js.map +1 -1
- package/dist/utility.d.ts +9 -1
- package/dist/utility.js +122 -1
- package/dist/utility.js.map +1 -1
- package/dist/val/AggFuncVal.d.ts +33 -0
- package/dist/val/AggFuncVal.js +202 -0
- package/dist/val/AggFuncVal.js.map +1 -0
- package/dist/val/ArithFuncVal.d.ts +31 -0
- package/dist/val/ArithFuncVal.js +62 -0
- package/dist/val/ArithFuncVal.js.map +1 -0
- package/dist/val/BagVal.d.ts +5 -0
- package/dist/val/BagVal.js +96 -5
- package/dist/val/BagVal.js.map +1 -1
- package/dist/val/CloseFuncVal.js +9 -1
- package/dist/val/CloseFuncVal.js.map +1 -1
- package/dist/val/ConjunctVal.d.ts +1 -1
- package/dist/val/ConjunctVal.js +19 -0
- package/dist/val/ConjunctVal.js.map +1 -1
- package/dist/val/ConstraintVal.d.ts +7 -1
- package/dist/val/ConstraintVal.js +490 -40
- package/dist/val/ConstraintVal.js.map +1 -1
- package/dist/val/CopyFuncVal.d.ts +1 -2
- package/dist/val/CopyFuncVal.js +7 -0
- package/dist/val/CopyFuncVal.js.map +1 -1
- package/dist/val/Decimal.d.ts +1 -0
- package/dist/val/Decimal.js +13 -0
- package/dist/val/Decimal.js.map +1 -1
- package/dist/val/DeprecateFuncVal.d.ts +11 -0
- package/dist/val/DeprecateFuncVal.js +47 -0
- package/dist/val/DeprecateFuncVal.js.map +1 -0
- package/dist/val/DisjunctVal.js +130 -21
- package/dist/val/DisjunctVal.js.map +1 -1
- package/dist/val/EachFuncVal.d.ts +15 -0
- package/dist/val/EachFuncVal.js +75 -0
- package/dist/val/EachFuncVal.js.map +1 -0
- package/dist/val/ExpectVal.js +27 -4
- package/dist/val/ExpectVal.js.map +1 -1
- package/dist/val/FeatureVal.js +1 -1
- package/dist/val/FeatureVal.js.map +1 -1
- package/dist/val/FilterFuncVal.d.ts +15 -0
- package/dist/val/FilterFuncVal.js +91 -0
- package/dist/val/FilterFuncVal.js.map +1 -0
- package/dist/val/FuncBaseVal.d.ts +6 -1
- package/dist/val/FuncBaseVal.js +171 -1
- package/dist/val/FuncBaseVal.js.map +1 -1
- package/dist/val/HideFuncVal.js.map +1 -1
- package/dist/val/IdFuncVal.d.ts +13 -0
- package/dist/val/IdFuncVal.js +54 -0
- package/dist/val/IdFuncVal.js.map +1 -0
- package/dist/val/JunctionVal.js +7 -1
- package/dist/val/JunctionVal.js.map +1 -1
- package/dist/val/KeyFuncVal.d.ts +1 -1
- package/dist/val/KeyFuncVal.js +38 -30
- package/dist/val/KeyFuncVal.js.map +1 -1
- package/dist/val/ListVal.js +101 -14
- package/dist/val/ListVal.js.map +1 -1
- package/dist/val/LowerFuncVal.js.map +1 -1
- package/dist/val/MapVal.js +93 -8
- package/dist/val/MapVal.js.map +1 -1
- package/dist/val/MatchFuncVal.d.ts +15 -0
- package/dist/val/MatchFuncVal.js +107 -0
- package/dist/val/MatchFuncVal.js.map +1 -0
- package/dist/val/MoveFuncVal.js.map +1 -1
- package/dist/val/NilVal.js +24 -0
- package/dist/val/NilVal.js.map +1 -1
- package/dist/val/OpBaseVal.d.ts +1 -1
- package/dist/val/OpBaseVal.js +19 -1
- package/dist/val/OpBaseVal.js.map +1 -1
- package/dist/val/OpenFuncVal.js +4 -1
- package/dist/val/OpenFuncVal.js.map +1 -1
- package/dist/val/PackFuncVal.d.ts +15 -0
- package/dist/val/PackFuncVal.js +108 -0
- package/dist/val/PackFuncVal.js.map +1 -0
- package/dist/val/PathFuncVal.js.map +1 -1
- package/dist/val/PlaceVal.d.ts +13 -0
- package/dist/val/PlaceVal.js +131 -0
- package/dist/val/PlaceVal.js.map +1 -0
- package/dist/val/PlusOpVal.js +11 -2
- package/dist/val/PlusOpVal.js.map +1 -1
- package/dist/val/PrefFuncVal.js.map +1 -1
- package/dist/val/PrefVal.d.ts +2 -2
- package/dist/val/PrefVal.js +78 -23
- package/dist/val/PrefVal.js.map +1 -1
- package/dist/val/RefVal.d.ts +1 -1
- package/dist/val/RefVal.js +89 -7
- package/dist/val/RefVal.js.map +1 -1
- package/dist/val/ReferFuncVal.d.ts +36 -0
- package/dist/val/ReferFuncVal.js +303 -0
- package/dist/val/ReferFuncVal.js.map +1 -0
- package/dist/val/ScalarKindVal.d.ts +1 -2
- package/dist/val/ScalarKindVal.js +0 -11
- package/dist/val/ScalarKindVal.js.map +1 -1
- package/dist/val/TopVal.js.map +1 -1
- package/dist/val/TypeFuncVal.js.map +1 -1
- package/dist/val/UpperFuncVal.js.map +1 -1
- package/dist/val/Val.d.ts +8 -1
- package/dist/val/Val.js +150 -1
- package/dist/val/Val.js.map +1 -1
- package/dist/val/VarVal.js.map +1 -1
- package/dist/val/arith.d.ts +6 -0
- package/dist/val/arith.js +170 -0
- package/dist/val/arith.js.map +1 -0
- package/dist/vet.d.ts +45 -0
- package/dist/vet.js +776 -0
- package/dist/vet.js.map +1 -0
- package/dist/walk.d.ts +2 -0
- package/dist/walk.js +91 -0
- package/dist/walk.js.map +1 -0
- package/grammar/aontu.gbnf +130 -0
- package/grammar/aontu.lark +113 -0
- package/package.json +21 -6
- package/skill/SKILL.md +37 -0
- package/skill/error-codes.md +62 -0
- package/skill/examples.md +99 -0
- package/skill/grammar-card.md +57 -0
- package/src/agentsmd.ts +135 -0
- package/src/aontu.ts +135 -4
- package/src/cli.ts +2858 -71
- package/src/ctx.ts +73 -1
- package/src/diff.ts +196 -0
- package/src/err.ts +42 -7
- package/src/graph.ts +135 -0
- package/src/hcanon.ts +169 -0
- package/src/hints.ts +208 -4
- package/src/jsonschema.ts +511 -0
- package/src/lang.ts +570 -70
- package/src/lsp.ts +281 -48
- package/src/mcp-server.ts +187 -0
- package/src/mcp.ts +993 -0
- package/src/mod-tool.ts +679 -0
- package/src/mod.ts +344 -0
- package/src/patch.ts +624 -0
- package/src/provenance.ts +430 -0
- package/src/query.ts +379 -0
- package/src/reach.ts +184 -0
- package/src/relation.ts +395 -0
- package/src/report-sarif.ts +137 -0
- package/src/site.ts +36 -1
- package/src/std.ts +73 -0
- package/src/subsume.ts +690 -0
- package/src/trim.ts +195 -0
- package/src/tsconfig.json +10 -4
- package/src/type.ts +51 -2
- package/src/unify.ts +274 -36
- package/src/utility.ts +139 -1
- package/src/val/AggFuncVal.ts +319 -0
- package/src/val/ArithFuncVal.ts +108 -0
- package/src/val/BagVal.ts +101 -4
- package/src/val/CloseFuncVal.ts +9 -1
- package/src/val/ConjunctVal.ts +20 -0
- package/src/val/ConstraintVal.ts +542 -43
- package/src/val/CopyFuncVal.ts +7 -1
- package/src/val/Decimal.ts +15 -0
- package/src/val/DeprecateFuncVal.ts +84 -0
- package/src/val/DisjunctVal.ts +139 -28
- package/src/val/EachFuncVal.ts +133 -0
- package/src/val/ExpectVal.ts +28 -6
- package/src/val/FeatureVal.ts +1 -1
- package/src/val/FilterFuncVal.ts +154 -0
- package/src/val/FuncBaseVal.ts +192 -1
- package/src/val/HideFuncVal.ts +0 -2
- package/src/val/IdFuncVal.ts +91 -0
- package/src/val/JunctionVal.ts +7 -1
- package/src/val/KeyFuncVal.ts +39 -35
- package/src/val/ListVal.ts +108 -15
- package/src/val/LowerFuncVal.ts +0 -1
- package/src/val/MapVal.ts +99 -8
- package/src/val/MatchFuncVal.ts +176 -0
- package/src/val/MoveFuncVal.ts +0 -2
- package/src/val/NilVal.ts +25 -0
- package/src/val/OpBaseVal.ts +20 -1
- package/src/val/OpenFuncVal.ts +4 -2
- package/src/val/PackFuncVal.ts +175 -0
- package/src/val/PathFuncVal.ts +0 -1
- package/src/val/PlaceVal.ts +193 -0
- package/src/val/PlusOpVal.ts +11 -2
- package/src/val/PrefFuncVal.ts +0 -1
- package/src/val/PrefVal.ts +79 -36
- package/src/val/RefVal.ts +91 -8
- package/src/val/ReferFuncVal.ts +387 -0
- package/src/val/ScalarKindVal.ts +0 -13
- package/src/val/TopVal.ts +0 -1
- package/src/val/TypeFuncVal.ts +0 -2
- package/src/val/UpperFuncVal.ts +0 -1
- package/src/val/Val.ts +205 -2
- package/src/val/VarVal.ts +0 -1
- package/src/val/arith.ts +316 -0
- package/src/vet.ts +992 -0
- package/src/walk.ts +99 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Aontu grammar card
|
|
2
|
+
|
|
3
|
+
Everything the language spells, on one page. The published machine
|
|
4
|
+
grammar is [`grammar/aontu.gbnf`](../grammar/aontu.gbnf) (and
|
|
5
|
+
`aontu.lark`); this is its human twin.
|
|
6
|
+
|
|
7
|
+
## Values
|
|
8
|
+
|
|
9
|
+
| Write | Means |
|
|
10
|
+
|-------|-------|
|
|
11
|
+
| `{"a":1}`, `a: 1` | a map; keys may be bare or quoted |
|
|
12
|
+
| `[1,2]` | a list |
|
|
13
|
+
| `"s"`, `1`, `1.5`, `true`, `null` | scalars, as JSON |
|
|
14
|
+
| `0d9007199254740993` | an EXACT number, at any magnitude |
|
|
15
|
+
| `string integer number float boolean null` | kinds: any value of that kind |
|
|
16
|
+
| `top` | anything at all; `nil` is the failure |
|
|
17
|
+
|
|
18
|
+
## Combining
|
|
19
|
+
|
|
20
|
+
| Write | Means |
|
|
21
|
+
|-------|-------|
|
|
22
|
+
| `a & b` | both must hold — the meet |
|
|
23
|
+
| `a \| b` | either may hold — the join |
|
|
24
|
+
| `*1 \| integer` | either, with `1` the DEFAULT a generation picks |
|
|
25
|
+
| | the branch keeps its kind: a later `1.5` is refused, not admitted |
|
|
26
|
+
| `x: 1` twice | the two meet; `1 & 2` is an error, `1 & integer` is `1` |
|
|
27
|
+
| `$.a.b` | the value at that path of this document |
|
|
28
|
+
| `1 + 2` | arithmetic on concrete numbers |
|
|
29
|
+
|
|
30
|
+
## Maps that say more
|
|
31
|
+
|
|
32
|
+
| Write | Means |
|
|
33
|
+
|-------|-------|
|
|
34
|
+
| `{&: {k: integer}}` | a TEMPLATE every key must satisfy |
|
|
35
|
+
| `close({a:1})` | no key beyond those named |
|
|
36
|
+
| `{a?: 1}` | optional: dropped if unresolved |
|
|
37
|
+
| `hide(x)` | evaluated, then dropped from the output |
|
|
38
|
+
| `type(x)` | a definition, not a value: it generates nothing |
|
|
39
|
+
| `deprecate(x, {msg:"…"})` | still works, and says so |
|
|
40
|
+
| `id(svc/auth) & x` | this value IS that entity; every node with the name unifies |
|
|
41
|
+
| `refer(t) & "svc/auth"` | a checked LINK: the name must resolve, and `t` flows into it |
|
|
42
|
+
|
|
43
|
+
## Constraints
|
|
44
|
+
|
|
45
|
+
`min(n) max(n) above(n) below(n)` bound a number;
|
|
46
|
+
`length(n)` and `unique()` bound a list or string;
|
|
47
|
+
`re("^…$")` matches a string; `neq(v)` refuses one value;
|
|
48
|
+
`must(cond, "why")` is the escape hatch.
|
|
49
|
+
|
|
50
|
+
Bounds compose: `integer & min(1) & max(10)` is a range, and two
|
|
51
|
+
ranges meet to their overlap.
|
|
52
|
+
|
|
53
|
+
## Files
|
|
54
|
+
|
|
55
|
+
`@"other.aon"` includes another document — it unifies in, it does not
|
|
56
|
+
concatenate. (A constrained decoder is not given this: generated
|
|
57
|
+
documents describe values, they do not load files.)
|
package/src/agentsmd.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* Copyright (c) 2025 Richard Rodger, MIT License */
|
|
2
|
+
|
|
3
|
+
// THE AGENTS.md STANZA (G7 phase 6,
|
|
4
|
+
// docs/capability-review/g7-machine-access.md): generated FROM the
|
|
5
|
+
// definition, so the prose entrypoint cannot drift from the formal
|
|
6
|
+
// source it points at.
|
|
7
|
+
//
|
|
8
|
+
// A hand-written "here is where the config lives" paragraph is stale
|
|
9
|
+
// the first time a key is renamed. This one is derived: the root keys
|
|
10
|
+
// come from the document, the pin comes from G6's canon-hash, and the
|
|
11
|
+
// commands are spelled with paths that exist. Re-running the verb
|
|
12
|
+
// after an edit produces the stanza that edit implies.
|
|
13
|
+
|
|
14
|
+
import { Aontu } from './aontu'
|
|
15
|
+
import type { TrustOptions } from './type'
|
|
16
|
+
import { canonHash } from './hcanon'
|
|
17
|
+
import { get } from './query'
|
|
18
|
+
import { evalFailure } from './query'
|
|
19
|
+
import type { VetFinding } from './vet'
|
|
20
|
+
import { cmpCodePoint } from './keyorder'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
// The markers an update rewrites between. A stanza outside them is
|
|
24
|
+
// prose someone wrote, and is left alone.
|
|
25
|
+
export const AGENTSMD_BEGIN = '<!-- aontu:begin -->'
|
|
26
|
+
export const AGENTSMD_END = '<!-- aontu:end -->'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export type AgentsMdReport = {
|
|
30
|
+
findings: VetFinding[]
|
|
31
|
+
ok: boolean
|
|
32
|
+
stanza: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type AgentsMdOptions = {
|
|
36
|
+
// The name the stanza should call the document. The engine never
|
|
37
|
+
// reads a file; the CLI passes what the author typed.
|
|
38
|
+
name?: string
|
|
39
|
+
path?: string
|
|
40
|
+
// The include capability this document evaluates under
|
|
41
|
+
// (G5, docs/trust.md); vet's precedent.
|
|
42
|
+
trust?: TrustOptions
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// The stanza for one document.
|
|
47
|
+
export function agentsMd(
|
|
48
|
+
src: string, opts?: AgentsMdOptions): AgentsMdReport {
|
|
49
|
+
const options = opts ?? {}
|
|
50
|
+
const name = options.name ?? 'the definition'
|
|
51
|
+
|
|
52
|
+
const aontu = new Aontu(
|
|
53
|
+
null == options.trust ? undefined : { trust: options.trust })
|
|
54
|
+
const ctx = aontu.ctx({ collect: true })
|
|
55
|
+
const parseOpts = null == options.path ? undefined : { path: options.path }
|
|
56
|
+
const v: any = aontu.unify(src, parseOpts, ctx)
|
|
57
|
+
if (0 < ctx.err.length) {
|
|
58
|
+
return { findings: [evalFailure(ctx)], ok: false, stanza: '' }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const keys = true === v.isMap ? Object.keys(v.peg).sort(cmpCodePoint) : []
|
|
62
|
+
const shape = get(src, '$', { view: 'types', depth: 2, path: options.path })
|
|
63
|
+
|
|
64
|
+
// A REAL path, so the example command works as written: the first
|
|
65
|
+
// root key when there is one, the root itself when there is not.
|
|
66
|
+
const example = 0 < keys.length ? '$.' + keys[0] : '$'
|
|
67
|
+
|
|
68
|
+
const lines = [
|
|
69
|
+
AGENTSMD_BEGIN,
|
|
70
|
+
'## Ground truth: `' + name + '`',
|
|
71
|
+
'',
|
|
72
|
+
'The values below are DERIVED from `' + name + '`, an Aontu',
|
|
73
|
+
'definition. Do not restate them here — read them from the source,',
|
|
74
|
+
'which is the only copy that cannot go stale.',
|
|
75
|
+
'',
|
|
76
|
+
'- Pin: `' + canonHash(v) + '`',
|
|
77
|
+
' (the canon-hash: it survives reformatting and moves on any',
|
|
78
|
+
' change of meaning — `aontu hash ' + name + '` re-derives it)',
|
|
79
|
+
'- Top-level keys: ' +
|
|
80
|
+
(0 === keys.length ? '_none_' : keys.map((k) => '`' + k + '`').join(', ')),
|
|
81
|
+
'- Shape: `' + shape.out + '`',
|
|
82
|
+
'',
|
|
83
|
+
'How to work with it:',
|
|
84
|
+
'',
|
|
85
|
+
'```',
|
|
86
|
+
'# what does it say at a path?',
|
|
87
|
+
'aontu get ' + example + ' ' + name,
|
|
88
|
+
'',
|
|
89
|
+
'# why does that value hold?',
|
|
90
|
+
'aontu why ' + example + ' ' + name,
|
|
91
|
+
'',
|
|
92
|
+
'# does my document satisfy it?',
|
|
93
|
+
'aontu vet ' + name + ' mine.aon',
|
|
94
|
+
'',
|
|
95
|
+
'# change it without editing it',
|
|
96
|
+
'aontu set ' + example + '=<value> --entry ' + name +
|
|
97
|
+
' --overlay overlay.aon',
|
|
98
|
+
'```',
|
|
99
|
+
'',
|
|
100
|
+
'Regenerate this section with `aontu agentsmd ' + name + '`.',
|
|
101
|
+
AGENTSMD_END,
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
return { findings: [], ok: true, stanza: lines.join('\n') + '\n' }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
// Splice the stanza into an existing document: replace what stands
|
|
109
|
+
// between the markers, or append when there is nothing to replace. A
|
|
110
|
+
// document is otherwise LEFT ALONE — the rest of an AGENTS.md is
|
|
111
|
+
// someone's prose, and a generator that rewrote it would be a
|
|
112
|
+
// generator nobody dared run twice.
|
|
113
|
+
export function agentsMdSplice(existing: string, stanza: string): string {
|
|
114
|
+
const from = existing.indexOf(AGENTSMD_BEGIN)
|
|
115
|
+
const to = existing.indexOf(AGENTSMD_END)
|
|
116
|
+
if (from < 0 || to < from) {
|
|
117
|
+
const head = '' === existing || existing.endsWith('\n')
|
|
118
|
+
? existing : existing + '\n'
|
|
119
|
+
return head + ('' === existing ? '' : '\n') + stanza
|
|
120
|
+
}
|
|
121
|
+
// Skip the end marker's line terminator, whatever it is, and only if
|
|
122
|
+
// it is there. The full note is on the Go twin (go/agentsmd.go): `+1`
|
|
123
|
+
// assumed one byte and got the CR of a CRLF document, leaving the LF
|
|
124
|
+
// to become a blank line on every regeneration -- and past the end of
|
|
125
|
+
// a document whose marker is its last content, where Go panicked and
|
|
126
|
+
// this side quietly did not.
|
|
127
|
+
let end = to + AGENTSMD_END.length
|
|
128
|
+
if ('\r' === existing[end]) {
|
|
129
|
+
end++
|
|
130
|
+
}
|
|
131
|
+
if ('\n' === existing[end]) {
|
|
132
|
+
end++
|
|
133
|
+
}
|
|
134
|
+
return existing.slice(0, from) + stanza + existing.slice(end)
|
|
135
|
+
}
|
package/src/aontu.ts
CHANGED
|
@@ -12,7 +12,18 @@ import { MapVal } from './val/MapVal'
|
|
|
12
12
|
import { Decimal } from './val/Decimal'
|
|
13
13
|
import { exactJSON } from './exactjson'
|
|
14
14
|
import { formatExplain } from './utility'
|
|
15
|
-
import { makeNilErr, descErr, AontuError } from './err'
|
|
15
|
+
import { makeNilErr, descErr, AontuError, setColor, colorActive } from './err'
|
|
16
|
+
import { vet } from './vet'
|
|
17
|
+
import { sarifReport } from './report-sarif'
|
|
18
|
+
import { subsume } from './subsume'
|
|
19
|
+
import { trimCheck } from './trim'
|
|
20
|
+
import { hcanon, canonHash } from './hcanon'
|
|
21
|
+
import { get, why } from './query'
|
|
22
|
+
import { patch } from './patch'
|
|
23
|
+
import { diff } from './diff'
|
|
24
|
+
import { agentsMd } from './agentsmd'
|
|
25
|
+
import { graphOf } from './graph'
|
|
26
|
+
import { relationCheck } from './relation'
|
|
16
27
|
|
|
17
28
|
|
|
18
29
|
// VERSION is the Aontu npm package version, and mirrors
|
|
@@ -22,7 +33,18 @@ import { makeNilErr, descErr, AontuError } from './err'
|
|
|
22
33
|
// Kept in step with package.json by the `version` npm lifecycle script,
|
|
23
34
|
// which runs on `npm version` / `npm run repo-bump`. version.test.ts
|
|
24
35
|
// fails if the two ever drift.
|
|
25
|
-
const VERSION = '0.
|
|
36
|
+
const VERSION = '0.53.0'
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
// A module file's VALUE, as far as it goes. COLLECTED, not raised: a
|
|
40
|
+
// module file that does not stand up has no `mod.main` to read, and
|
|
41
|
+
// the default entry name is the answer -- the resolution itself fails
|
|
42
|
+
// later, on the file that is not there, rather than here on a metadata
|
|
43
|
+
// read. That is what a collecting context does, so there is nothing to
|
|
44
|
+
// catch: it answers what it could generate and records the rest.
|
|
45
|
+
function genQuiet(val: any, aontu: Aontu): any {
|
|
46
|
+
return val.gen(aontu.ctx({ collect: true }))
|
|
47
|
+
}
|
|
26
48
|
|
|
27
49
|
|
|
28
50
|
class Aontu {
|
|
@@ -32,6 +54,42 @@ class Aontu {
|
|
|
32
54
|
|
|
33
55
|
constructor(popts?: AontuOptions) {
|
|
34
56
|
this.opts = popts ?? {}
|
|
57
|
+
|
|
58
|
+
// THE MODULE EVALUATOR (G6 phase 2, ts/src/mod.ts). Resolving a
|
|
59
|
+
// module import needs two answers that only evaluation can give:
|
|
60
|
+
// what a module file SAYS (its `mod.main`), and what a module
|
|
61
|
+
// MEANS (its canon-hash, for the integrity check). Injected here
|
|
62
|
+
// rather than imported there, because the resolver runs inside a
|
|
63
|
+
// parse that this class started, and the file it runs in cannot
|
|
64
|
+
// import this one without closing a cycle around the language.
|
|
65
|
+
//
|
|
66
|
+
// COLLECTED, not raised: a module that leans on consumer context
|
|
67
|
+
// (a `$.x` its importer supplies) does not stand up alone, and its
|
|
68
|
+
// hash is still the hash of what it says — that residue is part of
|
|
69
|
+
// the hashed meaning, which is why `hcanon` keeps it in textual
|
|
70
|
+
// form (docs/capability-review/g6-distribution.md).
|
|
71
|
+
;(this.opts as any).mod = {
|
|
72
|
+
...((this.opts as any).mod ?? {}),
|
|
73
|
+
eval: (this.opts as any).mod?.eval ?? ((src: string, path: string) => {
|
|
74
|
+
// One deeper: a module verified from inside a module
|
|
75
|
+
// verification is one more level of nesting, and the resolver
|
|
76
|
+
// refuses past its bound (MODULE_MAX_DEPTH in ts/src/mod.ts).
|
|
77
|
+
const inner = new Aontu({
|
|
78
|
+
...this.opts,
|
|
79
|
+
mod: {
|
|
80
|
+
// Never absent: the assignment this closure is part of has
|
|
81
|
+
// already run by the time it is called.
|
|
82
|
+
...(this.opts as any).mod,
|
|
83
|
+
eval: undefined,
|
|
84
|
+
depth: (((this.opts as any).mod?.depth ?? 0) as number) + 1,
|
|
85
|
+
},
|
|
86
|
+
} as any)
|
|
87
|
+
const ctx = inner.ctx({ collect: true })
|
|
88
|
+
const val = inner.unify(src, { path }, ctx)
|
|
89
|
+
return { gen: genQuiet(val, inner), hash: canonHash(val) }
|
|
90
|
+
}),
|
|
91
|
+
}
|
|
92
|
+
|
|
35
93
|
this.lang = new Lang(this.opts)
|
|
36
94
|
}
|
|
37
95
|
|
|
@@ -40,6 +98,11 @@ class Aontu {
|
|
|
40
98
|
ctx(cfg?: AontuContextConfig): AontuContext {
|
|
41
99
|
cfg = cfg ?? {}
|
|
42
100
|
cfg.fs = cfg.fs ?? this.opts.fs
|
|
101
|
+
// The trust profile rides the instance (its resolver is built once,
|
|
102
|
+
// in the Lang constructor); the context needs it too, for the
|
|
103
|
+
// budgets (G5, docs/trust.md).
|
|
104
|
+
cfg.opts = cfg.opts ?? {}
|
|
105
|
+
; (cfg.opts as any).trust = (cfg.opts as any).trust ?? this.opts.trust
|
|
43
106
|
const ac = new AontuContext(cfg)
|
|
44
107
|
return ac
|
|
45
108
|
}
|
|
@@ -85,7 +148,11 @@ class Aontu {
|
|
|
85
148
|
|
|
86
149
|
if (0 === errs.length) {
|
|
87
150
|
out = runparse(src, this.lang, ac)
|
|
88
|
-
|
|
151
|
+
// The include MANIFEST (G5, docs/trust.md): the resolved include
|
|
152
|
+
// closure as `{ path, capability }`, sorted and deduplicated so
|
|
153
|
+
// it is deterministic — the "file set" of hermeticity clause 1
|
|
154
|
+
// made observable. Content hashing and pinning stay with G6.
|
|
155
|
+
out.deps = manifestOf(ac.manifest)
|
|
89
156
|
ac.root = out
|
|
90
157
|
}
|
|
91
158
|
|
|
@@ -130,6 +197,11 @@ class Aontu {
|
|
|
130
197
|
out = uni.res
|
|
131
198
|
|
|
132
199
|
out.deps = pval.deps
|
|
200
|
+
// THE DERIVED STRUCTURES (G4 phase 3): the entity index and the
|
|
201
|
+
// edge set, computed once from the unified tree. Cheap on a
|
|
202
|
+
// document with no identity — one guarded walk — and the thing
|
|
203
|
+
// impact analysis and the relation checks are traversals over.
|
|
204
|
+
out.graph = graphOf(out)
|
|
133
205
|
out.err = errs
|
|
134
206
|
ac.root = out
|
|
135
207
|
}
|
|
@@ -266,12 +338,38 @@ function findConflictMarker(src: string): {
|
|
|
266
338
|
}
|
|
267
339
|
|
|
268
340
|
|
|
341
|
+
// Sort and deduplicate the raw manifest sink into the deterministic
|
|
342
|
+
// include closure: by path then capability, code-point order, one entry
|
|
343
|
+
// per (path, capability) pair.
|
|
344
|
+
function manifestOf(
|
|
345
|
+
sink: { path: string, capability: string }[]
|
|
346
|
+
): { path: string, capability: string }[] {
|
|
347
|
+
const seen = new Set<string>()
|
|
348
|
+
const out: { path: string, capability: string }[] = []
|
|
349
|
+
for (const dep of sink) {
|
|
350
|
+
const key = dep.path + ' ' + dep.capability
|
|
351
|
+
if (!seen.has(key)) {
|
|
352
|
+
seen.add(key)
|
|
353
|
+
out.push({ path: dep.path, capability: dep.capability })
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// No equal case: entries were deduplicated on exactly this key.
|
|
357
|
+
out.sort((a, b) => {
|
|
358
|
+
const ka = a.path + ' ' + a.capability
|
|
359
|
+
const kb = b.path + ' ' + b.capability
|
|
360
|
+
return ka < kb ? -1 : 1
|
|
361
|
+
})
|
|
362
|
+
return out
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
|
|
269
366
|
// Perform parse of source code (minor customizations over Lang.parse).
|
|
270
367
|
function runparse(src: string, lang: Lang, ctx: AontuContext): Val {
|
|
271
368
|
const popts = {
|
|
272
369
|
deps: ctx.deps,
|
|
273
370
|
fs: ctx.fs,
|
|
274
|
-
path: ctx.opts.path
|
|
371
|
+
path: ctx.opts.path,
|
|
372
|
+
manifest: ctx.manifest,
|
|
275
373
|
}
|
|
276
374
|
let val
|
|
277
375
|
|
|
@@ -301,6 +399,8 @@ export {
|
|
|
301
399
|
AontuOptions,
|
|
302
400
|
AontuContext,
|
|
303
401
|
AontuError,
|
|
402
|
+
setColor,
|
|
403
|
+
colorActive,
|
|
304
404
|
|
|
305
405
|
Val,
|
|
306
406
|
Lang,
|
|
@@ -314,6 +414,37 @@ export {
|
|
|
314
414
|
// `biginteger` generates as the language's own `bigint`).
|
|
315
415
|
exactJSON,
|
|
316
416
|
Decimal,
|
|
417
|
+
|
|
418
|
+
// G2 phase 2 -- the validation verb. The engine only: the CLI verb
|
|
419
|
+
// and the text/JSON renderers are phase 3, the Go port phase 4.
|
|
420
|
+
// `sarifReport` (phase 5) is library API so an embedder can emit the
|
|
421
|
+
// interchange form without shelling out.
|
|
422
|
+
vet,
|
|
423
|
+
sarifReport,
|
|
424
|
+
|
|
425
|
+
// G3 -- subsumption as a first-class query: does the general value
|
|
426
|
+
// admit every instance the specific value admits? Three-valued, with
|
|
427
|
+
// G2-shaped findings (class `compat`).
|
|
428
|
+
subsume,
|
|
429
|
+
trimCheck,
|
|
430
|
+
|
|
431
|
+
// G6 -- the hash form and the canon-hash pin. `hcanon` is the
|
|
432
|
+
// unify-level canon plus the close()/type()/hide() wrappers that
|
|
433
|
+
// close its semantic gaps; `canonHash` is
|
|
434
|
+
// "aon1-" + base64url(SHA-256(UTF-8(hcanon(v)))).
|
|
435
|
+
hcanon,
|
|
436
|
+
canonHash,
|
|
437
|
+
|
|
438
|
+
// G7 -- the machine-facing query surface: select one node by path
|
|
439
|
+
// and render it, plainly (json/canon) or as a lattice ABSTRACTION
|
|
440
|
+
// (types/depth/keys) that subsumes the truth it summarises.
|
|
441
|
+
get,
|
|
442
|
+
why,
|
|
443
|
+
patch,
|
|
444
|
+
diff,
|
|
445
|
+
agentsMd,
|
|
446
|
+
graphOf,
|
|
447
|
+
relationCheck,
|
|
317
448
|
}
|
|
318
449
|
|
|
319
450
|
|