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