fix: resolve process-cleanup signal delay and hashline_edit tool name mismatch
This commit is contained in:
@@ -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")
|
||||
})
|
||||
})
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user