Expand description
Tool system for kaish.
Tools are the primary way to perform actions in kaish. Every command
is a tool — builtins and user-defined tools all implement
the same Tool trait.
§Architecture
ToolRegistry
├── Builtins (echo, ls, cat, ...)
└── User Tools (defined via `tool` statements)Structs§
- Exec
Context - Execution context passed to tools.
- Global
Flags - Flags injected into every migrated builtin via
#[command(flatten)] global: GlobalFlags. - Param
Schema - Schema for a tool parameter.
- Tool
Args - Parsed arguments ready for tool execution.
- Tool
Registry - Registry of available tools.
- Tool
Schema - Schema describing a tool’s interface.
Enums§
- ArgBinding
- How the kernel’s argv binder hands a tool its arguments.
- External
Commands Unavailable - Why kaish will not run an external command for this dispatch — distinct
from “not found in PATH”, which is a different condition entirely (see
crate::tools::builtin::spawn::virtual_cwd_errorfor that one). - Output
Context - Output context determines how command output should be formatted.
- Overwrite
Expectation - What a snapshotted overwrite must still find at the target before it
writes — the compare-and-swap expectation
overwrite_checkedenforces.
Constants§
- WORD_
ASSIGN_ BUILTINS - Commands that consume bareword
key=valueargv (Arg::WordAssign) as shell-assignment pairs and route them throughtool_args.named. For every other command,key=valuelands as a positional"key=value"string — matching bash (cat foo=baropens a file namedfoo=bar).
Traits§
Functions§
- accepts_
word_ assign - external_
commands_ unavailable_ error - Refuse to run
nameas an external command, exit 127 — the same code POSIX gives “command not found”, since from here it’s indistinguishable to a caller checking only the exit code. The message is what carries the distinction; seeExternalCommandsUnavailable::condition. - global_
flag_ value_ is_ truthy - Is a kernel-owned global flag written as
--flag=VALUEon? - is_
global_ output_ flag - Check if a flag name is the kernel-owned
--jsonflag. - params_
from_ clap - Reflect each
Argin a clapCommandinto aParamSchema. - register_
builtins - Register all built-in tools with the registry.
- schema_
from_ clap - Build a
ToolSchemafor a builtin from its clapCommandreflection plus hand-written description and examples. - schema_
tree_ from_ clap - Build a recursive
ToolSchemafrom a composed clapCommandtree. - validate_
against_ schema - Validate arguments against a tool schema.
Type Aliases§
- Gate
Expectations - What each snapshotted target must still look like when the caller writes
it, keyed by resolved path (see
overwrite_checked).