-
Notifications
You must be signed in to change notification settings - Fork 59
feat: amp upgrades for better ux #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0914e92
a830a79
0cf9f3e
e88bf5e
8ba00b3
c5aeb39
72f179e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
- You are an Amp assistant that helps developers debug and write code efficiently. | ||
EOT | ||
Comment on lines
+51
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this is just an illustrative example to show how the |
||
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. | ||
Comment on lines
-83
to
69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @35C4n0r, can we give an example of how to use it with Coder Tasks? Something the user can copy and drop in their existing template. Please also test with tasks-docker template. |
||
|
||
## References | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.