fix: resolve process-cleanup signal delay and hashline_edit tool name mismatch

This commit is contained in:
YeonGyu-Kim
2026-03-31 16:59:04 -07:00
parent 9f2c4500e8
commit 7d6f47bf3d
4 changed files with 193 additions and 115 deletions
+29
View File
@@ -0,0 +1,29 @@
import { describe, expect, test } from "bun:test"
import { tool } from "@opencode-ai/plugin"
import type { ToolsRecord } from "./types"
import { trimToolsToCap } from "./tool-registry"
const fakeTool = tool({
description: "test tool",
args: {},
async execute(): Promise<string> {
return "ok"
},
})
describe("#given tool trimming prioritization", () => {
test("#when max_tools trims a hashline edit registration named edit #then edit is removed before higher-priority tools", () => {
const filteredTools = {
bash: fakeTool,
edit: fakeTool,
read: fakeTool,
} satisfies ToolsRecord
trimToolsToCap(filteredTools, 2)
expect(filteredTools).not.toHaveProperty("edit")
expect(filteredTools).toHaveProperty("bash")
expect(filteredTools).toHaveProperty("read")
})
})
+2 -2
View File
@@ -54,7 +54,7 @@ const LOW_PRIORITY_TOOL_ORDER = [
"task_update",
"background_output",
"background_cancel",
"hashline_edit",
"edit",
"ast_grep_replace",
"ast_grep_search",
"glob",
@@ -70,7 +70,7 @@ const LOW_PRIORITY_TOOL_ORDER = [
"lsp_diagnostics",
] as const
function trimToolsToCap(filteredTools: ToolsRecord, maxTools: number): void {
export function trimToolsToCap(filteredTools: ToolsRecord, maxTools: number): void {
const toolNames = Object.keys(filteredTools)
if (toolNames.length <= maxTools) return