From 186e0c4de6b7114c5a03bcec2eeafb83e6f77c31 Mon Sep 17 00:00:00 2001 From: 35C4n0r <70096901+35C4n0r@users.noreply.github.com> Date: Thu, 4 Dec 2025 01:57:14 +0530 Subject: [PATCH] feat(module/coder-labs/amp): add mode flag and disable animation (#550) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description 1. "mode" flag: Set the agent mode (free, rush, smart) — controls the model, system prompt, and tool selection. 2. `"amp.terminal.animation": false`: This disables the animation. 3. Update the readme ## Type of Change - [ ] New module - [ ] New template - [x] Bug fix - [x] Feature/enhancement - [x] Documentation - [ ] Other ## Module Information **Path:** `registry/coder-labs/modules/amp` **New version:** `v2.1.0` **Breaking change:** [ ] Yes [X] No ## Testing & Validation - [X] Tests pass (`bun test`) - [X] Code formatted (`bun fmt`) - [x] Changes tested locally ## Related Issues --------- Co-authored-by: DevCats --- .../coder-labs/modules/sourcegraph-amp/README.md | 14 +++++++------- .../coder-labs/modules/sourcegraph-amp/main.tf | 14 +++++++++++++- .../modules/sourcegraph-amp/scripts/install.sh | 5 ----- .../modules/sourcegraph-amp/scripts/start.sh | 12 ++++++++++-- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/registry/coder-labs/modules/sourcegraph-amp/README.md b/registry/coder-labs/modules/sourcegraph-amp/README.md index b0065318..6ba0576f 100644 --- a/registry/coder-labs/modules/sourcegraph-amp/README.md +++ b/registry/coder-labs/modules/sourcegraph-amp/README.md @@ -12,12 +12,12 @@ Run [Amp CLI](https://ampcode.com/) in your workspace to access Sourcegraph's AI ```tf module "amp-cli" { - source = "registry.coder.com/coder-labs/sourcegraph-amp/coder" - version = "2.0.2" - agent_id = coder_agent.example.id - sourcegraph_amp_api_key = var.sourcegraph_amp_api_key - install_sourcegraph_amp = true - agentapi_version = "2.0.2" + source = "registry.coder.com/coder-labs/sourcegraph-amp/coder" + version = "2.1.0" + agent_id = coder_agent.example.id + amp_api_key = var.amp_api_key + install_amp = true + agentapi_version = "latest" } ``` @@ -48,7 +48,7 @@ variable "amp_api_key" { module "amp-cli" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder-labs/sourcegraph-amp/coder" - amp_version = "2.0.2" + amp_version = "2.1.0" agent_id = coder_agent.example.id amp_api_key = var.amp_api_key # recommended for tasks usage workdir = "/home/coder/project" diff --git a/registry/coder-labs/modules/sourcegraph-amp/main.tf b/registry/coder-labs/modules/sourcegraph-amp/main.tf index fc36ea8d..31433795 100644 --- a/registry/coder-labs/modules/sourcegraph-amp/main.tf +++ b/registry/coder-labs/modules/sourcegraph-amp/main.tf @@ -55,7 +55,7 @@ variable "install_agentapi" { variable "agentapi_version" { type = string description = "The version of AgentAPI to install." - default = "v0.10.0" + default = "v0.11.1" } variable "cli_app" { @@ -160,6 +160,16 @@ variable "mcp" { default = null } +variable "mode" { + type = string + description = "Set the agent mode (free, rush, smart) — controls the model, system prompt, and tool selection. Default: smart" + default = "smart" + validation { + condition = contains(["", "free", "rush", "smart"], var.mode) + error_message = "Invalid mode. Select one from (free, rush, smart)" + } +} + data "external" "env" { program = ["sh", "-c", "echo '{\"CODER_AGENT_TOKEN\":\"'$CODER_AGENT_TOKEN'\",\"CODER_AGENT_URL\":\"'$CODER_AGENT_URL'\"}'"] } @@ -170,6 +180,7 @@ locals { default_base_config = jsonencode({ "amp.anthropic.thinking.enabled" = true "amp.todos.enabled" = true + "amp.terminal.animation" = false }) user_config = jsondecode(var.base_amp_config != "" ? var.base_amp_config : local.default_base_config) @@ -237,6 +248,7 @@ module "agentapi" { ARG_AMP_START_DIRECTORY='${var.workdir}' \ ARG_AMP_TASK_PROMPT='${base64encode(var.ai_prompt)}' \ ARG_REPORT_TASKS='${var.report_tasks}' \ + ARG_MODE='${var.mode}' \ /tmp/start.sh EOT diff --git a/registry/coder-labs/modules/sourcegraph-amp/scripts/install.sh b/registry/coder-labs/modules/sourcegraph-amp/scripts/install.sh index 123d7a1d..6b4e6649 100644 --- a/registry/coder-labs/modules/sourcegraph-amp/scripts/install.sh +++ b/registry/coder-labs/modules/sourcegraph-amp/scripts/install.sh @@ -1,9 +1,4 @@ #!/bin/bash - -if [ -f "$HOME/.bashrc" ]; then - source "$HOME"/.bashrc -fi - set -euo pipefail # ANSI colors diff --git a/registry/coder-labs/modules/sourcegraph-amp/scripts/start.sh b/registry/coder-labs/modules/sourcegraph-amp/scripts/start.sh index 7dbc22c1..5cd0d945 100644 --- a/registry/coder-labs/modules/sourcegraph-amp/scripts/start.sh +++ b/registry/coder-labs/modules/sourcegraph-amp/scripts/start.sh @@ -29,6 +29,7 @@ echo "--------------------------------" printf "Workspace: %s\n" "$ARG_AMP_START_DIRECTORY" printf "Task Prompt: %s\n" "$ARG_AMP_TASK_PROMPT" printf "ARG_REPORT_TASKS: %s\n" "$ARG_REPORT_TASKS" +printf "ARG_MODE: %s\n" "$ARG_MODE" echo "--------------------------------" ensure_command amp @@ -50,6 +51,13 @@ else printf "amp_api_key not provided\n" fi +ARGS=() + +if [ -n "$ARG_MODE" ]; then + printf "Running agent in: %s mode" "$ARG_MODE" + ARGS+=(--mode "$ARG_MODE") +fi + if [ -n "$ARG_AMP_TASK_PROMPT" ]; then if [ "$ARG_REPORT_TASKS" == "true" ]; then printf "amp task prompt provided : %s" "$ARG_AMP_TASK_PROMPT\n" @@ -58,8 +66,8 @@ if [ -n "$ARG_AMP_TASK_PROMPT" ]; then PROMPT="$ARG_AMP_TASK_PROMPT" fi # Pipe the prompt into amp, which will be run inside agentapi - agentapi server --type amp --term-width=67 --term-height=1190 -- bash -c "echo \"$PROMPT\" | amp" + agentapi server --type amp --term-width=67 --term-height=1190 -- bash -c "echo \"$PROMPT\" | amp" "${ARGS[@]}" else printf "No task prompt given.\n" - agentapi server --type amp --term-width=67 --term-height=1190 -- amp + agentapi server --type amp --term-width=67 --term-height=1190 -- amp "${ARGS[@]}" fi