@plurnk/plurnk-grammar 0.30.0 → 0.32.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
@@ -42,7 +42,7 @@ Exit `0` on clean parse, `1` on any error or unparsed tail.
42
42
  | `suffix` | `[A-Za-z0-9_]*` glued to `OP`; used for nesting |
43
43
  | `[…]` | optional CSV; per-OP semantics |
44
44
  | `(…)` | optional URI |
45
- | `<L>` | optional `<N>` or `<N-M>`; N, M ∈ signed integers |
45
+ | `<L>` | optional `<N>` or `<N-M>`; N, M ∈ signed numbers — decimals mean insert-between (lines) or score threshold (results) |
46
46
  | `:body:` | optional; opaque between fences |
47
47
 
48
48
  | OP | signal | body | line marker |
@@ -176,7 +176,13 @@ Nesting: outer body may contain inner `<<OP:…:OP` statements; outer must use a
176
176
  33. Think aloud — reasoning recorded to the log
177
177
  <<PLAN:Need the capital fact; discover via wiki, record to known, deliver.:PLAN
178
178
 
179
- 34. Quote a plurnk operation inside another (nesting via suffix discipline)
179
+ 34. Insert a line between lines 2 and 3 (decimal = between; replaces nothing)
180
+ <<EDIT(known://plan)<2.5>:- [ ] Verify against a second source:EDIT
181
+
182
+ 35. Semantic search with a similarity threshold (decimal = minimum score)
183
+ <<FIND(known://**)<0.7>:~territorial concessions:FIND
184
+
185
+ 36. Quote a plurnk operation inside another (nesting via suffix discipline)
180
186
  <<EDITouter(known://demo):
181
187
  The following is a quoted plurnk operation, preserved verbatim:
182
188
  <<EDIT(known://inner):hello world:EDIT
@@ -188,12 +194,13 @@ Errors are JSON-serializable. Shape: `{ line, column, source, message }` where `
188
194
 
189
195
  ## gbnf
190
196
 
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).
197
+ 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
198
 
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.
199
+ - **`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.
200
+ - **`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.
201
+ - **`plurnk-strict.gbnf`** — ops only, bounded newline separators. The tightest rail, for models that don't reason.
195
202
 
196
- The parser remains the permissive contract — everything either grammar can generate, the parser accepts (interstatement text surfaces as `kind: "text"` items).
203
+ The parser remains the permissive contract — everything any of the three can generate, the parser accepts (interstatement text surfaces as `kind: "text"` items).
197
204
 
198
205
  ```ts
199
206
  import.meta.resolve("@plurnk/plurnk-grammar/plurnk.gbnf")