Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
1d1be3d
feat(copilot-cli): Initial Commit
DevelopmentCats Sep 29, 2025
de1064e
test(copilot-cli): fix test variable formatting and remove model vali…
DevelopmentCats Sep 29, 2025
42f5e6a
chore: bun run fmt
DevelopmentCats Sep 29, 2025
5f24755
Merge branch 'main' into cat/copilot-cli
DevelopmentCats Sep 30, 2025
8b15765
Merge branch 'main' into cat/copilot-cli
DevelopmentCats Sep 30, 2025
f7c4af5
feat: add system prompt configuration support
DevelopmentCats Sep 30, 2025
151e811
fix: remove unused GitHub external auth data block
DevelopmentCats Sep 30, 2025
ca07248
feat: add back installation step
DevelopmentCats Sep 30, 2025
b880e24
chore: streamline argument handling in build_copilot_args function
DevelopmentCats Sep 30, 2025
3cef733
feat: add external auth ID handling and GitHub authentication setup
DevelopmentCats Sep 30, 2025
ab1e663
feat(copilot-cli): improve GitHub authentication with multiple fallba…
DevelopmentCats Oct 1, 2025
673b201
feat: enhance GitHub authentication with direct token support and imp…
DevelopmentCats Oct 1, 2025
3737c1a
chore: bun run fmt
DevelopmentCats Oct 1, 2025
a62146f
feat: enhance task reporting integration and support for GitHub token…
DevelopmentCats Oct 1, 2025
659a6b2
fix: streamline MCP server configuration
DevelopmentCats Oct 1, 2025
e32b159
chore: bun run fmt
DevelopmentCats Oct 1, 2025
5f1a86c
feat: update configuration setup
DevelopmentCats Oct 1, 2025
a6170e4
fix: update README and install script for Copilot CLI configuration p…
DevelopmentCats Oct 1, 2025
4f5636d
feat: correct MCP configuration with required parameters for GitHub a…
DevelopmentCats Oct 1, 2025
9e3c3ae
fix: simplify MCP server configuration
DevelopmentCats Oct 1, 2025
8cd93ad
fix: move mcp server creation back to manual method
DevelopmentCats Oct 1, 2025
d368522
feat: simplify mcp configuration based on github help docs
DevelopmentCats Oct 1, 2025
f08471f
feat: use hack method for coder mcp server
DevelopmentCats Oct 1, 2025
d460bbb
chore: bun run fmt
DevelopmentCats Oct 1, 2025
dd97065
fix: update MCP server configuration to use local type and allow all …
DevelopmentCats Oct 1, 2025
8151766
fix: update AgentAPI version to v0.8.0 and correct environment variab…
DevelopmentCats Oct 1, 2025
868b0a6
feat: add session resumption support for Copilot CLI and update relat…
DevelopmentCats Oct 1, 2025
994d951
fix: update session directory path for existing Copilot CLI session d…
DevelopmentCats Oct 1, 2025
3c16c5c
feat: update for new agentapi initial prompt, and type
DevelopmentCats Oct 2, 2025
e6a5138
chore: bun run fmt
DevelopmentCats Oct 2, 2025
fac2803
fix: remove system wrapper from system prompt
DevelopmentCats Oct 2, 2025
bff6ec1
docs: cleanup readme, and align with other ai modules
DevelopmentCats Oct 2, 2025
e0d560c
feat: enhance system prompt for Copilot CLI with detailed tool select…
DevelopmentCats Oct 2, 2025
8a4c3c7
chore: update copilot version to 0.1.0
DevelopmentCats Oct 2, 2025
baf61bd
Merge branch 'main' into cat/copilot-cli
DevelopmentCats Oct 2, 2025
b3dda60
test: rewrite tests
DevelopmentCats Oct 2, 2025
032a04d
docs: update README for Copilot CLI module with new MCP server config…
DevelopmentCats Oct 2, 2025
3e4cac5
Update registry/coder-labs/modules/copilot-cli/README.md
DevelopmentCats Oct 3, 2025
d15dd64
chore: update default model for copilot
DevelopmentCats Oct 3, 2025
4786c95
chore: add documentation links
DevelopmentCats Oct 3, 2025
f49d808
docs: update README for Copilot CLI module to include direct token au…
DevelopmentCats Oct 3, 2025
ab83854
docs: clarify standalone mode functionality and usage
DevelopmentCats Oct 3, 2025
dd14436
docs: combine advanced config and custom config examples
DevelopmentCats Oct 3, 2025
7405576
docs: add note on session resumption requirements for Copilot CLI module
DevelopmentCats Oct 3, 2025
24454b4
docs: update Copilot CLI README to clarify task reporting
DevelopmentCats Oct 3, 2025
4e6591b
fix: update copilot model version in tests and tftest file to match t…
DevelopmentCats Oct 3, 2025
a4c7b54
docs: reorder authentication methods in Copilot CLI README for clarity
DevelopmentCats Oct 3, 2025
d161d96
chore: update default AgentAPI version to v0.9.0 in Copilot CLI module
DevelopmentCats Oct 3, 2025
4d1446d
fix: fix unbound variable issue when github_token is not set
DevelopmentCats Oct 3, 2025
f23431c
fix: resolve unbound variable issue for GITHUB_TOKEN in install script
DevelopmentCats Oct 3, 2025
8883636
fix: update Copilot CLI configuration to set banner to 'never'
DevelopmentCats Oct 3, 2025
bb3cb02
fix: enhance Copilot CLI configuration to merge trusted directories w…
DevelopmentCats Oct 3, 2025
7c1b2a4
chore: align directories to match up with examples and tasks
DevelopmentCats Oct 3, 2025
2f65293
fix: improve session resumption logic in Copilot CLI script to identi…
DevelopmentCats Oct 3, 2025
fe83041
fix: redirect session resumption message to stderr in Copilot CLI scr…
DevelopmentCats Oct 3, 2025
5713bda
Merge branch 'main' into cat/copilot-cli
DevelopmentCats Oct 6, 2025
c96194e
chore: rename module from copilot-cli to copilot
DevelopmentCats Oct 6, 2025
5bceee2
Update registry/coder-labs/modules/copilot/README.md
DevelopmentCats Oct 6, 2025
1583557
feat: add copilot_version variable for version control in Copilot mod…
DevelopmentCats Oct 6, 2025
172158f
refactor: change task reporting prompt to be injected after the syste…
DevelopmentCats Oct 6, 2025
e28008d
fix: update task reporting description in Copilot install script for …
DevelopmentCats Oct 7, 2025
4fd0b39
refactor: update task reporting prompt formatting in Copilot module
DevelopmentCats Oct 7, 2025
b7b1fc2
Merge branch 'main' into cat/copilot-cli
DevelopmentCats Oct 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 213 additions & 0 deletions registry/coder-labs/modules/copilot-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
---
display_name: Copilot CLI
description: GitHub Copilot CLI agent for AI-powered terminal assistance
icon: ../../../../.icons/github.svg
verified: false
tags: [agent, copilot, ai, github, cli, tasks]
---

# Copilot CLI

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_cli" {
source = "registry.coder.com/coder-labs/copilot-cli/coder"
version = "0.1.0"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"
}
```

> [!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** (GitHub Copilot Pro, Pro+, Business, or Enterprise)
- **GitHub authentication** via one of:
- Direct token via `github_token` variable
- Coder external authentication (recommended)
- Interactive login in Copilot CLI

## Examples

### Usage with Tasks

For development environments where you want Copilot CLI 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 CLI."
mutable = true
}

module "copilot_cli" {
source = "registry.coder.com/coder-labs/copilot-cli/coder"
version = "0.1.0"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"

github_token = "your_github_token_here" # Or use data.coder_external_auth.github.access_token
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", "/tmp"]
}
```

### Advanced Configuration with Specific Tool Permissions

For more controlled environments where you want to specify exact tools:

```tf
module "copilot_cli" {
source = "registry.coder.com/coder-labs/copilot-cli/coder"
version = "0.1.0"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"

allow_tools = ["shell(git)", "shell(npm)", "write"]
trusted_directories = ["/home/coder/workspace", "/tmp"]

mcp_config = jsonencode({
mcpServers = {
filesystem = {
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/home/coder/workspace"]
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_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

```tf
module "copilot_cli" {
source = "registry.coder.com/coder-labs/copilot-cli/coder"
version = "0.1.0"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"
github_token = "your_github_token_here" # Or use data.coder_external_auth.github.access_token
}
```

### Standalone Mode

Run and configure Copilot CLI as a standalone tool in your workspace.

```tf
module "copilot_cli" {
source = "registry.coder.com/coder-labs/copilot-cli/coder"
version = "0.1.0"
agent_id = coder_agent.example.id
workdir = "/home/coder"
report_tasks = false
cli_app = true
}
```

### Custom Configuration

You can customize the entire Copilot CLI configuration:

```tf
module "copilot_cli" {
source = "registry.coder.com/coder-labs/copilot-cli/coder"
version = "0.1.0"
agent_id = coder_agent.example.id
workdir = "/home/coder/projects"

copilot_config = jsonencode({
banner = "auto"
theme = "dark"
trusted_folders = [
"/home/coder/workspace",
"/home/coder/projects"
]
})
}
```

## Authentication

The module supports multiple authentication methods (in priority order):

1. **Direct Token** - Pass `github_token` variable (OAuth or Personal Access Token)
2. **Coder External Auth** - Automatic if GitHub external auth is configured in Coder
3. **Interactive** - Copilot CLI prompts for login via `/login` command if no auth found

> [!NOTE]
> OAuth tokens work best with Copilot CLI. Personal Access Tokens may have limited functionality.

## Session Resumption

By default, the module resumes the latest Copilot CLI session when the workspace restarts. Set `resume_session = false` to always start fresh sessions.

## Task Reporting

When enabled (default), Copilot CLI can report task progress to the Coder UI using [AgentAPI](https://github.com/coder/agentapi). Custom MCP servers provided via `mcp_config` are merged with the Coder MCP server automatically.

To disable task reporting, set `report_tasks = false`.

## 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 CLI, you must have an active GitHub Copilot subscription.
> The `workdir` variable is required and specifies the directory where Copilot CLI 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)
Loading