This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Git Graph Plus is a VS Code extension that provides a full-featured Git GUI — commit graph visualization, branch/tag/stash/worktree management, diff viewer, and more. It uses a two-process architecture: a Node.js extension host (backend) and a Svelte 5 webview (frontend).
# Install dependencies (both root and webview-ui)
npm install && cd webview-ui && npm install && cd ..
# Build everything (extension + webview)
npm run build
# Development mode (watches both extension and webview)
npm run dev
# Build individually
npm run build:extension # esbuild bundles src/extension.ts → dist/extension.js
npm run build:webview # vite builds webview-ui → webview-ui/dist
# Type checking (no emit)
npm run lint # runs tsc --noEmit on the extension
# Webview type checking
cd webview-ui && npm run check # runs svelte-check
# Tests
npm test # vitest run (all: backend + webview projects)
npm run test:watch # vitest in watch mode
npx vitest run --project backend # only extension-host tests
npx vitest run --project webview # only Svelte/webview tests
npx vitest run src/git/__tests__/git-service.test.ts # single test file
# Package for marketplace
npm run package # vsce package → .vsix fileextension.ts— Entry point. Registers commands, tree views, file watcher, auto-fetch timer.git/git-service.ts— Core Git operations (wrapsgitCLI via child_process). This is the central hub (~90KB); nearly all git commands go through it.git/git-parser.ts— Parses raw git output (log, diff, branch list, etc.) into typed structures.git/git-graph-builder.ts— Builds the visual graph layout (rail assignment, merge lines) from parsed commits.git/patch-builder.ts— Builds patches for reverse-changes (undo file/hunk/line against working tree) and.patchexport.git/git-error-formatter.ts— Normalizes raw git stderr into user-facing error messages.git/git-binary.ts— Holds the resolved path to thegitexecutable (module-level, defaults to'git'on PATH).extension.tsresolves VS Code'sgit.pathsetting at activation and callssetGitBinaryPathso all spawn sites pick it up (matters on Windows portable/MSYS2 installs).git/vscode-git-bridge.ts— Bridges to the built-invscode.gitextension API (only the bits we use) to delegate credential auth on fetch/push.git/types.ts— Shared TypeScript types for git data structures.panels/MainPanel.ts— VS Code WebviewPanel host. Routes messages between the webview and GitService.utils/message-bus.ts— Typed message definitions for Extension ↔ Webview communication (discriminated union types).services/file-watcher.ts— Watches.git/directory for changes and triggers auto-refresh (file-watcher-helpers.tsresolves git dirs / classifies paths).services/repo-discovery.ts— Discovers git repos and submodules in the workspace.services/avatar-cache.ts— Caches Gravatar avatars for commit authors.views/— TreeDataProviders for the Activity Bar sidebar (branches, remotes, tags, stashes, worktrees).
- Svelte 5 (runes) with Vite, outputs to
webview-ui/dist/. src/App.svelte— Root component; routes between Graph, Reflog, and Stats views.src/components/graph/— CommitGraph, CommitNode, BranchLine — canvas-based graph rendering.src/components/commit/— CommitDetails panel with diff viewer (uses Shiki for syntax highlighting).src/components/modals/— Modal dialogs for git operations (create branch, merge, rebase, etc.).src/components/layout/— Toolbar and BottomPanel layout components.src/components/common/— Shared UI: context menus, search bar, image diff, stats view, bisect banner.src/components/rebase/— Interactive rebase UI with drag-to-reorder.src/lib/stores/— Svelte stores for shared state management.src/lib/actions/— Svelteuse:actions (e.g. drag-to-rebase/merge interactions).src/lib/i18n/— Frontend internationalization (en.ts,ko.ts,zh.ts).src/lib/vscode-api.ts— Typed wrapper foracquireVsCodeApi()messaging.
All communication is via postMessage / onDidReceiveMessage. Message types are defined in src/utils/message-bus.ts (WebviewMessage for webview→extension, ExtensionMessage for extension→webview). MainPanel.ts is the message router that dispatches webview requests to GitService.
⚠️ Svelte 5$statevalues are reactive proxies. Passing one directly topostMessagethrowsDataCloneError(silently failing). Spread/snapshot the value ($state.snapshot(...)or{ ...value }) before posting.
- Extension strings:
l10n/bundle.l10n.json(English),l10n/bundle.l10n.ko.json(Korean),l10n/bundle.l10n.zh-cn.json(Chinese Simplified), using VS Code'svscode.l10n.t(). - Webview strings:
webview-ui/src/lib/i18n/—en.ts,ko.ts,zh.ts. - Git terms (commit, merge, rebase, push, pull, fetch) are intentionally left untranslated.
- Extension is bundled with esbuild (CJS, Node target). Webview is bundled with Vite (ESM, browser target).
vscodeis an external dependency (not bundled) — provided by the VS Code runtime.git/modules stay free of anyvscodeimport so GitService and parsers remain unit-testable against the real git CLI. Anything vscode-aware (settings, the built-in git extension API) lives inextension.ts/panels/or a dedicated bridge (vscode-git-bridge.ts) and is injected in (e.g.setGitBinaryPath).- Guard rapid async with
utils/sequence-guard.ts(SequenceGuard):issue()a ticket before a request, and only apply the result if the ticketisCurrent()after the await — prevents a late-finishing older request (rapid clicks on different commits/files) from overwriting a newer one. - User-facing settings live under the
gitGraphPlus.*namespace and are read viautils/config.ts(e.g.timeoutseconds →GitService.setDefaultTimeout, initial/load-more commit counts). Add new settings topackage.jsoncontributes.configurationand read them through there. - The extension activates on
onStartupFinished; on activation it discovers repos in the workspace and is a no-op when none exist. - Tests use Vitest, split into two projects in
vitest.config.mts:backend— extension-host code (src/**/*.test.ts), node env, runs against the realgitCLI. Integration tests insrc/git/__tests__/integration/spawn real git/git-flow/git-lfs and use a 30s timeout.webview— Svelte components/stores (webview-ui/src/**/*.test.ts), happy-dom env.npm testruns both. Coverage is uploaded to Codecov; vscode-bound modules (extension.ts,panels/, canvas/shiki webview code) are excluded from the % — see the comments invitest.config.mts.
- Staging, committing, and inline blame are intentionally delegated to VS Code's built-in Source Control; Git Graph+ focuses on everything else.