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:
parent
9eb786debd
commit
af7b1ee620
@ -99,7 +99,6 @@
|
|||||||
"tasks-todowrite-disabler",
|
"tasks-todowrite-disabler",
|
||||||
"write-existing-file-guard",
|
"write-existing-file-guard",
|
||||||
"anthropic-effort",
|
"anthropic-effort",
|
||||||
"hashline-edit-disabler",
|
|
||||||
"hashline-read-enhancer"
|
"hashline-read-enhancer"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,6 @@ export const HookNameSchema = z.enum([
|
|||||||
"tasks-todowrite-disabler",
|
"tasks-todowrite-disabler",
|
||||||
"write-existing-file-guard",
|
"write-existing-file-guard",
|
||||||
"anthropic-effort",
|
"anthropic-effort",
|
||||||
"hashline-edit-disabler",
|
|
||||||
"hashline-read-enhancer",
|
"hashline-read-enhancer",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@ -1,113 +0,0 @@
|
|||||||
import { describe, expect, test, beforeEach } from "bun:test"
|
|
||||||
import { setProvider, getProvider, clearProvider } from "./hashline-provider-state"
|
|
||||||
|
|
||||||
describe("hashline-provider-state", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
// Clear state before each test
|
|
||||||
clearProvider("test-session-1")
|
|
||||||
clearProvider("test-session-2")
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("setProvider", () => {
|
|
||||||
test("should store provider ID for a session", () => {
|
|
||||||
// given
|
|
||||||
const sessionID = "test-session-1"
|
|
||||||
const providerID = "openai"
|
|
||||||
|
|
||||||
// when
|
|
||||||
setProvider(sessionID, providerID)
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(getProvider(sessionID)).toBe("openai")
|
|
||||||
})
|
|
||||||
|
|
||||||
test("should overwrite existing provider for same session", () => {
|
|
||||||
// given
|
|
||||||
const sessionID = "test-session-1"
|
|
||||||
setProvider(sessionID, "openai")
|
|
||||||
|
|
||||||
// when
|
|
||||||
setProvider(sessionID, "anthropic")
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(getProvider(sessionID)).toBe("anthropic")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("getProvider", () => {
|
|
||||||
test("should return undefined for non-existent session", () => {
|
|
||||||
// given
|
|
||||||
const sessionID = "non-existent-session"
|
|
||||||
|
|
||||||
// when
|
|
||||||
const result = getProvider(sessionID)
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(result).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
test("should return stored provider ID", () => {
|
|
||||||
// given
|
|
||||||
const sessionID = "test-session-1"
|
|
||||||
setProvider(sessionID, "anthropic")
|
|
||||||
|
|
||||||
// when
|
|
||||||
const result = getProvider(sessionID)
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(result).toBe("anthropic")
|
|
||||||
})
|
|
||||||
|
|
||||||
test("should handle multiple sessions independently", () => {
|
|
||||||
// given
|
|
||||||
setProvider("session-1", "openai")
|
|
||||||
setProvider("session-2", "anthropic")
|
|
||||||
|
|
||||||
// when
|
|
||||||
const result1 = getProvider("session-1")
|
|
||||||
const result2 = getProvider("session-2")
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(result1).toBe("openai")
|
|
||||||
expect(result2).toBe("anthropic")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("clearProvider", () => {
|
|
||||||
test("should remove provider for a session", () => {
|
|
||||||
// given
|
|
||||||
const sessionID = "test-session-1"
|
|
||||||
setProvider(sessionID, "openai")
|
|
||||||
|
|
||||||
// when
|
|
||||||
clearProvider(sessionID)
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(getProvider(sessionID)).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
test("should not affect other sessions", () => {
|
|
||||||
// given
|
|
||||||
setProvider("session-1", "openai")
|
|
||||||
setProvider("session-2", "anthropic")
|
|
||||||
|
|
||||||
// when
|
|
||||||
clearProvider("session-1")
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(getProvider("session-1")).toBeUndefined()
|
|
||||||
expect(getProvider("session-2")).toBe("anthropic")
|
|
||||||
})
|
|
||||||
|
|
||||||
test("should handle clearing non-existent session gracefully", () => {
|
|
||||||
// given
|
|
||||||
const sessionID = "non-existent"
|
|
||||||
|
|
||||||
// when
|
|
||||||
clearProvider(sessionID)
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(getProvider(sessionID)).toBeUndefined()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
const providerStateMap = new Map<string, string>()
|
|
||||||
|
|
||||||
export function setProvider(sessionID: string, providerID: string): void {
|
|
||||||
providerStateMap.set(sessionID, providerID)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getProvider(sessionID: string): string | undefined {
|
|
||||||
return providerStateMap.get(sessionID)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function clearProvider(sessionID: string): void {
|
|
||||||
providerStateMap.delete(sessionID)
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
export const HOOK_NAME = "hashline-edit-disabler"
|
|
||||||
|
|
||||||
export const EDIT_DISABLED_MESSAGE = `The 'edit' tool is disabled. Use 'hashline_edit' tool instead. Read the file first to get LINE:HASH anchors, then use hashline_edit with set_line, replace_lines, or insert_after operations.`
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
import type { Hooks, PluginInput } from "@opencode-ai/plugin"
|
|
||||||
import { getProvider } from "../../features/hashline-provider-state"
|
|
||||||
import { EDIT_DISABLED_MESSAGE } from "./constants"
|
|
||||||
|
|
||||||
export interface HashlineEditDisablerConfig {
|
|
||||||
experimental?: {
|
|
||||||
hashline_edit?: boolean
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createHashlineEditDisablerHook(
|
|
||||||
config: HashlineEditDisablerConfig,
|
|
||||||
): Hooks {
|
|
||||||
const isHashlineEnabled = config.experimental?.hashline_edit ?? false
|
|
||||||
|
|
||||||
return {
|
|
||||||
"tool.execute.before": async (
|
|
||||||
input: { tool: string; sessionID: string },
|
|
||||||
) => {
|
|
||||||
if (!isHashlineEnabled) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const toolName = input.tool.toLowerCase()
|
|
||||||
if (toolName !== "edit") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const providerID = getProvider(input.sessionID)
|
|
||||||
if (providerID === "openai") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error(EDIT_DISABLED_MESSAGE)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,168 +0,0 @@
|
|||||||
import { describe, it, expect, beforeEach, afterEach } from "bun:test"
|
|
||||||
import { createHashlineEditDisablerHook } from "./index"
|
|
||||||
import { setProvider, clearProvider } from "../../features/hashline-provider-state"
|
|
||||||
|
|
||||||
describe("hashline-edit-disabler hook", () => {
|
|
||||||
const sessionID = "test-session-123"
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
clearProvider(sessionID)
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
clearProvider(sessionID)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("blocks edit tool when hashline enabled + non-OpenAI provider", async () => {
|
|
||||||
//#given
|
|
||||||
setProvider(sessionID, "anthropic")
|
|
||||||
const hook = createHashlineEditDisablerHook({
|
|
||||||
experimental: { hashline_edit: true },
|
|
||||||
})
|
|
||||||
const input = { tool: "edit", sessionID }
|
|
||||||
const output = { args: {} }
|
|
||||||
|
|
||||||
//#when
|
|
||||||
const executeBeforeHandler = hook["tool.execute.before"]
|
|
||||||
if (!executeBeforeHandler) {
|
|
||||||
throw new Error("tool.execute.before handler not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//#then
|
|
||||||
await expect(executeBeforeHandler(input, output)).rejects.toThrow(
|
|
||||||
/hashline_edit/,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("passes through edit tool when hashline disabled", async () => {
|
|
||||||
//#given
|
|
||||||
setProvider(sessionID, "anthropic")
|
|
||||||
const hook = createHashlineEditDisablerHook({
|
|
||||||
experimental: { hashline_edit: false },
|
|
||||||
})
|
|
||||||
const input = { tool: "edit", sessionID }
|
|
||||||
const output = { args: {} }
|
|
||||||
|
|
||||||
//#when
|
|
||||||
const executeBeforeHandler = hook["tool.execute.before"]
|
|
||||||
if (!executeBeforeHandler) {
|
|
||||||
throw new Error("tool.execute.before handler not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//#then
|
|
||||||
const result = await executeBeforeHandler(input, output)
|
|
||||||
expect(result).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("passes through edit tool when OpenAI provider (even if hashline enabled)", async () => {
|
|
||||||
//#given
|
|
||||||
setProvider(sessionID, "openai")
|
|
||||||
const hook = createHashlineEditDisablerHook({
|
|
||||||
experimental: { hashline_edit: true },
|
|
||||||
})
|
|
||||||
const input = { tool: "edit", sessionID }
|
|
||||||
const output = { args: {} }
|
|
||||||
|
|
||||||
//#when
|
|
||||||
const executeBeforeHandler = hook["tool.execute.before"]
|
|
||||||
if (!executeBeforeHandler) {
|
|
||||||
throw new Error("tool.execute.before handler not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//#then
|
|
||||||
const result = await executeBeforeHandler(input, output)
|
|
||||||
expect(result).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("passes through non-edit tools", async () => {
|
|
||||||
//#given
|
|
||||||
setProvider(sessionID, "anthropic")
|
|
||||||
const hook = createHashlineEditDisablerHook({
|
|
||||||
experimental: { hashline_edit: true },
|
|
||||||
})
|
|
||||||
const input = { tool: "write", sessionID }
|
|
||||||
const output = { args: {} }
|
|
||||||
|
|
||||||
//#when
|
|
||||||
const executeBeforeHandler = hook["tool.execute.before"]
|
|
||||||
if (!executeBeforeHandler) {
|
|
||||||
throw new Error("tool.execute.before handler not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//#then
|
|
||||||
const result = await executeBeforeHandler(input, output)
|
|
||||||
expect(result).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("blocks case-insensitive edit tool names", async () => {
|
|
||||||
//#given
|
|
||||||
setProvider(sessionID, "anthropic")
|
|
||||||
const hook = createHashlineEditDisablerHook({
|
|
||||||
experimental: { hashline_edit: true },
|
|
||||||
})
|
|
||||||
|
|
||||||
//#when
|
|
||||||
const executeBeforeHandler = hook["tool.execute.before"]
|
|
||||||
if (!executeBeforeHandler) {
|
|
||||||
throw new Error("tool.execute.before handler not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//#then
|
|
||||||
for (const toolName of ["Edit", "EDIT", "edit", "EdIt"]) {
|
|
||||||
const input = { tool: toolName, sessionID }
|
|
||||||
const output = { args: {} }
|
|
||||||
await expect(executeBeforeHandler(input, output)).rejects.toThrow(
|
|
||||||
/hashline_edit/,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
it("passes through when hashline config is undefined", async () => {
|
|
||||||
//#given
|
|
||||||
setProvider(sessionID, "anthropic")
|
|
||||||
const hook = createHashlineEditDisablerHook({
|
|
||||||
experimental: {},
|
|
||||||
})
|
|
||||||
const input = { tool: "edit", sessionID }
|
|
||||||
const output = { args: {} }
|
|
||||||
|
|
||||||
//#when
|
|
||||||
const executeBeforeHandler = hook["tool.execute.before"]
|
|
||||||
if (!executeBeforeHandler) {
|
|
||||||
throw new Error("tool.execute.before handler not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//#then
|
|
||||||
const result = await executeBeforeHandler(input, output)
|
|
||||||
expect(result).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("error message includes hashline_edit tool guidance", async () => {
|
|
||||||
//#given
|
|
||||||
setProvider(sessionID, "anthropic")
|
|
||||||
const hook = createHashlineEditDisablerHook({
|
|
||||||
experimental: { hashline_edit: true },
|
|
||||||
})
|
|
||||||
const input = { tool: "edit", sessionID }
|
|
||||||
const output = { args: {} }
|
|
||||||
|
|
||||||
//#when
|
|
||||||
const executeBeforeHandler = hook["tool.execute.before"]
|
|
||||||
if (!executeBeforeHandler) {
|
|
||||||
throw new Error("tool.execute.before handler not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
//#then
|
|
||||||
try {
|
|
||||||
await executeBeforeHandler(input, output)
|
|
||||||
throw new Error("Expected error to be thrown")
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
expect(error.message).toContain("hashline_edit")
|
|
||||||
expect(error.message).toContain("set_line")
|
|
||||||
expect(error.message).toContain("replace_lines")
|
|
||||||
expect(error.message).toContain("insert_after")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
export { createHashlineEditDisablerHook } from "./hook"
|
|
||||||
export { HOOK_NAME, EDIT_DISABLED_MESSAGE } from "./constants"
|
|
||||||
@ -1,5 +1,4 @@
|
|||||||
import type { PluginInput } from "@opencode-ai/plugin"
|
import type { PluginInput } from "@opencode-ai/plugin"
|
||||||
import { getProvider } from "../../features/hashline-provider-state"
|
|
||||||
import { computeLineHash } from "../../tools/hashline-edit/hash-computation"
|
import { computeLineHash } from "../../tools/hashline-edit/hash-computation"
|
||||||
|
|
||||||
interface HashlineReadEnhancerConfig {
|
interface HashlineReadEnhancerConfig {
|
||||||
@ -12,15 +11,8 @@ function isReadTool(toolName: string): boolean {
|
|||||||
return toolName.toLowerCase() === "read"
|
return toolName.toLowerCase() === "read"
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldProcess(sessionID: string, config: HashlineReadEnhancerConfig): boolean {
|
function shouldProcess(config: HashlineReadEnhancerConfig): boolean {
|
||||||
if (!config.hashline_edit?.enabled) {
|
return config.hashline_edit?.enabled ?? false
|
||||||
return false
|
|
||||||
}
|
|
||||||
const providerID = getProvider(sessionID)
|
|
||||||
if (providerID === "openai") {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isTextFile(output: string): boolean {
|
function isTextFile(output: string): boolean {
|
||||||
@ -65,7 +57,7 @@ export function createHashlineReadEnhancerHook(
|
|||||||
if (typeof output.output !== "string") {
|
if (typeof output.output !== "string") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!shouldProcess(input.sessionID, config)) {
|
if (!shouldProcess(config)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
output.output = transformOutput(output.output)
|
output.output = transformOutput(output.output)
|
||||||
|
|||||||
@ -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 { createHashlineReadEnhancerHook } from "./hook"
|
||||||
import type { PluginInput } from "@opencode-ai/plugin"
|
import type { PluginInput } from "@opencode-ai/plugin"
|
||||||
import { setProvider, clearProvider } from "../../features/hashline-provider-state"
|
|
||||||
|
|
||||||
//#given - Test setup helpers
|
//#given - Test setup helpers
|
||||||
function createMockContext(): PluginInput {
|
function createMockContext(): PluginInput {
|
||||||
@ -27,11 +26,6 @@ describe("createHashlineReadEnhancerHook", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockCtx = createMockContext()
|
mockCtx = createMockContext()
|
||||||
clearProvider(sessionID)
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
clearProvider(sessionID)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("tool name matching", () => {
|
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", () => {
|
describe("output transformation", () => {
|
||||||
it("should transform 'N: content' format to 'N:HASH|content'", async () => {
|
it("should transform 'N: content' format to 'N:HASH|content'", async () => {
|
||||||
//#given
|
//#given
|
||||||
|
|||||||
@ -43,5 +43,4 @@ export { createUnstableAgentBabysitterHook } from "./unstable-agent-babysitter";
|
|||||||
export { createPreemptiveCompactionHook } from "./preemptive-compaction";
|
export { createPreemptiveCompactionHook } from "./preemptive-compaction";
|
||||||
export { createTasksTodowriteDisablerHook } from "./tasks-todowrite-disabler";
|
export { createTasksTodowriteDisablerHook } from "./tasks-todowrite-disabler";
|
||||||
export { createWriteExistingFileGuardHook } from "./write-existing-file-guard";
|
export { createWriteExistingFileGuardHook } from "./write-existing-file-guard";
|
||||||
export { createHashlineEditDisablerHook } from "./hashline-edit-disabler";
|
|
||||||
export { createHashlineReadEnhancerHook } from "./hashline-read-enhancer";
|
export { createHashlineReadEnhancerHook } from "./hashline-read-enhancer";
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import { setProvider } from "../features/hashline-provider-state"
|
|
||||||
|
|
||||||
type ChatParamsInput = {
|
type ChatParamsInput = {
|
||||||
sessionID: string
|
sessionID: string
|
||||||
agent: { name?: string }
|
agent: { name?: string }
|
||||||
@ -68,8 +66,6 @@ export function createChatParamsHandler(args: {
|
|||||||
if (!normalizedInput) return
|
if (!normalizedInput) return
|
||||||
if (!isChatParamsOutput(output)) return
|
if (!isChatParamsOutput(output)) return
|
||||||
|
|
||||||
setProvider(normalizedInput.sessionID, normalizedInput.model.providerID)
|
|
||||||
|
|
||||||
await args.anthropicEffort?.["chat.params"]?.(normalizedInput, output)
|
await args.anthropicEffort?.["chat.params"]?.(normalizedInput, output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import {
|
|||||||
createRulesInjectorHook,
|
createRulesInjectorHook,
|
||||||
createTasksTodowriteDisablerHook,
|
createTasksTodowriteDisablerHook,
|
||||||
createWriteExistingFileGuardHook,
|
createWriteExistingFileGuardHook,
|
||||||
createHashlineEditDisablerHook,
|
|
||||||
createHashlineReadEnhancerHook,
|
createHashlineReadEnhancerHook,
|
||||||
} from "../../hooks"
|
} from "../../hooks"
|
||||||
import {
|
import {
|
||||||
@ -30,7 +29,6 @@ export type ToolGuardHooks = {
|
|||||||
rulesInjector: ReturnType<typeof createRulesInjectorHook> | null
|
rulesInjector: ReturnType<typeof createRulesInjectorHook> | null
|
||||||
tasksTodowriteDisabler: ReturnType<typeof createTasksTodowriteDisablerHook> | null
|
tasksTodowriteDisabler: ReturnType<typeof createTasksTodowriteDisablerHook> | null
|
||||||
writeExistingFileGuard: ReturnType<typeof createWriteExistingFileGuardHook> | null
|
writeExistingFileGuard: ReturnType<typeof createWriteExistingFileGuardHook> | null
|
||||||
hashlineEditDisabler: ReturnType<typeof createHashlineEditDisablerHook> | null
|
|
||||||
hashlineReadEnhancer: ReturnType<typeof createHashlineReadEnhancerHook> | null
|
hashlineReadEnhancer: ReturnType<typeof createHashlineReadEnhancerHook> | null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,10 +87,6 @@ export function createToolGuardHooks(args: {
|
|||||||
? safeHook("write-existing-file-guard", () => createWriteExistingFileGuardHook(ctx))
|
? safeHook("write-existing-file-guard", () => createWriteExistingFileGuardHook(ctx))
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const hashlineEditDisabler = isHookEnabled("hashline-edit-disabler")
|
|
||||||
? safeHook("hashline-edit-disabler", () => createHashlineEditDisablerHook(pluginConfig))
|
|
||||||
: null
|
|
||||||
|
|
||||||
const hashlineReadEnhancer = isHookEnabled("hashline-read-enhancer")
|
const hashlineReadEnhancer = isHookEnabled("hashline-read-enhancer")
|
||||||
? safeHook("hashline-read-enhancer", () => createHashlineReadEnhancerHook(ctx, { hashline_edit: { enabled: pluginConfig.experimental?.hashline_edit ?? false } }))
|
? safeHook("hashline-read-enhancer", () => createHashlineReadEnhancerHook(ctx, { hashline_edit: { enabled: pluginConfig.experimental?.hashline_edit ?? false } }))
|
||||||
: null
|
: null
|
||||||
@ -106,7 +100,6 @@ export function createToolGuardHooks(args: {
|
|||||||
rulesInjector,
|
rulesInjector,
|
||||||
tasksTodowriteDisabler,
|
tasksTodowriteDisabler,
|
||||||
writeExistingFileGuard,
|
writeExistingFileGuard,
|
||||||
hashlineEditDisabler,
|
|
||||||
hashlineReadEnhancer,
|
hashlineReadEnhancer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,6 @@ export function createToolExecuteBeforeHandler(args: {
|
|||||||
await hooks.prometheusMdOnly?.["tool.execute.before"]?.(input, output)
|
await hooks.prometheusMdOnly?.["tool.execute.before"]?.(input, output)
|
||||||
await hooks.sisyphusJuniorNotepad?.["tool.execute.before"]?.(input, output)
|
await hooks.sisyphusJuniorNotepad?.["tool.execute.before"]?.(input, output)
|
||||||
await hooks.atlasHook?.["tool.execute.before"]?.(input, output)
|
await hooks.atlasHook?.["tool.execute.before"]?.(input, output)
|
||||||
await hooks.hashlineEditDisabler?.["tool.execute.before"]?.(input, output)
|
|
||||||
|
|
||||||
if (input.tool === "task") {
|
if (input.tool === "task") {
|
||||||
const argsObject = output.args
|
const argsObject = output.args
|
||||||
const category = typeof argsObject.category === "string" ? argsObject.category : undefined
|
const category = typeof argsObject.category === "string" ? argsObject.category : undefined
|
||||||
|
|||||||
@ -120,7 +120,7 @@ export function createToolRegistry(args: {
|
|||||||
|
|
||||||
const hashlineEnabled = pluginConfig.experimental?.hashline_edit ?? false
|
const hashlineEnabled = pluginConfig.experimental?.hashline_edit ?? false
|
||||||
const hashlineToolsRecord: Record<string, ToolDefinition> = hashlineEnabled
|
const hashlineToolsRecord: Record<string, ToolDefinition> = hashlineEnabled
|
||||||
? { hashline_edit: createHashlineEditTool() }
|
? { edit: createHashlineEditTool() }
|
||||||
: {}
|
: {}
|
||||||
|
|
||||||
const allTools: Record<string, ToolDefinition> = {
|
const allTools: Record<string, ToolDefinition> = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user