vibe/stdlib_v2/mod.rs
1//! VibeScript v0.02 (`vibe-0.2`) Standard Library — Directory-Backed Library (`AGENTS.md` §0-B).
2//!
3//! Organizes all Phase 2 capabilities from `docs/planning/Vibe vs (2).md` (§§1–22) into four
4//! focused, single-purpose module tracks:
5//! - [`reflect_and_types`]: Runtime type reflection (`reflect.*`), null-prototype record ops (`record.*`),
6//! immutable RFC 3986 URIs (`uri.*`), and machine-serializable CBOR-LD errors (`error.*`).
7//! - [`num_and_autodiff`]: Strict non-coercing numeric parsers (`num.*`), exact base-10 financial
8//! decimals (`decimal.*`), Euclidean/checked/saturating math & SplitMix64 PRNG (`math.*`),
9//! and forward/multivariate automatic differentiation (`autodiff.*`).
10//! - [`text_and_collections`]: Unicode UAX #29 extended grapheme cluster strings (`str.*`),
11//! stateless linear-time $O(n)$ Thompson NFA regex (`regex.*`), and immutable collections,
12//! natural sorting, deques, priority queues & structural sets (`list.*`, `deque.*`, `pqueue.*`, `set.*`).
13//! - [`topology_and_manifold`]: Simplicial complexes, hypergraphs, cellular sheaves, $\mathbb{F}_2$
14//! persistent homology (`simplex.*`, `hypergraph.*`, `sheaf.*`, `topology.*`, `homotopy.*`),
15//! AI-native ontological context manifolds & zero-copy `did:q42` pointers (`context.*`, `manifold.*`,
16//! `inference.*`, `ast.*`, `diagnostic.*`), and algebraic effects, content-addressed code,
17//! structured concurrency, design-by-contract, CRDT/provenance/ZK, and hardware-sympathetic
18//! Perceus/SoA/SIMD systems (`effect.*`, `code.*`, `task.*`, `supervisor.*`, `contract.*`,
19//! `state.*`, `value.*`, `crypto.*`, `runtime.*`, `continuation.*`, `memory.*`, `simd.*`, `channel.*`).
20
21pub mod num_and_autodiff;
22pub mod reflect_and_types;
23pub mod text_and_collections;
24pub mod topology_and_manifold;
25
26#[cfg(test)]
27mod tests;
28
29pub use num_and_autodiff::{call_num_and_autodiff, NUM_AND_AUTODIFF_BINDINGS};
30pub use reflect_and_types::{call_reflect_and_types, REFLECT_AND_TYPES_BINDINGS};
31pub use text_and_collections::{
32 call_text_and_collections, split_graphemes, TEXT_AND_COLLECTIONS_BINDINGS,
33};
34pub use topology_and_manifold::{call_topology_and_manifold, TOPOLOGY_AND_MANIFOLD_BINDINGS};
35
36use crate::error::Diagnostic;
37use crate::span::Span;
38use crate::value::Value;
39
40/// Dispatches any VibeScript `v0.02` (`vibe-0.2`) standard library call.
41pub fn call_stdlib_v2(
42 path: &str,
43 args: &[Value],
44 span: Span,
45) -> Result<Option<Value>, Diagnostic> {
46 if let Some(v) = call_reflect_and_types(path, args, span)? {
47 return Ok(Some(v));
48 }
49 if let Some(v) = call_num_and_autodiff(path, args, span)? {
50 return Ok(Some(v));
51 }
52 if let Some(v) = call_text_and_collections(path, args, span)? {
53 return Ok(Some(v));
54 }
55 if let Some(v) = call_topology_and_manifold(path, args, span)? {
56 return Ok(Some(v));
57 }
58 Ok(None)
59}