-
Notifications
You must be signed in to change notification settings - Fork 72
feat: New Copilot-CLI Module #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
1d1be3d
feat(copilot-cli): Initial Commit
DevelopmentCats de1064e
test(copilot-cli): fix test variable formatting and remove model vali…
DevelopmentCats 42f5e6a
chore: bun run fmt
DevelopmentCats 5f24755
Merge branch 'main' into cat/copilot-cli
DevelopmentCats 8b15765
Merge branch 'main' into cat/copilot-cli
DevelopmentCats f7c4af5
feat: add system prompt configuration support
DevelopmentCats 151e811
fix: remove unused GitHub external auth data block
DevelopmentCats ca07248
feat: add back installation step
DevelopmentCats b880e24
chore: streamline argument handling in build_copilot_args function
DevelopmentCats 3cef733
feat: add external auth ID handling and GitHub authentication setup
DevelopmentCats ab1e663
feat(copilot-cli): improve GitHub authentication with multiple fallba…
DevelopmentCats 673b201
feat: enhance GitHub authentication with direct token support and imp…
DevelopmentCats 3737c1a
chore: bun run fmt
DevelopmentCats a62146f
feat: enhance task reporting integration and support for GitHub token…
DevelopmentCats 659a6b2
fix: streamline MCP server configuration
DevelopmentCats e32b159
chore: bun run fmt
DevelopmentCats 5f1a86c
feat: update configuration setup
DevelopmentCats a6170e4
fix: update README and install script for Copilot CLI configuration p…
DevelopmentCats 4f5636d
feat: correct MCP configuration with required parameters for GitHub a…
DevelopmentCats 9e3c3ae
fix: simplify MCP server configuration
DevelopmentCats 8cd93ad
fix: move mcp server creation back to manual method
DevelopmentCats d368522
feat: simplify mcp configuration based on github help docs
DevelopmentCats f08471f
feat: use hack method for coder mcp server
DevelopmentCats d460bbb
chore: bun run fmt
DevelopmentCats dd97065
fix: update MCP server configuration to use local type and allow all …
DevelopmentCats 8151766
fix: update AgentAPI version to v0.8.0 and correct environment variab…
DevelopmentCats 868b0a6
feat: add session resumption support for Copilot CLI and update relat…
DevelopmentCats 994d951
fix: update session directory path for existing Copilot CLI session d…
DevelopmentCats 3c16c5c
feat: update for new agentapi initial prompt, and type
DevelopmentCats e6a5138
chore: bun run fmt
DevelopmentCats fac2803
fix: remove system wrapper from system prompt
DevelopmentCats bff6ec1
docs: cleanup readme, and align with other ai modules
DevelopmentCats e0d560c
feat: enhance system prompt for Copilot CLI with detailed tool select…
DevelopmentCats 8a4c3c7
chore: update copilot version to 0.1.0
DevelopmentCats baf61bd
Merge branch 'main' into cat/copilot-cli
DevelopmentCats b3dda60
test: rewrite tests
DevelopmentCats 032a04d
docs: update README for Copilot CLI module with new MCP server config…
DevelopmentCats 3e4cac5
Update registry/coder-labs/modules/copilot-cli/README.md
DevelopmentCats d15dd64
chore: update default model for copilot
DevelopmentCats 4786c95
chore: add documentation links
DevelopmentCats f49d808
docs: update README for Copilot CLI module to include direct token au…
DevelopmentCats ab83854
docs: clarify standalone mode functionality and usage
DevelopmentCats dd14436
docs: combine advanced config and custom config examples
DevelopmentCats 7405576
docs: add note on session resumption requirements for Copilot CLI module
DevelopmentCats 24454b4
docs: update Copilot CLI README to clarify task reporting
DevelopmentCats 4e6591b
fix: update copilot model version in tests and tftest file to match t…
DevelopmentCats a4c7b54
docs: reorder authentication methods in Copilot CLI README for clarity
DevelopmentCats d161d96
chore: update default AgentAPI version to v0.9.0 in Copilot CLI module
DevelopmentCats 4d1446d
fix: fix unbound variable issue when github_token is not set
DevelopmentCats f23431c
fix: resolve unbound variable issue for GITHUB_TOKEN in install script
DevelopmentCats 8883636
fix: update Copilot CLI configuration to set banner to 'never'
DevelopmentCats bb3cb02
fix: enhance Copilot CLI configuration to merge trusted directories w…
DevelopmentCats 7c1b2a4
chore: align directories to match up with examples and tasks
DevelopmentCats 2f65293
fix: improve session resumption logic in Copilot CLI script to identi…
DevelopmentCats fe83041
fix: redirect session resumption message to stderr in Copilot CLI scr…
DevelopmentCats 5713bda
Merge branch 'main' into cat/copilot-cli
DevelopmentCats c96194e
chore: rename module from copilot-cli to copilot
DevelopmentCats 5bceee2
Update registry/coder-labs/modules/copilot/README.md
DevelopmentCats 1583557
feat: add copilot_version variable for version control in Copilot mod…
DevelopmentCats 172158f
refactor: change task reporting prompt to be injected after the syste…
DevelopmentCats e28008d
fix: update task reporting description in Copilot install script for …
DevelopmentCats 4fd0b39
refactor: update task reporting prompt formatting in Copilot module
DevelopmentCats b7b1fc2
Merge branch 'main' into cat/copilot-cli
DevelopmentCats File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
--- | ||
display_name: Copilot | ||
description: GitHub Copilot CLI agent for AI-powered terminal assistance | ||
icon: ../../../../.icons/github.svg | ||
verified: false | ||
tags: [agent, copilot, ai, github, tasks] | ||
--- | ||
|
||
# Copilot | ||
|
||
Run [GitHub Copilot CLI](https://docs.github.com/copilot/concepts/agents/about-copilot-cli) in your workspace for AI-powered coding assistance directly from the terminal. This module integrates with [AgentAPI](https://github.com/coder/agentapi) for task reporting in the Coder UI. | ||
|
||
```tf | ||
module "copilot" { | ||
source = "registry.coder.com/coder-labs/copilot/coder" | ||
version = "0.1.0" | ||
agent_id = coder_agent.example.id | ||
workdir = "/home/coder/projects" | ||
} | ||
``` | ||
|
||
> [!IMPORTANT] | ||
> This example assumes you have [Coder external authentication](https://coder.com/docs/admin/external-auth) configured with `id = "github"`. If not, you can provide a direct token using the `github_token` variable or provide the correct external authentication id for GitHub by setting `external_auth_id = "my-github"`. | ||
|
||
> [!NOTE] | ||
> By default, this module is configured to run the embedded chat interface as a path-based application. In production, we recommend that you configure a [wildcard access URL](https://coder.com/docs/admin/setup#wildcard-access-url) and set `subdomain = true`. See [here](https://coder.com/docs/tutorials/best-practices/security-best-practices#disable-path-based-apps) for more details. | ||
|
||
## Prerequisites | ||
|
||
- **Node.js v22+** and **npm v10+** | ||
- **[Active Copilot subscription](https://docs.github.com/en/copilot/about-github-copilot/subscription-plans-for-github-copilot)** (GitHub Copilot Pro, Pro+, Business, or Enterprise) | ||
- **GitHub authentication** via one of: | ||
- [Coder external authentication](https://coder.com/docs/admin/external-auth) (recommended) | ||
- Direct token via `github_token` variable | ||
- Interactive login in Copilot | ||
|
||
## Examples | ||
|
||
### Usage with Tasks | ||
|
||
For development environments where you want Copilot to have full access to tools and automatically resume sessions: | ||
|
||
```tf | ||
data "coder_parameter" "ai_prompt" { | ||
type = "string" | ||
name = "AI Prompt" | ||
default = "" | ||
description = "Initial task prompt for Copilot." | ||
mutable = true | ||
} | ||
|
||
module "copilot" { | ||
source = "registry.coder.com/coder-labs/copilot/coder" | ||
version = "0.1.0" | ||
agent_id = coder_agent.example.id | ||
workdir = "/home/coder/projects" | ||
|
||
ai_prompt = data.coder_parameter.ai_prompt.value | ||
copilot_model = "claude-sonnet-4.5" | ||
allow_all_tools = true | ||
resume_session = true | ||
|
||
trusted_directories = ["/home/coder/projects", "/tmp"] | ||
} | ||
``` | ||
|
||
### Advanced Configuration | ||
|
||
Customize tool permissions, MCP servers, and Copilot settings: | ||
|
||
```tf | ||
module "copilot" { | ||
source = "registry.coder.com/coder-labs/copilot/coder" | ||
version = "0.1.0" | ||
agent_id = coder_agent.example.id | ||
workdir = "/home/coder/projects" | ||
|
||
# Version pinning (defaults to "0.0.334", use "latest" for newest version) | ||
copilot_version = "latest" | ||
|
||
# Tool permissions | ||
allow_tools = ["shell(git)", "shell(npm)", "write"] | ||
trusted_directories = ["/home/coder/projects", "/tmp"] | ||
|
||
# Custom Copilot configuration | ||
copilot_config = jsonencode({ | ||
banner = "never" | ||
theme = "dark" | ||
}) | ||
|
||
# MCP server configuration | ||
mcp_config = jsonencode({ | ||
mcpServers = { | ||
filesystem = { | ||
command = "npx" | ||
args = ["-y", "@modelcontextprotocol/server-filesystem", "/home/coder/projects"] | ||
description = "Provides file system access to the workspace" | ||
name = "Filesystem" | ||
timeout = 3000 | ||
type = "local" | ||
tools = ["*"] | ||
trust = true | ||
} | ||
playwright = { | ||
command = "npx" | ||
args = ["-y", "@playwright/mcp@latest", "--headless", "--isolated"] | ||
description = "Browser automation for testing and previewing changes" | ||
name = "Playwright" | ||
timeout = 5000 | ||
type = "local" | ||
tools = ["*"] | ||
trust = false | ||
} | ||
} | ||
}) | ||
|
||
# Pre-install Node.js if needed | ||
pre_install_script = <<-EOT | ||
#!/bin/bash | ||
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - | ||
sudo apt-get install -y nodejs | ||
EOT | ||
} | ||
``` | ||
|
||
> [!NOTE] | ||
> GitHub Copilot CLI does not automatically install MCP servers. You have two options: | ||
> | ||
> - Use `npx -y` in the MCP config (shown above) to auto-install on each run | ||
> - Pre-install MCP servers in `pre_install_script` for faster startup (e.g., `npm install -g @modelcontextprotocol/server-filesystem`) | ||
|
||
### Direct Token Authentication | ||
|
||
Use this example when you want to provide a GitHub Personal Access Token instead of using Coder external auth: | ||
|
||
```tf | ||
variable "github_token" { | ||
type = string | ||
description = "GitHub Personal Access Token" | ||
sensitive = true | ||
} | ||
|
||
module "copilot" { | ||
source = "registry.coder.com/coder-labs/copilot/coder" | ||
version = "0.1.0" | ||
agent_id = coder_agent.example.id | ||
workdir = "/home/coder/projects" | ||
github_token = var.github_token | ||
} | ||
``` | ||
|
||
### Standalone Mode | ||
|
||
Run Copilot as a command-line tool without task reporting or web interface. This installs and configures Copilot, making it available as a CLI app in the Coder agent bar that you can launch to interact with Copilot directly from your terminal. Set `report_tasks = false` to disable integration with Coder Tasks. | ||
|
||
```tf | ||
module "copilot" { | ||
source = "registry.coder.com/coder-labs/copilot/coder" | ||
version = "0.1.0" | ||
agent_id = coder_agent.example.id | ||
workdir = "/home/coder" | ||
report_tasks = false | ||
cli_app = true | ||
} | ||
``` | ||
|
||
## Authentication | ||
|
||
The module supports multiple authentication methods (in priority order): | ||
|
||
1. **[Coder External Auth](https://coder.com/docs/admin/external-auth) (Recommended)** - Automatic if GitHub external auth is configured in Coder | ||
2. **Direct Token** - Pass `github_token` variable (OAuth or Personal Access Token) | ||
3. **Interactive** - Copilot prompts for login via `/login` command if no auth found | ||
|
||
> [!NOTE] | ||
> OAuth tokens work best with Copilot. Personal Access Tokens may have limited functionality. | ||
|
||
## Session Resumption | ||
|
||
By default, the module resumes the latest Copilot session when the workspace restarts. Set `resume_session = false` to always start fresh sessions. | ||
|
||
> [!NOTE] | ||
> Session resumption requires persistent storage for the home directory or workspace volume. Without persistent storage, sessions will not resume across workspace restarts. | ||
|
||
## Troubleshooting | ||
|
||
If you encounter any issues, check the log files in the `~/.copilot-module` directory within your workspace for detailed information. | ||
|
||
```bash | ||
# Installation logs | ||
cat ~/.copilot-module/install.log | ||
|
||
# Startup logs | ||
cat ~/.copilot-module/agentapi-start.log | ||
|
||
# Pre/post install script logs | ||
cat ~/.copilot-module/pre_install.log | ||
cat ~/.copilot-module/post_install.log | ||
``` | ||
|
||
> [!NOTE] | ||
> To use tasks with Copilot, you must have an active GitHub Copilot subscription. | ||
> The `workdir` variable is required and specifies the directory where Copilot will run. | ||
|
||
## References | ||
|
||
- [GitHub Copilot CLI Documentation](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli) | ||
- [Installing GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/set-up/install-copilot-cli) | ||
- [AgentAPI Documentation](https://github.com/coder/agentapi) | ||
- [Coder AI Agents Guide](https://coder.com/docs/tutorials/ai-agents) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.