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