KeiSeiKit-1.0/_primitives/_rust/kei-router/src/rules.rs
Parfii-bot 0be354a920 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

35 lines
894 B
Rust

//! Keyword rule type + `require` predicate model.
use crate::extract::Extracted;
/// A dispatch rule: any matching keyword routes to `tool` if `require(extracted)` is true.
#[derive(Clone)]
pub struct KeywordRule {
pub tool: &'static str,
pub keywords: &'static [&'static str],
pub require: fn(&Extracted) -> bool,
}
/// A dynamic (runtime-added) rule — owned strings so caller can build at startup.
#[derive(Clone, Debug)]
pub struct DynRule {
pub tool: String,
pub keywords: Vec<String>,
}
// Predicates mirroring the Go require funcs.
pub fn always(_e: &Extracted) -> bool {
true
}
pub fn has_path(e: &Extracted) -> bool {
!e.path.is_empty()
}
pub fn has_id(e: &Extracted) -> bool {
e.id > 0
}
pub fn has_paths(e: &Extracted) -> bool {
!e.paths.is_empty()
}
pub fn has_any_id_or_query(e: &Extracted) -> bool {
e.id > 0 || !e.query.is_empty()
}