@howaboua/pi-durable-apply-patch 0.9.1 → 0.11.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 +2 -2
- package/dist/activation.d.ts +3 -0
- package/dist/activation.js +803 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +25 -5
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Apply Codex-format multi-file patches through the conversation's execution environment. The tool supports additions, updates, deletions, moves, ordered hunks, Unicode-tolerant matching, and mixed line endings. No Rust helper runs at runtime.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.
|
|
6
|
+
npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.11.0/howaboua-pi-durable-apply-patch-0.11.0.tgz
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
Install the bundle in your Durable registry:
|
|
@@ -32,7 +32,7 @@ Calls from this component serialize overlapping resolved and canonical paths wit
|
|
|
32
32
|
|
|
33
33
|
The registration is `replay: "unsafe"`. Reopening Durable does not replay an interrupted patch. Read the affected target before deciding what to retry.
|
|
34
34
|
|
|
35
|
-
Requires Durable, pi-ai, and Chord 1.
|
|
35
|
+
Requires Durable, pi-ai, and Chord 1.5.0. Derived engine code is Apache-2.0; adapter code is MIT. See [NOTICE](./NOTICE).
|
|
36
36
|
|
|
37
37
|
## Headless presentations
|
|
38
38
|
|
|
@@ -0,0 +1,803 @@
|
|
|
1
|
+
// packages/apply-patch/src/index.ts
|
|
2
|
+
import { defineExtension, defineTool } from "@earendil-works/pi-durable";
|
|
3
|
+
import { Type } from "typebox";
|
|
4
|
+
|
|
5
|
+
// packages/apply-patch/src/executor.ts
|
|
6
|
+
import { getOrThrow as getOrThrow3 } from "@earendil-works/pi-durable/env";
|
|
7
|
+
|
|
8
|
+
// packages/apply-patch/src/file-mutations.ts
|
|
9
|
+
import {
|
|
10
|
+
err,
|
|
11
|
+
FileError,
|
|
12
|
+
getOrThrow,
|
|
13
|
+
ok
|
|
14
|
+
} from "@earendil-works/pi-durable/env";
|
|
15
|
+
function checkAbort(context) {
|
|
16
|
+
if (context.abortSignal?.aborted)
|
|
17
|
+
throw new Error("apply_patch aborted. An interrupted mutation may have taken effect; read its target before retrying");
|
|
18
|
+
}
|
|
19
|
+
async function readText(env, path, context) {
|
|
20
|
+
const bytes = await env.readBinaryFile(path, context);
|
|
21
|
+
if (!bytes.ok)
|
|
22
|
+
return bytes;
|
|
23
|
+
try {
|
|
24
|
+
return ok(new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes.value));
|
|
25
|
+
} catch {
|
|
26
|
+
return err(new FileError("invalid", "stream did not contain valid UTF-8", path));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class PatchFileMutations {
|
|
31
|
+
accuracy = true;
|
|
32
|
+
env;
|
|
33
|
+
context;
|
|
34
|
+
constructor(env, context) {
|
|
35
|
+
this.env = env;
|
|
36
|
+
this.context = context;
|
|
37
|
+
}
|
|
38
|
+
get exact() {
|
|
39
|
+
return this.accuracy;
|
|
40
|
+
}
|
|
41
|
+
markUncertain() {
|
|
42
|
+
this.accuracy = false;
|
|
43
|
+
}
|
|
44
|
+
read(path) {
|
|
45
|
+
return readText(this.env, path, this.context);
|
|
46
|
+
}
|
|
47
|
+
async noteSupport(path) {
|
|
48
|
+
const info = await this.env.fileInfo(path, this.context);
|
|
49
|
+
if (info.ok && info.value.kind === "symlink") {
|
|
50
|
+
const target = await this.env.canonicalPath(path, this.context);
|
|
51
|
+
if (!target.ok && target.error.code === "not_found")
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (info.ok ? info.value.kind !== "file" : info.error.code !== "not_found")
|
|
55
|
+
this.markUncertain();
|
|
56
|
+
}
|
|
57
|
+
async optionalRead(path) {
|
|
58
|
+
await this.noteSupport(path);
|
|
59
|
+
const read = await this.read(path);
|
|
60
|
+
if (read.ok)
|
|
61
|
+
return read.value;
|
|
62
|
+
if (read.error.code !== "not_found")
|
|
63
|
+
this.markUncertain();
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
async write(path, contents, allowParents) {
|
|
67
|
+
checkAbort(this.context);
|
|
68
|
+
let result = await this.env.writeFile(path, contents, this.context);
|
|
69
|
+
if (!result.ok && result.error.code === "not_found" && allowParents && !this.context.abortSignal?.aborted) {
|
|
70
|
+
const parent = getOrThrow(await this.env.joinPath([path, ".."], this.context));
|
|
71
|
+
const created = await this.env.createDir(parent, { recursive: true }, this.context);
|
|
72
|
+
if (!created.ok) {
|
|
73
|
+
this.markUncertain();
|
|
74
|
+
throw new Error(`Failed to create parent directories for ${path}: ${created.error.message}`);
|
|
75
|
+
}
|
|
76
|
+
checkAbort(this.context);
|
|
77
|
+
result = await this.env.writeFile(path, contents, this.context);
|
|
78
|
+
}
|
|
79
|
+
if (!result.ok) {
|
|
80
|
+
this.markUncertain();
|
|
81
|
+
throw new Error(`Failed to write file ${path}: ${result.error.message}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async remove(path, oldContent, label) {
|
|
85
|
+
checkAbort(this.context);
|
|
86
|
+
let info = await this.env.fileInfo(path, this.context);
|
|
87
|
+
if (info.ok && info.value.kind === "symlink") {
|
|
88
|
+
const canonical = await this.env.canonicalPath(path, this.context);
|
|
89
|
+
if (!canonical.ok)
|
|
90
|
+
throw new Error(`${label} ${path}: ${canonical.error.message}`);
|
|
91
|
+
info = await this.env.fileInfo(canonical.value, this.context);
|
|
92
|
+
}
|
|
93
|
+
if (!info.ok)
|
|
94
|
+
throw new Error(`${label} ${path}: ${info.error.message}`);
|
|
95
|
+
if (info.value.kind === "directory")
|
|
96
|
+
throw new Error(`${label} ${path}: path is a directory`);
|
|
97
|
+
checkAbort(this.context);
|
|
98
|
+
const removed = await this.env.remove(path, { recursive: false, force: false }, this.context);
|
|
99
|
+
if (!removed.ok) {
|
|
100
|
+
const after = await this.read(path);
|
|
101
|
+
if (!(oldContent !== null && after.ok && after.value === oldContent))
|
|
102
|
+
this.markUncertain();
|
|
103
|
+
throw new Error(`${label} ${path}: ${removed.error.message}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// packages/apply-patch/src/mutation-queue.ts
|
|
109
|
+
import { awaitWithContext } from "@earendil-works/chord/context";
|
|
110
|
+
import { getOrThrow as getOrThrow2 } from "@earendil-works/pi-durable/env";
|
|
111
|
+
var tails = new Map;
|
|
112
|
+
function pathIdentity(path) {
|
|
113
|
+
return /^[A-Za-z]:[\\/]|^\\\\/.test(path) ? path.replace(/[A-Z]/g, (ch) => ch.toLowerCase()) : path;
|
|
114
|
+
}
|
|
115
|
+
async function canonical(env, path, context) {
|
|
116
|
+
const result = await env.canonicalPath(path, context);
|
|
117
|
+
if (result.ok)
|
|
118
|
+
return result.value;
|
|
119
|
+
if (result.error.code !== "not_found")
|
|
120
|
+
throw result.error;
|
|
121
|
+
const parent = getOrThrow2(await env.joinPath([path, ".."], context));
|
|
122
|
+
if (parent === path || !path.startsWith(parent))
|
|
123
|
+
return path;
|
|
124
|
+
const name = path.slice(parent.length + (/[/\\]$/.test(parent) ? 0 : 1));
|
|
125
|
+
return getOrThrow2(await env.joinPath([await canonical(env, parent, context), name], context));
|
|
126
|
+
}
|
|
127
|
+
async function withMutationKeys(env, paths, context, run, warnings = []) {
|
|
128
|
+
const keys = new Set;
|
|
129
|
+
for (const path of paths) {
|
|
130
|
+
keys.add(`${env.id}\x00${pathIdentity(path)}`);
|
|
131
|
+
try {
|
|
132
|
+
keys.add(`${env.id}\x00${pathIdentity(await canonical(env, path, context))}`);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
if (context.abortSignal?.aborted || error instanceof Error && "code" in error && error.code === "aborted")
|
|
135
|
+
throw error;
|
|
136
|
+
warnings.push(`Canonical-path locking unavailable for ${path}: ${error instanceof Error ? error.message : String(error)}. Serialized by resolved path only`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const previous = Promise.all([...keys].map((key) => tails.get(key) ?? Promise.resolve())).then(() => {});
|
|
140
|
+
let release = () => {};
|
|
141
|
+
const done = new Promise((resolve) => {
|
|
142
|
+
release = resolve;
|
|
143
|
+
});
|
|
144
|
+
const tail = previous.then(() => done);
|
|
145
|
+
for (const key of keys)
|
|
146
|
+
tails.set(key, tail);
|
|
147
|
+
try {
|
|
148
|
+
await awaitWithContext(previous, context);
|
|
149
|
+
if (context.abortSignal?.aborted)
|
|
150
|
+
throw new Error("apply_patch aborted");
|
|
151
|
+
return await run();
|
|
152
|
+
} finally {
|
|
153
|
+
release();
|
|
154
|
+
tail.then(() => {
|
|
155
|
+
for (const key of keys)
|
|
156
|
+
if (tails.get(key) === tail)
|
|
157
|
+
tails.delete(key);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// packages/apply-patch/src/parser.ts
|
|
163
|
+
var headers = [
|
|
164
|
+
["*** Add File: ", "add"],
|
|
165
|
+
["*** Delete File: ", "delete"],
|
|
166
|
+
["*** Update File: ", "update"]
|
|
167
|
+
];
|
|
168
|
+
function trimRust(text, endOnly = false) {
|
|
169
|
+
return text.replace(endOnly ? /\p{White_Space}+$/u : /^\p{White_Space}+|\p{White_Space}+$/gu, "");
|
|
170
|
+
}
|
|
171
|
+
function invalidPatch(message) {
|
|
172
|
+
throw new Error(`invalid patch: ${message}`);
|
|
173
|
+
}
|
|
174
|
+
function invalidHunk(line, message) {
|
|
175
|
+
throw new Error(`invalid hunk at line ${line}, ${message}`);
|
|
176
|
+
}
|
|
177
|
+
function unexpected(line, text) {
|
|
178
|
+
return invalidHunk(line, `Unexpected line found in update hunk: '${text}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)`);
|
|
179
|
+
}
|
|
180
|
+
function emptyChunk(chunk) {
|
|
181
|
+
return chunk !== undefined && chunk.oldLines.length === 0 && chunk.newLines.length === 0;
|
|
182
|
+
}
|
|
183
|
+
function ensureUpdate(action, line, text) {
|
|
184
|
+
if (action?.type !== "update")
|
|
185
|
+
return;
|
|
186
|
+
if (action.chunks.length === 0)
|
|
187
|
+
invalidHunk(action.line, `Update file hunk for path '${action.path}' is empty`);
|
|
188
|
+
if (emptyChunk(action.chunks.at(-1))) {
|
|
189
|
+
if (text === "*** End Patch")
|
|
190
|
+
invalidHunk(line, "Update hunk does not contain any lines");
|
|
191
|
+
unexpected(line, text);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function boundaries(lines) {
|
|
195
|
+
if (trimRust(lines[0] ?? "") !== "*** Begin Patch") {
|
|
196
|
+
return lines.length === 0 ? "The last line of the patch must be '*** End Patch'" : "The first line of the patch must be '*** Begin Patch'";
|
|
197
|
+
}
|
|
198
|
+
if (trimRust(lines.at(-1) ?? "") !== "*** End Patch")
|
|
199
|
+
return "The last line of the patch must be '*** End Patch'";
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
function parsePatch(input) {
|
|
203
|
+
const text = trimRust(input);
|
|
204
|
+
let lines = text === "" ? [] : text.split(`
|
|
205
|
+
`).map((line) => line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
206
|
+
let boundaryError = boundaries(lines);
|
|
207
|
+
if (boundaryError !== undefined) {
|
|
208
|
+
if (lines.length >= 4 && ["<<EOF", "<<'EOF'", '<<"EOF"'].includes(lines[0] ?? "") && lines.at(-1)?.endsWith("EOF")) {
|
|
209
|
+
lines = lines.slice(1, -1);
|
|
210
|
+
boundaryError = boundaries(lines);
|
|
211
|
+
}
|
|
212
|
+
if (boundaryError !== undefined)
|
|
213
|
+
invalidPatch(boundaryError);
|
|
214
|
+
}
|
|
215
|
+
const actions = [];
|
|
216
|
+
let environmentId;
|
|
217
|
+
let ended = false;
|
|
218
|
+
for (let index = 1;index < lines.length; index++) {
|
|
219
|
+
let original = lines[index];
|
|
220
|
+
if (index < lines.length - 1 && original.endsWith("\r"))
|
|
221
|
+
original = original.slice(0, -1);
|
|
222
|
+
const line = index + 1;
|
|
223
|
+
const action = actions.at(-1);
|
|
224
|
+
const trimmed = trimRust(original);
|
|
225
|
+
const marker = action?.type === "update" ? trimRust(original, true) : trimmed;
|
|
226
|
+
if (index === lines.length - 1 && trimmed === "*** End Patch") {
|
|
227
|
+
ensureUpdate(action, line, "*** End Patch");
|
|
228
|
+
ended = true;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (ended) {
|
|
232
|
+
if (trimmed !== "")
|
|
233
|
+
invalidPatch("The last line of the patch must be '*** End Patch'");
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (marker === "*** End Patch") {
|
|
237
|
+
ensureUpdate(action, line, "*** End Patch");
|
|
238
|
+
ended = true;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (action === undefined && marker.startsWith("*** Environment ID:")) {
|
|
242
|
+
if (environmentId !== undefined)
|
|
243
|
+
invalidPatch("apply_patch environment_id cannot be specified more than once");
|
|
244
|
+
environmentId = trimRust(marker.slice("*** Environment ID:".length));
|
|
245
|
+
if (!environmentId)
|
|
246
|
+
invalidPatch("apply_patch environment_id cannot be empty");
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
let headerFound = false;
|
|
250
|
+
for (const [prefix, type] of headers) {
|
|
251
|
+
if (!marker.startsWith(prefix))
|
|
252
|
+
continue;
|
|
253
|
+
ensureUpdate(action, line, marker);
|
|
254
|
+
const path = marker.slice(prefix.length);
|
|
255
|
+
if (type === "add")
|
|
256
|
+
actions.push({ type, path, contents: "" });
|
|
257
|
+
else if (type === "delete")
|
|
258
|
+
actions.push({ type, path });
|
|
259
|
+
else
|
|
260
|
+
actions.push({ type, path, movePath: undefined, chunks: [], line });
|
|
261
|
+
headerFound = true;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
if (headerFound)
|
|
265
|
+
continue;
|
|
266
|
+
if (action?.type === "add" && original.startsWith("+")) {
|
|
267
|
+
action.contents += original.slice(1) + `
|
|
268
|
+
`;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (action?.type !== "update") {
|
|
272
|
+
invalidHunk(line, `'${trimmed}' is not a valid hunk header. Valid hunk headers: '*** Add File: {path}', '*** Delete File: {path}', '*** Update File: {path}'`);
|
|
273
|
+
}
|
|
274
|
+
let chunk = action.chunks.at(-1);
|
|
275
|
+
const isContextMarker = marker === "@@" || marker.startsWith("@@ ");
|
|
276
|
+
if (chunk?.eof) {
|
|
277
|
+
if (marker === "")
|
|
278
|
+
continue;
|
|
279
|
+
if (!isContextMarker)
|
|
280
|
+
invalidHunk(line, `Expected update hunk to start with a @@ context marker, got: '${original}'`);
|
|
281
|
+
}
|
|
282
|
+
if (action.chunks.length === 0 && action.movePath === undefined && marker.startsWith("*** Move to: ")) {
|
|
283
|
+
action.movePath = marker.slice("*** Move to: ".length);
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
if (isContextMarker) {
|
|
287
|
+
if (emptyChunk(chunk))
|
|
288
|
+
unexpected(line, original);
|
|
289
|
+
action.chunks.push({
|
|
290
|
+
context: marker.startsWith("@@ ") ? marker.slice(3) : undefined,
|
|
291
|
+
oldLines: [],
|
|
292
|
+
newLines: [],
|
|
293
|
+
contextLines: [],
|
|
294
|
+
eof: false
|
|
295
|
+
});
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (marker === "*** End of File") {
|
|
299
|
+
if (emptyChunk(chunk))
|
|
300
|
+
invalidHunk(line, "Update hunk does not contain any lines");
|
|
301
|
+
if (chunk !== undefined)
|
|
302
|
+
chunk.eof = true;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (original === "" || /^[ +\-]/.test(original)) {
|
|
306
|
+
if (chunk === undefined) {
|
|
307
|
+
chunk = {
|
|
308
|
+
context: undefined,
|
|
309
|
+
oldLines: [],
|
|
310
|
+
newLines: [],
|
|
311
|
+
contextLines: [],
|
|
312
|
+
eof: false
|
|
313
|
+
};
|
|
314
|
+
action.chunks.push(chunk);
|
|
315
|
+
}
|
|
316
|
+
const value = original.slice(1);
|
|
317
|
+
if (original === "" || original.startsWith(" ")) {
|
|
318
|
+
chunk.contextLines.push({
|
|
319
|
+
old: chunk.oldLines.length,
|
|
320
|
+
new: chunk.newLines.length
|
|
321
|
+
});
|
|
322
|
+
chunk.oldLines.push(value);
|
|
323
|
+
chunk.newLines.push(value);
|
|
324
|
+
} else if (original.startsWith("+"))
|
|
325
|
+
chunk.newLines.push(value);
|
|
326
|
+
else
|
|
327
|
+
chunk.oldLines.push(value);
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (chunk !== undefined && !emptyChunk(chunk))
|
|
331
|
+
invalidHunk(line, `Expected update hunk to start with a @@ context marker, got: '${original}'`);
|
|
332
|
+
unexpected(line, original);
|
|
333
|
+
}
|
|
334
|
+
if (!ended)
|
|
335
|
+
invalidPatch("The last line of the patch must be '*** End Patch'");
|
|
336
|
+
return { actions, environmentId };
|
|
337
|
+
}
|
|
338
|
+
function sourcePathsForDuplicateGuard(input) {
|
|
339
|
+
const text = trimRust(input);
|
|
340
|
+
if (!text)
|
|
341
|
+
return;
|
|
342
|
+
let lines = text.split(`
|
|
343
|
+
`).map((line) => line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
344
|
+
if (boundaries(lines) !== undefined) {
|
|
345
|
+
if (lines.length < 4 || !["<<EOF", "<<'EOF'", '<<"EOF"'].includes(lines[0] ?? "") || !lines.at(-1)?.endsWith("EOF"))
|
|
346
|
+
return;
|
|
347
|
+
lines = lines.slice(1, -1);
|
|
348
|
+
if (boundaries(lines) !== undefined)
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const paths = [];
|
|
352
|
+
let section = "started";
|
|
353
|
+
let sawEnvironment = false;
|
|
354
|
+
for (let index = 1;index < lines.length - 1; index++) {
|
|
355
|
+
const original = lines[index];
|
|
356
|
+
const line = trimRust(original, section === "update");
|
|
357
|
+
if (line === "*** End Patch")
|
|
358
|
+
return;
|
|
359
|
+
const header = headers.find(([prefix]) => line.startsWith(prefix));
|
|
360
|
+
if (header !== undefined) {
|
|
361
|
+
const path = line.slice(header[0].length);
|
|
362
|
+
if (!path)
|
|
363
|
+
return;
|
|
364
|
+
paths.push(path);
|
|
365
|
+
section = header[1];
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if (section === "started") {
|
|
369
|
+
if (!line.startsWith("*** Environment ID:") || sawEnvironment || !trimRust(line.slice("*** Environment ID:".length)))
|
|
370
|
+
return;
|
|
371
|
+
sawEnvironment = true;
|
|
372
|
+
} else if (section === "add") {
|
|
373
|
+
if (!original.startsWith("+"))
|
|
374
|
+
return;
|
|
375
|
+
} else if (section === "delete")
|
|
376
|
+
return;
|
|
377
|
+
else if (!(original === "" || /^[ +\-]/.test(original) || line === "@@" || line.startsWith("@@ ") || line === "*** End of File" || line.startsWith("*** Move to: ")))
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
return paths;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// packages/apply-patch/src/patch-outcome.ts
|
|
384
|
+
class ExecutePatchError extends Error {
|
|
385
|
+
outcome;
|
|
386
|
+
action;
|
|
387
|
+
constructor(message, outcome, action) {
|
|
388
|
+
super(message);
|
|
389
|
+
this.name = "ExecutePatchError";
|
|
390
|
+
this.outcome = outcome;
|
|
391
|
+
this.action = action;
|
|
392
|
+
}
|
|
393
|
+
get result() {
|
|
394
|
+
return this.outcome.result;
|
|
395
|
+
}
|
|
396
|
+
hasPartialSuccess() {
|
|
397
|
+
return this.result.changedFiles.length > 0 || this.result.fuzz > 0;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function unique(values, value) {
|
|
401
|
+
if (!values.includes(value))
|
|
402
|
+
values.push(value);
|
|
403
|
+
}
|
|
404
|
+
function displayPath(env, path) {
|
|
405
|
+
const separator = /^[A-Za-z]:[\\/]|^\\\\/.test(env.cwd) ? "\\" : "/";
|
|
406
|
+
const prefix = env.cwd.replace(/[/\\]$/, "") + separator;
|
|
407
|
+
return pathIdentity(path).startsWith(pathIdentity(prefix)) ? path.slice(prefix.length) : path;
|
|
408
|
+
}
|
|
409
|
+
function summarize(env, changes, exact) {
|
|
410
|
+
const result = {
|
|
411
|
+
changedFiles: [],
|
|
412
|
+
createdFiles: [],
|
|
413
|
+
deletedFiles: [],
|
|
414
|
+
movedFiles: [],
|
|
415
|
+
fuzz: exact ? 0 : 1
|
|
416
|
+
};
|
|
417
|
+
const displayed = changes.map((change) => ({
|
|
418
|
+
...change,
|
|
419
|
+
path: displayPath(env, change.path),
|
|
420
|
+
...change.kind === "update" && change.movePath !== null ? { movePath: displayPath(env, change.movePath) } : {}
|
|
421
|
+
}));
|
|
422
|
+
for (const change of displayed) {
|
|
423
|
+
unique(result.changedFiles, change.path);
|
|
424
|
+
if (change.kind === "add" && change.overwrittenContent === null)
|
|
425
|
+
unique(result.createdFiles, change.path);
|
|
426
|
+
if (change.kind === "delete")
|
|
427
|
+
unique(result.deletedFiles, change.path);
|
|
428
|
+
if (change.kind === "update" && change.movePath !== null) {
|
|
429
|
+
unique(result.changedFiles, change.movePath);
|
|
430
|
+
unique(result.deletedFiles, change.path);
|
|
431
|
+
if (change.overwrittenMoveContent === null)
|
|
432
|
+
unique(result.createdFiles, change.movePath);
|
|
433
|
+
unique(result.movedFiles, `${change.path} -> ${change.movePath}`);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return { result, changes: displayed, exact };
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// packages/apply-patch/src/update.ts
|
|
440
|
+
function normalize(text) {
|
|
441
|
+
return trimRust(text).replace(/[\u2010-\u2015\u2212]/g, "-").replace(/[\u2018-\u201b]/g, "'").replace(/[\u201c-\u201f]/g, '"').replace(/[\u00a0\u2002-\u200a\u202f\u205f\u3000]/g, " ");
|
|
442
|
+
}
|
|
443
|
+
function seekSequence(lines, pattern, start, eof) {
|
|
444
|
+
if (pattern.length === 0)
|
|
445
|
+
return start;
|
|
446
|
+
if (pattern.length > lines.length)
|
|
447
|
+
return;
|
|
448
|
+
const limit = lines.length - pattern.length;
|
|
449
|
+
const searchStart = eof ? Math.max(limit, start) : start;
|
|
450
|
+
const tiers = [
|
|
451
|
+
(text) => text,
|
|
452
|
+
(text) => trimRust(text, true),
|
|
453
|
+
trimRust,
|
|
454
|
+
normalize
|
|
455
|
+
];
|
|
456
|
+
for (const transform of tiers) {
|
|
457
|
+
for (let index = searchStart;index <= limit; index++) {
|
|
458
|
+
if (pattern.every((text, offset) => transform(lines[index + offset]) === transform(text)))
|
|
459
|
+
return index;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
function computeReplacements(lines, path, chunks) {
|
|
465
|
+
const replacements = [];
|
|
466
|
+
let lineIndex = 0;
|
|
467
|
+
for (const chunk of chunks) {
|
|
468
|
+
if (chunk.context !== undefined) {
|
|
469
|
+
const index = seekSequence(lines, [chunk.context], lineIndex, false);
|
|
470
|
+
if (index === undefined)
|
|
471
|
+
throw new Error(`Failed to find context '${chunk.context}' in ${path}`);
|
|
472
|
+
lineIndex = index + 1;
|
|
473
|
+
}
|
|
474
|
+
if (chunk.oldLines.length === 0) {
|
|
475
|
+
replacements.push({
|
|
476
|
+
start: lines.length,
|
|
477
|
+
oldLength: 0,
|
|
478
|
+
newLines: chunk.newLines
|
|
479
|
+
});
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
let pattern = chunk.oldLines;
|
|
483
|
+
let newLines = chunk.newLines;
|
|
484
|
+
let found = seekSequence(lines, pattern, lineIndex, chunk.eof);
|
|
485
|
+
if (found === undefined && pattern.at(-1) === "") {
|
|
486
|
+
pattern = pattern.slice(0, -1);
|
|
487
|
+
if (newLines.at(-1) === "")
|
|
488
|
+
newLines = newLines.slice(0, -1);
|
|
489
|
+
found = seekSequence(lines, pattern, lineIndex, chunk.eof);
|
|
490
|
+
}
|
|
491
|
+
if (found === undefined)
|
|
492
|
+
throw new Error(`Failed to find expected lines in ${path}:
|
|
493
|
+
${chunk.oldLines.join(`
|
|
494
|
+
`)}`);
|
|
495
|
+
let oldStart = 0;
|
|
496
|
+
let newStart = 0;
|
|
497
|
+
for (const context of chunk.contextLines) {
|
|
498
|
+
if (context.old >= pattern.length || context.new >= newLines.length)
|
|
499
|
+
break;
|
|
500
|
+
if (oldStart !== context.old || newStart !== context.new) {
|
|
501
|
+
replacements.push({
|
|
502
|
+
start: found + oldStart,
|
|
503
|
+
oldLength: context.old - oldStart,
|
|
504
|
+
newLines: newLines.slice(newStart, context.new)
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
oldStart = context.old + 1;
|
|
508
|
+
newStart = context.new + 1;
|
|
509
|
+
}
|
|
510
|
+
if (oldStart !== pattern.length || newStart !== newLines.length) {
|
|
511
|
+
replacements.push({
|
|
512
|
+
start: found + oldStart,
|
|
513
|
+
oldLength: pattern.length - oldStart,
|
|
514
|
+
newLines: newLines.slice(newStart)
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
lineIndex = found + pattern.length;
|
|
518
|
+
}
|
|
519
|
+
return replacements.sort((a, b) => a.start - b.start);
|
|
520
|
+
}
|
|
521
|
+
function updateContents(contents, path, chunks) {
|
|
522
|
+
const lines = [];
|
|
523
|
+
let preferredEnding;
|
|
524
|
+
let cursor = 0;
|
|
525
|
+
for (const match of contents.matchAll(/\r\n|\r|\n/g)) {
|
|
526
|
+
preferredEnding ??= match[0];
|
|
527
|
+
lines.push({ text: contents.slice(cursor, match.index), ending: match[0] });
|
|
528
|
+
cursor = match.index + match[0].length;
|
|
529
|
+
}
|
|
530
|
+
if (cursor < contents.length)
|
|
531
|
+
lines.push({ text: contents.slice(cursor), ending: undefined });
|
|
532
|
+
preferredEnding ??= `
|
|
533
|
+
`;
|
|
534
|
+
const replacements = computeReplacements(lines.map((line) => line.text), path, chunks);
|
|
535
|
+
const output = [];
|
|
536
|
+
let sourceIndex = 0;
|
|
537
|
+
for (const replacement of replacements) {
|
|
538
|
+
const unchanged = Math.max(0, replacement.start - sourceIndex);
|
|
539
|
+
for (const line of lines.slice(sourceIndex, sourceIndex + unchanged))
|
|
540
|
+
output.push(line);
|
|
541
|
+
sourceIndex += unchanged + replacement.oldLength;
|
|
542
|
+
for (const text of replacement.newLines)
|
|
543
|
+
output.push({ text, ending: preferredEnding });
|
|
544
|
+
}
|
|
545
|
+
for (const line of lines.slice(sourceIndex))
|
|
546
|
+
output.push(line);
|
|
547
|
+
return output.map((line) => line.text + (line.ending ?? preferredEnding)).join("");
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// packages/apply-patch/src/executor.ts
|
|
551
|
+
async function resolveActions(env, actions, context) {
|
|
552
|
+
const resolved = [];
|
|
553
|
+
for (const action of actions) {
|
|
554
|
+
const path = getOrThrow3(await env.absolutePath(action.path, context));
|
|
555
|
+
resolved.push({
|
|
556
|
+
action,
|
|
557
|
+
path,
|
|
558
|
+
movePath: action.type === "update" && action.movePath !== undefined ? getOrThrow3(await env.absolutePath(action.movePath, context)) : undefined
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
return resolved;
|
|
562
|
+
}
|
|
563
|
+
async function applyActions(env, actions, context) {
|
|
564
|
+
const changes = [];
|
|
565
|
+
const files = new PatchFileMutations(env, context);
|
|
566
|
+
let current;
|
|
567
|
+
try {
|
|
568
|
+
if (actions.length === 0)
|
|
569
|
+
throw new Error("No files were modified.");
|
|
570
|
+
for (const { action, path, movePath } of actions) {
|
|
571
|
+
current = action;
|
|
572
|
+
checkAbort(context);
|
|
573
|
+
if (action.type === "add") {
|
|
574
|
+
const overwrittenContent = await files.optionalRead(path);
|
|
575
|
+
await files.write(path, action.contents, true);
|
|
576
|
+
changes.push({
|
|
577
|
+
path,
|
|
578
|
+
kind: "add",
|
|
579
|
+
content: action.contents,
|
|
580
|
+
overwrittenContent
|
|
581
|
+
});
|
|
582
|
+
} else if (action.type === "delete") {
|
|
583
|
+
await files.noteSupport(path);
|
|
584
|
+
const read = await files.read(path);
|
|
585
|
+
const content = read.ok ? read.value : null;
|
|
586
|
+
if (content === null)
|
|
587
|
+
files.markUncertain();
|
|
588
|
+
await files.remove(path, content, "Failed to delete file");
|
|
589
|
+
if (content !== null)
|
|
590
|
+
changes.push({ path, kind: "delete", content });
|
|
591
|
+
} else {
|
|
592
|
+
await files.noteSupport(path);
|
|
593
|
+
const read = await files.read(path);
|
|
594
|
+
if (!read.ok)
|
|
595
|
+
throw new Error(`Failed to read file to update ${path}: ${read.error.message}`);
|
|
596
|
+
const newContent = updateContents(read.value, path, action.chunks);
|
|
597
|
+
if (movePath !== undefined) {
|
|
598
|
+
const overwrittenMoveContent = await files.optionalRead(movePath);
|
|
599
|
+
await files.write(movePath, newContent, true);
|
|
600
|
+
const writeIndex = changes.length;
|
|
601
|
+
changes.push({
|
|
602
|
+
path: movePath,
|
|
603
|
+
kind: "add",
|
|
604
|
+
content: newContent,
|
|
605
|
+
overwrittenContent: overwrittenMoveContent
|
|
606
|
+
});
|
|
607
|
+
await files.remove(path, read.value, "Failed to remove original");
|
|
608
|
+
changes[writeIndex] = {
|
|
609
|
+
path,
|
|
610
|
+
kind: "update",
|
|
611
|
+
movePath,
|
|
612
|
+
oldContent: read.value,
|
|
613
|
+
overwrittenMoveContent,
|
|
614
|
+
newContent
|
|
615
|
+
};
|
|
616
|
+
} else {
|
|
617
|
+
await files.write(path, newContent, false);
|
|
618
|
+
changes.push({
|
|
619
|
+
path,
|
|
620
|
+
kind: "update",
|
|
621
|
+
movePath: null,
|
|
622
|
+
oldContent: read.value,
|
|
623
|
+
overwrittenMoveContent: null,
|
|
624
|
+
newContent
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
checkAbort(context);
|
|
629
|
+
}
|
|
630
|
+
return summarize(env, changes, files.exact);
|
|
631
|
+
} catch (error) {
|
|
632
|
+
if (context.abortSignal?.aborted)
|
|
633
|
+
files.markUncertain();
|
|
634
|
+
throw new ExecutePatchError(error instanceof Error ? error.message : String(error), summarize(env, changes, files.exact), current);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
async function executePatch(env, input, context) {
|
|
638
|
+
checkAbort(context);
|
|
639
|
+
if (input === "")
|
|
640
|
+
throw new Error("apply_patch returned invalid structured JSON output");
|
|
641
|
+
const seen = new Set;
|
|
642
|
+
for (const source of sourcePathsForDuplicateGuard(input) ?? []) {
|
|
643
|
+
const path = getOrThrow3(await env.absolutePath(source, context));
|
|
644
|
+
const identity = pathIdentity(path);
|
|
645
|
+
if (seen.has(identity))
|
|
646
|
+
throw new Error(`apply_patch rejected: multiple file sections resolve to ${path}. Combine changes for each source file into one section; use multiple @@ hunks for one update`);
|
|
647
|
+
seen.add(identity);
|
|
648
|
+
}
|
|
649
|
+
let patch;
|
|
650
|
+
try {
|
|
651
|
+
patch = parsePatch(input);
|
|
652
|
+
} catch (error) {
|
|
653
|
+
throw new ExecutePatchError(error instanceof Error ? error.message : String(error), summarize(env, [], true), undefined);
|
|
654
|
+
}
|
|
655
|
+
const actions = await resolveActions(env, patch.actions, context);
|
|
656
|
+
const paths = actions.flatMap((action) => action.movePath === undefined ? [action.path] : [action.path, action.movePath]);
|
|
657
|
+
const warnings = [];
|
|
658
|
+
try {
|
|
659
|
+
const outcome = await withMutationKeys(env, paths, context, () => applyActions(env, actions, context), warnings);
|
|
660
|
+
if (warnings.length)
|
|
661
|
+
outcome.serializationWarnings = warnings;
|
|
662
|
+
return outcome;
|
|
663
|
+
} catch (error) {
|
|
664
|
+
if (error instanceof ExecutePatchError && warnings.length)
|
|
665
|
+
error.outcome.serializationWarnings = warnings;
|
|
666
|
+
throw error;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// packages/apply-patch/src/index.ts
|
|
671
|
+
var patchSyntax = "*** Begin Patch / *** End Patch; actions: *** Add File: path | *** Update File: path | *** Delete File: path. *** Move to: path must immediately follow its Update File header and needs a nonempty @@ hunk (one unchanged context line for pure moves). Update hunks follow file order; copy exact context and indentation. @@ text is context, not a line range; reread a file before patching if it changed since your last read";
|
|
672
|
+
var parameters = Type.Object({
|
|
673
|
+
input: Type.String({
|
|
674
|
+
description: patchSyntax
|
|
675
|
+
})
|
|
676
|
+
});
|
|
677
|
+
function prepareArguments(args) {
|
|
678
|
+
if (args && typeof args === "object") {
|
|
679
|
+
if ("input" in args && typeof args.input === "string")
|
|
680
|
+
return { input: args.input };
|
|
681
|
+
if ("patchText" in args && typeof args.patchText === "string")
|
|
682
|
+
return { input: args.patchText };
|
|
683
|
+
if ("patch" in args && typeof args.patch === "string")
|
|
684
|
+
return { input: args.patch };
|
|
685
|
+
}
|
|
686
|
+
throw new Error("apply_patch requires a string 'input' parameter");
|
|
687
|
+
}
|
|
688
|
+
function counts(result) {
|
|
689
|
+
return `changed ${result.changedFiles.length} file${result.changedFiles.length === 1 ? "" : "s"}, created ${result.createdFiles.length}, deleted ${result.deletedFiles.length}, moved ${result.movedFiles.length}`;
|
|
690
|
+
}
|
|
691
|
+
function failedTargets(error) {
|
|
692
|
+
const action = error.action;
|
|
693
|
+
return action === undefined ? [] : [
|
|
694
|
+
action.type === "update" && action.movePath !== undefined ? `${action.path} -> ${action.movePath}` : action.path
|
|
695
|
+
];
|
|
696
|
+
}
|
|
697
|
+
function failureMessage(error, partial) {
|
|
698
|
+
const targets = failedTargets(error);
|
|
699
|
+
const prefix = partial ? `apply_patch partially failed after ${counts(error.result)}` : "apply_patch failed";
|
|
700
|
+
const preview = error.message.startsWith("Failed to find expected lines") ? error.message.split(`
|
|
701
|
+
`).slice(1).find((line) => line.trim() !== "")?.trim() : undefined;
|
|
702
|
+
const cause = preview === undefined ? error.message : `expected context not found
|
|
703
|
+
Expected near: ${preview}`;
|
|
704
|
+
let message = `${prefix}${targets.length ? ` while patching ${targets.join(", ")}` : ""}: ${cause}`;
|
|
705
|
+
const action = error.action;
|
|
706
|
+
const paths = action === undefined ? [] : [
|
|
707
|
+
...new Set([
|
|
708
|
+
action.path,
|
|
709
|
+
...action.type === "update" && action.movePath !== undefined ? [action.movePath] : []
|
|
710
|
+
])
|
|
711
|
+
];
|
|
712
|
+
if (partial) {
|
|
713
|
+
if (paths.length)
|
|
714
|
+
message += `
|
|
715
|
+
Failed file${paths.length === 1 ? "" : "s"}: ${paths.join(", ")}
|
|
716
|
+
Recovery: MUST read ${paths.join(", ")} before retrying`;
|
|
717
|
+
if (error.result.changedFiles.some((path) => !paths.includes(path))) {
|
|
718
|
+
message += `
|
|
719
|
+
Earlier file actions in this patch were already applied
|
|
720
|
+
Recovery: MUST NOT reread other files from this patch unless a specific dependency requires it`;
|
|
721
|
+
}
|
|
722
|
+
} else if (preview !== undefined) {
|
|
723
|
+
message += `
|
|
724
|
+
Recovery: MUST read ${targets.join(", ") || "the failed file"} and retry only the failed edit against current contents`;
|
|
725
|
+
}
|
|
726
|
+
return message;
|
|
727
|
+
}
|
|
728
|
+
function createApplyPatchTool() {
|
|
729
|
+
const constrainedSampling = process.env["PI_EXPERIMENTAL"] === "1" ? { type: "json_schema", strict: "prefer" } : undefined;
|
|
730
|
+
const tool = defineTool({
|
|
731
|
+
name: "apply_patch",
|
|
732
|
+
description: "Patch files",
|
|
733
|
+
parameters,
|
|
734
|
+
...constrainedSampling === undefined ? {} : { constrainedSampling },
|
|
735
|
+
executionMode: "sequential",
|
|
736
|
+
replay: "unsafe",
|
|
737
|
+
prepareArguments,
|
|
738
|
+
async execute(args, api, context) {
|
|
739
|
+
if (!api.env)
|
|
740
|
+
throw new Error("apply_patch requires an execution environment");
|
|
741
|
+
try {
|
|
742
|
+
const outcome = await executePatch(api.env, args.input, context);
|
|
743
|
+
const result = outcome.result;
|
|
744
|
+
return {
|
|
745
|
+
output: [
|
|
746
|
+
{
|
|
747
|
+
type: "text",
|
|
748
|
+
text: `Applied patch successfully
|
|
749
|
+
Changed files: ${result.changedFiles.length}
|
|
750
|
+
Created files: ${result.createdFiles.length}
|
|
751
|
+
Deleted files: ${result.deletedFiles.length}
|
|
752
|
+
Moved files: ${result.movedFiles.length}
|
|
753
|
+
Fuzz: ${result.fuzz}`
|
|
754
|
+
}
|
|
755
|
+
],
|
|
756
|
+
details: { status: "success", ...outcome, failedTargets: [] },
|
|
757
|
+
diagnostics: (outcome.serializationWarnings ?? []).map((message) => ({
|
|
758
|
+
severity: "warn",
|
|
759
|
+
message
|
|
760
|
+
}))
|
|
761
|
+
};
|
|
762
|
+
} catch (error) {
|
|
763
|
+
if (!(error instanceof ExecutePatchError))
|
|
764
|
+
throw error;
|
|
765
|
+
const partial = error.hasPartialSuccess();
|
|
766
|
+
const message = failureMessage(error, partial);
|
|
767
|
+
for (const warning of error.outcome.serializationWarnings ?? [])
|
|
768
|
+
api.diagnostic({ severity: "warn", message: warning });
|
|
769
|
+
if (!partial)
|
|
770
|
+
throw new Error(message, { cause: error });
|
|
771
|
+
return {
|
|
772
|
+
output: [{ type: "text", text: message }],
|
|
773
|
+
isError: true,
|
|
774
|
+
details: {
|
|
775
|
+
status: "partial_failure",
|
|
776
|
+
...error.outcome,
|
|
777
|
+
failedTargets: failedTargets(error)
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
return {
|
|
784
|
+
...tool,
|
|
785
|
+
executionHints: {
|
|
786
|
+
deferLoading: false,
|
|
787
|
+
usage: `await tools.apply_patch({ input: patch }) // ${patchSyntax}
|
|
788
|
+
Use apply_patch for text edits, creates, deletes and moves. Patch each file in one call; split oversized patches sequentially and batch independent files with Promise.allSettled. Reserve shell/Python for formatting and bulk rewrites.`
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
var ApplyPatch = defineExtension({
|
|
793
|
+
name: "apply-patch",
|
|
794
|
+
tools: [createApplyPatchTool()]
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
// packages/apply-patch/src/activation.ts
|
|
798
|
+
function createComponent(_request) {
|
|
799
|
+
return { extensions: [ApplyPatch], api: ApplyPatch, retention: "idle" };
|
|
800
|
+
}
|
|
801
|
+
export {
|
|
802
|
+
createComponent
|
|
803
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type } from "
|
|
1
|
+
import { Type } from "typebox";
|
|
2
2
|
import { type ExecutePatchResult, type FileChange } from "./patch-outcome.ts";
|
|
3
3
|
export { executePatch } from "./executor.ts";
|
|
4
4
|
export type { ExecutePatchResult, FileChange, PatchOutcome, } from "./patch-outcome.ts";
|
|
@@ -24,7 +24,7 @@ export declare function createApplyPatchTool(): {
|
|
|
24
24
|
prepareArguments?(args: unknown): {
|
|
25
25
|
input: string;
|
|
26
26
|
};
|
|
27
|
-
structuredOutputSchema?:
|
|
27
|
+
structuredOutputSchema?: object;
|
|
28
28
|
callers?: readonly ("model" | "tools")[];
|
|
29
29
|
deferred?: true;
|
|
30
30
|
outputLimits?: {
|
|
@@ -52,7 +52,7 @@ export declare const ApplyPatch: import("@earendil-works/pi-durable").Extension<
|
|
|
52
52
|
prepareArguments?(args: unknown): {
|
|
53
53
|
input: string;
|
|
54
54
|
};
|
|
55
|
-
structuredOutputSchema?:
|
|
55
|
+
structuredOutputSchema?: object;
|
|
56
56
|
callers?: readonly ("model" | "tools")[];
|
|
57
57
|
deferred?: true;
|
|
58
58
|
outputLimits?: {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/apply-patch/src/index.ts
|
|
2
|
-
import { Type } from "@earendil-works/pi-ai";
|
|
3
2
|
import { defineExtension, defineTool } from "@earendil-works/pi-durable";
|
|
3
|
+
import { Type } from "typebox";
|
|
4
4
|
|
|
5
5
|
// packages/apply-patch/src/executor.ts
|
|
6
6
|
import { getOrThrow as getOrThrow3 } from "@earendil-works/pi-durable/env";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-durable-apply-patch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Codex-style patches for Pi Durable",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0 AND MIT",
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
".": {
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./component": {
|
|
28
|
+
"types": "./dist/activation.d.ts",
|
|
29
|
+
"import": "./dist/activation.js"
|
|
26
30
|
}
|
|
27
31
|
},
|
|
28
32
|
"files": [
|
|
@@ -33,12 +37,28 @@
|
|
|
33
37
|
],
|
|
34
38
|
"sideEffects": false,
|
|
35
39
|
"peerDependencies": {
|
|
36
|
-
"@earendil-works/chord": "1.
|
|
37
|
-
"@earendil-works/pi-ai": "1.
|
|
38
|
-
"@earendil-works/pi-durable": "1.
|
|
39
|
-
"@modelcontextprotocol/sdk": "1.25.2"
|
|
40
|
+
"@earendil-works/chord": "1.5.0",
|
|
41
|
+
"@earendil-works/pi-ai": "1.5.0",
|
|
42
|
+
"@earendil-works/pi-durable": "1.5.0",
|
|
43
|
+
"@modelcontextprotocol/sdk": ">=1.25.2 <2"
|
|
40
44
|
},
|
|
41
45
|
"publishConfig": {
|
|
42
46
|
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@howaboua/pi-durable-components": "0.11.0",
|
|
50
|
+
"typebox": "1.3.27"
|
|
51
|
+
},
|
|
52
|
+
"durable": {
|
|
53
|
+
"schemaVersion": 1,
|
|
54
|
+
"kind": "extension",
|
|
55
|
+
"entry": "./component",
|
|
56
|
+
"runtimes": [
|
|
57
|
+
"node"
|
|
58
|
+
],
|
|
59
|
+
"requires": [],
|
|
60
|
+
"permissions": [
|
|
61
|
+
"filesystem"
|
|
62
|
+
]
|
|
43
63
|
}
|
|
44
64
|
}
|