batch3 T4: file_ops + file_index services; UI endpoints; tools refactor
- services/file_ops.ts: shared listDir/viewFile/grep/findFiles core - services/file_index.ts: per-project flat file list cached on mtime of project root + .git/HEAD + .git/index (rg --files honors .gitignore) - services/tools.ts: tools delegate to file_ops, output format unchanged - routes/projects.ts: GET /list_dir, /view_file, /files endpoints - web client: api.projects.listDir/viewFile/files + mirrored types Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import type {
|
||||
Message,
|
||||
ModelInfo,
|
||||
SidebarResponse,
|
||||
ListDirResult,
|
||||
ViewFileResult,
|
||||
} from './types';
|
||||
|
||||
export class ApiError extends Error {
|
||||
@@ -47,6 +49,12 @@ export const api = {
|
||||
}),
|
||||
remove: (id: string) =>
|
||||
request<void>(`/api/projects/${id}`, { method: 'DELETE' }),
|
||||
listDir: (id: string, path: string) =>
|
||||
request<ListDirResult>(`/api/projects/${id}/list_dir?path=${encodeURIComponent(path)}`),
|
||||
viewFile: (id: string, path: string) =>
|
||||
request<ViewFileResult>(`/api/projects/${id}/view_file?path=${encodeURIComponent(path)}`),
|
||||
files: (id: string) =>
|
||||
request<{ files: string[] }>(`/api/projects/${id}/files`),
|
||||
},
|
||||
|
||||
sessions: {
|
||||
|
||||
@@ -77,6 +77,25 @@ export interface SidebarResponse {
|
||||
projects: SidebarProject[];
|
||||
}
|
||||
|
||||
export interface FileEntry {
|
||||
name: string;
|
||||
kind: 'file' | 'dir';
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export interface ListDirResult {
|
||||
entries: FileEntry[];
|
||||
truncated: boolean;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface ViewFileResult {
|
||||
content: string;
|
||||
truncated: boolean;
|
||||
total_bytes: number;
|
||||
bytes_returned: number;
|
||||
}
|
||||
|
||||
export type WsFrame =
|
||||
| { type: 'snapshot'; messages: Message[] }
|
||||
| { type: 'message_started'; message_id: string; role: MessageRole }
|
||||
|
||||
Reference in New Issue
Block a user