Skip to content

Commit 139e578

Browse files
committed
Merge branch 'main' into mes/new-readme-files
2 parents 0bfbc66 + 496b09d commit 139e578

File tree

27 files changed

+1046
-143
lines changed

27 files changed

+1046
-143
lines changed

.icons/devcontainers.svg

Lines changed: 2 additions & 0 deletions
Loading

.icons/windsurf.svg

Lines changed: 3 additions & 0 deletions
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "modules",
2+
"name": "registry",
33
"scripts": {
44
"fmt": "bun x prettier --write **/*.sh **/*.ts **/*.md *.md && terraform fmt -recursive -diff",
55
"fmt:ci": "bun x prettier --check **/*.sh **/*.ts **/*.md *.md && terraform fmt -check -recursive -diff",

registry/coder/modules/claude-code/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude
1414
```tf
1515
module "claude-code" {
1616
source = "registry.coder.com/modules/claude-code/coder"
17-
version = "1.0.31"
17+
version = "1.2.1"
1818
agent_id = coder_agent.example.id
1919
folder = "/home/coder"
2020
install_claude_code = true
@@ -25,7 +25,7 @@ module "claude-code" {
2525
## Prerequisites
2626

2727
- Node.js and npm must be installed in your workspace to install Claude Code
28-
- `screen` must be installed in your workspace to run Claude Code in the background
28+
- Either `screen` or `tmux` must be installed in your workspace to run Claude Code in the background
2929
- You must add the [Coder Login](https://registry.coder.com/modules/coder-login) module to your template
3030

3131
The `codercom/oss-dogfood:latest` container image can be used for testing on container-based workspaces.
@@ -43,7 +43,7 @@ The `codercom/oss-dogfood:latest` container image can be used for testing on con
4343
> Join our [Discord channel](https://discord.gg/coder) or
4444
> [contact us](https://coder.com/contact) to get help or share feedback.
4545
46-
Your workspace must have `screen` installed to use this.
46+
Your workspace must have either `screen` or `tmux` installed to use this.
4747

4848
```tf
4949
variable "anthropic_api_key" {
@@ -71,7 +71,7 @@ data "coder_parameter" "ai_prompt" {
7171
resource "coder_agent" "main" {
7272
# ...
7373
env = {
74-
CODER_MCP_CLAUDE_API_KEY = var.anthropic_api_key # or use a coder_parameter
74+
CODER_MCP_CLAUDE_API_KEY = var.anthropic_api_key # or use a coder_parameter
7575
CODER_MCP_CLAUDE_TASK_PROMPT = data.coder_parameter.ai_prompt.value
7676
CODER_MCP_APP_STATUS_SLUG = "claude-code"
7777
CODER_MCP_CLAUDE_SYSTEM_PROMPT = <<-EOT
@@ -83,14 +83,14 @@ resource "coder_agent" "main" {
8383
module "claude-code" {
8484
count = data.coder_workspace.me.start_count
8585
source = "registry.coder.com/modules/claude-code/coder"
86-
version = "1.0.31"
86+
version = "1.1.0"
8787
agent_id = coder_agent.example.id
8888
folder = "/home/coder"
8989
install_claude_code = true
9090
claude_code_version = "0.2.57"
9191
9292
# Enable experimental features
93-
experiment_use_screen = true
93+
experiment_use_screen = true # Or use experiment_use_tmux = true to use tmux instead
9494
experiment_report_tasks = true
9595
}
9696
```
@@ -102,7 +102,7 @@ Run Claude Code as a standalone app in your workspace. This will install Claude
102102
```tf
103103
module "claude-code" {
104104
source = "registry.coder.com/modules/claude-code/coder"
105-
version = "1.0.31"
105+
version = "1.2.1"
106106
agent_id = coder_agent.example.id
107107
folder = "/home/coder"
108108
install_claude_code = true

registry/coder/modules/claude-code/main.tf

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,35 @@ variable "experiment_use_screen" {
5454
default = false
5555
}
5656

57+
variable "experiment_use_tmux" {
58+
type = bool
59+
description = "Whether to use tmux instead of screen for running Claude Code in the background."
60+
default = false
61+
}
62+
5763
variable "experiment_report_tasks" {
5864
type = bool
5965
description = "Whether to enable task reporting."
6066
default = false
6167
}
6268

69+
variable "experiment_pre_install_script" {
70+
type = string
71+
description = "Custom script to run before installing Claude Code."
72+
default = null
73+
}
74+
75+
variable "experiment_post_install_script" {
76+
type = string
77+
description = "Custom script to run after installing Claude Code."
78+
default = null
79+
}
80+
81+
locals {
82+
encoded_pre_install_script = var.experiment_pre_install_script != null ? base64encode(var.experiment_pre_install_script) : ""
83+
encoded_post_install_script = var.experiment_post_install_script != null ? base64encode(var.experiment_post_install_script) : ""
84+
}
85+
6386
# Install and Initialize Claude Code
6487
resource "coder_script" "claude_code" {
6588
agent_id = var.agent_id
@@ -74,6 +97,14 @@ resource "coder_script" "claude_code" {
7497
command -v "$1" >/dev/null 2>&1
7598
}
7699
100+
# Run pre-install script if provided
101+
if [ -n "${local.encoded_pre_install_script}" ]; then
102+
echo "Running pre-install script..."
103+
echo "${local.encoded_pre_install_script}" | base64 -d > /tmp/pre_install.sh
104+
chmod +x /tmp/pre_install.sh
105+
/tmp/pre_install.sh
106+
fi
107+
77108
# Install Claude Code if enabled
78109
if [ "${var.install_claude_code}" = "true" ]; then
79110
if ! command_exists npm; then
@@ -84,11 +115,52 @@ resource "coder_script" "claude_code" {
84115
npm install -g @anthropic-ai/claude-code@${var.claude_code_version}
85116
fi
86117
118+
# Run post-install script if provided
119+
if [ -n "${local.encoded_post_install_script}" ]; then
120+
echo "Running post-install script..."
121+
echo "${local.encoded_post_install_script}" | base64 -d > /tmp/post_install.sh
122+
chmod +x /tmp/post_install.sh
123+
/tmp/post_install.sh
124+
fi
125+
87126
if [ "${var.experiment_report_tasks}" = "true" ]; then
88127
echo "Configuring Claude Code to report tasks via Coder MCP..."
89128
coder exp mcp configure claude-code ${var.folder}
90129
fi
91130
131+
# Handle terminal multiplexer selection (tmux or screen)
132+
if [ "${var.experiment_use_tmux}" = "true" ] && [ "${var.experiment_use_screen}" = "true" ]; then
133+
echo "Error: Both experiment_use_tmux and experiment_use_screen cannot be true simultaneously."
134+
echo "Please set only one of them to true."
135+
exit 1
136+
fi
137+
138+
# Run with tmux if enabled
139+
if [ "${var.experiment_use_tmux}" = "true" ]; then
140+
echo "Running Claude Code in the background with tmux..."
141+
142+
# Check if tmux is installed
143+
if ! command_exists tmux; then
144+
echo "Error: tmux is not installed. Please install tmux manually."
145+
exit 1
146+
fi
147+
148+
touch "$HOME/.claude-code.log"
149+
150+
export LANG=en_US.UTF-8
151+
export LC_ALL=en_US.UTF-8
152+
153+
# Create a new tmux session in detached mode
154+
tmux new-session -d -s claude-code -c ${var.folder} "claude --dangerously-skip-permissions"
155+
156+
# Send the prompt to the tmux session if needed
157+
if [ -n "$CODER_MCP_CLAUDE_TASK_PROMPT" ]; then
158+
tmux send-keys -t claude-code "$CODER_MCP_CLAUDE_TASK_PROMPT"
159+
sleep 5
160+
tmux send-keys -t claude-code Enter
161+
fi
162+
fi
163+
92164
# Run with screen if enabled
93165
if [ "${var.experiment_use_screen}" = "true" ]; then
94166
echo "Running Claude Code in the background..."
@@ -149,20 +221,27 @@ resource "coder_app" "claude_code" {
149221
#!/bin/bash
150222
set -e
151223
152-
if [ "${var.experiment_use_screen}" = "true" ]; then
224+
export LANG=en_US.UTF-8
225+
export LC_ALL=en_US.UTF-8
226+
227+
if [ "${var.experiment_use_tmux}" = "true" ]; then
228+
if tmux has-session -t claude-code 2>/dev/null; then
229+
echo "Attaching to existing Claude Code tmux session." | tee -a "$HOME/.claude-code.log"
230+
tmux attach-session -t claude-code
231+
else
232+
echo "Starting a new Claude Code tmux session." | tee -a "$HOME/.claude-code.log"
233+
tmux new-session -s claude-code -c ${var.folder} "claude --dangerously-skip-permissions | tee -a \"$HOME/.claude-code.log\"; exec bash"
234+
fi
235+
elif [ "${var.experiment_use_screen}" = "true" ]; then
153236
if screen -list | grep -q "claude-code"; then
154-
export LANG=en_US.UTF-8
155-
export LC_ALL=en_US.UTF-8
156-
echo "Attaching to existing Claude Code session." | tee -a "$HOME/.claude-code.log"
237+
echo "Attaching to existing Claude Code screen session." | tee -a "$HOME/.claude-code.log"
157238
screen -xRR claude-code
158239
else
159-
echo "Starting a new Claude Code session." | tee -a "$HOME/.claude-code.log"
160-
screen -S claude-code bash -c 'export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; claude --dangerously-skip-permissions | tee -a "$HOME/.claude-code.log"; exec bash'
240+
echo "Starting a new Claude Code screen session." | tee -a "$HOME/.claude-code.log"
241+
screen -S claude-code bash -c 'claude --dangerously-skip-permissions | tee -a "$HOME/.claude-code.log"; exec bash'
161242
fi
162243
else
163244
cd ${var.folder}
164-
export LANG=en_US.UTF-8
165-
export LC_ALL=en_US.UTF-8
166245
claude
167246
fi
168247
EOT

registry/coder/modules/code-server/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Automatically install [code-server](https://github.com/coder/code-server) in a w
1515
module "code-server" {
1616
count = data.coder_workspace.me.start_count
1717
source = "registry.coder.com/modules/code-server/coder"
18-
version = "1.0.31"
18+
version = "1.1.0"
1919
agent_id = coder_agent.example.id
2020
}
2121
```
@@ -30,7 +30,7 @@ module "code-server" {
3030
module "code-server" {
3131
count = data.coder_workspace.me.start_count
3232
source = "registry.coder.com/modules/code-server/coder"
33-
version = "1.0.31"
33+
version = "1.1.0"
3434
agent_id = coder_agent.example.id
3535
install_version = "4.8.3"
3636
}
@@ -44,7 +44,7 @@ Install the Dracula theme from [OpenVSX](https://open-vsx.org/):
4444
module "code-server" {
4545
count = data.coder_workspace.me.start_count
4646
source = "registry.coder.com/modules/code-server/coder"
47-
version = "1.0.31"
47+
version = "1.1.0"
4848
agent_id = coder_agent.example.id
4949
extensions = [
5050
"dracula-theme.theme-dracula"
@@ -62,7 +62,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
6262
module "code-server" {
6363
count = data.coder_workspace.me.start_count
6464
source = "registry.coder.com/modules/code-server/coder"
65-
version = "1.0.31"
65+
version = "1.1.0"
6666
agent_id = coder_agent.example.id
6767
extensions = ["dracula-theme.theme-dracula"]
6868
settings = {
@@ -79,7 +79,7 @@ Just run code-server in the background, don't fetch it from GitHub:
7979
module "code-server" {
8080
count = data.coder_workspace.me.start_count
8181
source = "registry.coder.com/modules/code-server/coder"
82-
version = "1.0.31"
82+
version = "1.1.0"
8383
agent_id = coder_agent.example.id
8484
extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"]
8585
}
@@ -95,7 +95,7 @@ Run an existing copy of code-server if found, otherwise download from GitHub:
9595
module "code-server" {
9696
count = data.coder_workspace.me.start_count
9797
source = "registry.coder.com/modules/code-server/coder"
98-
version = "1.0.31"
98+
version = "1.1.0"
9999
agent_id = coder_agent.example.id
100100
use_cached = true
101101
extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"]
@@ -108,7 +108,7 @@ Just run code-server in the background, don't fetch it from GitHub:
108108
module "code-server" {
109109
count = data.coder_workspace.me.start_count
110110
source = "registry.coder.com/modules/code-server/coder"
111-
version = "1.0.31"
111+
version = "1.1.0"
112112
agent_id = coder_agent.example.id
113113
offline = true
114114
}

registry/coder/modules/code-server/main.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
coder = {
66
source = "coder/coder"
7-
version = ">= 0.17"
7+
version = ">= 2.1"
88
}
99
}
1010
}
@@ -122,6 +122,20 @@ variable "subdomain" {
122122
default = false
123123
}
124124

125+
variable "open_in" {
126+
type = string
127+
description = <<-EOT
128+
Determines where the app will be opened. Valid values are `"tab"` and `"slim-window" (default)`.
129+
`"tab"` opens in a new tab in the same browser window.
130+
`"slim-window"` opens a new browser window without navigation controls.
131+
EOT
132+
default = "slim-window"
133+
validation {
134+
condition = contains(["tab", "slim-window"], var.open_in)
135+
error_message = "The 'open_in' variable must be one of: 'tab', 'slim-window'."
136+
}
137+
}
138+
125139
resource "coder_script" "code-server" {
126140
agent_id = var.agent_id
127141
display_name = "code-server"
@@ -166,6 +180,7 @@ resource "coder_app" "code-server" {
166180
subdomain = var.subdomain
167181
share = var.share
168182
order = var.order
183+
open_in = var.open_in
169184

170185
healthcheck {
171186
url = "http://localhost:${var.port}/healthz"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
display_name: devcontainers-cli
3+
description: devcontainers-cli module provides an easy way to install @devcontainers/cli into a workspace
4+
icon: ../../../../.icons/devcontainers.svg
5+
verified: true
6+
maintainer_github: coder
7+
tags: [devcontainers]
8+
---
9+
10+
# devcontainers-cli
11+
12+
The devcontainers-cli module provides an easy way to install [`@devcontainers/cli`](https://github.com/devcontainers/cli) into a workspace. It can be used within any workspace as it runs only if
13+
@devcontainers/cli is not installed yet.
14+
`npm` is required and should be pre-installed in order for the module to work.
15+
16+
```tf
17+
module "devcontainers-cli" {
18+
source = "registry.coder.com/modules/devcontainers-cli/coder"
19+
version = "1.0.3"
20+
agent_id = coder_agent.example.id
21+
}
22+
```

0 commit comments

Comments
 (0)