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 ¶
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 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 ¶
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.
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.