Skip to content

Commit f5970dd

Browse files
committed
fix: fix tests
1 parent fb2578c commit f5970dd

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
display_name: Claude Code
3-
description: Run the Claude Code agent in your workspace to generate code and perform tasks.
3+
description: Run the Claude Code agent in your workspace.
44
icon: ../../../../.icons/claude.svg
55
verified: true
66
tags: [agent, claude-code, ai, tasks, anthropic]
@@ -33,12 +33,6 @@ module "claude-code" {
3333
This example shows how to configure the Claude Code module with a task prompt, API key, and other custom settings.
3434

3535
```tf
36-
variable "anthropic_api_key" {
37-
type = string
38-
description = "The Anthropic API key."
39-
sensitive = true
40-
}
41-
4236
data "coder_parameter" "task_prompt" {
4337
type = "string"
4438
name = "AI Task Prompt"
@@ -47,21 +41,16 @@ data "coder_parameter" "task_prompt" {
4741
mutable = true
4842
}
4943
50-
module "coder-login" {
51-
count = data.coder_workspace.me.start_count
52-
source = "registry.coder.com/coder/coder-login/coder"
53-
version = "1.0.31" # Use a recent version
54-
agent_id = coder_agent.example.id
55-
}
56-
5744
module "claude-code" {
5845
source = "registry.coder.com/coder/claude-code/coder"
5946
version = "3.0.0"
6047
agent_id = coder_agent.example.id
6148
workdir = "/home/coder/project"
6249
63-
# --- Authentication ---
64-
claude_api_key = var.anthropic_api_key # required for tasks
50+
# --- Authentication --- required for tasks
51+
claude_api_key = "xxxx-xxxxx-xxxx"
52+
# OR
53+
claude_code_oauth_token = "xxxxx-xxxx-xxxx"
6554
6655
# --- Versioning ---
6756
claude_code_version = "1.0.82" # Pin to a specific version

registry/coder/modules/claude-code/main.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ describe("claude-code", async () => {
134134
},
135135
});
136136
const { id } = await setup({
137+
skipClaudeMock: true,
137138
moduleVariables: {
138139
mcp: mcpConfig,
139140
},
@@ -142,7 +143,7 @@ describe("claude-code", async () => {
142143

143144
const resp = await readFileContainer(
144145
id,
145-
"/home/coder/.claude-module/install.log",
146+
"/home/coder/.claude.json",
146147
);
147148
expect(resp).toContain("test-cmd");
148149
});
@@ -151,7 +152,7 @@ describe("claude-code", async () => {
151152
const prompt = "This is a task prompt for Claude.";
152153
const { id } = await setup({
153154
moduleVariables: {
154-
task_prompt: prompt,
155+
ai_prompt: prompt,
155156
},
156157
});
157158
await execModuleScript(id);

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ variable "agentapi_version" {
8989
default = "v0.6.1"
9090
}
9191

92+
variable "ai_prompt" {
93+
type = string
94+
description = "Initial task prompt for Claude Code."
95+
default = ""
96+
}
97+
9298
# ---------------------------------------------------------------
9399

94100
variable "install_claude_code" {
@@ -162,13 +168,21 @@ variable "disallowed_tools" {
162168

163169
}
164170

165-
variable "ai_prompt" {
171+
variable "claude_code_oauth_token" {
166172
type = string
167-
description = "Task prompt for the Claude Code CLI"
168-
default = ""
173+
description = "Set up a long-lived authentication token (requires Claude subscription). Generated using `claude setup-token` command"
174+
sensitive = true
175+
}
176+
177+
resource "coder_env" "claude_code_oauth_token" {
178+
agent_id = var.agent_id
179+
name = "CLAUDE_CODE_OAUTH_TOKEN"
180+
value = var.claude_code_oauth_token
169181
}
170182

171183
resource "coder_env" "claude_api_key" {
184+
count = length(var.claude_api_key) > 0 ? 1 : 0
185+
172186
agent_id = var.agent_id
173187
name = "CLAUDE_API_KEY"
174188
value = var.claude_api_key

registry/coder/modules/claude-code/scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function setup_claude_configurations() {
6767
claude mcp add "$server_name" "$server_json"
6868
echo "------------------------"
6969
echo ""
70-
done < <(echo "${MCP:-{}}" | jq -r '.mcpServers | to_entries[] | .key, (.value | @json)')
70+
done < <(echo "${ARG_MCP:-{}}" | jq -r '.mcpServers | to_entries[] | .key, (.value | @json)')
7171

7272
if [ -n "$ARG_ALLOWED_TOOLS" ]; then
7373
coder --allowedTools "$ARG_ALLOWED_TOOLS"

0 commit comments

Comments
 (0)