aontu 0.62.0 → 0.64.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.
Files changed (373) hide show
  1. package/README.md +7 -7
  2. package/dist/agentsmd.js +0 -27
  3. package/dist/agentsmd.js.map +1 -1
  4. package/dist/alias.js.map +1 -1
  5. package/dist/allow.js +0 -92
  6. package/dist/allow.js.map +1 -1
  7. package/dist/aontu.d.ts +3 -3
  8. package/dist/aontu.js +4 -84
  9. package/dist/aontu.js.map +1 -1
  10. package/dist/aontumodel.d.ts +4 -0
  11. package/dist/aontumodel.js +27 -0
  12. package/dist/aontumodel.js.map +1 -0
  13. package/dist/casing.d.ts +5 -0
  14. package/dist/casing.js +90 -0
  15. package/dist/casing.js.map +1 -0
  16. package/dist/cli.d.ts +2 -2
  17. package/dist/cli.js +228 -935
  18. package/dist/cli.js.map +1 -1
  19. package/dist/ctx.js +0 -48
  20. package/dist/ctx.js.map +1 -1
  21. package/dist/diff.js +0 -32
  22. package/dist/diff.js.map +1 -1
  23. package/dist/err.js +0 -40
  24. package/dist/err.js.map +1 -1
  25. package/dist/escape.js +0 -45
  26. package/dist/escape.js.map +1 -1
  27. package/dist/exactjson.d.ts +0 -35
  28. package/dist/exactjson.js +0 -131
  29. package/dist/exactjson.js.map +1 -1
  30. package/dist/format.js +13 -203
  31. package/dist/format.js.map +1 -1
  32. package/dist/grammar.d.ts +9 -0
  33. package/dist/grammar.js +54 -0
  34. package/dist/grammar.js.map +1 -0
  35. package/dist/graph.js +0 -26
  36. package/dist/graph.js.map +1 -1
  37. package/dist/hcanon.js +0 -82
  38. package/dist/hcanon.js.map +1 -1
  39. package/dist/helpdoc.js +2 -2
  40. package/dist/helpdoc.js.map +1 -1
  41. package/dist/hints.d.ts +0 -6
  42. package/dist/hints.js +57 -55
  43. package/dist/hints.js.map +1 -1
  44. package/dist/jsonschema.js +0 -114
  45. package/dist/jsonschema.js.map +1 -1
  46. package/dist/keyorder.d.ts +0 -7
  47. package/dist/keyorder.js +0 -41
  48. package/dist/keyorder.js.map +1 -1
  49. package/dist/lang.js +17 -915
  50. package/dist/lang.js.map +1 -1
  51. package/dist/lsp-server.js +0 -16
  52. package/dist/lsp-server.js.map +1 -1
  53. package/dist/lsp.d.ts +1 -1
  54. package/dist/lsp.js +12 -159
  55. package/dist/lsp.js.map +1 -1
  56. package/dist/mcp-server.js +0 -26
  57. package/dist/mcp-server.js.map +1 -1
  58. package/dist/mcp.js +0 -149
  59. package/dist/mcp.js.map +1 -1
  60. package/dist/mod-tool.js +16 -131
  61. package/dist/mod-tool.js.map +1 -1
  62. package/dist/mod.js +0 -162
  63. package/dist/mod.js.map +1 -1
  64. package/dist/patch.js +0 -217
  65. package/dist/patch.js.map +1 -1
  66. package/dist/profile.d.ts +9 -0
  67. package/dist/profile.js +28 -0
  68. package/dist/profile.js.map +1 -0
  69. package/dist/provenance.js +0 -140
  70. package/dist/provenance.js.map +1 -1
  71. package/dist/query.js +0 -75
  72. package/dist/query.js.map +1 -1
  73. package/dist/reach.js +0 -43
  74. package/dist/reach.js.map +1 -1
  75. package/dist/relation.js +0 -61
  76. package/dist/relation.js.map +1 -1
  77. package/dist/report-sarif.d.ts +0 -11
  78. package/dist/report-sarif.js +0 -28
  79. package/dist/report-sarif.js.map +1 -1
  80. package/dist/sig.js +0 -35
  81. package/dist/sig.js.map +1 -1
  82. package/dist/sigdecl.js +1 -1
  83. package/dist/sigdecl.js.map +1 -1
  84. package/dist/siggate.js +0 -4
  85. package/dist/siggate.js.map +1 -1
  86. package/dist/site.js +3 -29
  87. package/dist/site.js.map +1 -1
  88. package/dist/subsume.d.ts +0 -10
  89. package/dist/subsume.js +0 -137
  90. package/dist/subsume.js.map +1 -1
  91. package/dist/template.d.ts +2 -1
  92. package/dist/template.js +58 -138
  93. package/dist/template.js.map +1 -1
  94. package/dist/trace.d.ts +21 -0
  95. package/dist/trace.js +107 -0
  96. package/dist/trace.js.map +1 -0
  97. package/dist/trim.js +0 -41
  98. package/dist/trim.js.map +1 -1
  99. package/dist/tsconfig.tsbuildinfo +1 -1
  100. package/dist/type.js.map +1 -1
  101. package/dist/unify.js +13 -248
  102. package/dist/unify.js.map +1 -1
  103. package/dist/utility.js +0 -22
  104. package/dist/utility.js.map +1 -1
  105. package/dist/val/AbnfFuncVal.d.ts +18 -0
  106. package/dist/val/AbnfFuncVal.js +132 -0
  107. package/dist/val/AbnfFuncVal.js.map +1 -0
  108. package/dist/val/AbsentVal.d.ts +11 -0
  109. package/dist/val/AbsentVal.js +30 -0
  110. package/dist/val/AbsentVal.js.map +1 -0
  111. package/dist/val/AggFuncVal.d.ts +10 -1
  112. package/dist/val/AggFuncVal.js +104 -116
  113. package/dist/val/AggFuncVal.js.map +1 -1
  114. package/dist/val/ArithFuncVal.js +0 -12
  115. package/dist/val/ArithFuncVal.js.map +1 -1
  116. package/dist/val/BagVal.js +1 -78
  117. package/dist/val/BagVal.js.map +1 -1
  118. package/dist/val/BigDecimalVal.js +0 -16
  119. package/dist/val/BigDecimalVal.js.map +1 -1
  120. package/dist/val/BigIntegerVal.js +0 -16
  121. package/dist/val/BigIntegerVal.js.map +1 -1
  122. package/dist/val/CloseFuncVal.js +0 -9
  123. package/dist/val/CloseFuncVal.js.map +1 -1
  124. package/dist/val/CmpFuncVal.d.ts +2 -0
  125. package/dist/val/CmpFuncVal.js +49 -72
  126. package/dist/val/CmpFuncVal.js.map +1 -1
  127. package/dist/val/ConjunctVal.js +0 -29
  128. package/dist/val/ConjunctVal.js.map +1 -1
  129. package/dist/val/ConstraintVal.js +0 -500
  130. package/dist/val/ConstraintVal.js.map +1 -1
  131. package/dist/val/ContainerKindVal.js +0 -2
  132. package/dist/val/ContainerKindVal.js.map +1 -1
  133. package/dist/val/CopyFuncVal.js +0 -3
  134. package/dist/val/CopyFuncVal.js.map +1 -1
  135. package/dist/val/Decimal.js +0 -179
  136. package/dist/val/Decimal.js.map +1 -1
  137. package/dist/val/DeprecateFuncVal.js.map +1 -1
  138. package/dist/val/DisjunctVal.js +0 -152
  139. package/dist/val/DisjunctVal.js.map +1 -1
  140. package/dist/val/EachFuncVal.js +0 -3
  141. package/dist/val/EachFuncVal.js.map +1 -1
  142. package/dist/val/EmitFuncVal.d.ts +1 -1
  143. package/dist/val/EmitFuncVal.js +6 -119
  144. package/dist/val/EmitFuncVal.js.map +1 -1
  145. package/dist/val/ExpectVal.js +0 -62
  146. package/dist/val/ExpectVal.js.map +1 -1
  147. package/dist/val/FilterFuncVal.js +0 -25
  148. package/dist/val/FilterFuncVal.js.map +1 -1
  149. package/dist/val/FuncBaseVal.d.ts +1 -0
  150. package/dist/val/FuncBaseVal.js +7 -127
  151. package/dist/val/FuncBaseVal.js.map +1 -1
  152. package/dist/val/GraphAtomVal.js +0 -15
  153. package/dist/val/GraphAtomVal.js.map +1 -1
  154. package/dist/val/HideFuncVal.js +0 -13
  155. package/dist/val/HideFuncVal.js.map +1 -1
  156. package/dist/val/IntegerVal.js +0 -61
  157. package/dist/val/IntegerVal.js.map +1 -1
  158. package/dist/val/JunctionVal.js +0 -20
  159. package/dist/val/JunctionVal.js.map +1 -1
  160. package/dist/val/KeyFuncVal.js +0 -46
  161. package/dist/val/KeyFuncVal.js.map +1 -1
  162. package/dist/val/ListVal.js +0 -57
  163. package/dist/val/ListVal.js.map +1 -1
  164. package/dist/val/LowerFuncVal.js +0 -11
  165. package/dist/val/LowerFuncVal.js.map +1 -1
  166. package/dist/val/MapVal.js +0 -151
  167. package/dist/val/MapVal.js.map +1 -1
  168. package/dist/val/MatchFuncVal.js +0 -27
  169. package/dist/val/MatchFuncVal.js.map +1 -1
  170. package/dist/val/{FormFuncVal.d.ts → MaybeFuncVal.d.ts} +5 -5
  171. package/dist/val/MaybeFuncVal.js +50 -0
  172. package/dist/val/MaybeFuncVal.js.map +1 -0
  173. package/dist/val/MoveFuncVal.js +0 -18
  174. package/dist/val/MoveFuncVal.js.map +1 -1
  175. package/dist/val/NilVal.js +0 -60
  176. package/dist/val/NilVal.js.map +1 -1
  177. package/dist/val/NomFuncVal.js +18 -54
  178. package/dist/val/NomFuncVal.js.map +1 -1
  179. package/dist/val/NumberVal.js +0 -15
  180. package/dist/val/NumberVal.js.map +1 -1
  181. package/dist/val/OpBaseVal.d.ts +1 -0
  182. package/dist/val/OpBaseVal.js +3 -15
  183. package/dist/val/OpBaseVal.js.map +1 -1
  184. package/dist/val/PackFuncVal.js +0 -34
  185. package/dist/val/PackFuncVal.js.map +1 -1
  186. package/dist/val/PathFuncVal.js +0 -6
  187. package/dist/val/PathFuncVal.js.map +1 -1
  188. package/dist/val/PathVal.js +0 -41
  189. package/dist/val/PathVal.js.map +1 -1
  190. package/dist/val/PlaceVal.js +0 -25
  191. package/dist/val/PlaceVal.js.map +1 -1
  192. package/dist/val/PlusOpVal.d.ts +1 -7
  193. package/dist/val/PlusOpVal.js +13 -74
  194. package/dist/val/PlusOpVal.js.map +1 -1
  195. package/dist/val/PrefFuncVal.js +0 -1
  196. package/dist/val/PrefFuncVal.js.map +1 -1
  197. package/dist/val/PrefVal.js +0 -167
  198. package/dist/val/PrefVal.js.map +1 -1
  199. package/dist/val/RecurseVal.js +0 -55
  200. package/dist/val/RecurseVal.js.map +1 -1
  201. package/dist/val/RefVal.js +0 -282
  202. package/dist/val/RefVal.js.map +1 -1
  203. package/dist/val/ReferFuncVal.js +3 -232
  204. package/dist/val/ReferFuncVal.js.map +1 -1
  205. package/dist/val/ScalarKindVal.js +0 -49
  206. package/dist/val/ScalarKindVal.js.map +1 -1
  207. package/dist/val/ScalarVal.js +0 -11
  208. package/dist/val/ScalarVal.js.map +1 -1
  209. package/dist/val/StrFuncVal.js +0 -18
  210. package/dist/val/StrFuncVal.js.map +1 -1
  211. package/dist/val/SuperFuncVal.js +0 -32
  212. package/dist/val/SuperFuncVal.js.map +1 -1
  213. package/dist/val/TopVal.js +0 -1
  214. package/dist/val/TopVal.js.map +1 -1
  215. package/dist/val/TranslateFuncVal.js +1 -3
  216. package/dist/val/TranslateFuncVal.js.map +1 -1
  217. package/dist/val/UpperFuncVal.js +0 -11
  218. package/dist/val/UpperFuncVal.js.map +1 -1
  219. package/dist/val/Val.d.ts +1 -0
  220. package/dist/val/Val.js +2 -133
  221. package/dist/val/Val.js.map +1 -1
  222. package/dist/val/VarVal.js +0 -12
  223. package/dist/val/VarVal.js.map +1 -1
  224. package/dist/val/arith.js +0 -37
  225. package/dist/val/arith.js.map +1 -1
  226. package/dist/val/caserange.js +0 -61
  227. package/dist/val/caserange.js.map +1 -1
  228. package/dist/val/members.js +0 -6
  229. package/dist/val/members.js.map +1 -1
  230. package/dist/val/numcmp.js +0 -11
  231. package/dist/val/numcmp.js.map +1 -1
  232. package/dist/val/numkind.js +0 -145
  233. package/dist/val/numkind.js.map +1 -1
  234. package/dist/val/valutil.js +0 -16
  235. package/dist/val/valutil.js.map +1 -1
  236. package/dist/vet.js +0 -461
  237. package/dist/vet.js.map +1 -1
  238. package/dist/view.js +0 -414
  239. package/dist/view.js.map +1 -1
  240. package/dist/walk.js +0 -41
  241. package/dist/walk.js.map +1 -1
  242. package/grammar/aontu.abnf +8 -6
  243. package/grammar/aontu.gbnf +4 -4
  244. package/grammar/aontu.lark +4 -4
  245. package/grammar/aontu.tmLanguage.json +1 -1
  246. package/package.json +4 -2
  247. package/skill/tasks.md +9 -7
  248. package/src/agentsmd.ts +0 -35
  249. package/src/alias.ts +0 -39
  250. package/src/allow.ts +1 -96
  251. package/src/aontu.ts +4 -116
  252. package/src/aontumodel.ts +26 -0
  253. package/src/casing.ts +95 -0
  254. package/src/cli.ts +258 -1024
  255. package/src/ctx.ts +0 -103
  256. package/src/diff.ts +0 -40
  257. package/src/err.ts +0 -40
  258. package/src/escape.ts +0 -46
  259. package/src/exactjson.ts +0 -131
  260. package/src/format.ts +14 -257
  261. package/src/grammar.ts +72 -0
  262. package/src/graph.ts +0 -61
  263. package/src/hcanon.ts +0 -82
  264. package/src/helpdoc.ts +2 -2
  265. package/src/hints.ts +69 -57
  266. package/src/jsonschema.ts +0 -123
  267. package/src/keyorder.ts +0 -42
  268. package/src/lang.ts +19 -931
  269. package/src/lsp-server.ts +0 -16
  270. package/src/lsp.ts +12 -180
  271. package/src/mcp-server.ts +0 -31
  272. package/src/mcp.ts +0 -169
  273. package/src/mod-tool.ts +18 -159
  274. package/src/mod.ts +0 -178
  275. package/src/patch.ts +0 -232
  276. package/src/profile.ts +42 -0
  277. package/src/provenance.ts +0 -183
  278. package/src/query.ts +0 -84
  279. package/src/reach.ts +0 -53
  280. package/src/relation.ts +0 -84
  281. package/src/report-sarif.ts +0 -48
  282. package/src/sig.ts +0 -35
  283. package/src/sigdecl.ts +1 -1
  284. package/src/siggate.ts +0 -30
  285. package/src/site.ts +3 -29
  286. package/src/subsume.ts +1 -161
  287. package/src/template.ts +69 -140
  288. package/src/trace.ts +157 -0
  289. package/src/trim.ts +0 -53
  290. package/src/type.ts +2 -45
  291. package/src/unify.ts +14 -257
  292. package/src/utility.ts +0 -31
  293. package/src/val/AbnfFuncVal.ts +181 -0
  294. package/src/val/AbsentVal.ts +54 -0
  295. package/src/val/AggFuncVal.ts +152 -188
  296. package/src/val/ArithFuncVal.ts +0 -20
  297. package/src/val/BagVal.ts +1 -78
  298. package/src/val/BigDecimalVal.ts +0 -16
  299. package/src/val/BigIntegerVal.ts +0 -16
  300. package/src/val/CloseFuncVal.ts +0 -9
  301. package/src/val/CmpFuncVal.ts +68 -184
  302. package/src/val/ConjunctVal.ts +0 -33
  303. package/src/val/ConstraintVal.ts +2 -537
  304. package/src/val/ContainerKindVal.ts +0 -18
  305. package/src/val/CopyFuncVal.ts +0 -5
  306. package/src/val/Decimal.ts +1 -185
  307. package/src/val/DeprecateFuncVal.ts +0 -10
  308. package/src/val/DisjunctVal.ts +0 -157
  309. package/src/val/EachFuncVal.ts +0 -40
  310. package/src/val/EmitFuncVal.ts +8 -208
  311. package/src/val/ExpectVal.ts +0 -62
  312. package/src/val/FilterFuncVal.ts +0 -55
  313. package/src/val/FuncBaseVal.ts +9 -130
  314. package/src/val/GraphAtomVal.ts +0 -42
  315. package/src/val/HideFuncVal.ts +0 -15
  316. package/src/val/IntegerVal.ts +0 -61
  317. package/src/val/JunctionVal.ts +0 -20
  318. package/src/val/KeyFuncVal.ts +0 -48
  319. package/src/val/ListVal.ts +0 -59
  320. package/src/val/LowerFuncVal.ts +0 -12
  321. package/src/val/MapVal.ts +0 -151
  322. package/src/val/MatchFuncVal.ts +0 -59
  323. package/src/val/MaybeFuncVal.ts +86 -0
  324. package/src/val/MoveFuncVal.ts +0 -20
  325. package/src/val/NilVal.ts +0 -60
  326. package/src/val/NomFuncVal.ts +10 -99
  327. package/src/val/NumberVal.ts +0 -16
  328. package/src/val/OpBaseVal.ts +4 -17
  329. package/src/val/PackFuncVal.ts +0 -63
  330. package/src/val/PathFuncVal.ts +0 -32
  331. package/src/val/PathVal.ts +0 -66
  332. package/src/val/PlaceVal.ts +0 -45
  333. package/src/val/PlusOpVal.ts +18 -75
  334. package/src/val/PrefFuncVal.ts +0 -1
  335. package/src/val/PrefVal.ts +0 -179
  336. package/src/val/RecurseVal.ts +0 -81
  337. package/src/val/RefVal.ts +1 -285
  338. package/src/val/ReferFuncVal.ts +4 -255
  339. package/src/val/ScalarKindVal.ts +0 -50
  340. package/src/val/ScalarVal.ts +0 -12
  341. package/src/val/StrFuncVal.ts +0 -44
  342. package/src/val/SuperFuncVal.ts +0 -42
  343. package/src/val/TopVal.ts +0 -1
  344. package/src/val/TranslateFuncVal.ts +1 -51
  345. package/src/val/UpperFuncVal.ts +0 -12
  346. package/src/val/Val.ts +3 -192
  347. package/src/val/VarVal.ts +0 -15
  348. package/src/val/arith.ts +0 -92
  349. package/src/val/caserange.ts +0 -62
  350. package/src/val/members.ts +0 -23
  351. package/src/val/numcmp.ts +1 -27
  352. package/src/val/numkind.ts +0 -149
  353. package/src/val/valutil.ts +0 -16
  354. package/src/vet.ts +1 -582
  355. package/src/view.ts +0 -507
  356. package/src/walk.ts +0 -41
  357. package/dist/lower.d.ts +0 -23
  358. package/dist/lower.js +0 -578
  359. package/dist/lower.js.map +0 -1
  360. package/dist/render.d.ts +0 -53
  361. package/dist/render.js +0 -547
  362. package/dist/render.js.map +0 -1
  363. package/dist/std.d.ts +0 -3
  364. package/dist/std.js +0 -672
  365. package/dist/std.js.map +0 -1
  366. package/dist/val/FormFuncVal.js +0 -55
  367. package/dist/val/FormFuncVal.js.map +0 -1
  368. package/dist/val/NamerFuncVal.d.ts +0 -12
  369. package/dist/val/NamerFuncVal.js +0 -176
  370. package/dist/val/NamerFuncVal.js.map +0 -1
  371. package/src/lower.ts +0 -636
  372. package/src/render.ts +0 -732
  373. package/src/std.ts +0 -683
package/src/lsp-server.ts CHANGED
@@ -1,22 +1,9 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
 
3
- // Aontu Language Server (stdio).
4
- //
5
- // aontu-lsp
6
- //
7
- // Speaks LSP over stdio (JSON-RPC with Content-Length framing) and
8
- // publishes unification diagnostics as `.aontu` files are edited. This
9
- // binary is intentionally thin: all protocol logic lives in the reusable
10
- // library ./lsp (LspHandler + computeDiagnostics). See docs/lsp.md for
11
- // editor configuration.
12
3
 
13
4
  import { LspHandler, Message, OutMessage } from './lsp'
14
5
 
15
6
 
16
- // A byte-level LSP framing codec: feed it incoming chunks, give it a
17
- // handler, and it decodes Content-Length frames, dispatches them, and
18
- // writes framed replies. Kept transport-injectable (write/onExit) so it
19
- // can be unit-tested without real stdio.
20
7
  class FrameCodec {
21
8
  private buffer = Buffer.alloc(0)
22
9
 
@@ -84,9 +71,6 @@ class FrameCodec {
84
71
  }
85
72
 
86
73
 
87
- // The streams and exit are injectable (defaulting to real stdio) so the
88
- // full wiring is unit-testable — the same shape as the Go server's
89
- // serve(in, out, logw).
90
74
  function main(
91
75
  stdin: NodeJS.ReadableStream = process.stdin,
92
76
  write: (chunk: Buffer) => void = (chunk) => void process.stdout.write(chunk),
package/src/lsp.ts CHANGED
@@ -1,20 +1,5 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
 
3
- // Aontu Language Server library.
4
- //
5
- // This module is the reusable, transport-free core of the language
6
- // server, deliberately split from the process that serves it:
7
- //
8
- // - `computeDiagnostics(src)` turns Aontu source into LSP diagnostics.
9
- // - `LspHandler` implements the LSP message flow (document sync ->
10
- // publishDiagnostics) over decoded JSON-RPC *objects*, with no
11
- // stdin/stdout. It is fully unit-testable and embeddable.
12
- // - the server (`lsp-server.ts`) is a thin stdio JSON-RPC loop that
13
- // frames bytes and feeds decoded messages to an `LspHandler`.
14
- //
15
- // The Go port mirrors this split in go/lsp (library) and
16
- // go/cmd/aontu-lsp (server). Diagnostic messages are built the same way
17
- // in both so editors see identical text regardless of implementation.
18
3
 
19
4
  import type { Val } from './type'
20
5
 
@@ -34,18 +19,11 @@ const SEVERITY_WARNING = 2
34
19
  const SEVERITY_INFORMATION = 3
35
20
  const SEVERITY_HINT = 4
36
21
 
37
- // Reported to the client in the initialize response. It is the
38
- // ENGINE's version, not a number of the server's own: a separately
39
- // maintained one drifts, and had -- the server answered 0.1.0 against
40
- // a package at 0.52.1, so a client could not tell which engine it was
41
- // talking to (status-2026-08-21.md section 10).
42
22
  const LSP_VERSION = VERSION
43
23
 
44
24
 
45
- // Zero-based line / UTF-16 character offset (LSP Position).
46
25
  type Position = { line: number, character: number }
47
26
 
48
- // Inclusive-start, exclusive-end span (LSP Range).
49
27
  type Range = { start: Position, end: Position }
50
28
 
51
29
  // A single LSP diagnostic.
@@ -80,18 +58,10 @@ type OutMessage = {
80
58
  }
81
59
 
82
60
 
83
- // Compute LSP diagnostics for a unit of Aontu source. A valid document —
84
- // including a non-concrete schema such as `a:string` — returns an empty
85
- // array; only genuine errors (conflicts, unresolved references, unknown
86
- // functions, syntax errors) produce diagnostics.
87
61
  function computeDiagnostics(
88
62
  src: string,
89
63
  opts?: { vars?: Record<string, Val>, trust?: any, textExt?: string[] }
90
64
  ): Diagnostic[] {
91
- // The trust profile (G5, docs/trust.md): the LSP is the
92
- // highest-exposure surface — merely OPENING a hostile .aon file in an
93
- // editor performs its reads — so the handler confines evaluation to
94
- // the workspace root and threads the profile through here.
95
65
  const aontu = new Aontu(includeOpts(opts ?? {}))
96
66
 
97
67
  let root: any
@@ -114,12 +84,6 @@ function computeDiagnostics(
114
84
  const seen = new Set()
115
85
  const nils: any[] = collectNils(root, seen)
116
86
 
117
- // Errors recorded on the context but not present in the tree — e.g. a
118
- // budget_passes exhaustion nil, which is about the whole evaluation
119
- // rather than any node — would otherwise be invisible here, and the
120
- // trust contract forbids silent truncation (docs/trust.md clause 2).
121
- // Tree nils are already on ctx.err too, so dedup by identity; the
122
- // transient disjunct-trial sentinel never surfaces.
123
87
  for (const e of ac.err) {
124
88
  if (e?.isNil && '|:trial-nil' !== e.why && !seen.has(e)) {
125
89
  seen.add(e)
@@ -129,11 +93,6 @@ function computeDiagnostics(
129
93
 
130
94
  const out = nils.map(nilToDiagnostic)
131
95
 
132
- // Deprecation tags (G3 phase 4): every sited value carrying the
133
- // deprecate() record — the declaration and, because the record rides
134
- // meets and reference clones, every use resolving through it — gets
135
- // the native Deprecated tag (2) at Hint severity, so editors strike
136
- // it through without shouting.
137
96
  for (const { val } of collectDeprecations(root)) {
138
97
  const v: any = val
139
98
  if (1 > (v.site?.row ?? -1) || 1 > (v.site?.col ?? -1)) {
@@ -187,38 +146,16 @@ function nilToDiagnostic(nil: any): Diagnostic {
187
146
  }
188
147
 
189
148
 
190
- // Length (UTF-16 units, like LSP characters) of the offending value's
191
- // SOURCE TEXT, used to size the diagnostic range (minimum 1).
192
149
  function labelLength(nil: any): number {
193
150
  return null == nil.primary ? 1 : siteExtent(nil.primary)
194
151
  }
195
152
 
196
153
 
197
- // The extent to underline for a value: its SOURCE TEXT's length, with
198
- // the canon as the fallback and 1 as the floor.
199
- //
200
- // CANON IS NOT SOURCE TEXT, which is the whole point of Site.len:
201
- // `0x1F` has canon `31`, so sizing by canon underlines two characters
202
- // of a four-character literal — hovering `0x1F` highlighted `0x` and
203
- // hovering `1F` answered nothing. The Go twin is the same fallback in
204
- // go/check.go (Problem.Len, ValueSpan.Len), in bytes there because it
205
- // is added to a byte offset before conversion.
206
- //
207
- // The fallback is for a value carrying no stamped span — one propagated
208
- // onto a result rather than written by a document — where canon is all
209
- // there is and an approximate underline beats none. A REPORT never
210
- // guesses this way: vet and why emit len only when it is known, because
211
- // there a wrong length is a corrupted document rather than a wonky
212
- // highlight.
213
154
  function siteExtent(v: any): number {
214
155
  const len = v?.site?.len
215
156
  if ('number' === typeof len && len > 0) {
216
157
  return len
217
158
  }
218
- // CANON IS READ DEFENSIVELY, as every other reader here does: it is a
219
- // getter that unifies, and a host-supplied value can throw from it
220
- // (hover-refuses-bad-input). A hover that cannot measure a value
221
- // still has to answer for the rest of the document.
222
159
  let c = ''
223
160
  try { c = v?.canon } catch { c = '' }
224
161
  return 'string' === typeof c && c.length > 0 ? c.length : 1
@@ -268,7 +205,6 @@ function parseErrorDiagnostic(err: any): Diagnostic {
268
205
  function initializeResult() {
269
206
  return {
270
207
  capabilities: {
271
- // 1 = TextDocumentSyncKind.Full
272
208
  textDocumentSync: 1,
273
209
  hoverProvider: true,
274
210
  completionProvider: {},
@@ -282,14 +218,6 @@ function initializeResult() {
282
218
  }
283
219
 
284
220
 
285
- // signatureHelp: the declared signature of the ENCLOSING call, served
286
- // from the registry (docs/design/SIGNATURES.0.md). The enclosing call
287
- // is found lexically -- scan back from the cursor for the nearest
288
- // unclosed '(' and read the word before it; commas at that depth
289
- // count the active parameter, capped at the last slot so a rest tail
290
- // stays active for every excess argument. Strings are skipped so a
291
- // paren or comma inside one does not miscount, and the scan stops at
292
- // the line start, a call being one line in practice.
293
221
  function computeSignatureHelp(text: string, pos: any): any {
294
222
  // Position to offset, under the full-sync model: lines are exactly
295
223
  // the text's newlines.
@@ -344,21 +272,10 @@ function publishDiagnosticsMsg(uri: string, diagnostics: Diagnostic[]): OutMessa
344
272
  }
345
273
 
346
274
 
347
- // --- Hover ------------------------------------------------------------
348
-
349
275
  type MarkupContent = { kind: 'markdown' | 'plaintext', value: string }
350
276
  type Hover = { contents: MarkupContent, range?: Range }
351
277
 
352
278
 
353
- // Resolve the value under the cursor and describe it. Returns null when
354
- // the position is not over a value with a known source location. Because
355
- // hover reads the *unified* tree, a literal shows its resolved value and
356
- // kind (e.g. a reference target resolves to the value it points at).
357
- // HOVER PROVENANCE (G7 phase 7) is CONFIG-GATED and off by default:
358
- // the contributions that met at the hovered path, appended to the
359
- // value's own hover. Hover already re-unifies the whole document per
360
- // request, so an editor that asks for this pays a second instrumented
361
- // evaluation knowingly, and one that does not pays nothing.
362
279
  function provenanceMarkdown(
363
280
  src: string, path: string[], trust?: any): string {
364
281
  if (0 === path.length) {
@@ -372,10 +289,6 @@ function provenanceMarkdown(
372
289
  }
373
290
 
374
291
 
375
- // The contributions as hover markdown. Exported for the direct test
376
- // (ADR-002): a siteless contribution and a named file are both shapes
377
- // the record allows and no hover produces, hover evaluating one
378
- // unnamed document.
379
292
  export function contributionsMarkdown(conjuncts: WhyConjunct[]): string {
380
293
  if (0 === conjuncts.length) {
381
294
  return ''
@@ -388,12 +301,6 @@ export function contributionsMarkdown(conjuncts: WhyConjunct[]): string {
388
301
  }
389
302
 
390
303
 
391
- // HOVER RUNS UNDER THE SAME CAPABILITY AS DIAGNOSTICS. It used to
392
- // evaluate through `new Aontu()` -- the full system resolver -- BESIDE
393
- // confined diagnostics in the same server, so a workspace-confined
394
- // session still resolved an escaping include the moment a cursor rested
395
- // on it (use-cases/REVIEW.md finding G). One document, two postures, is
396
- // not a confinement.
397
304
  function computeHover(
398
305
  src: string, position: Position, provenance?: boolean,
399
306
  trust?: any): Hover | null {
@@ -450,16 +357,6 @@ function collectHoverCandidates(
450
357
  // one, canon otherwise. See siteExtent.
451
358
  const span = siteExtent(v)
452
359
  const spanSrc = 'string' === typeof v.site?.src ? v.site.src : ''
453
- // Hover targets concrete values (scalars, kinds, refs, …), not
454
- // containers: a map/list source span is not reliably reconstructable
455
- // from a single site, and the same restriction in the Go port keeps
456
- // hover behaviour identical across implementations. The walk still
457
- // recurses into containers below to reach their leaf values. Canon is
458
- // single-line, so its length approximates the on-line source span.
459
- // Single-line is decided by the SOURCE TEXT when there is one: a
460
- // multi-line token cannot be described by one line's start and end,
461
- // and canon's newlines are not the token's. Falling back to canon
462
- // keeps the old test for a value with no stamped span.
463
360
  const multiline = '' === spanSrc ? canon.includes('\n') : spanSrc.includes('\n')
464
361
  if (row >= 1 && col >= 1 && canon.length > 0 && !multiline &&
465
362
  !v.isMap && !v.isList) {
@@ -505,8 +402,6 @@ function valKind(val: any): string {
505
402
  }
506
403
 
507
404
 
508
- // --- Completion -------------------------------------------------------
509
-
510
405
  type CompletionItem = {
511
406
  label: string
512
407
  kind?: number // LSP CompletionItemKind
@@ -519,21 +414,20 @@ import { funcSig, renderSig, renderSigArg } from './sig'
519
414
  const COMPLETION_FUNCTION = 3
520
415
  const COMPLETION_KEYWORD = 14
521
416
 
522
- // The built-in functions. Kept in sync with the engine by
523
- // `lsp.test.ts`, which asserts each is recognised and no others are.
524
- // The Go port derives its list from the engine's own name set
525
- // (`BuiltinFuncNames`, go/func.go), which is why a name added there
526
- // and forgotten here diverges silently — as `id` and `refer` did
527
- // between G4 phases 1/2 and G8 phase 1.
528
417
  const BUILTIN_FUNCS = [
529
- 'above', 'acyclic', 'add', 'below', 'close', 'copy', 'deprecate', 'div',
418
+ 'abnf', 'above', 'acyclic', 'add', 'below', 'close', 'content', 'copy',
419
+ 'copyfiles', 'deprecate',
420
+ 'div',
530
421
  'each', 'emit', 'esc',
531
- 'filter', 'greatest',
532
- 'hide', 'inverse', 'join', 'key', 'least', 'length', 'list', 'lower',
533
- 'map', 'match', 'max', 'min', 'mod', 'move', 'mul', 'must', 'neq', 'open',
534
- 'pack', 'path', 'pick',
535
- 'pref', 're', 'refer', 'rel', 'rem', 'rep', 'split', 'sub', 'sum',
536
- 'super', 'type', 'unique', 'upper', 'usc',
422
+ 'file', 'filter', 'folder', 'fragment', 'greatest',
423
+ 'hide', 'inject', 'inverse', 'join', 'key', 'least', 'length', 'line',
424
+ 'list', 'listitems', 'lower',
425
+ 'map', 'match', 'max', 'maybe', 'min', 'mod', 'move', 'mul', 'must', 'neq',
426
+ 'nom', 'open',
427
+ 'pack', 'parse', 'path', 'pick',
428
+ 'pref', 'project', 're', 'refer', 'rel', 'rem', 'rep', 'slot', 'sort',
429
+ 'split', 'sub', 'sum',
430
+ 'super', 'translate', 'type', 'unique', 'upper', 'usc',
537
431
  ]
538
432
 
539
433
  // Scalar-kind and literal keywords.
@@ -567,46 +461,11 @@ function computeCompletions(): CompletionItem[] {
567
461
  }
568
462
 
569
463
 
570
- // Transport-agnostic LSP message dispatcher. Consumes decoded JSON-RPC
571
- // messages and returns the messages to send back, tracking open document
572
- // text and recomputing diagnostics on open/change/close. Not safe for
573
- // concurrent use; drive it from a single loop (as the stdio server does).
574
- // A file:// uri's filesystem path, for the workspace-root confinement.
575
- // Percent-decoded; a non-file uri (or none) yields undefined.
576
- //
577
- // EXPORTED, inline as contributionsMarkdown is: part of the reusable
578
- // LSP library surface, and the twin of the package-visible uriToPath in
579
- // go/lsp/handler.go. Anything driving this module with its own
580
- // transport has to turn a client's uri into a path the same way the
581
- // confinement does, and the rules below are not guessable from outside.
582
- //
583
- // THE DRIVE-LETTER SLASH. A file uri names an absolute path after the
584
- // authority, so on Windows the standard spelling every editor sends is
585
- // file:///C:/Users/me/project — three slashes, and the third belongs to
586
- // the PATH. Stripping only `file://` leaves `/C:/Users/me/project`,
587
- // which is not a Windows path at all, so the workspace-root
588
- // confinement below compared real paths against nonsense and an editor
589
- // on Windows got no confinement it could rely on. Both ports carried
590
- // the defect identically (go/lsp/handler.go uriToPath), and no test
591
- // caught it because both ports' tests built the uri as `'file://' +
592
- // path` — two slashes, which is not what a client sends and which
593
- // accidentally produced a usable path.
594
- //
595
- // The leading slash is dropped only before a DRIVE LETTER, so a POSIX
596
- // path keeps the root it needs: file:///tmp/x stays /tmp/x.
597
464
  export function uriToPath(uri: unknown): string | undefined {
598
465
  if ('string' !== typeof uri || !uri.startsWith('file://')) {
599
466
  return undefined
600
467
  }
601
468
  const path = percentDecode(uri.slice('file://'.length))
602
- // AN EMPTY PATH IS NOT A ROOT. `file://` on its own yields '', and
603
- // '' is not nullish — so it won the `??` chain below and arrived as
604
- // `{ include: { root: '' } }`, a confinement root that then resolves
605
- // against the process working directory: the same client params made
606
- // the server allow or deny an include depending on where it was
607
- // started from. The Go twin never had it, because its chain tests
608
- // `"" != folder` explicitly (go/lsp/handler.go). Answering undefined
609
- // is what makes the two chains agree.
610
469
  if ('' === path) {
611
470
  return undefined
612
471
  }
@@ -614,23 +473,6 @@ export function uriToPath(uri: unknown): string | undefined {
614
473
  }
615
474
 
616
475
 
617
- // Percent-decoding that CANNOT THROW. `decodeURIComponent` raises a
618
- // URIError on a malformed escape (`%ZZ`), and this runs on a uri a
619
- // CLIENT sent — so a stray percent in a workspace path took the
620
- // exception straight out of the initialize handler, where the Go twin
621
- // swallowed the same failure and used the raw text
622
- // (go/lsp/handler.go). Two ports, two behaviours, for an input neither
623
- // of them controls.
624
- //
625
- // The agreement runs the other way for the SECOND way an escape can
626
- // fail to decode. `%FF` is well-formed and names a raw byte — a
627
- // perfectly good Linux filename — which Go produced and a JavaScript
628
- // string cannot hold at all, so the ports derived different workspace
629
- // roots for a uri a byte-oriented client really sends. Only one
630
- // direction is reachable from both languages, so Go now declines to
631
- // unescape a result that is not valid UTF-8 and both ports keep the
632
- // raw text. An undecodable path is still a path, and refusing to serve
633
- // a session over it helps nobody.
634
476
  function percentDecode(text: string): string {
635
477
  try {
636
478
  return decodeURIComponent(text)
@@ -655,12 +497,6 @@ class LspHandler {
655
497
  private shutdownOK = false
656
498
  private exited = false
657
499
 
658
- // The trust profile evaluation runs under (G5, docs/trust.md):
659
- // workspace-root confinement by default, set from the initialize
660
- // params. An `initializationOptions.aontu.trust.include` of 'system',
661
- // 'none' or { root } widens or narrows it explicitly. Undefined —
662
- // no workspace root and no explicit option — falls back to today's
663
- // unconfined behaviour, which single-file sessions rely on.
664
500
  private trust: any = undefined
665
501
 
666
502
  // Hover provenance (G7 phase 7): off unless an editor asks for it
@@ -687,10 +523,6 @@ class LspHandler {
687
523
  true === params.initializationOptions?.aontu?.provenance
688
524
  const explicit = params.initializationOptions?.aontu?.trust?.include
689
525
  if (null != explicit) {
690
- // An explicit setting wins — validated, and an unrecognised
691
- // value confines to NOTHING rather than silently widening:
692
- // deny is the safe reading of a setting the server does not
693
- // understand. The same rule as the Go handler.
694
526
  this.trust =
695
527
  'system' === explicit ? undefined :
696
528
  'none' === explicit ? { include: 'none' } :
package/src/mcp-server.ts CHANGED
@@ -1,27 +1,5 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
 
3
- // Aontu MCP server (stdio).
4
- //
5
- // aontu-mcp [--root <dir>]
6
- //
7
- // Speaks the Model Context Protocol over stdio: newline-delimited
8
- // JSON-RPC 2.0, one message per line. This binary is intentionally
9
- // thin — every tool and every protocol decision lives in the reusable
10
- // library ./mcp, the same three-layer split the language server uses
11
- // (docs/lsp.md).
12
- //
13
- // NDJSON, not the LSP's Content-Length framing: MCP stdio transport
14
- // is line-delimited, and a server that invented its own framing would
15
- // not be reachable by any client.
16
- //
17
- // The one startup decision is the PATH CAPABILITY: `--root <dir>`
18
- // grants the served evaluation the CLI's `--trust root:<dir>` posture
19
- // — includes resolve confined below the root, and every tool's
20
- // document arguments accept `<name>Path` file alternatives, confined
21
- // the same way. Without it the server denies all includes and refuses
22
- // path arguments (./mcp). The root is realpath'd HERE, once, so the
23
- // confinement prefix the library compares against is the real
24
- // directory, not a spelling of it.
25
3
 
26
4
  import { realpathSync, statSync } from 'node:fs'
27
5
 
@@ -40,11 +18,6 @@ const USAGE = 'aontu mcp - aontu MCP server (stdio, NDJSON JSON-RPC)\n' +
40
18
  ' denies every include and refuses path arguments.\n'
41
19
 
42
20
 
43
- // The startup arguments. Parsed here rather than in bin/aontu-mcp.js
44
- // or the CLI's mcp verb
45
- // so the parsing is import-testable; unknown options REFUSE rather
46
- // than warn, because a server whose operator typo'd --root must not
47
- // come up quietly unconfined.
48
21
  export type ServerArgs = {
49
22
  root?: string
50
23
  help?: boolean
@@ -152,10 +125,6 @@ function main(
152
125
  return undefined
153
126
  }
154
127
 
155
- // FAIL FAST on a root that is not a real directory: every later
156
- // call would refuse anyway, but a misconfigured server that answers
157
- // a thousand confusing refusals is worse than one that says so at
158
- // startup.
159
128
  let root: string | undefined
160
129
  if (null != args.root) {
161
130
  try {