diff options
| author | soryu <soryu@soryu.co> | 2026-01-19 13:47:32 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-19 13:47:32 +0000 |
| commit | 0833fb1f30c0c3b920157deb882e0e902c3af02a (patch) | |
| tree | 45110fb8cb9277dfbaccfeb53ed9c1f76975022b /makima/src/daemon/cli | |
| parent | 786510379bed060db2b3742b7dfca671552d2c34 (diff) | |
| download | soryu-0833fb1f30c0c3b920157deb882e0e902c3af02a.tar.gz soryu-0833fb1f30c0c3b920157deb882e0e902c3af02a.zip | |
Add interactive TUI browser for tasks, contracts, and files (makima view) (#7)
* feat(tui): Implement fuzzy search with real-time filtering and highlighting
Adds comprehensive fuzzy search functionality to the TUI browser:
## Fuzzy Matching (fuzzy.rs)
- FuzzyMatcher wrapper using SkimMatcherV2 from fuzzy-matcher crate
- fuzzy_match() returns score and matched character indices
- fuzzy_match_all() supports multi-term search (space-separated)
- Recency-aware scoring to boost recent items in results
- Unit tests for all matching scenarios
## App State (app.rs)
- FilteredItem struct with index, score, and matched_indices
- apply_filter() uses fuzzy matching with score-based sorting
- match_count() and has_no_matches() helper methods
- Results sorted by match score (highest first)
## List View (list_view.rs)
- Highlighted matched characters in search results
- Yellow bold styling for matched chars
- Status icons with color coding
## Search Input (search_input.rs)
- Real-time match count display (X/Y matches)
- Visual feedback for no matches (red border)
- Placeholder text when search is empty
- Active search mode indication (yellow border)
## Event Handling (event.rs)
- Arrow key navigation while in search mode
- Ctrl+K/J for vim-style navigation during search
- Delete key support alongside backspace
- Ctrl+U to clear search query
- Tab toggles preview while searching
- Escape clears search and exits search mode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Task completion checkpoint
* [WIP] Heartbeat checkpoint - 2026-01-19 11:20:34 UTC
* Task completion checkpoint
* [WIP] Heartbeat checkpoint - 2026-01-19 11:31:19 UTC
* Task completion checkpoint
* [WIP] Heartbeat checkpoint - 2026-01-19 11:39:07 UTC
* fix(tui): Fix module exports and main binary integration
- Update mod.rs to properly export app, event, fuzzy, and ui modules
- Add run() function for TUI entry point
- Fix run_view() to use ViewCommand enum instead of ViewArgs
- Fix event handling to use poll_event and handle_key_event
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/daemon/cli')
| -rw-r--r-- | makima/src/daemon/cli/mod.rs | 13 | ||||
| -rw-r--r-- | makima/src/daemon/cli/view.rs | 128 |
2 files changed, 141 insertions, 0 deletions
diff --git a/makima/src/daemon/cli/mod.rs b/makima/src/daemon/cli/mod.rs index cde6e16..842fa63 100644 --- a/makima/src/daemon/cli/mod.rs +++ b/makima/src/daemon/cli/mod.rs @@ -4,6 +4,7 @@ pub mod contract; pub mod daemon; pub mod server; pub mod supervisor; +pub mod view; use clap::{Parser, Subcommand}; @@ -11,6 +12,7 @@ pub use contract::ContractArgs; pub use daemon::DaemonArgs; pub use server::ServerArgs; pub use supervisor::SupervisorArgs; +pub use view::{ViewArgs, ViewCommand}; /// Makima - unified CLI for server, daemon, and task management. #[derive(Parser, Debug)] @@ -36,6 +38,17 @@ pub enum Commands { /// Contract commands for task-contract interaction #[command(subcommand)] Contract(ContractCommand), + + /// Interactive TUI browser for tasks, contracts, and files + /// + /// Provides a fuzzy-searchable interface with keyboard navigation. + /// + /// Keyboard shortcuts: + /// ↑/k: Move up ↓/j: Move down Enter: Select + /// /: Search Tab: Toggle preview q: Quit + /// e: Edit d: Delete c: cd to worktree + #[command(subcommand)] + View(ViewCommand), } /// Supervisor subcommands for contract orchestration. diff --git a/makima/src/daemon/cli/view.rs b/makima/src/daemon/cli/view.rs new file mode 100644 index 0000000..f42c490 --- /dev/null +++ b/makima/src/daemon/cli/view.rs @@ -0,0 +1,128 @@ +//! View subcommand - interactive TUI browser for tasks, contracts, and files. +//! +//! The `makima view` command provides an interactive Terminal User Interface (TUI) +//! for browsing and managing makima entities. It features fuzzy search filtering, +//! keyboard navigation, and quick actions. +//! +//! # Usage +//! +//! ```bash +//! # Browse tasks interactively +//! makima view tasks +//! +//! # Browse contracts with an initial search query +//! makima view contracts "my project" +//! +//! # Browse files without preview pane +//! makima view files --no-preview +//! +//! # Browse tasks for a specific contract +//! makima view tasks --contract-id <uuid> +//! +//! # Change directory to selected task's worktree +//! cd $(makima view tasks) +//! ``` +//! +//! # Keyboard Shortcuts +//! +//! | Key | Action | +//! |-------------|---------------------------| +//! | `↑` / `k` | Move selection up | +//! | `↓` / `j` | Move selection down | +//! | `Enter` | View/select item | +//! | `e` | Open in editor ($EDITOR) | +//! | `d` | Delete item (with confirm)| +//! | `Tab` | Toggle preview pane | +//! | `/` | Focus search input | +//! | `Esc` | Clear search / cancel | +//! | `q` | Quit | +//! | `c` | Navigate to worktree (cd) | +//! | `Ctrl+r` | Refresh data | +//! | `?` | Show help | +//! +//! # Features +//! +//! - **Fuzzy Search**: Type to filter items in real-time +//! - **Multi-term Search**: Use space-separated terms (e.g., "fix bug") +//! - **Recency Sorting**: Recent items appear higher in results +//! - **Preview Pane**: See item details without leaving the list +//! - **Status Indicators**: Visual icons for task states + +use clap::{Args, Subcommand}; +use uuid::Uuid; + +/// Interactive TUI browser for tasks, contracts, and files. +/// +/// Provides a fuzzy-searchable interface for browsing and managing +/// makima entities with keyboard navigation and quick actions. +/// +/// # Examples +/// +/// Browse tasks: +/// ```bash +/// makima view tasks +/// ``` +/// +/// Browse with initial search: +/// ```bash +/// makima view contracts "auth" +/// ``` +#[derive(Subcommand, Debug)] +pub enum ViewCommand { + /// Browse tasks interactively + /// + /// Shows all tasks for the current contract with status indicators, + /// fuzzy search filtering, and quick actions. + Tasks(ViewArgs), + + /// Browse contracts interactively + /// + /// Lists all contracts with their phase, status, and task counts. + Contracts(ViewArgs), + + /// Browse files interactively + /// + /// Shows contract files with preview of their content. + Files(ViewArgs), +} + +/// Common arguments for view commands. +/// +/// These arguments are shared across all view subcommands (tasks, contracts, files). +#[derive(Args, Debug, Clone)] +pub struct ViewArgs { + /// API URL for the makima server + #[arg(long, env = "MAKIMA_API_URL", default_value = "https://api.makima.jp")] + pub api_url: String, + + /// API key for authentication + #[arg(long, env = "MAKIMA_API_KEY")] + pub api_key: String, + + /// Contract ID to filter results (optional) + /// + /// When specified, only shows items belonging to this contract. + #[arg(long, env = "MAKIMA_CONTRACT_ID")] + pub contract_id: Option<Uuid>, + + /// Initial search query + /// + /// Pre-populates the search field with this query when the TUI opens. + #[arg(index = 1)] + pub query: Option<String>, + + /// Disable the preview pane + /// + /// Shows only the item list without the side preview panel. + /// Useful for smaller terminal windows. + #[arg(long)] + pub no_preview: bool, + + /// Sort order for results + /// + /// - `recent`: Sort by last updated time (default) + /// - `name`: Sort alphabetically by name + /// - `status`: Group by status, then by name + #[arg(long, default_value = "recent")] + pub sort: String, +} |
