A VSCode extension that graphically visualizes code dependencies and structure for TypeScript/JavaScript.
- Analyzes dependencies at function, class, and method levels
- Interactive D3.js graph rendered inside the VSCode sidebar
- Click any node to jump to that file (with cursor positioned at the symbol)
- Language Model Tool API integration so AI agents can drive the visualization
This is the easiest method during development.
- Install dependencies
npm install- Compile TypeScript
npm run compile- Launch the Extension Development Host
- Open this project in VSCode
- Press
F5, or - Select "Run Extension" from the Debug panel (
Cmd+Shift+D) and run it
- A new VSCode window opens
- This window is the Extension Development Host
- The extension runs in this window
- Use the extension
- The "LLM Code Map" view appears in the Explorer sidebar
- Click the refresh button to run code analysis
Use this method if you want to try it in a production-like environment.
- Install vsce (first time only)
npm install -g @vscode/vsce- Create a .vsix file
vsce packageThis produces codemap-<version>.vsix.
- Install in VSCode
- Press
Cmd+Shift+P(Mac) orCtrl+Shift+P(Windows/Linux) - Select "Extensions: Install from VSIX..."
- Pick the
.vsixfile
- Enable the extension
- Find "LLM Code Map" in the Extensions panel and enable it
- Reload VSCode
- Open the "LLM Code Map" view in the sidebar
- Click the refresh button
- The graph is displayed
Mention it in chat:
- "Visualize the dependencies of this project"
- "Display the code structure using #codemap"
The extension contributes a tool named codemap_analyze that an LLM can call directly. There are two ways to use it:
When the calling LLM has already analyzed the code, it can hand the graph in as-is and skip a full workspace scan:
{
"nodes": [
{ "id": "file:src/server.ts", "label": "server.ts", "type": "file" },
{
"id": "function:src/server.ts:listRooms",
"label": "listRooms",
"type": "function",
"filePath": "src/server.ts"
}
],
"edges": [
{
"source": "file:src/server.ts",
"target": "function:src/server.ts:listRooms",
"type": "reference",
"label": "contains"
}
]
}If the LLM only knows file/function/class names, it can pass hints and let the extension parse and filter:
| Parameter | Type | Purpose |
|---|---|---|
workspacePath |
string |
Absolute path of the workspace to analyze (defaults to current). |
filePattern |
string |
Glob to restrict analysis (defaults to **/*.{ts,tsx,js,jsx}). |
targetFile |
string |
Single file to focus on. |
relatedFiles |
string[] |
Additional files to keep in the graph (relative paths or basenames). |
relatedFunctions |
Array<{ name; filePath? }> |
Functions to include and BFS-expand connections from. |
relatedClasses |
Array<{ name; filePath? }> |
Classes to include (with their methods). |
focusNodes |
string[] |
Specific node IDs (file:..., function:...:name, etc.) to focus on. |
nodes / edges |
see above | Direct spec — when supplied, skips the discovery filtering entirely. |
file:<absolute-or-relative-path>function:<path>:<name>class:<path>:<name>method:<path>:<className>.<methodName>
import(file → file)export(file → file)call(function → function)extends(class → class)implements(class → interface)reference(file → contained function/class/method)
TypeScriptAnalyzer ──► DependencyExtractor ──► CodemapViewProvider ──► Webview (D3.js)
(TS Compiler API) (build nodes/edges) (post graph data) (force-directed)
analyzer/TypeScriptAnalyzer.ts— walks each source file with the TS Compiler API and extracts functions, classes, methods, imports, exports.analyzer/DependencyExtractor.ts— turns the raw analysis intoGraphNode[]+GraphEdge[]. Also handles LLM-context filtering and the directcreateGraphFromLLMSpecfast path.visualizer/CodemapViewProvider.ts—WebviewViewProviderfor the sidebar. Renders D3.js inline and bridges messages between the host and webview.visualizer/graphDataTransformer.ts— single source of truth for node/edge colors and the GraphData → D3 shape conversion.tools/codemapTool.ts— implements thecodemap_analyzeLanguage Model Tool.utils/logger.ts— wrapper aroundvscode.window.createOutputChannel('LLM Code Map').
codemap/
├── src/
│ ├── extension.ts # Entry point
│ ├── analyzer/ # TS analysis + graph extraction
│ ├── visualizer/ # WebviewViewProvider + D3 transform
│ ├── tools/ # Language Model Tool
│ └── utils/ # Logger, file/path helpers
├── media/ # d3.v7.min.js shipped to the webview
└── out/ # Compiled output
npm run compile— compile TypeScriptnpm run watch— compile in watch modenpm run lint— run ESLint (flat config)npm run format/npm run format:check— Prettier write / check
Extension-host logs are written to the LLM Code Map channel in the Output panel (View → Output). Webview-side logs still go to the webview's console — use the Developer Tools window opened from the Extension Development Host.
- Only TypeScript/JavaScript files are parsed (
.ts,.tsx,.js,.jsx). - The graph is rendered inline as part of the webview HTML, so very large workspaces (thousands of nodes) will be slow to lay out.
- Call edges use a simplified caller-attribution heuristic (any function node in the same file) — accurate enclosing-function detection is not implemented yet.
importresolution uses suffix matching against discovered files and may miss aliased paths (e.g. tsconfigpathsmappings).
- Reload VSCode (
Cmd+RorCtrl+R) - Check the Explorer sidebar
- Check for errors in the LLM Code Map output channel
- Verify a workspace is open
- Verify TypeScript/JavaScript files exist
- Click the refresh button
MIT
