Documentation
¶
Overview ¶
Package catalog reads, from the machine's files, what a composer offers for an agent CLI (Claude Code or Codex): its slash commands and skills for a folder, and the models and reasoning efforts it can be started with. The answers keep the shapes, texts and ordering of the previous runtime, which built them in JavaScript; the helpers here reproduce the few JavaScript string rules that change a result (what counts as whitespace, UTF-16 lengths, locale ordering, UTF-8 decoding with replacement).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrOutside = locale.T("The folder is outside the workspace", "Каталог вне рабочей папки") ErrNotFound = locale.T("Folder not found", "Каталог не найден") )
Errors of a folder check, as the composer shows them.
Functions ¶
func IsCommandName ¶
IsCommandName says whether a slash command may have this name.
Types ¶
type Catalog ¶
type Catalog struct {
Provider string `json:"provider"`
Cwd string `json:"cwd"`
GeneratedAt int64 `json:"generatedAt"`
Items []Item `json:"items"`
Counts Counts `json:"counts"`
Warnings []string `json:"warnings"`
Truncated bool `json:"truncated"`
}
Catalog is the answer for one agent and folder.
type Commands ¶
type Commands struct {
// contains filtered or unexported fields
}
Commands builds catalogs, keeping each provider and folder's for a minute and until a scanned root changes.
func (*Commands) Invalidate ¶
Invalidate drops the provider's cached catalogs: the CLI reloaded its plugins or skills, which may live outside the scanned folders.
func (*Commands) ResolveCwd ¶
ResolveCwd checks the folder project commands are looked up from: it must resolve (links included) inside the workspace root or a folder of one of the workspaces; none means the workspace root. It returns the resolved folder and the root it lies in, or the error text.
type Config ¶
type Config struct {
// ClaudeDir is Claude Code's config folder, CodexDir is Codex's home.
ClaudeDir, CodexDir string
// WorkspaceRoot is the runtime's workspace folder: no folder means it, and project commands are looked up to it.
WorkspaceRoot string
// QuickPromptsFile and WorkspacesFile are the runtime's data files.
QuickPromptsFile, WorkspacesFile string
}
Config is where the commands come from.
type Counts ¶
type Counts struct {
Quick int `json:"quick"`
Builtin int `json:"builtin"`
Project int `json:"project"`
User int `json:"user"`
Skill int `json:"skill"`
Plugin int `json:"plugin"`
}
Counts is the number of items per source.
type Item ¶
type Item struct {
// ID is "<source>:<plugin>:<name>", unique within a catalog.
ID string `json:"id"`
// Name is without the trigger: "compact", "commit-commands:commit".
Name string `json:"name"`
Trigger string `json:"trigger"`
Aliases []string `json:"aliases"`
Description string `json:"description"`
ArgumentHint *string `json:"argumentHint"`
Source string `json:"source"`
SourceLabel string `json:"sourceLabel"`
Plugin *string `json:"plugin"`
// Execution: send, model, effort, restart, help, skills, menu, confirm, terminal, blocked.
Execution string `json:"execution"`
// Output: transcript, reply, screen, none.
Output string `json:"output"`
// Welcome: allowed as the first message of a new conversation.
Welcome bool `json:"welcome"`
// Hidden: listed only under the whole list.
Hidden bool `json:"hidden"`
// Note: why a command is blocked, or the question a confirm command asks.
Note *string `json:"note"`
Danger bool `json:"danger"`
}
Item is one command a composer can offer. Field order is the answer's.
type LaunchConfig ¶
type LaunchConfig struct {
// AntigravityOptions supplies options from the cached native CLI probe.
AntigravityOptions func() LaunchOptions
ClaudeDir, CodexDir string
// RuntimeConfig is the runtime's config file, DefaultsKey its key holding the remembered choice per agent CLI.
RuntimeConfig, DefaultsKey string
}
LaunchConfig is where launch options come from.
func (LaunchConfig) Launch ¶
func (c LaunchConfig) Launch(provider string) LaunchOptions
Launch is what this machine can start an agent CLI with, and what it remembers.
type LaunchOptions ¶
type LaunchOptions struct {
Provider string `json:"provider"`
// Source: "static" for Claude and for Codex without a usable cache (the built-in list), "models-cache" for Codex.
Source string `json:"source"`
// FetchedAt is when Codex last refreshed its model list.
FetchedAt *string `json:"fetchedAt"`
Models []Model `json:"models"`
CliDefault Choice `json:"cliDefault"`
Warnings []string `json:"warnings"`
Saved *Choice `json:"saved"`
}
LaunchOptions: what this machine can start an agent CLI with, the CLI's default and the remembered choice.
type Model ¶
type Model struct {
ID string `json:"id"`
Label string `json:"label"`
Hint string `json:"hint"`
// Description is what the CLI itself says the model is for (Codex's models_cache.json), "" when it says nothing;
// it is not in the Legacy answer.
Description string `json:"-"`
// Efforts the model accepts; empty means the effort flag is not offered.
Efforts []string `json:"efforts"`
DefaultEffort *string `json:"defaultEffort"`
// Fast: the model runs in its CLI's fast mode (Codex's models_cache.json lists a «Fast» service tier for it); it is
// not in the Legacy answer.
Fast bool `json:"-"`
}
Model is one model an agent CLI can be started with.