Documentation
¶
Overview ¶
Package aitools reads and writes the on-disk configuration that AI coding CLIs (Claude Code, Codex) keep in the user's home directory: skills, agents, slash commands and MCP server definitions.
Everything here talks to an undocumented, private on-disk layout owned by those tools. Parsing is therefore deliberately lenient: a shape we do not recognize yields an empty result and a Warning the UI can surface, never a hard error and never a silent blank panel.
Index ¶
- Variables
- func DeleteItem(kind Kind, scope Scope, name string, projectDir string) error
- func ReadItem(kind Kind, scope Scope, name string, projectDir string) (string, error)
- func WriteItem(kind Kind, scope Scope, name string, projectDir string, content string) error
- type Inventory
- type Item
- type Kind
- type MCPServer
- type Scope
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidName = fmt.Errorf("name must be a single path segment without separators")
ErrInvalidName is returned for a name that is not a single safe path segment.
Functions ¶
func DeleteItem ¶
DeleteItem removes one item. For a skill this removes the whole skill directory, since a skill is a directory and leaving an empty one behind would keep it visible as a broken entry.
Types ¶
type Inventory ¶
type Inventory struct {
Skills []Item `json:"skills"`
Agents []Item `json:"agents"`
Commands []Item `json:"commands"`
MCP []MCPServer `json:"mcp"`
// Warnings records anything that could not be read or parsed. A non-empty
// Warnings with empty results is the signal that the on-disk format has
// drifted, as opposed to the user simply having nothing configured.
Warnings []string `json:"warnings,omitempty"`
}
Inventory is a full snapshot of the AI tool configuration.
func ReadInventory ¶
ReadInventory collects every skill, agent, command and MCP server visible from projectDir. Pass an empty projectDir to read user scope only.
User and project scope are kept as separate entries rather than merged: which file defines a server is exactly what a user needs to know when two scopes disagree, and merging would hide that.
type Item ¶
type Item struct {
Kind Kind `json:"kind"`
// Name is the addressable identifier: the directory name for a skill, the
// filename without extension for an agent or command.
Name string `json:"name"`
Scope Scope `json:"scope"`
Path string `json:"path"`
Description string `json:"description,omitempty"`
SizeBytes int64 `json:"sizebytes"`
ModTimeMs int64 `json:"modtimems"`
}
Item is one skill, agent or slash command.
type MCPServer ¶
type MCPServer struct {
Name string `json:"name"`
// Transport is "stdio" when the entry runs a command, "http" when it
// points at a URL. Derived, not stored on disk.
Transport string `json:"transport"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
URL string `json:"url,omitempty"`
Env map[string]string `json:"env,omitempty"`
Scope Scope `json:"scope"`
// SourcePath is the file the entry was read from, so the UI can say where
// a server is defined when user and project scope disagree.
SourcePath string `json:"sourcepath"`
}
MCPServer is one entry from an `mcpServers` map.