@plurnk/plurnk-grammar 0.1.0 → 0.2.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.
@@ -0,0 +1,183 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.plurnk.dev/v0/PlurnkStatement.json",
4
+ "title": "PlurnkStatement",
5
+ "description": "The parsed AST of one plurnk statement. Discriminated on `op`. SEND and EXEC have no `<L>` slot — `lineMarker` is always null for those. Body shape varies per op: matcher dialect for FIND/READ/SHOW/HIDE, raw string for EDIT/EXEC, ParsedPath for COPY/MOVE, SendBody for SEND.",
6
+ "oneOf": [
7
+ { "$ref": "#/$defs/FindStatement" },
8
+ { "$ref": "#/$defs/ReadStatement" },
9
+ { "$ref": "#/$defs/ShowStatement" },
10
+ { "$ref": "#/$defs/HideStatement" },
11
+ { "$ref": "#/$defs/EditStatement" },
12
+ { "$ref": "#/$defs/CopyStatement" },
13
+ { "$ref": "#/$defs/MoveStatement" },
14
+ { "$ref": "#/$defs/SendStatement" },
15
+ { "$ref": "#/$defs/ExecStatement" }
16
+ ],
17
+ "$defs": {
18
+ "TagSignal": {
19
+ "oneOf": [
20
+ { "type": "array", "items": { "type": "string" } },
21
+ { "type": "null" }
22
+ ]
23
+ },
24
+ "PathOrNull": {
25
+ "oneOf": [
26
+ { "$ref": "https://schemas.plurnk.dev/v0/ParsedPath.json" },
27
+ { "type": "null" }
28
+ ]
29
+ },
30
+ "LineMarkerOrNull": {
31
+ "oneOf": [
32
+ { "$ref": "https://schemas.plurnk.dev/v0/LineMarker.json" },
33
+ { "type": "null" }
34
+ ]
35
+ },
36
+ "MatcherBodyOrNull": {
37
+ "oneOf": [
38
+ { "$ref": "https://schemas.plurnk.dev/v0/MatcherBody.json" },
39
+ { "type": "null" }
40
+ ]
41
+ },
42
+ "SendBodyOrNull": {
43
+ "oneOf": [
44
+ { "$ref": "https://schemas.plurnk.dev/v0/SendBody.json" },
45
+ { "type": "null" }
46
+ ]
47
+ },
48
+ "PositionRef": {
49
+ "$ref": "https://schemas.plurnk.dev/v0/Position.json"
50
+ },
51
+ "FindStatement": {
52
+ "type": "object",
53
+ "required": ["op", "suffix", "signal", "path", "lineMarker", "body", "position"],
54
+ "additionalProperties": false,
55
+ "properties": {
56
+ "op": { "const": "FIND" },
57
+ "suffix": { "type": "string" },
58
+ "signal": { "$ref": "#/$defs/TagSignal" },
59
+ "path": { "$ref": "#/$defs/PathOrNull" },
60
+ "lineMarker": { "$ref": "#/$defs/LineMarkerOrNull" },
61
+ "body": { "$ref": "#/$defs/MatcherBodyOrNull" },
62
+ "position": { "$ref": "#/$defs/PositionRef" }
63
+ }
64
+ },
65
+ "ReadStatement": {
66
+ "type": "object",
67
+ "required": ["op", "suffix", "signal", "path", "lineMarker", "body", "position"],
68
+ "additionalProperties": false,
69
+ "properties": {
70
+ "op": { "const": "READ" },
71
+ "suffix": { "type": "string" },
72
+ "signal": { "$ref": "#/$defs/TagSignal" },
73
+ "path": { "$ref": "#/$defs/PathOrNull" },
74
+ "lineMarker": { "$ref": "#/$defs/LineMarkerOrNull" },
75
+ "body": { "$ref": "#/$defs/MatcherBodyOrNull" },
76
+ "position": { "$ref": "#/$defs/PositionRef" }
77
+ }
78
+ },
79
+ "ShowStatement": {
80
+ "type": "object",
81
+ "required": ["op", "suffix", "signal", "path", "lineMarker", "body", "position"],
82
+ "additionalProperties": false,
83
+ "properties": {
84
+ "op": { "const": "SHOW" },
85
+ "suffix": { "type": "string" },
86
+ "signal": { "$ref": "#/$defs/TagSignal" },
87
+ "path": { "$ref": "#/$defs/PathOrNull" },
88
+ "lineMarker": { "$ref": "#/$defs/LineMarkerOrNull" },
89
+ "body": { "$ref": "#/$defs/MatcherBodyOrNull" },
90
+ "position": { "$ref": "#/$defs/PositionRef" }
91
+ }
92
+ },
93
+ "HideStatement": {
94
+ "type": "object",
95
+ "required": ["op", "suffix", "signal", "path", "lineMarker", "body", "position"],
96
+ "additionalProperties": false,
97
+ "properties": {
98
+ "op": { "const": "HIDE" },
99
+ "suffix": { "type": "string" },
100
+ "signal": { "$ref": "#/$defs/TagSignal" },
101
+ "path": { "$ref": "#/$defs/PathOrNull" },
102
+ "lineMarker": { "$ref": "#/$defs/LineMarkerOrNull" },
103
+ "body": { "$ref": "#/$defs/MatcherBodyOrNull" },
104
+ "position": { "$ref": "#/$defs/PositionRef" }
105
+ }
106
+ },
107
+ "EditStatement": {
108
+ "type": "object",
109
+ "required": ["op", "suffix", "signal", "path", "lineMarker", "body", "position"],
110
+ "additionalProperties": false,
111
+ "properties": {
112
+ "op": { "const": "EDIT" },
113
+ "suffix": { "type": "string" },
114
+ "signal": { "$ref": "#/$defs/TagSignal" },
115
+ "path": { "$ref": "#/$defs/PathOrNull" },
116
+ "lineMarker": { "$ref": "#/$defs/LineMarkerOrNull" },
117
+ "body": { "type": ["string", "null"] },
118
+ "position": { "$ref": "#/$defs/PositionRef" }
119
+ }
120
+ },
121
+ "CopyStatement": {
122
+ "type": "object",
123
+ "required": ["op", "suffix", "signal", "path", "lineMarker", "body", "position"],
124
+ "additionalProperties": false,
125
+ "properties": {
126
+ "op": { "const": "COPY" },
127
+ "suffix": { "type": "string" },
128
+ "signal": { "$ref": "#/$defs/TagSignal" },
129
+ "path": { "$ref": "#/$defs/PathOrNull" },
130
+ "lineMarker": { "$ref": "#/$defs/LineMarkerOrNull" },
131
+ "body": { "$ref": "#/$defs/PathOrNull" },
132
+ "position": { "$ref": "#/$defs/PositionRef" }
133
+ }
134
+ },
135
+ "MoveStatement": {
136
+ "type": "object",
137
+ "required": ["op", "suffix", "signal", "path", "lineMarker", "body", "position"],
138
+ "additionalProperties": false,
139
+ "properties": {
140
+ "op": { "const": "MOVE" },
141
+ "suffix": { "type": "string" },
142
+ "signal": { "$ref": "#/$defs/TagSignal" },
143
+ "path": { "$ref": "#/$defs/PathOrNull" },
144
+ "lineMarker": { "$ref": "#/$defs/LineMarkerOrNull" },
145
+ "body": { "$ref": "#/$defs/PathOrNull" },
146
+ "position": { "$ref": "#/$defs/PositionRef" }
147
+ }
148
+ },
149
+ "SendStatement": {
150
+ "type": "object",
151
+ "required": ["op", "suffix", "signal", "path", "lineMarker", "body", "position"],
152
+ "additionalProperties": false,
153
+ "properties": {
154
+ "op": { "const": "SEND" },
155
+ "suffix": { "type": "string" },
156
+ "signal": {
157
+ "oneOf": [
158
+ { "type": "number" },
159
+ { "type": "null" }
160
+ ]
161
+ },
162
+ "path": { "$ref": "#/$defs/PathOrNull" },
163
+ "lineMarker": { "type": "null" },
164
+ "body": { "$ref": "#/$defs/SendBodyOrNull" },
165
+ "position": { "$ref": "#/$defs/PositionRef" }
166
+ }
167
+ },
168
+ "ExecStatement": {
169
+ "type": "object",
170
+ "required": ["op", "suffix", "signal", "path", "lineMarker", "body", "position"],
171
+ "additionalProperties": false,
172
+ "properties": {
173
+ "op": { "const": "EXEC" },
174
+ "suffix": { "type": "string" },
175
+ "signal": { "type": ["string", "null"] },
176
+ "path": { "$ref": "#/$defs/PathOrNull" },
177
+ "lineMarker": { "type": "null" },
178
+ "body": { "type": ["string", "null"] },
179
+ "position": { "$ref": "#/$defs/PositionRef" }
180
+ }
181
+ }
182
+ }
183
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.plurnk.dev/v0/Position.json",
4
+ "title": "Position",
5
+ "description": "A line/column position in a parsed plurnk document. ANTLR emits 1-based lines and 0-based columns; degraded positions may use 0 for both when the source token's location is unknown.",
6
+ "type": "object",
7
+ "required": ["line", "column"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "line": { "type": "integer", "minimum": 0 },
11
+ "column": { "type": "integer", "minimum": 0 }
12
+ }
13
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.plurnk.dev/v0/ProviderDeclaration.json",
4
+ "title": "ProviderDeclaration",
5
+ "description": "Declaration of the active provider for an agent. The grammar package owns these four fields; auth/connection config lives in the agent repo.",
6
+ "type": "object",
7
+ "required": ["provider", "family", "model", "contextSize", "currency"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "provider": { "type": "string", "minLength": 1, "description": "API vendor identifier (e.g. \"anthropic\", \"openai\", \"google\", \"local\")." },
11
+ "family": { "type": "string", "minLength": 1, "description": "Model family (e.g. \"claude\", \"gpt\", \"gemini\", \"llama\")." },
12
+ "model": { "type": "string", "minLength": 1, "description": "Specific model id (e.g. \"claude-opus-4-7\")." },
13
+ "contextSize": { "type": "integer", "minimum": 1, "description": "Total context window in tokens." },
14
+ "currency": { "type": "string", "pattern": "^[A-Z]{3}$", "description": "ISO 4217 code; the unit `cost_pico` is denominated in." }
15
+ }
16
+ }
@@ -0,0 +1,21 @@
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 and visibility state.",
6
+ "type": "object",
7
+ "required": ["id", "version", "session_id", "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
+ "created_at": { "type": "string", "format": "date-time" },
14
+ "parent_run_id": {
15
+ "type": ["integer", "null"],
16
+ "minimum": 1,
17
+ "description": "FK to parent run when this is a fork; null for the trunk run."
18
+ },
19
+ "cost_pico": { "type": "integer", "minimum": 0, "description": "Cumulative cost across this run's turns, in pico-units of the active provider's currency." }
20
+ }
21
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.plurnk.dev/v0/SchemeRegistration.json",
4
+ "title": "SchemeRegistration",
5
+ "description": "A scheme entry in the agent's scheme registry. Defines what `<name>://` resolves to and how it's accessible.",
6
+ "type": "object",
7
+ "required": ["name", "model_visible", "category", "default_scope", "default_channel", "writable_by", "volatile", "handler"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "name": {
11
+ "type": "string",
12
+ "pattern": "^[a-z][a-z0-9+.\\-]*$",
13
+ "description": "Scheme name without `://`. Matches the URL scheme character class."
14
+ },
15
+ "model_visible": { "type": "boolean" },
16
+ "category": { "type": "string", "minLength": 1 },
17
+ "default_scope": { "enum": ["agent", "session"] },
18
+ "default_channel": {
19
+ "type": "string",
20
+ "pattern": "^[a-z][a-z0-9_-]*$",
21
+ "description": "Channel name selected when an op against this scheme has no fragment. Conventionally `body`; exec schemes typically declare `stdout`."
22
+ },
23
+ "writable_by": {
24
+ "type": "array",
25
+ "items": { "enum": ["model", "client", "system", "plugin"] },
26
+ "uniqueItems": true
27
+ },
28
+ "volatile": { "type": "boolean" },
29
+ "handler": { "type": ["string", "null"] }
30
+ }
31
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.plurnk.dev/v0/SendBody.json",
4
+ "title": "SendBody",
5
+ "description": "Parsed body of a SEND statement. `raw` is the literal body text; `json` is the best-effort `JSON.parse(raw)` result, or null when the body isn't valid JSON.",
6
+ "type": "object",
7
+ "required": ["raw", "json"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "raw": { "type": "string" },
11
+ "json": true
12
+ }
13
+ }
@@ -0,0 +1,20 @@
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. Default form: `{modelAlias}-{unixtime}` until renamed." },
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
+ }
@@ -0,0 +1,30 @@
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", "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
+ "packet": { "$ref": "https://schemas.plurnk.dev/v0/Packet.json" }
29
+ }
30
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.plurnk.dev/v0/Visibility.json",
4
+ "title": "Visibility",
5
+ "description": "Per-run, per-channel visibility row. Pairs an (entry, channel) with an `indexed` boolean — true means the channel appears in the run's Index (visible to the model); false means Archive (out of working memory but addressable). Allows fine-grained promotion (e.g. exec://run-tests#stdout indexed while #stderr archived).",
6
+ "type": "object",
7
+ "required": ["entry_id", "channel", "indexed"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "entry_id": { "type": "integer", "minimum": 1 },
11
+ "channel": {
12
+ "type": "string",
13
+ "pattern": "^[a-z][a-z0-9_-]*$"
14
+ },
15
+ "indexed": { "type": "boolean" }
16
+ }
17
+ }