Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
Summary
This PR adds a Visual Studio Code extension for Codebase Time Machine (CTM) that enables developers to understand the "why" behind code directly from their editor. Users can select any lines of code, right-click, and get AI-powered explanations that trace the full decision chain from code to commits, PRs, and issues. Key capabilities:
How It Works
Architecture Overview
The extension follows a state-based agent architecture designed for token efficiency:
Extension Entry Point (extension.ts)
ctm.whyDoesThisExistcommandMCP Client (mcpClient.ts)
@modelcontextprotocol/sdkInvestigation Agent (agent.ts)
FactStore (factStore.ts)
Provider System (providers/)
UI Panel (contextPanel.ts)
Core Tools
The extension uses a curated subset of 10 tools (from the 35 available) to minimize schema token overhead (constants.ts:23-43):
get_local_line_context- Primary tool: blame + PR + issues + history in one callget_pr,get_issue- Full PR/issue details with commentssearch_prs_for_commit- Find PR from commit SHAget_github_file_history,get_github_commits_batch- File and commit analysisexplain_file,get_commit_diff- File overview and code change diffspickaxe_search- Find when code was added/removed (git -S equivalent)get_code_owners- Identify code expertsSystem Prompt
The agent uses a dedicated system prompt (SYSTEM_PROMPT.md) that:
Configuration
The extension exposes these settings in VS Code (via package.json contributes):
Server command/args are auto-detected but can be manually overridden with
ctm.serverCommandandctm.serverArgs.Tests
The extension includes unit tests using Mocha with the following coverage:
FactStore Tests (factStore.test.ts)
Provider Tests (providers.test.ts)
GitHub Utilities Tests (github.test.ts)
Constants Tests (constants.test.ts)
Run tests with:
npm testDevelopment Setup
Prerequisites:
cd extensions/vscode npm install npm run compileDebug with F5 in VS Code to launch Extension Development Host. Build for distribution:
npm run package # Creates codebase-time-machine-0.1.0.vsixInstall from VSIX:
Files Changed
Test Plan