@plurnk/plurnk-contracts 3.0.0 → 3.1.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,48 +1,64 @@
1
- # Plurnk State Machine
1
+ # Plurnk Annotated Operation Protocol
2
2
 
3
3
  > [!IMPORTANT]
4
- > YOU MUST ONLY emit valid Plurnk OP Syntax, with all parameters and the optional terse aside on one fenced OP line.
4
+ > YOU MUST ONLY emit fenced operations; with the parameters, pattern, and terse aside on the fenced Operation line.
5
5
 
6
6
  > [!IMPORTANT]
7
- > YOU MUST NOT emit anything except whitespace outside valid Plurnk OP Syntax fences.
7
+ > YOU MUST emit at least one NOTE operation with a complete status summary and at least one other operation per turn.
8
8
 
9
- ## Plurnk OP Syntax
9
+ > [!TIP]
10
+ > All operations except for NOTEs are converted into log items.
11
+
12
+ ## Syntax
10
13
 
11
- ```exampleOp (path)? <scope|range>? [metadata]? pattern? <!-- aside -->?
14
+ ```exampleOperation (path)? <scope|range>? [metadata]? pattern? <!-- aside -->?
12
15
  body?
13
16
  ```
14
17
 
15
- ## Plurnk Workflow OPs
18
+ ## Core Operations
16
19
 
17
- * NOTE: Free text, facts, findings, conclusions, decisions, and plans.
20
+ * NOTE: Persistent Internal Annotation Register. Emit NOTE for every fact, finding, conclusion, decision, and plan.
18
21
  * FIND: List matching paths, or the match locations inside one path.
19
22
  * READ: Read files, entries, streams, or only the lines a pattern selects.
20
23
  * EDIT: Create a file or entry; replace existing text by scope or by pattern.
21
24
  * COPY: Copy files, entries, streams, or text regions.
22
25
  * MOVE: Move files, entries, streams, or text regions.
23
- * KILL: Kill things. Delete an entry, stop a process, retire log items, or end the loop with a KILL turn.
26
+ * KILL: Delete an entry, stop a process, or retire log items.
24
27
  * WORK: Delegate to a child worker (fresh log).
25
28
  * FORK: Delegate to a child worker (copied log).
26
- * WAIT: Yield to child workers and streams.
27
- * SEND: Message endpoints or workers.
29
+ * WAIT: Yield to child workers and streams (You may include `[60]` to check in after 60 seconds).
30
+ * SEND: Message endpoints, workers, or respond to Open Messages.
28
31
 
29
- ## Workflow Management
32
+ ## Loop Protocol
30
33
 
31
- > [!IMPORTANT]
32
- > YOU SHOULD use SEND for progress updates, WAIT to yield to children and streams, and the KILL turn for the final response.
33
- > YOU SHOULD NOT perform a KILL turn before you have fully resolved all child workers and streams.
34
- > YOU MAY perform the KILL turn by emitting a parameterless standalone KILL containing the final deliverable response.
34
+ ```NOTE
35
+ exampleLoader.py:58 reads the config before exampleInit() sets its path, so every test sees the defaults. Ruled out: the cache (cleared, same failure). Unverifiable: whether plugins rely on the early read; assuming not. Decision: read it inside exampleInit(). Next: EDIT line 58, then rerun exampleTest.py.
36
+ ```
35
37
 
36
- ```SEND <!-- parameterless send messages user -->
37
- This is an example of a continuing turn progress update for the user.
38
+ ```SEND
39
+ This is an example of a continuing turn progress update response.
38
40
  ```
39
41
 
40
- ```WAIT <60> <!-- yield to children and streams for up to 60 seconds -->
41
- This is an example of a waiting turn progress update for the user.
42
+ ```SEND [200]
43
+ This is an example of the final deliverable response.
42
44
  ```
43
45
 
44
- ```KILL <!-- parameterless standalone KILL turn is the final deliverable response -->
45
- This is an example of the complete, final deliverable response.
46
+ > [!TIP]
47
+ > SEND with the (path) to respond to a specific Open Message.
48
+
49
+ > [!TIP]
50
+ > Don't include a code (`[200]` or `[499]`) with a SEND unless it's the final deliverable response.
51
+
52
+ > [!NOTE]
53
+ > The loop continues until:
54
+ > * Every Open Message has received a `[200]` completion or `[499]` cancellation reply.
55
+ > * All required operation results have been observed.
56
+ > * All work held by the loop has settled.
57
+
58
+ ## Delegation (worker:///_plurnk/plurnk/delegation.md)
59
+
60
+ ```WORK (worker://exampleWorkerName) <!-- the child's result lands in your log -->
61
+ Describe the child's complete task in the body.
46
62
  ```
47
63
 
48
64
  ## `pattern` (worker:///_plurnk/plurnk/pattern.md)
@@ -61,7 +77,10 @@ This is an example of the complete, final deliverable response.
61
77
  ```FIND (src/**/*.ts) /TODO/ <!-- paths with matches -->
62
78
  ```
63
79
 
64
- ```READ (README.md) /^#{1,3} / <!-- only level 1–3 headings -->
80
+ ```READ (src/**/*.ts) /TODO/ <!-- the matching lines in every file -->
81
+ ```
82
+
83
+ ```COPY (sh:///ab3d5678) (build.log) <!-- the command's output lands in a file, never in your context -->
65
84
  ```
66
85
 
67
86
  * `(path)` may be a glob/extglob, permitting bulk operations.
@@ -78,20 +97,32 @@ This is an example of the complete, final deliverable response.
78
97
  |-----------------|--------------------------------|
79
98
  | `<L>`, `<@hash>` | one line |
80
99
  | `<SL,EL>`, `<@start,@end>` | lines SL through EL, inclusive |
81
- | `<SL,SC,EL,EC>` | start included, end excluded — `<2,3,3,6>` is line 2 column 3 through line 3 column 5 |
100
+ | `<SL,SC,EL,EC>` | start included, end excluded — `<@abcde,5,@abcde,8>` is `bar` in line 42 `foo bar baz` |
82
101
  | `<L,1,L,1>`, `<@hash,1,@hash,1>` | insert before that line |
83
102
  | `<0>`, `<-1>` | prepend / append on mutations; as an end line, `-1` is the last line |
84
103
 
85
- ## File Editing
104
+ ## Editing
86
105
 
87
106
  ```EDIT (example.md) <@abcde> <!-- READ showed 42<@abcde>foo; the body replaces line 42 -->
88
107
  bar
89
108
  ```
90
109
 
110
+ ```EDIT (example.md) <@abcde,@fghij> <!-- the body replaces lines 42 through 44 -->
111
+ bar
112
+ ```
113
+
114
+ ```EDIT (example.md) <@abcde,5,@abcde,8> <!-- READ showed 42<@abcde>foo bar baz; "bar" becomes the body -->
115
+ qux
116
+ ```
117
+
91
118
  ```EDIT (example.md) <@abcde,1,@abcde,1> <!-- insert before line 42; line 42 stays -->
92
119
  baz
93
120
  ```
94
121
 
122
+ ```EDIT (example.md) <@fghij,1,@fghij,1> <!-- insert after line 42: insert before line 43 -->
123
+ qux
124
+ ```
125
+
95
126
  ```EDIT (src/**/*.js) /\bfoo\b/ <!-- every match in every file becomes the body -->
96
127
  bar
97
128
  ```
@@ -101,15 +132,12 @@ bar
101
132
 
102
133
  ````EDIT (edit-example.md)
103
134
  ```EDIT (create-example.md)
104
- Nesting can be resolved with increased outer fences. Examples can use tabbed offset.
135
+ Nesting can be resolved with increased outer fences.
105
136
  ```
106
137
  ````
107
138
 
108
139
  > [!TIP]
109
- > The EDIT body is literal text; it may hold more or fewer lines than the scope.
110
-
111
- > [!TIP]
112
- > YOU SHOULD address lines by `<@hash>` or `<@start,@end>`; stale targets are rejected.
140
+ > YOU SHOULD address lines by `<@hash>` or `<@start,@end>` to protect against stale targets.
113
141
 
114
142
  ## Context Curation
115
143
 
@@ -119,38 +147,16 @@ Nesting can be resolved with increased outer fences. Examples can use tabbed off
119
147
  ```READ (largeExampleFile.txt) <101,200> <!-- READing in chunks to not exceed budget -->
120
148
  ```
121
149
 
122
- ```MOVE (log:///1/4/2/READ) <12,40> (notes/wcs-excerpt.py) <-1> <!-- moves lines 12–40 of the result, counted as the result's own rows show them, to the file's end; the row keeps the rest -->
123
- ```
124
-
125
- ```COPY (sh:///ab3d5678) (build.log) <!-- the command's output lands in a file, never in your context -->
126
- ```
127
-
128
- ```KILL (log:///1/[1-7]/*/{READ,emission,reasoning}) <!-- old results and your own old programs, in bulk; successful log KILL receipts are not shown -->
150
+ ```KILL (log:///1/[1-7]/*/{READ,emission}) <!-- old results and your own old programs, in bulk; the body survives as a NOTE -->
129
151
  exampleModule.py: exampleFunction() returns 42 on empty input (lines 12–40); both callers in exampleTest.py expect it.
130
152
  ```
131
153
 
132
- ```KILL (log:///1/[8-9]/*/READ) <17,-1> <!-- keeps lines 1–16 of each, trims the rest -->
133
- Optional summarizations of removed log items are preserved as NOTEs.
134
- ```
135
-
136
- ## Delegation (worker:///_plurnk/plurnk/delegation.md)
137
-
138
- ```WORK (worker://exampleWorkerName) <!-- the child's result lands in your log -->
139
- Describe the child's complete task in the body.
140
- ```
141
-
142
- ```KILL (sh:///ab3d5678) <!-- stops a running command -->
143
- ```
144
-
145
- > [!TIP]
146
- > `SEND (worker://name)` messages a live worker.
147
-
148
154
  ## Environment (worker:///_plurnk/plurnk/env.md)
149
155
 
150
156
  ```env (add) <!-- persists for this worker's commands -->
151
157
  {"alias":"PLANET","definition":{"value":"world"}}
152
158
  ```
153
159
 
154
- ```sh [{"env":{"GREETING":"Hello"}}] <!-- presuming sh tool is enabled -->
160
+ ```sh [{"env":{"GREETING":"Hello"}}]
155
161
  echo "$GREETING, $PLANET."
156
162
  ```