Documentation
¶
Overview ¶
Package adapter resumes agent sessions via their CLIs (spec §6). Adapters are resume-based, never push-based.
Index ¶
- func BuildClaudeArgs(sessionID, prompt string) []string
- func BuildCodexArgs(sessionID, prompt string) []string
- func BuildCursorArgs(sessionID, prompt string) []string
- func BuildOpenCodeArgs(sessionID, prompt string) []string
- func ParseResultJSON(out []byte) (string, bool)
- type Adapter
- type Claude
- type Codex
- type Cursor
- type Fake
- type FakeCall
- type OpenCode
- type Registry
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildClaudeArgs ¶
BuildClaudeArgs builds the resume invocation. The prompt is a positional argument terminated by "--" so rendered prompts that start with a dash can never be eaten by claude's option parser (a "--help" prompt would otherwise exit 0 without resuming — a silent false success). --output-format must precede the terminator.
func BuildCodexArgs ¶
BuildCodexArgs: prompt positional after "--" (dash-safe, stage-3 lesson); --skip-git-repo-check keeps non-git repoPaths working.
func BuildCursorArgs ¶
BuildCursorArgs: the prompt is positional after "--" so dash-leading prompts can never be eaten by the option parser (stage-3 lesson).
func BuildOpenCodeArgs ¶
BuildOpenCodeArgs: prompt positional after "--" (dash-safe).
func ParseResultJSON ¶
ParseResultJSON extracts the "result" field from the JSON object that both Claude (`--output-format json`) and Cursor (`--output-format json`) print; falls back to the raw text. The boolean reports whether structured output was recognized.
Types ¶
type Adapter ¶
type Adapter interface {
Name() string
Resume(ctx context.Context, sess core.Session, prompt string) (Result, error)
Validate() error
}
Adapter resumes a session with an injected prompt and reports the outcome. Resume returns an error only when the run could not even be attempted (binary missing, spawn failure); a nonzero agent exit is a Result, not an error.
type Claude ¶
type Claude struct{}
Claude resumes Claude Code sessions headlessly:
claude --resume <session-id> -p "<prompt>" --output-format json
run in the session's repoPath (restores the original project config — see docs/reference/claude-code.md). v1 passes NO permission flags (owner decision): the agent runs with its project-configured permissions, and unapproved tool calls are denied in headless mode.
type Codex ¶
type Codex struct{}
Codex resumes Codex CLI sessions non-interactively:
codex exec resume <session-id> --skip-git-repo-check -- "<prompt>"
run in the session's repoPath. Default exec mode streams progress to stderr and prints only the final agent message to stdout (see docs/reference/codex-cli.md) — the shared runner keeps them apart. v1 passes NO sandbox/approval flags (owner decision); codex exec defaults to a read-only sandbox, a documented limitation.
type Cursor ¶
type Cursor struct{}
Cursor resumes Cursor CLI sessions headlessly:
agent -p --resume <chat-id> --output-format json -- "<prompt>"
run in the session's repoPath (the CLI treats cwd as the repository root — see docs/reference/cursor-cli.md). The -p+--resume combination is not shown combined in official docs; Validate() existing is why. v1 passes NO permission flags (no --force/--trust — owner decision): in print mode the agent proposes edits without applying them unless the workspace allows it.
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake is a controllable in-memory adapter for dispatcher tests.
func (*Fake) SetOutcome ¶
type OpenCode ¶
type OpenCode struct{}
OpenCode resumes OpenCode sessions non-interactively:
opencode run --session <ses_id> -- "<prompt>"
run in the session's repoPath (opencode stores sessions per-project keyed by directory — see docs/reference/opencode.md). Known caveat, documented there: opencode's CLI historically exits 0 on some errors; v1 trusts the exit code and records the output summary so failures are at least visible. The serve/HTTP path is a future improvement. v1 passes NO permission flags (owner decision).