Copilot Chat CLI is a command-line application designed to provide seamless interaction with GitHub Copilot models. It offers a fast, flexible, and interactive way to communicate with Copilot, enabling users to send prompts, process files, and manage chat history directly from the terminal.
This project is built with Rust and leverages asynchronous programming for high performance. It includes features such as file tracking, diff computation, and interactive chat sessions, making it ideal for developers who want to integrate AI-powered assistance into their workflows.
- Interactive Chat: Engage in real-time conversations with Copilot using the CLI.
- File Tracking: Send specific file content or ranges to Copilot for analysis.
- Diff Computation: Automatically compute and send differences between file versions to avoid sending duplicate file information.
- Commit Message Generation: Generate commit messages based on staged changes in your Git repository.
- Model Management: List available Copilot models and switch between them.
- Chat History Management: Save, load, and clear chat history for the current directory.
- Socket-Based Input: Accept input via TCP sockets for advanced integrations.
- Rust (latest stable version)
- Cargo (Rust's package manager)
- GitHub Copilot API credentials
-
Clone the repository:
git clone https://github.com/richardhapb/copilot-chat.git cd copilot-chat
-
Build the project:
cargo build --release
-
Run the binary:
./target/release/copilot-chat
-
Copy to PATH (Unix):
sudo ln -sf $(pwd)/target/release/copilot-chat /usr/local/bin
Start an interactive chat session:
copilot-chat
Send a one-time prompt to Copilot:
copilot-chat --prompt "Tell me a joke"
Or use piping directly
cat myfile.rs | copilot-chat give me feedback on this file
Send a file or file range to Copilot:
copilot-chat --files "/path/to/file:10-20,/path/to/another:30-50,/path/to/some"
Generate a commit message based on staged changes:
copilot-chat commit
List all available Copilot models:
copilot-chat models
Clear the saved chat history for the current directory:
copilot-chat clear
Send input via TCP socket:
- Start the CLI in interactive mode.
- Connect to the socket at
127.0.0.1:4000
and send data.
Specify a model for Copilot:
copilot-chat --model "gpt-4o"
Execute the test suite:
cargo test
src/main.rs
: Entry point for the application.src/chat
: Core chat logic and streaming implementation.src/tools
: Utilities for file handling, diff computation, and CLI execution.src/cli
: Command-line interface and subcommand handling.src/client
: Copilot API client and authentication.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch.
- Submit a pull request with a detailed description of your changes.
This project is licensed under the MIT License.