Documentation
¶
Overview ¶
Package config reads, writes, and resolves the clawtool configuration.
Schema mirrors ADR-006: core_tools, sources, tools (per-selector overrides), tags, groups, profile. v0.2 implements parsing of the full schema and the tool-level + server-level enabled resolver. Tag- and group-level resolution land in v0.3 once a source instance has actually been wired so we have real tools to tag.
Path resolution honors $XDG_CONFIG_HOME, falling back to ~/.config/clawtool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var KnownCoreTools = []string{
"Bash",
"Edit",
"Glob",
"Grep",
"Read",
"ToolSearch",
"WebFetch",
"WebSearch",
"Write",
}
KnownCoreTools is the compile-time list of core tools clawtool ships. Adding a tool here makes it appear in `clawtool init` output and `clawtool tools list`.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns the path the config should live at on this machine.
Honors $XDG_CONFIG_HOME, then $HOME/.config/clawtool/config.toml. If neither resolves we return a relative path so callers fail predictably with a recognizable error rather than reading from "/".
Types ¶
type Config ¶
type Config struct {
CoreTools map[string]CoreTool `toml:"core_tools,omitempty"`
Sources map[string]Source `toml:"sources,omitempty"`
Tools map[string]ToolOverride `toml:"tools,omitempty"`
Tags map[string]TagRule `toml:"tags,omitempty"`
Groups map[string]GroupDef `toml:"groups,omitempty"`
Profile ProfileConfig `toml:"profile,omitempty"`
}
Config is the full on-disk shape of ~/.config/clawtool/config.toml.
func Default ¶
func Default() Config
Default returns a Config preloaded with every known core tool enabled. Used by `clawtool init` to write a sensible starting point.
func Load ¶
Load reads and parses a config file. Returns os.ErrNotExist (wrapped) when the file is absent so callers can distinguish "no config" from a parse error.
func LoadOrDefault ¶
LoadOrDefault returns Load if the file exists, or Default() with no error when the file is missing. Used by `serve` so a fresh user can run without running `init` first.
func (Config) IsEnabled ¶
func (c Config) IsEnabled(selector string) Resolution
IsEnabled answers "should clawtool expose this tool?" for the given selector (CLI-form, e.g. "Bash" or "github-personal.create_issue").
Precedence per ADR-004 — v0.2 implements tool > server only:
- tools."<selector>".enabled (per-tool explicit override)
- core_tools.<Name>.enabled (only for core tools, where selector is the bare PascalCase name)
- default = true
Tag and group precedence land in v0.3.
func (Config) ListCoreTools ¶
func (c Config) ListCoreTools() []ToolListEntry
ListCoreTools returns the alphabetic list of known core tools paired with their resolved enabled state.
func (Config) Save ¶
Save writes the config to path, creating parent directories. File mode is 0600 because env values may carry secrets.
func (*Config) SetToolEnabled ¶
SetToolEnabled writes (or creates) an explicit per-tool override for a selector. Used by `clawtool tools enable / disable`.
type CoreTool ¶
type CoreTool struct {
Enabled *bool `toml:"enabled,omitempty"`
}
CoreTool toggles a clawtool-shipped tool. Default (missing entry) = enabled.
type GroupDef ¶
type GroupDef struct {
Include []string `toml:"include,omitempty"`
}
GroupDef bundles selectors. Toggling a group toggles every member.
type ProfileConfig ¶
type ProfileConfig struct {
Active string `toml:"active,omitempty"`
}
ProfileConfig selects the active profile. Profiles themselves layer on top of the same shape; v0.2 ships a single profile as part of the file.
type Resolution ¶
type Resolution struct {
Enabled bool
Rule string // "tools.<sel>", "core_tools.<name>", "default"
}
Resolution holds the result of resolving an enable/disable check.
type Source ¶
type Source struct {
Type string `toml:"type"` // currently only "mcp"
Command []string `toml:"command,omitempty"` // argv to spawn the MCP server
Env map[string]string `toml:"env,omitempty"` // env vars (`${VAR}` expansion at use)
}
Source defines a sourced MCP server instance. v0.2 stores the spec but does not yet spawn it; instance spawning lands when source instances ship.
type TagRule ¶
type TagRule struct {
Match []string `toml:"match,omitempty"`
Disabled bool `toml:"disabled,omitempty"`
Enabled bool `toml:"enabled,omitempty"`
}
TagRule applies an enable/disable across every tool whose selector matches any pattern in `match` (glob, evaluated against the selector form).
type ToolListEntry ¶
type ToolListEntry struct {
Selector string
Resolution Resolution
}
ToolListEntry is one row of `clawtool tools list`.
type ToolOverride ¶
type ToolOverride struct {
Enabled *bool `toml:"enabled,omitempty"`
}
ToolOverride is a per-selector explicit enable/disable. Pointer so absence is distinguishable from `false`.