GitHub Copilot
GitHub Copilot CLI integration for AI-powered code assistance.
Hanzo Dev includes comprehensive GitHub Copilot integration for AI-powered code assistance directly from the command line.
Setup
# Install GitHub CLI and Copilot extension
brew install gh
gh auth login
gh extension install github/copilot
# Auto-setup
dev copilot setup --install --authCommands
Interactive Chat
dev copilot chat
dev copilot chat --file src/main.rs
dev copilot chat "How do I implement async/await in Rust?"Code Suggestions
dev copilot suggest "function to sort array"
dev copilot suggest --file main.rs --language rustCode Review
dev copilot review src/lib.rs
dev copilot review main.rs --diff
dev copilot review main.rs --format markdownDocumentation Generation
dev copilot docs "fn calculate_sum(a: i32, b: i32) -> i32" --type comment
dev copilot docs src/ --type readme --output README.md
dev copilot docs api.rs --type apiCode Explanation
dev copilot explain "async fn fetch_data() -> Result<String, Error>"
dev copilot explain --file complex_algorithm.rs
dev copilot explain --level expert "impl Iterator for MyStruct"Shell Commands
dev copilot shell "find all Rust files and check them with clippy"
dev copilot shell --os macos "compress directory into tar.gz"
dev copilot shell --explain "backup database and compress"Git Integration
dev copilot commit --staged
git diff | dev copilot commit --diff -
dev copilot commit --style conventionalConfiguration
# ~/.hanzo/config.toml
[copilot]
enabled = true
auto_suggest = false
code_review = true
chat_enabled = true
model = "gpt-4"
max_tokens = 4096
context_window = 10000Git Hooks
Pre-commit
#!/bin/sh
# .git/hooks/pre-commit
dev copilot review --diff $(git diff --cached --name-only)Commit Message
#!/bin/sh
# .git/hooks/prepare-commit-msg
if [ -z "$2" ]; then
dev copilot commit --staged > "$1"
fiCI/CD
name: AI Code Review
on: [pull_request]
jobs:
copilot-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Hanzo Dev
run: npm install -g @hanzo/dev
- name: Review Changes
run: dev copilot review --diff --format markdown > review.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}