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 ¶
- func DefaultModel(reg *registry.Registry) string
- func FindRoot(dir string) string
- func NewBackend(a *App, h *TUIHost) tui.Backend
- func OnOpen(fn func(*App))
- type App
- func (a *App) AddSessionForbidden(pat string) bool
- func (a *App) Claims() []tui.ClaimRow
- func (a *App) CleanStorage(keys []string) (int64, error)
- func (a *App) Close() error
- func (a *App) ContinueTurn(ctx context.Context) (agent.TurnStats, error)
- func (a *App) ForceClaim(path string) (string, error)
- func (a *App) HookEvents() []tui.HookEvent
- func (a *App) Host() tools.Host
- func (a *App) OnClose(f func())
- func (a *App) Opts() Options
- func (a *App) ReleaseAllClaims() int
- func (a *App) ReleaseClaim(path string) (bool, error)
- func (a *App) RemoveSessionForbidden(pat string) bool
- func (a *App) RenderMap(conversationTokens int, focus []string) string
- func (a *App) Run(ctx context.Context, prompt string, images []llm.Part) (agent.TurnStats, error)
- func (a *App) SessionForbidden() []string
- func (a *App) SessionID() string
- func (a *App) SetHookEventOff(event string, off bool) error
- func (a *App) SetHost(h tools.Host)
- func (a *App) SetModel(ref string) error
- func (a *App) SetTabID(id string)
- func (a *App) StorageReport() []tui.StorageItem
- func (a *App) Subscribe(s agent.Sink)
- func (a *App) Transcript() []agent.Event
- type Options
- type TUIHost
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultModel ¶
DefaultModel picks a model when config and flags name none: the first provider with a key, else a local Ollama.
func NewBackend ¶
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.
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 (*App) AddSessionForbidden ¶
AddSessionForbidden forbids a pattern until Scribe exits.
func (*App) CleanStorage ¶
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) ContinueTurn ¶
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 ¶
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 ¶
HookEvents lists the hook events this session runs, with their switch state.
func (*App) ReleaseAllClaims ¶
ReleaseAllClaims drops every claim this tab holds and reports how many.
func (*App) ReleaseClaim ¶
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 ¶
RemoveSessionForbidden lifts a session-only pattern.
func (*App) RenderMap ¶
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) SessionForbidden ¶
SessionForbidden lists the forbidden patterns added for this session.
func (*App) SetHookEventOff ¶
SetHookEventOff switches one event's hooks off or on for this session only.
func (*App) SetHost ¶
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) SetTabID ¶
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) Transcript ¶
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 ¶
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.
Source Files
¶
- app.go
- autocheck.go
- backend.go
- backend_chatbudget_w25.go
- backend_cmds10.go
- backend_cmds9.go
- backend_codex_w39.go
- backend_config.go
- backend_context.go
- backend_data7.go
- backend_data8.go
- backend_diagnose_checks.go
- backend_diagnose_set12.go
- backend_export.go
- backend_git.go
- backend_health_intel.go
- backend_health_w25hc.go
- backend_lsp.go
- backend_map9.go
- backend_mcp.go
- backend_memory_cleanup.go
- backend_menus.go
- backend_optional.go
- backend_origin_w41.go
- backend_panels.go
- backend_proxy_w38.go
- backend_remote12.go
- backend_settings7.go
- backend_shutdown_w29.go
- backend_skills.go
- backend_tabclose.go
- budget.go
- claims.go
- continue.go
- diskfree_unix.go
- errsink8.go
- export_api.go
- features_w40.go
- mapfresh10.go
- memory_extract.go
- memory_w40.go
- open_hooks.go
- postedit.go
- postedit_clones.go
- postedit_crossfile.go
- postedit_fix.go
- reasoning.go
- reindex10.go
- requestdump.go
- skills_latch.go
- subagent.go
- summarize.go
- update_notes.go
- wire.go