Documentation
¶
Overview ¶
Package engine is Blitz without a user interface: it opens a workspace (registries, tools, sessions, the model and the engine) and exposes what a front end needs as an api.Backend. The service and the CLI's --local mode run it; none of it prints (spec_workspace_018).
Index ¶
- Constants
- Variables
- func AddedNote(blocks []api.ContextBlock) string
- func AttachmentNote(imgs []*images.Image) string
- func DisplayPrompt(text string) string
- func ExportSession(cfg *config.Config, id string) (string, error)
- func FileVersion(data []byte) string
- func ForgetProjectTrust(cfg *config.Config) error
- func ModelErrorSummary(err error, cfg *config.Config) string
- func PreviewType(p string) string
- func ReviewProject(cfg *config.Config) (api.ProjectSettings, error)
- func SecretRedactor(cfg *config.Config) *redact.Redactor
- func SetupLocale(cfg *config.Config, warn func(string)) *i18n.Bundle
- func SetupNetwork(cfg *config.Config) error
- func StartObservability(ctx context.Context, cfg *config.Config, version string, warn func(string)) func()
- func StylesDir() string
- func TrustProject(cfg *config.Config, hash string, trusted bool) error
- type Branch
- type CodeBlock
- type CommitDraft
- type CommitFile
- type CompletionList
- type ConflictChoice
- type Diagram
- type DiffAgainst
- type DirListing
- type DocumentDiagnostics
- type DocumentInfo
- type FileChangedError
- type FileContent
- type FileEntry
- type FileKind
- type GitAction
- type IgnoredElsewhereError
- type LanguageServerStatus
- type LanguageState
- type MergeResult
- type Options
- type PullOutcome
- type PullResult
- type RepoConfigError
- type RestoredFile
- type Revision
- type RunOptions
- type ServerNotInstalledError
- type SourceLocation
- type TableColumn
- type TablePage
- type TableQuery
- type TextEdit
- type TextPosition
- type WorkerRewrite
- type Workspace
- func (w *Workspace) AbortMerge(ctx context.Context) (api.GitStatus, error)
- func (w *Workspace) AcceptedMedia() []runtime.Accept
- func (w *Workspace) ActiveAgent() api.AgentInfo
- func (w *Workspace) ActiveAgentTools() api.AgentTools
- func (w *Workspace) ActiveSession() (api.SessionInfo, bool)
- func (w *Workspace) AddImage(name string, data []byte) (*images.Image, error)
- func (w *Workspace) AddMemory(ctx context.Context, text string) (string, error)
- func (w *Workspace) AddPermissionRule(effect, rule string, save api.Scope) (api.PermissionChange, error)
- func (w *Workspace) Agents() *agents.Registry
- func (w *Workspace) AllModelSettings() map[string]config.ModelSettings
- func (w *Workspace) AllTools() []api.ToolInfo
- func (w *Workspace) AnswerTaskRequest(id string, decision api.Decision, answer string) error
- func (w *Workspace) Audit() *audit.Logger
- func (w *Workspace) AuditShell(command string, exitCode int, startErr error)
- func (w *Workspace) AvailableLocales() (list []api.LocaleInfo, customDir string)
- func (w *Workspace) Branches(ctx context.Context) ([]Branch, error)
- func (w *Workspace) Busy() bool
- func (w *Workspace) ChangeDocument(ctx context.Context, id string, version int64, text string) error
- func (w *Workspace) ClearApprovals() (int, error)
- func (w *Workspace) ClearGoal() error
- func (w *Workspace) Close() error
- func (w *Workspace) CloseDocument(id string) error
- func (w *Workspace) Commit(ctx context.Context, message string) (hash, subject string, err error)
- func (w *Workspace) Compact(ctx context.Context, focus string) (api.CompactResult, error)
- func (w *Workspace) Complete(ctx context.Context, id string, version int64, line, col int, trigger string) (lsp.CompletionList, error)
- func (w *Workspace) CompleteMerge(ctx context.Context) (api.GitStatus, error)
- func (w *Workspace) Config() *config.Config
- func (w *Workspace) Context(parts bool) (api.ContextInfo, error)
- func (w *Workspace) CreateBranch(ctx context.Context, name string) (api.GitStatus, error)
- func (w *Workspace) CreateFolder(p string) error
- func (w *Workspace) CreateWorker(spec api.WorkerSpec) (api.WorkerInfo, []string, error)
- func (w *Workspace) DeleteFile(ctx context.Context, p string) error
- func (w *Workspace) DeleteSession(ctx context.Context, id string) error
- func (w *Workspace) DeleteWorker(name string) error
- func (w *Workspace) Dir() string
- func (w *Workspace) DisableWorker(name string) (api.WorkerInfo, error)
- func (w *Workspace) DocumentDefinition(ctx context.Context, id string, version int64, line, col int) ([]SourceLocation, error)
- func (w *Workspace) DocumentHover(ctx context.Context, id string, version int64, line, col int) (string, error)
- func (w *Workspace) DocumentReferences(ctx context.Context, id string, version int64, line, col int) ([]SourceLocation, error)
- func (w *Workspace) DraftCommit(ctx context.Context, stageAll bool) (CommitDraft, error)
- func (w *Workspace) EnableWorker(name, hash string) (api.WorkerInfo, error)
- func (w *Workspace) Engine() *runtime.Engine
- func (w *Workspace) ExportSession(id string) (string, error)
- func (w *Workspace) Fetch(ctx context.Context) (api.GitStatus, error)
- func (w *Workspace) FindFiles(ctx context.Context, query string, limit int) ([]string, error)
- func (w *Workspace) FindPaths(ctx context.Context, query string, limit int, folders bool) ([]string, error)
- func (w *Workspace) ForgetNote(name string) error
- func (w *Workspace) ForgetProjectTrust() error
- func (w *Workspace) ForkSession(ctx context.Context, turn int) (api.SessionInfo, error)
- func (w *Workspace) GetWorkerSpec(name string) (api.WorkerSpec, string, error)
- func (w *Workspace) GitDiff(ctx context.Context, color bool) (string, error)
- func (w *Workspace) GitFileAction(ctx context.Context, p string, action GitAction) error
- func (w *Workspace) GitInit(ctx context.Context) (api.GitStatus, error)
- func (w *Workspace) GitStatus(ctx context.Context) (api.GitStatus, error)
- func (w *Workspace) Goal() (api.Goal, error)
- func (w *Workspace) HarnessMissing() bool
- func (w *Workspace) HarnessStale() bool
- func (w *Workspace) History(ctx context.Context, p string, limit, skip int) (revs []Revision, more bool, err error)
- func (w *Workspace) ImagesEnabled() bool
- func (w *Workspace) KeepDocuments(client string) []string
- func (w *Workspace) KillProcess(sessions []string, id int) (api.ProcessInfo, error)
- func (w *Workspace) LanguageStatus() []lsp.ServerStatus
- func (w *Workspace) LanguageTrusted() bool
- func (w *Workspace) ListAgents() []api.AgentInfo
- func (w *Workspace) ListApprovals() []api.Approval
- func (w *Workspace) ListCheckpoints() []api.Checkpoint
- func (w *Workspace) ListCommands() []api.CommandInfo
- func (w *Workspace) ListDir(ctx context.Context, p string, showHidden bool) (DirListing, error)
- func (w *Workspace) ListEnvs() ([]api.Env, error)
- func (w *Workspace) ListHooks() []api.HookInfo
- func (w *Workspace) ListMCPServers() []api.MCPServer
- func (w *Workspace) ListNotes() ([]api.Note, error)
- func (w *Workspace) ListPermissionRules() []api.PermissionRule
- func (w *Workspace) ListProcesses(sessions []string) []api.ProcessInfo
- func (w *Workspace) ListSessions(all bool) ([]api.SessionInfo, error)
- func (w *Workspace) ListSkills() []api.SkillInfo
- func (w *Workspace) ListStyles() []api.StyleInfo
- func (w *Workspace) ListTasks() []api.TaskInfo
- func (w *Workspace) ListTasksIn(sessions []string) []api.TaskInfo
- func (w *Workspace) ListWorkers() ([]api.WorkerInfo, error)
- func (w *Workspace) LoadAttachments(paths []string, prompt string, warn func(string)) ([]*images.Image, error)
- func (w *Workspace) LoadImage(path string) (*images.Image, error)
- func (w *Workspace) LoadSession(ref string) (s api.SessionInfo, branched bool, err error)
- func (w *Workspace) Locales() *i18n.Bundle
- func (w *Workspace) MemoryFiles() []string
- func (w *Workspace) MergeBranch(ctx context.Context, name string) (MergeResult, error)
- func (w *Workspace) Model() api.ModelInfo
- func (w *Workspace) ModelErr() error
- func (w *Workspace) ModelSettings(ref string) (api.ModelSettingsInfo, error)
- func (w *Workspace) MoveSession(id string) (api.SessionInfo, error)
- func (w *Workspace) NewSession() (api.SessionInfo, error)
- func (w *Workspace) OnSettingsChanged(f func()) (stop func())
- func (w *Workspace) OpenDocument(client, p, text string, version int64, block *CodeBlock) (lsp.DocumentInfo, error)
- func (w *Workspace) OpenSession(resume string, cont bool) (api.SessionInfo, bool, error)
- func (w *Workspace) PendingTaskRequests() []api.TaskRequest
- func (w *Workspace) PendingTaskRequestsIn(sessions []string) []api.TaskRequest
- func (w *Workspace) PermissionsProblem() error
- func (w *Workspace) PinModel(ctx context.Context, agent, ref string) (api.PinResult, error)
- func (w *Workspace) ProcessOutput(sessions []string, id int) (string, api.ProcessInfo, error)
- func (w *Workspace) Processes() api.Processes
- func (w *Workspace) ProjectAgentsDir() string
- func (w *Workspace) ProjectSettings() api.ProjectSettings
- func (w *Workspace) PruneEnvs() (api.PruneResult, error)
- func (w *Workspace) Pull(ctx context.Context) (PullResult, error)
- func (w *Workspace) Push(ctx context.Context) (string, api.GitStatus, error)
- func (w *Workspace) ReadFile(p string) (FileContent, error)
- func (w *Workspace) ReadPreview(p string) (string, []byte, error)
- func (w *Workspace) ReadTable(ctx context.Context, q TableQuery) (TablePage, error)
- func (w *Workspace) RefreshAgents(ctx context.Context)
- func (w *Workspace) Reindex() error
- func (w *Workspace) Reload(ctx context.Context) (api.ReloadResult, error)
- func (w *Workspace) ReloadMemory(ctx context.Context) ([]string, error)
- func (w *Workspace) ReloadPermissions(cfg *config.Config) error
- func (w *Workspace) ReloadProviders(ctx context.Context, cfg *config.Config) error
- func (w *Workspace) ReloadSearch(cfg *config.Config)
- func (w *Workspace) RemoveEnv(key string) error
- func (w *Workspace) RemovePermissionRule(rule string, save api.Scope) (api.PermissionChange, error)
- func (w *Workspace) RenameFile(ctx context.Context, from, to string) error
- func (w *Workspace) RenameSession(title string) (api.SessionInfo, error)
- func (w *Workspace) RenderDocx(docPath, md string, diagrams map[string]Diagram) ([]byte, error)
- func (w *Workspace) ResolveConflict(ctx context.Context, p string, choice ConflictChoice) (api.GitStatus, error)
- func (w *Workspace) RestartLanguageServer(language string) error
- func (w *Workspace) Restore(ctx context.Context, p, rev, version string, preview bool) (string, []RestoredFile, error)
- func (w *Workspace) RestoreFileRevision(ctx context.Context, p, rev, version string) (string, error)
- func (w *Workspace) RestoreFolder(ctx context.Context, p, rev string, preview bool) ([]RestoredFile, error)
- func (w *Workspace) RetryModel(ctx context.Context) error
- func (w *Workspace) RevisionDiff(ctx context.Context, p, rev, other string, against DiffAgainst) (diff string, truncated bool, err error)
- func (w *Workspace) RevokeApprovals(keys ...string) (int, error)
- func (w *Workspace) Rewind(ctx context.Context, index int, mode api.RewindMode, force bool) (api.RewindResult, error)
- func (w *Workspace) RewindPoints() ([]api.RewindPoint, error)
- func (w *Workspace) RewriteWorker(ctx context.Context, spec api.WorkerSpec) (WorkerRewrite, error)
- func (w *Workspace) Run(ctx context.Context, sessionID string, t api.Turn, on func(api.Event)) (api.TurnResult, error)
- func (w *Workspace) RunDetached(ctx context.Context, t api.Turn, started func(sessionID string), ...) (api.TurnResult, error)
- func (w *Workspace) RunWorker(ctx context.Context, name string, o RunOptions) (api.Run, error)
- func (w *Workspace) SandboxSummary() []string
- func (w *Workspace) SaveSnapshot(name string, force bool) (api.SessionInfo, error)
- func (w *Workspace) Search(ctx context.Context, q api.SearchQuery) (api.SearchResult, error)
- func (w *Workspace) SearchProvider() (string, error)
- func (w *Workspace) SearchSession(terms string) (found int, prompt string)
- func (w *Workspace) SearchSkills(query string) []api.SkillInfo
- func (w *Workspace) SearchStatus() api.SearchStatus
- func (w *Workspace) SearchWeb(ctx context.Context, terms string) (api.WebSearch, error)
- func (w *Workspace) SessionDiff() string
- func (w *Workspace) SessionUsage() (api.Usage, error)
- func (w *Workspace) Set(ctx context.Context, key, value string) (string, error)
- func (w *Workspace) SetAgent(ctx context.Context, name string) (api.AgentInfo, error)
- func (w *Workspace) SetGoal(condition string) (api.Goal, error)
- func (w *Workspace) SetLocale(ctx context.Context, input string) (api.LocaleChange, error)
- func (w *Workspace) SetModel(ctx context.Context, ref string) (activePin string, err error)
- func (w *Workspace) SetPermissionMode(mode string) (string, error)
- func (w *Workspace) SetUI(approve api.Approver, ask api.UserPromptFunc)
- func (w *Workspace) Settings() api.Settings
- func (w *Workspace) SettingsChanges(ctx context.Context) <-chan struct{}
- func (w *Workspace) Skill(name string) (api.SkillInfo, bool)
- func (w *Workspace) Skills() *skills.Provider
- func (w *Workspace) StatFiles(paths []string) map[string]string
- func (w *Workspace) Steer(ctx context.Context, sessionID, text string) error
- func (w *Workspace) StopTask(id string) (api.TaskInfo, error)
- func (w *Workspace) StopTaskIn(sessions []string, id string) (api.TaskInfo, error)
- func (w *Workspace) Storage() *session.Storage
- func (w *Workspace) Suggestions(ctx context.Context) api.Suggestions
- func (w *Workspace) SwitchBranch(ctx context.Context, name string) (api.GitStatus, error)
- func (w *Workspace) TakeProcessNotices(session string) []string
- func (w *Workspace) Task(id string) (api.TaskInfo, []string, error)
- func (w *Workspace) TaskIn(sessions []string, id string) (api.TaskInfo, []string, error)
- func (w *Workspace) Tools() *tools.Registry
- func (w *Workspace) TrustProject(hash string, trusted bool) error
- func (w *Workspace) Undo(force bool) (api.UndoResult, error)
- func (w *Workspace) UndoWorkerRun(runID string, force bool) (api.UndoResult, error)
- func (w *Workspace) Unpin(ctx context.Context, agent string) (api.PinResult, error)
- func (w *Workspace) UpdateModelSettings(ref string, reset bool, changes []api.Setting) (api.ModelSettingsChange, error)
- func (w *Workspace) UpdateWorker(spec api.WorkerSpec, hash string) (api.WorkerInfo, []string, error)
- func (w *Workspace) UsageOf(sessionID string) api.Usage
- func (w *Workspace) WatchDiagnostics(ctx context.Context, client string, send func(lsp.DocumentDiagnostics) error) error
- func (w *Workspace) WatchTasks(ctx context.Context, sessions []string) <-chan api.SessionEvent
- func (w *Workspace) WorkerRuns(name string, limit int) ([]api.Run, error)
- func (w *Workspace) WriteBinaryFile(ctx context.Context, p string, data []byte, version string) (string, error)
- func (w *Workspace) WriteFile(ctx context.Context, p, text, version string) (string, error)
Constants ¶
const ( LanguageReady = lsp.StateReady LanguageStarting = lsp.StateStarting LanguageMissing = lsp.StateMissing LanguageFailed = lsp.StateFailed LanguageIdle = lsp.StateIdle LanguageNone = lsp.StateNone LanguageUntrusted = lsp.StateUntrusted )
The states of a language server.
const DefaultStyle = "default"
DefaultStyle adds nothing.
Variables ¶
var ( // ErrNoBranch is a branch that doesn't exist, locally or on a remote. ErrNoBranch = errors.New("there's no such branch") // ErrBranchExists is creating a branch whose name is taken. ErrBranchExists = errors.New("a branch with that name already exists") // ErrBadBranchName is a name git doesn't accept for a branch. ErrBadBranchName = errors.New("that isn't a valid branch name") // ErrLocalChanges is a switch that would overwrite uncommitted changes. ErrLocalChanges = errors.New("uncommitted changes would be overwritten: commit or stash them first") // ErrMergeSelf is merging the current branch into itself. ErrMergeSelf = errors.New("that's the current branch") )
var ( // ErrNoRemote is a push from a repository with no remote. ErrNoRemote = errors.New("the repository has no remote") // ErrNoUpstream is a pull on a branch that doesn't track a remote one. ErrNoUpstream = errors.New("the branch doesn't track a remote branch") // ErrPushRejected is a push the remote refused because it has commits // the branch doesn't: pull first. ErrPushRejected = errors.New("the remote has commits this branch doesn't have: pull them first") // ErrRemoteAuth is a fetch, pull or push the remote refused for want of // credentials. ErrRemoteAuth = errors.New("the remote wants credentials Blitz doesn't have: sign in with git in a terminal (or set up a credential helper or an SSH key), then try again") // ErrInProgress is a pull or push while a merge or rebase waits. ErrInProgress = errors.New("a merge or rebase is in progress: complete or abort it first") // ErrNoOperation is completing or aborting with no merge or rebase in // progress. ErrNoOperation = errors.New("no merge or rebase is in progress") // ErrConflictsRemain is completing a merge or rebase with files still in // conflict. ErrConflictsRemain = errors.New("some files are still in conflict") // ErrMarkersRemain is marking a file resolved that still has conflict // markers. ErrMarkersRemain = errors.New("the file still has conflict markers") // ErrNotConflicted is resolving a file that isn't in conflict. ErrNotConflicted = errors.New("the file isn't in conflict") )
var ( // ErrUnknownDocument means no open document has the ID. ErrUnknownDocument = lsp.ErrUnknownDocument // ErrStaleDocument means a request was about another version of the // document than the server has. ErrStaleDocument = lsp.ErrStale // ErrNoLanguageServer means no server is configured for a language. ErrNoLanguageServer = lsp.ErrNoServer )
Errors of the editor's language requests.
var ErrBadPath = errors.New("not a path in the workspace")
ErrBadPath means the path is outside the workspace, or in .git.
var ErrBadRevision = errors.New("not a revision in the history")
ErrBadRevision is a revision that isn't a commit hash of the history's.
var ErrBadTableFilter = table.ErrBadFilter
ErrBadTableFilter is returned for a column filter that can't be read.
var ErrEmptyMessage = errors.New("a commit needs a message")
ErrEmptyMessage is Commit's error without a message.
var ErrNoGit = errors.New("git isn't installed: it isn't on the Blitz service's PATH")
ErrNoGit is GitInit's error without git on PATH.
var ErrNoInstructions = errors.New("write what the worker should do first")
ErrNoInstructions is a rewrite of a worker with no instructions yet.
var ErrNoPreview = errors.New("no preview")
ErrNoPreview means the file has no preview: ReadPreview shows only images, PDFs and sound, up to 32 MB.
var ErrNotARepository = errors.New("the workspace isn't in a git repository")
ErrNotARepository is a git action outside a git repository.
var ErrNotTable = errors.New("not a table (CSV or TSV)")
ErrNotTable is returned for a file the table viewer doesn't read.
var ErrNothingStaged = errors.New("nothing is staged to commit")
ErrNothingStaged is Commit's error when the index matches HEAD.
var ErrUntrusted = errors.New("the project's settings aren't trusted: language servers run its code, so they start once you trust it")
ErrUntrusted means the workspace's project settings aren't trusted, so no language server starts for the editor (VE-43).
Functions ¶
func AddedNote ¶ added in v0.7.0
func AddedNote(blocks []api.ContextBlock) string
AddedNote is what the transcript records of the content added to a prompt, after its text (as AttachmentNote is for images): each block's title, or its URL.
func AttachmentNote ¶
AttachmentNote is what the transcript records for images sent with a prompt: their names.
func DisplayPrompt ¶
DisplayPrompt is a prompt as the user wrote it: without the note about their edits (withUserEdits), which is for the agent.
func ExportSession ¶
ExportSession is a stored session as Markdown (spec_parity_027 PAR-SES-11): its prompts, answers and tool calls (arguments and results in brief) with their times, from the event log (else the transcript), with configured secrets masked. It reads the files only, so the session's workspace needn't be open.
func FileVersion ¶
FileVersion is the version of content: its SHA-256.
func ForgetProjectTrust ¶
ForgetProjectTrust removes the decision for cfg's workspace, so it's asked again.
func ModelErrorSummary ¶
ModelErrorSummary makes a model error safe and readable: some SDK errors embed their whole client config, including the API key, and most need only their first line. A quota error is kept whole, on one line: Google's message names the quota to raise.
func PreviewType ¶
PreviewType is the media type the preview shows p as ("" when it has none).
func ReviewProject ¶
func ReviewProject(cfg *config.Config) (api.ProjectSettings, error)
ReviewProject is what the project files of cfg's workspace (cfg.Tools.WorkspaceDir, loaded with config.LoadWorkspace) say, and the trust decision for them, without opening the workspace: the CLI asks before it opens one.
func SecretRedactor ¶
SecretRedactor masks configured credentials and the values of scrubbed environment variables in audit entries, logs and telemetry.
func SetupLocale ¶
SetupLocale loads translation catalogs (built in, then ui.locales_dir) and activates ui.locale for the process.
func SetupNetwork ¶
SetupNetwork trusts [network] ca_file's certificate authorities besides the system's, in every client built from Go's default transport (the model SDKs, MCP, web search) and in web_fetch (spec_parity_027 PAR-MOD-05). Proxies come from the environment already.
Types ¶
type Branch ¶ added in v0.6.5
type Branch struct {
// Name is the branch's short name: "main", or "origin/feature" for a
// remote one.
Name string
// Remote is a remote's branch that no local branch tracks: switching to
// it makes a local one that does.
Remote bool
// Current is the branch checked out.
Current bool
// Upstream is a local branch's remote one, such as "origin/main".
Upstream string
// Subject and Time are its last commit's.
Subject string
Time time.Time
}
Branch is a branch the workspace can switch to or merge.
type CodeBlock ¶ added in v0.5.0
CodeBlock is a code block opened as a document (spec_visual_editor_037 §7): its language as a file extension, and the client's ID for it.
type CommitDraft ¶ added in v0.3.1
type CommitDraft struct {
Files []CommitFile
Message string
Problem string
}
CommitDraft is what the commit dialog shows: the staged files and a message the model drafted from their diff ("" with Problem saying why when it couldn't).
type CommitFile ¶ added in v0.3.1
CommitFile is one staged file: its git status letter (A, M, D, R, …) and workspace-relative path.
type CompletionList ¶ added in v0.5.0
type CompletionList = lsp.CompletionList
CompletionList is what Complete returns.
type ConflictChoice ¶ added in v0.6.4
type ConflictChoice string
ConflictChoice is how ResolveConflict settles a file.
const ( // KeepMine keeps the branch's version (the one from before the pull). KeepMine ConflictChoice = "mine" // TakeTheirs takes the remote's version. TakeTheirs ConflictChoice = "theirs" // MarkResolved stages the file as edited by hand. MarkResolved ConflictChoice = "resolved" )
type Diagram ¶ added in v0.6.0
Diagram is a ```mermaid block drawn as a PNG by the caller, at Width pixels.
type DiffAgainst ¶ added in v0.6.0
type DiffAgainst int
DiffAgainst is what a revision is compared with.
const ( // AgainstNow compares the revision with the working copy. AgainstNow DiffAgainst = iota // AgainstParent shows what the revision changed. AgainstParent // AgainstOther compares the revision with another one. AgainstOther )
type DirListing ¶
type DirListing struct {
Entries []FileEntry
Truncated bool
// Repo means the workspace is in a git repository.
Repo bool
}
DirListing is a folder's entries.
type DocumentDiagnostics ¶ added in v0.5.0
type DocumentDiagnostics = lsp.DocumentDiagnostics
DocumentDiagnostics are a document's diagnostics for a version.
type DocumentInfo ¶ added in v0.5.0
type DocumentInfo = lsp.DocumentInfo
DocumentInfo is what opening an editor document says.
type FileChangedError ¶
type FileChangedError struct {
Path string
// Current is the file's version now ("" when it doesn't exist).
Current string
}
FileChangedError reports that a write's version doesn't match the file's (it was changed since it was read, or it exists when it was expected not to).
func (*FileChangedError) Error ¶
func (e *FileChangedError) Error() string
Error says the file changed, or was deleted, since it was opened.
type FileContent ¶
type FileContent struct {
Path string
Text string
Version string
Size int64
Binary bool
TooLarge bool
AgentRule string
}
FileContent is a file as the editor opens it.
type FileEntry ¶
type FileEntry struct {
Name string
Path string
Kind FileKind
Size int64
Modified time.Time
// Git is the entry's git status ("modified", "added", "renamed",
// "untracked", "conflicted"; "changed" for a folder with changes
// under it), "" when clean or outside a repository.
Git string
// Staged says how much of a file's change is in git's index: "all"
// (staged), "some" (staged, then changed again), or "" (none, or a
// folder).
Staged string
// Hidden says why the entry is hidden by default: "blocked" (the
// agent's blocked paths), "ignored" (git), "dot", "agent" (an agent
// instruction file such as AGENTS.md, memory.files), or "".
Hidden string
// Ignored says git ignores it, whatever Hidden says (a dotfile git
// ignores is hidden as "dot").
Ignored bool
// AgentRule is the agent's rule for the path: "blocked", "read_only"
// or "".
AgentRule string
}
FileEntry is one entry of a folder.
type GitAction ¶
type GitAction string
GitAction is what GitFileAction does to a file or folder.
const ( // GitStage adds it to the index (a folder: everything changed under it). GitStage GitAction = "stage" // GitUnstage takes it out of the index, keeping the working copy. GitUnstage GitAction = "unstage" // GitDiscard puts it back as it was in the last commit. GitDiscard GitAction = "discard" // GitIgnore adds a line for it to the workspace's .gitignore. GitIgnore GitAction = "ignore" // GitUnignore takes the line GitIgnore added out of .gitignore. GitUnignore GitAction = "unignore" )
type IgnoredElsewhereError ¶ added in v0.6.0
type IgnoredElsewhereError struct {
Path string
Pattern string // as written, such as "*.log"
Source string // where, such as ".gitignore:12"
}
IgnoredElsewhereError is an unignore of a path that some other rule ignores (a pattern, another .gitignore): Blitz doesn't rewrite those.
func (*IgnoredElsewhereError) Error ¶ added in v0.6.0
func (e *IgnoredElsewhereError) Error() string
Error says which rule ignores the path, in the user's language.
type LanguageServerStatus ¶ added in v0.5.0
type LanguageServerStatus = lsp.ServerStatus
LanguageServerStatus is a language's server, for the status list.
type LanguageState ¶ added in v0.5.0
LanguageState is how a document's language server is.
type MergeResult ¶ added in v0.6.5
type MergeResult struct {
// Outcome is PullUpToDate, PullFastForward, PullMerged or PullConflicts
// (the merge waits for ResolveConflict and CompleteMerge, or AbortMerge).
Outcome PullOutcome
Commits int // commits brought in from the branch
Status api.GitStatus
}
MergeResult is what MergeBranch did, and the repository's state after it.
type Options ¶
type Options struct {
// Streaming asks the model for partial responses as they are generated.
Streaming bool
// AppendSystemPrompt is added to the agent's instructions for this run
// (--append-system-prompt).
AppendSystemPrompt string
// Warn receives problems that don't stop the workspace from opening.
Warn func(string)
// Model replaces the model built from the configuration (tests use a
// mock). Agents with their own model still get theirs.
Model model.LLM
// Workers records which workers are enabled; one store serves every
// workspace in a process (nil: ~/.blitz/workers.json).
Workers *workers.Store
// NewModel builds models by name for /model, pins and agents' own
// models (nil: runtime.NewModel).
NewModel func(ctx context.Context, cfg *config.Config, name string) (model.LLM, error)
// TrustProject loads the project settings that need trust for this
// run, without recording a decision (--trust-project).
TrustProject bool
}
Options configure Open.
type PullOutcome ¶ added in v0.6.4
type PullOutcome string
PullOutcome is how a pull went.
const ( // PullUpToDate brought nothing new. PullUpToDate PullOutcome = "up_to_date" // PullFastForward moved the branch to the remote's. PullFastForward PullOutcome = "fast_forward" // PullMerged made a merge commit. PullMerged PullOutcome = "merged" // PullRebased replayed the branch's commits on the remote's. PullRebased PullOutcome = "rebased" // PullConflicts stopped on conflicts: a merge or rebase is in progress. PullConflicts PullOutcome = "conflicts" )
type PullResult ¶ added in v0.6.4
type PullResult struct {
Outcome PullOutcome
Commits int // commits brought in from the remote
Status api.GitStatus
}
PullResult is what Pull did, and the repository's state after it.
type RepoConfigError ¶ added in v0.6.4
type RepoConfigError struct {
Key string // such as "core.sshcommand"
}
RepoConfigError is a remote action refused because the repository's own git config (which the agent can write) sets something that runs a command.
func (*RepoConfigError) Error ¶ added in v0.6.4
func (e *RepoConfigError) Error() string
Error says which setting, and what to do, in the user's language.
type RestoredFile ¶ added in v0.6.0
RestoredFile is a file a folder's restore puts back: changed since (restored), or deleted since (recreated).
type Revision ¶ added in v0.6.0
type Revision struct {
Commit string // the full hash
Short string // the abbreviated hash
Parents []string
Author string
Email string
When time.Time
Subject string
// Path is a file's path at that commit, from the repository's root (it
// differs from today's when the file was renamed since); "" for a
// folder's history.
Path string
// Added and Removed are the lines it changed in the file or folder,
// in Files files (binary files count as files, not lines).
Added, Removed, Files int
}
Revision is one commit in a history.
type RunOptions ¶
type RunOptions struct {
// Manual means the run started on request rather than by the schedule.
Manual bool
// OnStart receives the run's record as it starts (its ID and session).
OnStart func(api.Run)
// OnEvent receives the turn's events.
OnEvent func(api.Event)
}
RunWorker runs the named worker once, now, and records the run. The worker must be enabled at its current hash. The run has a session of its own (not the workspace's active one), gets exactly the worker's permissions after the host policy (anything else is refused and recorded), and stops at its limits. on receives the turn's events. A run of the same worker still going makes this ErrRunInProgress. RunOptions configure RunWorker.
type ServerNotInstalledError ¶ added in v0.5.0
type ServerNotInstalledError = lsp.NotInstalledError
ServerNotInstalledError is a server whose command isn't installed.
type SourceLocation ¶ added in v0.5.0
SourceLocation is a definition or reference, outside marking a file outside the workspace.
type TableColumn ¶ added in v0.3.0
TableColumn is a table's column: its name, what its first rows look like (kind, empty cells, a number column's range), and what a model said it holds (search.enrich), if it has.
type TablePage ¶ added in v0.3.0
type TablePage struct {
Columns []TableColumn
Rows []table.Row
Matched int
Total int
Sorted bool
Latin1 bool
}
TablePage is a page of a table: its columns, the rows asked for (each with its number, 1-based), how many matched and how many there are. Sorted is false when a sort was asked for but too many rows matched.
type TableQuery ¶ added in v0.3.0
type TableQuery struct {
Path string
Search string
Filters map[int]string
SortColumn int
Desc bool
Offset int
Limit int
}
TableQuery asks for a page of a table file's rows: those with Search in a cell and passing each column's filter, sorted by a column (SortColumn 1-based; 0: file order), from Offset, up to Limit (0: 100).
type TextPosition ¶ added in v0.5.0
TextPosition is a 1-based line and column, in characters.
type WorkerRewrite ¶ added in v0.6.4
type WorkerRewrite struct {
Prompt string
Permissions []string // "kind:pattern", each valid
Changes []string // what changed and why, a line each
Problem string
}
WorkerRewrite is a worker's instructions as the model rewrote them, the permissions they need, and what changed. A model that fails leaves it empty with Problem saying why: the user's own instructions stand.
type Workspace ¶
type Workspace struct {
// contains filtered or unexported fields
}
Workspace is a folder opened in Blitz: everything a session needs.
func Open ¶
Open wires registries, tools, the model and the engine for the workspace cfg.Tools.WorkspaceDir names. The workspace owns cfg from then on and changes it (the model, pins, settings), so each workspace needs its own copy. Open also activates cfg's interface language for the process.
func (*Workspace) AbortMerge ¶ added in v0.6.4
AbortMerge gives up the merge or rebase a pull started, putting the branch and the uncommitted changes back as they were.
func (*Workspace) AcceptedMedia ¶ added in v0.2.1
AcceptedMedia is what the active agent's model takes as attachments (spec_images_011), for the front ends to offer only those.
func (*Workspace) ActiveAgent ¶
ActiveAgent describes the agent that answers prompts.
func (*Workspace) ActiveAgentTools ¶
func (w *Workspace) ActiveAgentTools() api.AgentTools
ActiveAgentTools returns what the active agent can use: its built-in tools and the MCP servers offered to it.
func (*Workspace) ActiveSession ¶
func (w *Workspace) ActiveSession() (api.SessionInfo, bool)
ActiveSession returns the session prompts go to, with its messages.
func (*Workspace) AddImage ¶
AddImage stores image data (e.g. pasted from the clipboard) for a prompt.
func (*Workspace) AddMemory ¶
AddMemory appends text to the last project instruction file (BLITZ.md when none is configured), reloads memory, and returns the file's path.
func (*Workspace) AddPermissionRule ¶
func (w *Workspace) AddPermissionRule(effect, rule string, save api.Scope) (api.PermissionChange, error)
AddPermissionRule adds a rule for this session and, with a scope, to that settings file's [permissions]: global, or the workspace's own. It applies at once, except read rules, which need saving and apply from the next start.
func (*Workspace) AllModelSettings ¶
func (w *Workspace) AllModelSettings() map[string]config.ModelSettings
AllModelSettings returns every model's settings, by model name.
func (*Workspace) AnswerTaskRequest ¶
AnswerTaskRequest answers one: decision for an approval, answer for a question.
func (*Workspace) AuditShell ¶
AuditShell records a command the user ran directly.
func (*Workspace) AvailableLocales ¶
func (w *Workspace) AvailableLocales() (list []api.LocaleInfo, customDir string)
AvailableLocales returns the interface languages with a catalog, and the directory custom catalogs are read from ("" if none is configured).
func (*Workspace) Branches ¶ added in v0.6.5
Branches lists the local branches, then the remotes' branches no local branch tracks, each newest commit first.
func (*Workspace) ChangeDocument ¶ added in v0.5.0
func (w *Workspace) ChangeDocument(ctx context.Context, id string, version int64, text string) error
ChangeDocument replaces an editor document's text.
func (*Workspace) ClearApprovals ¶
ClearApprovals revokes every approval and returns how many there were, with RevokeApprovals' error.
func (*Workspace) Close ¶
Close kills background processes and MCP servers, flushes the audit log and releases the workspace.
func (*Workspace) CloseDocument ¶ added in v0.5.0
CloseDocument closes an editor document.
func (*Workspace) Commit ¶ added in v0.3.1
Commit commits what's staged with message (git commit -F -, the repository's hooks run) and returns the new commit's short hash and subject.
func (*Workspace) Compact ¶
Compact summarises the active session's older turns, keeping the latest, to shrink the model's context. focus steers what the summary keeps.
func (*Workspace) Complete ¶ added in v0.5.0
func (w *Workspace) Complete(ctx context.Context, id string, version int64, line, col int, trigger string) (lsp.CompletionList, error)
Complete is the completion at (line, col) of an editor document.
func (*Workspace) CompleteMerge ¶ added in v0.6.4
CompleteMerge finishes the merge or rebase a pull started once no file is in conflict: the merge commit with git's message, or the rebase's next commits (which may stop on conflicts of their own: the status says so).
func (*Workspace) Context ¶
func (w *Workspace) Context(parts bool) (api.ContextInfo, error)
Context returns the active session's context size and compaction setting, with its breakdown by category when parts is set (it reads the session's events).
func (*Workspace) CreateBranch ¶ added in v0.6.5
CreateBranch makes branch name at the current commit and switches to it, keeping uncommitted changes.
func (*Workspace) CreateFolder ¶
CreateFolder creates the folder p.
func (*Workspace) CreateWorker ¶
func (w *Workspace) CreateWorker(spec api.WorkerSpec) (api.WorkerInfo, []string, error)
CreateWorker writes a new worker, in the first of workers.paths (.agents/workers/<name>/WORKER.md by default), once the file it makes loads as a valid worker. Otherwise it writes nothing and returns why. A new worker is disabled until it's reviewed and enabled.
func (*Workspace) DeleteFile ¶
DeleteFile deletes p, a folder with everything in it.
func (*Workspace) DeleteSession ¶
DeleteSession deletes saved session id, which may be another workspace's: its transcript and history. The active session, or one a background run uses, is refused (api.ErrSessionOpen).
func (*Workspace) DeleteWorker ¶
DeleteWorker deletes a worker: its directory (WORKER.md and anything beside it) and whether it was enabled. Its past runs stay in the run log. The caller makes sure it isn't running.
func (*Workspace) DisableWorker ¶
func (w *Workspace) DisableWorker(name string) (api.WorkerInfo, error)
DisableWorker stops a worker from running.
func (*Workspace) DocumentDefinition ¶ added in v0.5.0
func (w *Workspace) DocumentDefinition(ctx context.Context, id string, version int64, line, col int) ([]SourceLocation, error)
DocumentDefinition is where the symbol at (line, col) is defined.
func (*Workspace) DocumentHover ¶ added in v0.5.0
func (w *Workspace) DocumentHover(ctx context.Context, id string, version int64, line, col int) (string, error)
DocumentHover is what the server says about the symbol at (line, col).
func (*Workspace) DocumentReferences ¶ added in v0.5.0
func (w *Workspace) DocumentReferences(ctx context.Context, id string, version int64, line, col int) ([]SourceLocation, error)
DocumentReferences are where the symbol at (line, col) is used.
func (*Workspace) DraftCommit ¶ added in v0.3.1
DraftCommit lists what's staged (all of the workspace's changes staged first with stageAll, as git add --all) and has the model draft a commit message from the diff, secrets redacted. With nothing staged it returns no files and asks nothing; a model that fails leaves the message empty, with Problem saying why, so the user can still write one.
func (*Workspace) EnableWorker ¶
func (w *Workspace) EnableWorker(name, hash string) (api.WorkerInfo, error)
EnableWorker lets a worker run on its schedule, pinned to hash: the one the caller reviewed, which must still be current (api.ErrHashMismatch otherwise). An invalid worker can't be enabled.
func (*Workspace) ExportSession ¶
ExportSession is session id (the active one when "") as Markdown.
func (*Workspace) Fetch ¶ added in v0.6.4
Fetch brings the remote's branches up to date (the upstream's remote, else every remote), for the ahead and behind counts.
func (*Workspace) FindFiles ¶
FindFiles returns up to limit files whose path matches query, best first. Hidden files are left out.
func (*Workspace) FindPaths ¶
func (w *Workspace) FindPaths(ctx context.Context, query string, limit int, folders bool) ([]string, error)
FindPaths is FindFiles, with folders also the folders the files are in ("src/cart/", with a trailing slash), matched the same way.
func (*Workspace) ForgetNote ¶
ForgetNote deletes the note name (or the only one whose name starts so); the agent's instructions lose it at the next reload or session.
func (*Workspace) ForgetProjectTrust ¶ added in v0.3.1
ForgetProjectTrust forgets the decision about the workspace's project settings: they wait for trust again.
func (*Workspace) ForkSession ¶
ForkSession starts a new session copied from the active one up to and including its prompt turn (1 the first; 0 or more than there are: all of it), in the transcript and the event log, and makes it active; the source is unchanged (spec_backlog_026 BL-SES-01, spec_parity_027 PAR-SES-10).
func (*Workspace) GetWorkerSpec ¶
GetWorkerSpec returns a worker's WORKER.md as written, for editing, and the hash UpdateWorker needs. The worker needn't be valid.
func (*Workspace) GitDiff ¶
GitDiff is every change in the workspace since the last commit (stat and patch): staged and not, and the files git doesn't track yet as new files (at most maxUntrackedDiffs of them). Before the first commit, it's everything staged and not. color keeps git's terminal colours. On failure the output holds git's message.
The agent can write the repository's .git/config, and git diff would run commands named there (fsmonitor, external diff, textconv and filter drivers) outside the sandbox. They are all switched off.
func (*Workspace) GitFileAction ¶
GitFileAction runs action on p, a workspace-relative file or folder.
func (*Workspace) GitInit ¶
GitInit makes the workspace a git repository (git init), unless it's in one already, and returns its git status.
func (*Workspace) GitStatus ¶
GitStatus reads the workspace's branch and changed files, its remote and upstream with the ahead and behind counts, and a merge or rebase in progress with its conflicts.
func (*Workspace) HarnessMissing ¶
HarnessMissing reports whether the workspace has no agent instructions: none of .agents/AGENTS.md, AGENTS.md, CLAUDE.md, GEMINI.md or BLITZ.md.
func (*Workspace) HarnessStale ¶ added in v0.5.3
HarnessStale reports whether the specification changed after the skills and agents: a spec in .agents/specs/ is newer than every file under .agents/skills/ and .agents/agents/, and there is at least one of those.
func (*Workspace) History ¶ added in v0.6.0
func (w *Workspace) History(ctx context.Context, p string, limit, skip int) (revs []Revision, more bool, err error)
History returns the commits that changed p (a file, following renames; a folder, anything under it; "" the workspace), newest first: limit of them (100 when 0, at most 500) after the first skip. more says older ones follow.
func (*Workspace) ImagesEnabled ¶
ImagesEnabled reports whether images can be attached.
func (*Workspace) KeepDocuments ¶ added in v0.5.0
KeepDocuments keeps client's documents open, returning those still open.
func (*Workspace) KillProcess ¶
KillProcess stops background process id and its descendants, when one of sessions started it (else api.ErrUnknownProcess).
func (*Workspace) LanguageStatus ¶ added in v0.5.0
func (w *Workspace) LanguageStatus() []lsp.ServerStatus
LanguageStatus lists the workspace's language servers.
func (*Workspace) LanguageTrusted ¶ added in v0.5.0
LanguageTrusted reports whether language servers may start for the editor: the project's settings are trusted, or none need trust.
func (*Workspace) ListAgents ¶
ListAgents returns every agent, in registry order.
func (*Workspace) ListApprovals ¶
ListApprovals returns this session's approvals, then saved ones.
func (*Workspace) ListCheckpoints ¶
func (w *Workspace) ListCheckpoints() []api.Checkpoint
ListCheckpoints returns the turns that changed files, newest first.
func (*Workspace) ListCommands ¶
func (w *Workspace) ListCommands() []api.CommandInfo
ListCommands returns the custom slash commands, by name. Files that don't parse are reported through the workspace's warnings.
func (*Workspace) ListDir ¶
ListDir lists the folder p (the workspace for ""), folders first. Hidden entries are left out unless showHidden.
func (*Workspace) ListHooks ¶
ListHooks are the configured hooks, with their sources and recent failures (spec_parity_027 PAR-HK-13).
func (*Workspace) ListMCPServers ¶
ListMCPServers returns the configured MCP servers, the disabled ones marked.
func (*Workspace) ListNotes ¶
ListNotes are the notes the agent saved in this workspace with its remember tool, newest first (spec_parity_027 PAR-MEM-11).
func (*Workspace) ListPermissionRules ¶
func (w *Workspace) ListPermissionRules() []api.PermissionRule
ListPermissionRules returns the rules in force: deny, then ask, then allow. A rule from the settings is labelled with the file it's in: global, or the workspace's.
func (*Workspace) ListProcesses ¶
func (w *Workspace) ListProcesses(sessions []string) []api.ProcessInfo
ListProcesses are the background processes started in any of sessions' turns, ordered by ID: a client's, which it accounts for when it exits.
func (*Workspace) ListSessions ¶
func (w *Workspace) ListSessions(all bool) ([]api.SessionInfo, error)
ListSessions returns this workspace's sessions, or with all every saved session, newest first. Messages are left out.
func (*Workspace) ListSkills ¶
ListSkills returns every skill found.
func (*Workspace) ListStyles ¶
ListStyles are the output styles, by name, with which is in use.
func (*Workspace) ListTasksIn ¶
ListTasksIn are the tasks sessions started, oldest first.
func (*Workspace) ListWorkers ¶
func (w *Workspace) ListWorkers() ([]api.WorkerInfo, error)
ListWorkers returns the workspace's workers, by name.
func (*Workspace) LoadAttachments ¶
func (w *Workspace) LoadAttachments(paths []string, prompt string, warn func(string)) ([]*images.Image, error)
LoadAttachments loads image and PDF files (failures are errors naming the path) and @image or @paper.pdf mentions in prompt (failures are warnings: the prompt may be piped text that merely contains an @path) through the workspace sandbox. Identical files are attached once.
func (*Workspace) LoadSession ¶
LoadSession makes the session ref names active: an ID, or the name of a snapshot, which starts a new session copied from it (branched). A session from another workspace can be loaded by ID.
func (*Workspace) MemoryFiles ¶
MemoryFiles are the project instruction file names looked for, in order.
func (*Workspace) MergeBranch ¶ added in v0.6.5
MergeBranch merges branch name (local or a remote's) into the current one: a fast-forward when it can, else a merge commit with git's message, keeping uncommitted changes (--autostash). A merge that stops on conflicts isn't an error: its outcome is PullConflicts, and it waits for ResolveConflict and CompleteMerge (or AbortMerge).
func (*Workspace) ModelErr ¶
ModelErr is why the configured model failed to initialise (nil if it didn't). The workspace then runs on a placeholder model.
func (*Workspace) ModelSettings ¶
func (w *Workspace) ModelSettings(ref string) (api.ModelSettingsInfo, error)
ModelSettings returns ref's settings ("provider/" optional).
func (*Workspace) MoveSession ¶
func (w *Workspace) MoveSession(id string) (api.SessionInfo, error)
MoveSession carries session id here from the workspace it was in and makes it active (/cd, PAR-SES-40): --continue here finds it, rewind stops at the move, and the agent's next prompt says the workspace changed.
func (*Workspace) NewSession ¶
func (w *Workspace) NewSession() (api.SessionInfo, error)
NewSession starts a new session for the active agent and makes it active. It is named after its first prompt.
func (*Workspace) OnSettingsChanged ¶
func (w *Workspace) OnSettingsChanged(f func()) (stop func())
OnSettingsChanged calls f after the rules or approvals changed on disk and were applied, until the returned function is called.
func (*Workspace) OpenDocument ¶ added in v0.5.0
func (w *Workspace) OpenDocument(client, p, text string, version int64, block *CodeBlock) (lsp.DocumentInfo, error)
OpenDocument opens the workspace file p (relative) for client's editor, with its text as the editor has it; or, with block, a code block in the Markdown file p, as a file of its own that's never written. In an untrusted workspace the document isn't opened: the state says why.
func (*Workspace) OpenSession ¶
OpenSession picks the session to use and points the audit log at it: the session resume names (an ID, or a snapshot to start a new session from), the most recent one in this workspace when cont is set or resume is "latest", or else a new session. It reports whether a session was resumed.
func (*Workspace) PendingTaskRequests ¶
func (w *Workspace) PendingTaskRequests() []api.TaskRequest
PendingTaskRequests are the background tasks' approval requests and questions waiting for an answer.
func (*Workspace) PendingTaskRequestsIn ¶
func (w *Workspace) PendingTaskRequestsIn(sessions []string) []api.TaskRequest
PendingTaskRequestsIn are those of sessions' tasks.
func (*Workspace) PermissionsProblem ¶ added in v0.3.0
PermissionsProblem is why some of the settings' permission rules were left out at the last reload, or nil when all apply. Until they're fixed those rules aren't enforced, and the workspace won't open with them at the next start.
func (*Workspace) PinModel ¶
PinModel runs agent on ref from now on and saves the pin in the workspace's own settings (over any global pin).
func (*Workspace) ProcessOutput ¶
ProcessOutput is the captured output and status of background process id, when one of sessions started it (else api.ErrUnknownProcess).
func (*Workspace) ProjectAgentsDir ¶
ProjectAgentsDir is the folder of the workspace's own agents.
func (*Workspace) ProjectSettings ¶
func (w *Workspace) ProjectSettings() api.ProjectSettings
ProjectSettings are the workspace's project settings, as they were when it opened, with the trust decision as it is now.
func (*Workspace) PruneEnvs ¶
func (w *Workspace) PruneEnvs() (api.PruneResult, error)
PruneEnvs removes environments no script the policy lets run needs, and incomplete ones.
func (*Workspace) Pull ¶ added in v0.6.4
func (w *Workspace) Pull(ctx context.Context) (PullResult, error)
Pull brings the upstream's commits into the branch as the repository's git config says (pull.rebase, pull.ff; a merge when neither is set), keeping uncommitted changes (--autostash). A pull that stops on conflicts isn't an error: its outcome is PullConflicts, and the merge or rebase waits for ResolveConflict and CompleteMerge (or AbortMerge).
func (*Workspace) Push ¶ added in v0.6.4
Push sends the branch's commits to its upstream; a branch without one is published to the remote ("origin", or the only one) under its own name, and tracks it from then on. It returns where it pushed, as "remote/branch".
func (*Workspace) ReadFile ¶
func (w *Workspace) ReadFile(p string) (FileContent, error)
ReadFile opens the file p for the editor: binary files and files over the editor's limit come without their text.
func (*Workspace) ReadPreview ¶
ReadPreview returns an image, PDF or sound file's bytes and media type, for the editor to show or play (FIL-54).
func (*Workspace) ReadTable ¶ added in v0.3.0
ReadTable reads a page of a CSV or TSV file in the workspace (the table viewer, spec_files_029): streamed, so a file of any size can be paged, searched, filtered and sorted.
func (*Workspace) RefreshAgents ¶
RefreshAgents loads the agents again if a file in their folders was added, changed or removed since they were loaded: a new agent is offered, an edited one's prompt, tools and model apply from the next turn, and a removed one is gone (the active agent falls back to blitz). Files that don't load are warnings.
func (*Workspace) Reload ¶ added in v0.6.5
Reload reads the agents, skills, instruction files and rules again whether or not they look changed (/reload), rebuilds the agent with them, and says what it loaded and what didn't load. MCP servers and the project's settings aren't reloaded: opening the workspace again does.
func (*Workspace) ReloadMemory ¶
ReloadMemory re-reads project instruction files into the engine and returns their paths.
func (*Workspace) ReloadPermissions ¶
ReloadPermissions applies cfg's [permissions] (global and the workspace's, and the built-in read-only rules if on) in place of the ones from the settings: after a settings change while a session runs. Session and flag rules stay; read rules apply from the next start. Rules that can't be read are left out, and PermissionsProblem says why until a reload applies them all.
func (*Workspace) ReloadProviders ¶
ReloadProviders applies the provider settings (keys, endpoints, provider) of cfg, a fresh load of this workspace's settings, and rebuilds the model: a key set in the settings takes effect without reopening the workspace. It returns why the model still can't be built, if it can't.
func (*Workspace) ReloadSearch ¶ added in v0.3.0
ReloadSearch applies cfg's search settings while the workspace is open: changed, the index is closed and opened again with them (an embedding model or the describer started or stopped); the same, nothing happens.
func (*Workspace) RemovePermissionRule ¶
RemovePermissionRule removes a rule (any effect) for this session and, with a scope, from that settings file.
func (*Workspace) RenameFile ¶
RenameFile moves from to to (a file or a folder); to must not exist.
func (*Workspace) RenameSession ¶
func (w *Workspace) RenameSession(title string) (api.SessionInfo, error)
RenameSession sets the active session's title. An empty title is refused.
func (*Workspace) RenderDocx ¶ added in v0.6.0
RenderDocx writes markdown (a Markdown file's text, as the editor has it, or a conversation's) as a Word document, for the desktop app's Export as Word and /export (FS-75). Its images are read beside docPath, the file it belongs to ("" for none), as the editor reads them: the agent's path rules bind the agent, not the user. diagrams are its ```mermaid blocks as the caller drew them, by their text; one not there stays as code.
func (*Workspace) ResolveConflict ¶ added in v0.6.4
func (w *Workspace) ResolveConflict(ctx context.Context, p string, choice ConflictChoice) (api.GitStatus, error)
ResolveConflict settles a file a pull left in conflict: the branch's version, the remote's, or as edited (MarkResolved, refused while conflict markers remain). During a rebase git's "ours" is the remote's side, so mine and theirs are swapped for it. A side that deleted the file deletes it.
func (*Workspace) RestartLanguageServer ¶ added in v0.5.0
RestartLanguageServer stops language's server; the next request starts it again.
func (*Workspace) Restore ¶ added in v0.6.0
func (w *Workspace) Restore(ctx context.Context, p, rev, version string, preview bool) (string, []RestoredFile, error)
Restore puts p back as it was in rev: a file as RestoreFileRevision does (its new version), a folder or the workspace as RestoreFolder does (the files it put back, or would with preview).
func (*Workspace) RestoreFileRevision ¶ added in v0.6.0
func (w *Workspace) RestoreFileRevision(ctx context.Context, p, rev, version string) (string, error)
RestoreFileRevision makes the file p as it was in rev, unless it changed since version (its version as the caller last saw it, FileVersion; "" when it doesn't exist). The index is left alone, so the restore shows as a change to commit or discard.
func (*Workspace) RestoreFolder ¶ added in v0.6.0
func (w *Workspace) RestoreFolder(ctx context.Context, p, rev string, preview bool) ([]RestoredFile, error)
RestoreFolder puts the files under the folder p ("" the workspace) back as they were in rev: those changed since, and those deleted since. Files added since are kept. With preview, it only says which it would put back. The index is left alone.
func (*Workspace) RetryModel ¶
RetryModel builds the models again when the configured one couldn't be built: what it lacked may have appeared since, above all a sign-in made outside Blitz (gcloud's Application Default Credentials, an `ant auth login` profile), which no settings change announces. It does nothing while the model works.
func (*Workspace) RevisionDiff ¶ added in v0.6.0
func (w *Workspace) RevisionDiff(ctx context.Context, p, rev, other string, against DiffAgainst) (diff string, truncated bool, err error)
RevisionDiff returns a unified diff for p (a file, a folder, "" the workspace): from rev to now, rev's own changes, or from rev to other. truncated says it was cut at 2 MB, at a line.
func (*Workspace) RevokeApprovals ¶
RevokeApprovals removes approvals by key, for this session and from the saved ones, and returns how many keys it was given. Saved ones that couldn't be removed from the file are an ErrApprovalsStillSaved naming them: they're gone for now but come back at the next start.
func (*Workspace) Rewind ¶
func (w *Workspace) Rewind(ctx context.Context, index int, mode api.RewindMode, force bool) (api.RewindResult, error)
Rewind takes the active session back to the prompt at transcript index index. Files are restored first (refusing on conflicts unless force), so a refused rewind changes nothing; then the conversation is cut before the prompt, whose text is returned to send again.
func (*Workspace) RewindPoints ¶
func (w *Workspace) RewindPoints() ([]api.RewindPoint, error)
RewindPoints lists the active session's prompts, oldest first.
func (*Workspace) RewriteWorker ¶ added in v0.6.4
func (w *Workspace) RewriteWorker(ctx context.Context, spec api.WorkerSpec) (WorkerRewrite, error)
RewriteWorker has the suggestions model (else the reviewer's, else the main one) rewrite a worker's instructions so an unattended run does the job well and quickly, and list the permissions they need. The spec is the form as the user has it: nothing is saved.
func (*Workspace) Run ¶
func (w *Workspace) Run(ctx context.Context, sessionID string, t api.Turn, on func(api.Event)) (api.TurnResult, error)
Run sends one prompt to the agent in the session and passes its events to on as they happen. It runs prompt_submit hooks, audits the prompt, starts a checkpoint for /undo and records both sides in the transcript. A refused prompt is a *BlockedError. A turn that fails part way still returns what it produced.
func (*Workspace) RunDetached ¶
func (w *Workspace) RunDetached(ctx context.Context, t api.Turn, started func(sessionID string), on func(api.Event)) (api.TurnResult, error)
RunDetached runs a turn in a new session of its own (blitz --bg): as a worker's does, the session doesn't become the workspace's active one, so the people working there aren't moved to it. started gets the session's ID before the turn begins.
func (*Workspace) RunWorker ¶
RunWorker runs the named worker once, as its schedule would: in a session of its own, with only the permissions it declares and within its limits, recorded in the run log. The worker must be enabled; a scheduled run of one that isn't is recorded as skipped.
func (*Workspace) SandboxSummary ¶
SandboxSummary describes the sandbox commands run in, one line each.
func (*Workspace) SaveSnapshot ¶
SaveSnapshot saves a copy of the active session under name. Snapshots are never continued in place: loading one starts a new session from it.
func (*Workspace) Search ¶ added in v0.3.0
func (w *Workspace) Search(ctx context.Context, q api.SearchQuery) (api.SearchResult, error)
Search searches the workspace's index (spec_search_035).
func (*Workspace) SearchProvider ¶
SearchProvider names the web search provider, or ErrNoFetch.
func (*Workspace) SearchSession ¶
SearchSession looks for terms in the active session's transcript (which keeps what compaction removed from the model's context) and returns how many passages matched and the prompt that asks the agent about them.
func (*Workspace) SearchSkills ¶
SearchSkills returns the skills matching query.
func (*Workspace) SearchStatus ¶ added in v0.3.0
func (w *Workspace) SearchStatus() api.SearchStatus
SearchStatus is how the workspace's index is, with the settings it follows (even off) and what kept them from applying in full.
func (*Workspace) SearchWeb ¶
SearchWeb searches the web for terms and prepares the agent's prompt from the results it can read.
func (*Workspace) SessionDiff ¶
SessionDiff is a unified diff of every file the agent changed in the active session, against its state before the first change ("" when none). Checkpoints persist, so this spans the session's earlier runs.
func (*Workspace) SessionUsage ¶
SessionUsage returns the active session's usage.
func (*Workspace) Set ¶
Set changes a setting for this session ("agency" or "agency_level") and returns the key in canonical form. The agents' instructions embed it, so they are rebuilt.
func (*Workspace) SetLocale ¶
SetLocale switches the language the model replies in, for this workspace, and saves it as ui.locale in the config file. input is a language tag or name. The interface language belongs to the client: a front end switches its own (i18n.SetCurrent) with the returned Tag.
func (*Workspace) SetModel ¶
SetModel switches every unpinned agent to ref (a name or "provider/model"). It returns the active agent's pin when there is one, since that still decides what the active agent runs on.
func (*Workspace) SetPermissionMode ¶
SetPermissionMode changes which actions run without asking, for every session of the workspace, and returns the mode's canonical name. Bypass needs the OS sandbox (ErrBypassNeedsSandbox).
func (*Workspace) SetUI ¶
func (w *Workspace) SetUI(approve api.Approver, ask api.UserPromptFunc)
SetUI routes approval requests and questions to the front end.
func (*Workspace) SettingsChanges ¶
SettingsChanges is a channel that hears of settings changes (at most one pending) until ctx ends.
func (*Workspace) StatFiles ¶
StatFiles returns each file's version, "" for one that's gone (or isn't a readable file). Files over the editor's limit get their size and time instead of a hash.
func (*Workspace) Steer ¶
Steer queues a message for the agent while a turn runs in the session; the agent reads it with its next tool result. prompt_submit hooks apply, as to any prompt (a refusal is a *BlockedError), and the transcript records it.
func (*Workspace) StopTaskIn ¶
StopTaskIn stops task id, when one of sessions (nil: any) started it.
func (*Workspace) Suggestions ¶
func (w *Workspace) Suggestions(ctx context.Context) api.Suggestions
Suggestions returns the workspace's welcome tiles: setup when it has no agent instructions, an update of the skills and agents when the specification changed after them, the latest conversation, uncommitted changes and a failed worker, then up to three ideas from the recent conversations. When those changed since the ideas were written, new ones are written in the background (Pending) and the earlier ones are returned meanwhile.
func (*Workspace) SwitchBranch ¶ added in v0.6.5
SwitchBranch checks out branch name, carrying uncommitted changes along when they don't clash with it (ErrLocalChanges when they do). A remote's branch ("origin/feature") gets a local branch that tracks it, as git switch does.
func (*Workspace) TakeProcessNotices ¶
TakeProcessNotices removes and returns the notices waiting for session (the REPL starts a turn with them).
func (*Workspace) TaskIn ¶
TaskIn is task id with its latest events, when one of sessions (nil: any) started it (else api.ErrUnknownTask).
func (*Workspace) Tools ¶
Tools returns the tool registry: workspace, approvals, processes, MCP, hooks.
func (*Workspace) TrustProject ¶
TrustProject records trusting or declining the workspace's project settings as they are now (their hash): they load when it next opens.
func (*Workspace) Undo ¶
func (w *Workspace) Undo(force bool) (api.UndoResult, error)
Undo restores the files the latest turn with changes modified, and audits it. A partial restore returns both what was restored and why the rest wasn't.
func (*Workspace) UndoWorkerRun ¶
UndoWorkerRun restores the files worker run runID changed, as they were before it (BL-WK-02), with /undo's conflict rules.
func (*Workspace) Unpin ¶
Unpin returns agent to the configured model, or to its own default_model if it declares one, and removes the pin from the workspace's settings.
func (*Workspace) UpdateModelSettings ¶
func (w *Workspace) UpdateModelSettings(ref string, reset bool, changes []api.Setting) (api.ModelSettingsChange, error)
UpdateModelSettings applies changes to ref's settings (reset clears them all first). They apply from the next model call and are saved in the config file, under the key it already uses for the model if any.
func (*Workspace) UpdateWorker ¶
func (w *Workspace) UpdateWorker(spec api.WorkerSpec, hash string) (api.WorkerInfo, []string, error)
UpdateWorker rewrites a worker's WORKER.md from spec, if its files still have hash (api.ErrHashMismatch otherwise: they changed since they were read) and the result loads as a valid worker; otherwise it writes nothing and returns why. The name, its directory, can't change. The new content has a new hash, so an enabled worker is suspended until it's enabled again, as after any edit.
func (*Workspace) WatchDiagnostics ¶ added in v0.5.0
func (w *Workspace) WatchDiagnostics(ctx context.Context, client string, send func(lsp.DocumentDiagnostics) error) error
WatchDiagnostics sends client's documents' diagnostics to send until ctx ends or send fails.
func (*Workspace) WatchTasks ¶
WatchTasks sends the events of sessions' tasks until ctx ends.
func (*Workspace) WorkerRuns ¶
WorkerRuns returns a worker's recorded runs, newest first.
Source Files
¶
- added.go
- agentfiles.go
- backend.go
- changes.go
- commands.go
- commit.go
- context.go
- event.go
- export.go
- extensions.go
- files.go
- fork.go
- gitbranches.go
- gitfiles.go
- gitremote.go
- gitrevisions.go
- goals.go
- language.go
- lock.go
- lock_unix.go
- media.go
- mentions.go
- models.go
- network.go
- notices.go
- observability.go
- permissions.go
- project.go
- rewind.go
- search.go
- sessions.go
- settingswatch.go
- styles.go
- suggestions.go
- tables.go
- tasks.go
- turn.go
- workerrewrite.go
- workers.go
- workspace.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agents loads the agents a workspace offers: the built-in ones and Markdown files with YAML frontmatter from ~/.blitz/agents, the project's .agents/agents (prompt text, loaded without trust; a project's agent may loosen the permission mode only once the project is trusted) and enabled plugins, each a name, a description, a system prompt, the tools it may use and optionally its own model (spec_agents_014).
|
Package agents loads the agents a workspace offers: the built-in ones and Markdown files with YAML frontmatter from ~/.blitz/agents, the project's .agents/agents (prompt text, loaded without trust; a project's agent may loosen the permission mode only once the project is trusted) and enabled plugins, each a name, a description, a system prompt, the tools it may use and optionally its own model (spec_agents_014). |
|
builtin
Package builtin holds the agents Blitz ships with, as Markdown files embedded in the binary.
|
Package builtin holds the agents Blitz ships with, as Markdown files embedded in the binary. |
|
Package audit writes an append-only JSONL record of what tools did and what the user approved or denied.
|
Package audit writes an append-only JSONL record of what tools did and what the user approved or denied. |
|
Package breaker is a small circuit breaker for dependencies that fail persistently (MCP servers, model APIs): after a run of failures calls are refused for a cooldown that grows with each failed trial.
|
Package breaker is a small circuit breaker for dependencies that fail persistently (MCP servers, model APIs): after a run of failures calls are refused for a cooldown that grows with each failed trial. |
|
Package browser drives a Chromium-family browser through the Chrome DevTools Protocol for the agent's browser tool (spec_parity_027 §5.2): its own throwaway profile, never the user's, with every request it makes going through a proxy that applies the web rules.
|
Package browser drives a Chromium-family browser through the Chrome DevTools Protocol for the agent's browser tool (spec_parity_027 §5.2): its own throwaway profile, never the user's, with every request it makes going through a proxy that applies the web rules. |
|
browsertest
Package browsertest is a fake DevTools page, to test code driving a browser without one: it answers the commands package browser sends as a simple page would, and records them.
|
Package browsertest is a fake DevTools page, to test code driving a browser without one: it answers the commands package browser sends as a simple page would, and records them. |
|
Package commands loads custom slash commands: Markdown files whose body is a prompt, from the user's and the project's command directories, plus the bundled ones.
|
Package commands loads custom slash commands: Markdown files whose body is a prompt, from the user's and the project's command directories, plus the bundled ones. |
|
Package lsp talks to language servers for the agent's code intelligence (spec_parity_027 PAR-TOOL-03): definitions, references, hover, symbols and diagnostics, from servers started lazily per language.
|
Package lsp talks to language servers for the agent's code intelligence (spec_parity_027 PAR-TOOL-03): definitions, references, hover, symbols and diagnostics, from servers started lazily per language. |
|
lsptest
Package lsptest is a fake language server for tests: the test binary runs it when started with BLITZ_FAKE_LSP=1 (call MaybeServe first in TestMain), and Launcher starts that.
|
Package lsptest is a fake language server for tests: the test binary runs it when started with BLITZ_FAKE_LSP=1 (call MaybeServe first in TestMain), and Launcher starts that. |
|
Package mdpdf typesets Markdown as a PDF in pure Go, for the export_pdf tool (spec_filetools_006): GitHub-flavoured Markdown parsed by goldmark, laid out with fpdf in embedded Noto fonts, with an outline of the headings, page numbers, tables, highlighted code and the images the caller lets it read.
|
Package mdpdf typesets Markdown as a PDF in pure Go, for the export_pdf tool (spec_filetools_006): GitHub-flavoured Markdown parsed by goldmark, laid out with fpdf in embedded Noto fonts, with an outline of the headings, page numbers, tables, highlighted code and the images the caller lets it read. |
|
Package memory loads project instruction files (AGENTS.md, CLAUDE.md, GEMINI.md, BLITZ.md), the files they import, and rule files, which are added to the agents' system prompt.
|
Package memory loads project instruction files (AGENTS.md, CLAUDE.md, GEMINI.md, BLITZ.md), the files they import, and rule files, which are added to the agents' system prompt. |
|
Package runtime runs the agent: it wraps Google's ADK runner, builds the agent tree with its tools and sub-agents, runs a prompt as a turn within its limits, delivers steering mid-turn, answers side questions without touching history, compacts history, and records usage and traces.
|
Package runtime runs the agent: it wraps Google's ADK runner, builds the agent tree with its tools and sub-agents, runs a prompt as a turn within its limits, delivers steering mid-turn, answers side questions without touching history, compacts history, and records usage and traces. |
|
Package search is workspace search: an index of what a workspace holds (its files, the text of its PDFs and notebooks, its chats, its notes), kept on disk per workspace, brought up to date by scans that read only what changed, and searched by words (SQLite FTS5, ranked by BM25) and by substrings for code (spec_search_035).
|
Package search is workspace search: an index of what a workspace holds (its files, the text of its PDFs and notebooks, its chats, its notes), kept on disk per workspace, brought up to date by scans that read only what changed, and searched by words (SQLite FTS5, ranked by BM25) and by substrings for code (spec_search_035). |
|
Package session stores conversations: each session's metadata and its messages and events on disk, snapshots to branch from, search over a session's history, and the store ADK reads the conversation from (spec_sessions_017).
|
Package session stores conversations: each session's metadata and its messages and events on disk, snapshots to branch from, search over a session's history, and the store ADK reads the conversation from (spec_sessions_017). |
|
Package skills loads the skills a workspace offers: a SKILL.md with frontmatter and instructions, optionally scripts, from the built-in set, ~/.blitz/skills and (when trusted) the project; and the policy that caps what their scripts may do (spec_skills_013).
|
Package skills loads the skills a workspace offers: a SKILL.md with frontmatter and instructions, optionally scripts, from the built-in set, ~/.blitz/skills and (when trusted) the project; and the policy that caps what their scripts may do (spec_skills_013). |
|
builtin
Package builtin holds the skills Blitz ships with (a SKILL.md each), embedded in the binary.
|
Package builtin holds the skills Blitz ships with (a SKILL.md each), embedded in the binary. |
|
Package table reads delimited tables (CSV, TSV) for the desktop app's table viewer and workspace search (spec_files_029, spec_search_035): their delimiter and encoding (Latin-1 is decoded), a profile of their columns, and pages of rows matched by a search across columns, filters on columns and a sort, streamed so a file of hundreds of megabytes isn't loaded whole.
|
Package table reads delimited tables (CSV, TSV) for the desktop app's table viewer and workspace search (spec_files_029, spec_search_035): their delimiter and encoding (Latin-1 is decoded), a profile of their columns, and pages of rows matched by a search across columns, filters on columns and a sort, streamed so a file of hundreds of megabytes isn't loaded whole. |
|
Package tools is everything the agent can do and the rules it does it under: file tools through the workspace's sandbox (with checkpoints for undo), shell commands under the command policy and the OS sandbox, approvals and permission rules, web fetch and search, MCP servers, skill scripts, images, the task list and questions to the user (spec_filetools_006, spec_shell_007, spec_approvals_005).
|
Package tools is everything the agent can do and the rules it does it under: file tools through the workspace's sandbox (with checkpoints for undo), shell commands under the command policy and the OS sandbox, approvals and permission rules, web fetch and search, MCP servers, skill scripts, images, the task list and questions to the user (spec_filetools_006, spec_shell_007, spec_approvals_005). |
|
Package workers reads workers: scheduled workflows a workspace defines in workers/<name>/WORKER.md (ROADMAP item 24).
|
Package workers reads workers: scheduled workflows a workspace defines in workers/<name>/WORKER.md (ROADMAP item 24). |