Skip to main content

kaish_kernel/
lib.rs

1//! kaish-kernel (核): The core of 会sh.
2//!
3//! This crate provides:
4//!
5//! - **Lexer**: Tokenizes kaish source code using logos
6//! - **Parser**: Builds AST from tokens using chumsky
7//! - **AST**: Type definitions for the abstract syntax tree
8//! - **Interpreter**: Expression evaluation, scopes, and the `$?` result type
9//! - **VFS**: Virtual filesystem with mount points
10//! - **Tools**: Tool trait, registry, and builtin commands
11//! - **Scheduler**: Pipeline execution and background job management
12//! - **Paths**: XDG-compliant path helpers
13
14pub mod arithmetic;
15pub mod ast;
16pub mod backend;
17pub(crate) mod backend_walker_fs;
18pub mod dispatch;
19pub mod duration;
20pub mod help;
21pub mod ignore_config;
22pub mod interpreter;
23pub mod output_limit;
24pub mod kernel;
25pub mod lexer;
26pub mod nonce;
27pub mod parser;
28pub mod paths;
29#[cfg(all(unix, feature = "native"))]
30pub mod pidfd;
31pub mod scheduler;
32pub mod tools;
33pub mod trash;
34#[cfg(feature = "native")]
35pub mod trash_system;
36pub mod validator;
37pub mod vfs;
38#[cfg(all(unix, feature = "native"))]
39pub mod terminal;
40
41// Re-export kaish_glob as our glob/walker modules for backwards compatibility
42pub use kaish_glob as glob_crate;
43
44/// Glob pattern matching (re-exported from kaish-glob).
45pub mod glob {
46    pub use kaish_glob::glob::{contains_glob, expand_braces, glob_match};
47}
48
49/// Recursive file walking infrastructure (re-exported from kaish-glob).
50pub mod walker {
51    pub use kaish_glob::{
52        EntryTypes, FileWalker, FilterResult, GlobPath, IgnoreFilter, IncludeExclude,
53        PathSegment, PatternError, WalkOptions, WalkerDirEntry, WalkerError, WalkerFs,
54    };
55    pub use crate::backend_walker_fs::BackendWalkerFs;
56}
57
58pub use backend::{
59    BackendError, BackendResult, KernelBackend, LocalBackend, PatchOp, ReadRange,
60    ToolInfo, ToolResult, VirtualOverlayBackend, WriteMode,
61};
62pub use dispatch::{CommandDispatcher, PipelinePosition};
63pub use ignore_config::{IgnoreConfig, IgnoreScope};
64pub use kernel::{ExecuteOptions, Kernel, KernelConfig, VfsMountMode};
65pub use output_limit::OutputLimitConfig;
66
67// ═══════════════════════════════════════════════════════════════════════════
68// Embedding Conveniences
69// ═══════════════════════════════════════════════════════════════════════════
70
71// Backend with /v/* support for embedders
72//
73// Use `Kernel::with_backend()` to provide a custom backend with automatic
74// `/v/*` path support (job observability, blob storage):
75//
76// ```ignore
77// let kernel = Kernel::with_backend(my_backend, config, |vfs| {
78//     vfs.mount_arc("/v/docs", docs_fs);
79// }, |_| {})?;
80// ```
81
82// Git types (for embedders that want direct GitVfs access)
83#[cfg(feature = "native")]
84pub use vfs::{FileStatus, GitVfs, LogEntry, StatusSummary, WorktreeInfo};
85
86// Job observability (for embedders capturing command output)
87pub use scheduler::{BoundedStream, StreamStats, DEFAULT_STREAM_MAX_SIZE, drain_to_stream};
88pub use vfs::JobFs;
89
90// XDG path primitives (embedders compose their own paths)
91pub use paths::{home_dir, xdg_cache_home, xdg_config_home, xdg_data_home, xdg_runtime_dir};
92
93// Tilde expansion utility
94pub use interpreter::expand_tilde;
95
96// Tool registration (for embedders registering custom tools)
97pub use tools::{Tool, ToolRegistry, ExecContext};