@plurnk/plurnk-contracts 1.4.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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -0
  3. package/SPEC.md +954 -0
  4. package/bin/plurnk-contracts.js +43 -0
  5. package/dist/plurnk.gbnf +394 -0
  6. package/dist/schema/ClientDisplayCapabilities.json +54 -0
  7. package/dist/schema/ClientStatement.json +68 -0
  8. package/dist/schema/EntryReadResult.json +101 -0
  9. package/dist/schema/LineMarker.json +16 -0
  10. package/dist/schema/LoopFlags.json +16 -0
  11. package/dist/schema/MatcherBody.json +84 -0
  12. package/dist/schema/Notice.json +67 -0
  13. package/dist/schema/OperationResult.json +44 -0
  14. package/dist/schema/ParsedPath.json +64 -0
  15. package/dist/schema/PlurnkStatement.json +264 -0
  16. package/dist/schema/Position.json +20 -0
  17. package/dist/schema/ProblemDetails.json +51 -0
  18. package/dist/schema/ProposalDisposition.json +26 -0
  19. package/dist/schema/ProposalProjection.json +44 -0
  20. package/dist/schema/ProviderCost.json +69 -0
  21. package/dist/schema/ResourceSelection.json +20 -0
  22. package/dist/schema/SendBody.json +13 -0
  23. package/dist/schema/TextRegion.json +31 -0
  24. package/dist/src/AstBuilder.d.ts +24 -0
  25. package/dist/src/AstBuilder.d.ts.map +1 -0
  26. package/dist/src/AstBuilder.js +609 -0
  27. package/dist/src/AstBuilder.js.map +1 -0
  28. package/dist/src/PathSyntax.d.ts +9 -0
  29. package/dist/src/PathSyntax.d.ts.map +1 -0
  30. package/dist/src/PathSyntax.js +36 -0
  31. package/dist/src/PathSyntax.js.map +1 -0
  32. package/dist/src/PlurnkErrorStrategy.d.ts +10 -0
  33. package/dist/src/PlurnkErrorStrategy.d.ts.map +1 -0
  34. package/dist/src/PlurnkErrorStrategy.js +147 -0
  35. package/dist/src/PlurnkErrorStrategy.js.map +1 -0
  36. package/dist/src/PlurnkParseError.d.ts +17 -0
  37. package/dist/src/PlurnkParseError.d.ts.map +1 -0
  38. package/dist/src/PlurnkParseError.js +24 -0
  39. package/dist/src/PlurnkParseError.js.map +1 -0
  40. package/dist/src/PlurnkParser.d.ts +9 -0
  41. package/dist/src/PlurnkParser.d.ts.map +1 -0
  42. package/dist/src/PlurnkParser.js +396 -0
  43. package/dist/src/PlurnkParser.js.map +1 -0
  44. package/dist/src/Problems.d.ts +8 -0
  45. package/dist/src/Problems.d.ts.map +1 -0
  46. package/dist/src/Problems.js +23 -0
  47. package/dist/src/Problems.js.map +1 -0
  48. package/dist/src/RecordingListener.d.ts +9 -0
  49. package/dist/src/RecordingListener.d.ts.map +1 -0
  50. package/dist/src/RecordingListener.js +19 -0
  51. package/dist/src/RecordingListener.js.map +1 -0
  52. package/dist/src/Validator.d.ts +49 -0
  53. package/dist/src/Validator.d.ts.map +1 -0
  54. package/dist/src/Validator.js +211 -0
  55. package/dist/src/Validator.js.map +1 -0
  56. package/dist/src/generated/plurnkLexer.d.ts +129 -0
  57. package/dist/src/generated/plurnkLexer.d.ts.map +1 -0
  58. package/dist/src/generated/plurnkLexer.js +808 -0
  59. package/dist/src/generated/plurnkLexer.js.map +1 -0
  60. package/dist/src/generated/plurnkParser.d.ts +525 -0
  61. package/dist/src/generated/plurnkParser.d.ts.map +1 -0
  62. package/dist/src/generated/plurnkParser.js +3896 -0
  63. package/dist/src/generated/plurnkParser.js.map +1 -0
  64. package/dist/src/generated/plurnkParserVisitor.d.ts +298 -0
  65. package/dist/src/generated/plurnkParserVisitor.d.ts.map +1 -0
  66. package/dist/src/generated/plurnkParserVisitor.js +257 -0
  67. package/dist/src/generated/plurnkParserVisitor.js.map +1 -0
  68. package/dist/src/index.d.ts +13 -0
  69. package/dist/src/index.d.ts.map +1 -0
  70. package/dist/src/index.js +10 -0
  71. package/dist/src/index.js.map +1 -0
  72. package/dist/src/types.d.ts +29 -0
  73. package/dist/src/types.d.ts.map +1 -0
  74. package/dist/src/types.generated.d.ts +450 -0
  75. package/dist/src/types.generated.d.ts.map +1 -0
  76. package/dist/src/types.generated.js +4 -0
  77. package/dist/src/types.generated.js.map +1 -0
  78. package/dist/src/types.js +23 -0
  79. package/dist/src/types.js.map +1 -0
  80. package/package.json +87 -0
  81. package/plurnk.md +220 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PossumTech Laboratories, LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # @plurnk/plurnk-contracts
2
+
3
+ The single authority for PLURNK's model-facing language, parser and AST,
4
+ generated model rail, shared schemas and types, runtime-neutral Problems,
5
+ operation results, Notices, and text coordinates. See SPEC
6
+ {§contract-authority}.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npm install @plurnk/plurnk-contracts
12
+ ```
13
+
14
+ Requires Node.js 26 or newer.
15
+
16
+ ## Contract surfaces
17
+
18
+ | Surface | Authority or public artifact |
19
+ |---------------------------------|------------------------------------------------------|
20
+ | Concise model language teaching | [`plurnk.md`](plurnk.md) |
21
+ | Stable behavioral contract | [`SPEC.md`](SPEC.md) |
22
+ | Accepted language syntax | `plurnkLexer.g4` and `plurnkParser.g4` |
23
+ | Shared wire shapes | `schema/*.json` |
24
+ | JavaScript and TypeScript API | `@plurnk/plurnk-contracts` |
25
+ | Published JSON Schemas | `@plurnk/plurnk-contracts/schema/*.json` |
26
+ | Optional local-model rail | `@plurnk/plurnk-contracts/plurnk.gbnf` |
27
+
28
+ JSON Schema owns shared wire shapes, generated TypeScript projects those
29
+ shapes, ANTLR owns accepted model-language syntax, and GBNF is a bounded
30
+ generation aid. See SPEC {§contract-representations} and
31
+ {§gbnf-rail-purpose}.
32
+
33
+ ## Parser
34
+
35
+ ```ts
36
+ import { PlurnkParser } from "@plurnk/plurnk-contracts";
37
+
38
+ const result = PlurnkParser.parse(input);
39
+
40
+ for (const item of result.items) {
41
+ if (item.kind === "statement") {
42
+ console.log(item.statement.op);
43
+ }
44
+ }
45
+ ```
46
+
47
+ Parse items are ordered and discriminate as `statement`, `error`, or `text`.
48
+ The parser entry points deliberately accept different document tiers:
49
+
50
+ | Entry point | Accepted input |
51
+ |--------------------------------|-------------------------------------------------------|
52
+ | `PlurnkParser.parse` | One PLAN-anchored model turn ending in terminal SEND |
53
+ | `PlurnkParser.parseStatements` | A strict sequence of protocol statements |
54
+ | `PlurnkParser.parseLog` | TURN-wrapped multi-turn script or log input |
55
+ | `PlurnkParser.parseClient` | Protocol statements plus client-only LOOK and BUFF |
56
+ | `parsePath` | One path or URI using parser-equivalent decomposition |
57
+ | `parseResourceSelection` | One COPY/MOVE destination and optional text scope |
58
+
59
+ See SPEC {§turn-shape} and {§tier-entrypoints} for the tier boundaries. All
60
+ AST, parse-result, schema-derived, and runtime-neutral wire types are exported
61
+ from the package root.
62
+
63
+ ## Wire validation
64
+
65
+ ```ts
66
+ import {
67
+ Problems,
68
+ Validator,
69
+ type OperationResult,
70
+ } from "@plurnk/plurnk-contracts";
71
+
72
+ const problem = Problems.create("scheme:file", "not-found", 404, "Missing.");
73
+ const result: OperationResult = { status: 404, problem };
74
+
75
+ Validator.assertOperationResult(result);
76
+ ```
77
+
78
+ Generated wire types, constructors, and validators share the package root entry
79
+ point described by SPEC {§wire-entrypoint}. Owning JSON Schemas use the published
80
+ `@plurnk/plurnk-contracts/schema/*.json` subpaths.
81
+
82
+ ## CLI
83
+
84
+ ```text
85
+ plurnk-contracts [file] parse a file, or standard input when omitted
86
+ plurnk-contracts --help show usage
87
+ ```
88
+
89
+ The CLI prints the parse result as JSON and exits `0` for a clean parse or `1`
90
+ when the result contains an error or unparsed tail.
91
+
92
+ ## Optional GBNF artifact
93
+
94
+ ```ts
95
+ const railUrl = import.meta.resolve(
96
+ "@plurnk/plurnk-contracts/plurnk.gbnf",
97
+ );
98
+ ```
99
+
100
+ The shipped rail constrains one raw reasoning-plus-PLURNK sentence before the
101
+ provider projects reasoning and content. It is not a second parser and does not
102
+ guarantee semantically valid output. See SPEC {§gbnf-turn-shape} and
103
+ {§gbnf-reasoning-boundary}.
104
+
105
+ ## Development
106
+
107
+ ```sh
108
+ npm run build
109
+ npm test
110
+ npm run test:smoke
111
+ ```
112
+
113
+ Generated parser, schema-type, distribution, and GBNF artifacts are rebuilt by
114
+ `npm run build`. Change their grammar, schema, or generator owner rather than
115
+ editing generated output directly.
116
+
117
+ ## License
118
+
119
+ MIT