opencode

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package opencode provides the OpenCode agent source for agentwatch.

OpenCode stores sessions in a SQLite database (typically at ~/.local/share/opencode/opencode.db). This source queries the database read-only to discover and parse session state.

This source does NOT resolve the database path from XDG_DATA_HOME or any environment variable. Callers must supply the path explicitly via WithDBPath. If no path is provided the source returns no sessions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(r *source.Registry, opts ...Option) error

Register registers this source with a source.Registry using a factory that calls New(opts...).

Types

type Option

type Option func(*Source)

Option configures a Source.

func WithDBPath

func WithDBPath(path string) Option

WithDBPath sets the path to the OpenCode SQLite database. Without this option the source discovers no sessions.

func WithDiscoverWindow

func WithDiscoverWindow(d time.Duration) Option

WithDiscoverWindow limits discovery to sessions whose updated_at is within d of the current time. Zero disables age filtering.

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source implements source.Source for OpenCode agent sessions.

func New

func New(opts ...Option) *Source

New creates a new OpenCode source with the given options.

func (*Source) Discover

func (s *Source) Discover(ctx context.Context) ([]source.SessionHandle, error)

Discover implements source.Source. It queries the OpenCode SQLite database for sessions, optionally filtering by the discover window.

func (*Source) Name

func (s *Source) Name() string

Name implements source.Source.

func (*Source) Parse

Parse implements source.Source. The cursor encodes message and tool call counts from the previous parse; deltas are computed by subtraction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL