ProjectContext

Struct ProjectContext 

Source
pub struct ProjectContext {
    pub root: PathBuf,
    pub db_path: PathBuf,
    pub pool: SqlitePool,
}

Fields§

§root: PathBuf§db_path: PathBuf§pool: SqlitePool

Implementations§

Source§

impl ProjectContext

Source

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.

Source

pub fn find_project_root() -> Option<PathBuf>

Find the project root by searching upwards for .intent-engine directory

Search strategy (in priority order):

  1. Check INTENT_ENGINE_PROJECT_DIR environment variable
  2. 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
  3. 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.

Source

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:

  1. Try to infer project root based on common markers
  2. If inference succeeds, initialize in the inferred root
  3. If inference fails, fallback to CWD and print warning to stderr
Source

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
  1. Try to infer project root starting from project_dir
  2. If inference succeeds, initialize in the inferred root
  3. If inference fails, use project_dir as 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(())
}
Source

pub async fn load() -> Result<Self>

Load an existing project context

Source

pub async fn load_or_init() -> Result<Self>

Load project context, initializing if necessary (for write commands)

Trait Implementations§

Source§

impl Debug for ProjectContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,