lowfat_plugin/plugin.rs
1use anyhow::Result;
2use lowfat_core::level::Level;
3
4/// Input to a filter plugin.
5#[derive(Debug, Clone)]
6pub struct FilterInput {
7 /// Raw command output (stdout + stderr merged)
8 pub raw: String,
9 /// Command name (e.g., "git")
10 pub command: String,
11 /// Subcommand (e.g., "status"), empty if none
12 pub subcommand: String,
13 /// Full argument list
14 pub args: Vec<String>,
15 /// Current intensity level
16 pub level: Level,
17 /// Head limit for this level
18 pub head_limit: usize,
19 /// Command exit code
20 pub exit_code: i32,
21}
22
23/// Output from a filter plugin.
24#[derive(Debug, Clone)]
25pub struct FilterOutput {
26 /// Filtered text
27 pub text: String,
28 /// Whether filter passed through without changes
29 pub passthrough: bool,
30}
31
32/// Info about a loaded plugin.
33#[derive(Debug, Clone)]
34pub struct PluginInfo {
35 pub name: String,
36 pub version: String,
37 pub commands: Vec<String>,
38 pub subcommands: Vec<String>,
39}
40
41/// Core trait for filter plugins. Implemented by both ProcessRunner and WasmRunner.
42pub trait FilterPlugin: Send + Sync {
43 /// Plugin metadata.
44 fn info(&self) -> PluginInfo;
45 /// Apply filter to command output.
46 fn filter(&self, input: &FilterInput) -> Result<FilterOutput>;
47}