aontu 0.61.0 → 0.63.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 +4 -4
- package/dist/agentsmd.d.ts +1 -0
- package/dist/agentsmd.js +7 -28
- package/dist/agentsmd.js.map +1 -1
- package/dist/alias.js.map +1 -1
- package/dist/allow.d.ts +23 -0
- package/dist/allow.js +138 -0
- package/dist/allow.js.map +1 -0
- package/dist/aontu.d.ts +4 -2
- package/dist/aontu.js +4 -80
- package/dist/aontu.js.map +1 -1
- package/dist/aontumodel.d.ts +4 -0
- package/dist/aontumodel.js +33 -0
- package/dist/aontumodel.js.map +1 -0
- package/dist/cli.d.ts +10 -1
- package/dist/cli.js +877 -479
- package/dist/cli.js.map +1 -1
- package/dist/ctx.js +0 -48
- package/dist/ctx.js.map +1 -1
- package/dist/diff.js +0 -32
- package/dist/diff.js.map +1 -1
- package/dist/err.js +0 -40
- package/dist/err.js.map +1 -1
- package/dist/escape.js +0 -45
- package/dist/escape.js.map +1 -1
- package/dist/exactjson.d.ts +0 -35
- package/dist/exactjson.js +0 -131
- package/dist/exactjson.js.map +1 -1
- package/dist/format.js +55 -189
- package/dist/format.js.map +1 -1
- package/dist/grammar.d.ts +9 -0
- package/dist/grammar.js +54 -0
- package/dist/grammar.js.map +1 -0
- package/dist/graph.js +0 -26
- package/dist/graph.js.map +1 -1
- package/dist/hcanon.js +0 -82
- package/dist/hcanon.js.map +1 -1
- package/dist/helpdoc.d.ts +16 -0
- package/dist/helpdoc.js +59 -0
- package/dist/helpdoc.js.map +1 -0
- package/dist/hints.d.ts +0 -6
- package/dist/hints.js +59 -47
- package/dist/hints.js.map +1 -1
- package/dist/jsonschema.js +0 -114
- package/dist/jsonschema.js.map +1 -1
- package/dist/keyorder.d.ts +0 -7
- package/dist/keyorder.js +0 -41
- package/dist/keyorder.js.map +1 -1
- package/dist/lang.js +32 -877
- package/dist/lang.js.map +1 -1
- package/dist/lower.d.ts +3 -0
- package/dist/lower.js +14 -61
- package/dist/lower.js.map +1 -1
- package/dist/lsp-server.js +0 -16
- package/dist/lsp-server.js.map +1 -1
- package/dist/lsp.d.ts +1 -1
- package/dist/lsp.js +12 -159
- package/dist/lsp.js.map +1 -1
- package/dist/mcp-server.js +0 -26
- package/dist/mcp-server.js.map +1 -1
- package/dist/mcp.js +0 -113
- package/dist/mcp.js.map +1 -1
- package/dist/mod-tool.js +0 -130
- package/dist/mod-tool.js.map +1 -1
- package/dist/mod.js +0 -162
- package/dist/mod.js.map +1 -1
- package/dist/patch.js +0 -217
- package/dist/patch.js.map +1 -1
- package/dist/provenance.js +0 -140
- package/dist/provenance.js.map +1 -1
- package/dist/query.js +0 -75
- package/dist/query.js.map +1 -1
- package/dist/reach.js +0 -43
- package/dist/reach.js.map +1 -1
- package/dist/relation.d.ts +2 -0
- package/dist/relation.js +3 -58
- package/dist/relation.js.map +1 -1
- package/dist/render.js +33 -143
- package/dist/render.js.map +1 -1
- package/dist/report-sarif.d.ts +0 -11
- package/dist/report-sarif.js +0 -28
- package/dist/report-sarif.js.map +1 -1
- package/dist/sig.js +0 -35
- package/dist/sig.js.map +1 -1
- package/dist/sigdecl.js +1 -1
- package/dist/sigdecl.js.map +1 -1
- package/dist/siggate.js +0 -4
- package/dist/siggate.js.map +1 -1
- package/dist/site.js +3 -29
- package/dist/site.js.map +1 -1
- package/dist/subsume.d.ts +0 -10
- package/dist/subsume.js +0 -137
- package/dist/subsume.js.map +1 -1
- package/dist/template.d.ts +2 -1
- package/dist/template.js +58 -138
- package/dist/template.js.map +1 -1
- package/dist/trim.js +0 -41
- package/dist/trim.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.js.map +1 -1
- package/dist/unify.js +12 -242
- package/dist/unify.js.map +1 -1
- package/dist/utility.js +0 -22
- package/dist/utility.js.map +1 -1
- package/dist/val/AbnfFuncVal.d.ts +18 -0
- package/dist/val/AbnfFuncVal.js +132 -0
- package/dist/val/AbnfFuncVal.js.map +1 -0
- package/dist/val/AbsentVal.d.ts +11 -0
- package/dist/val/AbsentVal.js +30 -0
- package/dist/val/AbsentVal.js.map +1 -0
- package/dist/val/AggFuncVal.d.ts +10 -1
- package/dist/val/AggFuncVal.js +104 -116
- package/dist/val/AggFuncVal.js.map +1 -1
- package/dist/val/ArithFuncVal.js +0 -12
- package/dist/val/ArithFuncVal.js.map +1 -1
- package/dist/val/BagVal.js +1 -78
- package/dist/val/BagVal.js.map +1 -1
- package/dist/val/BigDecimalVal.js +0 -16
- package/dist/val/BigDecimalVal.js.map +1 -1
- package/dist/val/BigIntegerVal.js +0 -16
- package/dist/val/BigIntegerVal.js.map +1 -1
- package/dist/val/CloseFuncVal.js +0 -9
- package/dist/val/CloseFuncVal.js.map +1 -1
- package/dist/val/CmpFuncVal.d.ts +20 -0
- package/dist/val/CmpFuncVal.js +188 -0
- package/dist/val/CmpFuncVal.js.map +1 -0
- package/dist/val/ConjunctVal.js +0 -29
- package/dist/val/ConjunctVal.js.map +1 -1
- package/dist/val/ConstraintVal.js +0 -500
- package/dist/val/ConstraintVal.js.map +1 -1
- package/dist/val/ContainerKindVal.js +0 -2
- package/dist/val/ContainerKindVal.js.map +1 -1
- package/dist/val/CopyFuncVal.js +0 -3
- package/dist/val/CopyFuncVal.js.map +1 -1
- package/dist/val/Decimal.js +0 -179
- package/dist/val/Decimal.js.map +1 -1
- package/dist/val/DeprecateFuncVal.js.map +1 -1
- package/dist/val/DisjunctVal.js +0 -152
- package/dist/val/DisjunctVal.js.map +1 -1
- package/dist/val/EachFuncVal.d.ts +1 -2
- package/dist/val/EachFuncVal.js +12 -29
- package/dist/val/EachFuncVal.js.map +1 -1
- package/dist/val/EmitFuncVal.d.ts +1 -1
- package/dist/val/EmitFuncVal.js +6 -119
- package/dist/val/EmitFuncVal.js.map +1 -1
- package/dist/val/ExpectVal.js +0 -62
- package/dist/val/ExpectVal.js.map +1 -1
- package/dist/val/FilterFuncVal.js +0 -25
- package/dist/val/FilterFuncVal.js.map +1 -1
- package/dist/val/FuncBaseVal.d.ts +1 -0
- package/dist/val/FuncBaseVal.js +7 -127
- package/dist/val/FuncBaseVal.js.map +1 -1
- package/dist/val/GraphAtomVal.js +0 -15
- package/dist/val/GraphAtomVal.js.map +1 -1
- package/dist/val/HideFuncVal.js +0 -13
- package/dist/val/HideFuncVal.js.map +1 -1
- package/dist/val/IntegerVal.js +0 -61
- package/dist/val/IntegerVal.js.map +1 -1
- package/dist/val/JunctionVal.js +0 -20
- package/dist/val/JunctionVal.js.map +1 -1
- package/dist/val/KeyFuncVal.js +0 -46
- package/dist/val/KeyFuncVal.js.map +1 -1
- package/dist/val/ListVal.js +0 -57
- package/dist/val/ListVal.js.map +1 -1
- package/dist/val/LowerFuncVal.js +11 -6
- package/dist/val/LowerFuncVal.js.map +1 -1
- package/dist/val/MapVal.js +0 -151
- package/dist/val/MapVal.js.map +1 -1
- package/dist/val/MatchFuncVal.js +0 -27
- package/dist/val/MatchFuncVal.js.map +1 -1
- package/dist/val/{FormFuncVal.d.ts → MaybeFuncVal.d.ts} +5 -5
- package/dist/val/MaybeFuncVal.js +50 -0
- package/dist/val/MaybeFuncVal.js.map +1 -0
- package/dist/val/MoveFuncVal.js +0 -18
- package/dist/val/MoveFuncVal.js.map +1 -1
- package/dist/val/NilVal.js +2 -36
- package/dist/val/NilVal.js.map +1 -1
- package/dist/val/NomFuncVal.d.ts +12 -0
- package/dist/val/NomFuncVal.js +153 -0
- package/dist/val/NomFuncVal.js.map +1 -0
- package/dist/val/NumberVal.js +0 -15
- package/dist/val/NumberVal.js.map +1 -1
- package/dist/val/OpBaseVal.d.ts +1 -0
- package/dist/val/OpBaseVal.js +3 -15
- package/dist/val/OpBaseVal.js.map +1 -1
- package/dist/val/PackFuncVal.js +0 -34
- package/dist/val/PackFuncVal.js.map +1 -1
- package/dist/val/PathFuncVal.js +0 -6
- package/dist/val/PathFuncVal.js.map +1 -1
- package/dist/val/PathVal.js +0 -41
- package/dist/val/PathVal.js.map +1 -1
- package/dist/val/PlaceVal.js +0 -25
- package/dist/val/PlaceVal.js.map +1 -1
- package/dist/val/PlusOpVal.d.ts +1 -7
- package/dist/val/PlusOpVal.js +13 -74
- package/dist/val/PlusOpVal.js.map +1 -1
- package/dist/val/PrefFuncVal.js +0 -1
- package/dist/val/PrefFuncVal.js.map +1 -1
- package/dist/val/PrefVal.js +0 -167
- package/dist/val/PrefVal.js.map +1 -1
- package/dist/val/RecurseVal.js +0 -55
- package/dist/val/RecurseVal.js.map +1 -1
- package/dist/val/RefVal.js +0 -282
- package/dist/val/RefVal.js.map +1 -1
- package/dist/val/ReferFuncVal.js +0 -232
- package/dist/val/ReferFuncVal.js.map +1 -1
- package/dist/val/ScalarKindVal.js +0 -49
- package/dist/val/ScalarKindVal.js.map +1 -1
- package/dist/val/ScalarVal.js +0 -11
- package/dist/val/ScalarVal.js.map +1 -1
- package/dist/val/StrFuncVal.js +0 -18
- package/dist/val/StrFuncVal.js.map +1 -1
- package/dist/val/SuperFuncVal.js +0 -32
- package/dist/val/SuperFuncVal.js.map +1 -1
- package/dist/val/TopVal.js +0 -1
- package/dist/val/TopVal.js.map +1 -1
- package/dist/val/TranslateFuncVal.d.ts +12 -0
- package/dist/val/TranslateFuncVal.js +99 -0
- package/dist/val/TranslateFuncVal.js.map +1 -0
- package/dist/val/UpperFuncVal.js +11 -6
- package/dist/val/UpperFuncVal.js.map +1 -1
- package/dist/val/Val.d.ts +1 -0
- package/dist/val/Val.js +2 -133
- package/dist/val/Val.js.map +1 -1
- package/dist/val/VarVal.js +0 -12
- package/dist/val/VarVal.js.map +1 -1
- package/dist/val/arith.js +0 -37
- package/dist/val/arith.js.map +1 -1
- package/dist/val/caserange.d.ts +3 -0
- package/dist/val/caserange.js +49 -0
- package/dist/val/caserange.js.map +1 -0
- package/dist/val/members.js +0 -6
- package/dist/val/members.js.map +1 -1
- package/dist/val/numcmp.js +0 -11
- package/dist/val/numcmp.js.map +1 -1
- package/dist/val/numkind.js +0 -145
- package/dist/val/numkind.js.map +1 -1
- package/dist/val/valutil.js +0 -16
- package/dist/val/valutil.js.map +1 -1
- package/dist/vet.d.ts +12 -0
- package/dist/vet.js +159 -412
- package/dist/vet.js.map +1 -1
- package/dist/view.js +0 -414
- package/dist/view.js.map +1 -1
- package/dist/walk.js +0 -41
- package/dist/walk.js.map +1 -1
- package/grammar/aontu.abnf +9 -7
- package/grammar/aontu.gbnf +5 -5
- package/grammar/aontu.lark +5 -5
- package/grammar/aontu.tmLanguage.json +1 -1
- package/package.json +4 -2
- package/skill/SKILL.md +8 -0
- package/skill/init/check.sh +28 -0
- package/skill/init/data.aon +12 -0
- package/skill/init/model.aon +19 -0
- package/skill/tasks.md +151 -0
- package/src/agentsmd.ts +8 -32
- package/src/alias.ts +0 -39
- package/src/allow.ts +221 -0
- package/src/aontu.ts +10 -108
- package/src/aontumodel.ts +32 -0
- package/src/cli.ts +1009 -540
- package/src/ctx.ts +0 -103
- package/src/diff.ts +0 -40
- package/src/err.ts +0 -40
- package/src/escape.ts +0 -46
- package/src/exactjson.ts +0 -131
- package/src/format.ts +63 -234
- package/src/grammar.ts +72 -0
- package/src/graph.ts +0 -61
- package/src/hcanon.ts +0 -82
- package/src/helpdoc.ts +77 -0
- package/src/hints.ts +72 -49
- package/src/jsonschema.ts +0 -123
- package/src/keyorder.ts +0 -42
- package/src/lang.ts +39 -895
- package/src/lower.ts +15 -65
- package/src/lsp-server.ts +0 -16
- package/src/lsp.ts +12 -180
- package/src/mcp-server.ts +0 -31
- package/src/mcp.ts +0 -130
- package/src/mod-tool.ts +0 -158
- package/src/mod.ts +0 -178
- package/src/patch.ts +0 -232
- package/src/provenance.ts +0 -183
- package/src/query.ts +0 -84
- package/src/reach.ts +0 -53
- package/src/relation.ts +7 -71
- package/src/render.ts +33 -180
- package/src/report-sarif.ts +0 -48
- package/src/sig.ts +0 -35
- package/src/sigdecl.ts +1 -1
- package/src/siggate.ts +0 -30
- package/src/site.ts +3 -29
- package/src/subsume.ts +1 -161
- package/src/template.ts +69 -140
- package/src/trim.ts +0 -53
- package/src/type.ts +2 -45
- package/src/unify.ts +13 -251
- package/src/utility.ts +0 -31
- package/src/val/AbnfFuncVal.ts +181 -0
- package/src/val/AbsentVal.ts +54 -0
- package/src/val/AggFuncVal.ts +152 -188
- package/src/val/ArithFuncVal.ts +0 -20
- package/src/val/BagVal.ts +1 -78
- package/src/val/BigDecimalVal.ts +0 -16
- package/src/val/BigIntegerVal.ts +0 -16
- package/src/val/CloseFuncVal.ts +0 -9
- package/src/val/CmpFuncVal.ts +249 -0
- package/src/val/ConjunctVal.ts +0 -33
- package/src/val/ConstraintVal.ts +2 -537
- package/src/val/ContainerKindVal.ts +0 -18
- package/src/val/CopyFuncVal.ts +0 -5
- package/src/val/Decimal.ts +1 -185
- package/src/val/DeprecateFuncVal.ts +0 -10
- package/src/val/DisjunctVal.ts +0 -157
- package/src/val/EachFuncVal.ts +12 -53
- package/src/val/EmitFuncVal.ts +8 -208
- package/src/val/ExpectVal.ts +0 -62
- package/src/val/FilterFuncVal.ts +0 -55
- package/src/val/FuncBaseVal.ts +9 -130
- package/src/val/GraphAtomVal.ts +0 -42
- package/src/val/HideFuncVal.ts +0 -15
- package/src/val/IntegerVal.ts +0 -61
- package/src/val/JunctionVal.ts +0 -20
- package/src/val/KeyFuncVal.ts +0 -48
- package/src/val/ListVal.ts +0 -59
- package/src/val/LowerFuncVal.ts +12 -7
- package/src/val/MapVal.ts +0 -151
- package/src/val/MatchFuncVal.ts +0 -59
- package/src/val/MaybeFuncVal.ts +86 -0
- package/src/val/MoveFuncVal.ts +0 -20
- package/src/val/NilVal.ts +2 -36
- package/src/val/NomFuncVal.ts +200 -0
- package/src/val/NumberVal.ts +0 -16
- package/src/val/OpBaseVal.ts +4 -17
- package/src/val/PackFuncVal.ts +0 -63
- package/src/val/PathFuncVal.ts +0 -32
- package/src/val/PathVal.ts +0 -66
- package/src/val/PlaceVal.ts +0 -45
- package/src/val/PlusOpVal.ts +18 -75
- package/src/val/PrefFuncVal.ts +0 -1
- package/src/val/PrefVal.ts +0 -179
- package/src/val/RecurseVal.ts +0 -81
- package/src/val/RefVal.ts +1 -285
- package/src/val/ReferFuncVal.ts +0 -255
- package/src/val/ScalarKindVal.ts +0 -50
- package/src/val/ScalarVal.ts +0 -12
- package/src/val/StrFuncVal.ts +0 -44
- package/src/val/SuperFuncVal.ts +0 -42
- package/src/val/TopVal.ts +0 -1
- package/src/val/TranslateFuncVal.ts +132 -0
- package/src/val/UpperFuncVal.ts +12 -7
- package/src/val/Val.ts +3 -192
- package/src/val/VarVal.ts +0 -15
- package/src/val/arith.ts +0 -92
- package/src/val/caserange.ts +53 -0
- package/src/val/members.ts +0 -23
- package/src/val/numcmp.ts +1 -27
- package/src/val/numkind.ts +0 -149
- package/src/val/valutil.ts +0 -16
- package/src/vet.ts +209 -504
- package/src/view.ts +0 -507
- package/src/walk.ts +0 -41
- package/dist/std.d.ts +0 -3
- package/dist/std.js +0 -637
- package/dist/std.js.map +0 -1
- package/dist/val/FormFuncVal.js +0 -55
- package/dist/val/FormFuncVal.js.map +0 -1
- package/src/std.ts +0 -648
- package/src/val/FormFuncVal.ts +0 -119
package/src/mod.ts
CHANGED
|
@@ -1,61 +1,24 @@
|
|
|
1
1
|
/* Copyright (c) 2025 Richard Rodger, MIT License */
|
|
2
2
|
|
|
3
|
-
// MODULE IDENTITY AND LOCAL RESOLUTION (G6 phase 2,
|
|
4
|
-
// docs/capability-review/g6-distribution.md).
|
|
5
|
-
//
|
|
6
|
-
// An import is still just `@"…"`; the string's SHAPE routes it, so the
|
|
7
|
-
// grammar is untouched and every existing include keeps its exact
|
|
8
|
-
// behaviour:
|
|
9
|
-
//
|
|
10
|
-
// service: @"corp.example/schemas/service@1"
|
|
11
|
-
// frozen: @"corp.example/schemas/service@1#aon1-4vJemVYtWFR2mQeN…"
|
|
12
|
-
// local: @"./fragment.aon" <- unchanged, not a module
|
|
13
|
-
//
|
|
14
|
-
// EVALUATION NEVER TOUCHES THE NETWORK. Resolution reads local stores
|
|
15
|
-
// only: `aontu_meta/vendor/` beside the project's `mod.aon`, then a
|
|
16
|
-
// content-addressed user cache keyed by canon-hash. Fetching is a
|
|
17
|
-
// separate, explicit tool step, and a module that is in neither store
|
|
18
|
-
// is an evaluation error that says so.
|
|
19
|
-
//
|
|
20
|
-
// TWO PINS, TWO ROLES. The lockfile's `oci` digest certifies that these
|
|
21
|
-
// are the bytes the registry served; the `canon` hash certifies that
|
|
22
|
-
// this is the MEANING that was reviewed. Only the second can be checked
|
|
23
|
-
// locally without the registry, and it is the one this file checks: the
|
|
24
|
-
// module is unified standalone and its canon-hash compared with the
|
|
25
|
-
// pin. An inline `#aon1-…` fragment is the same check without a
|
|
26
|
-
// lockfile — the degenerate mode for single-file and agent-sandbox use.
|
|
27
3
|
|
|
28
4
|
import { join as pathJoin, dirname as pathDirname } from 'node:path'
|
|
29
5
|
|
|
30
6
|
|
|
31
|
-
// A module import, as the string spells it.
|
|
32
7
|
export type ModuleRef = {
|
|
33
8
|
// The module path WITHOUT the major: `corp.example/schemas/service`.
|
|
34
9
|
path: string
|
|
35
|
-
// The major version, from the `@N` suffix.
|
|
36
10
|
major: number
|
|
37
11
|
// The inline canon-hash pin, if the import froze one.
|
|
38
12
|
hash?: string
|
|
39
13
|
}
|
|
40
14
|
|
|
41
15
|
|
|
42
|
-
// A file store the resolver can read. The engine passes its own `fs`
|
|
43
|
-
// when the host injected one, so a sandboxed evaluation stays in the
|
|
44
|
-
// filesystem the host gave it.
|
|
45
16
|
export type ModuleFs = {
|
|
46
17
|
existsSync: (p: string) => boolean
|
|
47
18
|
readFileSync: (p: string, enc: string) => string
|
|
48
19
|
}
|
|
49
20
|
|
|
50
21
|
|
|
51
|
-
// A module path is DOMAIN-SHAPED — the first segment carries a dot,
|
|
52
|
-
// which is what tells it apart from `./local.aon`, `pkg-name` and every
|
|
53
|
-
// other spelling already in use — and carries the major version in the
|
|
54
|
-
// path, CUE/Go-style, so two majors are two modules.
|
|
55
|
-
//
|
|
56
|
-
// The pattern is deliberately narrow: anything it does not match falls
|
|
57
|
-
// through to the existing resolver chain unchanged, so no document that
|
|
58
|
-
// worked before this phase can be routed somewhere new by it.
|
|
59
22
|
const MODULE_RE =
|
|
60
23
|
/^([a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)+(?:\/[A-Za-z0-9._-]+)*)@(\d+)(?:#(aon1-[A-Za-z0-9_-]+))?$/
|
|
61
24
|
|
|
@@ -73,33 +36,10 @@ export function parseModuleRef(spec: string): ModuleRef | undefined {
|
|
|
73
36
|
}
|
|
74
37
|
|
|
75
38
|
|
|
76
|
-
// SHAPE IS NOT VALIDITY, and the gap between them was a hole. MODULE_RE
|
|
77
|
-
// answers "does this string route to the module resolver" -- a
|
|
78
|
-
// ROUTING predicate, and it must stay one, because anything it rejects
|
|
79
|
-
// falls through to the file leg and a stricter pattern would silently
|
|
80
|
-
// re-route documents that work today. But its element class
|
|
81
|
-
// `[A-Za-z0-9._-]` admits `..`, and `moduleDir` joins elements with
|
|
82
|
-
// pathJoin, which CLEANS `..` rather than refusing it:
|
|
83
|
-
//
|
|
84
|
-
// moduleDir('/store/aontu_meta/vendor', 'corp.example/../../etc/passwd@1')
|
|
85
|
-
// -> /store/etc/passwd@1
|
|
86
|
-
//
|
|
87
|
-
// `mod vendor` then copied a tree THERE, outside the project entirely,
|
|
88
|
-
// and reported `verdict: ok`. So validity is a separate question asked
|
|
89
|
-
// separately, after the shape matched, and asked at every site that
|
|
90
|
-
// turns a module path into a directory.
|
|
91
|
-
//
|
|
92
|
-
// The rules are Go's (golang.org/x/mod/module.CheckPath), for the
|
|
93
|
-
// reason Go has them: a module path becomes a real directory on every
|
|
94
|
-
// platform the toolchain runs on, so it must be a legal one everywhere.
|
|
95
39
|
export const MODULE_MAX_PATH = 512
|
|
96
40
|
export const MODULE_MAX_ELEMS = 32
|
|
97
41
|
|
|
98
42
|
|
|
99
|
-
// Windows refuses these as file names whatever the extension, so a
|
|
100
|
-
// module path containing one cannot be materialised there at all. The
|
|
101
|
-
// check is on the element up to its first dot, which is where Windows
|
|
102
|
-
// stops looking too.
|
|
103
43
|
const RESERVED_ELEMS = new Set([
|
|
104
44
|
'con', 'prn', 'aux', 'nul',
|
|
105
45
|
'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9',
|
|
@@ -107,9 +47,6 @@ const RESERVED_ELEMS = new Set([
|
|
|
107
47
|
])
|
|
108
48
|
|
|
109
49
|
|
|
110
|
-
// Why a module path may not be used as a directory, or undefined when
|
|
111
|
-
// it may. The reason is user-facing: it goes in the refusal, because a
|
|
112
|
-
// path refused without saying which rule it broke is a puzzle.
|
|
113
50
|
export function validateModulePath(path: string): string | undefined {
|
|
114
51
|
if (MODULE_MAX_PATH < path.length) {
|
|
115
52
|
return 'longer than ' + MODULE_MAX_PATH + ' characters'
|
|
@@ -124,10 +61,6 @@ export function validateModulePath(path: string): string | undefined {
|
|
|
124
61
|
if ('' === elem) {
|
|
125
62
|
return 'an element is empty'
|
|
126
63
|
}
|
|
127
|
-
// This one rule kills `.` and `..` -- the traversal -- along with
|
|
128
|
-
// `.hidden` and `trailing.`, exactly as Go's does. Stating it as
|
|
129
|
-
// the rule rather than as "no `..`" is deliberate: a check that
|
|
130
|
-
// named the two dangerous spellings would miss the next one.
|
|
131
64
|
if (elem.startsWith('.') || elem.endsWith('.')) {
|
|
132
65
|
return 'an element begins or ends with "."'
|
|
133
66
|
}
|
|
@@ -140,46 +73,16 @@ export function validateModulePath(path: string): string | undefined {
|
|
|
140
73
|
}
|
|
141
74
|
|
|
142
75
|
|
|
143
|
-
// An element as it is spelled ON DISK. Uppercase is escaped to
|
|
144
|
-
// `!`+lowercase, Go's rule (go.dev/ref/mod, module proxy protocol) and
|
|
145
|
-
// for Go's reason: `github.com/Alice/Widgets` and
|
|
146
|
-
// `github.com/alice/widgets` are two module identities and, on macOS
|
|
147
|
-
// and Windows, ONE directory -- so without this the second module
|
|
148
|
-
// fetched silently clobbers the first, and an unpinned import resolves
|
|
149
|
-
// to whichever won.
|
|
150
|
-
//
|
|
151
|
-
// The WRITTEN path stays the identity; only the directory is escaped.
|
|
152
76
|
function escapeElem(elem: string): string {
|
|
153
77
|
return elem.replace(/[A-Z]/g, (c) => '!' + c.toLowerCase())
|
|
154
78
|
}
|
|
155
79
|
|
|
156
80
|
|
|
157
|
-
// The directory a module's files live in, under a store root.
|
|
158
|
-
//
|
|
159
|
-
// Callers must have validated the path (validateModulePath); this
|
|
160
|
-
// function cannot refuse, because it answers a location rather than a
|
|
161
|
-
// question, and every caller has a refusal shape of its own.
|
|
162
81
|
export function moduleDir(store: string, ref: ModuleRef): string {
|
|
163
82
|
return pathJoin(store, ...ref.path.split('/').map(escapeElem)) + '@' + ref.major
|
|
164
83
|
}
|
|
165
84
|
|
|
166
85
|
|
|
167
|
-
// EVERY project root at or above `from`, innermost first — a project
|
|
168
|
-
// root being a directory holding a `mod.aon`. This used to answer with
|
|
169
|
-
// the NEAREST one alone, and the plural is the fix, because a
|
|
170
|
-
// VENDORED MODULE IS A PROJECT INSIDE A PROJECT. A module in
|
|
171
|
-
// `aontu_meta/vendor/` carries its own `mod.aon`, which stopped the upward
|
|
172
|
-
// walk there, so a nested import resolved against the vendored
|
|
173
|
-
// module's own directory: a tree with no `aontu_meta/vendor/` of its own, and
|
|
174
|
-
// therefore a `module not fetched` for a dependency sitting flat
|
|
175
|
-
// beside it in the CONSUMER's vendor tree — the only layout `mod
|
|
176
|
-
// vendor` produces (use-cases/BUGS.md §31).
|
|
177
|
-
//
|
|
178
|
-
// The consumer's stores are searched after the module's own, so a
|
|
179
|
-
// module that vendors its dependencies nested still wins for its own
|
|
180
|
-
// tree, and one that does not falls through to the consumer that
|
|
181
|
-
// vendored it. The last element is `from` itself when nothing above it
|
|
182
|
-
// declares a module, which is the single-file inline-pin mode.
|
|
183
86
|
export function projectRoots(from: string, fs: ModuleFs): string[] {
|
|
184
87
|
const roots: string[] = []
|
|
185
88
|
let dir = from
|
|
@@ -196,18 +99,6 @@ export function projectRoots(from: string, fs: ModuleFs): string[] {
|
|
|
196
99
|
}
|
|
197
100
|
|
|
198
101
|
|
|
199
|
-
// The lockfile's pin for one import, or undefined.
|
|
200
|
-
//
|
|
201
|
-
// `mod-lock.aon` is machine-written CANONICAL Aontu, and canonical
|
|
202
|
-
// Aontu whose leaves are scalars IS JSON — which is why reading it here
|
|
203
|
-
// needs no evaluator, and why a hand-edited lockfile that is no longer
|
|
204
|
-
// canonical simply does not parse. It is generated; the file says so.
|
|
205
|
-
// The lockfile's JSON: its canonical line, with the generated-file
|
|
206
|
-
// header stripped. The file is AONTU, so it may carry `#` comments —
|
|
207
|
-
// and the header `aontu mod tidy` writes says not to edit it, which is
|
|
208
|
-
// worth more than the two lines it costs to skip. Everything below the
|
|
209
|
-
// comments is the canonical map, and canonical Aontu whose leaves are
|
|
210
|
-
// scalars is JSON.
|
|
211
102
|
export function lockJson(text: string): string {
|
|
212
103
|
return text
|
|
213
104
|
.split('\n')
|
|
@@ -216,38 +107,11 @@ export function lockJson(text: string): string {
|
|
|
216
107
|
}
|
|
217
108
|
|
|
218
109
|
|
|
219
|
-
// The user cache: `$XDG_CACHE_HOME/aontu/mod` unless the host names
|
|
220
|
-
// another, else the platform's own cache location. A host with nowhere
|
|
221
|
-
// to put one has no cache, which is a miss rather than a failure. One
|
|
222
|
-
// rule, in one place: the resolver reads this cache during evaluation
|
|
223
|
-
// and `aontu mod` writes into it, and two spellings of "where the cache
|
|
224
|
-
// is" is one bug.
|
|
225
110
|
export function modCacheDir(): string | undefined {
|
|
226
111
|
return modCacheDirFor(process.platform, process.env)
|
|
227
112
|
}
|
|
228
113
|
|
|
229
114
|
|
|
230
|
-
// That rule with the platform and the environment PASSED IN, so the
|
|
231
|
-
// Windows arm can be exercised off Windows — the only way a rule about
|
|
232
|
-
// a platform nobody here runs gets tested at all. The Go port splits
|
|
233
|
-
// the same way (modCacheDirFor, go/aontu.go).
|
|
234
|
-
//
|
|
235
|
-
// THE ORDER IS EXPLICIT BEFORE IMPLICIT, and LOCALAPPDATA is LAST.
|
|
236
|
-
// XDG_CACHE_HOME is the override and wins everywhere, Windows included:
|
|
237
|
-
// a caller who names a cache directory means it. HOME comes next and is
|
|
238
|
-
// also honoured on Windows, where it is not standard but IS set by Git
|
|
239
|
-
// Bash and by most development shells — a user who has one expects
|
|
240
|
-
// their tools to agree about where home is.
|
|
241
|
-
//
|
|
242
|
-
// LOCALAPPDATA is the PLATFORM DEFAULT beneath both, which is the whole
|
|
243
|
-
// addition: Windows sets neither XDG_CACHE_HOME nor HOME by default —
|
|
244
|
-
// it supplies USERPROFILE and LOCALAPPDATA, and LOCALAPPDATA is what a
|
|
245
|
-
// cache directory means there — so a rule that knew only the first two
|
|
246
|
-
// left every Windows user with NO cache. Putting it ABOVE HOME was the
|
|
247
|
-
// first attempt and was wrong: it made an explicitly set HOME
|
|
248
|
-
// unreachable on Windows, which broke the existing fallback test the
|
|
249
|
-
// moment CI ran it. A platform default that overrides what the
|
|
250
|
-
// environment was told is not a default.
|
|
251
115
|
export function modCacheDirFor(
|
|
252
116
|
platform: string,
|
|
253
117
|
env: Record<string, string | undefined>,
|
|
@@ -290,24 +154,10 @@ export function lockHash(root: string, ref: ModuleRef, fs: ModuleFs):
|
|
|
290
154
|
}
|
|
291
155
|
|
|
292
156
|
|
|
293
|
-
// What a module resolution needs from the engine: evaluate a source
|
|
294
|
-
// standalone and answer both what it MEANS (the generated value, for
|
|
295
|
-
// reading a module file's own metadata) and what its meaning HASHES to
|
|
296
|
-
// (for the integrity check). Injected rather than imported, because
|
|
297
|
-
// this is EVALUATION — the very thing this file is called from the
|
|
298
|
-
// middle of — and a module resolver that imported the evaluator would
|
|
299
|
-
// close a cycle around the whole language.
|
|
300
157
|
export type ModuleEval =
|
|
301
158
|
(src: string, path: string) => { gen: any, hash: string }
|
|
302
159
|
|
|
303
160
|
|
|
304
|
-
// How deep module verification may nest before it is refused. A module
|
|
305
|
-
// is verified by EVALUATING it, and that evaluation resolves the
|
|
306
|
-
// module's own imports -- so a vendor tree that leads back to itself
|
|
307
|
-
// (a symlink is enough) would recurse until the host's stack gave out,
|
|
308
|
-
// and a verdict that depends on the host's stack size is exactly what
|
|
309
|
-
// the determinism clause forbids (docs/trust.md, and the same argument
|
|
310
|
-
// unify_cycle rests on). Sixteen is far above any real vendor nesting.
|
|
311
161
|
export const MODULE_MAX_DEPTH = 16
|
|
312
162
|
|
|
313
163
|
|
|
@@ -316,10 +166,6 @@ export type ModuleOptions = {
|
|
|
316
166
|
// only when the expected hash is known, which is what "content
|
|
317
167
|
// addressed" means: without a pin there is no address.
|
|
318
168
|
cache?: string
|
|
319
|
-
// The standalone evaluator, for reading module files and for the
|
|
320
|
-
// integrity check. Always present: Aontu injects it (ts/src/aontu.ts)
|
|
321
|
-
// because only the class that evaluates can answer what a module
|
|
322
|
-
// MEANS, and the resolver runs inside a parse that class started.
|
|
323
169
|
eval: ModuleEval
|
|
324
170
|
// How many module verifications deep this evaluation already is.
|
|
325
171
|
depth?: number
|
|
@@ -333,23 +179,11 @@ export type ModuleFound = {
|
|
|
333
179
|
}
|
|
334
180
|
|
|
335
181
|
|
|
336
|
-
// EVERY code `resolveModule` can refuse with. The list lives HERE,
|
|
337
|
-
// beside the refusals themselves, because the parse layer has to
|
|
338
|
-
// recognise them to turn the throw into a parse-stage nil
|
|
339
|
-
// (ts/src/lang.ts) -- and when that list was written out longhand
|
|
340
|
-
// there, adding a fourth code left it unhandled and the refusal
|
|
341
|
-
// surfaced as `unexpected error` instead of the message it carries.
|
|
342
|
-
// The Go port has no such list (recordModErr takes any code), which is
|
|
343
|
-
// why only this side could drift.
|
|
344
182
|
export const MODULE_REFUSAL_CODES: ReadonlySet<string> = new Set([
|
|
345
183
|
'module_path', 'module_missing', 'module_integrity', 'module_depth',
|
|
346
184
|
])
|
|
347
185
|
|
|
348
186
|
|
|
349
|
-
// A refusal that carries its code to the parse layer, exactly as a
|
|
350
|
-
// denied include does (makeModelResolver's `deny`): the resolver
|
|
351
|
-
// THROWS, so a bare-member module import cannot vanish in the merge and
|
|
352
|
-
// leave a plausible, silently-partial document.
|
|
353
187
|
function refuse(code: string, message: string): never {
|
|
354
188
|
const err: any = new Error(message)
|
|
355
189
|
err.code = code
|
|
@@ -364,11 +198,6 @@ export function resolveModule(
|
|
|
364
198
|
fs: ModuleFs,
|
|
365
199
|
options: ModuleOptions,
|
|
366
200
|
): ModuleFound {
|
|
367
|
-
// THE PATH IS CHECKED BEFORE ANYTHING IS BUILT FROM IT. This is
|
|
368
|
-
// first because it is a question about the REQUEST, not about the
|
|
369
|
-
// state of the machine: a path that cannot legally be a directory is
|
|
370
|
-
// refused identically whether or not the module is present, and
|
|
371
|
-
// whether or not the depth bound is near.
|
|
372
201
|
const badpath = validateModulePath(ref.path)
|
|
373
202
|
if (undefined !== badpath) {
|
|
374
203
|
refuse('module_path',
|
|
@@ -401,9 +230,6 @@ export function resolveModule(
|
|
|
401
230
|
|
|
402
231
|
const dir = stores.find((d) => fs.existsSync(pathJoin(d, 'mod.aon')))
|
|
403
232
|
if (undefined === dir) {
|
|
404
|
-
// The wording is the contract (docs/capability-review/
|
|
405
|
-
// g6-distribution.md): it names the module AND the step that fixes
|
|
406
|
-
// it, because an agent reading this error is the audience.
|
|
407
233
|
refuse('module_missing',
|
|
408
234
|
'module not fetched: ' + ref.path + '@' + ref.major +
|
|
409
235
|
' (run: aontu mod get)')
|
|
@@ -439,10 +265,6 @@ export function resolveModule(
|
|
|
439
265
|
}
|
|
440
266
|
|
|
441
267
|
|
|
442
|
-
// The `mod.main` a module file declares, or the default entry name.
|
|
443
|
-
// The module file is ORDINARY AONTU, read by the language itself — the
|
|
444
|
-
// toolchain dogfooding its own evaluator rather than pattern-matching
|
|
445
|
-
// its own syntax with a regexp.
|
|
446
268
|
function moduleMain(file: string, fs: ModuleFs, options: ModuleOptions): string {
|
|
447
269
|
const gen: any = options.eval(fs.readFileSync(file, 'utf8'), file).gen
|
|
448
270
|
const main = gen?.mod?.main
|