aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-client/src/history.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/atuin-client/src/history.rs')
-rw-r--r--crates/atuin-client/src/history.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/atuin-client/src/history.rs b/crates/atuin-client/src/history.rs
index a5adc233..996208d9 100644
--- a/crates/atuin-client/src/history.rs
+++ b/crates/atuin-client/src/history.rs
@@ -18,6 +18,24 @@ use time::OffsetDateTime;
mod builder;
pub mod store;
+/// Known AI agent author values. Used to expand `$all-agent` and `$all-user` filters.
+pub const KNOWN_AGENTS: &[&str] = &["claude-code", "codex", "copilot"];
+pub const AUTHOR_FILTER_ALL_USER: &str = "$all-user";
+pub const AUTHOR_FILTER_ALL_AGENT: &str = "$all-agent";
+
+pub fn is_known_agent(author: &str) -> bool {
+ KNOWN_AGENTS.contains(&author)
+}
+
+pub fn author_matches_filters(author: &str, filters: &[String]) -> bool {
+ filters.is_empty()
+ || filters.iter().any(|filter| match filter.as_str() {
+ AUTHOR_FILTER_ALL_USER => !is_known_agent(author),
+ AUTHOR_FILTER_ALL_AGENT => is_known_agent(author),
+ literal => author == literal,
+ })
+}
+
pub(crate) const HISTORY_VERSION_V0: &str = "v0";
pub(crate) const HISTORY_VERSION_V1: &str = "v1";
const HISTORY_RECORD_VERSION_V0: u16 = 0;