Skip to main content

GriteClient

Struct GriteClient 

Source
pub struct GriteClient { /* private fields */ }
Expand description

Client for interacting with the Grite CLI.

Implementations§

Source§

impl GriteClient

Source

pub fn new(repo_root: impl Into<PathBuf>) -> Self

Create a new GriteClient for the given repository root.

Source

pub fn is_initialized(&self, git_dir: &Path) -> bool

Check if Grit is initialized in the repository.

Source

pub fn repo_root(&self) -> &Path

Get the repository root path.

Source

pub fn issue_create( &self, title: &str, body: &str, labels: &[String], ) -> Result<String, GriteError>

Create a new issue with the given title, body, and labels.

Source

pub fn issue_list( &self, labels: &[&str], state: Option<&str>, ) -> Result<Vec<GriteIssueSummary>, GriteError>

List issues with optional label filters.

Source

pub fn issue_show(&self, issue_id: &str) -> Result<GriteIssue, GriteError>

Get a single issue by ID.

Source

pub fn issue_label_add( &self, issue_id: &str, labels: &[&str], ) -> Result<(), GriteError>

Add labels to an issue.

Source

pub fn issue_label_remove( &self, issue_id: &str, labels: &[&str], ) -> Result<(), GriteError>

Remove labels from an issue.

Source

pub fn issue_comment( &self, issue_id: &str, body: &str, ) -> Result<(), GriteError>

Add a comment to an issue.

Source

pub fn convoy_create( &self, title: &str, body: Option<&str>, ) -> Result<Convoy, GriteError>

Create a new convoy.

Source

pub fn convoy_list(&self) -> Result<Vec<Convoy>, GriteError>

List all convoys.

Source

pub fn convoy_get(&self, convoy_id: &str) -> Result<Convoy, GriteError>

Get a convoy by its Brat convoy ID.

Source

pub fn task_create( &self, convoy_id: &str, title: &str, body: Option<&str>, ) -> Result<Task, GriteError>

Create a new task linked to a convoy.

Source

pub fn task_list( &self, convoy_id: Option<&str>, ) -> Result<Vec<Task>, GriteError>

List tasks, optionally filtered by convoy.

Source

pub fn task_get(&self, task_id: &str) -> Result<Task, GriteError>

Get a task by its Brat task ID.

Unlike task_list, this returns the full task including body.

Source

pub fn task_update_status( &self, task_id: &str, new_status: TaskStatus, ) -> Result<(), GriteError>

Update task status with validation.

This validates the state transition before updating. Use task_update_status_with_options with force=true to bypass validation.

Source

pub fn task_update_status_with_options( &self, task_id: &str, new_status: TaskStatus, force: bool, ) -> Result<(), GriteError>

Update task status with options.

If force is true, bypasses state machine validation (admin override).

Source

pub fn session_create( &self, task_id: &str, role: SessionRole, session_type: SessionType, engine: &str, worktree: &str, pid: Option<u32>, ) -> Result<Session, GriteError>

Create a new session for a task.

This posts a session comment to the task issue and updates labels. Sessions are stored as comments on task issues, not as separate issues.

Source

pub fn session_create_with_id( &self, session_id: Option<&str>, task_id: &str, role: SessionRole, session_type: SessionType, engine: &str, worktree: &str, pid: Option<u32>, ) -> Result<Session, GriteError>

Create a new session with an optional pre-generated ID.

This is useful when the session ID needs to be known before creation, such as when creating a worktree that uses the session ID as its name.

If session_id is None, a new ID will be generated.

Source

pub fn session_list( &self, task_id: Option<&str>, ) -> Result<Vec<Session>, GriteError>

List active sessions, optionally filtered by task.

Only returns sessions that are not in the Exit state.

Source

pub fn session_get(&self, session_id: &str) -> Result<Session, GriteError>

Get a session by its Brat session ID.

Source

pub fn session_update_status( &self, session_id: &str, new_status: SessionStatus, ) -> Result<(), GriteError>

Update session status with validation.

Source

pub fn session_update_status_with_options( &self, session_id: &str, new_status: SessionStatus, force: bool, ) -> Result<(), GriteError>

Update session status with options.

If force is true, bypasses state machine validation.

Source

pub fn session_heartbeat(&self, session_id: &str) -> Result<(), GriteError>

Record session heartbeat.

Posts a new session comment with updated heartbeat timestamp.

Source

pub fn session_exit( &self, session_id: &str, exit_code: i32, exit_reason: &str, last_output_ref: Option<&str>, ) -> Result<(), GriteError>

Record session exit.

Posts a final session comment with exit information and updates labels.

Source

pub fn lock_acquire( &self, resource: &str, ttl_ms: i64, ) -> Result<LockResult, GriteError>

Acquire a lock on a resource.

Returns a LockResult indicating whether the lock was acquired. If the lock is already held by another actor, acquired will be false and holder will contain the current owner.

Source

pub fn lock_release(&self, resource: &str) -> Result<(), GriteError>

Release a lock on a resource.

This is a best-effort operation; errors are logged but not fatal.

Source

pub fn task_dep_add( &self, task_issue_id: &str, target_issue_id: &str, dep_type: DependencyType, ) -> Result<(), GriteError>

Add a dependency between two tasks.

The dependency is from task_issue_id to target_issue_id with the given type. For example, DependencyType::DependsOn means the task depends on the target.

Source

pub fn task_dep_remove( &self, task_issue_id: &str, target_issue_id: &str, dep_type: DependencyType, ) -> Result<(), GriteError>

Remove a dependency between two tasks.

Source

pub fn task_dep_list( &self, task_issue_id: &str, reverse: bool, ) -> Result<Vec<TaskDependency>, GriteError>

List dependencies for a task.

If reverse is true, returns issues that depend on this task. If reverse is false, returns issues that this task depends on.

Source

pub fn task_topo_order( &self, label: Option<&str>, ) -> Result<Vec<GriteIssueSummary>, GriteError>

Get tasks in topological order (ready-to-run first).

Returns issues sorted so that dependencies come before dependents. Optionally filter by label (e.g., “convoy:c-xxx” to get tasks for a specific convoy).

Source

pub fn context_index( &self, paths: &[&str], force: bool, pattern: Option<&str>, ) -> Result<ContextIndexResult, GriteError>

Index files for symbol extraction.

If paths is empty, indexes all tracked files. If force is true, re-indexes even if content hasn’t changed. If pattern is provided, only files matching the glob are indexed.

Source

pub fn context_query(&self, query: &str) -> Result<Vec<SymbolMatch>, GriteError>

Query for symbols matching a pattern.

Returns symbol names and their file paths.

Source

pub fn context_show(&self, path: &str) -> Result<FileContext, GriteError>

Show context for a specific file.

Returns file metadata and extracted symbols.

Source

pub fn context_project_get( &self, key: &str, ) -> Result<Option<String>, GriteError>

Get a project context value by key.

Returns None if the key doesn’t exist.

Source

pub fn context_project_list( &self, ) -> Result<Vec<ProjectContextEntry>, GriteError>

List all project context entries.

Source

pub fn context_project_set( &self, key: &str, value: &str, ) -> Result<(), GriteError>

Set a project context value.

Trait Implementations§

Source§

impl Clone for GriteClient

Source§

fn clone(&self) -> GriteClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V