1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! # harn-rules
//!
//! The declarative structural rule engine for Harn — the Rust core that
//! powers `harn rules` / lint / codemod surfaces. A **rule** describes
//! *what to match* (a pattern snippet, a node kind, or a regex) and
//! optionally *how to rewrite* it (a `fix`); the engine compiles that rule
//! against the tree-sitter machinery in [`harn_hostlib::ast`] and produces
//! [`RuleMatch`]es with metavariable bindings.
//!
//! This crate delivers the **atomic matching tier** (issue #2832):
//!
//! - [`model`] — the serde rule data model (`id` / `language` / `severity`
//! / `message` / `rule` block / `fix`).
//! - [`pattern`] — the snippet → tree-sitter-query compiler (`$VAR`
//! metavariable lifting + unification).
//! - [`engine`] — compile a [`Rule`] and run it to produce matches.
//! - [`loader`] — load rules from a TOML file or a directory.
//!
//! Relational/composite matching (#2833) and `where` / `transform` / `fix`
//! interpolation (#2834) layer onto this surface.
//!
//! ```
//! use harn_rules::{Rule, CompiledRule};
//!
//! let rule = Rule::from_toml_str(
//! r#"
//! id = "destructure-default"
//! language = "typescript"
//! fix = "{ $KEY: $SRC }"
//! [rule]
//! pattern = "$SRC?.$KEY ?? $DEFAULT"
//! "#,
//! ).unwrap();
//! let compiled = CompiledRule::compile(&rule).unwrap();
//! let matches = compiled.run("const a = cfg?.timeout ?? 30;").unwrap();
//! assert_eq!(matches[0].bindings["KEY"].text, "timeout");
//! ```
pub use ;
pub use RulesError;
pub use ;
pub use ;
pub use ;