Expand description
Stable plugin API for kaish tools.
This leaf crate defines the contract that every kaish tool — builtin or
third-party — implements, without pulling in kaish-kernel’s parser,
interpreter, or async runtime internals. It exists so out-of-tree tool
bundles (kaish-tools-host, kaish-tools-git, a hypothetical
kaish-tools-perl) can be written against a small, audited surface.
§The surface
Tool— the trait every command implements. Itsexecutetakes a&mut dyn ToolCtx, so the concrete kernel context never leaks into the public API.ToolCtx— the trimmed execution context. It exposes only what a well-behaved, portable tool needs (backend I/O, cwd, variable access, output format). Trusted in-tree builtins that need deeper kernel state (job control, pipes, the dispatcher) recover the concrete context viaToolCtx::as_any_mut— a documented escape hatch, not part of the portable contract.KernelBackend— the I/O + tool-dispatch backend a tool reaches throughctx.backend().GlobalFlags,schema_from_clap,validate_against_schema— the clap-reflection and validation machinery shared by all builtins.
The pure-data types tools traffic in (Value, ToolArgs, ToolSchema,
ExecResult, OutputData, …) live one layer down in kaish-types.
Structs§
- Exec
Result - The result of executing a command or pipeline.
- Global
Flags - Flags injected into every migrated builtin via
#[command(flatten)] global: GlobalFlags. - Output
Data - Structured output data from a command.
- Param
Schema - Schema for a tool parameter.
- Span
- Source location span.
- Tool
Args - Parsed arguments ready for tool execution.
- Tool
Schema - Schema describing a tool’s interface.
- Validation
Issue - A validation issue found in the script.
Enums§
- Issue
Code - Categorizes validation issues for filtering and tooling.
- Output
Format - Output serialization format, requested via global flags.
- Severity
- Severity level for validation issues.
- Value
- A literal value.
Traits§
- Kernel
Backend - Abstract backend interface for file operations and tool dispatch.
- Tool
- A tool that can be executed.
- ToolCtx
- The portable execution context a tool sees.
Functions§
- is_
global_ output_ flag - Check if a flag name is the kernel-owned
--jsonflag. - params_
from_ clap - Reflect each
Argin a clapCommandinto aParamSchema. - 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.