pi-openai-codex-compat 0.0.6 → 0.0.7
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/APPLY_PATCH_INSTRUCTION_FEEDBACK.md +617 -0
- package/CHANGELOG.md +44 -0
- package/LICENSES/tree-sitter-wasms-MIT.txt +21 -0
- package/LICENSES/web-tree-sitter-MIT.txt +21 -0
- package/README.md +37 -9
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/extensions/openai-codex-compat/apply-patch-diff-render.ts +499 -20
- package/extensions/openai-codex-compat/apply-patch-engine.ts +4085 -491
- package/extensions/openai-codex-compat/apply-patch-matcher.ts +1535 -0
- package/extensions/openai-codex-compat/apply-patch-render.ts +85 -19
- package/extensions/openai-codex-compat/apply-patch.ts +41 -5
- package/extensions/openai-codex-compat/codex-provider.ts +252 -14
- package/extensions/openai-codex-compat/codex-stream.ts +78 -61
- package/extensions/openai-codex-compat/compaction-checkpoint.ts +28 -0
- package/extensions/openai-codex-compat/config.ts +18 -0
- package/extensions/openai-codex-compat/footer.ts +4 -8
- package/extensions/openai-codex-compat/index.ts +4 -1
- package/extensions/openai-codex-compat/remote-compaction.ts +4 -0
- package/extensions/openai-codex-compat/settings-pane.ts +11 -0
- package/extensions/openai-codex-compat/tools.ts +2 -1
- package/package.json +10 -4
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
# `apply_patch` Instruction Feedback
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
This document is the standalone implementation reference for model and TUI
|
|
6
|
+
feedback produced by `apply_patch`. It defines the agreed result structure,
|
|
7
|
+
terminology, rendering, failure inspection, and test requirements.
|
|
8
|
+
|
|
9
|
+
`APPLY_PATCH_SEMANTIC_OPERATIONS.md` remains authoritative for filesystem and
|
|
10
|
+
matching semantics. This document is authoritative for presenting those
|
|
11
|
+
semantics to the model and user.
|
|
12
|
+
|
|
13
|
+
## Goals
|
|
14
|
+
|
|
15
|
+
Feedback must:
|
|
16
|
+
|
|
17
|
+
1. retain the aggregate changed-file summary;
|
|
18
|
+
2. when an instruction ledger is needed, report every instruction without a
|
|
19
|
+
model-facing limit;
|
|
20
|
+
3. attribute filesystem effects, errors, and matching evidence to the
|
|
21
|
+
instruction that produced them;
|
|
22
|
+
4. report failed and not-run instructions;
|
|
23
|
+
5. use concise, simplified technical English;
|
|
24
|
+
6. report deterministic facts rather than speculative outcomes; and
|
|
25
|
+
7. avoid repeating old or replacement text supplied in the patch.
|
|
26
|
+
|
|
27
|
+
## Aggregate summary
|
|
28
|
+
|
|
29
|
+
Successful results retain the current summary:
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
Success. Updated the following files:
|
|
33
|
+
A added.txt
|
|
34
|
+
M updated.txt
|
|
35
|
+
D deleted.txt
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
When every instruction has no filesystem effect:
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
Success. No files were changed.
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Failed results identify the failed instruction and list confirmed changed
|
|
45
|
+
paths:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
Patch failed at instruction 3 of 5.
|
|
49
|
+
Files changed:
|
|
50
|
+
M updated.txt
|
|
51
|
+
A destination.txt
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The changed-file list includes completed effects from failed instructions. A
|
|
55
|
+
path whose final state is not verified is not listed as changed unless another
|
|
56
|
+
completed, verified effect on that path is available.
|
|
57
|
+
|
|
58
|
+
When a failed instruction creates only a directory or leaves only a temporary
|
|
59
|
+
entry, use:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
Filesystem changed.
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The directory or temporary-entry path remains on its instruction instead of
|
|
66
|
+
being mislabelled as an added file.
|
|
67
|
+
|
|
68
|
+
`No files were changed.` is valid only when every relevant path was verified
|
|
69
|
+
unchanged. When no changed path is confirmed and at least one relevant final
|
|
70
|
+
state is not verified, omit the global changed/unchanged statement and report
|
|
71
|
+
the unverified state on its instruction.
|
|
72
|
+
|
|
73
|
+
Keep the existing exit-code and wall-time envelope where the tool currently
|
|
74
|
+
uses it.
|
|
75
|
+
|
|
76
|
+
## Patch instruction results
|
|
77
|
+
|
|
78
|
+
Append an instruction ledger when at least one instruction is not `APPLIED` or
|
|
79
|
+
an applied instruction has a feedback clause. Omit the ledger when every
|
|
80
|
+
instruction is `APPLIED` without feedback.
|
|
81
|
+
|
|
82
|
+
When included, the aggregate summary is followed by this exact heading:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
Patch instruction results:
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Every instruction is then listed in source order, including ordinary applied
|
|
89
|
+
instructions without feedback. Model feedback has no instruction limit and no
|
|
90
|
+
omitted-count message.
|
|
91
|
+
|
|
92
|
+
Visible statuses are:
|
|
93
|
+
|
|
94
|
+
- `APPLIED`
|
|
95
|
+
- `NO CHANGE`
|
|
96
|
+
- `SKIPPED`
|
|
97
|
+
- `FAILED`
|
|
98
|
+
- `NOT RUN`
|
|
99
|
+
|
|
100
|
+
The TUI may additionally use `PLANNED` while an `apply_patch` call is still in
|
|
101
|
+
progress. Pi renders this read-only preview after the arguments are complete
|
|
102
|
+
and before execution begins. `PLANNED` is not sent to the model and does not
|
|
103
|
+
appear in completed tool results.
|
|
104
|
+
|
|
105
|
+
Example:
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
Patch instruction results:
|
|
109
|
+
1. [APPLIED] Update a.txt
|
|
110
|
+
2. [NO CHANGE] Delete missing.txt - Path already absent.
|
|
111
|
+
3. [FAILED] Update & Move source.txt -> destination.txt - Created destination.txt; source.txt remains; The updated content was written to the destination, but removing the source failed: permission denied; The file at destination.txt contains the requested content byte-for-byte despite the reported error.
|
|
112
|
+
4. [NOT RUN] Update other.txt - Instruction 3 failed.
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Model-facing separators and move arrows are ASCII. The TUI may use styled
|
|
116
|
+
status labels and Unicode arrows.
|
|
117
|
+
|
|
118
|
+
## Concision rules
|
|
119
|
+
|
|
120
|
+
When the ledger is included because another instruction needs explanation, an
|
|
121
|
+
ordinary applied instruction needs only its status and operation:
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
1. [APPLIED] Add a.txt
|
|
125
|
+
2. [APPLIED] Update b.txt
|
|
126
|
+
3. [APPLIED] Update & Move c.txt -> d.txt
|
|
127
|
+
4. [APPLIED] Move e.txt -> f.txt
|
|
128
|
+
5. [APPLIED] Delete g.txt
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Add a short clause only for:
|
|
132
|
+
|
|
133
|
+
- a no-change or skipped reason;
|
|
134
|
+
- a failure;
|
|
135
|
+
- a non-obvious externally visible filesystem effect;
|
|
136
|
+
- a partial effect;
|
|
137
|
+
- a final state that is not verified; or
|
|
138
|
+
- concise matcher evidence.
|
|
139
|
+
|
|
140
|
+
Do not include:
|
|
141
|
+
|
|
142
|
+
- old or replacement patch blocks;
|
|
143
|
+
- a diff-availability warning;
|
|
144
|
+
- verbose proof sections;
|
|
145
|
+
- a duplicated raw error section;
|
|
146
|
+
- a detached matcher section; or
|
|
147
|
+
- prose that merely restates an ordinary successful operation.
|
|
148
|
+
|
|
149
|
+
## Terminology
|
|
150
|
+
|
|
151
|
+
Do not expose these terms in model or TUI feedback:
|
|
152
|
+
|
|
153
|
+
- `Committed prefix`
|
|
154
|
+
- `exact`
|
|
155
|
+
- `inexact`
|
|
156
|
+
- `dead`
|
|
157
|
+
- `dominated`
|
|
158
|
+
- `no-op`
|
|
159
|
+
- `preflight`
|
|
160
|
+
- `installed`
|
|
161
|
+
|
|
162
|
+
Prefer:
|
|
163
|
+
|
|
164
|
+
- `created`
|
|
165
|
+
- `replaced`
|
|
166
|
+
- `updated`
|
|
167
|
+
- `deleted`
|
|
168
|
+
- `removed`
|
|
169
|
+
- `moved`
|
|
170
|
+
- `present`
|
|
171
|
+
- `absent`
|
|
172
|
+
- `remains`
|
|
173
|
+
- `not verified`
|
|
174
|
+
- `validation`
|
|
175
|
+
- `patch format`
|
|
176
|
+
- `symlink`
|
|
177
|
+
|
|
178
|
+
Generated explanatory text must not speculate with words such as `may`,
|
|
179
|
+
`might`, `possibly`, `probably`, or `likely`. When inspection cannot determine
|
|
180
|
+
a path's state, say:
|
|
181
|
+
|
|
182
|
+
```text
|
|
183
|
+
Final state not verified for a.txt.
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## No-change results
|
|
187
|
+
|
|
188
|
+
Render semantic no-ops as `NO CHANGE`:
|
|
189
|
+
|
|
190
|
+
```text
|
|
191
|
+
1. [NO CHANGE] Update a.txt - The instruction contains no changes.
|
|
192
|
+
2. [NO CHANGE] Update b.txt - Old and replacement content are identical.
|
|
193
|
+
3. [NO CHANGE] Update c.txt - Applying the update would not change the file.
|
|
194
|
+
4. [NO CHANGE] Add d.txt - The file already contains the requested content byte-for-byte.
|
|
195
|
+
5. [NO CHANGE] Delete e.txt - Path already absent.
|
|
196
|
+
6. [NO CHANGE] Move f.txt -> f.txt - Source and destination identify the same entry.
|
|
197
|
+
7. [NO CHANGE] Move a.txt -> b.txt - Instruction 2 already moved this entry.
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The fulfilled-move result records and references the earlier instruction that
|
|
201
|
+
performed the move. A missing related instruction number is an internal
|
|
202
|
+
invariant failure; there is no generic earlier-instruction fallback.
|
|
203
|
+
|
|
204
|
+
## Skipped results
|
|
205
|
+
|
|
206
|
+
Render a semantically eliminated operation as `SKIPPED`, not `DEAD`.
|
|
207
|
+
|
|
208
|
+
```text
|
|
209
|
+
2. [SKIPPED] Update a.txt - Instruction 4 deletes a.txt before another instruction reads it.
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
For a shared hard-linked file:
|
|
213
|
+
|
|
214
|
+
```text
|
|
215
|
+
2. [SKIPPED] Update a.txt - Instructions 4 and 6 delete every link before another instruction reads the file.
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The concise reason and related instruction numbers remain on the skipped
|
|
219
|
+
instruction. Do not create a separate proof section.
|
|
220
|
+
|
|
221
|
+
## Per-instruction filesystem effects
|
|
222
|
+
|
|
223
|
+
Each instruction result stores:
|
|
224
|
+
|
|
225
|
+
- its status;
|
|
226
|
+
- an optional concise reason;
|
|
227
|
+
- completed externally visible filesystem effects;
|
|
228
|
+
- relevant final path states;
|
|
229
|
+
- an optional error;
|
|
230
|
+
- optional matcher evidence; and
|
|
231
|
+
- related instruction numbers.
|
|
232
|
+
|
|
233
|
+
The operation label is sufficient for ordinary successful effects. Explicit
|
|
234
|
+
effects are required for:
|
|
235
|
+
|
|
236
|
+
- a partial effect from a failed instruction;
|
|
237
|
+
- destination replacement;
|
|
238
|
+
- symlink entry versus target behavior, including the raw target pathname
|
|
239
|
+
stored in the symlink;
|
|
240
|
+
- a parent directory that remains after failure;
|
|
241
|
+
- deletion of a destination before replacement failure;
|
|
242
|
+
- a temporary entry remaining after cleanup failure;
|
|
243
|
+
- a source remaining after destination creation or replacement; and
|
|
244
|
+
- a final state that is not verified.
|
|
245
|
+
|
|
246
|
+
Effects from a failed instruction remain attached to that instruction. They
|
|
247
|
+
must not be called earlier changes.
|
|
248
|
+
|
|
249
|
+
Use only `symlink` terminology. Symlink feedback records the raw target
|
|
250
|
+
pathname returned by `readlink`; it does not substitute a resolved absolute
|
|
251
|
+
path.
|
|
252
|
+
|
|
253
|
+
Every replacement effect records both the verified previous entry type and the
|
|
254
|
+
verified resulting entry type. A resulting symlink also records its raw target
|
|
255
|
+
pathname. Replacement feedback must not omit either entry type. If
|
|
256
|
+
neither execution nor post-failure inspection can verify the result, report
|
|
257
|
+
the final state as not verified instead of claiming a replacement.
|
|
258
|
+
|
|
259
|
+
Examples:
|
|
260
|
+
|
|
261
|
+
```text
|
|
262
|
+
1. [APPLIED] Add alias.txt - alias.txt, previously a symlink to target.txt, is now a regular file.
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
```text
|
|
266
|
+
1. [APPLIED] Update alias.txt - Modified file content through the symlink at alias.txt (target: target.txt); the symlink was not modified.
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
```text
|
|
270
|
+
1. [APPLIED] Move alias.txt -> moved/alias.txt - Moved the symlink alias.txt; moved/alias.txt is now a symlink to target.txt.
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Deletion and move differ only because deletion removes the symlink while a
|
|
274
|
+
move preserves it and its stored target pathname. Feedback reports the
|
|
275
|
+
resulting path directly rather than making an unconditional claim about the
|
|
276
|
+
filesystem path named by the target.
|
|
277
|
+
|
|
278
|
+
Failure examples:
|
|
279
|
+
|
|
280
|
+
```text
|
|
281
|
+
3. [FAILED] Update & Move a.txt -> b.txt - Created b.txt; a.txt remains; The updated content was written to the destination, but removing the source failed: permission denied; The file at b.txt contains the requested content byte-for-byte despite the reported error.
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
```text
|
|
285
|
+
3. [FAILED] Move a.txt -> b.txt - b.txt is still a regular file; a.txt remains; Move failed: permission denied.
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
```text
|
|
289
|
+
3. [FAILED] Move a.txt -> b.txt - Deleted the previous b.txt; b.txt is absent; replacement failed: permission denied.
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
```text
|
|
293
|
+
3. [FAILED] Move a.txt -> dir/b.txt - Created directory dir; move failed: permission denied.
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Post-failure inspection
|
|
297
|
+
|
|
298
|
+
After a low-level filesystem operation fails, inspect every relevant source,
|
|
299
|
+
destination, parent, followed target, and temporary path before constructing
|
|
300
|
+
feedback.
|
|
301
|
+
|
|
302
|
+
Path-state feedback uses only deterministic states:
|
|
303
|
+
|
|
304
|
+
- present as a regular file;
|
|
305
|
+
- present as a symlink;
|
|
306
|
+
- absent;
|
|
307
|
+
- unchanged;
|
|
308
|
+
- contains the requested content byte-for-byte;
|
|
309
|
+
- differs from the requested content;
|
|
310
|
+
- differs from the previously observed content;
|
|
311
|
+
- differs from both the requested and previously observed content;
|
|
312
|
+
- is a different filesystem entry;
|
|
313
|
+
- entry type changed; or
|
|
314
|
+
- not verified.
|
|
315
|
+
|
|
316
|
+
Examples:
|
|
317
|
+
|
|
318
|
+
```text
|
|
319
|
+
3. [FAILED] Update a.txt - Write failed: permission denied; a.txt is unchanged.
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
```text
|
|
323
|
+
3. [FAILED] Update a.txt - Write reported an error; The file at a.txt contains the requested content byte-for-byte despite the reported error.
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
```text
|
|
327
|
+
3. [FAILED] Update a.txt - Write failed: input/output error; final state not verified for a.txt.
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
An empty recorded-change list is not proof that no file changed.
|
|
331
|
+
|
|
332
|
+
## Unreadable previous content
|
|
333
|
+
|
|
334
|
+
Replacing a file without reading its previous content produces ordinary
|
|
335
|
+
success feedback:
|
|
336
|
+
|
|
337
|
+
```text
|
|
338
|
+
Success. Updated the following files:
|
|
339
|
+
A file.txt
|
|
340
|
+
|
|
341
|
+
Patch instruction results:
|
|
342
|
+
1. [APPLIED] Add file.txt
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Do not tell the model that previous content was unreadable, a diff is
|
|
346
|
+
unavailable, history is incomplete, or the result is inexact. Diff
|
|
347
|
+
availability is a TUI/history concern, not an operation result.
|
|
348
|
+
|
|
349
|
+
## Matcher feedback
|
|
350
|
+
|
|
351
|
+
Matcher feedback belongs to the failed update instruction. Do not emit a
|
|
352
|
+
detached `Matcher diagnostics:` section or repeat old/replacement patch text.
|
|
353
|
+
|
|
354
|
+
Examples:
|
|
355
|
+
|
|
356
|
+
```text
|
|
357
|
+
3. [FAILED] Update file.ts - Old content was not found. Read the current file and use apply_patch again with updated instructions if needed.
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
```text
|
|
361
|
+
3. [FAILED] Update file.ts - The requested changes match in reverse source-file order at lines 10-12 and lines 30-32. Use apply_patch again with the requested changes in source-file order if needed.
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
```text
|
|
365
|
+
3. [FAILED] Update file.ts - Matching locations at lines 10-12 and lines 40-42 produce different results. Use apply_patch again with more specific surrounding context or smaller changes if needed.
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
```text
|
|
369
|
+
3. [FAILED] Update file.ts - More than 256 possible ways to apply the requested changes were found. Use apply_patch again with more specific surrounding context or smaller changes if needed.
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
```text
|
|
373
|
+
3. [FAILED] Update file.ts - Requested replacement found at lines 40-44, but old content was not found. Inspect the reported lines and use apply_patch again with updated instructions if needed.
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
The 64-location limit, different-result ambiguity, and 256-way limit use the
|
|
377
|
+
same guidance because each requires more specific surrounding context or
|
|
378
|
+
smaller requested changes. Reverse-order and overlap failures instead tell the
|
|
379
|
+
model to reorder or separate the requested changes.
|
|
380
|
+
|
|
381
|
+
## Not-run results
|
|
382
|
+
|
|
383
|
+
Every not-run instruction identifies why it did not run:
|
|
384
|
+
|
|
385
|
+
```text
|
|
386
|
+
4. [NOT RUN] Update other.txt - Instruction 3 failed.
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
For errors not owned by an instruction:
|
|
390
|
+
|
|
391
|
+
```text
|
|
392
|
+
1. [NOT RUN] Update a.txt - Patch format error.
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
```text
|
|
396
|
+
1. [NOT RUN] Update a.txt - apply_patch setup failed before this instruction was executed.
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Cancellation uses
|
|
400
|
+
`apply_patch was cancelled before this instruction was executed.` A
|
|
401
|
+
non-cancellation stop without an owning instruction uses
|
|
402
|
+
`apply_patch stopped before this instruction was executed.` Patch-level
|
|
403
|
+
cancellation says `apply_patch was cancelled before execution.` or identifies
|
|
404
|
+
the last completed instruction.
|
|
405
|
+
|
|
406
|
+
## Patch-level failures
|
|
407
|
+
|
|
408
|
+
Use a patch-level statement only when no instruction owns the error.
|
|
409
|
+
|
|
410
|
+
```text
|
|
411
|
+
Patch format error at line 1: the patch must begin with "*** Begin Patch".
|
|
412
|
+
|
|
413
|
+
Patch instruction results:
|
|
414
|
+
1. [NOT RUN] Update a.txt - Patch format error.
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
```text
|
|
418
|
+
apply_patch setup failed: filesystem access failed for path.
|
|
419
|
+
|
|
420
|
+
Patch instruction results:
|
|
421
|
+
1. [NOT RUN] Update a.txt - apply_patch setup failed before this instruction was executed.
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Rejected tool input uses `apply_patch request rejected: <cause>` once at patch
|
|
425
|
+
level and `The apply_patch request was rejected before this instruction was
|
|
426
|
+
executed.` on each affected instruction.
|
|
427
|
+
|
|
428
|
+
If cancellation or an integration callback stops the patch after an
|
|
429
|
+
instruction completed and before another instruction became active:
|
|
430
|
+
|
|
431
|
+
```text
|
|
432
|
+
apply_patch stopped after instruction 3.
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Completed instruction effects remain listed normally.
|
|
436
|
+
|
|
437
|
+
## TUI
|
|
438
|
+
|
|
439
|
+
The TUI retains its aggregate visual summary. It follows that summary with
|
|
440
|
+
`Patch instruction results:` and every instruction row under the same
|
|
441
|
+
conditional rule as model feedback.
|
|
442
|
+
|
|
443
|
+
Collapsed rendering keeps each row concise:
|
|
444
|
+
|
|
445
|
+
```text
|
|
446
|
+
• Edited 2 files (+3 -1)
|
|
447
|
+
|
|
448
|
+
Patch instruction results:
|
|
449
|
+
1. [APPLIED] Update a.txt
|
|
450
|
+
2. [NO CHANGE] Delete missing.txt — Path already absent.
|
|
451
|
+
3. [FAILED] Update & Move source.txt → destination.txt — Created destination.txt; source.txt remains; The updated content was written to the destination, but removing the source failed; The file at destination.txt contains the requested content byte-for-byte despite the reported error.
|
|
452
|
+
4. [NOT RUN] Update other.txt — Instruction 3 failed.
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
Expanded rendering nests these details beneath the relevant instruction:
|
|
456
|
+
|
|
457
|
+
- applied textual diffs;
|
|
458
|
+
- non-obvious filesystem effects;
|
|
459
|
+
- final-state verification;
|
|
460
|
+
- concise matcher locations; and
|
|
461
|
+
- useful system-error details.
|
|
462
|
+
|
|
463
|
+
Partial effects are not rendered as detached successful operations. Failed
|
|
464
|
+
matching feedback does not repeat old or replacement patch blocks.
|
|
465
|
+
|
|
466
|
+
When the default-off `applyPatchDebug` setting is enabled, the title becomes
|
|
467
|
+
`apply_patch (debug)` and a completed collapsed result renders the exact text
|
|
468
|
+
content returned to the model without an extra renderer-only heading. Expanding
|
|
469
|
+
the same result continues to render the normal aggregate visual summary,
|
|
470
|
+
instruction rows, and complete diffs. Partial tool-call previews are unchanged
|
|
471
|
+
because they do not yet have final model-facing feedback.
|
|
472
|
+
|
|
473
|
+
## Canonical data
|
|
474
|
+
|
|
475
|
+
Model and TUI formatters consume one canonical instruction-result structure:
|
|
476
|
+
|
|
477
|
+
```ts
|
|
478
|
+
type InstructionResult = {
|
|
479
|
+
index: number;
|
|
480
|
+
operation: OperationLabel;
|
|
481
|
+
status: "applied" | "planned" | "no-change" | "skipped" | "failed" | "not-run";
|
|
482
|
+
reason?: InstructionReason;
|
|
483
|
+
effects: InstructionEffect[];
|
|
484
|
+
finalStates: FinalPathState[];
|
|
485
|
+
error?: InstructionError;
|
|
486
|
+
matching?: MatchingEvidence;
|
|
487
|
+
relatedInstructions?: number[];
|
|
488
|
+
};
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Replacement effects are complete:
|
|
492
|
+
|
|
493
|
+
```ts
|
|
494
|
+
type FileEntry = { entryType: "regular-file" } | { entryType: "symlink"; target: string };
|
|
495
|
+
|
|
496
|
+
type ReplacementEffect = {
|
|
497
|
+
kind: "replaced";
|
|
498
|
+
path: string;
|
|
499
|
+
previousEntry: FileEntry;
|
|
500
|
+
replacementEntry: FileEntry;
|
|
501
|
+
};
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
Only presentation differs:
|
|
505
|
+
|
|
506
|
+
- styled status labels;
|
|
507
|
+
- path presentation;
|
|
508
|
+
- ASCII versus Unicode move arrows and separators;
|
|
509
|
+
- expanded TUI diffs;
|
|
510
|
+
- syntax highlighting; and
|
|
511
|
+
- expanded system-error details.
|
|
512
|
+
|
|
513
|
+
Semantic wording and facts remain shared.
|
|
514
|
+
|
|
515
|
+
## Matcher candidate deduplication
|
|
516
|
+
|
|
517
|
+
Before applying candidate and mapping limits:
|
|
518
|
+
|
|
519
|
+
1. canonicalize candidates by complete byte-edit effect;
|
|
520
|
+
2. remove byte-identical duplicate candidates;
|
|
521
|
+
3. retain every semantically distinct candidate; and
|
|
522
|
+
4. do not rank candidates or use heuristic preference.
|
|
523
|
+
|
|
524
|
+
This prevents duplicate line-level and structural candidates from consuming
|
|
525
|
+
the exhaustive mapping bound.
|
|
526
|
+
|
|
527
|
+
## Required tests
|
|
528
|
+
|
|
529
|
+
### Completeness
|
|
530
|
+
|
|
531
|
+
- model and TUI results with 1, 8, 9, 100, and 500 instructions;
|
|
532
|
+
- every instruction appears whenever the ledger is included;
|
|
533
|
+
- all-applied instructions without feedback omit the ledger;
|
|
534
|
+
- one applied instruction with feedback includes every instruction;
|
|
535
|
+
- no omitted-count message exists.
|
|
536
|
+
|
|
537
|
+
### Summary and attribution
|
|
538
|
+
|
|
539
|
+
- successful A/M/D summary remains;
|
|
540
|
+
- all-no-change summary remains;
|
|
541
|
+
- failed summary lists confirmed changed paths;
|
|
542
|
+
- effects from failed instructions appear under that instruction;
|
|
543
|
+
- an unverified final state does not produce `No files were changed.`.
|
|
544
|
+
|
|
545
|
+
### Terminology
|
|
546
|
+
|
|
547
|
+
Generated model and TUI feedback does not contain:
|
|
548
|
+
|
|
549
|
+
- `Committed prefix`
|
|
550
|
+
- `exact`
|
|
551
|
+
- `inexact`
|
|
552
|
+
- `installed`
|
|
553
|
+
- `dead`
|
|
554
|
+
- `dominated`
|
|
555
|
+
- `Matcher diagnostics`
|
|
556
|
+
- the heading `Instructions:`
|
|
557
|
+
|
|
558
|
+
When the conditional ledger is present, its heading is
|
|
559
|
+
`Patch instruction results:`.
|
|
560
|
+
|
|
561
|
+
### Deterministic failures
|
|
562
|
+
|
|
563
|
+
Cover:
|
|
564
|
+
|
|
565
|
+
- patch-level input and format errors appear once;
|
|
566
|
+
- cancelled execution, no-owner stops, setup failures, rejected requests, and
|
|
567
|
+
patch-format failures use distinct reasons;
|
|
568
|
+
- every replacement records both entry types and every resulting symlink
|
|
569
|
+
records its raw target;
|
|
570
|
+
- unchanged after failure;
|
|
571
|
+
- requested content present after a reported write failure;
|
|
572
|
+
- different content after failure;
|
|
573
|
+
- same-content entry replacement after failure;
|
|
574
|
+
- entry-type change after failure;
|
|
575
|
+
- unchanged planned content from an earlier instruction;
|
|
576
|
+
- final state not verified;
|
|
577
|
+
- a confirmed partial move remains in the changed-file summary when later
|
|
578
|
+
inspection cannot verify the destination;
|
|
579
|
+
- destination created while source remains;
|
|
580
|
+
- destination replaced while source remains;
|
|
581
|
+
- destination deleted and replacement absent;
|
|
582
|
+
- parents created without a false no-change statement;
|
|
583
|
+
- temporary entry remains without a false no-change statement; and
|
|
584
|
+
- post-operation verification failure.
|
|
585
|
+
|
|
586
|
+
Every formatter-matcher failure reason is covered with its direct retry
|
|
587
|
+
guidance.
|
|
588
|
+
|
|
589
|
+
### No patch-content repetition
|
|
590
|
+
|
|
591
|
+
Model feedback does not reproduce old or replacement hunk blocks.
|
|
592
|
+
|
|
593
|
+
### Model/TUI parity
|
|
594
|
+
|
|
595
|
+
Every fixture has the same statuses, concise reasons, filesystem effects,
|
|
596
|
+
final path states, and instruction attribution in model and TUI output.
|
|
597
|
+
|
|
598
|
+
With `applyPatchDebug` enabled:
|
|
599
|
+
|
|
600
|
+
- a completed collapsed result contains the complete model-facing text;
|
|
601
|
+
- a completed expanded result contains the normal visual summary and diffs;
|
|
602
|
+
- changing the setting updates existing result components; and
|
|
603
|
+
- partial previews remain unchanged.
|
|
604
|
+
|
|
605
|
+
### Matcher deduplication
|
|
606
|
+
|
|
607
|
+
A multi-group formatter-recovery fixture proves duplicate candidates do not
|
|
608
|
+
consume the mapping limit.
|
|
609
|
+
|
|
610
|
+
## Documentation
|
|
611
|
+
|
|
612
|
+
Implementation changes must also update:
|
|
613
|
+
|
|
614
|
+
- `APPLY_PATCH_SEMANTIC_OPERATIONS.md`
|
|
615
|
+
- `APPLY_PATCH_REMAINING_WORK.md`
|
|
616
|
+
- `README.md`
|
|
617
|
+
- `CHANGELOG.md`
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.0.7 - 2026-08-16
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Add a default-off `applyPatchDebug` setting, environment override, and `/codex-settings` control that labels calls `apply_patch (debug)` and shows exact model-facing feedback without a redundant renderer-only heading in collapsed completed results while preserving normal diffs when expanded.
|
|
10
|
+
- Persist content-free provider response decisions for nontrivial continuations and record the compaction reason and retry intent in native checkpoint details.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Omit Pi's auto-compaction state from the compatibility footer until extensions can observe its live value.
|
|
15
|
+
- Evaluate grammar-valid `apply_patch` operations against a sequential virtual filesystem, accepting harmless no-ops and provably dead updates while rejecting conflicts before writes.
|
|
16
|
+
- Recover uniquely determined `apply_patch` edits after whitespace-only formatter line reflow using the official `web-tree-sitter` runtime and packaged `@2h2d/tree-sitter-wasms` grammars for JavaScript, JSX, TypeScript, TSX, Python, Go, Java, and Scala, including typed Markdown code fences and formatter-aligned tables; require exact old-side punctuation and apply requested replacement lines without reinterpretation.
|
|
17
|
+
- Move regular files and symlink entries opaquely for move-only `apply_patch` hunks, preserving arbitrary binary bytes and rendering path-only move history.
|
|
18
|
+
- Preserve the aggregate `apply_patch` changed-file summary and, when any instruction is not applied or an applied instruction has feedback, list every concise source-ordered result under `Patch instruction results:` as `N. [STATUS] operation` in model and TUI feedback while omitting the redundant ledger for ordinary all-applied patches.
|
|
19
|
+
- Label combined operations `Update & Move`, require verified previous and resulting entry types for replacement feedback, describe regular-file-over-regular-file replacements as remaining regular files, report raw symlink targets in straightforward move results, distinguish byte-identical update outcomes from identical adds, and use explicit metadata, partial-move, and post-failure content wording.
|
|
20
|
+
- Add direct retry guidance to every formatter-matcher failure, including clearer wording when more than 256 possible applications are found.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- Return complete function and custom tool calls to Pi before provider-owned continuation, recover incomplete call batches without execution, and retry failed call-bearing responses without replaying calls that have no tool output.
|
|
25
|
+
- Preserve each matched source region's local line endings when strict `apply_patch` matching edits CRLF or mixed-line-ending files.
|
|
26
|
+
- Model native renames and cross-filesystem copy-and-unlink moves with distinct hard-link topology, and account for earlier planned unlinks when proving later edits dead.
|
|
27
|
+
- Record symlink deletion as a path-only entry operation so history and rendering never claim that the link target's bytes were deleted.
|
|
28
|
+
- Serialize same-process `apply_patch` calls across case, Unicode, symlink-parent, and hard-link aliases while retaining Pi's ordinary path queues.
|
|
29
|
+
- Render semantic no-change and skipped results in simplified technical English, without instruction limits, detached proof sections, or repeated patch text.
|
|
30
|
+
- Attribute completed filesystem effects, deterministic post-failure path states, matcher evidence, and errors to the instruction that produced them.
|
|
31
|
+
- Preserve confirmed partial-move effects in changed-file summaries when later inspection is unavailable, without rendering the partial operation as a completed rename.
|
|
32
|
+
- Report parent-directory and temporary-entry failure effects without a false no-change summary.
|
|
33
|
+
- Report patch-level errors once and distinguish cancelled or stopped execution, `apply_patch` setup failures, rejected requests, and patch-format failures.
|
|
34
|
+
- Keep unreadable previous content and diff availability out of model feedback.
|
|
35
|
+
- Execute the move strategy proven during validation, with an injectable filesystem boundary covering native rename, cross-filesystem replacement, Windows overwrite fallback, and partial-failure inspection.
|
|
36
|
+
- Retry Tree-sitter parser and grammar initialization after transient failures, and cover cancellation across queue, matching, pre-mutation, and committed-prefix phases.
|
|
37
|
+
- Reject FIFOs, Unix sockets, directories, and available character or block devices during side-effect-free preflight.
|
|
38
|
+
- Avoid dereferencing symlink targets while queuing entry-only operations and no-op updates, including cyclic links.
|
|
39
|
+
- Replay later add/delete entry state when proving stale hard-link updates dead.
|
|
40
|
+
- Preserve cancellation raised during Tree-sitter work and classify pure-move filesystems from the source entry rather than its parent.
|
|
41
|
+
- Re-resolve relative symlink targets from their destination after native or cross-filesystem pure moves.
|
|
42
|
+
- Deduplicate byte-identical line and structural matcher candidates before applying candidate and mapping limits.
|
|
43
|
+
|
|
44
|
+
### Security
|
|
45
|
+
|
|
46
|
+
- Require npm releases to match a locally built SHA-256 recorded in an SSH-signed release commit before trusted publishing can stage the package.
|
|
47
|
+
- Require code-owner review for release policy, protect `main` and `v*` refs, and gate npm OIDC behind a reviewed tag-only environment.
|
|
48
|
+
|
|
5
49
|
## 0.0.6 - 2026-08-10
|
|
6
50
|
|
|
7
51
|
### Added
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kaan Ozdokmeci
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|