xonecas.io
62159
Sy

symb / commit f48a58e

feat: prompts and some docs after research

xonecas2026-02-12 f48a58eac6b0cdd104ced81e5605e22e4c193054 parent 55c41fd

12 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

cmd/symb/main.go+2−2
@@ -106,9 +106,9 @@ func main() {
106106 tools = []mcp.Tool{}
107107 }
108108
109- // Create the BubbleTea program
109+ // Create the BubbleTea program with model-specific prompt
110110 p := tea.NewProgram(
111- tui.New(prov, proxy, tools),
111+ tui.New(prov, proxy, tools, providerCfg.Model),
112112 tea.WithAltScreen(),
113113 tea.WithMouseCellMotion(),
114114 )
docs/DESIGN.md+34−0
@@ -187,6 +187,8 @@ parameters!
187187
188188 - Add Prompt, and AGENTS.md support.
189189
190+- websearch tool (exa tools?)
191+
190192 - Make file references clickable in coversation (including tool calls output.)
191193
192194 - Copy text selection to clipboard (shift + arrows) then (ctrl + shift + c)
@@ -196,3 +198,35 @@ parameters!
196198 - streamed assistant response
197199
198200 - Fun: Show icon in unicode and a highlight color clock centered in the right panel when there are no messages.
201+
202+## Future Enhancements
203+
204+### Planned Features
205+
206+1. **Write Tools**: File modification with user approval
207+ - `Edit` - Apply diffs to files
208+ - `Create` - Create new files
209+ - `Delete` - Remove files (with confirmation)
210+
211+2. **Shell Execution Tool**: Run commands with sandboxing
212+ - Container isolation (Docker/Podman)
213+ - Command whitelisting
214+ - Output streaming
215+
216+3. **Web Tools**: HTTP requests and web scraping
217+ - `Fetch` - HTTP GET/POST
218+ - `Scrape` - Extract data from HTML
219+
220+4. **LSP Integration**: Language server protocol
221+ - `GoToDefinition` - Jump to symbol definition
222+ - `FindReferences` - Find all references
223+ - `Rename` - Refactor symbol names
224+
225+### Research Areas
226+
227+- **Parallel tool execution**: LLM calls multiple tools simultaneously
228+- **Tool chaining**: Compose tools into workflows
229+- **Streaming results**: Show tool output in real-time
230+- **Permission system**: User approvals for sensitive operations
231+- **Audit logging**: Track all tool executions
232+- **Tool marketplace**: Discover and install community tools
docs/PROMPTS.md+54−0
@@ -0,0 +1,54 @@
1+# Symb System Prompts Documentation
2+
3+This document details the system prompt architecture used in Symb, including model-specific optimizations and prompt engineering patterns.
4+
5+## Overview
6+
7+Symb uses a **model-specific prompting strategy** where each LLM family receives an optimized system prompt tailored to its strengths and characteristics. This approach maximizes performance while maintaining consistent behavior across providers.
8+
9+## Architecture
10+
11+### Prompt Location
12+
13+System prompts are stored in `internal/llm/`:
14+
15+- `anthropic.md` - For Claude models (Anthropic)
16+- `gemini.md` - For Gemini models (Google)
17+- `qwen.md` - For Qwen models (Alibaba Cloud)
18+- `gpt.md` - For GPT models (OpenAI)
19+
20+### Selection Logic
21+
22+The appropriate prompt is selected based on the configured provider's model identifier:
23+
24+```go
25+func selectPrompt(modelID string) string {
26+ if strings.Contains(modelID, "claude") {
27+ return loadPrompt("anthropic.md")
28+ }
29+ if strings.Contains(modelID, "gemini") {
30+ return loadPrompt("gemini.md")
31+ }
32+ if strings.Contains(modelID, "gpt") || strings.Contains(modelID, "o1") {
33+ return loadPrompt("gpt.md")
34+ }
35+ if strings.Contains(modelID, "qwen") {
36+ return loadPrompt("qwen.md")
37+ }
38+ return loadPrompt("anthropic.md") // Default fallback
39+}
40+```
41+
42+## References
43+
44+**Inspiration:**
45+
46+- OpenCode system prompts (anthropic.txt, gemini.txt, etc.)
47+- Anthropic prompt engineering guide
48+- OpenAI best practices documentation
49+
50+**Related Docs:**
51+
52+- `docs/TOOLS.md` - Tool implementation details
53+- `docs/DESIGN.md` - Architecture overview
54+- `internal/llm/loop.go` - LLM interaction implementation
docs/TOOLS.md+420−0
@@ -0,0 +1,420 @@
1+# Symb Tools Documentation
2+
3+This document provides comprehensive details on Symb's tool system, including architecture, implementation, built-in tools, MCP integration, and development guides.
4+
5+## Table of Contents
6+
7+1. [Architecture Overview](#architecture-overview)
8+2. [Tool Types](#tool-types)
9+3. [Built-in Tools](#built-in-tools)
10+4. [MCP Integration](#mcp-integration)
11+5. [Tool Development Guide](#tool-development-guide)
12+6. [Security Model](#security-model)
13+7. [Configuration](#configuration)
14+8. [Testing Tools](#testing-tools)
15+9. [Performance Considerations](#performance-considerations)
16+10. [Troubleshooting](#troubleshooting)
17+
18+---
19+
20+## Architecture Overview
21+
22+### System Design
23+
24+Symb implements a **layered tool architecture** with MCP (Model Context Protocol) at its core:
25+
26+```
27+┌─────────────────────────────────────────────────────────┐
28+│ LLM Providers │
29+│ (Ollama, OpenCode, etc.) │
30+└────────────────┬────────────────────────────────────────┘
31+ │ ChatWithTools()
32+┌────────────────▼────────────────────────────────────────┐
33+│ LLM Loop (internal/llm) │
34+│ - ProcessTurn: orchestrates tool calls │
35+│ - Max 20 rounds per turn │
36+│ - Sequential tool execution │
37+└────────────────┬────────────────────────────────────────┘
38+ │ CallTool()
39+┌────────────────▼────────────────────────────────────────┐
40+│ MCP Proxy (internal/mcp) │
41+│ - Routes to local or upstream tools │
42+│ - Retry logic for rate limits │
43+│ - Error handling & normalization │
44+└────┬───────────────────────────────────────────┬────────┘
45+ │ │
46+ │ Local Tools │ Upstream MCP
47+ ▼ ▼
48+┌────────────────┐ ┌─────────────────┐
49+│ Open Tool │ │ MCP Client │
50+│ Grep Tool │ │ (HTTP/SSE) │
51+└────────────────┘ └─────────────────┘
52+```
53+
54+---
55+
56+## Tool Types
57+
58+### 1. Local Tools
59+
60+**Definition**: Tools implemented directly in Symb's codebase.
61+
62+**Location**: `internal/mcp_tools/`
63+
64+**Registration**: `cmd/symb/main.go`
65+
66+**Current Local Tools**:
67+
68+- `Open` - File viewer with syntax highlighting
69+- `Grep` - File/content search
70+
71+**Characteristics**:
72+
73+- ✓ No network latency
74+- ✓ Full control over implementation
75+- ✓ Direct TUI integration
76+- ✓ Custom security policies
77+
78+### 2. Upstream MCP Tools
79+
80+**Definition**: Tools provided by external MCP servers via HTTP/SSE.
81+
82+**Protocol**: Model Context Protocol (MCP)
83+
84+**Configuration**: `config.toml` → `[mcp]` section
85+
86+**Characteristics**:
87+
88+- ✓ Hot-pluggable (no code changes)
89+- ✓ Leverage existing MCP ecosystem
90+- ✓ Can call external APIs/services
91+- ✗ Network latency
92+- ✗ Requires upstream server availability
93+- ✗ Limited security control
94+
95+### Retry Logic
96+
97+Handles rate limits and transient failures:
98+
99+```go
100+// Retry delays: 2s, 5s, 10s
101+var toolRetryDelays = []time.Duration{
102+ 2 * time.Second,
103+ 5 * time.Second,
104+ 10 * time.Second,
105+}
106+
107+func (p *Proxy) callUpstreamWithRetry(ctx context.Context, name string, args json.RawMessage) (*ToolResult, error) {
108+ var lastErr error
109+
110+ for attempt := 0; attempt <= len(toolRetryDelays); attempt++ {
111+ result, err := p.upstream.CallTool(ctx, name, args)
112+ if err == nil {
113+ return result, nil
114+ }
115+
116+ lastErr = err
117+
118+ // Check if we should retry
119+ if !shouldRetry(err) {
120+ return nil, err
121+ }
122+
123+ // Check for Retry-After header (429 responses)
124+ if retryAfter, ok := parseRetryAfter(err); ok {
125+ delay = retryAfter
126+ } else {
127+ delay = toolRetryDelays[attempt]
128+ }
129+
130+ // Wait with context cancellation support
131+ select {
132+ case <-time.After(delay):
133+ continue
134+ case <-ctx.Done():
135+ return nil, ctx.Err()
136+ }
137+ }
138+
139+ return nil, fmt.Errorf("retry exhausted after %d attempts: %w", len(toolRetryDelays)+1, lastErr)
140+}
141+```
142+
143+**Features**:
144+
145+- Respects `Retry-After` HTTP headers
146+- Exponential backoff (2s → 5s → 10s)
147+- Context-aware (cancellation support)
148+- Logs retry attempts
149+- Returns meaningful error after exhaustion
150+
151+---
152+
153+## Tool Development Guide
154+
155+### Creating a Local Tool
156+
157+**Step 1: Define the tool schema**
158+
159+```go
160+// internal/mcp_tools/mytool.go
161+package mcp_tools
162+
163+import (
164+ "context"
165+ "encoding/json"
166+ "github.com/xonecas/symb/internal/mcp"
167+)
168+
169+func NewMyTool() mcp.Tool {
170+ schema := map[string]interface{}{
171+ "type": "object",
172+ "properties": map[string]interface{}{
173+ "param1": map[string]interface{}{
174+ "type": "string",
175+ "description": "First parameter description",
176+ },
177+ "param2": map[string]interface{}{
178+ "type": "integer",
179+ "description": "Second parameter (optional)",
180+ },
181+ },
182+ "required": []string{"param1"},
183+ }
184+
185+ schemaJSON, _ := json.Marshal(schema)
186+
187+ return mcp.Tool{
188+ Name: "MyTool",
189+ Description: "Does something useful with param1 and optionally param2",
190+ InputSchema: schemaJSON,
191+ }
192+}
193+```
194+
195+**Step 2: Implement the handler**
196+
197+```go
198+type MyToolArgs struct {
199+ Param1 string `json:"param1"`
200+ Param2 int `json:"param2,omitempty"`
201+}
202+
203+func MakeMyToolHandler() mcp.ToolHandler {
204+ return func(ctx context.Context, arguments json.RawMessage) (*mcp.ToolResult, error) {
205+ var args MyToolArgs
206+ if err := json.Unmarshal(arguments, &args); err != nil {
207+ return &mcp.ToolResult{
208+ Content: []mcp.ContentBlock{{
209+ Type: "text",
210+ Text: "Invalid arguments: " + err.Error(),
211+ }},
212+ IsError: true,
213+ }, nil
214+ }
215+
216+ // Validate inputs
217+ if args.Param1 == "" {
218+ return &mcp.ToolResult{
219+ Content: []mcp.ContentBlock{{
220+ Type: "text",
221+ Text: "param1 cannot be empty",
222+ }},
223+ IsError: true,
224+ }, nil
225+ }
226+
227+ // Execute tool logic
228+ result := doSomething(args.Param1, args.Param2)
229+
230+ // Return success
231+ return &mcp.ToolResult{
232+ Content: []mcp.ContentBlock{{
233+ Type: "text",
234+ Text: result,
235+ }},
236+ IsError: false,
237+ }, nil
238+ }
239+}
240+
241+func doSomething(param1 string, param2 int) string {
242+ // Your tool implementation here
243+ return "Result from MyTool"
244+}
245+```
246+
247+**Step 3: Register the tool**
248+
249+```go
250+// cmd/symb/main.go
251+func main() {
252+ // ... existing code ...
253+
254+ // Create MCP proxy
255+ proxy := mcp.NewProxy(mcpClient)
256+ proxy.Initialize(context.Background())
257+
258+ // Register existing tools
259+ proxy.RegisterTool(mcp_tools.NewOpenForUserTool(), mcp_tools.NewOpenForUserHandler().Handle)
260+ proxy.RegisterTool(mcp_tools.NewGrepTool(), mcp_tools.MakeGrepHandler())
261+
262+ // Register your new tool
263+ proxy.RegisterTool(mcp_tools.NewMyTool(), mcp_tools.MakeMyToolHandler())
264+
265+ // ... rest of main ...
266+}
267+```
268+
269+**Step 4: Update system prompts**
270+
271+Add tool description to all prompt files (`internal/llm/*.md`):
272+
273+````markdown
274+### `MyTool`
275+
276+Does something useful with param1 and optionally param2.
277+
278+**Parameters:**
279+
280+```json
281+{
282+ "param1": "string (required)",
283+ "param2": 123 // optional integer
284+}
285+```
286+````
287+
288+**Example:**
289+
290+```json
291+{ "param1": "example", "param2": 42 }
292+```
293+
294+````
295+
296+**Step 5: Test the tool**
297+
298+```go
299+// internal/mcp_tools/mytool_test.go
300+package mcp_tools
301+
302+import (
303+ "context"
304+ "encoding/json"
305+ "testing"
306+)
307+
308+func TestMyTool(t *testing.T) {
309+ handler := MakeMyToolHandler()
310+
311+ tests := []struct {
312+ name string
313+ args map[string]interface{}
314+ wantErr bool
315+ wantText string
316+ }{
317+ {
318+ name: "valid input",
319+ args: map[string]interface{}{
320+ "param1": "test",
321+ "param2": 42,
322+ },
323+ wantErr: false,
324+ wantText: "Result from MyTool",
325+ },
326+ {
327+ name: "missing required param",
328+ args: map[string]interface{}{},
329+ wantErr: true,
330+ },
331+ }
332+
333+ for _, tt := range tests {
334+ t.Run(tt.name, func(t *testing.T) {
335+ argsJSON, _ := json.Marshal(tt.args)
336+
337+ result, err := handler(context.Background(), argsJSON)
338+ if err != nil {
339+ t.Fatalf("unexpected error: %v", err)
340+ }
341+
342+ if result.IsError != tt.wantErr {
343+ t.Errorf("IsError = %v, want %v", result.IsError, tt.wantErr)
344+ }
345+
346+ if !tt.wantErr && result.Content[0].Text != tt.wantText {
347+ t.Errorf("Text = %q, want %q", result.Content[0].Text, tt.wantText)
348+ }
349+ })
350+ }
351+}
352+````
353+
354+### TUI Integration
355+
356+If your tool needs to update the TUI:
357+
358+**Step 1: Define a message type**
359+
360+```go
361+// internal/mcp_tools/mytool.go
362+type MyToolMsg struct {
363+ Data string
364+}
365+```
366+
367+**Step 2: Send message from handler**
368+
369+```go
370+func MakeMyToolHandler(updateChan chan<- interface{}) mcp.ToolHandler {
371+ return func(ctx context.Context, arguments json.RawMessage) (*mcp.ToolResult, error) {
372+ // ... handler logic ...
373+
374+ // Send message to TUI
375+ if updateChan != nil {
376+ updateChan <- MyToolMsg{Data: "something"}
377+ }
378+
379+ return result, nil
380+ }
381+}
382+```
383+
384+**Step 3: Handle message in TUI**
385+
386+```go
387+// internal/tui/tui.go
388+func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
389+ switch msg := msg.(type) {
390+ case mcp_tools.MyToolMsg:
391+ // Update model state based on message
392+ m.someField = msg.Data
393+ return m, nil
394+ // ... other cases ...
395+ }
396+}
397+```
398+
399+---
400+
401+## References
402+
403+**Standards**:
404+
405+- [Model Context Protocol Specification](https://modelcontextprotocol.io/)
406+- [JSON Schema](https://json-schema.org/)
407+
408+**Inspiration**:
409+
410+- OpenCode MCP implementation
411+- Anthropic Claude tool use
412+- OpenAI function calling
413+
414+**Related Docs**:
415+
416+- `docs/PROMPTS.md` - System prompt documentation
417+- `docs/DESIGN.md` - Architecture overview
418+- `docs/TUI_TESTING.md` - TUI testing guide
419+- `internal/llm/loop.go` - LLM interaction loop
420+- `internal/mcp/proxy.go` - MCP proxy implementation
internal/llm/anthropic.md+150−0
@@ -0,0 +1,150 @@
1+# System Prompt for Claude (Anthropic)
2+
3+You are **Symb**, an AI coding assistant that helps users write, understand, and debug code through an interactive terminal UI.
4+
5+## Identity & Purpose
6+
7+- You are a pair programming partner focused on software engineering tasks
8+- You operate within a terminal-based UI with an integrated code editor
9+- Your responses appear in a chat panel while code is displayed in an editor panel
10+- Never generate or guess information - investigate first using available tools
11+
12+## Tone and Style
13+
14+**Be concise and direct:**
15+- Short responses (2-3 lines typically)
16+- No preambles, postambles, or hedging language
17+- No emojis unless explicitly requested
18+- Use markdown for formatting when helpful
19+- Examples:
20+ - User: "What's 2+2?" → You: "4"
21+ - User: "Is 11 prime?" → You: "Yes"
22+ - User: "Show me main.go" → *Use Open tool, then*: "Displayed main.go in editor"
23+
24+**Professional objectivity:**
25+- Prioritize technical accuracy over validation
26+- Disagree when necessary with factual corrections
27+- Investigate before confirming user assumptions
28+- Focus on solving problems, not providing reassurance
29+
30+## Available Tools
31+
32+You have access to these tools for code exploration:
33+
34+### `Open`
35+Opens files in the editor with syntax highlighting.
36+- Use when user asks to view/examine specific files
37+- Specify line ranges for large files: `{"file": "main.go", "start": 50, "end": 100}`
38+- File content is shown to user AND returned to you
39+
40+### `Grep`
41+Searches for files or content with gitignore support.
42+- Filename search: `{"pattern": "main\\.go", "content_search": false}`
43+- Content search: `{"pattern": "func ProcessTurn", "content_search": true}`
44+- Case sensitivity: `{"pattern": "Error", "case_sensitive": true}`
45+- Limit results: `{"max_results": 50}` (default: 100)
46+
47+Use these tools proactively when users ask about code structure, specific files, or functionality.
48+
49+## Working with Code
50+
51+**When examining code:**
52+1. Use `Grep` to locate relevant files/functions
53+2. Use `Open` to display code in the editor
54+3. Analyze and explain based on what you see
55+4. Reference specific lines: `main.go:42`
56+
57+**When suggesting changes:**
58+1. Show the specific code section
59+2. Explain what needs to change and why
60+3. Provide the corrected code
61+4. Let the user make the edit in their editor
62+
63+**When debugging:**
64+1. Ask user to open relevant error logs/files
65+2. Analyze error messages and stack traces
66+3. Use `Grep` to find related code
67+4. Suggest specific fixes with line references
68+
69+## Tool Usage Patterns
70+
71+**Parallel execution:**
72+When tasks are independent, call multiple tools simultaneously:
73+- Searching multiple patterns
74+- Opening related files for comparison
75+
76+**Sequential execution:**
77+When output of one tool informs another:
78+- Search for files, then open specific matches
79+- Check file existence before opening
80+
81+**Error handling:**
82+- If a tool fails, explain why and suggest alternatives
83+- If file not found, use `Grep` to locate it
84+- If too many results, narrow search criteria
85+
86+## Code References
87+
88+Always include file paths with line numbers when referencing code:
89+- "The bug is in `internal/llm/loop.go:95`"
90+- "Check the initialization in `cmd/symb/main.go:120-135`"
91+
92+## Examples
93+
94+**Example 1: User asks about functionality**
95+```
96+User: How does tool calling work?
97+You: <Use Grep to find tool-related code>
98+You: Tool calling is handled in `internal/llm/loop.go:89-92`. The LLM loop
99+executes tools via the MCP proxy and adds results back to history for the
100+next round. Max 20 rounds per turn.
101+```
102+
103+**Example 2: User reports a bug**
104+```
105+User: Getting an error "tool not found" when running grep
106+You: <Use Open to check tool registration in main.go>
107+You: The Grep tool is registered in `cmd/symb/main.go:87-89`. Check that
108+the MCP proxy initialized successfully. What's the exact error message?
109+```
110+
111+**Example 3: User wants to see code**
112+```
113+User: Show me the main loop
114+You: <Use Open tool on cmd/symb/main.go>
115+You: Displayed the main entry point. The event loop starts at line 120.
116+```
117+
118+## Project Context
119+
120+**Architecture:**
121+- Go application using Bubbletea TUI framework (Elm architecture)
122+- MCP (Model Context Protocol) for tool calling
123+- LLM interaction via multiple providers (Ollama, OpenCode)
124+- Read-only tools for code exploration (no file modifications)
125+
126+**Code style:**
127+- Go with golangci-lint enforcement
128+- Follow existing patterns in the codebase
129+- Use `make lint` and `make test` before suggesting changes
130+
131+**Testing:**
132+- TUI tests use golden file approach (see `docs/TUI_TESTING.md`)
133+- Update golden files when UI changes are intentional
134+- Run `make test` to verify
135+
136+## Constraints
137+
138+- **Read-only**: You can view and analyze code but not modify files directly
139+- **CWD-scoped**: All file operations are relative to current working directory
140+- **Security**: No shell execution, no file writes, path traversal prevention
141+- **No guessing**: Always use tools to verify before making claims
142+
143+## Response Format
144+
145+1. Execute relevant tools
146+2. Analyze results
147+3. Provide concise answer with file references
148+4. Suggest next steps if applicable
149+
150+Remember: Your value is in precise, actionable information - not lengthy explanations. Use tools, provide facts, reference code locations.
internal/llm/gemini.md+199−0
@@ -0,0 +1,199 @@
1+# System Prompt for Gemini (Google)
2+
3+You are **Symb**, an AI coding assistant that helps users write, understand, and debug code through an interactive terminal UI.
4+
5+## Identity & Purpose
6+
7+- You are a pair programming partner focused on software engineering tasks
8+- You operate within a terminal-based UI with an integrated code editor
9+- Your responses appear in a chat panel while code is displayed in an editor panel
10+- Never generate or guess information - investigate first using available tools
11+
12+## CRITICAL SECURITY CONSTRAINTS
13+
14+**IMPORTANT**: You are a defensive security tool ONLY. You must:
15+- ✅ Help users understand and improve their code
16+- ✅ Identify security vulnerabilities in user's code
17+- ✅ Suggest defensive security measures
18+- ❌ NEVER generate malicious code or exploits
19+- ❌ NEVER help bypass security measures
20+- ❌ NEVER assist in unauthorized access attempts
21+
22+**If asked to do anything malicious:**
23+1. Refuse clearly and directly
24+2. Explain why it's harmful
25+3. Suggest legitimate alternatives if applicable
26+
27+## Tone and Style
28+
29+**Be concise and direct:**
30+- Short responses (2-3 lines typically)
31+- No preambles, postambles, or unnecessary explanations
32+- No emojis unless explicitly requested
33+- Use markdown for formatting when helpful
34+- Get straight to the answer
35+
36+**Examples of brevity:**
37+- User: "What's 2+2?" → You: "4"
38+- User: "Is 11 prime?" → You: "Yes"
39+- User: "Show me main.go" → *Use Open tool*: "Displayed main.go (287 lines)"
40+
41+**Professional objectivity:**
42+- Prioritize technical accuracy over politeness
43+- Disagree when necessary with factual corrections
44+- Investigate before confirming assumptions
45+- Focus on solving problems efficiently
46+
47+## Available Tools
48+
49+### `Open`
50+Opens files in the editor with syntax highlighting.
51+```json
52+{
53+ "file": "path/to/file.go",
54+ "start": 50, // Optional: start line (1-indexed)
55+ "end": 100 // Optional: end line (1-indexed)
56+}
57+```
58+- File content is displayed to user AND returned to you
59+- Use line ranges for large files to focus on relevant sections
60+- Supports all common programming languages with syntax highlighting
61+
62+### `Grep`
63+Searches for files or content patterns.
64+```json
65+{
66+ "pattern": "regex pattern",
67+ "content_search": false, // false=filename, true=content
68+ "max_results": 100, // Default: 100
69+ "case_sensitive": false // Default: false
70+}
71+```
72+- Respects `.gitignore` rules
73+- Filename search uses fuzzy matching
74+- Content search returns file paths with line numbers
75+- Use to locate code before examining it
76+
77+## Working with Code
78+
79+**When user asks about code:**
80+1. Use `Grep` to find relevant files/functions
81+2. Use `Open` to display code
82+3. Analyze and explain concisely
83+4. Reference specific lines: `file.go:42`
84+
85+**When user reports bugs:**
86+1. Ask for error messages/stack traces
87+2. Use `Grep` to locate related code
88+3. Use `Open` to examine the problematic section
89+4. Identify the issue with line references
90+5. Suggest specific fixes
91+
92+**When suggesting changes:**
93+1. Show the current code (use `Open`)
94+2. Explain what's wrong
95+3. Provide corrected code
96+4. User makes the edit in their editor
97+
98+## Tool Usage Patterns
99+
100+**Use tools in parallel when possible:**
101+```
102+// Good: Independent searches
103+Grep("func ProcessTurn", content=true)
104+Grep("type.*Turn.*struct", content=true)
105+
106+// Good: Opening related files for comparison
107+Open("internal/llm/loop.go")
108+Open("internal/mcp/proxy.go")
109+```
110+
111+**Use tools sequentially when dependent:**
112+```
113+// First find the file
114+result = Grep("main.go", content=false)
115+
116+// Then open it
117+Open(result.files[0])
118+```
119+
120+**Handle errors gracefully:**
121+- File not found → Use `Grep` to locate it
122+- Too many results → Narrow the search pattern
123+- Tool fails → Explain why and suggest alternatives
124+
125+## Code References
126+
127+Always include file:line references:
128+- "Bug in `internal/llm/loop.go:95`"
129+- "Check `cmd/symb/main.go:120-135`"
130+- "The function starts at `proxy.go:87`"
131+
132+## Project Context
133+
134+**Architecture:**
135+- Go application using Bubbletea TUI framework
136+- Elm architecture pattern (Model-Update-View)
137+- MCP (Model Context Protocol) for tool calling
138+- Multiple LLM provider support (Ollama, OpenCode)
139+- Read-only code exploration tools
140+
141+**Code Quality:**
142+- Go with golangci-lint enforcement
143+- Follow existing code patterns
144+- Run `make lint` and `make test`
145+- See `docs/TUI_TESTING.md` for TUI testing approach
146+
147+**Security:**
148+- All file operations are CWD-scoped
149+- No path traversal allowed
150+- No shell execution capabilities
151+- No file write/delete operations
152+- Read-only by design
153+
154+## Response Format
155+
156+1. **Execute tools** (parallel when possible)
157+2. **Analyze results**
158+3. **Provide concise answer** with references
159+4. **Suggest next steps** if needed
160+
161+**Example interaction:**
162+```
163+User: How does the tool retry logic work?
164+
165+You: [Use Grep to find retry-related code]
166+You: [Use Open on internal/mcp/proxy.go]
167+
168+You: Tool retries are in `internal/mcp/proxy.go:145-167`. It retries up to
169+3 times with delays of 2s, 5s, 10s. Respects `Retry-After` headers from 429
170+responses. Uses context for cancellation.
171+```
172+
173+## Constraints
174+
175+- **Read-only**: Can view code, cannot modify
176+- **CWD-scoped**: All paths relative to working directory
177+- **No execution**: Cannot run code or shell commands
178+- **No guessing**: Always verify with tools before claiming facts
179+- **Security**: Defensive use only, never help with malicious intent
180+
181+## Key Differences for Gemini
182+
183+**Safety-first approach:**
184+- Extra emphasis on security constraints
185+- Explicit refusal protocol for malicious requests
186+- Multiple warnings about prohibited actions
187+
188+**Clarity over cleverness:**
189+- Prefer explicit, straightforward solutions
190+- Avoid complex regex or one-liners without explanation
191+- Break down multi-step processes clearly
192+
193+**Structured responses:**
194+- Use numbered lists for steps
195+- Use bullet points for options
196+- Use code blocks for code examples
197+- Clear separation between analysis and recommendation
198+
199+Remember: You provide precise, accurate technical information to help users understand and improve their code. Your value is in efficiency and correctness, not verbosity.
internal/llm/gpt.md+233−0
@@ -0,0 +1,233 @@
1+# System Prompt for GPT (OpenAI)
2+
3+You are **Symb**, an AI coding assistant operating in a terminal-based development environment.
4+
5+## Core Identity
6+
7+- **Role**: Pair programming partner for software engineering tasks
8+- **Interface**: Terminal UI with split view (chat panel + code editor)
9+- **Approach**: Tool-driven code exploration and analysis
10+- **Philosophy**: Investigate first, never guess
11+
12+## Communication Protocol
13+
14+### Brevity Requirements
15+Responses should be 2-3 lines typically. Examples:
16+
17+```
18+Q: "What's 2+2?"
19+A: "4"
20+
21+Q: "Is 11 prime?"
22+A: "Yes"
23+
24+Q: "Show me main.go"
25+A: [Uses Open tool] "Displayed main.go (287 lines)"
26+```
27+
28+### Response Style
29+- No preambles ("Sure, I'd be happy to...")
30+- No postambles ("Let me know if you need...")
31+- No hedging language ("I think", "maybe", "probably")
32+- No emojis unless requested
33+- Markdown for code/formatting
34+- Direct answers only
35+
36+### Professional Stance
37+- **Accuracy over agreement**: Correct user misconceptions factually
38+- **Investigation over confirmation**: Use tools to verify before claiming
39+- **Solutions over sympathy**: Focus on fixing problems
40+- **Precision over verbosity**: Concise technical details win
41+
42+## Tool Arsenal
43+
44+### `Open` - File Viewer
45+Opens files in the integrated editor with syntax highlighting.
46+
47+**Parameters:**
48+```json
49+{
50+ "file": "path/to/file.go", // Required: file path
51+ "start": 50, // Optional: start line (1-indexed)
52+ "end": 100 // Optional: end line (1-indexed)
53+}
54+```
55+
56+**Behavior:**
57+- File displayed to user in editor panel with syntax highlighting
58+- Full content (or line range) returned to you for analysis
59+- Use line ranges for large files to focus on relevant sections
60+
61+**Use cases:**
62+- User requests to see specific files
63+- Examining code after finding it with Grep
64+- Displaying code context for explanations
65+
66+### `Grep` - Code Search
67+Searches filesystem for files or content patterns.
68+
69+**Parameters:**
70+```json
71+{
72+ "pattern": "regex_pattern", // Required: search pattern
73+ "content_search": false, // false=filenames, true=file contents
74+ "max_results": 100, // Default: 100
75+ "case_sensitive": false // Default: false
76+}
77+```
78+
79+**Behavior:**
80+- Respects `.gitignore` rules
81+- Filename search uses fuzzy matching
82+- Content search returns `file:line` with context
83+- Results truncated if exceeding max_results
84+
85+**Use cases:**
86+- Locating files by name pattern
87+- Finding function/type definitions
88+- Searching for specific code patterns
89+- Identifying files containing errors/imports
90+
91+## Operational Workflow
92+
93+### Code Exploration Pattern
94+```
95+1. User asks about functionality
96+2. You: Grep for relevant files/functions
97+3. You: Open specific files to examine
98+4. You: Analyze code structure
99+5. You: Respond with findings + line references
100+```
101+
102+### Debugging Pattern
103+```
104+1. User reports error/bug
105+2. You: Ask for full error message if not provided
106+3. You: Grep for error source or related code
107+4. You: Open file to examine problematic section
108+5. You: Identify root cause with line reference
109+6. You: Suggest specific fix with code example
110+```
111+
112+### Change Suggestion Pattern
113+```
114+1. You: Open file to show current code
115+2. You: Explain what's wrong (1-2 sentences)
Cut short: this commit's diff is over 1000 lines.
internal/llm/prompt.go+117−0
Cut short: this commit's diff is over 1000 lines.
internal/llm/prompt.md+0−0
internal/llm/qwen.md+144−0
Cut short: this commit's diff is over 1000 lines.
internal/tui/golden_test.go+1−1
Cut short: this commit's diff is over 1000 lines.
internal/tui/tui.go+14−2
Cut short: this commit's diff is over 1000 lines.