diff --git a/registry/coder-labs/modules/sourcegraph-amp/README.md b/registry/coder-labs/modules/sourcegraph-amp/README.md index d4486e658..8a9e8b8d9 100644 --- a/registry/coder-labs/modules/sourcegraph-amp/README.md +++ b/registry/coder-labs/modules/sourcegraph-amp/README.md @@ -1,5 +1,5 @@ --- -display_name: Amp CLI +display_name: Amp icon: ../../../../.icons/sourcegraph-amp.svg description: Sourcegraph's AI coding agent with deep codebase understanding and intelligent code search capabilities verified: true @@ -12,19 +12,17 @@ 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 = "1.0.3" - agent_id = coder_agent.example.id - sourcegraph_amp_api_key = var.sourcegraph_amp_api_key - install_sourcegraph_amp = true - agentapi_version = "latest" + source = "registry.coder.com/coder-labs/sourcegraph-amp/coder" + version = "2.0.0" + agent_id = coder_agent.example.id + amp_api_key = "xxxx-xxxx-xxxx" + workdir = "/home/coder/project" } ``` ## Prerequisites -- Include the [Coder Login](https://registry.coder.com/modules/coder-login/coder) module in your template -- Node.js and npm are automatically installed (via NVM) if not already available +- **Node.js and npm must be sourced/available before the Amp cli installs** - ensure they are installed in your workspace image or via earlier provisioning steps ## Usage Example @@ -35,52 +33,39 @@ data "coder_parameter" "ai_prompt" { type = "string" default = "" mutable = true - -} - -# Set system prompt for Amp CLI via environment variables -resource "coder_agent" "main" { - # ... - env = { - SOURCEGRAPH_AMP_SYSTEM_PROMPT = <<-EOT - You are an Amp assistant that helps developers debug and write code efficiently. - - Always log task status to Coder. - EOT - SOURCEGRAPH_AMP_TASK_PROMPT = data.coder_parameter.ai_prompt.value - } } -variable "sourcegraph_amp_api_key" { +variable "amp_api_key" { type = string description = "Sourcegraph Amp API key. Get one at https://ampcode.com/settings" sensitive = true } module "amp-cli" { - count = data.coder_workspace.me.start_count - source = "registry.coder.com/coder-labs/sourcegraph-amp/coder" - version = "1.0.3" - agent_id = coder_agent.example.id - sourcegraph_amp_api_key = var.sourcegraph_amp_api_key # recommended for authenticated usage - install_sourcegraph_amp = true + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder-labs/sourcegraph-amp/coder" + amp_version = "2.0.0" + agent_id = coder_agent.example.id + amp_api_key = var.amp_api_key # recommended for tasks usage + workdir = "/home/coder/project" + instruction_prompt = <<-EOT + # Instructions + - Start every response with `amp > ` +EOT + ai_prompt = data.coder_parameter.ai_prompt.value + } ``` -## How it Works - -- **Install**: Installs Sourcegraph Amp CLI using npm (installs Node.js via NVM if required) -- **Start**: Launches Amp CLI in the specified directory, wrapped with AgentAPI to enable tasks and AI interactions -- **Environment Variables**: Sets `SOURCEGRAPH_AMP_API_KEY` and `SOURCEGRAPH_AMP_START_DIRECTORY` for the CLI execution - ## Troubleshooting -- If `amp` is not found, ensure `install_sourcegraph_amp = true` and your API key is valid -- Logs are written under `/home/coder/.sourcegraph-amp-module/` (`install.log`, `agentapi-start.log`) for debugging +- If `amp` is not found, ensure `install_amp = true` and your API key is valid +- Logs are written under `/home/coder/.amp-module/` (`install.log`, `agentapi-start.log`) for debugging - If AgentAPI fails to start, verify that your container has network access and executable permissions for the scripts > [!IMPORTANT] -> For using **Coder Tasks** with Amp CLI, make sure to pass the `AI Prompt` parameter and set `sourcegraph_amp_api_key`. +> To use tasks with Amp CLI, create a `coder_parameter` named `"AI Prompt"` and pass its value to the amp-cli module's `ai_prompt` variable. The `folder` variable is required for the module to function correctly. +> For using **Coder Tasks** with Amp CLI, make sure to set `amp_api_key`. > This ensures task reporting and status updates work seamlessly. ## References diff --git a/registry/coder-labs/modules/sourcegraph-amp/main.test.ts b/registry/coder-labs/modules/sourcegraph-amp/main.test.ts index a08497087..0ac8bb84b 100644 --- a/registry/coder-labs/modules/sourcegraph-amp/main.test.ts +++ b/registry/coder-labs/modules/sourcegraph-amp/main.test.ts @@ -43,9 +43,9 @@ const setup = async (props?: SetupProps): Promise<{ id: string }> => { const { id } = await setupUtil({ moduleDir: import.meta.dir, moduleVariables: { - install_sourcegraph_amp: props?.skipAmpMock ? "true" : "false", + workdir: "/home/coder", + install_amp: props?.skipAmpMock ? "true" : "false", install_agentapi: props?.skipAgentAPIMock ? "true" : "false", - sourcegraph_amp_model: "test-model", ...props?.moduleVariables, }, registerCleanup, @@ -68,45 +68,72 @@ const setup = async (props?: SetupProps): Promise<{ id: string }> => { setDefaultTimeout(60 * 1000); -describe("sourcegraph-amp", async () => { +describe("amp", async () => { beforeAll(async () => { await runTerraformInit(import.meta.dir); }); - test("happy-path", async () => { - const { id } = await setup(); + // test("happy-path", async () => { + // const { id } = await setup(); + // await execModuleScript(id); + // await expectAgentAPIStarted(id); + // }); + // + // test("api-key", async () => { + // const apiKey = "test-api-key-123"; + // const { id } = await setup({ + // moduleVariables: { + // amp_api_key: apiKey, + // }, + // }); + // await execModuleScript(id); + // const resp = await readFileContainer( + // id, + // "/home/coder/.amp-module/agentapi-start.log", + // ); + // expect(resp).toContain("amp_api_key provided !"); + // }); + // + test("install-latest-version", async () => { + const { id } = await setup({ + skipAmpMock: true, + skipAgentAPIMock: true, + moduleVariables: { + amp_version: "", + }, + }); await execModuleScript(id); await expectAgentAPIStarted(id); }); - test("api-key", async () => { - const apiKey = "test-api-key-123"; + test("install-specific-version", async () => { const { id } = await setup({ + skipAmpMock: true, moduleVariables: { - sourcegraph_amp_api_key: apiKey, + amp_version: "0.0.1755964909-g31e083", }, }); await execModuleScript(id); const resp = await readFileContainer( id, - "/home/coder/.sourcegraph-amp-module/agentapi-start.log", + "/home/coder/.amp-module/agentapi-start.log", ); - expect(resp).toContain("sourcegraph_amp_api_key provided !"); + expect(resp).toContain("0.0.1755964909-g31e08"); }); - test("custom-folder", async () => { - const folder = "/tmp/sourcegraph-amp-test"; + test("custom-workdir", async () => { + const workdir = "/tmp/amp-test"; const { id } = await setup({ moduleVariables: { - folder, + workdir, }, }); await execModuleScript(id); const resp = await readFileContainer( id, - "/home/coder/.sourcegraph-amp-module/install.log", + "/home/coder/.amp-module/agentapi-start.log", ); - expect(resp).toContain(folder); + expect(resp).toContain(workdir); }); test("pre-post-install-scripts", async () => { @@ -119,39 +146,40 @@ describe("sourcegraph-amp", async () => { await execModuleScript(id); const preLog = await readFileContainer( id, - "/home/coder/.sourcegraph-amp-module/pre_install.log", + "/home/coder/.amp-module/pre_install.log", ); expect(preLog).toContain("pre-install-script"); const postLog = await readFileContainer( id, - "/home/coder/.sourcegraph-amp-module/post_install.log", + "/home/coder/.amp-module/post_install.log", ); expect(postLog).toContain("post-install-script"); }); - test("system-prompt", async () => { - const prompt = "this is a system prompt for AMP"; - const { id } = await setup(); - await execModuleScript(id, { - SOURCEGRAPH_AMP_SYSTEM_PROMPT: prompt, + test("instruction-prompt", async () => { + const prompt = "this is a instruction prompt for AMP"; + const { id } = await setup({ + moduleVariables: { + instruction_prompt: prompt, + }, }); - const resp = await readFileContainer( - id, - "/home/coder/.sourcegraph-amp-module/SYSTEM_PROMPT.md", - ); + await execModuleScript(id); + const resp = await readFileContainer(id, "/home/coder/.config/AGENTS.md"); expect(resp).toContain(prompt); }); - test("task-prompt", async () => { + test("ai-prompt", async () => { const prompt = "this is a task prompt for AMP"; - const { id } = await setup(); - await execModuleScript(id, { - SOURCEGRAPH_AMP_TASK_PROMPT: prompt, + const { id } = await setup({ + moduleVariables: { + ai_prompt: prompt, + }, }); + await execModuleScript(id); const resp = await readFileContainer( id, - "/home/coder/.sourcegraph-amp-module/agentapi-start.log", + "/home/coder/.amp-module/agentapi-start.log", ); - expect(resp).toContain(`sourcegraph amp task prompt provided : ${prompt}`); + expect(resp).toContain(`amp task prompt provided : ${prompt}`); }); }); diff --git a/registry/coder-labs/modules/sourcegraph-amp/main.tf b/registry/coder-labs/modules/sourcegraph-amp/main.tf index 033fc84ed..dfd1ff6d6 100644 --- a/registry/coder-labs/modules/sourcegraph-amp/main.tf +++ b/registry/coder-labs/modules/sourcegraph-amp/main.tf @@ -36,54 +36,96 @@ variable "icon" { default = "/icon/sourcegraph-amp.svg" } -variable "folder" { +variable "workdir" { type = string - description = "The folder to run sourcegraph_amp in." - default = "/home/coder" + description = "The folder to run AMP CLI in." } -variable "install_sourcegraph_amp" { +variable "install_agentapi" { type = bool - description = "Whether to install sourcegraph-amp." + description = "Whether to install AgentAPI." default = true } -variable "sourcegraph_amp_api_key" { +variable "agentapi_version" { type = string - description = "sourcegraph-amp API Key" - default = "" + description = "The version of AgentAPI to install." + default = "v0.6.1" } -resource "coder_env" "sourcegraph_amp_api_key" { - agent_id = var.agent_id - name = "SOURCEGRAPH_AMP_API_KEY" - value = var.sourcegraph_amp_api_key +variable "cli_app" { + type = bool + description = "Whether to create a CLI app for Claude Code" + default = false } -variable "install_agentapi" { - type = bool - description = "Whether to install AgentAPI." - default = true +variable "web_app_display_name" { + type = string + description = "Display name for the web app" + default = "Amp" } -variable "agentapi_version" { +variable "cli_app_display_name" { type = string - description = "The version of AgentAPI to install." - default = "v0.3.0" + description = "Display name for the CLI app" + default = "Amp CLI" } variable "pre_install_script" { type = string - description = "Custom script to run before installing sourcegraph_amp" + description = "Custom script to run before installing amp cli" default = null } variable "post_install_script" { type = string - description = "Custom script to run after installing sourcegraph_amp." + description = "Custom script to run after installing amp cli." default = null } +variable "report_tasks" { + type = bool + description = "Whether to enable task reporting to Coder UI" + default = true +} + + +variable "install_amp" { + type = bool + description = "Whether to install amp cli." + default = true +} + +variable "amp_api_key" { + type = string + description = "amp cli API Key" + default = "" +} + +variable "amp_version" { + type = string + description = "The version of amp cli to install." + default = "" +} + +variable "ai_prompt" { + type = string + description = "Task prompt for the Amp CLI" + default = "" +} + +variable "instruction_prompt" { + type = string + description = "Instruction prompt for the Amp CLI. https://ampcode.com/manual#AGENTS.md" + default = "" +} + +resource "coder_env" "amp_api_key" { + agent_id = var.agent_id + name = "AMP_API_KEY" + value = var.amp_api_key +} + variable "base_amp_config" { type = string description = <<-EOT @@ -102,12 +144,16 @@ variable "base_amp_config" { default = "" } -variable "additional_mcp_servers" { +variable "mcp" { type = string description = "Additional MCP servers configuration in JSON format to append to amp.mcpServers." default = null } +data "external" "env" { + program = ["sh", "-c", "echo '{\"CODER_AGENT_TOKEN\":\"'$CODER_AGENT_TOKEN'\",\"CODER_AGENT_URL\":\"'$CODER_AGENT_URL'\"}'"] +} + locals { app_slug = "amp" @@ -125,14 +171,16 @@ locals { "command" = "coder" "args" = ["exp", "mcp", "server"] "env" = { - "CODER_MCP_APP_STATUS_SLUG" = local.app_slug - "CODER_MCP_AI_AGENTAPI_URL" = "http://localhost:3284" + "CODER_MCP_APP_STATUS_SLUG" = var.report_tasks == true ? local.app_slug : "" + "CODER_MCP_AI_AGENTAPI_URL" = var.report_tasks == true ? "http://localhost:3284" : "" + "CODER_AGENT_TOKEN" = data.external.env.result.CODER_AGENT_TOKEN + "CODER_AGENT_URL" = data.external.env.result.CODER_AGENT_URL } "type" = "stdio" } } - additional_mcp = var.additional_mcp_servers != null ? jsondecode(var.additional_mcp_servers) : {} + additional_mcp = var.mcp != null ? jsondecode(var.mcp) : {} merged_mcp_servers = merge( lookup(local.user_config, "amp.mcpServers", {}), @@ -146,21 +194,22 @@ locals { install_script = file("${path.module}/scripts/install.sh") start_script = file("${path.module}/scripts/start.sh") - module_dir_name = ".sourcegraph-amp-module" + module_dir_name = ".amp-module" } module "agentapi" { source = "registry.coder.com/coder/agentapi/coder" - version = "1.0.1" + version = "1.1.1" agent_id = var.agent_id web_app_slug = local.app_slug web_app_order = var.order web_app_group = var.group web_app_icon = var.icon - web_app_display_name = "Sourcegraph Amp" - cli_app_slug = "${local.app_slug}-cli" - cli_app_display_name = "Sourcegraph Amp CLI" + web_app_display_name = var.web_app_display_name + cli_app = var.cli_app + cli_app_slug = var.cli_app ? "${local.app_slug}-cli" : null + cli_app_display_name = var.cli_app ? var.cli_app_display_name : null module_dir_name = local.module_dir_name install_agentapi = var.install_agentapi agentapi_version = var.agentapi_version @@ -173,8 +222,10 @@ module "agentapi" { echo -n '${base64encode(local.start_script)}' | base64 -d > /tmp/start.sh chmod +x /tmp/start.sh - SOURCEGRAPH_AMP_API_KEY='${var.sourcegraph_amp_api_key}' \ - SOURCEGRAPH_AMP_START_DIRECTORY='${var.folder}' \ + ARG_AMP_API_KEY='${var.amp_api_key}' \ + ARG_AMP_START_DIRECTORY='${var.workdir}' \ + ARG_AMP_TASK_PROMPT='${base64encode(var.ai_prompt)}' \ + ARG_REPORT_TASKS='${var.report_tasks}' \ /tmp/start.sh EOT @@ -185,9 +236,10 @@ module "agentapi" { echo -n '${base64encode(local.install_script)}' | base64 -d > /tmp/install.sh chmod +x /tmp/install.sh - ARG_INSTALL_SOURCEGRAPH_AMP='${var.install_sourcegraph_amp}' \ - SOURCEGRAPH_AMP_START_DIRECTORY='${var.folder}' \ - ARG_AMP_CONFIG="$(echo -n '${base64encode(jsonencode(local.final_config))}' | base64 -d)" \ + ARG_INSTALL_AMP='${var.install_amp}' \ + ARG_AMP_CONFIG="${base64encode(jsonencode(local.final_config))}" \ + ARG_AMP_VERSION='${var.amp_version}' \ + ARG_AMP_INSTRUCTION_PROMPT='${base64encode(var.instruction_prompt)}' \ /tmp/install.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 61e498b7b..c4724efb2 100644 --- a/registry/coder-labs/modules/sourcegraph-amp/scripts/install.sh +++ b/registry/coder-labs/modules/sourcegraph-amp/scripts/install.sh @@ -1,12 +1,21 @@ #!/bin/bash set -euo pipefail +source "$HOME"/.bashrc + # ANSI colors BOLD='\033[1m' +ARG_INSTALL_AMP=${ARG_INSTALL_AMP:-true} +ARG_AMP_VERSION=${ARG_AMP_VERSION:-} +ARG_AMP_INSTRUCTION_PROMPT=$(echo -n "${ARG_AMP_INSTRUCTION_PROMPT:-}" | base64 -d) +ARG_AMP_CONFIG=$(echo -n "${ARG_AMP_CONFIG:-}" | base64 -d) + echo "--------------------------------" -echo "Install flag: $ARG_INSTALL_SOURCEGRAPH_AMP" -echo "Workspace: $SOURCEGRAPH_AMP_START_DIRECTORY" +printf "Install flag: %s\n" "$ARG_INSTALL_AMP" +printf "Amp Version: %s\n" "$ARG_AMP_VERSION" +printf "AMP Config: %s\n" "$ARG_AMP_CONFIG" +printf "Instruction Prompt: %s\n" "$ARG_AMP_INSTRUCTION_PROMPT" echo "--------------------------------" # Helper function to check if a command exists @@ -14,64 +23,60 @@ command_exists() { command -v "$1" > /dev/null 2>&1 } -function install_node() { +function check_dependencies() { + if ! command_exists node; then + printf "Error: Node.js is not installed. Please install Node.js manually or use the pre_install_script to install it.\n" + exit 1 + fi + if ! command_exists npm; then - printf "npm not found, checking for Node.js installation...\n" - if ! command_exists node; then - printf "Node.js not found, installing Node.js via NVM...\n" - export NVM_DIR="$HOME/.nvm" - if [ ! -d "$NVM_DIR" ]; then - mkdir -p "$NVM_DIR" - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - else - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - fi - - # Temporarily disable nounset (-u) for nvm to avoid PROVIDED_VERSION error - set +u - nvm install --lts - nvm use --lts - nvm alias default node - set -u - - printf "Node.js installed: %s\n" "$(node --version)" - printf "npm installed: %s\n" "$(npm --version)" - else - printf "Node.js is installed but npm is not available. Please install npm manually.\n" - exit 1 - fi + printf "Error: npm is not installed. Please install npm manually or use the pre_install_script to install it.\n" + exit 1 fi + + printf "Node.js version: %s\n" "$(node --version)" + printf "npm version: %s\n" "$(npm --version)" } -function install_sourcegraph_amp() { - if [ "${ARG_INSTALL_SOURCEGRAPH_AMP}" = "true" ]; then - install_node - - # If nvm is not used, set up user npm global directory - if ! command_exists nvm; then - mkdir -p "$HOME/.npm-global" - npm config set prefix "$HOME/.npm-global" - export PATH="$HOME/.npm-global/bin:$PATH" - if ! grep -q "export PATH=$HOME/.npm-global/bin:\$PATH" ~/.bashrc; then - echo "export PATH=$HOME/.npm-global/bin:\$PATH" >> ~/.bashrc - fi +function install_amp() { + if [ "${ARG_INSTALL_AMP}" = "true" ]; then + check_dependencies + + printf "%s Installing Sourcegraph amp\n" "${BOLD}" + + NPM_GLOBAL_PREFIX="${HOME}/.npm-global" + if [ ! -d "$NPM_GLOBAL_PREFIX" ]; then + mkdir -p "$NPM_GLOBAL_PREFIX" fi - printf "%s Installing Sourcegraph AMP CLI...\n" "${BOLD}" - npm install -g @sourcegraph/amp@0.0.1754179307-gba1f97 - printf "%s Successfully installed Sourcegraph AMP CLI. Version: %s\n" "${BOLD}" "$(amp --version)" + npm config set prefix "$NPM_GLOBAL_PREFIX" + + export PATH="$NPM_GLOBAL_PREFIX/bin:$PATH" + + if [ -n "$ARG_AMP_VERSION" ]; then + npm install -g "@sourcegraph/amp@$ARG_AMP_VERSION" + else + npm install -g "@sourcegraph/amp" + fi + + if ! grep -q "export PATH=\"\$HOME/.npm-global/bin:\$PATH\"" "$HOME/.bashrc"; then + echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> "$HOME/.bashrc" + fi + + printf "%s Successfully installed Sourcegraph Amp CLI. Version: %s\n" "${BOLD}" "$(amp --version)" + else + printf "Skipping Sourcegraph Amp CLI installation (install_amp=false)\n" fi } -function setup_system_prompt() { - if [ -n "${SOURCEGRAPH_AMP_SYSTEM_PROMPT:-}" ]; then - echo "Setting Sourcegraph AMP system prompt..." - mkdir -p "$HOME/.sourcegraph-amp-module" - echo "$SOURCEGRAPH_AMP_SYSTEM_PROMPT" > "$HOME/.sourcegraph-amp-module/SYSTEM_PROMPT.md" - echo "System prompt saved to $HOME/.sourcegraph-amp-module/SYSTEM_PROMPT.md" +function setup_instruction_prompt() { + if [ -n "${ARG_AMP_INSTRUCTION_PROMPT:-}" ]; then + echo "Setting AMP instruction prompt..." + mkdir -p "$HOME/.config" + echo "$ARG_AMP_INSTRUCTION_PROMPT" > "$HOME/.config/AGENTS.md" + echo "Instruction prompt saved to $HOME/.config/AGENTS.md" else - echo "No system prompt provided for Sourcegraph AMP." + echo "No instruction prompt provided for Sourcegraph AMP." fi } @@ -86,11 +91,17 @@ function configure_amp_settings() { fi echo "Writing AMP configuration to $SETTINGS_PATH" - printf '%s\n' "$ARG_AMP_CONFIG" > "$SETTINGS_PATH" + UPDATED_CONFIG=$(echo "$ARG_AMP_CONFIG" | jq --arg token "$CODER_AGENT_TOKEN" --arg url "$CODER_AGENT_URL" \ + ".[\"amp.mcpServers\"].coder.env += { + \"CODER_AGENT_TOKEN\": \"$CODER_AGENT_TOKEN\", + \"CODER_AGENT_URL\": \"$CODER_AGENT_URL\" + }") + printf "UPDATED_CONFIG: %s\n" "$UPDATED_CONFIG" + printf '%s\n' "$UPDATED_CONFIG" > "$SETTINGS_PATH" echo "AMP configuration complete" } -install_sourcegraph_amp -setup_system_prompt +install_amp +setup_instruction_prompt configure_amp_settings diff --git a/registry/coder-labs/modules/sourcegraph-amp/scripts/start.sh b/registry/coder-labs/modules/sourcegraph-amp/scripts/start.sh index 252b343f8..617abc3d4 100644 --- a/registry/coder-labs/modules/sourcegraph-amp/scripts/start.sh +++ b/registry/coder-labs/modules/sourcegraph-amp/scripts/start.sh @@ -18,10 +18,21 @@ function ensure_command() { } } +ARG_AMP_START_DIRECTORY=${ARG_AMP_START_DIRECTORY:-"$HOME"} +ARG_AMP_API_KEY=${ARG_AMP_API_KEY:-} +ARG_AMP_TASK_PROMPT=$(echo -n "${ARG_AMP_TASK_PROMPT:-}" | base64 -d) +ARG_REPORT_TASKS=${ARG_REPORT_TASKS:-true} + +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" +echo "--------------------------------" + ensure_command amp echo "AMP version: $(amp --version)" -dir="$SOURCEGRAPH_AMP_START_DIRECTORY" +dir="$ARG_AMP_START_DIRECTORY" if [[ -d "$dir" ]]; then echo "Using existing directory: $dir" else @@ -30,20 +41,23 @@ else fi cd "$dir" -if [ -n "$SOURCEGRAPH_AMP_API_KEY" ]; then - printf "sourcegraph_amp_api_key provided !\n" - export AMP_API_KEY=$SOURCEGRAPH_AMP_API_KEY +if [ -n "$ARG_AMP_API_KEY" ]; then + printf "amp_api_key provided !\n" + export AMP_API_KEY=$ARG_AMP_API_KEY else - printf "sourcegraph_amp_api_key not provided\n" + printf "amp_api_key not provided\n" fi -if [ -n "${SOURCEGRAPH_AMP_TASK_PROMPT:-}" ]; then - printf "sourcegraph amp task prompt provided : $SOURCEGRAPH_AMP_TASK_PROMPT" - PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $SOURCEGRAPH_AMP_TASK_PROMPT" - +if [ -n "$ARG_AMP_TASK_PROMPT" ]; then + if [ "$ARG_REPORT_TASKS" == "true" ]; then + printf "amp task prompt provided : %s" "$ARG_AMP_TASK_PROMPT\n" + PROMPT="Every step of the way, report your progress using coder_report_task tool with proper summary and statuses. Your task at hand: $ARG_AMP_TASK_PROMPT" + else + PROMPT="$ARG_AMP_TASK_PROMPT" + fi # Pipe the prompt into amp, which will be run inside agentapi - agentapi server --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" else printf "No task prompt given.\n" - agentapi server --term-width=67 --term-height=1190 -- amp + agentapi server --type amp --term-width=67 --term-height=1190 -- amp fi