catalog

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 20 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 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

View Source
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

func IsCommandName(name string) bool

IsCommandName says whether a slash command may have this name.

func IsProvider

func IsProvider(p string) bool

IsProvider says whether an agent CLI is known.

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 Choice

type Choice struct {
	Model  *string `json:"model"`
	Effort *string `json:"effort"`
}

Choice is a model and reasoning effort; nil means the CLI's own default.

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 New

func New(cfg Config, encode func(any) []byte) *Commands

New returns a catalog builder; encode is how answers are encoded.

func (*Commands) Get

func (c *Commands) Get(provider, cwd, root string) Result

Get is the catalog of one agent CLI for a folder ResolveCwd accepted.

func (*Commands) Invalidate

func (c *Commands) Invalidate(provider string)

Invalidate drops the provider's cached catalogs: the CLI reloaded its plugins or skills, which may live outside the scanned folders.

func (*Commands) ResolveCwd

func (c *Commands) ResolveCwd(cwd string) (dir, root, errText string)

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.

func Builtin

func Builtin(provider, name string) (Item, bool)

Builtin is the curated built-in of an agent CLI ("claude" or "codex") behind a name or one of its aliases, compared in lower case. False for anything else — skills, plugins, typos — which the CLI gets typed as is.

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.

type Result

type Result struct {
	Catalog Catalog
	Body    json.RawMessage
	Tag     string
}

Result is a catalog, its encoded body and the content tag of its items and warnings.

Jump to

Keyboard shortcuts

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