@plurnk/plurnk-grammar 0.28.0 → 0.31.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 +15 -5
- package/dist/plurnk-closed.gbnf +836 -0
- package/dist/plurnk-strict.gbnf +836 -0
- package/dist/plurnk.gbnf +113 -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 +4 -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,13 @@ Errors are JSON-serializable. Shape: `{ line, column, source, message }` where `
|
|
|
184
188
|
|
|
185
189
|
## gbnf
|
|
186
190
|
|
|
187
|
-
|
|
191
|
+
Three generated [GBNF](https://github.com/ggml-org/llama.cpp/blob/master/grammars/README.md) grammars ship in the package for llama.cpp constrained sampling, most→least permissive. All dictate the canonical statement form (digit suffixes, comma line markers, three-digit SEND signals); free text can never contain a complete `<<OP` opener — emitting one commits the sampler into statement mode, so operations stay fully enforced everywhere.
|
|
192
|
+
|
|
193
|
+
- **`plurnk.gbnf` (default, open)** — free reasoning text and statements interleave; EOS is admissible at any boundary, so termination is the model's own choice. The grammar filter sits below the reasoning/content split on llama.cpp; the open root lets reasoning-tuned models think — including reasoning *about* concluding without being forced to conclude.
|
|
194
|
+
- **`plurnk-closed.gbnf`** — text allowed, but the turn must close with a final pathless `SEND[102]`/`SEND[200]` status update, after which nothing is admissible (forced EOS). For models that ramble past optional stopping points.
|
|
195
|
+
- **`plurnk-strict.gbnf`** — ops only, bounded newline separators. The tightest rail, for models that don't reason.
|
|
196
|
+
|
|
197
|
+
The parser remains the permissive contract — everything any of the three can generate, the parser accepts (interstatement text surfaces as `kind: "text"` items).
|
|
188
198
|
|
|
189
199
|
```ts
|
|
190
200
|
import.meta.resolve("@plurnk/plurnk-grammar/plurnk.gbnf")
|