bctx-weave 0.1.29

bctx-weave — FilterMesh lens pipeline, CLI interception, domain compression
Documentation
pub mod compiler;
pub mod loader;
pub mod validator;

use serde::{Deserialize, Serialize};

/// A single find-and-replace rule inside a recipe.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct RecipeReplace {
    /// Regex pattern to find.
    pub from: String,
    /// Replacement string (supports `$1`, `$2` capture groups).
    pub to: String,
}

/// A declarative TOML-defined compression rule loaded from
/// `.bctx/recipes/` or `~/.config/bctx/recipes/`.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Recipe {
    /// Human-readable name shown in `bctx doctor`.
    pub name: String,
    /// Regex matched against the full command string (`program args...`).
    pub match_command: String,
    /// Lens names to apply after the recipe preprocessor.
    /// Valid values: "clarity", "focus", "narrow", "depth", "wide".
    #[serde(default)]
    pub lens: Vec<String>,
    /// Hard token budget. Lines are dropped tail-first until under budget.
    pub budget_tokens: Option<usize>,
    /// List of regex patterns — matching lines are stripped entirely.
    #[serde(default)]
    pub strip_lines: Vec<String>,
    /// Find-and-replace rules applied to each surviving line.
    #[serde(default)]
    pub replace: Vec<RecipeReplace>,
    /// Message to emit when the compressed output is empty.
    pub on_empty: Option<String>,
    /// Set to `false` to disable secret scanning for this recipe's output.
    /// Useful when the agent needs to see a credential you are sharing intentionally.
    /// Default: `true` (scanning enabled).
    #[serde(default = "default_true")]
    pub scan_secrets: bool,
}

fn default_true() -> bool {
    true
}