nika_engine/binding/mod.rs
1//! Binding Module - Data binding between tasks.
2//!
3//! Handles `with:` block data binding:
4//! - `entry`: YAML types (BindingSpec/BindingEntry + WithSpec/WithEntry)
5//! - `resolve`: Runtime resolution (ResolvedBindings) with lazy support
6//! - `template`: Template substitution (`{{with.alias}}`)
7//! - `jsonpath`: RFC 9535 JSONPath via serde_json_path
8//! - `types`: Core types (BindingPath, BindingSource, PathSegment, BindingType)
9//! - `transform`: 27 built-in transforms with pipe chains
10//!
11//! Unified `with:` syntax (eager resolution):
12//! ```yaml
13//! with:
14//! forecast: weather.summary # Simple path
15//! temp: weather.data.temp ?? 20 # With numeric default
16//! name: user.name ?? "Anonymous" # With string default (quoted)
17//! cfg: settings ?? {"debug": false} # With object default
18//! ```
19//!
20//! Extended syntax for lazy bindings:
21//! ```yaml
22//! with:
23//! lazy_val:
24//! path: future.result
25//! lazy: true # Deferred resolution
26//! lazy_with_default:
27//! path: optional.value
28//! lazy: true
29//! default: "fallback"
30//! ```
31//!
32//! Data flow:
33//! ```text
34//! YAML `with:` block → BindingSpec (entry)
35//! ↓
36//! ┌───────┴───────┐
37//! ▼ ▼
38//! Eager (lazy=false) Lazy (lazy=true)
39//! resolve now store Pending
40//! │ │
41//! ▼ ▼
42//! ResolvedBindings (Resolved | Pending)
43//! ↓
44//! Template substitution
45//! (resolves Pending on access)
46//! ↓
47//! Resolved prompt
48//! ```
49
50pub mod jsonpath;
51pub mod mention;
52mod resolve;
53mod template;
54mod validate;
55
56// Re-export from nika-core: identical modules
57pub use nika_core::binding::transform;
58pub use nika_core::binding::types;
59// Re-export entry types from nika-core
60pub use mention::{
61 has_parallel_marker, mentions_to_bindings, parse_mentions, resolve_mention,
62 strip_parallel_marker, text_to_bindings, Mention, MentionResolutionError, ResolvedMention,
63};
64pub use nika_core::binding::{
65 parse_binding_entry, parse_with_entry, BindingEntry, BindingSpec, WithEntry,
66 WithEntryParseError, WithSpec,
67};
68pub use resolve::{LazyBinding, ResolvedBindings};
69pub use template::{
70 escape_for_shell, extract_refs, extract_with_refs, parse_template_expr,
71 resolve as template_resolve, resolve_for_shell as template_resolve_for_shell,
72 resolve_with as template_resolve_with, validate_refs, validate_with_refs, TemplateExpr,
73};
74pub use transform::{TransformError, TransformExpr, TransformOp, TransformParseError};
75pub use types::{BindingPath, BindingPathError, BindingSource, BindingType, PathSegment};
76pub use validate::validate_task_id;