grite 0.5.3

Git-backed issue tracker with CRDT merging, designed for AI coding agents
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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;

#[derive(Parser)]
#[command(name = "grite", about = "Git-backed issue tracking", version)]
pub struct Cli {
    /// Output in JSON format
    #[arg(long, global = true)]
    pub json: bool,

    /// Suppress human-readable output
    #[arg(long, global = true)]
    pub quiet: bool,

    /// Override the data directory
    #[arg(long, global = true)]
    pub data_dir: Option<PathBuf>,

    /// Override the actor ID
    #[arg(long, global = true)]
    pub actor: Option<String>,

    /// Force local execution (skip daemon)
    #[arg(long, global = true)]
    pub no_daemon: bool,

    #[command(subcommand)]
    pub command: Command,
}

#[derive(Subcommand)]
pub enum Command {
    /// Initialize grite in the current repository
    Init {
        /// Skip creating/updating AGENTS.md
        #[arg(long)]
        no_agents_md: bool,
    },

    /// Actor management commands
    Actor {
        #[command(subcommand)]
        cmd: ActorCommand,
    },

    /// Issue management commands
    Issue {
        #[command(subcommand)]
        cmd: IssueCommand,
    },

    /// Database management commands
    Db {
        #[command(subcommand)]
        cmd: DbCommand,
    },

    /// Export issues to file
    Export {
        /// Export format
        #[arg(long)]
        format: ExportFormat,

        /// Export changes since timestamp or event ID
        #[arg(long)]
        since: Option<String>,
    },

    /// Rebuild local database from events
    Rebuild {
        /// Use latest snapshot as base (faster for large repos)
        #[arg(long)]
        from_snapshot: bool,
    },

    /// Sync with remote repository
    Sync {
        /// Remote name (default: origin)
        #[arg(long, default_value = "origin")]
        remote: String,

        /// Pull only (don't push)
        #[arg(long)]
        pull: bool,

        /// Push only (don't pull)
        #[arg(long)]
        push: bool,
    },

    /// Snapshot management
    Snapshot {
        #[command(subcommand)]
        cmd: SnapshotCommand,
    },

    /// Daemon management
    Daemon {
        #[command(subcommand)]
        cmd: DaemonCommand,
    },

    /// Lock management for team coordination
    Lock {
        #[command(subcommand)]
        cmd: LockCommand,
    },

    /// Run health checks and optionally repair issues
    Doctor {
        /// Automatically fix issues where possible
        #[arg(long)]
        fix: bool,
    },

    /// Context store management (file/symbol indexing)
    Context {
        #[command(subcommand)]
        cmd: ContextCommand,
    },

    /// Install the Claude Code skill for grite
    InstallSkill {
        /// Install globally instead of per-repo
        #[arg(long)]
        global: bool,

        /// Force overwrite if skill already exists
        #[arg(long)]
        force: bool,
    },
}

#[derive(Clone, Subcommand)]
pub enum ActorCommand {
    /// Create a new actor
    Init {
        /// Human-friendly label for the actor
        #[arg(long)]
        label: Option<String>,

        /// Generate Ed25519 signing key for this actor
        #[arg(long)]
        generate_key: bool,
    },

    /// List all actors
    List,

    /// Show actor details
    Show {
        /// Actor ID (defaults to current)
        id: Option<String>,
    },

    /// Show current actor
    Current,

    /// Set the default actor
    Use {
        /// Actor ID to use as default
        id: String,
    },
}

#[derive(Clone, Subcommand)]
pub enum IssueCommand {
    /// Create a new issue
    Create {
        /// Issue title
        #[arg(long, allow_hyphen_values = true)]
        title: String,

        /// Issue body
        #[arg(long, default_value = "", allow_hyphen_values = true)]
        body: String,

        /// Labels to add
        #[arg(long)]
        label: Vec<String>,
    },

    /// List issues
    List {
        /// Filter by state
        #[arg(long)]
        state: Option<String>,

        /// Filter by label
        #[arg(long)]
        label: Option<String>,
    },

    /// Show issue details
    Show {
        /// Issue ID
        id: String,
    },

    /// Update an issue
    Update {
        /// Issue ID
        id: String,

        /// New title
        #[arg(long, allow_hyphen_values = true)]
        title: Option<String>,

        /// New body
        #[arg(long, allow_hyphen_values = true)]
        body: Option<String>,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },

    /// Add a comment to an issue
    Comment {
        /// Issue ID
        id: String,

        /// Comment body
        #[arg(long, allow_hyphen_values = true)]
        body: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },

    /// Close an issue
    Close {
        /// Issue ID
        id: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },

    /// Reopen an issue
    Reopen {
        /// Issue ID
        id: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },

    /// Label operations
    Label {
        #[command(subcommand)]
        cmd: LabelCommand,
    },

    /// Assignee operations
    Assignee {
        #[command(subcommand)]
        cmd: AssigneeCommand,
    },

    /// Link operations
    Link {
        #[command(subcommand)]
        cmd: LinkCommand,
    },

    /// Attachment operations
    Attachment {
        #[command(subcommand)]
        cmd: AttachmentCommand,
    },

    /// Dependency operations
    Dep {
        #[command(subcommand)]
        cmd: DepCommand,
    },
}

#[derive(Clone, Subcommand)]
pub enum LabelCommand {
    /// Add a label to an issue
    Add {
        /// Issue ID
        id: String,

        /// Label to add
        #[arg(long)]
        label: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },

    /// Remove a label from an issue
    Remove {
        /// Issue ID
        id: String,

        /// Label to remove
        #[arg(long)]
        label: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },
}

#[derive(Clone, Subcommand)]
pub enum AssigneeCommand {
    /// Add an assignee to an issue
    Add {
        /// Issue ID
        id: String,

        /// User to assign
        #[arg(long)]
        user: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },

    /// Remove an assignee from an issue
    Remove {
        /// Issue ID
        id: String,

        /// User to unassign
        #[arg(long)]
        user: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },
}

#[derive(Clone, Subcommand)]
pub enum LinkCommand {
    /// Add a link to an issue
    Add {
        /// Issue ID
        id: String,

        /// URL to link
        #[arg(long)]
        url: String,

        /// Optional note
        #[arg(long, allow_hyphen_values = true)]
        note: Option<String>,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },
}

#[derive(Clone, Subcommand)]
pub enum AttachmentCommand {
    /// Add an attachment reference to an issue
    Add {
        /// Issue ID
        id: String,

        /// Attachment name
        #[arg(long)]
        name: String,

        /// SHA256 hash of the attachment
        #[arg(long)]
        sha256: String,

        /// MIME type
        #[arg(long)]
        mime: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },
}

#[derive(Clone, Subcommand)]
pub enum DbCommand {
    /// Show database statistics
    Stats,

    /// Check database integrity (hash verification)
    Check {
        /// Also verify parent event references
        #[arg(long)]
        verify_parents: bool,
    },

    /// Verify event signatures
    Verify {
        /// Show details for each event
        #[arg(long)]
        verbose: bool,
    },
}

#[derive(Clone, Subcommand)]
pub enum SnapshotCommand {
    /// Create a new snapshot
    Create,

    /// List all snapshots
    List,

    /// Garbage collect old snapshots
    Gc {
        /// Number of snapshots to keep
        #[arg(long, default_value = "5")]
        keep: usize,
    },
}

#[derive(Clone, ValueEnum)]
pub enum ExportFormat {
    Json,
    Md,
}

#[derive(Clone, Subcommand)]
pub enum DaemonCommand {
    /// Start the daemon in background
    Start {
        /// Idle timeout in seconds (daemon auto-stops after this period of inactivity)
        #[arg(long, default_value = "300")]
        idle_timeout: u64,
    },

    /// Show daemon status
    Status,

    /// Stop the daemon
    Stop,
}

#[derive(Clone, Subcommand)]
pub enum LockCommand {
    /// Acquire a lock on a resource
    Acquire {
        /// Resource to lock (e.g., "repo:global", "issue:abc123", "path:src/")
        resource: String,

        /// Lock duration in seconds (default: 300)
        #[arg(long, default_value = "300")]
        ttl: u64,
    },

    /// Release a lock
    Release {
        /// Resource to unlock
        resource: String,
    },

    /// Renew a lock's TTL
    Renew {
        /// Resource to renew
        resource: String,

        /// New lock duration in seconds (default: 300)
        #[arg(long, default_value = "300")]
        ttl: u64,
    },

    /// Show lock status
    Status,

    /// Garbage collect expired locks
    Gc,
}

#[derive(Clone, Subcommand)]
pub enum DepCommand {
    /// Add a dependency between issues
    Add {
        /// Source issue ID (the issue that has the dependency)
        id: String,

        /// Target issue ID (the issue being depended on / blocked)
        #[arg(long)]
        target: String,

        /// Dependency type: blocks, depends_on, related_to
        #[arg(long, default_value = "depends_on")]
        r#type: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },

    /// Remove a dependency between issues
    Remove {
        /// Source issue ID
        id: String,

        /// Target issue ID
        #[arg(long)]
        target: String,

        /// Dependency type: blocks, depends_on, related_to
        #[arg(long, default_value = "depends_on")]
        r#type: String,

        /// Acquire lock before operation, release after
        #[arg(long)]
        lock: bool,
    },

    /// List dependencies for an issue
    List {
        /// Issue ID
        id: String,

        /// Show reverse dependencies (what depends on this issue)
        #[arg(long)]
        reverse: bool,
    },

    /// Show topological order of issues based on dependencies
    Topo {
        /// Filter by state
        #[arg(long)]
        state: Option<String>,

        /// Filter by label
        #[arg(long)]
        label: Option<String>,
    },
}

#[derive(Clone, Subcommand)]
pub enum ContextCommand {
    /// Index files in the repository
    Index {
        /// Specific paths to index (default: all tracked files)
        #[arg(long)]
        path: Vec<String>,

        /// Force re-index even if hash unchanged
        #[arg(long)]
        force: bool,

        /// Only index files matching glob pattern
        #[arg(long)]
        pattern: Option<String>,
    },

    /// Query the context store for symbols
    Query {
        /// Search query (symbol name)
        query: String,
    },

    /// Show context for a specific file
    Show {
        /// File path
        path: String,
    },

    /// Show or set project-level context
    Project {
        /// Key to show (or all if omitted)
        key: Option<String>,
    },

    /// Set a project-level context entry
    Set {
        /// Key to set
        key: String,

        /// Value to set
        value: String,
    },
}