diff --git a/README.md b/README.md index 77c571f..5bc64bc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cmd/server/server.go b/cmd/server/server.go index 3313b51..1b4c5c8 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -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 ) @@ -38,6 +39,7 @@ var agentTypeMap = map[AgentType]bool{ AgentTypeAider: true, AgentTypeCodex: true, AgentTypeGemini: true, + AgentTypeAmp: true, AgentTypeCustom: true, } diff --git a/cmd/server/server_test.go b/cmd/server/server_test.go index 59b1ccc..894c095 100644 --- a/cmd/server/server_test.go +++ b/cmd/server/server_test.go @@ -33,6 +33,11 @@ func TestParseAgentType(t *testing.T) { agentTypeVar: "", want: AgentTypeGemini, }, + { + firstArg: "amp", + agentTypeVar: "", + want: AgentTypeAmp, + }, { firstArg: "goose", agentTypeVar: "", diff --git a/lib/msgfmt/msgfmt.go b/lib/msgfmt/msgfmt.go index 3560aa7..a3cdd57 100644 --- a/lib/msgfmt/msgfmt.go +++ b/lib/msgfmt/msgfmt.go @@ -206,6 +206,7 @@ const ( AgentTypeAider AgentType = "aider" AgentTypeCodex AgentType = "codex" AgentTypeGemini AgentType = "gemini" + AgentTypeAmp AgentType = "amp" AgentTypeCustom AgentType = "custom" ) @@ -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: diff --git a/lib/msgfmt/msgfmt_test.go b/lib/msgfmt/msgfmt_test.go index b02cbbc..837ff52 100644 --- a/lib/msgfmt/msgfmt_test.go +++ b/lib/msgfmt/msgfmt_test.go @@ -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))) diff --git a/lib/msgfmt/testdata/format/amp/first_message/expected.txt b/lib/msgfmt/testdata/format/amp/first_message/expected.txt new file mode 100644 index 0000000..09bc56e --- /dev/null +++ b/lib/msgfmt/testdata/format/amp/first_message/expected.txt @@ -0,0 +1 @@ + Welcome to Amp \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/amp/first_message/msg.txt b/lib/msgfmt/testdata/format/amp/first_message/msg.txt new file mode 100644 index 0000000..c6e02c6 --- /dev/null +++ b/lib/msgfmt/testdata/format/amp/first_message/msg.txt @@ -0,0 +1,5 @@ + Welcome to Amp + +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/amp/first_message/user.txt b/lib/msgfmt/testdata/format/amp/first_message/user.txt new file mode 100644 index 0000000..e69de29 diff --git a/lib/msgfmt/testdata/format/amp/multi-line-input/expected.txt b/lib/msgfmt/testdata/format/amp/multi-line-input/expected.txt new file mode 100644 index 0000000..83d3fbd --- /dev/null +++ b/lib/msgfmt/testdata/format/amp/multi-line-input/expected.txt @@ -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. \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/amp/multi-line-input/msg.txt b/lib/msgfmt/testdata/format/amp/multi-line-input/msg.txt new file mode 100644 index 0000000..b56a298 --- /dev/null +++ b/lib/msgfmt/testdata/format/amp/multi-line-input/msg.txt @@ -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. \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/amp/multi-line-input/user.txt b/lib/msgfmt/testdata/format/amp/multi-line-input/user.txt new file mode 100644 index 0000000..c3b14b0 --- /dev/null +++ b/lib/msgfmt/testdata/format/amp/multi-line-input/user.txt @@ -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); + }; +}, []); +``` diff --git a/lib/msgfmt/testdata/format/amp/second_message/expected.txt b/lib/msgfmt/testdata/format/amp/second_message/expected.txt new file mode 100644 index 0000000..9315a81 --- /dev/null +++ b/lib/msgfmt/testdata/format/amp/second_message/expected.txt @@ -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? \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/amp/second_message/msg.txt b/lib/msgfmt/testdata/format/amp/second_message/msg.txt new file mode 100644 index 0000000..5a53bfe --- /dev/null +++ b/lib/msgfmt/testdata/format/amp/second_message/msg.txt @@ -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? \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/amp/second_message/user.txt b/lib/msgfmt/testdata/format/amp/second_message/user.txt new file mode 100644 index 0000000..3099b43 --- /dev/null +++ b/lib/msgfmt/testdata/format/amp/second_message/user.txt @@ -0,0 +1 @@ +How are you? \ No newline at end of file