How leonkohli/copy4ai works
Copy4AI is a VS Code extension that packages selected workspace files as a project tree plus file contents for pasting into an LLM. Users initiate copy commands from Explorer, editor tabs, Source Control, or the Command Palette; the extension resolves selections, applies exclusions, reads files or diffs, formats the result, and writes it to the clipboard. Separate documented branches support tree-only copies, force copy, repeat copy, and token warnings. The excerpts show key processing and utility behavior, but not the full command-registration and clipboard-writing code, so some orchestration links rely on README documentation.
Main entry points: extension.ts Command orchestrator · types.ts Shared data types · fileProcessor.ts File processing · uriUtils.ts URI resolution
Components 17
Commands and orchestration
- Command orchestrator
src/extension.ts - Repeat selection state
src/utils/lastCopy.ts
Selection and policy
- Copy settings
src/utils/configuration.ts - Settings migration
src/utils/settingsMigration.ts - Tab selection
src/utils/tabSelection.ts - URI resolution
src/utils/uriUtils.ts - Exclusion rules
src/utils/ignoreUtils.ts
Content and presentation
- File processing
src/utils/fileProcessor.ts - Project tree
src/utils/projectTree.ts - Output formatting
src/utils/formatters.ts - Shared data types
src/types.ts
SCM and assistance
- SCM file contents
src/extension.ts - Git change diffs
src/utils/scmChanges.ts - Token estimate
src/utils/tokenCounter.ts - Copy feedback
src/utils/feedback.ts
Other components
- VS Code user
- VS Code clipboard
Connections 26
- VS Code user → Command orchestrator: runs command
README.md - Command orchestrator → Copy settings: reads settings
src/extension.ts - Command orchestrator → Settings migration: migrates settings
src/extension.ts - Command orchestrator → Tab selection: resolves tabs
README.md - Command orchestrator → URI resolution: resolves paths
src/extension.ts - Command orchestrator → Exclusion rules: applies exclusions
src/extension.ts - Command orchestrator → File processing: reads files
README.md - Command orchestrator → Project tree: generates tree
README.md - Command orchestrator → Git change diffs: requests diffs
README.md - Command orchestrator → SCM file contents: copies changed files
README.md - Command orchestrator → Repeat selection state: stores selection
README.md - Command orchestrator → Output formatting: formats output
README.md - Command orchestrator → VS Code clipboard: writes result
README.md - Command orchestrator → Token estimate: checks token count
README.md - Command orchestrator → Copy feedback: reports completion
src/extension.ts - File processing → Exclusion rules: checks exclusions
src/utils/fileProcessor.ts - File processing → URI resolution: builds relative paths
src/utils/fileProcessor.ts - Project tree → Exclusion rules: checks exclusions
src/utils/projectTree.ts - Project tree → URI resolution: builds relative paths
src/utils/projectTree.ts - Git change diffs → URI resolution: gets file names
src/utils/scmChanges.ts - Token estimate → Copy feedback: reports warnings
src/utils/tokenCounter.ts - Copy settings → Shared data types: uses settings types
src/utils/configuration.ts - File processing → Shared data types: uses content types
src/utils/fileProcessor.ts - Output formatting → Shared data types: formats content types
src/utils/formatters.ts - Token estimate → Shared data types: returns token data
src/utils/tokenCounter.ts - Settings migration → Shared data types: uses exclusion types
src/utils/settingsMigration.ts