Skip to content

Commit b00ad08

Browse files
committed
refactor(common): enforce utils:: path, remove top-level re-exports
- Remove pub use utils::{id, path, text, debug} from lib.rs - All call sites now use crab_common::utils::id::new_ulid() etc. - 20 files updated across auth, bridge, cli, config, daemon, fs, process, session, telemetry, tui crates - Follows Rust convention: module path reflects logical grouping
1 parent 7516418 commit b00ad08

21 files changed

Lines changed: 30 additions & 36 deletions

File tree

crates/auth/src/oauth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl TokenStore {
110110
/// Return the default token file path: `~/.crab/auth/tokens.json`.
111111
#[must_use]
112112
pub fn default_token_path() -> PathBuf {
113-
crab_common::path::home_dir()
113+
crab_common::utils::path::home_dir()
114114
.join(".crab")
115115
.join(TOKEN_DIR)
116116
.join(TOKEN_FILE)

crates/bridge/src/repl_bridge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl ReplBridge {
7575
));
7676
}
7777

78-
let id = ConnectionId::new(crab_common::id::new_ulid());
78+
let id = ConnectionId::new(crab_common::utils::id::new_ulid());
7979
self.clients.push(ClientHandle {
8080
id: id.clone(),
8181
info,

crates/bridge/src/trusted_device.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl TrustedDeviceRegistry {
3737

3838
/// Load the registry from the config directory.
3939
pub fn load() -> crab_common::Result<Self> {
40-
let path = crab_common::path::home_dir()
40+
let path = crab_common::utils::path::home_dir()
4141
.join(".crab")
4242
.join("trusted_devices.json");
4343
if !path.exists() {
@@ -52,7 +52,7 @@ impl TrustedDeviceRegistry {
5252

5353
/// Save the registry to the config directory.
5454
pub fn save(&self) -> crab_common::Result<()> {
55-
let path = crab_common::path::home_dir()
55+
let path = crab_common::utils::path::home_dir()
5656
.join(".crab")
5757
.join("trusted_devices.json");
5858
if let Some(parent) = path.parent() {

crates/cli/src/commands/chat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub async fn run_chat(config: ChatConfig) -> anyhow::Result<()> {
167167
None
168168
};
169169

170-
let session_id = crab_common::id::new_ulid();
170+
let session_id = crab_common::utils::id::new_ulid();
171171

172172
// 7. Build system prompt
173173
let registry = crab_tools::builtin::create_default_registry();

crates/cli/src/commands/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub async fn run_once(config: RunConfig) -> anyhow::Result<()> {
165165
);
166166

167167
let global_dir = settings::global_config_dir();
168-
let session_id = crab_common::id::new_ulid();
168+
let session_id = crab_common::utils::id::new_ulid();
169169

170170
// 6. Build session config
171171
let session_config = SessionConfig {

crates/cli/src/commands/update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct VersionCheckCache {
8181

8282
/// Path to the version check cache file.
8383
fn cache_path() -> PathBuf {
84-
crab_common::path::home_dir()
84+
crab_common::utils::path::home_dir()
8585
.join(".crab")
8686
.join("update-check-cache.json")
8787
}

crates/cli/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,13 @@ fn resolve_system_prompt(
531531
#[allow(clippy::too_many_lines)]
532532
async fn run(cli: &Cli, resume_session_id: Option<String>) -> anyhow::Result<()> {
533533
// Initialise debug/tracing if requested
534-
let debug_filter = crab_common::debug::resolve_debug_filter(cli.debug.as_deref());
535-
let debug_config = crab_common::debug::DebugConfig {
534+
let debug_filter = crab_common::utils::debug::resolve_debug_filter(cli.debug.as_deref());
535+
let debug_config = crab_common::utils::debug::DebugConfig {
536536
enabled: debug_filter.is_some() || cli.verbose,
537537
filter: debug_filter,
538538
file: cli.debug_file.clone(),
539539
};
540-
crab_common::debug::init_debug(&debug_config);
540+
crab_common::utils::debug::init_debug(&debug_config);
541541

542542
let working_dir = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
543543

@@ -678,9 +678,9 @@ async fn run(cli: &Cli, resume_session_id: Option<String>) -> anyhow::Result<()>
678678
let session_id = if let Some(ref id) = cli.session_id {
679679
id.clone()
680680
} else if cli.fork_session && effective_resume_id.is_some() {
681-
crab_common::id::new_ulid()
681+
crab_common::utils::id::new_ulid()
682682
} else {
683-
crab_common::id::new_ulid()
683+
crab_common::utils::id::new_ulid()
684684
};
685685

686686
// Build allowed/denied tool lists from CLI flags

crates/cli/src/setup.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ pub fn install_panic_hook() {
129129

130130
/// Initialize the tracing/logging system.
131131
///
132-
/// This delegates to `crab_common::debug::init_debug` which supports:
132+
/// This delegates to `crab_common::utils::debug::init_debug` which supports:
133133
/// - Console output to stderr (with level filtering)
134134
/// - Optional file output to `~/.crab/logs/`
135135
///
136136
/// When `verbose` is true, enables `crab=debug` level logging.
137137
/// Otherwise, tracing stays at its default (warn+error only).
138138
pub fn init_logging(verbose: bool) {
139-
let config = crab_common::debug::DebugConfig {
139+
let config = crab_common::utils::debug::DebugConfig {
140140
enabled: verbose,
141141
filter: if verbose {
142142
Some("crab=debug".to_string())
@@ -145,7 +145,7 @@ pub fn init_logging(verbose: bool) {
145145
},
146146
file: if verbose { Some(log_file_path()) } else { None },
147147
};
148-
crab_common::debug::init_debug(&config);
148+
crab_common::utils::debug::init_debug(&config);
149149
}
150150

151151
/// Run all initialization steps.
@@ -161,15 +161,15 @@ pub fn initialize(verbose: bool) {
161161

162162
/// Return the crash log path: `~/.crab/logs/crash.log`.
163163
fn crash_log_path() -> PathBuf {
164-
crab_common::path::home_dir()
164+
crab_common::utils::path::home_dir()
165165
.join(".crab")
166166
.join("logs")
167167
.join("crash.log")
168168
}
169169

170170
/// Return the debug log file path: `~/.crab/logs/debug.log`.
171171
fn log_file_path() -> PathBuf {
172-
crab_common::path::home_dir()
172+
crab_common::utils::path::home_dir()
173173
.join(".crab")
174174
.join("logs")
175175
.join("debug.log")

crates/common/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@ pub mod utils;
44

55
pub use error::Error;
66
pub use result::Result;
7-
8-
// Re-export utils at top level for backwards compatibility
9-
pub use utils::debug;
10-
pub use utils::id;
11-
pub use utils::path;
12-
pub use utils::text;

crates/config/src/config_toml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub struct ProviderProfile {
4949
/// `~/.config/crab-code/config.toml` (XDG-style).
5050
#[must_use]
5151
pub fn config_toml_path() -> PathBuf {
52-
crab_common::path::home_dir()
52+
crab_common::utils::path::home_dir()
5353
.join(".config")
5454
.join("crab-code")
5555
.join("config.toml")

0 commit comments

Comments
 (0)