diff --git a/src/hooks/hashline-read-enhancer/hook.ts b/src/hooks/hashline-read-enhancer/hook.ts index b6f4db30..09a46c11 100644 --- a/src/hooks/hashline-read-enhancer/hook.ts +++ b/src/hooks/hashline-read-enhancer/hook.ts @@ -1,6 +1,5 @@ import type { PluginInput } from "@opencode-ai/plugin" import { computeLineHash } from "../../tools/hashline-edit/hash-computation" -import { toHashlineContent } from "../../tools/hashline-edit/diff-utils" interface HashlineReadEnhancerConfig { hashline_edit?: { enabled: boolean } @@ -137,10 +136,6 @@ function extractFilePath(metadata: unknown): string | undefined { } async function appendWriteHashlineOutput(output: { output: string; metadata: unknown }): Promise { - if (output.output.includes("Updated file (LINE#ID|content):")) { - return - } - const filePath = extractFilePath(output.metadata) if (!filePath) { return @@ -152,8 +147,8 @@ async function appendWriteHashlineOutput(output: { output: string; metadata: unk } const content = await file.text() - const hashlined = toHashlineContent(content) - output.output = `${output.output}\n\nUpdated file (LINE#ID|content):\n${hashlined}` + const lineCount = content === "" ? 0 : content.split("\n").length + output.output = `File written successfully. ${lineCount} lines written.` } export function createHashlineReadEnhancerHook( diff --git a/src/hooks/hashline-read-enhancer/index.test.ts b/src/hooks/hashline-read-enhancer/index.test.ts index 0f41874b..627380e0 100644 --- a/src/hooks/hashline-read-enhancer/index.test.ts +++ b/src/hooks/hashline-read-enhancer/index.test.ts @@ -164,7 +164,7 @@ describe("hashline-read-enhancer", () => { expect(lines[2]).toMatch(/^2#[ZPMQVRWSNKTXJBYH]{2}\|const y = 2$/) }) - it("appends LINE#ID output for write tool using metadata filepath", async () => { + it("appends simple summary for write tool instead of full hashlined content", async () => { //#given const hook = createHashlineReadEnhancerHook(mockCtx(), { hashline_edit: { enabled: true } }) const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "hashline-write-")) @@ -181,9 +181,10 @@ describe("hashline-read-enhancer", () => { await hook["tool.execute.after"](input, output) //#then - expect(output.output).toContain("Updated file (LINE#ID|content):") - expect(output.output).toMatch(/1#[ZPMQVRWSNKTXJBYH]{2}\|const x = 1/) - expect(output.output).toMatch(/2#[ZPMQVRWSNKTXJBYH]{2}\|const y = 2/) + expect(output.output).toContain("File written successfully.") + expect(output.output).toContain("2 lines written.") + expect(output.output).not.toContain("Updated file (LINE#ID|content):") + expect(output.output).not.toContain("const x = 1") fs.rmSync(tempDir, { recursive: true, force: true }) })