Skip to content

Extension Host

Gourav Mittal edited this page Oct 11, 2026 · 17 revisions

The VS Code side: commands, settings, editors, and supervising the daemon. Lives in extension/src.

File Owns
extension.ts Commands, context keys, settings, the status bar, opening editors, and the open editor tabs is:open matches
daemon.ts Spawns the daemon: handshake, crash restarts (up to 3 a minute), restarting one that stops answering while requests wait, graceful stop
jsonRpc.ts The JSON-RPC client: Content-Length framing that finds the next frame again after stray output or a miscounted body, and writes that wait while the daemon isn't reading, a newer settings, watches or roots notification replacing an older one still waiting
controller.ts Turns panel messages into daemon calls. No vscode import, so it's tested against the real daemon in plain Node
syntaxColors.ts, colorTheme.ts Syntax colors as the editor's: vscode-textmate (VS Code's grammar engine) runs the grammars the installed extensions contribute with the color theme's token colors, read from the theme's file and editor.tokenColorCustomizations. No vscode import
syntaxLines.ts, syntaxSource.ts Which lines of code a batch or preview shows, colored after it is posted (syntax.lines), and colored again when the theme, the extensions or the setting change
savedState.ts What a window keeps across reloads: the box's text and the recent queries, each with the question Ask wrote it for, and the query left in the box going under Recent when the window opens again
watches.ts What query watches found since each query last ran, saved in the workspace's state, and the pop-up's text
replaceEdits.ts The one write path: reads a replace's files 16 at a time and keeps those whose lines still read as indexed, editing a file the plan lists twice once; extension.ts applies the edits as one WorkspaceEdit
webviewMessages.ts Defines what webviews may post and validates each message; the webview isn't trusted
panel.ts, helpPanel.ts, welcomePanel.ts Host the search panel, help page and welcome page, each opened by webviewPanel.ts on webviewPage.ts
resultMenu.ts The result menu: its commands (the right-click menu on a result, contributed as webview/context), the clipboard, browser, pop-ups and save dialog they use, remotes.state each time the panel gets its state, and the vscode://spelunk.spelunk/search?q= link handler
folderSearch.ts, folderScope.ts Search in Folder: the Explorer's right-clicked folders, a second pick joining the first, and the notes folder/explain gives. folderScope.ts writes the anchored f:/repo: scope, escaped for any folder name, with no vscode import
editorNavigation.ts, navigation.ts VS Code's Go to Symbol in Workspace, Go to Definition and Find References from the index, as spelunk.editor.* says: symbols/find for definitions, ref: for uses. navigation.ts decides what to ask, with no vscode import
editorSeed.ts, seedQuery.ts Searching from the editor: Spelunk: Open with its key's { fromEditor: true }, and Find Definitions and Find Uses for the name at the cursor. seedQuery.ts turns the selection or name into a query, with no vscode import
resultActions.ts, resultText.ts, permalinks.ts, allResults.ts What each item does, what Copy and the exports write, each Git host's link format from what link/resolve names, and every result of a query for an export, page by page. No vscode import
commitDocuments.ts, commitText.ts Show commits as read-only diffs
revisionDocuments.ts, revisionPath.ts Show a file as it was at a revision (an at: result), read-only, and name its diff against the file now
agentAccess.ts, commandInstall.ts The spelunk command and agents (Agents and the Terminal): Install 'spelunk' Command in PATH, Add to Claude Code and its CLAUDE.md note, Spelunk's MCP server for VS Code's agents, and ~/.spelunk/cli.json, the settings the command's reader uses. commandInstall.ts has no vscode import
e2e/ End-to-end tests run in a real VS Code by scripts/e2e.mjs

Logs go to the Spelunk output channel.

Clone this wiki locally