app

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 50 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 app assembles a Scribe session: config, model registry, tools, code map, language servers, memory, hooks, MCP servers, session storage and the agent itself. The TUI (through tui.Backend), the headless runner and the Lectern bridge all drive an *App.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultModel

func DefaultModel(reg *registry.Registry) string

DefaultModel picks a model when config and flags name none: the first provider with a key, else a local Ollama.

func FindRoot

func FindRoot(dir string) string

FindRoot returns the git repository root containing dir, or dir.

func NewBackend

func NewBackend(a *App, h *TUIHost) tui.Backend

NewBackend wraps an opened App for the TUI. h must be the TUIHost that was passed as a.opts.Host, or approvals will not reach the TUI.

func OnOpen

func OnOpen(fn func(*App))

OnOpen registers fn to run at the end of every Open in this process. Registration is process-wide and cannot be undone; register once.

Types

type App

type App struct {
	Workdir string
	Cfg     config.Config
	// ConfigWarning is set when the project config was ignored at start
	// (a parse error); empty otherwise. The TUI shows it once.
	ConfigWarning string

	Registry *registry.Registry
	Tools    *tools.Registry
	Agent    *agent.Agent
	Planner  *agent.Planner
	Dispatch *agent.Dispatcher

	Store  *session.Store
	Meta   session.Meta
	Checks *session.Checkpoints
	Memory *memory.Stores
	Skills *skills.Set
	// contains filtered or unexported fields
}

App is one Scribe session.

func Open

func Open(ctx context.Context, o Options) (*App, error)

Open builds a session.

func (*App) AddSessionForbidden

func (a *App) AddSessionForbidden(pat string) bool

AddSessionForbidden forbids a pattern until Scribe exits.

func (*App) Claims

func (a *App) Claims() []tui.ClaimRow

Claims lists the file claims held by every tab in this process.

func (*App) CleanStorage

func (a *App) CleanStorage(keys []string) (int64, error)

CleanStorage deletes the contents of the named storage areas (the directories themselves stay) and reports the bytes freed. The current session's folder is always kept.

func (*App) Close

func (a *App) Close() error

Close releases everything.

func (*App) ContinueTurn

func (a *App) ContinueTurn(ctx context.Context) (agent.TurnStats, error)

ContinueTurn re-runs the session's interrupted turn (`/session continue`, `lectern code --continue`). It does not add the prompt again: the history already holds it. It returns agent.ErrNothingToContinue when the last turn finished.

func (*App) ForceClaim

func (a *App) ForceClaim(path string) (string, error)

ForceClaim takes a file from whichever tab holds it. It returns the label of the tab that lost it, or "" when nobody held it.

func (*App) HookEvents

func (a *App) HookEvents() []tui.HookEvent

HookEvents lists the hook events this session runs, with their switch state.

func (*App) Host

func (a *App) Host() tools.Host

Host returns the host that answers approvals and questions.

func (*App) OnClose

func (a *App) OnClose(f func())

func (*App) Opts

func (a *App) Opts() Options

Opts returns the options the app was opened with.

func (*App) ReleaseAllClaims

func (a *App) ReleaseAllClaims() int

ReleaseAllClaims drops every claim this tab holds and reports how many.

func (*App) ReleaseClaim

func (a *App) ReleaseClaim(path string) (bool, error)

ReleaseClaim drops this tab's claim on one file. It never touches another tab's claim; false means this tab did not hold the file.

func (*App) RemoveSessionForbidden

func (a *App) RemoveSessionForbidden(pat string) bool

RemoveSessionForbidden lifts a session-only pattern.

func (*App) RenderMap

func (a *App) RenderMap(conversationTokens int, focus []string) string

RenderMap returns the code map sized for a conversation of conversationTokens tokens (budgetFor), focused on focus when given. It is "" until the first build has finished or when the map is off. It never waits for the build, so the TUI and the prompt path can call it freely.

func (*App) Run

func (a *App) Run(ctx context.Context, prompt string, images []llm.Part) (agent.TurnStats, error)

Run executes one user turn synchronously.

func (*App) SessionForbidden

func (a *App) SessionForbidden() []string

SessionForbidden lists the forbidden patterns added for this session.

func (*App) SessionID

func (a *App) SessionID() string

SessionID returns the session id ("" for ephemeral).

func (*App) SetHookEventOff

func (a *App) SetHookEventOff(event string, off bool) error

SetHookEventOff switches one event's hooks off or on for this session only.

func (*App) SetHost

func (a *App) SetHost(h tools.Host)

SetHost replaces the host that answers approvals and questions. Call it before the first Run (OnOpen hooks are the intended place): tool calls read the host when they start, and a swap in the middle of a turn is not supported.

func (*App) SetModel

func (a *App) SetModel(ref string) error

SetModel switches model.

func (*App) SetTabID

func (a *App) SetTabID(id string)

SetTabID records the TUI tab that owns this session, on the App and on its lead agent, so the model log tags the tab the user actually sees.

func (*App) StorageReport

func (a *App) StorageReport() []tui.StorageItem

StorageReport sizes Scribe's own data for this project.

func (*App) Subscribe

func (a *App) Subscribe(s agent.Sink)

Subscribe adds an event listener (TUI, headless printer, Lectern bridge).

func (*App) Transcript

func (a *App) Transcript() []agent.Event

Transcript returns the recorded events of this session.

type Options

type Options struct {
	Workdir   string
	Model     string // provider/model override
	Mode      string
	Resume    string // session id prefix to resume ("" = new session)
	NoRepoMap bool
	System    string // extra system prompt text
	Version   string
	// Host answers approvals and questions. Nil means headless rules:
	// deny risky actions unless mode is auto, first option for questions.
	Host tools.Host
	// Ephemeral sessions are not saved (headless without --save-session).
	Ephemeral bool
	MaxSteps  int
	// Preset names a preset (config.LoadWithPreset) merged over the config.
	Preset string
	// TabID is the TUI tab that owns this session. The lead agent's model log
	// records it on every call, so the log shows which tab made each call.
	TabID string
}

Options configures Open.

type TUIHost

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

TUIHost answers approvals and questions through the TUI. Create it before Open, pass it as Options.Host, then give it to NewBackend. Each tab has its own TUIHost, so each tab has its own session-level allow list.

func NewTUIHost

func NewTUIHost() *TUIHost

NewTUIHost returns a host with no backend attached yet.

func (*TUIHost) Approve

func (h *TUIHost) Approve(ctx context.Context, ap tools.Approval) tools.Decision

Approve asks the TUI. A grant of AllowSession is remembered for the rest of the session for the same kind of action and tool. A cancelled context denies.

func (*TUIHost) Ask

func (h *TUIHost) Ask(ctx context.Context, q tools.Question) (string, error)

Ask puts a question to the user and returns their answer.

func (*TUIHost) Progress

func (h *TUIHost) Progress(callID, text string)

Progress streams partial tool output to the event feed.

Directories

Path Synopsis
Command smoke runs one headless turn against a real model (dev only).
Command smoke runs one headless turn against a real model (dev only).

Jump to

Keyboard shortcuts

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