@mwillbanks/ast-mcp 0.6.4 → 0.6.6
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/dist/ast-mcp.js +325 -324
- package/dist/ast-mcp.js.map +82 -26
- package/package.json +2 -2
- package/src/intelligence/mutation/journal.ts +42 -2
- package/src/intelligence/mutation/service.ts +614 -46
- package/src/intelligence/mutation/types.ts +2 -0
- package/src/patch/engine.ts +69 -20
- package/src/runtime/attributes.ts +161 -26
- package/src/runtime/file-delete.ts +32 -26
- package/src/runtime/file-read.ts +34 -11
- package/src/runtime/file-rename.ts +15 -10
- package/src/runtime/hash.ts +42 -1
- package/src/runtime/reference-target-index.ts +35 -0
- package/src/runtime/snapshot-blob.ts +733 -0
- package/src/tools/lifecycle.ts +9 -7
package/src/tools/lifecycle.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
applyFileChattr,
|
|
29
29
|
type FileChattr,
|
|
30
30
|
readFileChattrSnapshot,
|
|
31
|
+
FileChattrSnapshots,
|
|
31
32
|
} from "../runtime/attributes";
|
|
32
33
|
import { deleteFilesSafely } from "../runtime/file-delete";
|
|
33
34
|
import { renameFilesSafely } from "../runtime/file-rename";
|
|
@@ -93,10 +94,7 @@ export default function registerLifecycleTools(
|
|
|
93
94
|
const fence = async (): Promise<void> => {
|
|
94
95
|
await Promise.all(leases.map((lease) => lease.fence()));
|
|
95
96
|
};
|
|
96
|
-
|
|
97
|
-
string,
|
|
98
|
-
Awaited<ReturnType<typeof readFileChattrSnapshot>>
|
|
99
|
-
>();
|
|
97
|
+
await using snapshots = new FileChattrSnapshots();
|
|
100
98
|
for (const { filePath, request } of entries) {
|
|
101
99
|
await requireExpectedHash(
|
|
102
100
|
request.expectedSha256,
|
|
@@ -106,10 +104,10 @@ export default function registerLifecycleTools(
|
|
|
106
104
|
filePath,
|
|
107
105
|
signal,
|
|
108
106
|
);
|
|
107
|
+
snapshots.set(filePath, captured);
|
|
109
108
|
const actual = captured.sha256;
|
|
110
109
|
if (request.expectedSha256)
|
|
111
110
|
verifyExpectedHash(request.expectedSha256, actual);
|
|
112
|
-
snapshots.set(filePath, captured);
|
|
113
111
|
}
|
|
114
112
|
const workspace = currentWorkspace() ?? null;
|
|
115
113
|
const plan = entries.map(({ filePath }) => {
|
|
@@ -119,8 +117,8 @@ export default function registerLifecycleTools(
|
|
|
119
117
|
return {
|
|
120
118
|
candidateSha256: snapshot.sha256,
|
|
121
119
|
filePath,
|
|
122
|
-
sourceContentBase64:
|
|
123
|
-
|
|
120
|
+
sourceContentBase64: null,
|
|
121
|
+
sourceBlob: snapshot.sourceBlob,
|
|
124
122
|
sourceGid:
|
|
125
123
|
process.platform === "win32"
|
|
126
124
|
? null
|
|
@@ -144,6 +142,7 @@ export default function registerLifecycleTools(
|
|
|
144
142
|
workspaceId: workspace.workspaceId,
|
|
145
143
|
})
|
|
146
144
|
: randomUUID();
|
|
145
|
+
snapshots.disposable = false;
|
|
147
146
|
await beginMutation({
|
|
148
147
|
files: plan,
|
|
149
148
|
operationId,
|
|
@@ -152,6 +151,7 @@ export default function registerLifecycleTools(
|
|
|
152
151
|
});
|
|
153
152
|
const applied: string[] = [];
|
|
154
153
|
try {
|
|
154
|
+
await snapshots.verify(signal);
|
|
155
155
|
for (const { filePath, request } of entries) {
|
|
156
156
|
signal?.throwIfAborted();
|
|
157
157
|
const snapshot = snapshots.get(filePath);
|
|
@@ -188,6 +188,7 @@ export default function registerLifecycleTools(
|
|
|
188
188
|
return { filePath, sha256: snapshot.sha256 };
|
|
189
189
|
}),
|
|
190
190
|
);
|
|
191
|
+
snapshots.disposable = true;
|
|
191
192
|
} catch (error) {
|
|
192
193
|
await failMutation(operationId, error).catch(
|
|
193
194
|
() => undefined,
|
|
@@ -225,6 +226,7 @@ export default function registerLifecycleTools(
|
|
|
225
226
|
{ details: { affectedPaths: applied } },
|
|
226
227
|
);
|
|
227
228
|
await recordMutationRollback(operationId);
|
|
229
|
+
snapshots.disposable = true;
|
|
228
230
|
throw error;
|
|
229
231
|
}
|
|
230
232
|
},
|