aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_client/history.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/turtle/src/atuin_client/history.rs')
-rw-r--r--crates/turtle/src/atuin_client/history.rs72
1 files changed, 36 insertions, 36 deletions
diff --git a/crates/turtle/src/atuin_client/history.rs b/crates/turtle/src/atuin_client/history.rs
index cef65115..6bc0bc38 100644
--- a/crates/turtle/src/atuin_client/history.rs
+++ b/crates/turtle/src/atuin_client/history.rs
@@ -16,18 +16,18 @@ use crate::atuin_client::utils::get_host_user;
use time::OffsetDateTime;
mod builder;
-pub mod store;
+pub(crate) 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", "pi"];
-pub const AUTHOR_FILTER_ALL_USER: &str = "$all-user";
-pub const AUTHOR_FILTER_ALL_AGENT: &str = "$all-agent";
+pub(crate) const KNOWN_AGENTS: &[&str] = &["claude-code", "codex", "copilot", "pi"];
+pub(crate) const AUTHOR_FILTER_ALL_USER: &str = "$all-user";
+pub(crate) const AUTHOR_FILTER_ALL_AGENT: &str = "$all-agent";
-pub fn is_known_agent(author: &str) -> bool {
+pub(crate) fn is_known_agent(author: &str) -> bool {
KNOWN_AGENTS.contains(&author)
}
-pub fn author_matches_filters(author: &str, filters: &[String]) -> bool {
+pub(crate) 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),
@@ -41,12 +41,12 @@ pub(crate) const HISTORY_VERSION_V1: &str = "v1";
const HISTORY_RECORD_VERSION_V0: u16 = 0;
const HISTORY_RECORD_VERSION_V1: u16 = 1;
pub(crate) const HISTORY_VERSION: &str = HISTORY_VERSION_V1;
-pub const HISTORY_TAG: &str = "history";
+pub(crate) const HISTORY_TAG: &str = "history";
const HISTORY_AUTHOR_ENV: &str = "ATUIN_HISTORY_AUTHOR";
const HISTORY_INTENT_ENV: &str = "ATUIN_HISTORY_INTENT";
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
-pub struct HistoryId(pub String);
+pub(crate) struct HistoryId(pub(crate) String);
impl Display for HistoryId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
@@ -74,51 +74,51 @@ impl From<String> for HistoryId {
// New fields must be added to `History::{serialize,deserialize}` in a backwards
// compatible way (sensible defaults and careful `nfields` handling).
#[derive(Debug, Clone, PartialEq, Eq, sqlx::FromRow)]
-pub struct History {
+pub(crate) struct History {
/// A client-generated ID, used to identify the entry when syncing.
///
/// Stored as `client_id` in the database.
- pub id: HistoryId,
+ pub(crate) id: HistoryId,
/// When the command was run.
- pub timestamp: OffsetDateTime,
+ pub(crate) timestamp: OffsetDateTime,
/// How long the command took to run.
- pub duration: i64,
+ pub(crate) duration: i64,
/// The exit code of the command.
- pub exit: i64,
+ pub(crate) exit: i64,
/// The command that was run.
- pub command: String,
+ pub(crate) command: String,
/// The current working directory when the command was run.
- pub cwd: String,
+ pub(crate) cwd: String,
/// The session ID, associated with a terminal session.
- pub session: String,
+ pub(crate) session: String,
/// The hostname of the machine the command was run on.
- pub hostname: String,
+ pub(crate) hostname: String,
/// Who wrote this command (human user or automation/agent identity).
- pub author: String,
+ pub(crate) author: String,
/// Optional rationale for why the command was executed.
- pub intent: Option<String>,
+ pub(crate) intent: Option<String>,
/// Timestamp, which is set when the entry is deleted, allowing a soft delete.
- pub deleted_at: Option<OffsetDateTime>,
+ pub(crate) deleted_at: Option<OffsetDateTime>,
}
#[derive(Debug, Clone, PartialEq, Eq, sqlx::FromRow)]
-pub struct HistoryStats {
+pub(crate) struct HistoryStats {
/// The command that was ran after this one in the session
- pub next: Option<History>,
+ pub(crate) next: Option<History>,
///
/// The command that was ran before this one in the session
- pub previous: Option<History>,
+ pub(crate) previous: Option<History>,
/// How many times has this command been ran?
- pub total: u64,
+ pub(crate) total: u64,
- pub average_duration: u64,
+ pub(crate) average_duration: u64,
- pub exits: Vec<(i64, i64)>,
+ pub(crate) exits: Vec<(i64, i64)>,
- pub day_of_week: Vec<(String, i64)>,
+ pub(crate) day_of_week: Vec<(String, i64)>,
- pub duration_over_time: Vec<(String, i64)>,
+ pub(crate) duration_over_time: Vec<(String, i64)>,
}
impl History {
@@ -177,7 +177,7 @@ impl History {
}
}
- pub fn serialize(&self) -> Result<DecryptedData> {
+ pub(crate) fn serialize(&self) -> Result<DecryptedData> {
// This is pretty much the same as what we used for the old history, with one difference -
// it uses integers for timestamps rather than a string format.
@@ -366,7 +366,7 @@ impl History {
})
}
- pub fn deserialize(bytes: &[u8], version: &str) -> Result<History> {
+ pub(crate) fn deserialize(bytes: &[u8], version: &str) -> Result<History> {
match version {
HISTORY_VERSION_V0 => Self::deserialize_v0(bytes),
HISTORY_VERSION_V1 => Self::deserialize_v1(bytes),
@@ -416,7 +416,7 @@ impl History {
/// .build()
/// .into();
/// ```
- pub fn import() -> builder::HistoryImportedBuilder {
+ pub(crate) fn import() -> builder::HistoryImportedBuilder {
builder::HistoryImported::builder()
}
@@ -450,7 +450,7 @@ impl History {
/// .build()
/// .into();
/// ```
- pub fn capture() -> builder::HistoryCapturedBuilder {
+ pub(crate) fn capture() -> builder::HistoryCapturedBuilder {
builder::HistoryCaptured::builder()
}
@@ -492,7 +492,7 @@ impl History {
/// .build()
/// .into();
/// ```
- pub fn daemon() -> builder::HistoryDaemonCaptureBuilder {
+ pub(crate) fn daemon() -> builder::HistoryDaemonCaptureBuilder {
builder::HistoryDaemonCapture::builder()
}
@@ -518,15 +518,15 @@ impl History {
/// .build()
/// .into();
/// ```
- pub fn from_db() -> builder::HistoryFromDbBuilder {
+ pub(crate) fn from_db() -> builder::HistoryFromDbBuilder {
builder::HistoryFromDb::builder()
}
- pub fn success(&self) -> bool {
+ pub(crate) fn success(&self) -> bool {
self.exit == 0 || self.duration == -1
}
- pub fn should_save(&self, settings: &Settings) -> bool {
+ pub(crate) fn should_save(&self, settings: &Settings) -> bool {
!(self.command.starts_with(' ')
|| self.command.is_empty()
|| settings.history_filter.is_match(&self.command)