kaish_kernel/tools/mod.rs
1//! Tool system for kaish.
2//!
3//! Tools are the primary way to perform actions in kaish. Every command
4//! is a tool — builtins and user-defined tools all implement
5//! the same `Tool` trait.
6//!
7//! # Architecture
8//!
9//! ```text
10//! ToolRegistry
11//! ├── Builtins (echo, ls, cat, ...)
12//! └── User Tools (defined via `tool` statements)
13//! ```
14
15mod builtin;
16mod clap_schema;
17mod context;
18mod global_flags;
19mod registry;
20mod traits;
21
22pub use builtin::register_builtins;
23#[cfg(feature = "subprocess")]
24pub use builtin::resolve_in_path;
25pub use clap_schema::{params_from_clap, schema_from_clap, schema_tree_from_clap};
26pub use context::{ExecContext, OutputContext};
27pub use global_flags::GlobalFlags;
28pub use registry::ToolRegistry;
29pub use traits::{is_global_output_flag, validate_against_schema, Tool, ToolArgs, ToolCtx, ToolSchema, ParamSchema};
30
31/// Commands that consume bareword `key=value` argv (Arg::WordAssign) as
32/// shell-assignment pairs and route them through `tool_args.named`. For every
33/// other command, `key=value` lands as a positional `"key=value"` string —
34/// matching bash (`cat foo=bar` opens a file named `foo=bar`).
35///
36/// Add to this list only for builtins that have a documented shell-assignment
37/// argv contract (`export FOO=bar`, `alias greet='echo hi'`). Long-flag
38/// `--key=value` is a separate AST node (`Arg::Named`) and always routes
39/// through `tool_args.named` regardless.
40pub const WORD_ASSIGN_BUILTINS: &[&str] = &["export", "alias", "unalias"];
41
42pub fn accepts_word_assign(name: &str) -> bool {
43 WORD_ASSIGN_BUILTINS.contains(&name)
44}