Skip to content
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AgentAPI

Control [Claude Code](https://github.com/anthropics/claude-code), [AmazonQ](https://aws.amazon.com/developer/learning/q-developer-cli/), [Opencode](https://opencode.ai/), [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), [Codex](https://github.com/openai/codex), [Auggie](https://docs.augmentcode.com/cli/overview), and [Cursor CLI](https://cursor.com/en/cli) with an HTTP API.
Control [Claude Code](https://github.com/anthropics/claude-code), [AmazonQ](https://aws.amazon.com/developer/learning/q-developer-cli/), [Opencode](https://opencode.ai/), [Goose](https://github.com/block/goose), [Aider](https://github.com/Aider-AI/aider), [Gemini](https://github.com/google-gemini/gemini-cli), [GitHub Copilot](https://github.com/github/copilot-cli), [Sourcegraph Amp](https://github.com/sourcegraph/amp-cli), [Codex](https://github.com/openai/codex), [Auggie](https://docs.augmentcode.com/cli/overview), and [Cursor CLI](https://cursor.com/en/cli) with an HTTP API.

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

Expand Down Expand Up @@ -65,7 +65,7 @@ agentapi server -- goose
```

> [!NOTE]
> When using Codex, Opencode, Gemini, Amp or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break.
> When using Codex, Opencode, Copilot, Gemini, Amp or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break.

An OpenAPI schema is available in [openapi.json](openapi.json).

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
AgentTypeCopilot AgentType = msgfmt.AgentTypeCopilot
AgentTypeAmp AgentType = msgfmt.AgentTypeAmp
AgentTypeCursor AgentType = msgfmt.AgentTypeCursor
AgentTypeAuggie AgentType = msgfmt.AgentTypeAuggie
Expand All @@ -43,6 +44,7 @@ var agentTypeAliases = map[string]AgentType{
"aider": AgentTypeAider,
"codex": AgentTypeCodex,
"gemini": AgentTypeGemini,
"copilot": AgentTypeCopilot,
"amp": AgentTypeAmp,
"auggie": AgentTypeAuggie,
"cursor": AgentTypeCursor,
Expand Down
10 changes: 10 additions & 0 deletions cmd/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func TestParseAgentType(t *testing.T) {
agentTypeVar: "",
want: AgentTypeGemini,
},
{
firstArg: "copilot",
agentTypeVar: "",
want: AgentTypeCopilot,
},
{
firstArg: "cursor-agent",
agentTypeVar: "",
Expand Down Expand Up @@ -102,6 +107,11 @@ func TestParseAgentType(t *testing.T) {
agentTypeVar: "goose",
want: AgentTypeGoose,
},
{
firstArg: "claude",
agentTypeVar: "copilot",
want: AgentTypeCopilot,
},
{
firstArg: "goose",
agentTypeVar: "claude",
Expand Down
27 changes: 15 additions & 12 deletions lib/msgfmt/msgfmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func RemoveUserInput(msgRaw string, userInputRaw string, agentType AgentType) st
lastUserInputLineIdx := msgRuneLineLocations[userInputEndIdx]

// Skip Gemini/Cursor trailing input box line
if agentType == AgentTypeGemini {
if agentType == AgentTypeGemini || agentType == AgentTypeCopilot {
if idx, found := skipTrailingInputBoxLine(msgLines, lastUserInputLineIdx, "╯", "╰"); found {
lastUserInputLineIdx = idx
}
Expand Down Expand Up @@ -232,17 +232,18 @@ func trimEmptyLines(message string) string {
type AgentType string

const (
AgentTypeClaude AgentType = "claude"
AgentTypeGoose AgentType = "goose"
AgentTypeAider AgentType = "aider"
AgentTypeCodex AgentType = "codex"
AgentTypeGemini AgentType = "gemini"
AgentTypeAmp AgentType = "amp"
AgentTypeCursor AgentType = "cursor"
AgentTypeAuggie AgentType = "auggie"
AgentTypeAmazonQ AgentType = "amazonq"
AgentTypeOpencode AgentType = "opencode"
AgentTypeCustom AgentType = "custom"
AgentTypeClaude AgentType = "claude"
AgentTypeGoose AgentType = "goose"
AgentTypeAider AgentType = "aider"
AgentTypeCodex AgentType = "codex"
AgentTypeGemini AgentType = "gemini"
AgentTypeCopilot AgentType = "copilot"
AgentTypeAmp AgentType = "amp"
AgentTypeCursor AgentType = "cursor"
AgentTypeAuggie AgentType = "auggie"
AgentTypeAmazonQ AgentType = "amazonq"
AgentTypeOpencode AgentType = "opencode"
AgentTypeCustom AgentType = "custom"
)

func formatGenericMessage(message string, userInput string, agentType AgentType) string {
Expand Down Expand Up @@ -278,6 +279,8 @@ func FormatAgentMessage(agentType AgentType, message string, userInput string) s
return formatCodexMessage(message, userInput)
case AgentTypeGemini:
return formatGenericMessage(message, userInput, agentType)
case AgentTypeCopilot:
return formatGenericMessage(message, userInput, agentType)
case AgentTypeAmp:
return formatGenericMessage(message, userInput, agentType)
case AgentTypeCursor:
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, AgentTypeAmp, AgentTypeCodex, AgentTypeCursor, AgentTypeAuggie, AgentTypeAmazonQ, AgentTypeOpencode, AgentTypeCustom}
agentTypes := []AgentType{AgentTypeClaude, AgentTypeGoose, AgentTypeAider, AgentTypeGemini, AgentTypeCopilot, AgentTypeAmp, AgentTypeCodex, AgentTypeCursor, AgentTypeAuggie, AgentTypeAmazonQ, AgentTypeOpencode, AgentTypeCustom}
for _, agentType := range agentTypes {
t.Run(string(agentType), func(t *testing.T) {
cases, err := testdataDir.ReadDir(path.Join(dir, string(agentType)))
Expand Down
21 changes: 21 additions & 0 deletions lib/msgfmt/testdata/format/copilot/confirmation_box/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
● I'll search for this code in the repository to find which file it belongs to.

○ Search for files containing the useEffect code with polling setup
$ find . -type f -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" | xargs grep -l "useEffect.*checkServerStatus\|Set up polling for messages and server status" 2>/dev/null
↪ 1 line...

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Search for files containing the useEffect code with polling setup: │
│ │
│ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ find . -type f -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" | xargs grep -l "useEffect.*checkServerStatus\|Set up polling for messages and server status" 2>/dev/null │ │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ Do you want to run this command? │
│ │
│ ❯ 1. Yes │
│ 2. Yes, and approve `xargs` for the rest of the running session │
│ 3. No, and tell Copilot what to do differently (Esc) │
│ │
│ Confirm with number keys or ↑↓ keys and Enter, Cancel with Esc │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Loading