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 `VirtualOverlayBackend` to wrap your custom backend and get automatic
63// support for `/v/*` paths (job observability, blob storage, etc.):
64//
65// ```ignore
66// let my_backend = Arc::new(MyBackend::new());
67// let overlay = VirtualOverlayBackend::new(my_backend, vfs);
68// let kernel = Kernel::with_backend(Arc::new(overlay), config)?;
69// ```
70//
71// Or use the convenience constructor:
72//
73// ```ignore
74// let kernel = Kernel::with_backend_and_virtual_paths(my_backend, config)?;
75// ```
76
77// Git types (for embedders that want direct GitVfs access)
78pub use vfs::{FileStatus, GitVfs, LogEntry, StatusSummary, WorktreeInfo};
79
80// Job observability (for embedders capturing command output)
81pub use scheduler::{BoundedStream, StreamStats, DEFAULT_STREAM_MAX_SIZE, drain_to_stream};
82pub use vfs::JobFs;
83
84// XDG path primitives (embedders compose their own paths)
85pub use paths::{home_dir, xdg_cache_home, xdg_config_home, xdg_data_home, xdg_runtime_dir};
86
87// Tilde expansion utility
88pub use interpreter::expand_tilde;