From 9706aaf552c3d1c85160e6ba5d107207019b931a Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Tue, 20 Jan 2026 00:32:29 -0600 Subject: [PATCH] rm filetime assertions from patch tool --- packages/opencode/src/tool/apply_patch.ts | 8 -------- packages/opencode/test/tool/apply_patch.test.ts | 16 ---------------- 2 files changed, 24 deletions(-) diff --git a/packages/opencode/src/tool/apply_patch.ts b/packages/opencode/src/tool/apply_patch.ts index 7b0ba6150..ec24643fc 100644 --- a/packages/opencode/src/tool/apply_patch.ts +++ b/packages/opencode/src/tool/apply_patch.ts @@ -2,7 +2,6 @@ import z from "zod" import * as path from "path" import * as fs from "fs/promises" import { Tool } from "./tool" -import { FileTime } from "../file/time" import { Bus } from "../bus" import { FileWatcher } from "../file/watcher" import { Instance } from "../project/instance" @@ -96,8 +95,6 @@ export const ApplyPatchTool = Tool.define("apply_patch", { throw new Error(`apply_patch verification failed: Failed to read file to update: ${filePath}`) } - // Read file and update time tracking (like edit tool does) - await FileTime.assert(ctx.sessionID, filePath) const oldContent = await fs.readFile(filePath, "utf-8") let newContent = oldContent @@ -203,11 +200,6 @@ export const ApplyPatchTool = Tool.define("apply_patch", { break } - // Update file time tracking - FileTime.read(ctx.sessionID, change.filePath) - if (change.movePath) { - FileTime.read(ctx.sessionID, change.movePath) - } } // Publish file change events diff --git a/packages/opencode/test/tool/apply_patch.test.ts b/packages/opencode/test/tool/apply_patch.test.ts index d8f05a9d9..6445c6845 100644 --- a/packages/opencode/test/tool/apply_patch.test.ts +++ b/packages/opencode/test/tool/apply_patch.test.ts @@ -3,7 +3,6 @@ import path from "path" import * as fs from "fs/promises" import { ApplyPatchTool } from "../../src/tool/apply_patch" import { Instance } from "../../src/project/instance" -import { FileTime } from "../../src/file/time" import { tmpdir } from "../fixture/fixture" const baseCtx = { @@ -71,8 +70,6 @@ describe("tool.apply_patch freeform", () => { const deletePath = path.join(fixture.path, "delete.txt") await fs.writeFile(modifyPath, "line1\nline2\n", "utf-8") await fs.writeFile(deletePath, "obsolete\n", "utf-8") - FileTime.read(ctx.sessionID, modifyPath) - FileTime.read(ctx.sessionID, deletePath) const patchText = "*** Begin Patch\n*** Add File: nested/new.txt\n+created\n*** Delete File: delete.txt\n*** Update File: modify.txt\n@@\n-line2\n+changed\n*** End Patch" @@ -101,7 +98,6 @@ describe("tool.apply_patch freeform", () => { fn: async () => { const target = path.join(fixture.path, "multi.txt") await fs.writeFile(target, "line1\nline2\nline3\nline4\n", "utf-8") - FileTime.read(ctx.sessionID, target) const patchText = "*** Begin Patch\n*** Update File: multi.txt\n@@\n-line2\n+changed2\n@@\n-line4\n+changed4\n*** End Patch" @@ -122,7 +118,6 @@ describe("tool.apply_patch freeform", () => { fn: async () => { const target = path.join(fixture.path, "insert_only.txt") await fs.writeFile(target, "alpha\nomega\n", "utf-8") - FileTime.read(ctx.sessionID, target) const patchText = "*** Begin Patch\n*** Update File: insert_only.txt\n@@\n alpha\n+beta\n omega\n*** End Patch" @@ -142,7 +137,6 @@ describe("tool.apply_patch freeform", () => { fn: async () => { const target = path.join(fixture.path, "no_newline.txt") await fs.writeFile(target, "no newline at end", "utf-8") - FileTime.read(ctx.sessionID, target) const patchText = "*** Begin Patch\n*** Update File: no_newline.txt\n@@\n-no newline at end\n+first line\n+second line\n*** End Patch" @@ -166,7 +160,6 @@ describe("tool.apply_patch freeform", () => { const original = path.join(fixture.path, "old", "name.txt") await fs.mkdir(path.dirname(original), { recursive: true }) await fs.writeFile(original, "old content\n", "utf-8") - FileTime.read(ctx.sessionID, original) const patchText = "*** Begin Patch\n*** Update File: old/name.txt\n*** Move to: renamed/dir/name.txt\n@@\n-old content\n+new content\n*** End Patch" @@ -193,7 +186,6 @@ describe("tool.apply_patch freeform", () => { await fs.mkdir(path.dirname(destination), { recursive: true }) await fs.writeFile(original, "from\n", "utf-8") await fs.writeFile(destination, "existing\n", "utf-8") - FileTime.read(ctx.sessionID, original) const patchText = "*** Begin Patch\n*** Update File: old/name.txt\n*** Move to: renamed/dir/name.txt\n@@\n-from\n+new\n*** End Patch" @@ -294,7 +286,6 @@ describe("tool.apply_patch freeform", () => { fn: async () => { const target = path.join(fixture.path, "modify.txt") await fs.writeFile(target, "line1\nline2\n", "utf-8") - FileTime.read(ctx.sessionID, target) const patchText = "*** Begin Patch\n*** Update File: modify.txt\n@@\n-missing\n+changed\n*** End Patch" @@ -331,7 +322,6 @@ describe("tool.apply_patch freeform", () => { fn: async () => { const target = path.join(fixture.path, "tail.txt") await fs.writeFile(target, "alpha\nlast\n", "utf-8") - FileTime.read(ctx.sessionID, target) const patchText = "*** Begin Patch\n*** Update File: tail.txt\n@@\n-last\n+end\n*** End of File\n*** End Patch" @@ -350,7 +340,6 @@ describe("tool.apply_patch freeform", () => { fn: async () => { const target = path.join(fixture.path, "two_chunks.txt") await fs.writeFile(target, "a\nb\nc\nd\n", "utf-8") - FileTime.read(ctx.sessionID, target) const patchText = "*** Begin Patch\n*** Update File: two_chunks.txt\n@@\n-b\n+B\n\n-d\n+D\n*** End Patch" @@ -369,7 +358,6 @@ describe("tool.apply_patch freeform", () => { fn: async () => { const target = path.join(fixture.path, "multi_ctx.txt") await fs.writeFile(target, "fn a\nx=10\ny=2\nfn b\nx=10\ny=20\n", "utf-8") - FileTime.read(ctx.sessionID, target) const patchText = "*** Begin Patch\n*** Update File: multi_ctx.txt\n@@ fn b\n-x=10\n+x=11\n*** End Patch" @@ -389,7 +377,6 @@ describe("tool.apply_patch freeform", () => { const target = path.join(fixture.path, "eof_anchor.txt") // File has duplicate "marker" lines - one in middle, one at end await fs.writeFile(target, "start\nmarker\nmiddle\nmarker\nend\n", "utf-8") - FileTime.read(ctx.sessionID, target) // With EOF anchor, should match the LAST "marker" line, not the first const patchText = @@ -454,7 +441,6 @@ EOF` const target = path.join(fixture.path, "trailing_ws.txt") // File has trailing spaces on some lines await fs.writeFile(target, "line1 \nline2\nline3 \n", "utf-8") - FileTime.read(ctx.sessionID, target) // Patch doesn't have trailing spaces - should still match via rstrip pass const patchText = "*** Begin Patch\n*** Update File: trailing_ws.txt\n@@\n-line2\n+changed\n*** End Patch" @@ -475,7 +461,6 @@ EOF` const target = path.join(fixture.path, "leading_ws.txt") // File has leading spaces await fs.writeFile(target, " line1\nline2\n line3\n", "utf-8") - FileTime.read(ctx.sessionID, target) // Patch without leading spaces - should match via trim pass const patchText = "*** Begin Patch\n*** Update File: leading_ws.txt\n@@\n-line2\n+changed\n*** End Patch" @@ -499,7 +484,6 @@ EOF` const rightQuote = "\u201D" const emDash = "\u2014" await fs.writeFile(target, `He said ${leftQuote}hello${rightQuote}\nsome${emDash}dash\nend\n`, "utf-8") - FileTime.read(ctx.sessionID, target) // Patch uses ASCII equivalents - should match via normalized pass // The replacement uses ASCII quotes from the patch (not preserving Unicode)