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:
2026-05-15 15:15:48 +00:00
parent 124beae2bc
commit 890d229875
6 changed files with 467 additions and 71 deletions

View File

@@ -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: {