pub struct GriteClient { /* private fields */ }Expand description
Client for interacting with the Grite CLI.
Implementations§
Source§impl GriteClient
impl GriteClient
Sourcepub fn new(repo_root: impl Into<PathBuf>) -> Self
pub fn new(repo_root: impl Into<PathBuf>) -> Self
Create a new GriteClient for the given repository root.
Sourcepub fn is_initialized(&self, git_dir: &Path) -> bool
pub fn is_initialized(&self, git_dir: &Path) -> bool
Check if Grit is initialized in the repository.
Sourcepub fn issue_create(
&self,
title: &str,
body: &str,
labels: &[String],
) -> Result<String, GriteError>
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.
Sourcepub fn issue_list(
&self,
labels: &[&str],
state: Option<&str>,
) -> Result<Vec<GriteIssueSummary>, GriteError>
pub fn issue_list( &self, labels: &[&str], state: Option<&str>, ) -> Result<Vec<GriteIssueSummary>, GriteError>
List issues with optional label filters.
Sourcepub fn issue_show(&self, issue_id: &str) -> Result<GriteIssue, GriteError>
pub fn issue_show(&self, issue_id: &str) -> Result<GriteIssue, GriteError>
Get a single issue by ID.
Sourcepub fn issue_label_add(
&self,
issue_id: &str,
labels: &[&str],
) -> Result<(), GriteError>
pub fn issue_label_add( &self, issue_id: &str, labels: &[&str], ) -> Result<(), GriteError>
Add labels to an issue.
Sourcepub fn issue_label_remove(
&self,
issue_id: &str,
labels: &[&str],
) -> Result<(), GriteError>
pub fn issue_label_remove( &self, issue_id: &str, labels: &[&str], ) -> Result<(), GriteError>
Remove labels from an issue.
Sourcepub fn issue_comment(
&self,
issue_id: &str,
body: &str,
) -> Result<(), GriteError>
pub fn issue_comment( &self, issue_id: &str, body: &str, ) -> Result<(), GriteError>
Add a comment to an issue.
Sourcepub fn convoy_create(
&self,
title: &str,
body: Option<&str>,
) -> Result<Convoy, GriteError>
pub fn convoy_create( &self, title: &str, body: Option<&str>, ) -> Result<Convoy, GriteError>
Create a new convoy.
Sourcepub fn convoy_list(&self) -> Result<Vec<Convoy>, GriteError>
pub fn convoy_list(&self) -> Result<Vec<Convoy>, GriteError>
List all convoys.
Sourcepub fn convoy_get(&self, convoy_id: &str) -> Result<Convoy, GriteError>
pub fn convoy_get(&self, convoy_id: &str) -> Result<Convoy, GriteError>
Get a convoy by its Brat convoy ID.
Sourcepub fn task_create(
&self,
convoy_id: &str,
title: &str,
body: Option<&str>,
) -> Result<Task, GriteError>
pub fn task_create( &self, convoy_id: &str, title: &str, body: Option<&str>, ) -> Result<Task, GriteError>
Create a new task linked to a convoy.
Sourcepub fn task_list(
&self,
convoy_id: Option<&str>,
) -> Result<Vec<Task>, GriteError>
pub fn task_list( &self, convoy_id: Option<&str>, ) -> Result<Vec<Task>, GriteError>
List tasks, optionally filtered by convoy.
Sourcepub fn task_get(&self, task_id: &str) -> Result<Task, GriteError>
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.
Sourcepub fn task_update_status(
&self,
task_id: &str,
new_status: TaskStatus,
) -> Result<(), GriteError>
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.
Sourcepub fn task_update_status_with_options(
&self,
task_id: &str,
new_status: TaskStatus,
force: bool,
) -> Result<(), GriteError>
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).
Sourcepub fn session_create(
&self,
task_id: &str,
role: SessionRole,
session_type: SessionType,
engine: &str,
worktree: &str,
pid: Option<u32>,
) -> Result<Session, GriteError>
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.
Sourcepub 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>
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.
Sourcepub fn session_list(
&self,
task_id: Option<&str>,
) -> Result<Vec<Session>, GriteError>
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.
Sourcepub fn session_get(&self, session_id: &str) -> Result<Session, GriteError>
pub fn session_get(&self, session_id: &str) -> Result<Session, GriteError>
Get a session by its Brat session ID.
Sourcepub fn session_update_status(
&self,
session_id: &str,
new_status: SessionStatus,
) -> Result<(), GriteError>
pub fn session_update_status( &self, session_id: &str, new_status: SessionStatus, ) -> Result<(), GriteError>
Update session status with validation.
Sourcepub fn session_update_status_with_options(
&self,
session_id: &str,
new_status: SessionStatus,
force: bool,
) -> Result<(), GriteError>
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.
Sourcepub fn session_heartbeat(&self, session_id: &str) -> Result<(), GriteError>
pub fn session_heartbeat(&self, session_id: &str) -> Result<(), GriteError>
Record session heartbeat.
Posts a new session comment with updated heartbeat timestamp.
Sourcepub fn session_exit(
&self,
session_id: &str,
exit_code: i32,
exit_reason: &str,
last_output_ref: Option<&str>,
) -> Result<(), GriteError>
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.
Sourcepub fn lock_acquire(
&self,
resource: &str,
ttl_ms: i64,
) -> Result<LockResult, GriteError>
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.
Sourcepub fn lock_release(&self, resource: &str) -> Result<(), GriteError>
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.
Sourcepub fn task_dep_add(
&self,
task_issue_id: &str,
target_issue_id: &str,
dep_type: DependencyType,
) -> Result<(), GriteError>
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.
Sourcepub fn task_dep_remove(
&self,
task_issue_id: &str,
target_issue_id: &str,
dep_type: DependencyType,
) -> Result<(), GriteError>
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.
Sourcepub fn task_dep_list(
&self,
task_issue_id: &str,
reverse: bool,
) -> Result<Vec<TaskDependency>, GriteError>
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.
Sourcepub fn task_topo_order(
&self,
label: Option<&str>,
) -> Result<Vec<GriteIssueSummary>, GriteError>
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).
Sourcepub fn context_index(
&self,
paths: &[&str],
force: bool,
pattern: Option<&str>,
) -> Result<ContextIndexResult, GriteError>
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.
Sourcepub fn context_query(&self, query: &str) -> Result<Vec<SymbolMatch>, GriteError>
pub fn context_query(&self, query: &str) -> Result<Vec<SymbolMatch>, GriteError>
Query for symbols matching a pattern.
Returns symbol names and their file paths.
Sourcepub fn context_show(&self, path: &str) -> Result<FileContext, GriteError>
pub fn context_show(&self, path: &str) -> Result<FileContext, GriteError>
Show context for a specific file.
Returns file metadata and extracted symbols.
Sourcepub fn context_project_get(
&self,
key: &str,
) -> Result<Option<String>, GriteError>
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.
Sourcepub fn context_project_list(
&self,
) -> Result<Vec<ProjectContextEntry>, GriteError>
pub fn context_project_list( &self, ) -> Result<Vec<ProjectContextEntry>, GriteError>
List all project context entries.
Sourcepub fn context_project_set(
&self,
key: &str,
value: &str,
) -> Result<(), GriteError>
pub fn context_project_set( &self, key: &str, value: &str, ) -> Result<(), GriteError>
Set a project context value.
Trait Implementations§
Source§impl Clone for GriteClient
impl Clone for GriteClient
Source§fn clone(&self) -> GriteClient
fn clone(&self) -> GriteClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more