-
Notifications
You must be signed in to change notification settings - Fork 291
Explain summary provider #887
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
base: codex-explain-generate
Are you sure you want to change the base?
Changes from all commits
d204056
f5e6650
fe711b0
ece160c
ecf914f
9c585b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package codex | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os/exec" | ||
|
|
||
| "github.com/entireio/cli/cmd/entire/cli/agent" | ||
| ) | ||
|
|
||
| var codexCommandRunner = exec.CommandContext | ||
|
|
||
| // GenerateText sends a prompt to the Codex CLI and returns the raw text response. | ||
| func (c *CodexAgent) GenerateText(ctx context.Context, prompt string, model string) (string, error) { | ||
| args := []string{"exec", "--skip-git-repo-check"} | ||
| if model != "" { | ||
| args = append(args, "--model", model) | ||
| } | ||
| args = append(args, "-") | ||
|
|
||
| result, err := agent.RunIsolatedTextGeneratorCLI(ctx, codexCommandRunner, "codex", "codex", args, prompt) | ||
| if err != nil { | ||
| return "", fmt.Errorf("codex text generation failed: %w", err) | ||
| } | ||
| return result, nil | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package copilotcli | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os/exec" | ||
|
|
||
| "github.com/entireio/cli/cmd/entire/cli/agent" | ||
| ) | ||
|
|
||
| var copilotCommandRunner = exec.CommandContext | ||
|
|
||
| // GenerateText sends a prompt to the Copilot CLI and returns the raw text response. | ||
| func (c *CopilotCLIAgent) GenerateText(ctx context.Context, prompt string, model string) (string, error) { | ||
| args := []string{"-p", prompt, "--allow-all-tools"} | ||
| if model != "" { | ||
| args = append(args, "--model", model) | ||
| } | ||
|
|
||
| result, err := agent.RunIsolatedTextGeneratorCLI(ctx, copilotCommandRunner, "copilot", "copilot", args, "") | ||
| if err != nil { | ||
| return "", fmt.Errorf("copilot text generation failed: %w", err) | ||
| } | ||
| return result, nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package cursor | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
|
|
||
| "github.com/entireio/cli/cmd/entire/cli/agent" | ||
| ) | ||
|
|
||
| var cursorCommandRunner = exec.CommandContext | ||
|
|
||
| // GenerateText sends a prompt to the Cursor agent CLI and returns the raw text response. | ||
| func (c *CursorAgent) GenerateText(ctx context.Context, prompt string, model string) (string, error) { | ||
| args := []string{"-p", prompt, "--force", "--trust", "--workspace", os.TempDir()} | ||
| if model != "" { | ||
| args = append(args, "--model", model) | ||
| } | ||
|
|
||
| result, err := agent.RunIsolatedTextGeneratorCLI(ctx, cursorCommandRunner, "agent", "cursor", args, "") | ||
| if err != nil { | ||
| return "", fmt.Errorf("cursor text generation failed: %w", err) | ||
| } | ||
| return result, nil | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package geminicli | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os/exec" | ||
|
|
||
| "github.com/entireio/cli/cmd/entire/cli/agent" | ||
| ) | ||
|
|
||
| var geminiCommandRunner = exec.CommandContext | ||
|
|
||
| // GenerateText sends a prompt to the Gemini CLI and returns the raw text response. | ||
| func (g *GeminiCLIAgent) GenerateText(ctx context.Context, prompt string, model string) (string, error) { | ||
| args := []string{"-p", ""} | ||
| if model != "" { | ||
| args = append(args, "--model", model) | ||
| } | ||
|
|
||
| result, err := agent.RunIsolatedTextGeneratorCLI(ctx, geminiCommandRunner, "gemini", "gemini", args, prompt) | ||
| if err != nil { | ||
|
Comment on lines
+14
to
+21
|
||
| return "", fmt.Errorf("gemini text generation failed: %w", err) | ||
| } | ||
| return result, nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| package agent | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "strings" | ||
| ) | ||
|
|
||
| // TextCommandRunner matches exec.CommandContext and allows tests to inject a runner. | ||
| type TextCommandRunner func(ctx context.Context, name string, args ...string) *exec.Cmd | ||
|
|
||
| // RunIsolatedTextGeneratorCLI executes a text-generation CLI in an isolated temp | ||
| // directory with all GIT_* environment variables removed. This avoids recursive | ||
| // hook triggers and repo side effects while preserving provider-specific flags. | ||
| func RunIsolatedTextGeneratorCLI(ctx context.Context, runner TextCommandRunner, binary, displayName string, args []string, stdin string) (string, error) { | ||
| if runner == nil { | ||
| runner = exec.CommandContext | ||
| } | ||
|
|
||
| cmd := runner(ctx, binary, args...) | ||
| cmd.Dir = os.TempDir() | ||
| cmd.Env = StripGitEnv(os.Environ()) | ||
| if stdin != "" { | ||
| cmd.Stdin = strings.NewReader(stdin) | ||
| } | ||
|
|
||
| var stdout, stderr bytes.Buffer | ||
| cmd.Stdout = &stdout | ||
| cmd.Stderr = &stderr | ||
|
|
||
| if err := cmd.Run(); err != nil { | ||
| var execErr *exec.Error | ||
| if errors.As(err, &execErr) { | ||
| return "", fmt.Errorf("%s CLI not found: %w", displayName, err) | ||
| } | ||
| var exitErr *exec.ExitError | ||
| if errors.As(err, &exitErr) { | ||
| detail := stderr.String() | ||
| if detail == "" { | ||
| detail = stdout.String() | ||
| } | ||
| return "", fmt.Errorf("%s CLI failed (exit %d): %s", displayName, exitErr.ExitCode(), detail) | ||
| } | ||
| return "", fmt.Errorf("failed to run %s CLI: %w", displayName, err) | ||
| } | ||
|
|
||
| return strings.TrimSpace(stdout.String()), nil | ||
| } | ||
|
|
||
| func StripGitEnv(env []string) []string { | ||
| filtered := make([]string, 0, len(env)) | ||
| for _, e := range env { | ||
| if !strings.HasPrefix(e, "GIT_") { | ||
| filtered = append(filtered, e) | ||
| } | ||
| } | ||
| return filtered | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot and Cursor pass large prompts as CLI arguments
Medium Severity
The Copilot and Cursor
GenerateTextimplementations embed the fullpromptas a command-line argument via-p. When used throughTextGeneratorAdapterfor summarization, this prompt includes the entire formatted transcript, which can be very large. This can exceed OS argument length limits (e.g., ~256 KB on macOS), causing theexeccall to fail. Other providers (Claude Code, Codex, Gemini) correctly pass the prompt via stdin.Additional Locations (1)
cmd/entire/cli/agent/cursor/generate.go#L15-L16Reviewed by Cursor Bugbot for commit c3d84bc. Configure here.