core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package core assembles the app: it prepares the data directory, opens and migrates the database, syncs the discovered agent profiles, adds the starter prompts, and builds every service the window binds to.

Core is plain Go with no desktop dependency, so the whole startup path is tested on any OS. The desktop shell only adds the window, binds Services, and runs the scheduler.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoDataDir is returned when Options.Paths has no root directory.
	ErrNoDataDir = errors.New("the data directory is not set")

	// ErrNoHomeDir is returned when Options.Home is empty.
	ErrNoHomeDir = errors.New("the home directory is not set")
)

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock tells the time.

type Core

type Core struct {
	// DB is the open, migrated database.
	DB *gorm.DB

	// The services bound to the frontend.
	Settings       *settings.Service
	Profiles       *profiles.Service
	Prompts        *prompts.Service
	LaunchDefaults *launchdefaults.Service
	Inbox          *inbox.Service
	Launcher       *launcher.Service
	Worktrees      *worktrees.Service
	Notifications  *notify.Service
	AppInfo        *appinfo.Service

	// Scheduler refreshes the inbox on start and every five minutes once Run is called.
	// A worktrees.Sweeper over Worktrees does the same for the automatic worktree
	// cleanup.
	Scheduler *inbox.Scheduler

	// Timing records the first paint.
	Timing *timing.Recorder
}

Core is the assembled app: the database and every service.

func Bootstrap

func Bootstrap(ctx context.Context, opts Options) (*Core, error)

Bootstrap prepares the data directory, opens the database (backing it up and applying any pending migrations), syncs the agent profiles found under the home directory, adds any starter prompt not added before, and builds every service. It contacts no network; the scheduler does that once started.

func (*Core) Close

func (c *Core) Close() error

Close closes the database.

func (*Core) Services

func (c *Core) Services() []any

Services returns the services the frontend binds to, in a stable order.

type Options

type Options struct {
	// Paths is where the database, launch files, and logs live.
	Paths appdata.Paths

	// Home is the user's home directory: profiles are discovered there, and a ~ clone
	// root expands to it.
	Home string

	// Version is the build's version; it is reported to the frontend and to GitHub as
	// part of the user agent.
	Version string

	// Release is the release version and Build the build number; both are reported to
	// the frontend.
	Release string
	Build   string

	// Clock stamps refreshes, launches, and worktree listings. It defaults to the system
	// clock.
	Clock Clock

	// Notifier is told when the stored inbox changed.
	Notifier inbox.Notifier

	// WorktreeNotifier is told when an automatic worktree sweep changed something.
	WorktreeNotifier worktrees.Notifier

	// ThemeNotifier is told when the theme was changed and stored.
	ThemeNotifier settings.ThemeNotifier

	// MenuBarNotifier is told when the menu bar setting was changed and stored.
	MenuBarNotifier settings.MenuBarNotifier

	// Banners shows native notifications; without it the notification log is still kept.
	Banners notify.Poster

	// NotificationsNotifier is told when the notification log changed.
	NotificationsNotifier notify.Notifier

	// Runner runs external programs. It defaults to an execpath.Runner whose finder
	// searches the well-known directories under Home.
	Runner Runner

	// Logger receives scheduler and timing records. It defaults to slog.Default().
	Logger *slog.Logger

	// OnFirstPaint is called once when the frontend reports its first paint.
	OnFirstPaint func(timing.Measurement)
}

Options configure Bootstrap. Paths and Home are required; the rest are optional.

type Runner

type Runner interface {
	Run(ctx context.Context, name string, args ...string) (stdout, stderr []byte, err error)
}

Runner runs a program as an argv, never through a shell. execpath.Runner implements it; the GitHub token source, the clone scan, the confirmed clone of a missing repository, the terminal drivers, and the worktree service all run their programs through it.

Jump to

Keyboard shortcuts

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