-
Notifications
You must be signed in to change notification settings - Fork 198
[harness] Add Cursor CLI provider to Go SDK #293
Copy link
Copy link
Open
Labels
ai-friendlyWell-documented task suitable for AI-assisted developmentWell-documented task suitable for AI-assisted developmentarea:harnessCoding agent harness integrationCoding agent harness integrationcore-teamMaintained by core team — not open for external contributionMaintained by core team — not open for external contributionenhancementNew feature or requestNew feature or requestsdk:goGo SDK relatedGo SDK related
Description
Parent Epic
Part of #291 — Add Cursor as a Harness Provider
Summary
Add CursorProvider to the Go SDK harness system. This follows the same pattern as existing ClaudeCodeProvider and OpenCodeProvider, using the shared RunCLI() function.
Files to Create/Modify
New
sdk/go/harness/cursor.go—CursorProviderstruct +Execute()method
Modify
sdk/go/harness/provider.go— AddProviderCursor = "cursor"constantsdk/go/harness/runner.go— Addcase ProviderCursor:to provider switch
Tests
sdk/go/harness/cursor_test.go
Implementation Details
CLI Command Construction
func (p *CursorProvider) Execute(ctx context.Context, prompt string, opts Options) (*RawResult, error) {
bin := opts.BinPath
if bin == "" {
bin = "agent"
}
args := []string{"-p", "--force", "--trust", "--output-format", "json"}
if opts.Cwd != "" {
args = append(args, "--workspace", opts.Cwd)
}
if opts.Model != "" {
args = append(args, "--model", opts.Model)
}
if opts.ResumeSessionID != "" {
args = append(args, "--resume", opts.ResumeSessionID)
}
if opts.PermissionMode == "plan" {
args = append(args, "--mode", "plan")
}
args = append(args, prompt)
return RunCLI(ctx, bin, args, opts.Env, opts.Timeout)
}Output Parsing
Use json mode (single JSON object on completion):
{
"type": "result",
"subtype": "success",
"result": "<text>",
"session_id": "<uuid>",
"duration_ms": 1234
}Parse result field as the text output, session_id for resume capability.
Provider Registration
// provider.go
const ProviderCursor = "cursor"
// runner.go — in buildProvider()
case ProviderCursor:
return &CursorProvider{}, nilAcceptance Criteria
-
CursorProviderimplementsProviderinterface - Provider constant and routing in place
- Uses shared
RunCLI()for subprocess execution - JSON output parsed for result text and session_id
- Session resume via
--resumeflag - Timeout handling via
RunCLI - Custom binary path via
BinPathoption - Tests cover: basic execution, JSON parsing, session resume, timeout, missing binary
- Follows exact patterns from
claudecode.goandopencode.go
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ai-friendlyWell-documented task suitable for AI-assisted developmentWell-documented task suitable for AI-assisted developmentarea:harnessCoding agent harness integrationCoding agent harness integrationcore-teamMaintained by core team — not open for external contributionMaintained by core team — not open for external contributionenhancementNew feature or requestNew feature or requestsdk:goGo SDK relatedGo SDK related