get_file_context
Retrieve comprehensive file context including sessions, decisions, mistakes, and commits to support manuscript analysis and writing assistance.
Instructions
Get all context for a file (sessions, decisions, mistakes, commits)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | No | Path to manuscript directory (defaults to current directory) | |
| file_path | Yes | File to get context for |
Implementation Reference
- src/tools/WriterToolHandlers.ts:507-511 (handler)The main handler function for the 'get_file_context' MCP tool. Extracts the file_path argument and delegates execution to WritersAid.getFileContext.private async getFileContext(args: Record<string, unknown>) { const filePath = args.file_path as string; return this.writersAid.getFileContext({ filePath }); }
- Input schema and metadata definition for the 'get_file_context' tool, defining parameters like file_path.name: "get_file_context", description: "Get all context for a file (sessions, decisions, mistakes, commits)", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to manuscript directory (defaults to current directory)" }, file_path: { type: "string", description: "File to get context for" }, }, required: ["file_path"], }, },
- Core implementation of getFileContext: performs a holistic search across sessions, decisions, mistakes, and commits layers for the given filePath, then categorizes the results.async getFileContext(filePath: string): Promise<{ recentSessions: SearchResult[]; recentDecisions: SearchResult[]; recentMistakes: SearchResult[]; commits: SearchResult[]; }> { const results = await this.search({ query: filePath, layers: ["sessions", "decisions", "mistakes", "commits"], limit: 5, }); const byLayer = { recentSessions: results.results.filter((r) => r.layer === "sessions"), recentDecisions: results.results.filter((r) => r.layer === "decisions"), recentMistakes: results.results.filter((r) => r.layer === "mistakes"), commits: results.results.filter((r) => r.layer === "commits"), }; return byLayer; }
- src/WritersAid.ts:773-775 (helper)Delegation method in WritersAid class that forwards getFileContext call to the HolisticSearcher instance.async getFileContext(options: { filePath: string }) { return this.holisticSearcher.getFileContext(options.filePath); }
- src/tools/WriterToolHandlers.ts:94-95 (registration)Dispatch case in handleTool switch statement that routes 'get_file_context' calls to the handler method.case "get_file_context": return this.getFileContext(args);