Jesús Pérez 9cef9b8d57 refactor: consolidate configuration directories
Merge _configs/ into config/ for single configuration directory.
Update all path references.

Changes:
- Move _configs/* to config/
- Update .gitignore for new patterns
- No code references to _configs/ found

Impact: -1 root directory (layout_conventions.md compliance)
2025-12-26 18:36:23 +00:00

108 lines
3.2 KiB
Rust

//! Tools Shared Utilities
//!
//! Provides common functionality for all Tools ecosystem CLIs:
//! - Configuration discovery across multiple locations
//! - Manifest management for resource tracking
//! - Database path resolution
//! - XDG Base Directory support
//! - Project auto-detection and interactive selection
//!
//! # Configuration Discovery
//!
//! All Tools CLIs search for configuration in this order (uses first found):
//! 1. `.project/{name}` - External projects using Tools
//! 2. `.vapora/{name}` - VAPORA platform projects
//! 3. `.coder/{name}` - Documentation tracking
//! 4. Current directory - Fallback
//!
//! # Project Auto-Detection
//!
//! Tools can automatically detect projects by searching for `.project/` or `.vapora/`
//! configuration files in the current working directory and parent directories:
//!
//! ```no_run
//! use tools_shared::detect_project_from_cwd;
//!
//! if let Some(project) = detect_project_from_cwd("config.toml") {
//! println!("Working on project: {}", project.name);
//! }
//! ```
//!
//! # Global Database Support
//!
//! Tools can use a single global database to manage multiple projects:
//!
//! ```no_run
//! use tools_shared::find_global_db_path;
//!
//! let db_path = find_global_db_path("my-tool");
//! // Returns: ~/.local/share/tools/my-tool/my-tool.db
//! ```
//!
//! # Database Migrations
//!
//! Tools can execute SQL migrations from files:
//!
//! ```no_run
//! use tools_shared::run_migration_file;
//!
//! # fn example() -> anyhow::Result<()> {
//! run_migration_file("migrations/001_initial.sql")?;
//! # Ok(()) }
//! ```
//!
//! # Examples
//!
//! ```no_run
//! use tools_shared::find_config_path;
//! use std::path::Path;
//!
//! // Find a configuration file
//! let config = find_config_path("tracking.toml")
//! .unwrap_or_else(|| std::path::PathBuf::from("tracking.toml"));
//! println!("Using config: {}", config.display());
//! ```
pub mod config_finder;
pub mod db_migration;
pub mod global_db;
pub mod project_detection;
pub mod project_selector;
pub mod xdg;
#[cfg(feature = "manifest")]
pub mod manifest_manager;
// Re-export commonly used items from config_finder
pub use config_finder::{
find_config_path, find_config_path_or, find_config_path_warn_conflicts,
get_global_syntaxis_config_dir, get_global_vapora_config_dir, get_local_syntaxis_config_dir,
get_local_vapora_config_dir,
};
// Re-export XDG utilities
pub use xdg::{ensure_dir, tool_cache_dir, tool_config_dir, tool_data_dir};
// Re-export global database utilities
pub use global_db::{find_global_db_path, find_global_db_path_custom, global_db_exists};
// Re-export project detection
pub use project_detection::{
detect_project_from_cwd, detect_project_from_path, load_last_project, save_last_project,
DetectedProject,
};
// Re-export project selector
#[cfg(feature = "interactive")]
pub use project_selector::select_project;
pub use project_selector::{format_project_option, SelectableProject};
// Re-export database migration utilities
pub use db_migration::{
find_migration_files, has_migration_directory, list_migration_files, migration_directory,
run_migration_file,
};
#[cfg(feature = "manifest")]
pub use manifest_manager::{ConfigEntry, Manifest, ResourceType};