get_history_stats
Retrieve detailed statistics on local file history, including total files and entries, to enhance context awareness and track version history efficiently.
Instructions
Get statistics about the local history (total files, entries, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:470-487 (handler)The handler function for the 'get_history_stats' tool. It calls the history parser to get stats and formats a textual response with the statistics.private async getHistoryStats() { const stats = this.historyParser.getHistoryStats(); return { content: [ { type: 'text', text: '📊 Local History Statistics\n\n' + `History directory: ${stats.historyDirPath}\n` + `Directory exists: ${stats.historyDirExists ? '✅' : '❌'}\n` + `Total files with history: ${stats.totalFiles}\n` + `Total history entries: ${stats.totalEntries}\n` + `Average entries per file: ${stats.totalFiles > 0 ? (stats.totalEntries / stats.totalFiles).toFixed(1) : 'N/A'}`, }, ], }; }
- src/index.ts:131-135 (schema)Input schema definition for the 'get_history_stats' tool, specifying no required parameters.inputSchema: { type: 'object', properties: {}, additionalProperties: false, },
- src/index.ts:127-136 (registration)Tool registration in the ListToolsRequestHandler response, including name, description, and input schema.{ name: 'get_history_stats', description: 'Get statistics about the local history (total files, entries, etc.)', inputSchema: { type: 'object', properties: {}, additionalProperties: false, }, },
- src/history-parser.ts:259-277 (helper)Supporting method in VSCodeHistoryParser that computes the actual history statistics by iterating over all file histories.public getHistoryStats(): { totalFiles: number; totalEntries: number; historyDirExists: boolean; historyDirPath: string; } { const histories = this.getAllFileHistories(); const totalEntries = histories.reduce( (sum, history) => sum + history.entries.length, 0, ); return { totalFiles: histories.length, totalEntries, historyDirExists: this.historyDirectoryExists(), historyDirPath: this.historyDir, }; }