extensions

package
v0.93.0-rc.14 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 41 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 extensions runs what the user installed under lich's extensions directory: separate programs that speak the JSON lines of the extension contract over stdin and stdout. Each is started at boot, restarted when it crashes, and stopped with the backend. An extension is unsandboxed code, but what it writes is input the window draws, so every line is vetted here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check added in v0.91.0

func Check(path string) (extension.Manifest, error)

Check runs an install's checks on an extension's folder or on a release archive named <id>_<goos>_<goarch>.tar.gz, on a copy it then deletes, and returns the manifest that passed. It needs no lich running and no network. minLichVersion is checked for its form only: the lich that checks is not the one that installs.

func DataDir

func DataDir(configDir string) string

DataDir holds a directory per extension id for what the extension keeps, apart from Dir so a reinstall, which replaces the install directory, keeps it.

func Dir

func Dir(configDir string) string

Dir is where extensions are installed under configDir. A dev instance has its own, as it has its own themes and database: otherwise `task dev` would start a second copy of every extension the installed lich runs.

Types

type Lich

type Lich struct {
	Projects  func(context.Context, api.None) ([]api.Project, error)
	Peers     func(context.Context, api.PeersOptions) ([]api.Peer, error)
	Worktrees func(context.Context, api.WorktreesOptions) ([]api.WorktreeCheckout, error)
	Open      func(context.Context, api.OpenSessionOptions) (api.OpenedSession, error)
	Send      func(context.Context, api.SendOptions) (api.SendResult, error)
	Wait      func(context.Context, api.WaitOptions) (api.SendResult, error)

	Project        func(context.Context, api.ProjectRefOptions) (api.ProjectRef, error)
	Services       func(context.Context, api.None) ([]api.Service, error)
	StartService   func(context.Context, api.ServiceIDOptions) (api.None, error)
	StopService    func(context.Context, api.ServiceIDOptions) (api.None, error)
	RestartService func(context.Context, api.ServiceIDOptions) (api.None, error)
	Output         func(context.Context, api.ServiceIDOptions) ([]byte, error)
	LiveOutput     func(context.Context, api.ServiceIDOptions) ([]byte, error)

	Diff        func(context.Context, api.PathOptions) (api.DiffStats, error)
	BaseStatus  func(context.Context, api.PathOptions) (*api.BaseStatus, error)
	Upstream    func(context.Context, api.PathOptions) (api.BaseFreshness, error)
	PullRequest func(context.Context, api.PathOptions) (*api.PullRequest, error)

	Notify   func(context.Context, api.NotifyOptions) (api.None, error)
	ShowCode func(context.Context, api.ShowCodeOptions) (api.ShowCode, error)
	OpenURL  func(context.Context, api.BrowserOpenOptions) (api.BrowserHandle, error)
	// Attached is whether a window is connected to show what ShowCode and
	// OpenURL do.
	Attached func() bool
	// PromptLang is the language an extension's name is worded in for the
	// agents it sends to.
	PromptLang func() prompt.Lang
}

Lich is what an extension's calls reach: the services lich's MCP tools call, each called as the lich command line outside a session calls it.

type Service

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

Service is every installed extension and its process.

func New

func New(dir, dataDir, lichVersion string, env []string, emit func(name string, data any)) *Service

New returns the extensions under dir, none discovered or running until Boot. env is what their processes get, and each one's data directory is under dataDir.

func (*Service) Boot

func (s *Service) Boot()

Boot deletes what earlier runs left staged, then discovers the extensions and starts every valid one.

func (*Service) Catalog added in v0.91.0

Catalog is the catalog in memory, read now when there is none; the read's error is the answer only when that leaves none.

func (*Service) CatalogImage added in v0.91.0

func (s *Service) CatalogImage(_ context.Context, opts api.ExtensionCatalogImageOptions) ([]byte, error)

CatalogImage reads an image the catalog in memory names, held to the listing's limit for it: the window draws what the catalog shows through here, and no other address is fetched on its behalf.

func (*Service) CheckUpdates added in v0.91.0

func (s *Service) CheckUpdates(ctx context.Context, _ api.None) ([]api.Extension, error)

CheckUpdates looks for a newer release of every extension installed from GitHub, tells the window of each one whose answer changed, and returns the list as it then stands.

func (*Service) CommitInstall

func (s *Service) CommitInstall(ctx context.Context, opts api.ExtensionInstallTokenOptions) (api.Extension, error)

CommitInstall moves the staged copy into the extensions directory and starts it, in place of the installed version when it is an update.

func (*Service) DeleteData

func (s *Service) DeleteData(_ context.Context, opts api.ExtensionIDOptions) (api.None, error)

DeleteData deletes the data directory of an extension that is not installed. installMu keeps an install of the same id from starting while it goes.

func (*Service) DiscardInstall

func (s *Service) DiscardInstall(_ context.Context, opts api.ExtensionInstallTokenOptions) (api.None, error)

DiscardInstall deletes the staged copy.

func (*Service) ExtensionsDir

func (s *Service) ExtensionsDir(context.Context, api.None) (string, error)

ExtensionsDir is the directory extensions are read from and installed into.

func (*Service) List

func (s *Service) List(_ context.Context, _ api.None) ([]api.Extension, error)

List is every installed extension with its state, by directory name.

func (*Service) Observe

func (s *Service) Observe(name string, data any)

Observe hands every app event to the extensions subscribed to it. It runs on the emitter's goroutine, so it only queues.

func (*Service) PrepareFromDir

PrepareFromDir copies a folder holding manifest.json and the executable at its root into a stage for CommitInstall. The folder is left as it was.

func (*Service) PrepareFromGit

PrepareFromGit downloads a GitHub repository's extension for this platform, verifies and unpacks it, and stages it for CommitInstall: the release the catalog lists for a listed repository, the latest for another.

func (*Service) PrepareUpdate added in v0.91.0

PrepareUpdate stages the latest release of the repository an extension was installed from, for CommitInstall to put in its place. The installed version keeps running until then.

func (*Service) Remove

func (s *Service) Remove(ctx context.Context, opts api.ExtensionIDOptions) (api.None, error)

Remove stops an extension and deletes its directory. A directory that is a symlink, an extension developed in place, loses the link and keeps its target. Its data directory stays, for DeleteData or the next install of the same id.

func (*Service) Restart

func (s *Service) Restart(ctx context.Context, opts api.ExtensionIDOptions) (api.None, error)

Restart starts an extension again, which is the only way back from failed, and starts its count of quick crashes over. One that is running or waiting to restart is stopped first, as lich stops it on exit. The directory is read again, so an edited manifest is what runs and one that no longer validates shows invalid with its reason instead of starting. The id is the directory name, so a manifest whose id changed on disk is invalid like any other.

func (*Service) Send

Send writes one message to an extension's process.

func (*Service) SetLanguage

func (s *Service) SetLanguage(language func() string)

SetLanguage names where the interface language an extension starts with comes from, before Boot. Without one it starts with English.

func (*Service) SetLich

func (s *Service) SetLich(lich Lich)

SetLich wires the services calls reach, before Boot.

func (*Service) Shutdown

func (s *Service) Shutdown()

Shutdown stops every extension: stdin closes, each gets its grace, and what is still up is killed. Bounded, so nothing here can hold up lich's exit.

func (*Service) WatchUpdates added in v0.91.0

func (s *Service) WatchUpdates()

WatchUpdates reads the catalog and looks for newer releases now and every updateCheckEvery, until Shutdown.

Jump to

Keyboard shortcuts

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