From e15694a1f20cf41a167c53d0450c89839c70d279 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 31 Oct 2025 18:46:56 +0530 Subject: [PATCH 01/11] fix: claude-code continue issue --- .../scripts/remove-last-session-id.sh | 12 ++++++--- .../modules/claude-code/scripts/start.sh | 26 +++++++++---------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/registry/coder/modules/claude-code/scripts/remove-last-session-id.sh b/registry/coder/modules/claude-code/scripts/remove-last-session-id.sh index dac86a03c..da799f808 100755 --- a/registry/coder/modules/claude-code/scripts/remove-last-session-id.sh +++ b/registry/coder/modules/claude-code/scripts/remove-last-session-id.sh @@ -26,15 +26,21 @@ echo ".claude.json path $claude_json_path" # Check if .claude.json exists if [ ! -f "$claude_json_path" ]; then echo "No .claude.json file found" - exit 0 + exit 2 fi # Use jq to check if lastSessionId exists for the working directory and remove it if jq -e ".projects[\"$working_dir\"].lastSessionId" "$claude_json_path" > /dev/null 2>&1; then # Remove lastSessionId and update the file - jq "del(.projects[\"$working_dir\"].lastSessionId)" "$claude_json_path" > "${claude_json_path}.tmp" && mv "${claude_json_path}.tmp" "$claude_json_path" - echo "Removed lastSessionId from .claude.json" + if jq "del(.projects[\"$working_dir\"].lastSessionId)" "$claude_json_path" > "${claude_json_path}.tmp" && mv "${claude_json_path}.tmp" "$claude_json_path"; then + echo "Removed lastSessionId from .claude.json" + exit 0 + else + echo "Failed to remove lastSessionId from .claude.json" + exit 3 + fi else echo "No lastSessionId found in .claude.json - nothing to do" + exit 4 fi diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index f5527b4fd..1a2cd06fb 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -49,8 +49,16 @@ echo "--------------------------------" # see the remove-last-session-id.sh script for details # about why we need it -# avoid exiting if the script fails -bash "/tmp/remove-last-session-id.sh" "$(pwd)" 2> /dev/null || true +CAN_CONTINUE_CONVERSATION=false + +bash "/tmp/remove-last-session-id.sh" "$(pwd)" 2> /dev/null +session_cleanup_exit_code=$? + +case $session_cleanup_exit_code in + 0) + CAN_CONTINUE_CONVERSATION=true + ;; +esac function install_boundary() { # Install boundary from public github repo @@ -69,16 +77,6 @@ function validate_claude_installation() { fi } -TASK_SESSION_ID="cd32e253-ca16-4fd3-9825-d837e74ae3c2" - -task_session_exists() { - if find "$HOME/.claude" -type f -name "*${TASK_SESSION_ID}*" 2> /dev/null | grep -q .; then - return 0 - else - return 1 - fi -} - ARGS=() function start_agentapi() { @@ -103,9 +101,9 @@ function start_agentapi() { ARGS+=(--dangerously-skip-permissions) fi elif [ "$ARG_CONTINUE" = "true" ]; then - if task_session_exists; then + if [ "$CAN_CONTINUE_CONVERSATION" = true ]; then echo "Task session detected (ID: $TASK_SESSION_ID)" - ARGS+=(--resume "$TASK_SESSION_ID") + ARGS+=(--continue) if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then ARGS+=(--dangerously-skip-permissions) fi From 678497192c87411c3c64409c37054d7780e8623c Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 31 Oct 2025 19:45:49 +0530 Subject: [PATCH 02/11] wip --- registry/coder/modules/claude-code/scripts/start.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index 1a2cd06fb..451a49107 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -58,6 +58,9 @@ case $session_cleanup_exit_code in 0) CAN_CONTINUE_CONVERSATION=true ;; + *) + printf "OwO" + ;; esac function install_boundary() { From 42df97d12abb95dac6a3fd4c7b3e3e0b8f68742d Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 31 Oct 2025 19:54:27 +0530 Subject: [PATCH 03/11] wip --- registry/coder/modules/claude-code/scripts/start.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index 451a49107..20f8044e8 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -50,9 +50,10 @@ echo "--------------------------------" # see the remove-last-session-id.sh script for details # about why we need it CAN_CONTINUE_CONVERSATION=false - + set +e bash "/tmp/remove-last-session-id.sh" "$(pwd)" 2> /dev/null session_cleanup_exit_code=$? + set -e case $session_cleanup_exit_code in 0) From c81adcc354283563cbc35141d864e6593e6ca485 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 31 Oct 2025 19:57:57 +0530 Subject: [PATCH 04/11] wip --- registry/coder/modules/claude-code/scripts/start.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index 20f8044e8..35b0abd40 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -106,7 +106,7 @@ function start_agentapi() { fi elif [ "$ARG_CONTINUE" = "true" ]; then if [ "$CAN_CONTINUE_CONVERSATION" = true ]; then - echo "Task session detected (ID: $TASK_SESSION_ID)" + echo "Previous session exists" ARGS+=(--continue) if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then ARGS+=(--dangerously-skip-permissions) @@ -114,7 +114,6 @@ function start_agentapi() { echo "Resuming existing task session" else echo "No existing task session found" - ARGS+=(--session-id "$TASK_SESSION_ID") if [ -n "$ARG_AI_PROMPT" ]; then ARGS+=(--dangerously-skip-permissions "$ARG_AI_PROMPT") echo "Starting new task session with prompt" From 96fdab13fedb3edd9c431d89949b847ae770cc24 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 31 Oct 2025 23:32:00 +0530 Subject: [PATCH 05/11] wip --- .../modules/claude-code/scripts/remove-last-session-id.sh | 4 +--- registry/coder/modules/claude-code/scripts/start.sh | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/registry/coder/modules/claude-code/scripts/remove-last-session-id.sh b/registry/coder/modules/claude-code/scripts/remove-last-session-id.sh index da799f808..d72369fa7 100755 --- a/registry/coder/modules/claude-code/scripts/remove-last-session-id.sh +++ b/registry/coder/modules/claude-code/scripts/remove-last-session-id.sh @@ -26,7 +26,7 @@ echo ".claude.json path $claude_json_path" # Check if .claude.json exists if [ ! -f "$claude_json_path" ]; then echo "No .claude.json file found" - exit 2 + exit 1 fi # Use jq to check if lastSessionId exists for the working directory and remove it @@ -38,9 +38,7 @@ if jq -e ".projects[\"$working_dir\"].lastSessionId" "$claude_json_path" > /dev/ exit 0 else echo "Failed to remove lastSessionId from .claude.json" - exit 3 fi else echo "No lastSessionId found in .claude.json - nothing to do" - exit 4 fi diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index 35b0abd40..19d85ccd9 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -59,9 +59,6 @@ case $session_cleanup_exit_code in 0) CAN_CONTINUE_CONVERSATION=true ;; - *) - printf "OwO" - ;; esac function install_boundary() { From 8b99b56f51faf204faed868e288bd444adb5a7ef Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Fri, 31 Oct 2025 16:02:45 -0500 Subject: [PATCH 06/11] chore(start.sh): improve session management messages --- .../coder/modules/claude-code/scripts/start.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index 19d85ccd9..460ac900e 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -47,13 +47,12 @@ printf "ARG_CODER_HOST: %s\n" "$ARG_CODER_HOST" echo "--------------------------------" -# see the remove-last-session-id.sh script for details -# about why we need it +# Clean up stale session data (see remove-last-session-id.sh for details) CAN_CONTINUE_CONVERSATION=false - set +e +set +e bash "/tmp/remove-last-session-id.sh" "$(pwd)" 2> /dev/null session_cleanup_exit_code=$? - set -e +set -e case $session_cleanup_exit_code in 0) @@ -96,7 +95,7 @@ function start_agentapi() { fi if [ -n "$ARG_RESUME_SESSION_ID" ]; then - echo "Using explicit resume_session_id: $ARG_RESUME_SESSION_ID" + echo "Resuming task session by ID: $ARG_RESUME_SESSION_ID" ARGS+=(--resume "$ARG_RESUME_SESSION_ID") if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then ARGS+=(--dangerously-skip-permissions) @@ -108,17 +107,17 @@ function start_agentapi() { if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then ARGS+=(--dangerously-skip-permissions) fi - echo "Resuming existing task session" + echo "Resuming existing session" else - echo "No existing task session found" + echo "No existing session found" if [ -n "$ARG_AI_PROMPT" ]; then ARGS+=(--dangerously-skip-permissions "$ARG_AI_PROMPT") - echo "Starting new task session with prompt" + echo "Starting new session with prompt" else if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then ARGS+=(--dangerously-skip-permissions) fi - echo "Starting new task session" + echo "Starting new session" fi fi else From 0821ffcf98ea56e07353b6afb47bc6d7f292b6bb Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Fri, 31 Oct 2025 16:37:46 -0500 Subject: [PATCH 07/11] feat(claude-code): enhance session management and reporting functionality. - Sessions are now only using the hardcoded task id when `report_tasks` is true - Session resumption is still possible with standalone but it will use the continue flah when sessions are found in the workdir - Tests are updated for new print statements, and logic - `--dangerously-skip-permissions` is now only forced when `report_tasks` is true instead of `ai_prompt` --- .../coder/modules/claude-code/main.test.ts | 97 ++++++++++++++++++- registry/coder/modules/claude-code/main.tf | 1 + .../coder/modules/claude-code/main.tftest.hcl | 6 +- .../modules/claude-code/scripts/start.sh | 44 ++++++++- 4 files changed, 140 insertions(+), 8 deletions(-) diff --git a/registry/coder/modules/claude-code/main.test.ts b/registry/coder/modules/claude-code/main.test.ts index a7c2dd14c..142c61008 100644 --- a/registry/coder/modules/claude-code/main.test.ts +++ b/registry/coder/modules/claude-code/main.test.ts @@ -198,15 +198,16 @@ describe("claude-code", async () => { expect(startLog.stdout).toContain(`--model ${model}`); }); - test("claude-continue-resume-existing-session", async () => { + test("claude-continue-resume-task-session", async () => { const { id } = await setup({ moduleVariables: { continue: "true", + report_tasks: "true", ai_prompt: "test prompt", }, }); - // Create a mock session file with the predefined task session ID + // Create a mock task session file with the hardcoded task session ID const taskSessionId = "cd32e253-ca16-4fd3-9825-d837e74ae3c2"; const sessionDir = `/home/coder/.claude/projects/-home-coder-project`; await execContainer(id, ["mkdir", "-p", sessionDir]); @@ -228,6 +229,42 @@ describe("claude-code", async () => { expect(startLog.stdout).toContain("Resuming existing task session"); }); + test("claude-continue-resume-general-session", async () => { + const { id } = await setup({ + moduleVariables: { + continue: "true", + report_tasks: "false", + ai_prompt: "test prompt", + }, + }); + + const sessionId = "some-random-session-id"; + const workdir = "/home/coder/project"; + const claudeJson = { + projects: { + [workdir]: { + lastSessionId: sessionId, + }, + }, + }; + + await execContainer(id, [ + "bash", + "-c", + `echo '${JSON.stringify(claudeJson)}' > /home/coder/.claude.json`, + ]); + + await execModuleScript(id); + + const startLog = await execContainer(id, [ + "bash", + "-c", + "cat /home/coder/.claude-module/agentapi-start.log", + ]); + expect(startLog.stdout).toContain("--continue"); + expect(startLog.stdout).toContain("Resuming existing session"); + }); + test("pre-post-install-scripts", async () => { const { id } = await setup({ moduleVariables: { @@ -322,4 +359,60 @@ describe("claude-code", async () => { "ARG_AGENTAPI_CHAT_BASE_PATH=/@default/default.foo/apps/ccw/chat", ); }); + + test("continue-false-with-report-tasks-uses-task-id", async () => { + const taskSessionId = "cd32e253-ca16-4fd3-9825-d837e74ae3c2"; + const { id } = await setup({ + moduleVariables: { + continue: "false", + report_tasks: "true", + }, + }); + await execModuleScript(id); + + const startLog = await execContainer(id, [ + "bash", + "-c", + "cat /home/coder/.claude-module/agentapi-start.log", + ]); + expect(startLog.stdout).toContain("--session-id"); + expect(startLog.stdout).toContain(taskSessionId); + }); + + test("prompt-in-general-mode-allows-permissions", async () => { + const { id } = await setup({ + moduleVariables: { + report_tasks: "false", + ai_prompt: "Review the code", + }, + }); + await execModuleScript(id); + + const startLog = await execContainer(id, [ + "bash", + "-c", + "cat /home/coder/.claude-module/agentapi-start.log", + ]); + expect(startLog.stdout).toContain("Review the code"); + expect(startLog.stdout).not.toContain("--dangerously-skip-permissions"); + }); + + test("prompt-in-task-mode-skips-permissions", async () => { + const { id } = await setup({ + moduleVariables: { + report_tasks: "true", + ai_prompt: "Fix the tests", + }, + }); + await execModuleScript(id); + + const startLog = await execContainer(id, [ + "bash", + "-c", + "cat /home/coder/.claude-module/agentapi-start.log", + ]); + // Should have both the prompt AND --dangerously-skip-permissions + expect(startLog.stdout).toContain("Fix the tests"); + expect(startLog.stdout).toContain("--dangerously-skip-permissions"); + }); }); diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index 93b3761b6..bf08af033 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -349,6 +349,7 @@ module "agentapi" { ARG_PERMISSION_MODE='${var.permission_mode}' \ ARG_WORKDIR='${local.workdir}' \ ARG_AI_PROMPT='${base64encode(var.ai_prompt)}' \ + ARG_REPORT_TASKS='${var.report_tasks}' \ ARG_ENABLE_BOUNDARY='${var.enable_boundary}' \ ARG_BOUNDARY_VERSION='${var.boundary_version}' \ ARG_BOUNDARY_LOG_DIR='${var.boundary_log_dir}' \ diff --git a/registry/coder/modules/claude-code/main.tftest.hcl b/registry/coder/modules/claude-code/main.tftest.hcl index 6994caf24..adfca6d20 100644 --- a/registry/coder/modules/claude-code/main.tftest.hcl +++ b/registry/coder/modules/claude-code/main.tftest.hcl @@ -57,7 +57,7 @@ run "test_claude_code_with_custom_options" { group = "development" icon = "/icon/custom.svg" model = "opus" - task_prompt = "Help me write better code" + ai_prompt = "Help me write better code" permission_mode = "plan" continue = true install_claude_code = false @@ -88,8 +88,8 @@ run "test_claude_code_with_custom_options" { } assert { - condition = var.task_prompt == "Help me write better code" - error_message = "Task prompt variable should be set correctly" + condition = var.ai_prompt == "Help me write better code" + error_message = "AI prompt variable should be set correctly" } assert { diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index 460ac900e..910f56cb7 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -20,6 +20,7 @@ ARG_DANGEROUSLY_SKIP_PERMISSIONS=${ARG_DANGEROUSLY_SKIP_PERMISSIONS:-} ARG_PERMISSION_MODE=${ARG_PERMISSION_MODE:-} ARG_WORKDIR=${ARG_WORKDIR:-"$HOME"} ARG_AI_PROMPT=$(echo -n "${ARG_AI_PROMPT:-}" | base64 -d) +ARG_REPORT_TASKS=${ARG_REPORT_TASKS:-true} ARG_ENABLE_BOUNDARY=${ARG_ENABLE_BOUNDARY:-false} ARG_BOUNDARY_VERSION=${ARG_BOUNDARY_VERSION:-"main"} ARG_BOUNDARY_LOG_DIR=${ARG_BOUNDARY_LOG_DIR:-"/tmp/boundary_logs"} @@ -38,6 +39,7 @@ printf "ARG_DANGEROUSLY_SKIP_PERMISSIONS: %s\n" "$ARG_DANGEROUSLY_SKIP_PERMISSIO printf "ARG_PERMISSION_MODE: %s\n" "$ARG_PERMISSION_MODE" printf "ARG_AI_PROMPT: %s\n" "$ARG_AI_PROMPT" printf "ARG_WORKDIR: %s\n" "$ARG_WORKDIR" +printf "ARG_REPORT_TASKS: %s\n" "$ARG_REPORT_TASKS" printf "ARG_ENABLE_BOUNDARY: %s\n" "$ARG_ENABLE_BOUNDARY" printf "ARG_BOUNDARY_VERSION: %s\n" "$ARG_BOUNDARY_VERSION" printf "ARG_BOUNDARY_LOG_DIR: %s\n" "$ARG_BOUNDARY_LOG_DIR" @@ -77,6 +79,21 @@ function validate_claude_installation() { fi } +# Hardcoded task session ID for Coder task reporting +# This ensures all task sessions use a consistent, predictable ID +TASK_SESSION_ID="cd32e253-ca16-4fd3-9825-d837e74ae3c2" + +task_session_exists() { + local workdir_normalized=$(echo "$ARG_WORKDIR" | tr '/' '-') + local project_dir="$HOME/.claude/projects/${workdir_normalized}" + + if [ -d "$project_dir" ] && find "$project_dir" -type f -name "*${TASK_SESSION_ID}*" 2> /dev/null | grep -q .; then + return 0 + else + return 1 + fi +} + ARGS=() function start_agentapi() { @@ -101,7 +118,14 @@ function start_agentapi() { ARGS+=(--dangerously-skip-permissions) fi elif [ "$ARG_CONTINUE" = "true" ]; then - if [ "$CAN_CONTINUE_CONVERSATION" = true ]; then + if [ "$ARG_REPORT_TASKS" = "true" ] && task_session_exists; then + echo "Task session detected (ID: $TASK_SESSION_ID)" + ARGS+=(--resume "$TASK_SESSION_ID") + if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then + ARGS+=(--dangerously-skip-permissions) + fi + echo "Resuming existing task session" + elif [ "$ARG_REPORT_TASKS" = "false" ] && [ "$CAN_CONTINUE_CONVERSATION" = true ]; then echo "Previous session exists" ARGS+=(--continue) if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then @@ -110,8 +134,15 @@ function start_agentapi() { echo "Resuming existing session" else echo "No existing session found" + if [ "$ARG_REPORT_TASKS" = "true" ]; then + ARGS+=(--session-id "$TASK_SESSION_ID") + fi if [ -n "$ARG_AI_PROMPT" ]; then - ARGS+=(--dangerously-skip-permissions "$ARG_AI_PROMPT") + if [ "$ARG_REPORT_TASKS" = "true" ]; then + ARGS+=(--dangerously-skip-permissions "$ARG_AI_PROMPT") + else + ARGS+=("$ARG_AI_PROMPT") + fi echo "Starting new session with prompt" else if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then @@ -122,8 +153,15 @@ function start_agentapi() { fi else echo "Continue disabled, starting fresh session" + if [ "$ARG_REPORT_TASKS" = "true" ]; then + ARGS+=(--session-id "$TASK_SESSION_ID") + fi if [ -n "$ARG_AI_PROMPT" ]; then - ARGS+=(--dangerously-skip-permissions "$ARG_AI_PROMPT") + if [ "$ARG_REPORT_TASKS" = "true" ]; then + ARGS+=(--dangerously-skip-permissions "$ARG_AI_PROMPT") + else + ARGS+=("$ARG_AI_PROMPT") + fi echo "Starting new session with prompt" else if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then From df95c72a5854b365c4d7c9111637c87f4b4446d9 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Fri, 31 Oct 2025 16:39:54 -0500 Subject: [PATCH 08/11] chore: bump version to 3.4.5 --- registry/coder/modules/claude-code/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/registry/coder/modules/claude-code/README.md b/registry/coder/modules/claude-code/README.md index 8e26416e2..87f9a4dfe 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.4.4" + version = "3.4.5" 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.4.4" + version = "3.4.5" 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.4.4" + version = "3.4.5" 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.4.4" + version = "3.4.5" 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.4.4" + version = "3.4.5" 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.4.4" + version = "3.4.5" agent_id = coder_agent.example.id workdir = "/home/coder/project" model = "claude-sonnet-4@20250514" From 0b49e615a91ac2674e7c51d6f9b1cd4e915fe16c Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Fri, 31 Oct 2025 16:54:43 -0500 Subject: [PATCH 09/11] chore: remove redundant tests that were included in last commit --- .../coder/modules/claude-code/main.test.ts | 58 +------------------ 1 file changed, 1 insertion(+), 57 deletions(-) diff --git a/registry/coder/modules/claude-code/main.test.ts b/registry/coder/modules/claude-code/main.test.ts index 142c61008..494aeda1f 100644 --- a/registry/coder/modules/claude-code/main.test.ts +++ b/registry/coder/modules/claude-code/main.test.ts @@ -229,7 +229,7 @@ describe("claude-code", async () => { expect(startLog.stdout).toContain("Resuming existing task session"); }); - test("claude-continue-resume-general-session", async () => { + test("claude-continue-resume-standalone-session", async () => { const { id } = await setup({ moduleVariables: { continue: "true", @@ -359,60 +359,4 @@ describe("claude-code", async () => { "ARG_AGENTAPI_CHAT_BASE_PATH=/@default/default.foo/apps/ccw/chat", ); }); - - test("continue-false-with-report-tasks-uses-task-id", async () => { - const taskSessionId = "cd32e253-ca16-4fd3-9825-d837e74ae3c2"; - const { id } = await setup({ - moduleVariables: { - continue: "false", - report_tasks: "true", - }, - }); - await execModuleScript(id); - - const startLog = await execContainer(id, [ - "bash", - "-c", - "cat /home/coder/.claude-module/agentapi-start.log", - ]); - expect(startLog.stdout).toContain("--session-id"); - expect(startLog.stdout).toContain(taskSessionId); - }); - - test("prompt-in-general-mode-allows-permissions", async () => { - const { id } = await setup({ - moduleVariables: { - report_tasks: "false", - ai_prompt: "Review the code", - }, - }); - await execModuleScript(id); - - const startLog = await execContainer(id, [ - "bash", - "-c", - "cat /home/coder/.claude-module/agentapi-start.log", - ]); - expect(startLog.stdout).toContain("Review the code"); - expect(startLog.stdout).not.toContain("--dangerously-skip-permissions"); - }); - - test("prompt-in-task-mode-skips-permissions", async () => { - const { id } = await setup({ - moduleVariables: { - report_tasks: "true", - ai_prompt: "Fix the tests", - }, - }); - await execModuleScript(id); - - const startLog = await execContainer(id, [ - "bash", - "-c", - "cat /home/coder/.claude-module/agentapi-start.log", - ]); - // Should have both the prompt AND --dangerously-skip-permissions - expect(startLog.stdout).toContain("Fix the tests"); - expect(startLog.stdout).toContain("--dangerously-skip-permissions"); - }); }); From 07b0caad3866ce41b23d96eb1b227ae3ea782350 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Sat, 1 Nov 2025 00:13:33 +0000 Subject: [PATCH 10/11] fix(claude-code): ensure `--dangerously-skip-permissions` is always included during task session resumption --- registry/coder/modules/claude-code/main.test.ts | 1 + registry/coder/modules/claude-code/scripts/start.sh | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/registry/coder/modules/claude-code/main.test.ts b/registry/coder/modules/claude-code/main.test.ts index 494aeda1f..94fcb391a 100644 --- a/registry/coder/modules/claude-code/main.test.ts +++ b/registry/coder/modules/claude-code/main.test.ts @@ -227,6 +227,7 @@ describe("claude-code", async () => { expect(startLog.stdout).toContain("--resume"); expect(startLog.stdout).toContain(taskSessionId); expect(startLog.stdout).toContain("Resuming existing task session"); + expect(startLog.stdout).toContain("--dangerously-skip-permissions"); }); test("claude-continue-resume-standalone-session", async () => { diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index 910f56cb7..943065dcb 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -121,9 +121,7 @@ function start_agentapi() { if [ "$ARG_REPORT_TASKS" = "true" ] && task_session_exists; then echo "Task session detected (ID: $TASK_SESSION_ID)" ARGS+=(--resume "$TASK_SESSION_ID") - if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then - ARGS+=(--dangerously-skip-permissions) - fi + ARGS+=(--dangerously-skip-permissions) echo "Resuming existing task session" elif [ "$ARG_REPORT_TASKS" = "false" ] && [ "$CAN_CONTINUE_CONVERSATION" = true ]; then echo "Previous session exists" From 858a4aa476638a35ffca2e197abad18b0540eda6 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Sat, 1 Nov 2025 00:46:12 +0000 Subject: [PATCH 11/11] fix(claude-code): fix when dangerously-skip-permissions is added. either when report_tasks is true or if the variable is true --- registry/coder/modules/claude-code/scripts/start.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index 943065dcb..40b164563 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -139,11 +139,14 @@ function start_agentapi() { if [ "$ARG_REPORT_TASKS" = "true" ]; then ARGS+=(--dangerously-skip-permissions "$ARG_AI_PROMPT") else + if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then + ARGS+=(--dangerously-skip-permissions) + fi ARGS+=("$ARG_AI_PROMPT") fi echo "Starting new session with prompt" else - if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then + if [ "$ARG_REPORT_TASKS" = "true" ] || [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then ARGS+=(--dangerously-skip-permissions) fi echo "Starting new session" @@ -158,11 +161,14 @@ function start_agentapi() { if [ "$ARG_REPORT_TASKS" = "true" ]; then ARGS+=(--dangerously-skip-permissions "$ARG_AI_PROMPT") else + if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then + ARGS+=(--dangerously-skip-permissions) + fi ARGS+=("$ARG_AI_PROMPT") fi echo "Starting new session with prompt" else - if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then + if [ "$ARG_REPORT_TASKS" = "true" ] || [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then ARGS+=(--dangerously-skip-permissions) fi echo "Starting claude code session"