@plurnk/plurnk-grammar 0.28.0 → 0.30.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 +14 -5
- package/dist/plurnk-strict.gbnf +834 -0
- package/dist/plurnk.gbnf +111 -2
- package/dist/schema/LogEntry.json +2 -2
- package/dist/schema/PlurnkStatement.json +17 -2
- package/dist/src/AstBuilder.d.ts.map +1 -1
- package/dist/src/AstBuilder.js +14 -0
- package/dist/src/AstBuilder.js.map +1 -1
- package/dist/src/PlurnkErrorStrategy.d.ts.map +1 -1
- package/dist/src/PlurnkErrorStrategy.js +1 -0
- package/dist/src/PlurnkErrorStrategy.js.map +1 -1
- package/dist/src/generated/plurnkLexer.d.ts +8 -6
- package/dist/src/generated/plurnkLexer.d.ts.map +1 -1
- package/dist/src/generated/plurnkLexer.js +179 -161
- package/dist/src/generated/plurnkLexer.js.map +1 -1
- package/dist/src/generated/plurnkParser.d.ts +29 -15
- package/dist/src/generated/plurnkParser.d.ts.map +1 -1
- package/dist/src/generated/plurnkParser.js +366 -269
- package/dist/src/generated/plurnkParser.js.map +1 -1
- package/dist/src/generated/plurnkParserVisitor.d.ts +7 -0
- package/dist/src/generated/plurnkParserVisitor.d.ts.map +1 -1
- package/dist/src/generated/plurnkParserVisitor.js +6 -0
- package/dist/src/generated/plurnkParserVisitor.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.generated.d.ts +11 -2
- package/dist/src/types.generated.d.ts.map +1 -1
- package/dist/src/types.generated.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ const result = PlurnkParser.parse(input);
|
|
|
19
19
|
// result.unparsedTail?: { from, reason }
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Discriminate on `item.kind`. For `statement` items, narrow on `statement.op` (one of `FIND READ EDIT COPY MOVE OPEN FOLD SEND EXEC KILL`) to access per-OP typed fields. Full API: [SPEC.md §12](SPEC.md#12-public-api).
|
|
22
|
+
Discriminate on `item.kind`. For `statement` items, narrow on `statement.op` (one of `FIND READ EDIT COPY MOVE OPEN FOLD SEND EXEC KILL PLAN`) to access per-OP typed fields. Full API: [SPEC.md §12](SPEC.md#12-public-api).
|
|
23
23
|
|
|
24
24
|
## cli
|
|
25
25
|
|
|
@@ -38,7 +38,7 @@ Exit `0` on clean parse, `1` on any error or unparsed tail.
|
|
|
38
38
|
|
|
39
39
|
| slot | shape |
|
|
40
40
|
|----------|----------------------------------------------------|
|
|
41
|
-
| `OP` | `FIND READ EDIT COPY MOVE OPEN FOLD SEND EXEC KILL` |
|
|
41
|
+
| `OP` | `FIND READ EDIT COPY MOVE OPEN FOLD SEND EXEC KILL PLAN` |
|
|
42
42
|
| `suffix` | `[A-Za-z0-9_]*` glued to `OP`; used for nesting |
|
|
43
43
|
| `[…]` | optional CSV; per-OP semantics |
|
|
44
44
|
| `(…)` | optional URI |
|
|
@@ -57,6 +57,7 @@ Exit `0` on clean parse, `1` on any error or unparsed tail.
|
|
|
57
57
|
| SEND | HTTP status int | payload (JSON conv.) | n/a |
|
|
58
58
|
| EXEC | executor | command or code | n/a |
|
|
59
59
|
| KILL | unix signal int | annotation (opaque) | n/a |
|
|
60
|
+
| PLAN | tags | reasoning text | n/a |
|
|
60
61
|
|
|
61
62
|
Matcher body dialect by leading char: `//` xpath · `/…/flags` regex · `$` jsonpath · `~` semantic · `@` graph · else glob. A body that fails its prefix-indicated dialect falls back to glob.
|
|
62
63
|
|
|
@@ -158,7 +159,7 @@ Nesting: outer body may contain inner `<<OP:…:OP` statements; outer must use a
|
|
|
158
159
|
<<SEND[200]:{"answer":"Paris","confidence":0.95}:SEND
|
|
159
160
|
|
|
160
161
|
28. Report a client error (JSON body the model can traverse with jsonpath)
|
|
161
|
-
<<SEND[400]:{"reason":"unrecognized OP","got":"FOOBAR","expected":["FIND","READ","EDIT","COPY","MOVE","OPEN","FOLD","SEND","EXEC","KILL"]}:SEND
|
|
162
|
+
<<SEND[400]:{"reason":"unrecognized OP","got":"FOOBAR","expected":["FIND","READ","EDIT","COPY","MOVE","OPEN","FOLD","SEND","EXEC","KILL","PLAN"]}:SEND
|
|
162
163
|
|
|
163
164
|
29. Report a server error with explicit recipient
|
|
164
165
|
<<SEND[503](log://errors):{"reason":"git unavailable","command":"git status"}:SEND
|
|
@@ -172,7 +173,10 @@ Nesting: outer body may contain inner `<<OP:…:OP` statements; outer must use a
|
|
|
172
173
|
32. Permanently delete an entry
|
|
173
174
|
<<KILL(known://obsolete/note)::KILL
|
|
174
175
|
|
|
175
|
-
33.
|
|
176
|
+
33. Think aloud — reasoning recorded to the log
|
|
177
|
+
<<PLAN:Need the capital fact; discover via wiki, record to known, deliver.:PLAN
|
|
178
|
+
|
|
179
|
+
34. Quote a plurnk operation inside another (nesting via suffix discipline)
|
|
176
180
|
<<EDITouter(known://demo):
|
|
177
181
|
The following is a quoted plurnk operation, preserved verbatim:
|
|
178
182
|
<<EDIT(known://inner):hello world:EDIT
|
|
@@ -184,7 +188,12 @@ Errors are JSON-serializable. Shape: `{ line, column, source, message }` where `
|
|
|
184
188
|
|
|
185
189
|
## gbnf
|
|
186
190
|
|
|
187
|
-
|
|
191
|
+
Two generated [GBNF](https://github.com/ggml-org/llama.cpp/blob/master/grammars/README.md) grammars ship in the package for llama.cpp constrained sampling. Both dictate the canonical form (digit suffixes, comma line markers, three-digit SEND signals) and the turn shape — a batch of ops (mid-batch SENDs allowed) closed by a final pathless `SEND[102]`/`SEND[200]` status update, after which nothing is admissible: termination is structural (forced EOS).
|
|
192
|
+
|
|
193
|
+
- **`plurnk.gbnf` (default, relaxed)** — free reasoning text is allowed before and between operations (never after the final status SEND). The grammar filter sits below the reasoning/content split on llama.cpp, so an ops-only grammar chokes thinking on reasoning-tuned models. Operations stay fully enforced: text cannot contain a complete `<<OP` opener — emitting one commits the sampler into statement mode.
|
|
194
|
+
- **`plurnk-strict.gbnf`** — ops only, bounded newline separators. For models that don't reason and benefit from the tighter rail.
|
|
195
|
+
|
|
196
|
+
The parser remains the permissive contract — everything either grammar can generate, the parser accepts (interstatement text surfaces as `kind: "text"` items).
|
|
188
197
|
|
|
189
198
|
```ts
|
|
190
199
|
import.meta.resolve("@plurnk/plurnk-grammar/plurnk.gbnf")
|