mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
- 新增 CORE_TOOLS 白名单常量(31 个核心工具),重构 isDeferredTool 为白名单制判定 - 新建 TF-IDF 工具索引模块(toolIndex.ts),复用 localSearch.ts 算法函数 - 新建 ExecuteTool 跨 API provider 统一工具执行入口 - 增强 ToolSearchTool:TF-IDF 搜索路径、discover: 模式、并行搜索合并、文本模式回退 - 新增 27 个单元测试,precheck 零错误通过(4108 tests pass) Co-Authored-By: glm-5.1[1m] <zai-org@claude-code-best.win>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
/**
|
|
* ExecuteTool.test.ts
|
|
*
|
|
* Thin subprocess wrapper that runs the actual tests in an isolated bun:test
|
|
* process. This prevents mock.module() leaks from other test files
|
|
* (e.g., agentToolUtils.test.ts mocking src/Tool.js) from affecting
|
|
* ExecuteTool's tests.
|
|
*/
|
|
|
|
import { describe, test, expect } from 'bun:test'
|
|
import { resolve, relative } from 'path'
|
|
|
|
const PROJECT_ROOT = resolve(__dirname, '..', '..', '..', '..', '..')
|
|
const RUNNER_ABS = resolve(__dirname, 'ExecuteTool.runner.ts')
|
|
const RUNNER_REL = './' + relative(PROJECT_ROOT, RUNNER_ABS).replace(/\\/g, '/')
|
|
|
|
describe('ExecuteTool', () => {
|
|
test('runs all ExecuteTool tests in isolated subprocess', async () => {
|
|
const proc = Bun.spawn(['bun', 'test', RUNNER_REL], {
|
|
cwd: PROJECT_ROOT,
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
})
|
|
const code = await proc.exited
|
|
if (code !== 0) {
|
|
const stderr = await new Response(proc.stderr).text()
|
|
const stdout = await new Response(proc.stdout).text()
|
|
const output = (stderr + '\n' + stdout).slice(-3000)
|
|
throw new Error(
|
|
`ExecuteTool test subprocess failed (exit ${code}):\n${output}`,
|
|
)
|
|
}
|
|
}, 60_000)
|
|
})
|