extensions

package
v0.89.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0 Imports: 35 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 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)
	Ask       func(context.Context, api.AskSessionOptions) (api.SessionAnswer, 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
}

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) CommitInstall

CommitInstall moves the staged copy into the extensions directory and starts it.

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 the latest release of a GitHub repository's extension for this platform, verifies and unpacks it, and stages it for CommitInstall.

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.

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.

Jump to

Keyboard shortcuts

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