pub struct ProjectContext {
pub root: PathBuf,
pub db_path: PathBuf,
pub pool: SqlitePool,
}Fields§
§root: PathBuf§db_path: PathBuf§pool: SqlitePoolImplementations§
Source§impl ProjectContext
impl ProjectContext
Sourcepub fn get_database_path_info() -> DatabasePathInfo
pub fn get_database_path_info() -> DatabasePathInfo
Collect detailed information about database path resolution for diagnostics
This function traces through all the steps of finding the database location, showing which directories were checked and why a particular location was chosen.
Sourcepub fn find_project_root() -> Option<PathBuf>
pub fn find_project_root() -> Option<PathBuf>
Find the project root by searching upwards for .intent-engine directory
Search strategy (in priority order):
- Check INTENT_ENGINE_PROJECT_DIR environment variable
- Search upwards from current directory for .intent-engine/, but:
- Stop at project boundary (defined by PROJECT_ROOT_MARKERS)
- Do NOT cross into parent projects to prevent database mixing
- Check user’s home directory for .intent-engine/
Important: This function now respects project boundaries to prevent nested projects from accidentally using parent project databases.
Sourcepub async fn initialize_project() -> Result<Self>
pub async fn initialize_project() -> Result<Self>
Initialize a new Intent-Engine project using smart root inference
This function implements the smart lazy initialization algorithm:
- Try to infer project root based on common markers
- If inference succeeds, initialize in the inferred root
- If inference fails, fallback to CWD and print warning to stderr
Sourcepub async fn initialize_project_at(project_dir: PathBuf) -> Result<Self>
pub async fn initialize_project_at(project_dir: PathBuf) -> Result<Self>
Initialize a new Intent-Engine project at a specific directory
This is a thread-safe alternative to initialize_project() that doesn’t
rely on the global current directory. It’s particularly useful for:
- Concurrent tests that need isolated project initialization
- Tools that need to initialize projects in specific directories
- Any scenario where changing the global current directory is undesirable
§Arguments
project_dir- The directory where the project should be initialized
§Algorithm
- Try to infer project root starting from
project_dir - If inference succeeds, initialize in the inferred root
- If inference fails, use
project_diras the root directly
§Examples
use intent_engine::project::ProjectContext;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let project_dir = PathBuf::from("/tmp/my-project");
let ctx = ProjectContext::initialize_project_at(project_dir).await?;
Ok(())
}Sourcepub async fn load_or_init() -> Result<Self>
pub async fn load_or_init() -> Result<Self>
Load project context, initializing if necessary (for write commands)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProjectContext
impl !RefUnwindSafe for ProjectContext
impl Send for ProjectContext
impl Sync for ProjectContext
impl Unpin for ProjectContext
impl !UnwindSafe for ProjectContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more