Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9c0cf89
feat(registry/coder-labs/modules/copilot): migrate off AgentAPI and C…
35C4n0r Sep 15, 2026
e97afcc
refactor(registry/coder-labs/modules/copilot): remove AI Gateway support
35C4n0r Sep 16, 2026
186d411
fix(registry/coder-labs/modules/copilot): merge mcp-config.json with …
35C4n0r Sep 16, 2026
ddf95a6
refactor(registry/coder-labs/modules/copilot): clear ownership for co…
35C4n0r Sep 16, 2026
8cda4f5
refactor(registry/coder-labs/modules/copilot): drop unnecessary mcpSe…
35C4n0r Sep 16, 2026
18fcc89
feat(registry/coder-labs/modules/copilot): restore AI Bridge Proxy as…
35C4n0r Sep 16, 2026
350c0f8
refactor(registry/coder-labs/modules/copilot): align config to settin…
35C4n0r Sep 24, 2026
7f8585e
Merge remote-tracking branch 'origin/main' into 35C4n0r/copilot-remov…
35C4n0r Sep 24, 2026
94f832a
refactor(registry/coder-labs/modules/copilot): export only COPILOT_GI…
35C4n0r Sep 26, 2026
81c7cc9
refactor(registry/coder-labs/modules/copilot): use managed_settings a…
35C4n0r Sep 27, 2026
a506f01
docs(registry/coder-labs/modules/copilot): trim verbose comments
35C4n0r Sep 27, 2026
efe08bf
fix(registry/coder-labs/modules/copilot): drop invalid 'copilot confi…
35C4n0r Sep 27, 2026
b184220
docs(registry/coder-labs/modules/copilot): use playwright MCP in READ…
35C4n0r Sep 27, 2026
0891ffe
docs(registry/coder-labs/modules/copilot): trim README prerequisites …
35C4n0r Sep 27, 2026
38ba497
docs(registry/coder-labs/modules/copilot): use coder_external_auth da…
35C4n0r Sep 27, 2026
c361d36
docs(registry/coder-labs/modules/copilot): drop proxy-scoping note, b…
35C4n0r Sep 27, 2026
f5db206
refactor(registry/coder-labs/modules/copilot): default copilot_model …
35C4n0r Sep 27, 2026
1874ad9
fix(registry/coder-labs/modules/copilot): apply review suggestions
35C4n0r Sep 28, 2026
37b6673
feat(registry/coder-labs/modules/copilot): add base_copilot_config
35C4n0r Oct 14, 2026
9c0d5e0
refactor(registry/coder-labs/modules/copilot): simplify base config a…
35C4n0r Oct 14, 2026
6c77938
docs(registry/coder-labs/modules/copilot): trim README to examples an…
35C4n0r Oct 14, 2026
f418e16
docs(registry/coder-labs/modules/copilot): use heredoc JSON in README…
35C4n0r Oct 14, 2026
39c8d98
Merge branch 'main' into 35C4n0r/copilot-remove-tasks
DevelopmentCats Oct 14, 2026
a918633
docs(registry/coder-labs/modules/copilot): describe pre/post scripts …
DevelopmentCats Oct 14, 2026
5b4c23a
fix(registry/coder-labs/modules/copilot): preserve config.json when t…
DevelopmentCats Oct 14, 2026
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
265 changes: 108 additions & 157 deletions registry/coder-labs/modules/copilot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,135 +3,66 @@ 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, tasks, ai-gateway]
tags: [agent, copilot, ai, github, ai-gateway]
---

# 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.
Install and configure the [GitHub Copilot CLI](https://docs.github.com/copilot/concepts/agents/about-copilot-cli) in your workspace.

```tf
module "copilot" {
source = "registry.coder.com/coder-labs/copilot/coder"
version = "0.4.2"
version = "1.0.0"
agent_id = coder_agent.example.id
workdir = "/home/coder/projects"
workdir = "/home/coder/project"
}
```

> [!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
> [!WARNING]
> If upgrading from v0.x of this module: v1 is a major refactor that drops support for Coder Tasks and AgentAPI. The module now only installs and configures Copilot; you launch it yourself with a `coder_app` (see below). `copilot_config` is renamed to `base_copilot_config` and now overwrites [`~/.copilot/settings.json`](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-config-dir-reference).

## Examples

### Usage with Tasks
### Launcher app with GitHub external auth

For development environments where you want Copilot to have full access to tools and automatically resume sessions:
This assumes [Coder external authentication](https://coder.com/docs/admin/external-auth) is configured with `id = "github"`.

```tf
data "coder_parameter" "ai_prompt" {
type = "string"
name = "AI Prompt"
default = ""
description = "Initial task prompt for Copilot."
mutable = true
locals {
copilot_workdir = "/home/coder/project"
}

module "copilot" {
source = "registry.coder.com/coder-labs/copilot/coder"
version = "0.4.2"
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"]
data "coder_external_auth" "github" {
id = "github"
}
```

### Advanced Configuration

Customize tool permissions, MCP servers, and Copilot settings:

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

# Version pinning (defaults to "latest", use specific version if desired)
copilot_version = "0.2.3"

# 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
}
}
})
source = "registry.coder.com/coder-labs/copilot/coder"
version = "1.0.0"
agent_id = coder_agent.example.id
workdir = local.copilot_workdir
github_token = data.coder_external_auth.github.access_token
}

# Pre-install Node.js if needed
pre_install_script = <<-EOT
resource "coder_app" "copilot" {
agent_id = coder_agent.example.id
slug = "copilot"
display_name = "Copilot"
icon = "/icon/github-copilot.svg"
open_in = "slim-window"
command = <<-EOT
#!/usr/bin/env bash
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
set -e
cd "${local.copilot_workdir}"
exec copilot --allow-all-tools
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
### Direct token authentication

Use this example when you want to provide a GitHub Personal Access Token instead of using Coder external auth:
`github_token` is exported as `COPILOT_GITHUB_TOKEN`.

```tf
variable "github_token" {
Expand All @@ -142,32 +73,16 @@ variable "github_token" {

module "copilot" {
source = "registry.coder.com/coder-labs/copilot/coder"
version = "0.4.2"
version = "1.0.0"
agent_id = coder_agent.example.id
workdir = "/home/coder/projects"
workdir = "/home/coder/project"
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.4.2"
agent_id = coder_agent.example.id
workdir = "/home/coder"
report_tasks = false
cli_app = true
}
```

### Usage with AI Gateway Proxy

[AI Gateway Proxy](https://coder.com/docs/ai-coder/ai-gateway/ai-gateway-proxy) routes Copilot traffic through [AI Gateway](https://coder.com/docs/ai-coder/ai-gateway) for centralized LLM management and governance.
The proxy environment variables are scoped to the Copilot process only and do not affect other workspace traffic.

```tf
module "aibridge-proxy" {
Expand All @@ -178,66 +93,102 @@ module "aibridge-proxy" {
}

module "copilot" {
source = "registry.coder.com/coder-labs/copilot/coder"
version = "0.4.2"
agent_id = coder_agent.main.id
workdir = "/home/coder/projects"
enable_aibridge_proxy = true
aibridge_proxy_auth_url = module.aibridge-proxy.proxy_auth_url
aibridge_proxy_cert_path = module.aibridge-proxy.cert_path
source = "registry.coder.com/coder-labs/copilot/coder"
version = "1.0.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"
enable_ai_gateway = true
ai_gateway_proxy_auth_url = module.aibridge-proxy.proxy_auth_url
ai_gateway_proxy_cert_path = module.aibridge-proxy.cert_path
}
```

> [!NOTE]
> AI Gateway Proxy is a Premium Coder feature that requires [AI Governance Add-On](https://coder.com/docs/ai-coder/ai-governance).
> See the [AI Gateway Proxy setup guide](https://coder.com/docs/ai-coder/ai-gateway/ai-gateway-proxy/setup) for details on configuring the proxy on your Coder deployment.
> GitHub authentication is still required for Copilot as the proxy authenticates with AI Gateway using the Coder session token, but does not replace GitHub authentication.
### Advanced configuration

> [!IMPORTANT]
> When using AI Gateway Proxy, enable [startup coordination](https://coder.com/docs/admin/templates/startup-coordination) by setting `CODER_AGENT_SOCKET_SERVER_ENABLED=true` in the workspace container environment.
> This ensures the Copilot module waits for the `aibridge-proxy` module to complete before starting. Without it, the Copilot start script may fail if the AI Gateway Proxy setup has not completed in time.
Customize MCP servers, policy, and Copilot settings:

## Authentication
```tf
module "copilot" {
source = "registry.coder.com/coder-labs/copilot/coder"
version = "1.0.0"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"

The module supports multiple authentication methods (in priority order):
copilot_version = "1.0.88"

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
managed_settings = {
model = "claude-sonnet-4.5"
permissions = {
deny = ["Shell(rm -rf *)"]
}
}

base_copilot_config = <<-EOF
{
"banner": "never"
}
EOF

mcp = <<-EOF
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp@latest"],
"type": "local",
"tools": ["*"]
}
}
}
EOF

> [!NOTE]
> OAuth tokens work best with Copilot. Personal Access Tokens may have limited functionality.
pre_install_script = <<-EOT
#!/usr/bin/env bash
npm install -g @playwright/mcp
EOT
}
```

## Session Resumption
### Serialize a downstream `coder_script` after the install pipeline

By default, the module resumes the latest Copilot session when the workspace restarts. Set `resume_session = false` to always start fresh sessions.
The module exposes the `scripts` output: an ordered list of `coder exp sync` names for the scripts this module creates (pre_install, install, post_install). Scripts that were not configured are absent.

> [!NOTE]
> Session resumption requires persistent storage for the home directory or workspace volume. Without persistent storage, sessions will not resume across workspace restarts.
```tf
module "copilot" {
source = "registry.coder.com/coder-labs/copilot/coder"
version = "1.0.0"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"
}

## Troubleshooting
resource "coder_script" "post_copilot" {
agent_id = coder_agent.example.id
display_name = "Run after Copilot install"
run_on_start = true
script = <<-EOT
#!/usr/bin/env bash
set -euo pipefail
trap 'coder exp sync complete post-copilot' EXIT
coder exp sync want post-copilot ${join(" ", module.copilot.scripts)}
coder exp sync start post-copilot

If you encounter any issues, check the log files in the `~/.copilot-module` directory within your workspace for detailed information.
copilot --version
EOT
}
```

```bash
# Installation logs
cat ~/.copilot-module/install.log
## Troubleshooting

# Startup logs
cat ~/.copilot-module/agentapi-start.log
Check the log files in `~/.coder-modules/coder-labs/copilot/logs/` for detailed information.

# Pre/post install script logs
cat ~/.copilot-module/pre_install.log
cat ~/.copilot-module/post_install.log
```bash
cat ~/.coder-modules/coder-labs/copilot/logs/install.log
cat ~/.coder-modules/coder-labs/copilot/logs/pre_install.log
cat ~/.coder-modules/coder-labs/copilot/logs/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)
Loading
Loading