Skip to content

Commit 1b6c85b

Browse files
authored
feat: support Sourcegraph Amp cli (#43)
1 parent 797a81e commit 1b6c85b

File tree

14 files changed

+102
-2
lines changed

14 files changed

+102
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AgentAPI
22

3-
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.
3+
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.
44

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

cmd/server/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
AgentTypeAider AgentType = msgfmt.AgentTypeAider
2929
AgentTypeCodex AgentType = msgfmt.AgentTypeCodex
3030
AgentTypeGemini AgentType = msgfmt.AgentTypeGemini
31+
AgentTypeAmp AgentType = msgfmt.AgentTypeAmp
3132
AgentTypeCustom AgentType = msgfmt.AgentTypeCustom
3233
)
3334

@@ -38,6 +39,7 @@ var agentTypeMap = map[AgentType]bool{
3839
AgentTypeAider: true,
3940
AgentTypeCodex: true,
4041
AgentTypeGemini: true,
42+
AgentTypeAmp: true,
4143
AgentTypeCustom: true,
4244
}
4345

cmd/server/server_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func TestParseAgentType(t *testing.T) {
4747
agentTypeVar: "",
4848
want: AgentTypeGemini,
4949
},
50+
{
51+
firstArg: "amp",
52+
agentTypeVar: "",
53+
want: AgentTypeAmp,
54+
},
5055
{
5156
firstArg: "goose",
5257
agentTypeVar: "",

lib/msgfmt/msgfmt.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ const (
206206
AgentTypeAider AgentType = "aider"
207207
AgentTypeCodex AgentType = "codex"
208208
AgentTypeGemini AgentType = "gemini"
209+
AgentTypeAmp AgentType = "amp"
209210
AgentTypeCustom AgentType = "custom"
210211
)
211212

@@ -235,6 +236,8 @@ func FormatAgentMessage(agentType AgentType, message string, userInput string) s
235236
return formatCodexMessage(message, userInput)
236237
case AgentTypeGemini:
237238
return formatGenericMessage(message, userInput)
239+
case AgentTypeAmp:
240+
return formatGenericMessage(message, userInput)
238241
case AgentTypeCustom:
239242
return formatGenericMessage(message, userInput)
240243
default:

lib/msgfmt/msgfmt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func TestTrimEmptyLines(t *testing.T) {
218218

219219
func TestFormatAgentMessage(t *testing.T) {
220220
dir := "testdata/format"
221-
agentTypes := []AgentType{AgentTypeClaude, AgentTypeGoose, AgentTypeAider, AgentTypeGemini, AgentTypeCodex, AgentTypeCustom}
221+
agentTypes := []AgentType{AgentTypeClaude, AgentTypeGoose, AgentTypeAider, AgentTypeGemini, AgentTypeAmp, AgentTypeCodex, AgentTypeCustom}
222222
for _, agentType := range agentTypes {
223223
t.Run(string(agentType), func(t *testing.T) {
224224
cases, err := testdataDir.ReadDir(path.Join(dir, string(agentType)))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Welcome to Amp
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Welcome to Amp
2+
3+
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
4+
│ │
5+
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

lib/msgfmt/testdata/format/amp/first_message/user.txt

Whitespace-only changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
∴ Thinking
2+
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
3+
for messages and server status. I need to search for this code in the codebase to find the file it belongs to.
4+
5+
I should use the Grep tool to search for some unique parts of this code to locate the file.
6+
7+
✓ Grep Set up polling for messages and server status
8+
9+
✓ Grep const messageInterval = setInterval\(fetchMessages, 1000\)
10+
11+
✓ List Directory /mnt/c/Users/Username/test-amp
12+
13+
No files found in the workspace containing this code.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
┃ Which file is this code from?
2+
3+
┃ ```ts
4+
┃ // Set up polling for messages and server status
5+
┃ useEffect(() => {
6+
┃ // Check server status initially
7+
┃ checkServerStatus();
8+
9+
┃ // Set up polling intervals
10+
┃ const messageInterval = setInterval(fetchMessages, 1000);
11+
┃ const statusInterval = setInterval(checkServerStatus, 250);
12+
13+
┃ // Clean up intervals on component unmount
14+
┃ return () => {
15+
┃ clearInterval(messageInterval);
16+
┃ clearInterval(statusInterval);
17+
┃ };
18+
┃ }, []);
19+
┃ ```
20+
21+
∴ Thinking
22+
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
23+
for messages and server status. I need to search for this code in the codebase to find the file it belongs to.
24+
25+
I should use the Grep tool to search for some unique parts of this code to locate the file.
26+
27+
✓ Grep Set up polling for messages and server status
28+
29+
✓ Grep const messageInterval = setInterval\(fetchMessages, 1000\)
30+
31+
✓ List Directory /mnt/c/Users/Username/test-amp
32+
33+
No files found in the workspace containing this code.

0 commit comments

Comments
 (0)