aontu 0.57.0 → 0.59.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 +4 -2
- package/dist/aontu.js +12 -3
- package/dist/aontu.js.map +1 -1
- package/dist/cli.d.ts +3 -1
- package/dist/cli.js +486 -4
- package/dist/cli.js.map +1 -1
- package/dist/ctx.d.ts +4 -0
- package/dist/ctx.js +3 -0
- package/dist/ctx.js.map +1 -1
- package/dist/err.js +6 -3
- package/dist/err.js.map +1 -1
- package/dist/format.js +8 -2
- package/dist/format.js.map +1 -1
- package/dist/hints.js +40 -9
- package/dist/hints.js.map +1 -1
- package/dist/lang.js +409 -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 +1 -1
- package/dist/lsp.js.map +1 -1
- package/dist/mcp-server.js +1 -1
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +40 -3
- package/dist/mcp.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/type.d.ts +2 -0
- package/dist/type.js.map +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/DisjunctVal.js +33 -2
- package/dist/val/DisjunctVal.js.map +1 -1
- package/dist/val/EachFuncVal.d.ts +1 -1
- package/dist/val/EachFuncVal.js +8 -13
- package/dist/val/EachFuncVal.js.map +1 -1
- package/dist/val/EmitFuncVal.d.ts +23 -4
- package/dist/val/EmitFuncVal.js +298 -28
- package/dist/val/EmitFuncVal.js.map +1 -1
- package/dist/val/FilterFuncVal.js +8 -4
- 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.js +36 -13
- package/dist/val/FuncBaseVal.js.map +1 -1
- package/dist/val/ListVal.js +9 -1
- package/dist/val/ListVal.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 +22 -18
- package/dist/val/PackFuncVal.js.map +1 -1
- package/dist/val/PlaceVal.js +7 -2
- package/dist/val/PlaceVal.js.map +1 -1
- package/dist/val/RefVal.d.ts +3 -0
- package/dist/val/RefVal.js +181 -18
- package/dist/val/RefVal.js.map +1 -1
- package/dist/val/Val.d.ts +8 -1
- package/dist/val/Val.js +39 -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 +1 -1
- package/grammar/aontu.gbnf +1 -1
- package/grammar/aontu.lark +1 -1
- 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 +528 -4
- package/src/ctx.ts +18 -0
- package/src/err.ts +6 -3
- package/src/format.ts +12 -2
- package/src/hints.ts +47 -9
- package/src/lang.ts +453 -63
- package/src/lower.ts +636 -0
- package/src/lsp.ts +1 -1
- package/src/mcp-server.ts +1 -1
- package/src/mcp.ts +43 -4
- 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/type.ts +10 -1
- 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/DisjunctVal.ts +33 -2
- package/src/val/EachFuncVal.ts +8 -16
- package/src/val/EmitFuncVal.ts +376 -39
- package/src/val/FilterFuncVal.ts +11 -4
- package/src/val/FormFuncVal.ts +119 -0
- package/src/val/FuncBaseVal.ts +36 -13
- package/src/val/ListVal.ts +9 -1
- package/src/val/MapVal.ts +3 -2
- package/src/val/PackFuncVal.ts +23 -19
- package/src/val/PlaceVal.ts +7 -2
- package/src/val/RefVal.ts +193 -20
- package/src/val/Val.ts +75 -4
- package/src/val/members.ts +86 -0
package/src/val/Val.ts
CHANGED
|
@@ -11,6 +11,16 @@ import {
|
|
|
11
11
|
import { INNER_OF, WRITTEN } from '../provenance'
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
// THE DISPATCH RECORD (RENDER.0.md D11, P7): the address of the node
|
|
15
|
+
// a rule matched, and the address of the rule that matched it -- the
|
|
16
|
+
// table's own address and the rule's index in it, joined by `#`,
|
|
17
|
+
// which no path holds.
|
|
18
|
+
type EmitOrigin = {
|
|
19
|
+
node: string,
|
|
20
|
+
rule: string,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
14
24
|
type ValMark = {
|
|
15
25
|
type: boolean,
|
|
16
26
|
hide: boolean,
|
|
@@ -34,9 +44,12 @@ type ValSpec = {
|
|
|
34
44
|
// depth explicitly: `dup: true` makes FuncBaseVal, PrefVal and
|
|
35
45
|
// OpBaseVal clone their inner Vals too, and the bag/junction clones
|
|
36
46
|
// carry the flag down. Set by pack/each template instantiation,
|
|
37
|
-
// filter condition testing,
|
|
38
|
-
// ListVal.spreadClone)
|
|
39
|
-
//
|
|
47
|
+
// filter condition testing, spread application (MapVal/
|
|
48
|
+
// ListVal.spreadClone), and REFERENCE RESOLUTION of a target that
|
|
49
|
+
// holds no staged call, whose copy is a per-destination instance
|
|
50
|
+
// too (ADR-025) — never by the residuation clone, whose sharing is
|
|
51
|
+
// pinned behaviour, and never by a copy of something still being
|
|
52
|
+
// settled at its own site, which is what keeps the ghost rows.
|
|
40
53
|
dup?: boolean,
|
|
41
54
|
|
|
42
55
|
|
|
@@ -168,6 +181,24 @@ abstract class Val {
|
|
|
168
181
|
// and the edge set (ts/src/graph.ts) is exactly the set of these.
|
|
169
182
|
link?: string
|
|
170
183
|
|
|
184
|
+
// THE READ ADDRESS (RENDER.0.md P7): the tree path a reference
|
|
185
|
+
// resolved this value AT, stamped where it was found. A resolved
|
|
186
|
+
// reference CLONES its target into the referring position, so a
|
|
187
|
+
// value that arrived by reference otherwise knows only where it came
|
|
188
|
+
// to rest -- and a trace saying a line came from `$.code.units.0`
|
|
189
|
+
// names the output, not the model. Written only by an instrumented
|
|
190
|
+
// run (AontuContext.reads), carried by clone and by the meet rider,
|
|
191
|
+
// exactly as the deprecation record is.
|
|
192
|
+
origin?: string
|
|
193
|
+
|
|
194
|
+
// THE DISPATCH THAT PRODUCED THIS PIECE (RENDER.0.md D11, P7): the
|
|
195
|
+
// node an `emit` matched and the rule it took, stamped on every
|
|
196
|
+
// piece the dispatch instantiated. The INNERMOST dispatch wins: a
|
|
197
|
+
// nested rule set splices its pieces into the outer result, and the
|
|
198
|
+
// rule that wrote a line is the one that wrote it. Written only by
|
|
199
|
+
// an instrumented run, and carried like `origin`.
|
|
200
|
+
emitted?: EmitOrigin
|
|
201
|
+
|
|
171
202
|
// The GRAPH of an evaluated document (G4 phase 3): the edge set,
|
|
172
203
|
// stamped on the result by Aontu.unify the way the include manifest
|
|
173
204
|
// is. Absent on every Val that is not a unify result.
|
|
@@ -301,6 +332,18 @@ abstract class Val {
|
|
|
301
332
|
out.deprecation = this.deprecation
|
|
302
333
|
}
|
|
303
334
|
|
|
335
|
+
// THE RENDER RIDERS TRAVEL WITH THE CLONE (P7), for the reason the
|
|
336
|
+
// deprecation record does: a clone of a value read at `$.schema`
|
|
337
|
+
// was read at `$.schema`, and a clone of an emitted piece is still
|
|
338
|
+
// that dispatch's. Both are absent unless the run is instrumented,
|
|
339
|
+
// so this is two undefined reads otherwise.
|
|
340
|
+
if (null != this.origin) {
|
|
341
|
+
out.origin = this.origin
|
|
342
|
+
}
|
|
343
|
+
if (null != this.emitted) {
|
|
344
|
+
out.emitted = this.emitted
|
|
345
|
+
}
|
|
346
|
+
|
|
304
347
|
// THE APPLY-ONCE MARK TRAVELS WITH THE CLONE. `_spr` records which
|
|
305
348
|
// spread template has already been merged into this value, and the
|
|
306
349
|
// bag loops read it to keep a template from being applied twice
|
|
@@ -400,6 +443,33 @@ abstract class Val {
|
|
|
400
443
|
}
|
|
401
444
|
|
|
402
445
|
|
|
446
|
+
// A STAGED CALL STANDING ANYWHERE IN THIS VALUE (the `staged` flag,
|
|
447
|
+
// G8 phase 0). Such a call has not decided: its arguments are still
|
|
448
|
+
// being driven AT ITS OWN SITE, so a REFERENCE's copy shares it
|
|
449
|
+
// rather than owning a set of arguments it would drive at the
|
|
450
|
+
// referring position instead (RefVal.find, ADR-025). Not cached:
|
|
451
|
+
// unlike isPathDependent this is a fact about the value's current
|
|
452
|
+
// state, and the whole point is that it stops being true.
|
|
453
|
+
get holdsStaged(): boolean {
|
|
454
|
+
if (true === (this as any).staged) {
|
|
455
|
+
return true
|
|
456
|
+
}
|
|
457
|
+
const peg: any = this.peg
|
|
458
|
+
if (Array.isArray(peg)) {
|
|
459
|
+
for (let i = 0; i < peg.length; i++) {
|
|
460
|
+
if (true === peg[i]?.isVal && peg[i].holdsStaged) return true
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else if (null != peg && 'object' === typeof peg) {
|
|
464
|
+
for (const k in peg) {
|
|
465
|
+
if (true === peg[k]?.isVal && peg[k].holdsStaged) return true
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
const spreadCj = (this as any).spread?.cj as Val | undefined
|
|
469
|
+
return true === spreadCj?.isVal && (spreadCj as any).holdsStaged
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
|
|
403
473
|
// PUT A MINTED VALUE WHERE THIS ONE STANDS: the site travels, and so
|
|
404
474
|
// does provenance, because the two answer one question. A narrowed
|
|
405
475
|
// disjunction, a lifted kind, a resolved reference -- each is a
|
|
@@ -670,10 +740,11 @@ function empty(o: any) {
|
|
|
670
740
|
|| (null != o && 'object' === typeof o && 0 === Object.keys(o).length)
|
|
671
741
|
|| false
|
|
672
742
|
)
|
|
673
|
-
} /* node:coverage ignore next
|
|
743
|
+
} /* node:coverage ignore next 18 */
|
|
674
744
|
|
|
675
745
|
|
|
676
746
|
export type {
|
|
747
|
+
EmitOrigin,
|
|
677
748
|
ValMark,
|
|
678
749
|
ValSpec,
|
|
679
750
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* Copyright (c) 2025 Richard Rodger, MIT License */
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// THE MEMBERS OF A BAG, as every fold and every generator over a bag
|
|
5
|
+
// sees them (use-cases/BUGS.md §79; G9 phase 0 item 4). A member is a
|
|
6
|
+
// child that generation would EMIT: a hide()- or type()-marked child
|
|
7
|
+
// is not one, an alias declaration is not one, and an optional key
|
|
8
|
+
// whose value generates nothing -- an unfilled `y?: string`, an absent
|
|
9
|
+
// optional subtree -- is not one. `each`, `emit`, `filter`, `pick`,
|
|
10
|
+
// `join` and the aggregates read a bag through this one function, so a
|
|
11
|
+
// value the document withholds from its output is withheld from every
|
|
12
|
+
// text and every total the document computes from it: a hidden field
|
|
13
|
+
// that reached generated source through `join` is the defect this
|
|
14
|
+
// closes, and it was one behaviour in both ports because each verb
|
|
15
|
+
// had its own enumeration and none of them asked the mark.
|
|
16
|
+
//
|
|
17
|
+
// Maps list their members in code-point key order (../keyorder.ts),
|
|
18
|
+
// lists in index order -- the one order canon, generation and the Go
|
|
19
|
+
// port agree on (BUGS.md §62). Twin of bagMembers in go/members.go.
|
|
20
|
+
|
|
21
|
+
import type { Val } from '../type'
|
|
22
|
+
import { AontuContext } from '../ctx'
|
|
23
|
+
import { cmpCodePoint } from '../keyorder'
|
|
24
|
+
import { empty } from './Val'
|
|
25
|
+
import { bagGenable } from './BagVal'
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
type Member = { key: string, val: Val }
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
function bagMembers(data: any, ctx: AontuContext): Member[] | undefined {
|
|
32
|
+
if (true !== data?.isMap && true !== data?.isList) {
|
|
33
|
+
return undefined
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const keys: string[] = true === data.isMap ?
|
|
37
|
+
Object.keys(data.peg).sort(cmpCodePoint) :
|
|
38
|
+
(data.peg as Val[]).map((_v: Val, i: number) => '' + i)
|
|
39
|
+
|
|
40
|
+
// A member marked while its bag is not was marked in its own right,
|
|
41
|
+
// and is left out as generation leaves it out. Under a MARKED bag
|
|
42
|
+
// every child carries the mark (hide() and type() mark to the
|
|
43
|
+
// leaves), so there the mark says nothing about the member and every
|
|
44
|
+
// child is one -- the members of a hidden bag are what the bag
|
|
45
|
+
// holds, exactly as a reference to it lifts them.
|
|
46
|
+
const lifted = true === data.mark.hide || true === data.mark.type
|
|
47
|
+
|
|
48
|
+
const out: Member[] = []
|
|
49
|
+
for (const key of keys) {
|
|
50
|
+
const val: any = data.peg[key]
|
|
51
|
+
if ((!lifted && (true === val.mark.hide || true === val.mark.type))
|
|
52
|
+
|| data.aliasKeys.includes(key)) {
|
|
53
|
+
continue
|
|
54
|
+
}
|
|
55
|
+
if (data.optionalKeys.includes(key) && !filled(val, ctx)) {
|
|
56
|
+
continue
|
|
57
|
+
}
|
|
58
|
+
out.push({ key, val })
|
|
59
|
+
}
|
|
60
|
+
return out
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// An optional child is a member when it generates something, decided
|
|
65
|
+
// as BagVal.gen decides it: in an isolated collect context, so residue
|
|
66
|
+
// inside an absent optional subtree is dropped rather than raised.
|
|
67
|
+
function filled(val: any, ctx: AontuContext): boolean {
|
|
68
|
+
if (!bagGenable(val)) {
|
|
69
|
+
return false
|
|
70
|
+
}
|
|
71
|
+
const cval = val.gen(ctx.clone({ err: [], collect: true }))
|
|
72
|
+
return undefined !== cval && !empty(cval)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// The member values alone, for the verbs that do not need the keys.
|
|
77
|
+
function memberVals(data: any, ctx: AontuContext): Val[] | undefined {
|
|
78
|
+
const members = bagMembers(data, ctx)
|
|
79
|
+
return undefined === members ? undefined : members.map((m) => m.val)
|
|
80
|
+
} /* node:coverage ignore next 6 */
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
bagMembers,
|
|
85
|
+
memberVals,
|
|
86
|
+
}
|