-
Notifications
You must be signed in to change notification settings - Fork 94
feat: Improved initial prompt handling #142
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
Open
35C4n0r
wants to merge
8
commits into
coder:main
Choose a base branch
from
35C4n0r:feat-splash-detection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9e37080
feat: improved initial prompt
35C4n0r 6a974dd
chore: rename file
35C4n0r 46fe9a6
Merge branch 'main' into feat-splash-detection
35C4n0r ff26f8c
feat: minor fixes
35C4n0r dcd146f
feat: add tests
35C4n0r aeae1b1
chore: refactor names
35C4n0r d8057d5
chore: update tests
35C4n0r 96b1610
chore
35C4n0r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package msgfmt | ||
|
|
||
| func IsAgentReadyForInitialPrompt(agentType AgentType, message string) bool { | ||
| switch agentType { | ||
| case AgentTypeClaude: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| case AgentTypeGoose: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| case AgentTypeAider: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| case AgentTypeCodex: | ||
| return isCodexAgentReadyForInitialPrompt(message) | ||
| case AgentTypeGemini: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| case AgentTypeCopilot: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| case AgentTypeAmp: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| case AgentTypeCursor: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| case AgentTypeAuggie: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| case AgentTypeAmazonQ: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| case AgentTypeOpencode: | ||
| return isOpencodeAgentReadyForInitialPrompt(message) | ||
| case AgentTypeCustom: | ||
| return isGenericAgentReadyForInitialPrompt(message) | ||
| default: | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| func isGenericAgentReadyForInitialPrompt(message string) bool { | ||
| message = trimEmptyLines(message) | ||
| messageWithoutInputBox := removeMessageBox(message) | ||
| return len(messageWithoutInputBox) != len(message) | ||
| } | ||
|
|
||
| func isOpencodeAgentReadyForInitialPrompt(message string) bool { | ||
| message = trimEmptyLines(message) | ||
| messageWithoutInputBox := removeOpencodeMessageBox(message) | ||
| return len(messageWithoutInputBox) != len(message) | ||
| } | ||
|
|
||
| func isCodexAgentReadyForInitialPrompt(message string) bool { | ||
| message = trimEmptyLines(message) | ||
| messageWithoutInputBox := removeCodexInputBox(message) | ||
| return len(messageWithoutInputBox) != len(message) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package msgfmt | ||
|
|
||
| import ( | ||
| "path" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestIsAgentReadyForInitialPrompt(t *testing.T) { | ||
| dir := "testdata/initialization" | ||
| 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) { | ||
| t.Run("ready", func(t *testing.T) { | ||
| cases, err := testdataDir.ReadDir(path.Join(dir, string(agentType), "ready")) | ||
| if err != nil { | ||
| t.Skipf("failed to read ready cases for agent type %s: %s", agentType, err) | ||
| } | ||
| if len(cases) == 0 { | ||
| t.Skipf("no ready cases found for agent type %s", agentType) | ||
| } | ||
| for _, c := range cases { | ||
| if c.IsDir() { | ||
| continue | ||
| } | ||
| t.Run(c.Name(), func(t *testing.T) { | ||
| msg, err := testdataDir.ReadFile(path.Join(dir, string(agentType), "ready", c.Name())) | ||
| assert.NoError(t, err) | ||
| assert.True(t, IsAgentReadyForInitialPrompt(agentType, string(msg)), "Expected agent to be ready for message:\n%s", string(msg)) | ||
| }) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("not_ready", func(t *testing.T) { | ||
| cases, err := testdataDir.ReadDir(path.Join(dir, string(agentType), "not_ready")) | ||
| if err != nil { | ||
| t.Skipf("failed to read not_ready cases for agent type %s: %s", agentType, err) | ||
| } | ||
| if len(cases) == 0 { | ||
| t.Skipf("no not_ready cases found for agent type %s", agentType) | ||
| } | ||
| for _, c := range cases { | ||
| if c.IsDir() { | ||
| continue | ||
| } | ||
| t.Run(c.Name(), func(t *testing.T) { | ||
| msg, err := testdataDir.ReadFile(path.Join(dir, string(agentType), "not_ready", c.Name())) | ||
| assert.NoError(t, err) | ||
| assert.False(t, IsAgentReadyForInitialPrompt(agentType, string(msg)), "Expected agent to not be ready for message:\n%s", string(msg)) | ||
| }) | ||
| } | ||
| }) | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ──────────────────────────────────────────────────────────────────────────────── | ||
| Aider v0.81.1 | ||
| Main model: anthropic/claude-3-7-sonnet-20250219 with diff edit format, infinite | ||
| output | ||
| Weak model: anthropic/claude-3-5-haiku-20241022 | ||
| Git repo: .git with 47 files | ||
| Repo-map: using 4096 tokens, auto refresh | ||
| ──────────────────────────────────────────────────────────────────────────────── |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ──────────────────────────────────────────────────────────────────────────────── | ||
| Aider v0.81.1 | ||
| Main model: anthropic/claude-3-7-sonnet-20250219 with diff edit format, infinite | ||
| output | ||
| Weak model: anthropic/claude-3-5-haiku-20241022 | ||
| Git repo: .git with 47 files | ||
| Repo-map: using 4096 tokens, auto refresh | ||
| ──────────────────────────────────────────────────────────────────────────────── | ||
| > |
12 changes: 12 additions & 0 deletions
12
lib/msgfmt/testdata/initialization/amazonq/not_ready/msg.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ✓ coder loaded in 0.03 s | ||
|
|
||
| Welcome to Amazon Q! | ||
|
|
||
| 💡 Run /prompts to learn how to build & run repeatable workflows | ||
|
|
||
| /help all commands | ||
| ctrl + j new lines | ||
| ctrl + s fuzzy search | ||
|
|
||
|
|
||
| 🤖 You are chatting with claude-sonnet-4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| ✓ coder loaded in 0.03 s | ||
|
|
||
| Welcome to Amazon Q! | ||
|
|
||
| 💡 Run /prompts to learn how to build & run repeatable workflows | ||
|
|
||
| /help all commands | ||
| ctrl + j new lines | ||
| ctrl + s fuzzy search | ||
|
|
||
|
|
||
| 🤖 You are chatting with claude-sonnet-4 | ||
|
|
||
| > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
|
|
||
|
|
||
| ............ | ||
| ..:::-------::::... | ||
| ..::--=========---:::... Welcome to Amp | ||
| .::-===++++++++===---:::.. | ||
| ..:--==+++******+++===--:::... | ||
| .:--=+++**********++===--:::... Type / to use slash commands | ||
| .::-==++***#####****++==---:::.. Type @ to mention files | ||
| .:--=++****#####****++===---::... Ctrl+C to exit | ||
| .:--=+++****###****+++===---:::.. | ||
| .:--==+++*********++++===---:::.. | ||
| ..:--==++++*****++++====----:::.. /help for more | ||
| .::--===+++++++++====-----:::... | ||
| .::---===========------::::... | ||
| ..:::-------------:::::::... amp -x "Run the linter and fix the errors" | ||
| ...::::::::::::::::..... | ||
| .................. | ||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
|
|
||
|
|
||
| ............ | ||
| ..:::-------::::... | ||
| ..::--=========---:::... Welcome to Amp | ||
| .::-===++++++++===---:::.. | ||
| ..:--==+++******+++===--:::... | ||
| .:--=+++**********++===--:::... Type / to use slash commands | ||
| .::-==++***#####****++==---:::.. Type @ to mention files | ||
| .:--=++****#####****++===---::... Ctrl+C to exit | ||
| .:--=+++****###****+++===---:::.. | ||
| .:--==+++*********++++===---:::.. | ||
| ..:--==++++*****++++====----:::.. /help for more | ||
| .::--===+++++++++====-----:::... | ||
| .::---===========------::::... | ||
| ..:::-------------:::::::... amp -x "Run the linter and fix the errors" | ||
| ...::::::::::::::::..... | ||
| .................. | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ─────────────── | ||
| > | ||
| ─────────────── |
12 changes: 12 additions & 0 deletions
12
lib/msgfmt/testdata/initialization/auggie/not_ready/msg.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
|
|
||
|
|
||
| Getting started with Auggie by Augment Code | ||
| 1. You can ask questions, edit files, or run commands | ||
| 2. Your workspace is automatically indexed for best results | ||
| 3. Commands will run automatically | ||
|
|
||
|
|
||
| 💡 For automation, use 'auggie --print "your task"' | ||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
|
|
||
| Getting started with Auggie by Augment Code | ||
| 1. You can ask questions, edit files, or run commands | ||
| 2. Your workspace is automatically indexed for best results | ||
| 3. Commands will run automatically | ||
|
|
||
|
|
||
| 💡 For automation, use 'auggie --print "your task"' | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ | ||
| │ › Try 'how do I log an error?' or type / for commands │ | ||
| ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ | ||
| Type / for commands • ↑↓ for history • Esc/Ctrl+C to interrupt ~/Documents/work/agentapi | ||
|
|
||
|
|
14 changes: 14 additions & 0 deletions
14
lib/msgfmt/testdata/initialization/claude/not_ready/msg.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| ╭────────────────────────────────────────────╮ | ||
| │ ✻ Welcome to Claude Code research preview! │ | ||
| │ │ | ||
| │ /help for help │ | ||
| │ │ | ||
| │ cwd: /Users/hugodutka/dev/agentapi │ | ||
| ╰────────────────────────────────────────────╯ | ||
|
|
||
| Tips for getting started: | ||
|
|
||
| 1. Run /init to create a CLAUDE.md file with instructions for Claude | ||
| 2. Run /terminal-setup to set up terminal integration | ||
| 3. Use Claude to help with file analysis, editing, bash commands and git | ||
| 4. Be as specific as you would with another engineer for the best results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ╭────────────────────────────────────────────╮ | ||
| │ ✻ Welcome to Claude Code research preview! │ | ||
| │ │ | ||
| │ /help for help │ | ||
| │ │ | ||
| │ cwd: /Users/hugodutka/dev/agentapi │ | ||
| ╰────────────────────────────────────────────╯ | ||
|
|
||
| Tips for getting started: | ||
|
|
||
| 1. Run /init to create a CLAUDE.md file with instructions for Claude | ||
| 2. Run /terminal-setup to set up terminal integration | ||
| 3. Use Claude to help with file analysis, editing, bash commands and git | ||
| 4. Be as specific as you would with another engineer for the best results | ||
|
|
||
| ╭──────────────────────────────────────────────────────────────────────────────╮ | ||
| │ > Try "refactor handler.go" │ | ||
| ╰──────────────────────────────────────────────────────────────────────────────╯ | ||
| ? for shortcuts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| >_ You are using OpenAI Codex in ~ | ||
|
|
||
| To get started, describe a task or try one of these commands: | ||
|
|
||
| /init - create an AGENTS.md file with instructions for Codex | ||
| /status - show current session configuration and token usage | ||
| /diff - show git diff (including untracked files) | ||
| /prompts - show example prompts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| >_ You are using OpenAI Codex in ~ | ||
|
|
||
| To get started, describe a task or try one of these commands: | ||
|
|
||
| /init - create an AGENTS.md file with instructions for Codex | ||
| /status - show current session configuration and token usage | ||
| /diff - show git diff (including untracked files) | ||
| /prompts - show example prompts | ||
|
|
||
| ▌ Ask Codex to do anything | ||
| ⏎ send Shift+⏎ newline Ctrl+C quit |
11 changes: 11 additions & 0 deletions
11
lib/msgfmt/testdata/initialization/copilot/not_ready/msg.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| Welcome to GitHub Copilot CLI | ||
| Version 0.0.328 · Commit 3755a93 | ||
|
|
||
| Copilot can write, test and debug code right from your terminal. Describe a | ||
| task to get started or enter ? for help. Copilot uses AI, check for mistakes. | ||
|
|
||
| ● Logged in with gh as user: 35C4n0r | ||
|
|
||
| ● Connected to GitHub MCP Server | ||
|
|
||
| ~/Documents/work/agentapi [⎇ feat-github-cli*] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| Welcome to GitHub Copilot CLI | ||
| Version 0.0.328 · Commit 3755a93 | ||
|
|
||
| Copilot can write, test and debug code right from your terminal. Describe a | ||
| task to get started or enter ? for help. Copilot uses AI, check for mistakes. | ||
|
|
||
| ● Logged in with gh as user: 35C4n0r | ||
|
|
||
| ● Connected to GitHub MCP Server | ||
|
|
||
| ~/Documents/work/agentapi [⎇ feat-github-cli*] | ||
| ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ | ||
| │ > Enter @ to mention files or / for commands │ | ||
| ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ | ||
| Ctrl+c Exit · Ctrl+r Expand all |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.