mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
feat: 实现 Tool Search 基础设施层(CORE_TOOLS 白名单 + TF-IDF 索引 + ExecuteTool + 搜索增强)
- 新增 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>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// biome-ignore-all assist/source/organizeImports: ANT-ONLY import markers must not be reordered
|
||||
import type { ToolDiscoveryResult } from '../services/toolSearch/prefetch.js'
|
||||
import {
|
||||
logEvent,
|
||||
type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
|
||||
@@ -97,6 +98,12 @@ const skillSearchModules = feature('EXPERIMENTAL_SKILL_SEARCH')
|
||||
require('../services/skillSearch/prefetch.js') as typeof import('../services/skillSearch/prefetch.js'),
|
||||
}
|
||||
: null
|
||||
const toolSearchModules = feature('EXPERIMENTAL_TOOL_SEARCH')
|
||||
? {
|
||||
prefetch:
|
||||
require('../services/toolSearch/prefetch.js') as typeof import('../services/toolSearch/prefetch.js'),
|
||||
}
|
||||
: null
|
||||
const autoModeStateModule = feature('TRANSCRIPT_CLASSIFIER')
|
||||
? (require('./permissions/autoModeState.js') as typeof import('./permissions/autoModeState.js'))
|
||||
: null
|
||||
@@ -553,6 +560,14 @@ export type Attachment =
|
||||
activePath?: string
|
||||
}
|
||||
}
|
||||
| {
|
||||
type: 'tool_discovery'
|
||||
tools: ToolDiscoveryResult[]
|
||||
trigger: 'assistant_turn' | 'user_input'
|
||||
queryText: string
|
||||
durationMs: number
|
||||
indexSize: number
|
||||
}
|
||||
| {
|
||||
type: 'queued_command'
|
||||
prompt: string | Array<ContentBlockParam>
|
||||
@@ -830,6 +845,25 @@ export async function getAttachments(
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
// Tool discovery on turn 0. Inter-turn discovery runs via
|
||||
// startToolSearchPrefetch in query.ts.
|
||||
...(feature('EXPERIMENTAL_TOOL_SEARCH') &&
|
||||
toolSearchModules &&
|
||||
!options?.skipSkillDiscovery
|
||||
? [
|
||||
maybe('tool_discovery', async () => {
|
||||
if (suppressNextDiscovery) {
|
||||
return []
|
||||
}
|
||||
const result =
|
||||
await toolSearchModules.prefetch.getTurnZeroToolSearchPrefetch(
|
||||
input,
|
||||
context.options.tools ?? [],
|
||||
)
|
||||
return result ? [result] : []
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
]
|
||||
: []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user