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