@plurnk/plurnk-grammar 0.65.0 → 0.68.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/plurnk.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Plurnk System Grammar
2
2
 
3
- YOU MUST ONLY use the Extended HEREDOC Plurnk Operations (FIND|READ|EDIT|COPY|MOVE|OPEN|FOLD|KILL|EXEC|SEND).
3
+ YOU MUST ONLY use the Extended HEREDOC Plurnk Operations (PLAN|FIND|READ|EDIT|COPY|MOVE|OPEN|FOLD|KILL|EXEC|SEND).
4
4
 
5
5
  ## Syntax
6
6
 
@@ -12,6 +12,7 @@ Slots between `<<OPsuffix` and `:body:` are all optional. `:body:` fences are re
12
12
 
13
13
  | OP | `[signal]` | `(target)` | `<Line> / <Result>` | body |
14
14
  |------|-------------|------------|---------------------|------------------|
15
+ | PLAN | - | - | - | plan / reasoning |
15
16
  | FIND | filter tags | required | results `N,M` | matcher |
16
17
  | READ | filter tags | required | lines `N,M` | matcher |
17
18
  | EDIT | tags | required | lines `N,M` | content |
@@ -26,7 +27,6 @@ Slots between `<<OPsuffix` and `:body:` are all optional. `:body:` fences are re
26
27
  Operations emit their status and/or results on the subsequent turn.
27
28
  READ output prefixes every line with line numbers and a hard tab, `N: `. The prefix is not part of the source.
28
29
  EDIT is only for entries. Do not attempt to edit log items.
29
- SEND broadcasts to uri when a path is included and messages the user when no path is included.
30
30
  EXEC defaults to `sh`; override with an optional executor (`sqlite`, `node`, etc.).
31
31
 
32
32
  ## Context
@@ -148,8 +148,10 @@ chmod +x ./example.sh
148
148
 
149
149
  ## Imperatives
150
150
 
151
+ YOU MUST begin the turn with <<PLAN:...:PLAN
151
152
  YOU MUST ONLY use EXEC commands for actions that can't be performed with Extended HEREDOC Plurnk Operations.
152
- YOU MUST ONLY communicate with SEND, not with free text between operations.
153
+ YOU MUST NOT emit free text between operations.
154
+ YOU SHOULD NOT leak internal resource information when SENDing user messages.
153
155
  YOU MUST document all relevant questions and uncertainties into taxonomized, tagged, and topical unknown entries.
154
156
  YOU MUST ONLY populate known entries with source entry information, never with model training.
155
157
  YOU SHOULD manage your own context to maximize signal, as irrelevant tokens degrade reasoning.
@@ -1,18 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.dev/v0/Agent.json",
4
- "title": "Agent",
5
- "description": "Top-level singleton. Owns the default scheme registry and the active provider declaration. Sessions, runs, and below derive from their own tables (queried by FK to the singleton agent).",
6
- "type": "object",
7
- "required": ["version", "provider", "scheme_registry"],
8
- "additionalProperties": false,
9
- "properties": {
10
- "version": { "type": "integer", "minimum": 0 },
11
- "provider": { "$ref": "https://schemas.plurnk.dev/v0/ProviderDeclaration.json" },
12
- "scheme_registry": {
13
- "type": "array",
14
- "items": { "$ref": "https://schemas.plurnk.dev/v0/SchemeRegistration.json" },
15
- "description": "Agent-wide default scheme registrations. The v0 inventory ships with `plurnk`, `known`, `unknown`; everything else is plugin-registered."
16
- }
17
- }
18
- }
@@ -1,51 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.dev/v0/Entry.json",
4
- "title": "Entry",
5
- "description": "The unit of canonical state at agent or session scope. Pure state — no interaction forensics. Identity is `(scope, scheme, pathname)`; `session_id` discriminates session-scoped rows. Content lives in one or more named channels (e.g. `body`, `stdout`/`stderr` for exec, `body`/`headers` for https). The scheme registry declares each scheme's default channel.",
6
- "type": "object",
7
- "required": [
8
- "id", "version", "scope", "session_id",
9
- "scheme", "username", "password", "hostname", "port", "pathname", "params",
10
- "channels",
11
- "attributes", "tags"
12
- ],
13
- "additionalProperties": false,
14
- "properties": {
15
- "id": { "type": "integer", "minimum": 1 },
16
- "version": { "type": "integer", "minimum": 0 },
17
- "scope": { "enum": ["agent", "session"] },
18
- "session_id": { "type": ["integer", "null"], "minimum": 1 },
19
- "scheme": { "type": ["string", "null"], "minLength": 1 },
20
- "username": { "type": ["string", "null"] },
21
- "password": { "type": ["string", "null"] },
22
- "hostname": { "type": ["string", "null"] },
23
- "port": { "type": ["integer", "null"], "minimum": 0, "maximum": 65535 },
24
- "pathname": { "type": "string" },
25
- "params": {
26
- "oneOf": [
27
- { "$ref": "https://schemas.plurnk.dev/v0/Params.json" },
28
- { "type": "null" }
29
- ]
30
- },
31
- "channels": {
32
- "type": "object",
33
- "description": "Named channels on this entry. Keys are channel names (lowercase identifiers); values are ChannelContent. Must be non-empty. The scheme registry declares which channel is the default for unspecified ops.",
34
- "minProperties": 1,
35
- "propertyNames": { "pattern": "^[a-z][a-z0-9_-]*$" },
36
- "additionalProperties": { "$ref": "https://schemas.plurnk.dev/v0/ChannelContent.json" }
37
- },
38
- "attributes": { "type": "object" },
39
- "tags": { "type": "array", "items": { "type": "string" } }
40
- },
41
- "allOf": [
42
- {
43
- "if": { "properties": { "scope": { "const": "session" } } },
44
- "then": { "properties": { "session_id": { "type": "integer" } } }
45
- },
46
- {
47
- "if": { "properties": { "scope": { "const": "agent" } } },
48
- "then": { "properties": { "session_id": { "type": "null" } } }
49
- }
50
- ]
51
- }
@@ -1,118 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.dev/v0/LogEntry.json",
4
- "title": "LogEntry",
5
- "description": "An immutable, append-only event log row. Structured as the parsed AST of one executed plurnk statement plus turn-coordinate context plus the response. Addressable via log://<loop>/<turn>/<action>.",
6
- "type": "object",
7
- "required": [
8
- "id", "version",
9
- "run_id", "loop_id", "turn_id", "sequence",
10
- "at", "origin",
11
- "op", "suffix", "signal",
12
- "scheme", "username", "password", "hostname", "port", "pathname", "params", "fragment",
13
- "lineMarker",
14
- "tx", "mimetype_tx",
15
- "rx", "mimetype_rx", "status_rx",
16
- "state", "outcome",
17
- "tokens"
18
- ],
19
- "additionalProperties": false,
20
- "properties": {
21
- "id": { "type": "integer", "minimum": 1 },
22
- "version": { "type": "integer", "minimum": 0 },
23
- "run_id": { "type": "integer", "minimum": 1 },
24
- "loop_id": { "type": "integer", "minimum": 1 },
25
- "turn_id": { "type": "integer", "minimum": 1 },
26
- "sequence": { "type": "integer", "minimum": 1, "description": "1-based within the turn; resets at each new turn." },
27
- "at": { "type": "string", "format": "date-time" },
28
- "origin": { "enum": ["model", "client", "system", "plugin"] },
29
- "op": { "enum": ["FIND", "READ", "EDIT", "COPY", "MOVE", "OPEN", "FOLD", "SEND", "EXEC", "KILL", "PLAN"] },
30
- "suffix": { "type": "string" },
31
- "signal": {
32
- "oneOf": [
33
- { "type": "array", "items": { "type": "string" } },
34
- { "type": "number" },
35
- { "type": "string" },
36
- { "type": "null" }
37
- ]
38
- },
39
- "scheme": { "type": ["string", "null"], "minLength": 1 },
40
- "username": { "type": ["string", "null"] },
41
- "password": { "type": ["string", "null"] },
42
- "hostname": { "type": ["string", "null"] },
43
- "port": { "type": ["integer", "null"], "minimum": 0, "maximum": 65535 },
44
- "pathname": { "type": ["string", "null"] },
45
- "params": {
46
- "oneOf": [
47
- { "$ref": "https://schemas.plurnk.dev/v0/Params.json" },
48
- { "type": "null" }
49
- ]
50
- },
51
- "fragment": {
52
- "type": ["string", "null"],
53
- "description": "Channel selector at request time. Names the channel the op targeted; null when the op used the scheme's default channel."
54
- },
55
- "lineMarker": {
56
- "oneOf": [
57
- { "$ref": "https://schemas.plurnk.dev/v0/LineMarker.json" },
58
- { "type": "null" }
59
- ]
60
- },
61
- "tx": { "type": "string", "description": "Raw request payload. For origin=model: the literal plurnk DSL substring of assistant.content. For origin=system/client/plugin: whatever the originator emitted, with `mimetype_tx` declaring the structure." },
62
- "mimetype_tx": { "type": "string", "minLength": 1, "description": "Mimetype of `tx`. Typically `text/vnd.plurnk` for model-origin rows; arbitrary per-origin for system/client/plugin." },
63
- "rx": { "type": "string", "description": "Raw response payload bytes/string." },
64
- "mimetype_rx": { "type": "string", "minLength": 1 },
65
- "status_rx": { "type": "integer", "minimum": 100, "maximum": 599 },
66
- "state": {
67
- "enum": ["proposed", "resolved", "failed", "cancelled"],
68
- "description": "Lifecycle position; orthogonal to status_rx. status_rx is the HTTP-aligned outcome of the network call; state is where the entry sits in the proposal lifecycle. Side-effecting ops that route through a proposal flow transition proposed → {resolved | failed | cancelled}; non-proposing ops settle at 'resolved' on first write."
69
- },
70
- "outcome": {
71
- "type": ["string", "null"],
72
- "description": "Short reason string when state ∈ {failed, cancelled}; null otherwise. Common values: rejected, loop_aborted, timeout, policy_veto, apply_failed, write_failed. Open vocabulary — schemes mint their own as needed."
73
- },
74
- "tokens": { "type": "integer", "minimum": 0 }
75
- },
76
- "allOf": [
77
- {
78
- "if": { "properties": { "op": { "const": "SEND" } } },
79
- "then": {
80
- "properties": {
81
- "signal": { "type": ["number", "null"] },
82
- "lineMarker": { "type": "null" }
83
- }
84
- }
85
- },
86
- {
87
- "if": { "properties": { "op": { "const": "EXEC" } } },
88
- "then": {
89
- "properties": {
90
- "signal": { "type": ["string", "null"] },
91
- "lineMarker": { "type": "null" }
92
- }
93
- }
94
- },
95
- {
96
- "if": { "properties": { "op": { "const": "KILL" } } },
97
- "then": {
98
- "properties": {
99
- "signal": { "type": ["number", "null"] },
100
- "lineMarker": { "type": "null" }
101
- }
102
- }
103
- },
104
- {
105
- "if": { "properties": { "op": { "enum": ["FIND", "READ", "EDIT", "COPY", "MOVE", "OPEN", "FOLD", "PLAN"] } } },
106
- "then": {
107
- "properties": {
108
- "signal": {
109
- "oneOf": [
110
- { "type": "array", "items": { "type": "string" } },
111
- { "type": "null" }
112
- ]
113
- }
114
- }
115
- }
116
- }
117
- ]
118
- }
@@ -1,20 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.dev/v0/Loop.json",
4
- "title": "Loop",
5
- "description": "An iteration within a run. The persisted status domain is a superset of the model-emittable terminals (the model emits 102/200/202/499; the engine also imposes 413/429/500/508 via direct write, and 100 marks a created-but-unstarted loop). The loop's prompt is replayed on every turn within it; turn.packet.user.prompt is a copy.",
6
- "type": "object",
7
- "required": ["id", "version", "run_id", "sequence", "status", "prompt"],
8
- "additionalProperties": false,
9
- "properties": {
10
- "id": { "type": "integer", "minimum": 1 },
11
- "version": { "type": "integer", "minimum": 0 },
12
- "run_id": { "type": "integer", "minimum": 1 },
13
- "sequence": { "type": "integer", "minimum": 1, "description": "1-based within the run." },
14
- "status": {
15
- "enum": [100, 102, 200, 413, 429, 499, 500, 508],
16
- "description": "Persisted loop status. Model-emittable: 100 = created (not yet started); 102 = continuing; 200 = terminal success; 499 = terminal give-up/cancellation. Engine-imposed (never a model SEND): 413 = budget overflow; 429 = max turns; 500 = failed (strike-out); 508 = loop detected (cycle)."
17
- },
18
- "prompt": { "type": "string", "description": "The original user prompt for this loop, replayed on every turn." }
19
- }
20
- }
@@ -1,72 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.dev/v0/Packet.json",
4
- "title": "Packet",
5
- "description": "One turn's full exchange with the provider: { system, user, assistant, assistantRaw }. system aggregates durable + accumulating context (definition, persona, in-scope log rows). user carries the per-turn ephemera. assistant is the provider-normalized output. assistantRaw is opaque.",
6
- "type": "object",
7
- "required": ["tokens", "system", "user", "assistant", "assistantRaw"],
8
- "additionalProperties": false,
9
- "properties": {
10
- "tokens": {
11
- "type": "integer",
12
- "minimum": 0,
13
- "description": "Total packet tokens — sum of section subtotals."
14
- },
15
- "system": {
16
- "type": "object",
17
- "required": ["tokens", "system_definition", "persona", "log"],
18
- "additionalProperties": false,
19
- "properties": {
20
- "tokens": { "type": "integer", "minimum": 0 },
21
- "system_definition": { "type": "string", "description": "text/markdown — plurnk grammar + scheme registry refs." },
22
- "persona": { "type": "string", "description": "text/markdown — identity / mission." },
23
- "log": {
24
- "type": "array",
25
- "items": { "$ref": "https://schemas.plurnk.dev/v0/LogEntry.json" }
26
- }
27
- }
28
- },
29
- "user": {
30
- "type": "object",
31
- "required": ["tokens", "prompt", "telemetry", "system_requirements"],
32
- "additionalProperties": false,
33
- "properties": {
34
- "tokens": { "type": "integer", "minimum": 0 },
35
- "prompt": { "type": "string", "description": "Copy of loop.prompt — never null on a continuation turn." },
36
- "telemetry": {
37
- "type": "object",
38
- "description": "Per-turn instrumentation surfaced to the model. `budget` is renderer-provided markdown describing remaining context / cost / etc. `events` carries the cross-ecosystem error/telemetry stream (parser errors, scheme dispatch failures, engine rail signals, provider faults) — consumers route on each event's `source` + `kind` discriminator.",
39
- "required": ["budget", "events"],
40
- "additionalProperties": false,
41
- "properties": {
42
- "budget": { "type": "string", "description": "text/markdown — budget surface (token/cost/etc. left to spend). Empty string when nothing to surface." },
43
- "events": {
44
- "type": "array",
45
- "items": { "$ref": "https://schemas.plurnk.dev/v0/TelemetryEvent.json" },
46
- "description": "TelemetryEvent[]. Empty array when nothing to surface."
47
- }
48
- }
49
- },
50
- "system_requirements": { "type": "string", "description": "text/markdown — per-turn rules." }
51
- }
52
- },
53
- "assistant": {
54
- "type": "object",
55
- "required": ["content", "ops", "reasoning"],
56
- "additionalProperties": true,
57
- "properties": {
58
- "content": { "type": "string", "description": "Raw DSL string emitted by the model." },
59
- "ops": {
60
- "type": "array",
61
- "items": { "$ref": "https://schemas.plurnk.dev/v0/PlurnkStatement.json" },
62
- "description": "Parsed PlurnkStatement[] derived from `content`."
63
- },
64
- "reasoning": {
65
- "type": ["string", "null"],
66
- "description": "text/plain — provider-exposed CoT when present, null otherwise."
67
- }
68
- }
69
- },
70
- "assistantRaw": true
71
- }
72
- }
@@ -1,26 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.dev/v0/Run.json",
4
- "title": "Run",
5
- "description": "A stretch of work within a session. Forkable via parent_run_id. Owns per-run logs.",
6
- "type": "object",
7
- "required": ["id", "version", "session_id", "name", "created_at", "parent_run_id", "cost_pico"],
8
- "additionalProperties": false,
9
- "properties": {
10
- "id": { "type": "integer", "minimum": 1 },
11
- "version": { "type": "integer", "minimum": 0 },
12
- "session_id": { "type": "integer", "minimum": 1 },
13
- "name": {
14
- "type": "string",
15
- "minLength": 1,
16
- "description": "Unique within the session. Auto-populated default form `run-{unixtime}` until renamed. Clients display this; cross-table references use `id` so renames don't cascade-break."
17
- },
18
- "created_at": { "type": "string", "format": "date-time" },
19
- "parent_run_id": {
20
- "type": ["integer", "null"],
21
- "minimum": 1,
22
- "description": "FK to parent run when this is a fork; null for the trunk run."
23
- },
24
- "cost_pico": { "type": "integer", "minimum": 0, "description": "Cumulative cost across this run's turns, in pico-units of the active provider's currency." }
25
- }
26
- }
@@ -1,20 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.dev/v0/Session.json",
4
- "title": "Session",
5
- "description": "A durable user-named workspace. Never ends except by explicit removal. Shares session-scoped entries and any scheme-registry additions across all its runs.",
6
- "type": "object",
7
- "required": ["id", "version", "name", "created_at", "cost_pico", "scheme_registry_additions"],
8
- "additionalProperties": false,
9
- "properties": {
10
- "id": { "type": "integer", "minimum": 1 },
11
- "version": { "type": "integer", "minimum": 0 },
12
- "name": { "type": "string", "minLength": 1, "description": "Unique within the agent. Auto-populated default form `session-{unixtime}` until renamed. Clients display this; cross-table references use `id` so renames don't cascade-break." },
13
- "created_at": { "type": "string", "format": "date-time" },
14
- "cost_pico": { "type": "integer", "minimum": 0, "description": "Cumulative cost across this session's runs." },
15
- "scheme_registry_additions": {
16
- "type": "array",
17
- "items": { "$ref": "https://schemas.plurnk.dev/v0/SchemeRegistration.json" }
18
- }
19
- }
20
- }
@@ -1,39 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.dev/v0/Turn.json",
4
- "title": "Turn",
5
- "description": "The leaf of the envelope hierarchy. One model-provider exchange. Persists the full packet plus provider-returned usage and the turn-level status.",
6
- "type": "object",
7
- "required": ["id", "version", "loop_id", "sequence", "timestamp", "status", "usage", "finish_reason", "model", "packet"],
8
- "additionalProperties": false,
9
- "properties": {
10
- "id": { "type": "integer", "minimum": 1 },
11
- "version": { "type": "integer", "minimum": 0 },
12
- "loop_id": { "type": "integer", "minimum": 1 },
13
- "sequence": { "type": "integer", "minimum": 1, "description": "1-based within the loop; resets at each new loop." },
14
- "timestamp": { "type": "string", "format": "date-time" },
15
- "status": { "type": "integer", "minimum": 100, "maximum": 599 },
16
- "usage": {
17
- "type": "object",
18
- "description": "Provider-returned token counts and computed cost.",
19
- "required": ["prompt", "completion", "cached", "cost_pico"],
20
- "additionalProperties": false,
21
- "properties": {
22
- "prompt": { "type": "integer", "minimum": 0 },
23
- "completion": { "type": "integer", "minimum": 0 },
24
- "cached": { "type": "integer", "minimum": 0 },
25
- "cost_pico": { "type": "integer", "minimum": 0, "description": "Per-turn cost in pico-units of the active provider's currency." }
26
- }
27
- },
28
- "finish_reason": {
29
- "type": ["string", "null"],
30
- "description": "Provider-reported completion-state token (`stop` | `length` | `tool_calls` | `content_filter` | provider-specific). Null when not reported. Distinct from `status` (HTTP-aligned turn outcome); `finish_reason` describes how the model stopped, `status` describes how the turn resolved."
31
- },
32
- "model": {
33
- "type": "string",
34
- "minLength": 1,
35
- "description": "Wire-reported model identifier. May differ from `agent.provider.model` for routing-relay providers (OpenRouter, etc.); the verification surface for served-vs-requested alignment."
36
- },
37
- "packet": { "$ref": "https://schemas.plurnk.dev/v0/Packet.json" }
38
- }
39
- }