feat(module/coder-labs/amp): add mode flag and disable animation (#550)
## 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 <!-- Briefly describe what this PR does and why --> ## Type of Change - [ ] New module - [ ] New template - [x] Bug fix - [x] Feature/enhancement - [x] Documentation - [ ] Other ## Module Information <!-- Delete this section if not applicable --> **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 <!-- Link related issues or write "None" if not applicable --> --------- Co-authored-by: DevCats <christofer@coder.com>
This commit is contained in:
parent
69e5dc5c80
commit
186e0c4de6
@ -12,12 +12,12 @@ Run [Amp CLI](https://ampcode.com/) in your workspace to access Sourcegraph's AI
|
|||||||
|
|
||||||
```tf
|
```tf
|
||||||
module "amp-cli" {
|
module "amp-cli" {
|
||||||
source = "registry.coder.com/coder-labs/sourcegraph-amp/coder"
|
source = "registry.coder.com/coder-labs/sourcegraph-amp/coder"
|
||||||
version = "2.0.2"
|
version = "2.1.0"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
sourcegraph_amp_api_key = var.sourcegraph_amp_api_key
|
amp_api_key = var.amp_api_key
|
||||||
install_sourcegraph_amp = true
|
install_amp = true
|
||||||
agentapi_version = "2.0.2"
|
agentapi_version = "latest"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ variable "amp_api_key" {
|
|||||||
module "amp-cli" {
|
module "amp-cli" {
|
||||||
count = data.coder_workspace.me.start_count
|
count = data.coder_workspace.me.start_count
|
||||||
source = "registry.coder.com/coder-labs/sourcegraph-amp/coder"
|
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
|
agent_id = coder_agent.example.id
|
||||||
amp_api_key = var.amp_api_key # recommended for tasks usage
|
amp_api_key = var.amp_api_key # recommended for tasks usage
|
||||||
workdir = "/home/coder/project"
|
workdir = "/home/coder/project"
|
||||||
|
|||||||
@ -55,7 +55,7 @@ variable "install_agentapi" {
|
|||||||
variable "agentapi_version" {
|
variable "agentapi_version" {
|
||||||
type = string
|
type = string
|
||||||
description = "The version of AgentAPI to install."
|
description = "The version of AgentAPI to install."
|
||||||
default = "v0.10.0"
|
default = "v0.11.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "cli_app" {
|
variable "cli_app" {
|
||||||
@ -160,6 +160,16 @@ variable "mcp" {
|
|||||||
default = null
|
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" {
|
data "external" "env" {
|
||||||
program = ["sh", "-c", "echo '{\"CODER_AGENT_TOKEN\":\"'$CODER_AGENT_TOKEN'\",\"CODER_AGENT_URL\":\"'$CODER_AGENT_URL'\"}'"]
|
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({
|
default_base_config = jsonencode({
|
||||||
"amp.anthropic.thinking.enabled" = true
|
"amp.anthropic.thinking.enabled" = true
|
||||||
"amp.todos.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)
|
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_START_DIRECTORY='${var.workdir}' \
|
||||||
ARG_AMP_TASK_PROMPT='${base64encode(var.ai_prompt)}' \
|
ARG_AMP_TASK_PROMPT='${base64encode(var.ai_prompt)}' \
|
||||||
ARG_REPORT_TASKS='${var.report_tasks}' \
|
ARG_REPORT_TASKS='${var.report_tasks}' \
|
||||||
|
ARG_MODE='${var.mode}' \
|
||||||
/tmp/start.sh
|
/tmp/start.sh
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ -f "$HOME/.bashrc" ]; then
|
|
||||||
source "$HOME"/.bashrc
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# ANSI colors
|
# ANSI colors
|
||||||
|
|||||||
@ -29,6 +29,7 @@ echo "--------------------------------"
|
|||||||
printf "Workspace: %s\n" "$ARG_AMP_START_DIRECTORY"
|
printf "Workspace: %s\n" "$ARG_AMP_START_DIRECTORY"
|
||||||
printf "Task Prompt: %s\n" "$ARG_AMP_TASK_PROMPT"
|
printf "Task Prompt: %s\n" "$ARG_AMP_TASK_PROMPT"
|
||||||
printf "ARG_REPORT_TASKS: %s\n" "$ARG_REPORT_TASKS"
|
printf "ARG_REPORT_TASKS: %s\n" "$ARG_REPORT_TASKS"
|
||||||
|
printf "ARG_MODE: %s\n" "$ARG_MODE"
|
||||||
echo "--------------------------------"
|
echo "--------------------------------"
|
||||||
|
|
||||||
ensure_command amp
|
ensure_command amp
|
||||||
@ -50,6 +51,13 @@ else
|
|||||||
printf "amp_api_key not provided\n"
|
printf "amp_api_key not provided\n"
|
||||||
fi
|
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 [ -n "$ARG_AMP_TASK_PROMPT" ]; then
|
||||||
if [ "$ARG_REPORT_TASKS" == "true" ]; then
|
if [ "$ARG_REPORT_TASKS" == "true" ]; then
|
||||||
printf "amp task prompt provided : %s" "$ARG_AMP_TASK_PROMPT\n"
|
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"
|
PROMPT="$ARG_AMP_TASK_PROMPT"
|
||||||
fi
|
fi
|
||||||
# Pipe the prompt into amp, which will be run inside agentapi
|
# 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
|
else
|
||||||
printf "No task prompt given.\n"
|
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
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user