libgrite-cli 0.5.3

Programmatic CLI library for grite: issue tracking, sync, and context management
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

/// Options for resolving the grite context (mirrors CLI global flags).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ResolveOptions {
    /// Override the data directory
    pub data_dir: Option<PathBuf>,

    /// Override the actor ID
    pub actor: Option<String>,
}

/// Options for `grite init`.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct InitOptions {
    /// Skip creating/updating AGENTS.md
    pub no_agents_md: bool,
}

/// Result of `grite init`.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InitResult {
    pub actor_id: String,
    pub data_dir: PathBuf,
    pub created_agents_md: bool,
}

/// Options for creating an issue.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueCreateOptions {
    pub title: String,
    pub body: String,
    pub labels: Vec<String>,
}

/// Result of creating an issue.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueCreateResult {
    pub issue_id: String,
    pub event_id: String,
}

/// Options for listing issues.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueListOptions {
    pub state: Option<String>,
    pub label: Option<String>,
}

/// Result of listing issues.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueListResult {
    pub issues: Vec<libgrite_core::IssueSummary>,
}

/// Options for showing an issue.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueShowOptions {
    pub issue_id: String,
}

/// Result of showing an issue.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueShowResult {
    pub issue: libgrite_core::IssueProjection,
    pub events: Vec<libgrite_core::Event>,
}

/// Options for updating an issue.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueUpdateOptions {
    pub issue_id: String,
    pub title: Option<String>,
    pub body: Option<String>,
    pub acquire_lock: bool,
}

/// Result of updating an issue.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueUpdateResult {
    pub issue_id: String,
    pub event_id: String,
}

/// Options for adding a comment.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueCommentOptions {
    pub issue_id: String,
    pub body: String,
    pub acquire_lock: bool,
}

/// Result of adding a comment.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueCommentResult {
    pub issue_id: String,
    pub event_id: String,
}

/// Options for changing issue state.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueStateOptions {
    pub issue_id: String,
    pub acquire_lock: bool,
}

/// Result of changing issue state.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueStateResult {
    pub issue_id: String,
    pub event_id: String,
    pub action: String,
}

/// Options for label operations.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueLabelOptions {
    pub issue_id: String,
    pub add: Vec<String>,
    pub remove: Vec<String>,
    pub acquire_lock: bool,
}

/// Result of label operation.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueLabelResult {
    pub issue_id: String,
    pub event_id: String,
}

/// Options for assignee operations.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueAssignOptions {
    pub issue_id: String,
    pub add: Vec<String>,
    pub remove: Vec<String>,
    pub acquire_lock: bool,
}

/// Result of assignee operation.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueAssignResult {
    pub issue_id: String,
    pub event_id: String,
}

/// Options for adding a link.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueLinkOptions {
    pub issue_id: String,
    pub url: String,
    pub note: Option<String>,
    pub acquire_lock: bool,
}

/// Result of adding a link.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueLinkResult {
    pub issue_id: String,
    pub event_id: String,
}

/// Options for adding an attachment.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct IssueAttachOptions {
    pub issue_id: String,
    pub name: String,
    pub sha256: String,
    pub mime: String,
    pub acquire_lock: bool,
}

/// Result of adding an attachment.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IssueAttachResult {
    pub issue_id: String,
    pub event_id: String,
}

/// Options for dependency operations.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DepAddOptions {
    pub issue_id: String,
    pub target_id: String,
    pub dep_type: String,
    pub acquire_lock: bool,
}

/// Result of adding a dependency.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DepAddResult {
    pub issue_id: String,
    pub target_id: String,
    pub event_id: String,
}

/// Options for removing a dependency.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DepRemoveOptions {
    pub issue_id: String,
    pub target_id: String,
    pub dep_type: String,
    pub acquire_lock: bool,
}

/// Result of removing a dependency.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DepRemoveResult {
    pub issue_id: String,
    pub target_id: String,
    pub event_id: String,
}

/// Options for listing dependencies.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DepListOptions {
    pub issue_id: String,
    pub reverse: bool,
}

/// Result of listing dependencies.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DepListResult {
    pub deps: Vec<libgrite_core::IssueProjection>,
}

/// Options for topological sort.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DepTopoOptions {
    pub state: Option<String>,
    pub label: Option<String>,
}

/// Result of topological sort.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DepTopoResult {
    pub issues: Vec<libgrite_core::IssueProjection>,
}

/// Options for actor init.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ActorInitOptions {
    pub label: Option<String>,
    pub generate_key: bool,
}

/// Result of actor init.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActorInitResult {
    pub actor_id: String,
    pub label: Option<String>,
    pub data_dir: PathBuf,
    pub public_key: Option<String>,
}

/// Options for actor show.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ActorShowOptions {
    pub id: Option<String>,
}

/// Options for actor use.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ActorUseOptions {
    pub id: String,
}

/// Result of actor list.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActorListResult {
    pub actors: Vec<libgrite_core::ActorConfig>,
}

/// Result of actor show/current.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActorShowResult {
    pub actor: libgrite_core::ActorConfig,
    pub source: String,
}

/// Options for DB stats.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DbStatsOptions {}

/// Result of DB stats.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DbStatsResult {
    pub path: PathBuf,
    pub event_count: usize,
    pub issue_count: usize,
    pub size_bytes: u64,
    pub last_rebuild_ts: Option<u64>,
    pub events_since_rebuild: usize,
    pub days_since_rebuild: Option<u32>,
    pub rebuild_recommended: bool,
}

/// Options for DB check.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DbCheckOptions {
    pub verify_parents: bool,
}

/// Result of DB check.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DbCheckResult {
    pub checked_events: usize,
    pub hash_mismatches: Vec<String>,
    pub parent_errors: Vec<String>,
}

/// Options for DB verify.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DbVerifyOptions {
    pub verbose: bool,
}

/// Result of DB verify.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DbVerifyResult {
    pub checked_events: usize,
    pub invalid_signatures: Vec<String>,
}

/// Export format.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum ExportFormat {
    #[default]
    Json,
    Md,
}

/// Options for export.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ExportOptions {
    pub format: ExportFormat,
    pub since: Option<String>,
}

/// Result of export.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExportResult {
    pub output_path: PathBuf,
    pub event_count: usize,
}

/// Options for rebuild.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct RebuildOptions {
    pub from_snapshot: bool,
}

/// Result of rebuild.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RebuildResult {
    pub event_count: usize,
    pub issue_count: usize,
}

/// Options for sync.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct SyncOptions {
    pub remote: String,
    pub pull: bool,
    pub push: bool,
}

/// Result of sync.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SyncResult {
    pub pulled_events: usize,
    pub pushed_events: usize,
}

/// Options for snapshot create.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct SnapshotCreateOptions {}

/// Result of snapshot create.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SnapshotCreateResult {
    pub snapshot_ref: String,
    pub event_count: usize,
}

/// Options for snapshot list.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct SnapshotListOptions {}

/// A snapshot entry for listing.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SnapshotEntry {
    pub oid: String,
    pub timestamp: u64,
    pub ref_name: String,
}

/// Result of snapshot list.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SnapshotListResult {
    pub snapshots: Vec<SnapshotEntry>,
}

/// Options for snapshot gc.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct SnapshotGcOptions {
    pub keep: usize,
}

/// Result of snapshot gc.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SnapshotGcResult {
    pub removed: usize,
}

/// Options for daemon start.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DaemonStartOptions {
    pub idle_timeout: u64,
}

/// Result of daemon start.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DaemonStartResult {
    pub pid: u32,
    pub endpoint: String,
}

/// Result of daemon status.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DaemonStatusResult {
    pub running: bool,
    pub pid: Option<u32>,
    pub endpoint: Option<String>,
}

/// Options for lock acquire.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct LockAcquireOptions {
    pub resource: String,
    pub ttl: u64,
}

/// Result of lock acquire.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LockAcquireResult {
    pub resource: String,
    pub expires_at: u64,
}

/// Options for lock release.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct LockReleaseOptions {
    pub resource: String,
}

/// Options for lock renew.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct LockRenewOptions {
    pub resource: String,
    pub ttl: u64,
}

/// Result of lock renew.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LockRenewResult {
    pub resource: String,
    pub expires_at: u64,
}

/// Options for lock status.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct LockStatusOptions {}

/// Result of lock status.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LockStatusResult {
    pub locks: Vec<libgrite_core::Lock>,
}

/// Options for doctor.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DoctorOptions {
    pub fix: bool,
}

/// Result of doctor.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DoctorResult {
    pub checks: Vec<DoctorCheckResult>,
    pub fixed: Vec<String>,
}

/// Individual doctor check result.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DoctorCheckResult {
    pub name: String,
    pub ok: bool,
    pub message: String,
}

/// Options for context index.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextIndexOptions {
    pub paths: Vec<String>,
    pub force: bool,
    pub pattern: Option<String>,
}

/// Result of context index.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextIndexResult {
    pub indexed_files: usize,
    pub indexed_symbols: usize,
}

/// Options for context query.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextQueryOptions {
    pub query: String,
}

/// Result of context query.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextQueryResult {
    pub symbols: Vec<libgrite_core::SymbolInfo>,
}

/// Options for context show.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextShowOptions {
    pub path: String,
}

/// Result of context show.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextShowResult {
    pub file: libgrite_core::FileContext,
}

/// Options for context project.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextProjectOptions {
    pub key: Option<String>,
}

/// Result of context project.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextProjectResult {
    pub entries: Vec<libgrite_core::ProjectContextEntry>,
}

/// Options for context set.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextSetOptions {
    pub key: String,
    pub value: String,
}

/// Result of context set.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextSetResult {
    pub key: String,
    pub event_id: String,
}