Skip to main content

sift_queue/
lib.rs

1pub mod cli;
2pub mod queue;
3pub mod queue_path;
4
5use clap::{Parser, Subcommand};
6use std::path::PathBuf;
7
8#[derive(Parser)]
9#[command(name = "sq", about = "Manage Sift's review queue")]
10pub struct Cli {
11    /// Path to queue file
12    #[arg(short = 'q', long = "queue", value_name = "PATH", global = true)]
13    pub queue: Option<PathBuf>,
14
15    #[command(subcommand)]
16    pub command: Commands,
17}
18
19#[derive(Subcommand)]
20pub enum Commands {
21    /// Add a new item to the review queue
22    Add(AddArgs),
23    /// List queue items
24    List(ListArgs),
25    /// Show details of a queue item
26    Show(ShowArgs),
27    /// Edit an existing queue item
28    Edit(EditArgs),
29    /// Remove an item from the queue
30    Rm(RmArgs),
31    /// Output sift workflow context for AI agents
32    Prime(PrimeArgs),
33}
34
35#[derive(Parser)]
36pub struct AddArgs {
37    /// Add diff source (repeatable)
38    #[arg(long = "diff", value_name = "PATH")]
39    pub diff: Vec<String>,
40
41    /// Add file source (repeatable)
42    #[arg(long = "file", value_name = "PATH")]
43    pub file: Vec<String>,
44
45    /// Add text source (repeatable)
46    #[arg(long = "text", value_name = "STRING")]
47    pub text: Vec<String>,
48
49    /// Add directory source (repeatable)
50    #[arg(long = "directory", value_name = "PATH")]
51    pub directory: Vec<String>,
52
53    /// Read source content from stdin (diff|file|text|directory)
54    #[arg(long = "stdin", value_name = "TYPE")]
55    pub stdin: Option<String>,
56
57    /// Title for the item
58    #[arg(long = "title", value_name = "TITLE")]
59    pub title: Option<String>,
60
61    /// Attach metadata as JSON
62    #[arg(long = "metadata", value_name = "JSON")]
63    pub metadata: Option<String>,
64
65    /// Comma-separated blocker IDs
66    #[arg(long = "blocked-by", value_name = "IDS")]
67    pub blocked_by: Option<String>,
68}
69
70#[derive(Parser)]
71pub struct ListArgs {
72    /// Filter by status (pending|in_progress|closed)
73    #[arg(long = "status", value_name = "STATUS")]
74    pub status: Option<String>,
75
76    /// Output as JSON
77    #[arg(long = "json")]
78    pub json: bool,
79
80    /// jq select expression
81    #[arg(long = "filter", value_name = "EXPR")]
82    pub filter: Option<String>,
83
84    /// jq path expression to sort by
85    #[arg(long = "sort", value_name = "PATH")]
86    pub sort: Option<String>,
87
88    /// Reverse sort order
89    #[arg(long = "reverse")]
90    pub reverse: bool,
91
92    /// Show only ready items (pending and unblocked)
93    #[arg(long = "ready")]
94    pub ready: bool,
95}
96
97#[derive(Parser)]
98pub struct ShowArgs {
99    /// Item ID
100    pub id: Option<String>,
101
102    /// Output as JSON
103    #[arg(long = "json")]
104    pub json: bool,
105}
106
107#[derive(Parser)]
108pub struct EditArgs {
109    /// Item ID
110    pub id: Option<String>,
111
112    /// Add diff source
113    #[arg(long = "add-diff", value_name = "PATH")]
114    pub add_diff: Vec<String>,
115
116    /// Add file source
117    #[arg(long = "add-file", value_name = "PATH")]
118    pub add_file: Vec<String>,
119
120    /// Add text source
121    #[arg(long = "add-text", value_name = "STRING")]
122    pub add_text: Vec<String>,
123
124    /// Add directory source
125    #[arg(long = "add-directory", value_name = "PATH")]
126    pub add_directory: Vec<String>,
127
128    /// Add transcript source
129    #[arg(long = "add-transcript", value_name = "PATH")]
130    pub add_transcript: Vec<String>,
131
132    /// Remove source by index (0-based, repeatable)
133    #[arg(long = "rm-source", value_name = "INDEX")]
134    pub rm_source: Vec<usize>,
135
136    /// Change status (pending|in_progress|closed)
137    #[arg(long = "set-status", value_name = "STATUS")]
138    pub set_status: Option<String>,
139
140    /// Set title for the item
141    #[arg(long = "set-title", value_name = "TITLE")]
142    pub set_title: Option<String>,
143
144    /// Set metadata as JSON
145    #[arg(long = "set-metadata", value_name = "JSON")]
146    pub set_metadata: Option<String>,
147
148    /// Set blocker IDs (comma-separated, empty to clear)
149    #[arg(long = "set-blocked-by", value_name = "IDS")]
150    pub set_blocked_by: Option<String>,
151}
152
153#[derive(Parser)]
154pub struct RmArgs {
155    /// Item ID
156    pub id: Option<String>,
157}
158
159#[derive(Parser)]
160pub struct PrimeArgs {
161    /// Force full CLI output
162    #[arg(long = "full")]
163    pub full: bool,
164}