This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A VS Code extension ("Partial Diff") that lets users compare text selections within a file, across files, or against the clipboard using VS Code's built-in diff viewer.
npm test— run all tests (mocha, TDD style)npm test -- --grep "pattern"— run a single test by namenpm run lint— tslintnpm run compile:dev— webpack dev buildnpm run compile:prod— clean + webpack prod build (output:dist/extension.js)npm run watch— webpack dev build in watch modenpm run prep— full pre-PR check (compile:prod + lint + test)npm run coverage— nyc coverage report
- Store git worktrees under
.git-worktrees/<branch_name>relative to the repository root. <branch_name>must not contain/. Use a slash-free branch name when creating worktrees.
Entry flow: src/extension.ts → BootstrapperFactory → Bootstrapper → registers commands and content provider with VS Code.
Adaptor pattern: All VS Code API access is wrapped in adaptors (src/lib/adaptors/) so the core logic is testable without VS Code. TextEditor, WindowAdaptor, WorkspaceAdaptor, and CommandAdaptor each wrap a corresponding VS Code API surface.
Command pattern: Each user action is a Command (interface in src/lib/commands/command.ts) created by CommandFactory. Commands are either TEXT_EDITOR type (receive the active editor) or GENERAL type.
Diff flow: Commands store selections in SelectionInfoRegistry (keyed by text keys: reg1, reg2, clipboard, visible1, visible2). When a diff is requested, DiffPresenter builds partialdiff:// URIs and calls vscode.diff. VS Code then calls ContentProvider.provideTextDocumentContent() to resolve the URI back to text, applying normalization rules via TextProcessRuleApplier.
Text normalization: NormalisationRuleStore loads rules from user config and tracks active/inactive state. TextProcessRuleApplier applies active rules to text before it enters the diff view. The diff title uses ~ instead of ↔ when normalization is active.
- Framework: Mocha with TDD interface (
suite/test, notdescribe/it) - Mocking: testdouble (
td) — helpers insrc/test/helpers.tsprovidemock(),mockType(),mockMethods(),verify,when,contains,any, andwrapVerify - Test location:
src/test/mirrorssrc/lib/structure - Execution: Tests run directly via ts-node (not compiled first)