feat(ui): 实现 @ 文件提及自动补全功能

- Core: 添加 file-index 模块,使用 ripgrep 索引文件,fuzzysort 模糊搜索
- Server: 添加 /api/files/search 端点,支持文件模糊搜索
- Server: WebSocket 消息处理中将 @filepath 转换为 ./filepath 格式
- UI: 新增 FileMenu 组件,显示文件搜索结果列表
- UI: 新增 FileMentionTag 组件,高亮显示文件提及
- UI: 新增 useFileMention hook,管理文件提及状态
- UI: ChatInput 集成 @ 触发的文件自动补全
- UI: ChatMessage 用户消息中高亮显示 @filepath
This commit is contained in:
2025-12-15 16:32:59 +08:00
parent 5b7b0ff1e4
commit 865e0906b9
15 changed files with 1137 additions and 53 deletions
+23
View File
@@ -48,6 +48,8 @@ import type {
// Context types
ContextUsageInfo,
CompressionResult,
// File search types
FileSearchResponse,
} from './types.js';
// Re-export types
@@ -124,6 +126,9 @@ export type {
CompressionResult,
// WebSocket error types
ConfigErrorPayload,
// File search types
FileSearchResult,
FileSearchResponse,
} from './types.js';
// API Configuration
@@ -974,3 +979,21 @@ export async function compressContext(
}> {
return request('POST', `/sessions/${encodeURIComponent(sessionId)}/compress`, options || {});
}
// ============ File Search API ============
/**
* 模糊搜索项目文件
*/
export async function searchFiles(
query: string = '',
limit: number = 10,
type: 'file' | 'directory' | 'all' = 'file'
): Promise<FileSearchResponse> {
const params = new URLSearchParams({
query,
limit: String(limit),
type,
});
return request('GET', `/files/search?${params}`);
}