Skip to content

feat: support Sourcegraph Amp cli #43

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

Merged
merged 6 commits into from
Aug 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# AgentAPI

Control [Claude Code](https://github.com/anthropics/claude-code), [Goose](https://github.com/block/goose), [Aider](https://github.com/Aider-AI/aider), [Gemini](https://github.com/google-gemini/gemini-cli) and [Codex](https://github.com/openai/codex) with an HTTP API.
Control [Claude Code](https://github.com/anthropics/claude-code), [Goose](https://github.com/block/goose), [Aider](https://github.com/Aider-AI/aider), [Gemini](https://github.com/google-gemini/gemini-cli), [Sourcegraph Amp](https://github.com/sourcegraph/amp-cli) and [Codex](https://github.com/openai/codex) with an HTTP API.

![agentapi-chat](https://github.com/user-attachments/assets/57032c9f-4146-4b66-b219-09e38ab7690d)


You can use AgentAPI:

- to build a unified chat interface for coding agents
Expand Down
2 changes: 2 additions & 0 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
AgentTypeAider AgentType = msgfmt.AgentTypeAider
AgentTypeCodex AgentType = msgfmt.AgentTypeCodex
AgentTypeGemini AgentType = msgfmt.AgentTypeGemini
AgentTypeAmp AgentType = msgfmt.AgentTypeAmp
AgentTypeCustom AgentType = msgfmt.AgentTypeCustom
)

Expand All @@ -38,6 +39,7 @@ var agentTypeMap = map[AgentType]bool{
AgentTypeAider: true,
AgentTypeCodex: true,
AgentTypeGemini: true,
AgentTypeAmp: true,
AgentTypeCustom: true,
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func TestParseAgentType(t *testing.T) {
agentTypeVar: "",
want: AgentTypeGemini,
},
{
firstArg: "amp",
agentTypeVar: "",
want: AgentTypeAmp,
},
{
firstArg: "goose",
agentTypeVar: "",
Expand Down
3 changes: 3 additions & 0 deletions lib/msgfmt/msgfmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ const (
AgentTypeAider AgentType = "aider"
AgentTypeCodex AgentType = "codex"
AgentTypeGemini AgentType = "gemini"
AgentTypeAmp AgentType = "amp"
AgentTypeCustom AgentType = "custom"
)

Expand Down Expand Up @@ -236,6 +237,8 @@ func FormatAgentMessage(agentType AgentType, message string, userInput string) s
return formatCodexMessage(message, userInput)
case AgentTypeGemini:
return formatGenericMessage(message, userInput)
case AgentTypeAmp:
return formatGenericMessage(message, userInput)
case AgentTypeCustom:
return formatGenericMessage(message, userInput)
default:
Expand Down
2 changes: 1 addition & 1 deletion lib/msgfmt/msgfmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestTrimEmptyLines(t *testing.T) {

func TestFormatAgentMessage(t *testing.T) {
dir := "testdata/format"
agentTypes := []AgentType{AgentTypeClaude, AgentTypeGoose, AgentTypeAider, AgentTypeGemini, AgentTypeCodex, AgentTypeCustom}
agentTypes := []AgentType{AgentTypeClaude, AgentTypeGoose, AgentTypeAider, AgentTypeGemini, AgentTypeAmp, AgentTypeCodex, AgentTypeCustom}
for _, agentType := range agentTypes {
t.Run(string(agentType), func(t *testing.T) {
cases, err := testdataDir.ReadDir(path.Join(dir, string(agentType)))
Expand Down
1 change: 1 addition & 0 deletions lib/msgfmt/testdata/format/amp/first_message/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Welcome to Amp
5 changes: 5 additions & 0 deletions lib/msgfmt/testdata/format/amp/first_message/msg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Welcome to Amp

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Empty file.
13 changes: 13 additions & 0 deletions lib/msgfmt/testdata/format/amp/multi-line-input/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
∴ Thinking
The user is asking me to identify which file contains this specific TypeScript code snippet. The code shows a useEffect hook that sets up polling
for messages and server status. I need to search for this code in the codebase to find the file it belongs to.

I should use the Grep tool to search for some unique parts of this code to locate the file.

✓ Grep Set up polling for messages and server status

✓ Grep const messageInterval = setInterval\(fetchMessages, 1000\)

✓ List Directory /mnt/c/Users/Username/test-amp

No files found in the workspace containing this code.
33 changes: 33 additions & 0 deletions lib/msgfmt/testdata/format/amp/multi-line-input/msg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
┃ Which file is this code from?
┃ ```ts
┃ // Set up polling for messages and server status
┃ useEffect(() => {
┃ // Check server status initially
┃ checkServerStatus();
┃ // Set up polling intervals
┃ const messageInterval = setInterval(fetchMessages, 1000);
┃ const statusInterval = setInterval(checkServerStatus, 250);
┃ // Clean up intervals on component unmount
┃ return () => {
┃ clearInterval(messageInterval);
┃ clearInterval(statusInterval);
┃ };
┃ }, []);
┃ ```

∴ Thinking
The user is asking me to identify which file contains this specific TypeScript code snippet. The code shows a useEffect hook that sets up polling
for messages and server status. I need to search for this code in the codebase to find the file it belongs to.

I should use the Grep tool to search for some unique parts of this code to locate the file.

✓ Grep Set up polling for messages and server status

✓ Grep const messageInterval = setInterval\(fetchMessages, 1000\)

✓ List Directory /mnt/c/Users/Username/test-amp

No files found in the workspace containing this code.
19 changes: 19 additions & 0 deletions lib/msgfmt/testdata/format/amp/multi-line-input/user.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Which file is this code from?

```ts
// Set up polling for messages and server status
useEffect(() => {
// Check server status initially
checkServerStatus();

// Set up polling intervals
const messageInterval = setInterval(fetchMessages, 1000);
const statusInterval = setInterval(checkServerStatus, 250);

// Clean up intervals on component unmount
return () => {
clearInterval(messageInterval);
clearInterval(statusInterval);
};
}, []);
```
8 changes: 8 additions & 0 deletions lib/msgfmt/testdata/format/amp/second_message/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
∴ Thinking
The user is asking a simple social greeting "How are you?". This is a casual question about my state/wellbeing. I should respond concisely and
directly as per my instructions to keep responses short (fewer than 4 lines unless asked for detail). I don't need to use any tools for this simple
greeting.

I should avoid elaborate explanations or summaries, and just give a brief, direct response.

I'm ready to help you with your coding tasks. What would you like to work on?
10 changes: 10 additions & 0 deletions lib/msgfmt/testdata/format/amp/second_message/msg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
┃ How are you?

∴ Thinking
The user is asking a simple social greeting "How are you?". This is a casual question about my state/wellbeing. I should respond concisely and
directly as per my instructions to keep responses short (fewer than 4 lines unless asked for detail). I don't need to use any tools for this simple
greeting.

I should avoid elaborate explanations or summaries, and just give a brief, direct response.

I'm ready to help you with your coding tasks. What would you like to work on?
1 change: 1 addition & 0 deletions lib/msgfmt/testdata/format/amp/second_message/user.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
How are you?