refactor(hashline): override native edit tool instead of separate tool + disabler hook

Replace 3-component hashline system (separate hashline_edit tool + edit
disabler hook + OpenAI-exempted read enhancer) with 2-component system
that directly overrides the native edit tool key, matching the
delegate_task pattern.

- Register hashline tool as 'edit' key to override native edit
- Delete hashline-edit-disabler hook (no longer needed)
- Delete hashline-provider-state module (no remaining consumers)
- Remove OpenAI exemption from read enhancer (explicit opt-in means all providers)
- Remove setProvider wiring from chat-params
This commit is contained in:
YeonGyu-Kim
2026-02-16 22:02:52 +09:00
parent bcf0a4998d
commit 8a80b88a08
15 changed files with 5 additions and 416 deletions
+3 -11
View File
@@ -1,5 +1,4 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { getProvider } from "../../features/hashline-provider-state"
import { computeLineHash } from "../../tools/hashline-edit/hash-computation"
interface HashlineReadEnhancerConfig {
@@ -12,15 +11,8 @@ function isReadTool(toolName: string): boolean {
return toolName.toLowerCase() === "read"
}
function shouldProcess(sessionID: string, config: HashlineReadEnhancerConfig): boolean {
if (!config.hashline_edit?.enabled) {
return false
}
const providerID = getProvider(sessionID)
if (providerID === "openai") {
return false
}
return true
function shouldProcess(config: HashlineReadEnhancerConfig): boolean {
return config.hashline_edit?.enabled ?? false
}
function isTextFile(output: string): boolean {
@@ -65,7 +57,7 @@ export function createHashlineReadEnhancerHook(
if (typeof output.output !== "string") {
return
}
if (!shouldProcess(input.sessionID, config)) {
if (!shouldProcess(config)) {
return
}
output.output = transformOutput(output.output)
+1 -52
View File
@@ -1,7 +1,6 @@
import { describe, it, expect, beforeEach, afterEach } from "bun:test"
import { describe, it, expect, beforeEach } from "bun:test"
import { createHashlineReadEnhancerHook } from "./hook"
import type { PluginInput } from "@opencode-ai/plugin"
import { setProvider, clearProvider } from "../../features/hashline-provider-state"
//#given - Test setup helpers
function createMockContext(): PluginInput {
@@ -27,11 +26,6 @@ describe("createHashlineReadEnhancerHook", () => {
beforeEach(() => {
mockCtx = createMockContext()
clearProvider(sessionID)
})
afterEach(() => {
clearProvider(sessionID)
})
describe("tool name matching", () => {
@@ -120,51 +114,6 @@ describe("createHashlineReadEnhancerHook", () => {
})
})
describe("provider check", () => {
it("should skip when provider is OpenAI", async () => {
//#given
setProvider(sessionID, "openai")
const hook = createHashlineReadEnhancerHook(mockCtx, createMockConfig(true))
const input = { tool: "read", sessionID, callID: "call-1" }
const originalOutput = "1: hello\n2: world"
const output = { title: "Read", output: originalOutput, metadata: {} }
//#when
await hook["tool.execute.after"](input, output)
//#then
expect(output.output).toBe(originalOutput)
})
it("should process when provider is Claude", async () => {
//#given
setProvider(sessionID, "anthropic")
const hook = createHashlineReadEnhancerHook(mockCtx, createMockConfig(true))
const input = { tool: "read", sessionID, callID: "call-1" }
const output = { title: "Read", output: "1: hello\n2: world", metadata: {} }
//#when
await hook["tool.execute.after"](input, output)
//#then
expect(output.output).toContain("|")
})
it("should process when provider is unknown (undefined)", async () => {
//#given
// Provider not set, getProvider returns undefined
const hook = createHashlineReadEnhancerHook(mockCtx, createMockConfig(true))
const input = { tool: "read", sessionID, callID: "call-1" }
const output = { title: "Read", output: "1: hello\n2: world", metadata: {} }
//#when
await hook["tool.execute.after"](input, output)
//#then
expect(output.output).toContain("|")
})
})
describe("output transformation", () => {
it("should transform 'N: content' format to 'N:HASH|content'", async () => {
//#given