projets_indexer/
lib.rs

1//! # Projects Indexer
2//!
3//! `projets-indexer` is a powerful command-line tool for indexing and organizing your projects
4//! with AI-powered tag generation. It helps developers maintain a clear overview of their project
5//! collection by scanning directories, detecting project types, and providing detailed statistics.
6//!
7//! ## Features
8//!
9//! - 🔍 Recursive directory scanning with configurable depth
10//! - 📊 Project status detection (active/archived) based on git history
11//! - 🏷️ AI-powered tag generation using Ollama
12//! - 📁 Smart project categorization based on directory structure
13//! - 🔎 Search functionality across projects, tags, and categories
14//! - 📈 Detailed project statistics and insights
15//!
16//! ## Usage
17//!
18//! ```bash
19//! # Index projects with default settings
20//! projets-indexer index
21//!
22//! # Index projects with custom directory and output
23//! projets-indexer index -d ~/my-projects -o my-index.json
24//!
25//! # Search projects
26//! projets-indexer search "machine learning"
27//!
28//! # Show project statistics
29//! projets-indexer stats
30//!
31//! # Generate tags for a specific project
32//! projets-indexer generate-tags -p ~/projects/my-project
33//! ```
34//!
35//! ## Modules
36//!
37//! - [`cli`](cli/index.html): Command-line interface implementation using clap
38//! - [`config`](config/index.html): Configuration structures and handling
39//! - [`indexer`](indexer/index.html): Core project indexing functionality
40//! - [`models`](models/index.html): Data structures for projects and related entities
41//! - [`ollama`](ollama/index.html): Integration with Ollama for AI-powered tag generation
42//! - [`ui`](ui/index.html): Terminal UI components and progress indicators
43//! - [`error`](error/index.html): Error types and handling
44//!
45//! ## Examples
46//!
47//! Basic usage of the library:
48//!
49//! ```rust,no_run
50//! use projets_indexer::{
51//!     config::IndexerConfig,
52//!     indexer::ProjectIndexer,
53//! };
54//! use std::path::PathBuf;
55//!
56//! #[tokio::main]
57//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
58//!     // Create indexer configuration
59//!     let config = IndexerConfig::new(
60//!         PathBuf::from("~/projects"),
61//!         PathBuf::from("index.json"),
62//!         true, // enable Ollama
63//!     );
64//!
65//!     // Initialize project indexer
66//!     let indexer = ProjectIndexer::new(config)?;
67//!
68//!     // Index projects with a progress callback
69//!     let projects = indexer.index_projects(|project_name| {
70//!         println!("Indexing: {}", project_name);
71//!     }).await?;
72//!
73//!     println!("Found {} projects", projects.len());
74//!     Ok(())
75//! }
76//! ```
77//!
78//! ## Re-exports
79//!
80//! The following types are re-exported for convenience:
81//!
82//! - [`IndexerConfig`]: Configuration for the project indexer
83//! - [`ProjectIndexer`]: Main indexer implementation
84//! - [`Project`]: Project metadata structure
85//! - [`ProjectStatus`]: Project status enumeration
86//! - [`OllamaClient`]: Client for interacting with Ollama API
87//!
88//! ## Error Handling
89//!
90//! The library uses a custom error type [`OllamaError`] and a type alias [`Result`]
91//! for consistent error handling across all modules.
92//!
93//! ## Dependencies
94//!
95//! - `tokio`: Async runtime
96//! - `serde`: Serialization/deserialization
97//! - `walkdir`: Directory traversal
98//! - `tracing`: Logging and diagnostics
99//! - `reqwest`: HTTP client for Ollama API
100
101pub mod cli;
102pub mod config;
103pub mod error;
104pub mod indexer;
105pub mod models;
106pub mod ollama;
107pub mod ui;
108
109pub use cli::{Cli, Commands};
110pub use config::indexer_config::IndexerConfig;
111pub use error::{OllamaError, Result};
112pub use indexer::project_indexer::ProjectIndexer;
113pub use models::project::{Project, ProjectStatus};
114pub use ollama::{ClientConfig, GenerateRequest, GenerateResponse, OllamaClient};
115
116/// Common types and traits for the projects indexer.
117///
118/// This module re-exports commonly used types and traits to simplify imports.
119/// It's recommended to use this module when you need multiple types from different
120/// submodules.
121pub mod prelude {
122    pub use crate::error::{OllamaError, Result};
123    pub use crate::ollama::{
124        ClientConfig, GenerateOptions, GenerateRequest, GenerateResponse, OllamaClient,
125    };
126}