@plurnk/plurnk-grammar 0.23.1 → 0.26.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 SHOW HIDE SEND EXEC`) 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`) 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 SHOW HIDE SEND EXEC` |
41
+ | `OP` | `FIND READ EDIT COPY MOVE OPEN FOLD SEND EXEC` |
42
42
  | `suffix` | `[A-Za-z0-9_]*` glued to `OP`; used for nesting |
43
43
  | `[…]` | optional CSV; per-OP semantics |
44
44
  | `(…)` | optional URI |
@@ -52,8 +52,8 @@ Exit `0` on clean parse, `1` on any error or unparsed tail.
52
52
  | EDIT | tags | content (empty=clear) | entry lines |
53
53
  | COPY | tags-to-apply | destination URI | entry lines |
54
54
  | MOVE | tags-to-apply | destination URI | entry lines |
55
- | SHOW | tag filter | matcher | result-set range |
56
- | HIDE | tag filter | matcher | result-set range |
55
+ | OPEN | tag filter | matcher | result-set range |
56
+ | FOLD | tag filter | matcher | result-set range |
57
57
  | SEND | HTTP status int | payload (JSON conv.) | n/a |
58
58
  | EXEC | executor | command or code | n/a |
59
59
 
@@ -109,10 +109,10 @@ Nesting: outer body may contain inner `<<OP:…:OP` statements; outer must use a
109
109
  <<EDIT(known://countries/france/capital)::EDIT
110
110
 
111
111
  13. Collapse every distilled fetch-log row
112
- <<HIDE(log://1/*/*/get)::HIDE
112
+ <<FOLD(log://1/*/*/get)::FOLD
113
113
 
114
114
  14. Restore collapsed log rows by tag filter
115
- <<SHOW[france](log://**)::SHOW
115
+ <<OPEN[france](log://**)::OPEN
116
116
 
117
117
  15. Rename a draft entry
118
118
  <<MOVE(known://draft):known://final/answer:MOVE
@@ -148,16 +148,16 @@ Nesting: outer body may contain inner `<<OP:…:OP` statements; outer must use a
148
148
  :EXEC
149
149
 
150
150
  25. Restore log rows tagged france whose content matches (combined filters)
151
- <<SHOW[france](log://**):Paris*:SHOW
151
+ <<OPEN[france](log://**):Paris*:OPEN
152
152
 
153
153
  26. Collapse the second hundred of stale fetch-log rows (pagination)
154
- <<HIDE(log://**/get)<101-200>::HIDE
154
+ <<FOLD(log://**/get)<101-200>::FOLD
155
155
 
156
156
  27. Deliver a structured answer (JSON body)
157
157
  <<SEND[200]:{"answer":"Paris","confidence":0.95}:SEND
158
158
 
159
159
  28. Report a client error (JSON body the model can traverse with jsonpath)
160
- <<SEND[400]:{"reason":"unrecognized OP","got":"FOOBAR","expected":["FIND","READ","EDIT","COPY","MOVE","SHOW","HIDE","SEND","EXEC"]}:SEND
160
+ <<SEND[400]:{"reason":"unrecognized OP","got":"FOOBAR","expected":["FIND","READ","EDIT","COPY","MOVE","OPEN","FOLD","SEND","EXEC"]}:SEND
161
161
 
162
162
  29. Report a server error with explicit recipient
163
163
  <<SEND[503](log://errors):{"reason":"git unavailable","command":"git status"}:SEND
@@ -175,6 +175,16 @@ Nesting: outer body may contain inner `<<OP:…:OP` statements; outer must use a
175
175
 
176
176
  Errors are JSON-serializable. Shape: `{ line, column, source, message }` where `source` ∈ `lexer | parser | visitor`. Messages use protocol vocabulary (`unrecognized character '<<' in path`, `expected close tag; got end of input`).
177
177
 
178
+ ## gbnf
179
+
180
+ `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 contract — everything the GBNF can generate, the parser accepts.
181
+
182
+ ```ts
183
+ import.meta.resolve("@plurnk/plurnk-grammar/plurnk.gbnf")
184
+ ```
185
+
186
+ `npm run test:llama` validates the grammar against a live llama-server (`PLURNK_LLAMA_URL`, default `http://127.0.0.1:11435`) and demos constrained emission end-to-end. Opt-in; not part of `test:all`.
187
+
178
188
  ## spec
179
189
 
180
190
  [SPEC.md](SPEC.md) — full grammar specification: canonical form, per-OP semantics, matcher dialects, path decomposition, error model, whitespace rules, implementation notes.