diff options
| author | Ellie Huxtable <ellie@atuin.sh> | 2026-04-11 05:26:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-11 05:26:52 +0100 |
| commit | 4d81ec537f91ebed0d5498a36596a516dbf7d26b (patch) | |
| tree | 01c9ed9f3e3e6ecf61461c99fd8fd6998c26a8c3 /crates/atuin-client/src/history.rs | |
| parent | fix: ensure daemon is running (#3384) (diff) | |
| download | atuin-4d81ec537f91ebed0d5498a36596a516dbf7d26b.zip | |
feat: track coding agent shell usage (#3388)
https://github.com/user-attachments/assets/7868c7a4-6a91-4c93-ac6a-e8665cf1f799
## Checks
- [ ] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [ ] I have checked that there are no existing pull requests for the
same thing
Diffstat (limited to 'crates/atuin-client/src/history.rs')
| -rw-r--r-- | crates/atuin-client/src/history.rs | 18 |
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; |
