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
3 changes: 1 addition & 2 deletions internal/ai/provider/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,9 @@ func NewClaudeCLIProvider(model string) *ClaudeCLIProvider {

// GenerateContent generates content using the Claude Code CLI.
func (p *ClaudeCLIProvider) GenerateContent(_ context.Context, systemMessage, userMessage string) (string, Usage, error) {
prompt := fmt.Sprintf("System: %s\nUser: %s", systemMessage, userMessage)
cfg := claudecli.Config{Model: p.model}
client := claudecli.NewClientWithConfig(cfg)
resp, err := client.Execute(prompt)
resp, err := client.ExecuteWithSystemPrompt(systemMessage, userMessage)
if err != nil {
return "", Usage{}, fmt.Errorf("claudecli execution failed: %w", err)
}
Expand Down
20 changes: 17 additions & 3 deletions pkg/claudecli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

const (
ClaudeCommand = "claude"
DefaultTimeout = 60 * time.Second
DefaultTimeout = 120 * time.Second
DefaultModel = "sonnet"
)

Expand Down Expand Up @@ -51,7 +51,12 @@ func NewClientWithConfig(config Config) *Client {

// Execute runs the claude CLI with the given prompt in print mode.
func (c *Client) Execute(prompt string) (string, error) {
if prompt == "" {
return c.ExecuteWithSystemPrompt("", prompt)
}

// ExecuteWithSystemPrompt runs the claude CLI with separate system and user prompts in print mode.
func (c *Client) ExecuteWithSystemPrompt(systemPrompt, userPrompt string) (string, error) {
if userPrompt == "" {
return "", fmt.Errorf("prompt cannot be empty")
}

Expand All @@ -60,7 +65,16 @@ func (c *Client) Execute(prompt string) (string, error) {
return "", fmt.Errorf("claude command not found: %w", err)
}

args := []string{"-p", prompt, "--model", c.model, "--output-format", "text"}
args := []string{
"-p", userPrompt,
"--model", c.model,
"--output-format", "text",
"--max-turns", "1",
"--allowedTools", "[]",
}
if systemPrompt != "" {
args = append(args, "--system-prompt", systemPrompt)
}
cmd := exec.Command(claudePath, args...)

var stdout, stderr bytes.Buffer
Expand Down