Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ atuin-server-sqlite SQLite implementation (sqlx)

- Rust 2024 edition, toolchain 1.93.1.
- Errors: `eyre::Result` in binaries, `thiserror` for typed errors in libraries.
- Derive boilerplate: `derive_more` (workspace dep) for `Display`, `From`, `Into`, `AsRef`, `Deref`, `Debug` on newtypes and simple enums. Prefer `derive_more` over manual `impl` when the formatting/conversion is a straight delegation. Use `thiserror` (not `derive_more`) for error types. Use `#[as_ref(forward)]` on string newtypes for `AsRef<str>`.
- Async: tokio. Client uses `current_thread`; server uses `multi_thread`.
- `#![deny(unsafe_code)]` on client/common, `#![forbid(unsafe_code)]` on server.
- Clippy: `pedantic` + `nursery` on main crate. CI enforces `-D warnings -D clippy::redundant_clone`.
Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ time = { version = "0.3.47", features = [
] }
clap = { version = "4.5.7", features = ["derive"] }
config = { version = "0.15.8", default-features = false, features = ["toml"] }
derive_more = { version = "2", features = ["as_ref", "deref", "display", "error", "from", "into"] }
directories = "6.0.0"
eyre = "0.6"
fs-err = "3.1"
Expand Down
1 change: 1 addition & 0 deletions crates/atuin-ai/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tree-sitter = ["dep:tree-sitter-lib", "dep:tree-sitter-bash", "dep:tree-sitter-f
[dependencies]
async-trait = { workspace = true }
atuin-client = { workspace = true }
derive_more = { workspace = true }
atuin-common = { workspace = true }
atuin-daemon = { workspace = true }
tokio = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/atuin-ai/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub(crate) struct ToolPreview {
}

/// A tool call from the server, with parsed input parameters.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, derive_more::From)]
pub(crate) enum ClientToolCall {
Read(ReadToolCall),
Edit(EditToolCall),
Expand Down
1 change: 1 addition & 0 deletions crates/atuin-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ check-update = []

[dependencies]
atuin-common = { path = "../atuin-common", version = "18.16.1" }
derive_more = { workspace = true }

log = { workspace = true }
base64 = { workspace = true }
Expand Down
17 changes: 2 additions & 15 deletions crates/atuin-client/src/history.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use core::fmt::Formatter;
use rmp::decode::DecodeStringError;
use rmp::decode::ValueReadError;
use rmp::{Marker, decode::Bytes};
use std::env;
use std::fmt::Display;

use atuin_common::record::DecryptedData;
use atuin_common::utils::uuid_v7;
Expand Down Expand Up @@ -45,21 +43,10 @@ pub 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)]
#[derive(Clone, Debug, Eq, PartialEq, Hash, derive_more::Display, derive_more::From)]
#[display("{_0}")]
pub struct HistoryId(pub String);

impl Display for HistoryId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}

impl From<String> for HistoryId {
fn from(s: String) -> Self {
Self(s)
}
}

/// Client-side history entry.
///
/// Client stores data unencrypted, and only encrypts it before sending to the server.
Expand Down
20 changes: 7 additions & 13 deletions crates/atuin-client/src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, fmt, io::prelude::*, path::PathBuf, str::FromStr, sync::OnceLock};
use std::{collections::HashMap, io::prelude::*, path::PathBuf, str::FromStr, sync::OnceLock};
use tokio::sync::OnceCell;

use atuin_common::record::HostId;
Expand Down Expand Up @@ -29,6 +29,8 @@ pub(crate) mod meta;
mod scripts;
pub mod watcher;

#[derive(derive_more::AsRef)]
#[as_ref(forward)]
Comment thread
markovejnovic marked this conversation as resolved.
Outdated
pub struct HubEndpoint(String);

/// Default sync address for Atuin's hosted service
Expand All @@ -43,12 +45,6 @@ impl Default for HubEndpoint {
}
}

impl AsRef<str> for HubEndpoint {
fn as_ref(&self) -> &str {
&self.0
}
}

#[derive(Clone, Debug, Deserialize, Copy, ValueEnum, PartialEq, Serialize)]
pub enum SearchMode {
#[serde(rename = "prefix")]
Expand Down Expand Up @@ -164,13 +160,11 @@ impl From<Dialect> for interim::Dialect {
/// multithreaded runtime, otherwise it will fail on most Unix systems.
///
/// See: <https://github.com/atuinsh/atuin/pull/1517#discussion_r1447516426>
#[derive(Clone, Copy, Debug, Eq, PartialEq, DeserializeFromStr, Serialize)]
#[derive(
Clone, Copy, Debug, Eq, PartialEq, DeserializeFromStr, Serialize, derive_more::Display,
)]
#[display("{_0}")]
pub struct Timezone(pub UtcOffset);
impl fmt::Display for Timezone {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
/// format: <+|-><hour>[:<minute>[:<second>]]
static OFFSET_FMT: &[FormatItem<'_>] = format_description!(
"[offset_hour sign:mandatory padding:none][optional [:[offset_minute padding:none][optional [:[offset_second padding:none]]]]]"
Expand Down
1 change: 1 addition & 0 deletions crates/atuin-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repository = { workspace = true }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
derive_more = { workspace = true }
time = { workspace = true }
serde = { workspace = true }
uuid = { workspace = true }
Expand Down
4 changes: 4 additions & 0 deletions crates/atuin-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ macro_rules! new_uuid {
Ord,
serde::Serialize,
serde::Deserialize,
derive_more::Display,
derive_more::From,
derive_more::Deref,
)]
#[serde(transparent)]
#[display("{_0}")]
pub struct $name(pub Uuid);

impl<DB: sqlx::Database> sqlx::Type<DB> for $name
Expand Down
2 changes: 1 addition & 1 deletion crates/atuin-common/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
use uuid::Uuid;

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, derive_more::Deref, derive_more::From)]
pub struct DecryptedData(pub Vec<u8>);

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down
29 changes: 9 additions & 20 deletions crates/atuin-common/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,26 @@ use serde::Serialize;
use sysinfo::{Process, System, get_current_pid};
use thiserror::Error;

#[derive(PartialEq)]
#[derive(PartialEq, derive_more::Display)]
pub enum Shell {
#[display("sh")]
Sh,
#[display("bash")]
Bash,
#[display("fish")]
Fish,
#[display("zsh")]
Zsh,
#[display("xonsh")]
Xonsh,
#[display("nu")]
Nu,
#[display("powershell")]
Powershell,

#[display("unknown")]
Unknown,
}

impl std::fmt::Display for Shell {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let shell = match self {
Shell::Bash => "bash",
Shell::Fish => "fish",
Shell::Zsh => "zsh",
Shell::Nu => "nu",
Shell::Xonsh => "xonsh",
Shell::Sh => "sh",
Shell::Powershell => "powershell",

Shell::Unknown => "unknown",
};

write!(f, "{shell}")
}
}
Comment thread
markovejnovic marked this conversation as resolved.

#[derive(Debug, Error, Serialize)]
pub enum ShellError {
#[error("shell not supported")]
Expand Down
1 change: 1 addition & 0 deletions crates/atuin-daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ readme.workspace = true
[dependencies]
atuin-client = { path = "../atuin-client", version = "18.16.1" }
atuin-common = { path = "../atuin-common", version = "18.16.1" }
derive_more = { workspace = true }
atuin-dotfiles = { path = "../atuin-dotfiles", version = "18.16.1" }
atuin-history = { path = "../atuin-history", version = "18.16.1" }

Expand Down
17 changes: 3 additions & 14 deletions crates/atuin-daemon/src/components/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! them by history ID for AI tool lookup.

use std::collections::{HashMap, VecDeque};
use std::fmt::{Display, Formatter};
use std::sync::Arc;

use atuin_client::history::{History, HistoryId};
Expand Down Expand Up @@ -45,7 +44,9 @@ struct SemanticState {
pending_histories: VecDeque<History>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, derive_more::Display, derive_more::AsRef)]
#[display("{_0}")]
#[as_ref(forward)]
struct SessionId(String);

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -440,18 +441,6 @@ impl TryFrom<String> for SessionId {
}
}

impl AsRef<str> for SessionId {
fn as_ref(&self) -> &str {
&self.0
}
}

impl Display for SessionId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}

pub struct SemanticGrpcService {
inner: Arc<SemanticComponentInner>,
}
Expand Down
1 change: 1 addition & 0 deletions crates/atuin-dotfiles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ readme.workspace = true
[dependencies]
atuin-common = { path = "../atuin-common", version = "18.16.1" }
atuin-client = { path = "../atuin-client", version = "18.16.1" }
derive_more = { workspace = true }

eyre = { workspace = true }
tokio = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/atuin-kv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ readme.workspace = true
[dependencies]
atuin-client = { path = "../atuin-client", version = "18.16.1" }
atuin-common = { path = "../atuin-common", version = "18.16.1" }
derive_more = { workspace = true }

tracing = { workspace = true }
tracing-subscriber = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/atuin-scripts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ readme.workspace = true
[dependencies]
atuin-client = { path = "../atuin-client", version = "18.16.1" }
atuin-common = { path = "../atuin-common", version = "18.16.1" }
derive_more = { workspace = true }

tracing = { workspace = true }
tracing-subscriber = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/atuin-server-database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repository = { workspace = true }

[dependencies]
atuin-common = { path = "../atuin-common", version = "18.16.1" }
derive_more = { workspace = true }

async-trait = { workspace = true }
eyre = { workspace = true }
Expand Down
Loading
Loading