summaryrefslogtreecommitdiffhomepage
path: root/internal/llm/prompt
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-16 20:06:23 +0200
committerKujtim Hoxha <[email protected]>2025-04-21 13:42:00 +0200
commitbbfa60c787f2ec459f1689b9a650ddbec9693ed9 (patch)
treef7f2aa31c460c8cc22ec40cc299c386277152241 /internal/llm/prompt
parent76b4065f17b87a63092acfd98c997bab53700b35 (diff)
downloadopencode-bbfa60c787f2ec459f1689b9a650ddbec9693ed9.tar.gz
opencode-bbfa60c787f2ec459f1689b9a650ddbec9693ed9.zip
reimplement agent,provider and add file history
Diffstat (limited to 'internal/llm/prompt')
-rw-r--r--internal/llm/prompt/coder.go28
-rw-r--r--internal/llm/prompt/prompt.go19
-rw-r--r--internal/llm/prompt/task.go5
-rw-r--r--internal/llm/prompt/title.go4
4 files changed, 39 insertions, 17 deletions
diff --git a/internal/llm/prompt/coder.go b/internal/llm/prompt/coder.go
index 47941f976..7439fd570 100644
--- a/internal/llm/prompt/coder.go
+++ b/internal/llm/prompt/coder.go
@@ -9,11 +9,22 @@ import (
"time"
"github.com/kujtimiihoxha/termai/internal/config"
+ "github.com/kujtimiihoxha/termai/internal/llm/models"
"github.com/kujtimiihoxha/termai/internal/llm/tools"
)
-func CoderOpenAISystemPrompt() string {
- basePrompt := `You are termAI, an autonomous CLI-based software engineer. Your job is to reduce user effort by proactively reasoning, inferring context, and solving software engineering tasks end-to-end with minimal prompting.
+func CoderPrompt(provider models.ModelProvider) string {
+ basePrompt := baseAnthropicCoderPrompt
+ switch provider {
+ case models.ProviderOpenAI:
+ basePrompt = baseOpenAICoderPrompt
+ }
+ envInfo := getEnvironmentInfo()
+
+ return fmt.Sprintf("%s\n\n%s\n%s", basePrompt, envInfo, lspInformation())
+}
+
+const baseOpenAICoderPrompt = `You are termAI, an autonomous CLI-based software engineer. Your job is to reduce user effort by proactively reasoning, inferring context, and solving software engineering tasks end-to-end with minimal prompting.
# Your mindset
Act like a competent, efficient software engineer who is familiar with large codebases. You should:
@@ -65,13 +76,7 @@ assistant: [searches repo for references, returns file paths and lines]
Never commit changes unless the user explicitly asks you to.`
- envInfo := getEnvironmentInfo()
-
- return fmt.Sprintf("%s\n\n%s\n%s", basePrompt, envInfo, lspInformation())
-}
-
-func CoderAnthropicSystemPrompt() string {
- basePrompt := `You are termAI, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
+const baseAnthropicCoderPrompt = `You are termAI, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure.
@@ -166,11 +171,6 @@ NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTAN
You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.`
- envInfo := getEnvironmentInfo()
-
- return fmt.Sprintf("%s\n\n%s\n%s", basePrompt, envInfo, lspInformation())
-}
-
func getEnvironmentInfo() string {
cwd := config.WorkingDirectory()
isGit := isGitRepo(cwd)
diff --git a/internal/llm/prompt/prompt.go b/internal/llm/prompt/prompt.go
new file mode 100644
index 000000000..63fc2df7b
--- /dev/null
+++ b/internal/llm/prompt/prompt.go
@@ -0,0 +1,19 @@
+package prompt
+
+import (
+ "github.com/kujtimiihoxha/termai/internal/config"
+ "github.com/kujtimiihoxha/termai/internal/llm/models"
+)
+
+func GetAgentPrompt(agentName config.AgentName, provider models.ModelProvider) string {
+ switch agentName {
+ case config.AgentCoder:
+ return CoderPrompt(provider)
+ case config.AgentTitle:
+ return TitlePrompt(provider)
+ case config.AgentTask:
+ return TaskPrompt(provider)
+ default:
+ return "You are a helpful assistant"
+ }
+}
diff --git a/internal/llm/prompt/task.go b/internal/llm/prompt/task.go
index ee3c707fa..8bf604ad9 100644
--- a/internal/llm/prompt/task.go
+++ b/internal/llm/prompt/task.go
@@ -2,11 +2,12 @@ package prompt
import (
"fmt"
+
+ "github.com/kujtimiihoxha/termai/internal/llm/models"
)
-func TaskAgentSystemPrompt() string {
+func TaskPrompt(_ models.ModelProvider) string {
agentPrompt := `You are an agent for termAI. Given the user's prompt, you should use the tools available to you to answer the user's question.
-
Notes:
1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...".
2. When relevant, share file names and code snippets relevant to the query
diff --git a/internal/llm/prompt/title.go b/internal/llm/prompt/title.go
index 5c47f4d64..3023a8550 100644
--- a/internal/llm/prompt/title.go
+++ b/internal/llm/prompt/title.go
@@ -1,6 +1,8 @@
package prompt
-func TitlePrompt() string {
+import "github.com/kujtimiihoxha/termai/internal/llm/models"
+
+func TitlePrompt(_ models.ModelProvider) string {
return `you will generate a short title based on the first message a user begins a conversation with
- ensure it is not more than 50 characters long
- the title should be a summary of the user's message