core

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataDir

func DataDir(hash, projectID string) string

DataDir returns the data directory for a project: ~/.sweo/data/{hash}-{projectID}

func DeleteMetadata

func DeleteMetadata(sessionsDir, sessionID string) error

DeleteMetadata removes the metadata file for a session.

func GenerateSessionID

func GenerateSessionID(prefix string, num int) string

GenerateSessionID creates a session ID: {prefix}-{num}

func GenerateSessionPrefix

func GenerateSessionPrefix(projectID string) string

GenerateSessionPrefix generates a short prefix from a project ID. Rules: <=4 chars -> as-is, kebab/snake -> initials, CamelCase -> uppercase letters, else first 3.

func GenerateTmuxName

func GenerateTmuxName(hash, prefix string, num int) string

GenerateTmuxName creates a globally unique tmux session name: {hash}-{prefix}-{num}

func GetNextSessionNumber

func GetNextSessionNumber(existing []string, prefix string) int

GetNextSessionNumber finds the next available session number for the given prefix.

func ListSessions

func ListSessions(sessionsDir string) ([]string, error)

ListSessions returns all session IDs in the sessions directory.

func ParseKeyValue

func ParseKeyValue(content string) map[string]string

ParseKeyValue parses key=value lines into a map.

func ReadMetadata

func ReadMetadata(sessionsDir, sessionID string) (map[string]string, error)

ReadMetadata reads the key=value metadata file for a session. Returns nil, nil if the file does not exist.

func ReserveSessionID

func ReserveSessionID(sessionsDir, sessionID string) error

ReserveSessionID atomically creates an empty metadata file, failing if it already exists.

func SerializeKeyValue

func SerializeKeyValue(data map[string]string) string

SerializeKeyValue serializes a map to key=value lines, sorted by key.

func SessionsDir

func SessionsDir(hash, projectID string) string

SessionsDir returns the sessions directory for a project.

func UpdateMetadata

func UpdateMetadata(sessionsDir, sessionID string, updates map[string]string) error

UpdateMetadata merges updates into existing metadata. Empty string values delete keys.

func ValidateSessionID

func ValidateSessionID(id string) error

ValidateSessionID checks that a session ID is safe for filesystem use.

func WorktreesDir

func WorktreesDir(hash, projectID string) string

WorktreesDir returns the worktrees directory for a project.

func WriteMetadata

func WriteMetadata(sessionsDir, sessionID string, data map[string]string) error

WriteMetadata atomically writes key=value metadata for a session.

Types

type Session

type Session struct {
	ID            string
	ProjectID     string
	Status        SessionStatus
	Branch        string
	IssueID       string
	IssueTitle    string
	PRURL         string
	PRNumber      int
	WorkspacePath string
	TmuxName      string
	Agent         string
	CreatedAt     time.Time
	Metadata      map[string]string
}

Session represents a running or completed agent session.

type SessionStatus

type SessionStatus string

SessionStatus represents the current state of a session.

const (
	StatusSpawning         SessionStatus = "spawning"
	StatusWorking          SessionStatus = "working"
	StatusWaitingInput     SessionStatus = "waiting_input"
	StatusPROpen           SessionStatus = "pr_open"
	StatusCIFailed         SessionStatus = "ci_failed"
	StatusChangesRequested SessionStatus = "changes_requested"
	StatusReviewPending    SessionStatus = "review_pending"
	StatusMerged           SessionStatus = "merged"
	StatusCleanup          SessionStatus = "cleanup"
	StatusDone             SessionStatus = "done"
	StatusErrored          SessionStatus = "errored"
	StatusStuck            SessionStatus = "stuck"
)

func (SessionStatus) IsTerminal

func (s SessionStatus) IsTerminal() bool

IsTerminal returns true if the status is a final state.

Jump to

Keyboard shortcuts

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