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 help;
20pub mod interpreter;
21pub mod kernel;
22pub mod lexer;
23pub mod parser;
24pub mod paths;
25pub mod rpc;
26pub mod scheduler;
27pub mod tools;
28pub mod validator;
29pub mod vfs;
30#[cfg(unix)]
31pub mod terminal;
32
33// Re-export kaish_glob as our glob/walker modules for backwards compatibility
34pub use kaish_glob as glob_crate;
35
36/// Glob pattern matching (re-exported from kaish-glob).
37pub mod glob {
38 pub use kaish_glob::glob::{contains_glob, expand_braces, glob_match};
39}
40
41/// Recursive file walking infrastructure (re-exported from kaish-glob).
42pub mod walker {
43 pub use kaish_glob::{
44 EntryTypes, FileWalker, FilterResult, GlobPath, IgnoreFilter, IncludeExclude,
45 PathSegment, PatternError, WalkOptions, WalkerDirEntry, WalkerError, WalkerFs,
46 };
47 pub use crate::backend_walker_fs::BackendWalkerFs;
48}
49
50pub use backend::{
51 BackendError, BackendResult, EntryInfo, KernelBackend, LocalBackend, PatchOp, ReadRange,
52 ToolInfo, ToolResult, VirtualOverlayBackend, WriteMode,
53};
54pub use dispatch::{BackendDispatcher, CommandDispatcher, PipelinePosition};
55pub use kernel::{Kernel, KernelConfig, VfsMountMode};
56pub use rpc::KernelRpcServer;
57
58// ═══════════════════════════════════════════════════════════════════════════
59// Embedding Conveniences
60// ═══════════════════════════════════════════════════════════════════════════
61
62// Backend with /v/* support for embedders
63//
64// Use `Kernel::with_backend()` to provide a custom backend with automatic
65// `/v/*` path support (job observability, blob storage):
66//
67// ```ignore
68// let kernel = Kernel::with_backend(my_backend, config, |vfs| {
69// vfs.mount_arc("/v/docs", docs_fs);
70// })?;
71// ```
72
73// Git types (for embedders that want direct GitVfs access)
74pub use vfs::{FileStatus, GitVfs, LogEntry, StatusSummary, WorktreeInfo};
75
76// Job observability (for embedders capturing command output)
77pub use scheduler::{BoundedStream, StreamStats, DEFAULT_STREAM_MAX_SIZE, drain_to_stream};
78pub use vfs::JobFs;
79
80// XDG path primitives (embedders compose their own paths)
81pub use paths::{home_dir, xdg_cache_home, xdg_config_home, xdg_data_home, xdg_runtime_dir};
82
83// Tilde expansion utility
84pub use interpreter::expand_tilde;