diff --git a/registry/coder-labs/templates/tasks-docker/main.tf b/registry/coder-labs/templates/tasks-docker/main.tf index c0a165fcc..2935d125e 100644 --- a/registry/coder-labs/templates/tasks-docker/main.tf +++ b/registry/coder-labs/templates/tasks-docker/main.tf @@ -1,7 +1,8 @@ terraform { required_providers { coder = { - source = "coder/coder" + source = "coder/coder" + version = ">= 2.12" } docker = { source = "kreuzwerker/docker" @@ -12,28 +13,32 @@ terraform { # This template requires a valid Docker socket # However, you can reference our Kubernetes/VM # example templates and adapt the Claude Code module -# -# see: https://registry.coder.com/templates +# +# see: https://registry.coder.com/templates provider "docker" {} # The Claude Code module does the automatic task reporting # Other agent modules: https://registry.coder.com/modules?search=agent -# Or use a custom agent: +# Or use a custom agent: module "claude-code" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/claude-code/coder" - version = "3.0.0" + version = "4.0.0" agent_id = coder_agent.main.id workdir = "/home/coder/projects" order = 999 claude_api_key = "" - ai_prompt = data.coder_parameter.ai_prompt.value + ai_prompt = coder_ai_task.task.prompt system_prompt = data.coder_parameter.system_prompt.value model = "sonnet" permission_mode = "plan" post_install_script = data.coder_parameter.setup_script.value } +resource "coder_ai_task" "task" { + app_id = module.claude-code.task_app_id +} + # We are using presets to set the prompts, image, and set up instructions # See https://coder.com/docs/admin/templates/extending-templates/parameters#workspace-presets data "coder_workspace_preset" "default" { @@ -51,13 +56,13 @@ data "coder_workspace_preset" "default" { (servers, dev watchers, GUI apps). - Built-in tools - use for everything else: (file operations, git commands, builds & installs, one-off shell commands) - + Remember this decision rule: - Stays running? → desktop-commander - Finishes immediately? → built-in tools - + -- Context -- - There is an existing app and tmux dev server running on port 8000. Be sure to read it's CLAUDE.md (./realworld-django-rest-framework-angular/CLAUDE.md) to learn more about it. + There is an existing app and tmux dev server running on port 8000. Be sure to read it's CLAUDE.md (./realworld-django-rest-framework-angular/CLAUDE.md) to learn more about it. Since this app is for demo purposes and the user is previewing the homepage and subsequent pages, aim to make the first visual change/prototype very quickly so the user can preview it, then focus on backend or logic which can be a more involved, long-running architecture plan. @@ -107,7 +112,7 @@ data "coder_workspace_preset" "default" { # Pre-builds is a Coder Premium # feature to speed up workspace creation - # + # # see https://coder.com/docs/admin/templates/extending-templates/prebuilt-workspaces # prebuilds { # instances = 1 @@ -126,13 +131,6 @@ data "coder_parameter" "system_prompt" { description = "System prompt for the agent with generalized instructions" mutable = false } -data "coder_parameter" "ai_prompt" { - type = "string" - name = "AI Prompt" - default = "" - description = "Write a prompt for Claude Code" - mutable = true -} data "coder_parameter" "setup_script" { name = "setup_script" display_name = "Setup Script" @@ -373,4 +371,4 @@ resource "docker_container" "workspace" { label = "coder.workspace_name" value = data.coder_workspace.me.name } -} \ No newline at end of file +} diff --git a/registry/coder/modules/claude-code/README.md b/registry/coder/modules/claude-code/README.md index 1c17fab83..27c31584f 100644 --- a/registry/coder/modules/claude-code/README.md +++ b/registry/coder/modules/claude-code/README.md @@ -13,7 +13,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude ```tf module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.3.0" + version = "4.0.0" agent_id = coder_agent.example.id workdir = "/home/coder/project" claude_api_key = "xxxx-xxxxx-xxxx" @@ -70,7 +70,7 @@ data "coder_parameter" "ai_prompt" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.3.0" + version = "4.0.0" agent_id = coder_agent.example.id workdir = "/home/coder/project" @@ -106,7 +106,7 @@ Run and configure Claude Code as a standalone CLI in your workspace. ```tf module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.3.0" + version = "4.0.0" agent_id = coder_agent.example.id workdir = "/home/coder" install_claude_code = true @@ -129,7 +129,7 @@ variable "claude_code_oauth_token" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.3.0" + version = "4.0.0" agent_id = coder_agent.example.id workdir = "/home/coder/project" claude_code_oauth_token = var.claude_code_oauth_token @@ -202,7 +202,7 @@ resource "coder_env" "bedrock_api_key" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.3.0" + version = "4.0.0" agent_id = coder_agent.example.id workdir = "/home/coder/project" model = "global.anthropic.claude-sonnet-4-5-20250929-v1:0" @@ -259,7 +259,7 @@ resource "coder_env" "google_application_credentials" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.3.0" + version = "4.0.0" agent_id = coder_agent.example.id workdir = "/home/coder/project" model = "claude-sonnet-4@20250514" diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index 926b2402a..1046d9527 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -4,7 +4,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = ">= 2.7" + version = ">= 2.12" } } } @@ -270,7 +270,7 @@ resource "coder_env" "claude_api_key" { locals { # we have to trim the slash because otherwise coder exp mcp will - # set up an invalid claude config + # set up an invalid claude config workdir = trimsuffix(var.workdir, "/") app_slug = "ccw" install_script = file("${path.module}/scripts/install.sh") @@ -313,9 +313,8 @@ locals { } module "agentapi" { - source = "registry.coder.com/coder/agentapi/coder" - version = "1.2.0" + version = "2.0.0" agent_id = var.agent_id web_app_slug = local.app_slug @@ -379,3 +378,7 @@ module "agentapi" { /tmp/install.sh EOT } + +output "task_app_id" { + value = module.agentapi.task_app_id +}