@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.
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/SPEC.md +954 -0
- package/bin/plurnk-contracts.js +43 -0
- package/dist/plurnk.gbnf +394 -0
- package/dist/schema/ClientDisplayCapabilities.json +54 -0
- package/dist/schema/ClientStatement.json +68 -0
- package/dist/schema/EntryReadResult.json +101 -0
- package/dist/schema/LineMarker.json +16 -0
- package/dist/schema/LoopFlags.json +16 -0
- package/dist/schema/MatcherBody.json +84 -0
- package/dist/schema/Notice.json +67 -0
- package/dist/schema/OperationResult.json +44 -0
- package/dist/schema/ParsedPath.json +64 -0
- package/dist/schema/PlurnkStatement.json +264 -0
- package/dist/schema/Position.json +20 -0
- package/dist/schema/ProblemDetails.json +51 -0
- package/dist/schema/ProposalDisposition.json +26 -0
- package/dist/schema/ProposalProjection.json +44 -0
- package/dist/schema/ProviderCost.json +69 -0
- package/dist/schema/ResourceSelection.json +20 -0
- package/dist/schema/SendBody.json +13 -0
- package/dist/schema/TextRegion.json +31 -0
- package/dist/src/AstBuilder.d.ts +24 -0
- package/dist/src/AstBuilder.d.ts.map +1 -0
- package/dist/src/AstBuilder.js +609 -0
- package/dist/src/AstBuilder.js.map +1 -0
- package/dist/src/PathSyntax.d.ts +9 -0
- package/dist/src/PathSyntax.d.ts.map +1 -0
- package/dist/src/PathSyntax.js +36 -0
- package/dist/src/PathSyntax.js.map +1 -0
- package/dist/src/PlurnkErrorStrategy.d.ts +10 -0
- package/dist/src/PlurnkErrorStrategy.d.ts.map +1 -0
- package/dist/src/PlurnkErrorStrategy.js +147 -0
- package/dist/src/PlurnkErrorStrategy.js.map +1 -0
- package/dist/src/PlurnkParseError.d.ts +17 -0
- package/dist/src/PlurnkParseError.d.ts.map +1 -0
- package/dist/src/PlurnkParseError.js +24 -0
- package/dist/src/PlurnkParseError.js.map +1 -0
- package/dist/src/PlurnkParser.d.ts +9 -0
- package/dist/src/PlurnkParser.d.ts.map +1 -0
- package/dist/src/PlurnkParser.js +396 -0
- package/dist/src/PlurnkParser.js.map +1 -0
- package/dist/src/Problems.d.ts +8 -0
- package/dist/src/Problems.d.ts.map +1 -0
- package/dist/src/Problems.js +23 -0
- package/dist/src/Problems.js.map +1 -0
- package/dist/src/RecordingListener.d.ts +9 -0
- package/dist/src/RecordingListener.d.ts.map +1 -0
- package/dist/src/RecordingListener.js +19 -0
- package/dist/src/RecordingListener.js.map +1 -0
- package/dist/src/Validator.d.ts +49 -0
- package/dist/src/Validator.d.ts.map +1 -0
- package/dist/src/Validator.js +211 -0
- package/dist/src/Validator.js.map +1 -0
- package/dist/src/generated/plurnkLexer.d.ts +129 -0
- package/dist/src/generated/plurnkLexer.d.ts.map +1 -0
- package/dist/src/generated/plurnkLexer.js +808 -0
- package/dist/src/generated/plurnkLexer.js.map +1 -0
- package/dist/src/generated/plurnkParser.d.ts +525 -0
- package/dist/src/generated/plurnkParser.d.ts.map +1 -0
- package/dist/src/generated/plurnkParser.js +3896 -0
- package/dist/src/generated/plurnkParser.js.map +1 -0
- package/dist/src/generated/plurnkParserVisitor.d.ts +298 -0
- package/dist/src/generated/plurnkParserVisitor.d.ts.map +1 -0
- package/dist/src/generated/plurnkParserVisitor.js +257 -0
- package/dist/src/generated/plurnkParserVisitor.js.map +1 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +10 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +29 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.generated.d.ts +450 -0
- package/dist/src/types.generated.d.ts.map +1 -0
- package/dist/src/types.generated.js +4 -0
- package/dist/src/types.generated.js.map +1 -0
- package/dist/src/types.js +23 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +87 -0
- 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
|