a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
// Package cursor is the Cursor Agent CLI llm.Provider.
|
|
//
|
|
// It shells out to the user's locally installed `cursor-agent` binary
|
|
// in non-interactive print mode (`-p`), reusing the existing Cursor
|
|
// sign-in — no API key in gortex's environment. `--output-format text`
|
|
// keeps stdout to the model's answer. The shared agentcli engine
|
|
// handles spawning, timeout, capture, and structured extraction.
|
|
package cursor
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/zzet/gortex/internal/llm"
|
|
"github.com/zzet/gortex/internal/llm/provider/agentcli"
|
|
)
|
|
|
|
// New constructs the Cursor Agent CLI provider, verifying the binary is
|
|
// on $PATH. The prompt is passed via `-p`, the model via `--model`, and
|
|
// output is forced to plain text.
|
|
func New(cfg llm.CLIConfig) (llm.Provider, error) {
|
|
return agentcli.New(agentcli.Spec{
|
|
ProviderID: "cursor",
|
|
Model: strings.TrimSpace(cfg.Model),
|
|
ModelFlag: "--model",
|
|
BaseArgs: []string{"--output-format", "text"},
|
|
Delivery: agentcli.DeliveryFlag,
|
|
PromptFlag: "-p",
|
|
ExtraArgs: append([]string(nil), cfg.Args...),
|
|
Timeout: time.Duration(cfg.TimeoutSeconds) * time.Second,
|
|
}, cfg.Binary, "cursor-agent")
|
|
}
|