Skip to main content

libgrite_cli/
types.rs

1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3
4/// Options for resolving the grite context (mirrors CLI global flags).
5#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6pub struct ResolveOptions {
7    /// Override the data directory
8    pub data_dir: Option<PathBuf>,
9
10    /// Override the actor ID
11    pub actor: Option<String>,
12}
13
14/// Options for `grite init`.
15#[derive(Debug, Clone, Default, Serialize, Deserialize)]
16pub struct InitOptions {
17    /// Skip creating/updating AGENTS.md
18    pub no_agents_md: bool,
19}
20
21/// Result of `grite init`.
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct InitResult {
24    pub actor_id: String,
25    pub data_dir: PathBuf,
26    pub created_agents_md: bool,
27}
28
29/// Options for creating an issue.
30#[derive(Debug, Clone, Default, Serialize, Deserialize)]
31pub struct IssueCreateOptions {
32    pub title: String,
33    pub body: String,
34    pub labels: Vec<String>,
35}
36
37/// Result of creating an issue.
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct IssueCreateResult {
40    pub issue_id: String,
41    pub event_id: String,
42}
43
44/// Options for listing issues.
45#[derive(Debug, Clone, Default, Serialize, Deserialize)]
46pub struct IssueListOptions {
47    pub state: Option<String>,
48    pub label: Option<String>,
49}
50
51/// Result of listing issues.
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct IssueListResult {
54    pub issues: Vec<libgrite_core::IssueSummary>,
55}
56
57/// Options for showing an issue.
58#[derive(Debug, Clone, Default, Serialize, Deserialize)]
59pub struct IssueShowOptions {
60    pub issue_id: String,
61}
62
63/// Result of showing an issue.
64#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct IssueShowResult {
66    pub issue: libgrite_core::IssueProjection,
67    pub events: Vec<libgrite_core::Event>,
68}
69
70/// Options for updating an issue.
71#[derive(Debug, Clone, Default, Serialize, Deserialize)]
72pub struct IssueUpdateOptions {
73    pub issue_id: String,
74    pub title: Option<String>,
75    pub body: Option<String>,
76    pub acquire_lock: bool,
77}
78
79/// Result of updating an issue.
80#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct IssueUpdateResult {
82    pub issue_id: String,
83    pub event_id: String,
84}
85
86/// Options for adding a comment.
87#[derive(Debug, Clone, Default, Serialize, Deserialize)]
88pub struct IssueCommentOptions {
89    pub issue_id: String,
90    pub body: String,
91    pub acquire_lock: bool,
92}
93
94/// Result of adding a comment.
95#[derive(Debug, Clone, Serialize, Deserialize)]
96pub struct IssueCommentResult {
97    pub issue_id: String,
98    pub event_id: String,
99}
100
101/// Options for changing issue state.
102#[derive(Debug, Clone, Default, Serialize, Deserialize)]
103pub struct IssueStateOptions {
104    pub issue_id: String,
105    pub acquire_lock: bool,
106}
107
108/// Result of changing issue state.
109#[derive(Debug, Clone, Serialize, Deserialize)]
110pub struct IssueStateResult {
111    pub issue_id: String,
112    pub event_id: String,
113    pub action: String,
114}
115
116/// Options for label operations.
117#[derive(Debug, Clone, Default, Serialize, Deserialize)]
118pub struct IssueLabelOptions {
119    pub issue_id: String,
120    pub add: Vec<String>,
121    pub remove: Vec<String>,
122    pub acquire_lock: bool,
123}
124
125/// Result of label operation.
126#[derive(Debug, Clone, Serialize, Deserialize)]
127pub struct IssueLabelResult {
128    pub issue_id: String,
129    pub event_id: String,
130}
131
132/// Options for assignee operations.
133#[derive(Debug, Clone, Default, Serialize, Deserialize)]
134pub struct IssueAssignOptions {
135    pub issue_id: String,
136    pub add: Vec<String>,
137    pub remove: Vec<String>,
138    pub acquire_lock: bool,
139}
140
141/// Result of assignee operation.
142#[derive(Debug, Clone, Serialize, Deserialize)]
143pub struct IssueAssignResult {
144    pub issue_id: String,
145    pub event_id: String,
146}
147
148/// Options for adding a link.
149#[derive(Debug, Clone, Default, Serialize, Deserialize)]
150pub struct IssueLinkOptions {
151    pub issue_id: String,
152    pub url: String,
153    pub note: Option<String>,
154    pub acquire_lock: bool,
155}
156
157/// Result of adding a link.
158#[derive(Debug, Clone, Serialize, Deserialize)]
159pub struct IssueLinkResult {
160    pub issue_id: String,
161    pub event_id: String,
162}
163
164/// Options for adding an attachment.
165#[derive(Debug, Clone, Default, Serialize, Deserialize)]
166pub struct IssueAttachOptions {
167    pub issue_id: String,
168    pub name: String,
169    pub sha256: String,
170    pub mime: String,
171    pub acquire_lock: bool,
172}
173
174/// Result of adding an attachment.
175#[derive(Debug, Clone, Serialize, Deserialize)]
176pub struct IssueAttachResult {
177    pub issue_id: String,
178    pub event_id: String,
179}
180
181/// Options for dependency operations.
182#[derive(Debug, Clone, Default, Serialize, Deserialize)]
183pub struct DepAddOptions {
184    pub issue_id: String,
185    pub target_id: String,
186    pub dep_type: String,
187    pub acquire_lock: bool,
188}
189
190/// Result of adding a dependency.
191#[derive(Debug, Clone, Serialize, Deserialize)]
192pub struct DepAddResult {
193    pub issue_id: String,
194    pub target_id: String,
195    pub event_id: String,
196}
197
198/// Options for removing a dependency.
199#[derive(Debug, Clone, Default, Serialize, Deserialize)]
200pub struct DepRemoveOptions {
201    pub issue_id: String,
202    pub target_id: String,
203    pub dep_type: String,
204    pub acquire_lock: bool,
205}
206
207/// Result of removing a dependency.
208#[derive(Debug, Clone, Serialize, Deserialize)]
209pub struct DepRemoveResult {
210    pub issue_id: String,
211    pub target_id: String,
212    pub event_id: String,
213}
214
215/// Options for listing dependencies.
216#[derive(Debug, Clone, Default, Serialize, Deserialize)]
217pub struct DepListOptions {
218    pub issue_id: String,
219    pub reverse: bool,
220}
221
222/// Result of listing dependencies.
223#[derive(Debug, Clone, Serialize, Deserialize)]
224pub struct DepListResult {
225    pub deps: Vec<libgrite_core::IssueProjection>,
226}
227
228/// Options for topological sort.
229#[derive(Debug, Clone, Default, Serialize, Deserialize)]
230pub struct DepTopoOptions {
231    pub state: Option<String>,
232    pub label: Option<String>,
233}
234
235/// Result of topological sort.
236#[derive(Debug, Clone, Serialize, Deserialize)]
237pub struct DepTopoResult {
238    pub issues: Vec<libgrite_core::IssueProjection>,
239}
240
241/// Options for actor init.
242#[derive(Debug, Clone, Default, Serialize, Deserialize)]
243pub struct ActorInitOptions {
244    pub label: Option<String>,
245    pub generate_key: bool,
246}
247
248/// Result of actor init.
249#[derive(Debug, Clone, Serialize, Deserialize)]
250pub struct ActorInitResult {
251    pub actor_id: String,
252    pub label: Option<String>,
253    pub data_dir: PathBuf,
254    pub public_key: Option<String>,
255}
256
257/// Options for actor show.
258#[derive(Debug, Clone, Default, Serialize, Deserialize)]
259pub struct ActorShowOptions {
260    pub id: Option<String>,
261}
262
263/// Options for actor use.
264#[derive(Debug, Clone, Default, Serialize, Deserialize)]
265pub struct ActorUseOptions {
266    pub id: String,
267}
268
269/// Result of actor list.
270#[derive(Debug, Clone, Serialize, Deserialize)]
271pub struct ActorListResult {
272    pub actors: Vec<libgrite_core::ActorConfig>,
273}
274
275/// Result of actor show/current.
276#[derive(Debug, Clone, Serialize, Deserialize)]
277pub struct ActorShowResult {
278    pub actor: libgrite_core::ActorConfig,
279    pub source: String,
280}
281
282/// Options for DB stats.
283#[derive(Debug, Clone, Default, Serialize, Deserialize)]
284pub struct DbStatsOptions {}
285
286/// Result of DB stats.
287#[derive(Debug, Clone, Serialize, Deserialize)]
288pub struct DbStatsResult {
289    pub path: PathBuf,
290    pub event_count: usize,
291    pub issue_count: usize,
292    pub size_bytes: u64,
293    pub last_rebuild_ts: Option<u64>,
294    pub events_since_rebuild: usize,
295    pub days_since_rebuild: Option<u32>,
296    pub rebuild_recommended: bool,
297}
298
299/// Options for DB check.
300#[derive(Debug, Clone, Default, Serialize, Deserialize)]
301pub struct DbCheckOptions {
302    pub verify_parents: bool,
303}
304
305/// Result of DB check.
306#[derive(Debug, Clone, Serialize, Deserialize)]
307pub struct DbCheckResult {
308    pub checked_events: usize,
309    pub hash_mismatches: Vec<String>,
310    pub parent_errors: Vec<String>,
311}
312
313/// Options for DB verify.
314#[derive(Debug, Clone, Default, Serialize, Deserialize)]
315pub struct DbVerifyOptions {
316    pub verbose: bool,
317}
318
319/// Result of DB verify.
320#[derive(Debug, Clone, Serialize, Deserialize)]
321pub struct DbVerifyResult {
322    pub checked_events: usize,
323    pub invalid_signatures: Vec<String>,
324}
325
326/// Export format.
327#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
328pub enum ExportFormat {
329    #[default]
330    Json,
331    Md,
332}
333
334/// Options for export.
335#[derive(Debug, Clone, Default, Serialize, Deserialize)]
336pub struct ExportOptions {
337    pub format: ExportFormat,
338    pub since: Option<String>,
339}
340
341/// Result of export.
342#[derive(Debug, Clone, Serialize, Deserialize)]
343pub struct ExportResult {
344    pub output_path: PathBuf,
345    pub event_count: usize,
346}
347
348/// Options for rebuild.
349#[derive(Debug, Clone, Default, Serialize, Deserialize)]
350pub struct RebuildOptions {
351    pub from_snapshot: bool,
352}
353
354/// Result of rebuild.
355#[derive(Debug, Clone, Serialize, Deserialize)]
356pub struct RebuildResult {
357    pub event_count: usize,
358    pub issue_count: usize,
359}
360
361/// Options for sync.
362#[derive(Debug, Clone, Default, Serialize, Deserialize)]
363pub struct SyncOptions {
364    pub remote: String,
365    pub pull: bool,
366    pub push: bool,
367}
368
369/// Result of sync.
370#[derive(Debug, Clone, Serialize, Deserialize)]
371pub struct SyncResult {
372    pub pulled_events: usize,
373    pub pushed_events: usize,
374}
375
376/// Options for snapshot create.
377#[derive(Debug, Clone, Default, Serialize, Deserialize)]
378pub struct SnapshotCreateOptions {}
379
380/// Result of snapshot create.
381#[derive(Debug, Clone, Serialize, Deserialize)]
382pub struct SnapshotCreateResult {
383    pub snapshot_ref: String,
384    pub event_count: usize,
385}
386
387/// Options for snapshot list.
388#[derive(Debug, Clone, Default, Serialize, Deserialize)]
389pub struct SnapshotListOptions {}
390
391/// A snapshot entry for listing.
392#[derive(Debug, Clone, Serialize, Deserialize)]
393pub struct SnapshotEntry {
394    pub oid: String,
395    pub timestamp: u64,
396    pub ref_name: String,
397}
398
399/// Result of snapshot list.
400#[derive(Debug, Clone, Serialize, Deserialize)]
401pub struct SnapshotListResult {
402    pub snapshots: Vec<SnapshotEntry>,
403}
404
405/// Options for snapshot gc.
406#[derive(Debug, Clone, Default, Serialize, Deserialize)]
407pub struct SnapshotGcOptions {
408    pub keep: usize,
409}
410
411/// Result of snapshot gc.
412#[derive(Debug, Clone, Serialize, Deserialize)]
413pub struct SnapshotGcResult {
414    pub removed: usize,
415}
416
417/// Options for daemon start.
418#[derive(Debug, Clone, Default, Serialize, Deserialize)]
419pub struct DaemonStartOptions {
420    pub idle_timeout: u64,
421}
422
423/// Result of daemon start.
424#[derive(Debug, Clone, Serialize, Deserialize)]
425pub struct DaemonStartResult {
426    pub pid: u32,
427    pub endpoint: String,
428}
429
430/// Result of daemon status.
431#[derive(Debug, Clone, Serialize, Deserialize)]
432pub struct DaemonStatusResult {
433    pub running: bool,
434    pub pid: Option<u32>,
435    pub endpoint: Option<String>,
436}
437
438/// Options for lock acquire.
439#[derive(Debug, Clone, Default, Serialize, Deserialize)]
440pub struct LockAcquireOptions {
441    pub resource: String,
442    pub ttl: u64,
443}
444
445/// Result of lock acquire.
446#[derive(Debug, Clone, Serialize, Deserialize)]
447pub struct LockAcquireResult {
448    pub resource: String,
449    pub expires_at: u64,
450}
451
452/// Options for lock release.
453#[derive(Debug, Clone, Default, Serialize, Deserialize)]
454pub struct LockReleaseOptions {
455    pub resource: String,
456}
457
458/// Options for lock renew.
459#[derive(Debug, Clone, Default, Serialize, Deserialize)]
460pub struct LockRenewOptions {
461    pub resource: String,
462    pub ttl: u64,
463}
464
465/// Result of lock renew.
466#[derive(Debug, Clone, Serialize, Deserialize)]
467pub struct LockRenewResult {
468    pub resource: String,
469    pub expires_at: u64,
470}
471
472/// Options for lock status.
473#[derive(Debug, Clone, Default, Serialize, Deserialize)]
474pub struct LockStatusOptions {}
475
476/// Result of lock status.
477#[derive(Debug, Clone, Serialize, Deserialize)]
478pub struct LockStatusResult {
479    pub locks: Vec<libgrite_core::Lock>,
480}
481
482/// Options for doctor.
483#[derive(Debug, Clone, Default, Serialize, Deserialize)]
484pub struct DoctorOptions {
485    pub fix: bool,
486}
487
488/// Result of doctor.
489#[derive(Debug, Clone, Serialize, Deserialize)]
490pub struct DoctorResult {
491    pub checks: Vec<DoctorCheckResult>,
492    pub fixed: Vec<String>,
493}
494
495/// Individual doctor check result.
496#[derive(Debug, Clone, Serialize, Deserialize)]
497pub struct DoctorCheckResult {
498    pub name: String,
499    pub ok: bool,
500    pub message: String,
501}
502
503/// Options for context index.
504#[derive(Debug, Clone, Default, Serialize, Deserialize)]
505pub struct ContextIndexOptions {
506    pub paths: Vec<String>,
507    pub force: bool,
508    pub pattern: Option<String>,
509}
510
511/// Result of context index.
512#[derive(Debug, Clone, Serialize, Deserialize)]
513pub struct ContextIndexResult {
514    pub indexed_files: usize,
515    pub indexed_symbols: usize,
516}
517
518/// Options for context query.
519#[derive(Debug, Clone, Default, Serialize, Deserialize)]
520pub struct ContextQueryOptions {
521    pub query: String,
522}
523
524/// Result of context query.
525#[derive(Debug, Clone, Serialize, Deserialize)]
526pub struct ContextQueryResult {
527    pub symbols: Vec<libgrite_core::SymbolInfo>,
528}
529
530/// Options for context show.
531#[derive(Debug, Clone, Default, Serialize, Deserialize)]
532pub struct ContextShowOptions {
533    pub path: String,
534}
535
536/// Result of context show.
537#[derive(Debug, Clone, Serialize, Deserialize)]
538pub struct ContextShowResult {
539    pub file: libgrite_core::FileContext,
540}
541
542/// Options for context project.
543#[derive(Debug, Clone, Default, Serialize, Deserialize)]
544pub struct ContextProjectOptions {
545    pub key: Option<String>,
546}
547
548/// Result of context project.
549#[derive(Debug, Clone, Serialize, Deserialize)]
550pub struct ContextProjectResult {
551    pub entries: Vec<libgrite_core::ProjectContextEntry>,
552}
553
554/// Options for context set.
555#[derive(Debug, Clone, Default, Serialize, Deserialize)]
556pub struct ContextSetOptions {
557    pub key: String,
558    pub value: String,
559}
560
561/// Result of context set.
562#[derive(Debug, Clone, Serialize, Deserialize)]
563pub struct ContextSetResult {
564    pub key: String,
565    pub event_id: String,
566}