Copy to LLM
Streamline your workflow with LLMs using this powerful VS Code extension!
Overview
"Copy to LLM" is a Visual Studio Code extension designed to simplify the process of collecting and formatting code for use with Large Language Models (LLMs) like ChatGPT. With just a few clicks, you can compile the contents of selected files or entire directories into a format that's optimized for LLM input.
Features
- Context Menu Integration: Easily access the extension's functionality by right-clicking on files or folders in the VS Code Explorer.
- Multi-Select Support: Copy contents from multiple files and folders simultaneously.
- Directory Traversal: Recursively collect files from selected directories.
- Customizable File Types: Configure which file extensions to include when processing directories.
- Formatted Output: Generate well-structured content with file paths and appropriate code blocks.
- Clipboard Support: Quickly copy single file contents to your clipboard.
- New Document Creation: Open compiled content in a new VS Code document for easy editing and review.
Installation
- Open Visual Studio Code
- Press
Ctrl+P
(or Cmd+P
on macOS) to open the Quick Open dialog
- Type
ext install Compile-TomaszKasperczyk.copy-to-llm
and press Enter
- Click the Install button
Alternatively, you can install the extension from the Visual Studio Code Marketplace.
Usage
Copy a Single File
- Right-click on a file in the Explorer
- Select "Copy to LLM"
- A new document will open containing the formatted content of the selected file
Process Multiple Files or Folders
- Select multiple files and/or folders in the Explorer (use Ctrl/Cmd+Click for multi-select)
- Right-click on one of the selected items
- Choose "Copy to LLM"
- A new document will open containing the formatted content of all selected items
Process an Entire Folder
- Right-click on a folder in the Explorer
- Select "Copy to LLM"
- A new document will open with the formatted content of all matching files in the folder and its subfolders
You can copy the contents of the new document and paste it as the prompt of your LLM.
Configuration
You can customize which file types are included when processing directories. To do this:
- Open VS Code Settings (File > Preferences > Settings)
- Search for "Copy to LLM"
- Edit the "Copy to LLM: Extensions" setting to add or remove file extensions
Default included extensions:
[".ts", ".tsx", ".mjs", ".ex", ".heex", ".svelte"]
Example Output
When you use "Copy to LLM" on a file or directory, the output will look similar to this:
src/components/Button.tsx:
```tsx
import React from 'react';
const Button = ({ label, onClick }) => (
<button onClick={onClick}>{label}</button>
);
export default Button;
src/utils/helpers.ts:
export const capitalizeString = (str: string): string => {
return str.charAt(0).toUpperCase() + str.slice(1);
};
This format makes it easy to understand the structure of your code when sharing it with an LLM.
Contributing
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository
- Create a new branch for your feature or bug fix
- Make your changes and commit them with a clear commit message
- Push your changes to your fork
- Create a pull request to the main repository
Please ensure your code adheres to the existing style and includes appropriate tests.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
If you encounter any issues or have suggestions for improvements, please open an issue on our GitHub repository.
Acknowledgements
Special thanks to all the contributors and users who have helped improve this extension. Your feedback and support are greatly appreciated!
Made with ❤️ by developers, for developers