@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 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. Quote a plurnk operation inside another (nesting via suffix discipline)
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
- `dist/plurnk.gbnf` ships in the package — a generated [GBNF](https://github.com/ggml-org/llama.cpp/blob/master/grammars/README.md) grammar for llama.cpp constrained sampling. It dictates the canonical form (digit suffixes, comma line markers, three-digit SEND signals); the parser remains the permissive contracteverything the GBNF can generate, the parser accepts. The root encodes 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), not an optional stop a near-greedy decoder can skip.
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")