codex-supervisor-mcp 0.8.0 → 0.9.1

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/src/worktree.js CHANGED
@@ -11,9 +11,10 @@
11
11
  // so the committed part is read as `git diff --name-only <base> HEAD`, where
12
12
  // base is the commit the worktree was created from.
13
13
  import { execFileSync } from "node:child_process";
14
- import { existsSync, readFileSync } from "node:fs";
14
+ import { existsSync, readFileSync, lstatSync } from "node:fs";
15
15
  import { join } from "node:path";
16
16
  import { truncateMiddleChars } from "./truncate.js";
17
+ import { createHash } from "node:crypto";
17
18
 
18
19
  const defaultGitBin = process.env.GIT_BIN?.trim() || "git";
19
20
 
@@ -212,6 +213,29 @@ export function readTaskChanges(task) {
212
213
  return mergeChangedFiles(task.changed_files, readWorktreeChanges(task.worktree_path, worktreeRef(task)));
213
214
  }
214
215
 
216
+ // Compare output at this run's start/end, rather than treating the previous
217
+ // run's committed or uncommitted work as fresh evidence. If the bounded read
218
+ // cannot prove the full state, leave the fingerprint unknown.
219
+ export function snapshotTaskOutput(task) {
220
+ const diff = readWorktreeDiff(task.worktree_path, worktreeRef(task), { maxChars: 2_000_000 });
221
+ if (diff.error || diff.truncated_files > 0 || diff.files.some((file) => file.patch == null)) return null;
222
+ try {
223
+ let remaining = 2_000_000;
224
+ const files = diff.files.map((file) => {
225
+ let content = "deleted";
226
+ if (file.status !== "deleted") {
227
+ const path = join(task.worktree_path, file.path);
228
+ const info = lstatSync(path);
229
+ if (!info.isFile() || info.size > remaining) throw new Error("unknown output");
230
+ remaining -= info.size;
231
+ content = createHash("sha256").update(readFileSync(path)).digest("hex");
232
+ }
233
+ return { path: file.path, from: file.from, status: file.status, patch: file.patch, content };
234
+ });
235
+ return createHash("sha256").update(JSON.stringify(files)).digest("hex");
236
+ } catch { return null; }
237
+ }
238
+
215
239
  // How far the project has moved since the worktree was cut. Compared with
216
240
  // the project directory's HEAD, which is the branch the main thread
217
241
  // integrates on. contains_base false means the base was rewritten (an