Skip to content

[harness] Add Cursor CLI provider to Go SDK #293

@santoshkumarradha

Description

@santoshkumarradha

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.goCursorProvider struct + Execute() method

Modify

  • sdk/go/harness/provider.go — Add ProviderCursor = "cursor" constant
  • sdk/go/harness/runner.go — Add case 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{}, nil

Acceptance Criteria

  • CursorProvider implements Provider interface
  • Provider constant and routing in place
  • Uses shared RunCLI() for subprocess execution
  • JSON output parsed for result text and session_id
  • Session resume via --resume flag
  • Timeout handling via RunCLI
  • Custom binary path via BinPath option
  • Tests cover: basic execution, JSON parsing, session resume, timeout, missing binary
  • Follows exact patterns from claudecode.go and opencode.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-friendlyWell-documented task suitable for AI-assisted developmentarea:harnessCoding agent harness integrationcore-teamMaintained by core team — not open for external contributionenhancementNew feature or requestsdk:goGo SDK related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions