ππΌββοΈ The blackboard for coding agents - agentic development environment for claude code, codex, cursor, opencode, grok and more.
Rust adeai-agentsclaudeclaude-codecodexcursorgeminigrokopencodespec-driven-developmentvibe-codingvim
feat: add codex, gemini, copilot cli (#21)
Fynn FlΓΌgge7346a5cee083
diff --git a/README.md b/README.mdindex 8b4b5e0..bab9cc3 100644--- a/README.md+++ b/README.md@@ -8,7 +8,7 @@- **Kanban workflow**: Backlog β Planning β Running β Review β Done- **Git worktree and tmux isolation**: Each task gets its own worktree and tmux window, keeping work separated-- **Claude Code integration**: Automatic session management with resume capability+- **Coding Agent integrations**: Automatic session management for Claude Code, Codex, Gemini and Copilot CLI- **PR workflow**: Generate descriptions with AI, create PRs directly from the TUI- **Multi-project dashboard**: Manage tasks across all your projects- **Customizable themes**: Configure colors via config file@@ -32,7 +32,7 @@ cp target/release/agtx ~/.local/bin/- **tmux** - Agent sessions run in a dedicated tmux server- **gh** - GitHub CLI for PR operations-- **claude** - Claude Code CLI+- Supported coding agents: [Claude Code](https://github.com/anthropics/claude-code), [Codex](https://github.com/openai/codex), [Gemini](https://github.com/google-gemini/gemini-cli), [Copilot](https://github.com/github/copilot-cli)## Quick Start@@ -72,7 +72,7 @@ agtx -g2. **Move to Planning** (`m`): Creates worktree, starts Claude in planning mode3. **Move to Running** (`m`): Claude implements the plan4. **Move to Review** (`m`): Opens PR with AI-generated description-5. **Move to Done** (`m`): Cleans up after PR is merged+5. **Move to Done** (`m`): Cleans up worktree and tmux after PR is merged### Claude Session Features@@ -157,6 +157,7 @@ and before the agent session starts.β Git Worktrees ββ .agtx/worktrees/task2/ ββ .agtx/worktrees/task3/ β+ β .agtx/worktrees/task4/ ββββββββββββββββββββββββββββββ```@@ -179,7 +180,7 @@ tmux -L agtx attach### Data Storage-- **Database**: `~/.config/agtx/` (stores task metadata per project)+- **Database**: `~/Library/Application Support/agtx/` (macOS) or `~/.local/share/agtx/` (Linux)- **Worktrees**: `.agtx/worktrees/` in each project- **Tmux**: Dedicated server `agtx` with per-project sessionsdiff --git a/src/agent/mod.rs b/src/agent/mod.rsindex 57f715c..e1f0cf5 100644--- a/src/agent/mod.rs+++ b/src/agent/mod.rs@@ -42,23 +42,14 @@ impl Agent {"claude" => {format!("claude --dangerously-skip-permissions '{}'", escaped_prompt)}- "aider" => {- format!("aider --message '{}'", escaped_prompt)- }"codex" => {- format!("codex '{}'", escaped_prompt)- }- "gh-copilot" => {- format!("gh copilot suggest '{}'", escaped_prompt)- }- "opencode" => {- format!("opencode '{}'", escaped_prompt)+ format!("codex --approval-mode full-auto '{}'", escaped_prompt)}- "cline" => {- format!("cline '{}'", escaped_prompt)+ "copilot" => {+ format!("copilot --allow-all-tools -p '{}'", escaped_prompt)}- "q" => {- format!("q chat '{}'", escaped_prompt)+ "gemini" => {+ format!("gemini -p '{}'", escaped_prompt)}_ => {format!("{} '{}'", self.command, escaped_prompt)@@ -71,12 +62,13 @@ impl Agent {pub fn known_agents() -> Vec<Agent> {vec![Agent::new("claude", "claude", "Anthropic's Claude Code CLI", "Claude <[email protected]>"),- Agent::new("aider", "aider", "AI pair programming in your terminal", "Aider <[email protected]>"),Agent::new("codex", "codex", "OpenAI's Codex CLI", "Codex <[email protected]>"),- Agent::new("gh-copilot", "gh", "GitHub Copilot CLI", "GitHub Copilot <[email protected]>"),- Agent::new("opencode", "opencode", "AI-powered coding assistant", "OpenCode <[email protected]>"),- Agent::new("cline", "cline", "AI coding assistant for VS Code", "Cline <[email protected]>"),- Agent::new("q", "q", "Amazon Q Developer CLI", "Amazon Q <[email protected]>"),+ Agent::new("copilot", "copilot", "GitHub Copilot CLI", "GitHub Copilot <[email protected]>"),+ Agent::new("gemini", "gemini", "Google Gemini CLI", "Gemini <[email protected]>"),+ // TODO: investigate CLI usage before enabling+ // Agent::new("aider", "aider", "AI pair programming in your terminal", "Aider <[email protected]>"),+ // Agent::new("opencode", "opencode", "AI-powered coding assistant", "OpenCode <[email protected]>"),+ // Agent::new("cline", "cline", "AI coding assistant for VS Code", "Cline <[email protected]>"),]}@@ -93,21 +85,6 @@ pub fn get_agent(name: &str) -> Option<Agent> {known_agents().into_iter().find(|a| a.name == name)}-/// Find the default agent (first available from preference order)-pub fn default_agent() -> Option<Agent> {- let preference_order = ["claude", "aider", "codex", "gh-copilot", "opencode", "cline", "q"];-- for name in preference_order {- if let Some(agent) = get_agent(name) {- if agent.is_available() {- return Some(agent);- }- }- }-- None-}-/// Agent availability status for display#[derive(Debug)]pub struct AgentStatus {@@ -126,6 +103,23 @@ pub fn all_agent_status() -> Vec<AgentStatus> {.collect()}+/// Parse user input for agent selection.+/// Returns the index (0-based) of the selected agent, or None for invalid input.+/// Empty input returns Some(0) (first agent as default).+pub fn parse_agent_selection(input: &str, agent_count: usize) -> Option<usize> {+ let input = input.trim();+ if input.is_empty() {+ return Some(0);+ }+ if let Ok(num) = input.parse::<usize>() {+ if num >= 1 && num <= agent_count {+ return Some(num - 1);+ }+ }+ None+}++/// Build the command arguments for spawning an agentpub fn build_spawn_args(agent: &Agent, prompt: &str, task_id: &str) -> Vec<String> {let mut args = agent.args.clone();@@ -136,14 +130,8 @@ pub fn build_spawn_args(agent: &Agent, prompt: &str, task_id: &str) -> Vec<Strinargs.extend(["--session".to_string(), task_id.to_string()]);args.push(prompt.to_string());}- "aider" => {- // Aider uses --message for the initial prompt- args.extend(["--message".to_string(), prompt.to_string()]);- }- "gh-copilot" => {- // GitHub Copilot needs subcommand- args.extend(["copilot".to_string(), "suggest".to_string()]);- args.push(prompt.to_string());+ "copilot" => {+ args.extend(["-p".to_string(), prompt.to_string()]);}_ => {// Default: just pass the promptdiff --git a/src/agent/operations.rs b/src/agent/operations.rsindex 5b67872..1dae96f 100644--- a/src/agent/operations.rs+++ b/src/agent/operations.rs@@ -37,13 +37,6 @@ impl CodingAgent {pub fn new(agent: Agent) -> Self {Self { agent }}-- /// Create a CodingAgent for the default available agent- pub fn default() -> Self {- let agent = super::default_agent()- .unwrap_or_else(|| super::get_agent("claude").unwrap());- Self::new(agent)- }}impl AgentOperations for CodingAgent {@@ -51,12 +44,9 @@ impl AgentOperations for CodingAgent {// Build the command based on agent typelet (cmd, args) = match self.agent.name.as_str() {"claude" => ("claude", vec!["--print", prompt]),- "aider" => ("aider", vec!["--message", prompt, "--no-auto-commits"]),- "codex" => ("codex", vec!["--print", prompt]),- "gh-copilot" => ("gh", vec!["copilot", "explain", prompt]),- "opencode" => ("opencode", vec!["--print", prompt]),- "cline" => ("cline", vec!["--print", prompt]),- "q" => ("q", vec!["chat", "--no-interactive", prompt]),+ "codex" => ("codex", vec!["-q", prompt]),+ "copilot" => ("copilot", vec!["-p", prompt]),+ "gemini" => ("gemini", vec!["-p", prompt]),_ => (self.agent.command.as_str(), vec![prompt]),};diff --git a/src/config/mod.rs b/src/config/mod.rsindex d521ead..c4afaa0 100644--- a/src/config/mod.rs+++ b/src/config/mod.rs@@ -220,10 +220,10 @@ impl GlobalConfig {}/// Get the path to the global config file+ /// Always uses ~/.config/agtx/ on all platformspub fn config_path() -> Result<PathBuf> {- let dirs = directories::ProjectDirs::from("", "", "agtx")- .context("Could not determine config directory")?;- Ok(dirs.config_dir().join("config.toml"))+ let home = std::env::var("HOME").context("Could not determine home directory")?;+ Ok(PathBuf::from(home).join(".config").join("agtx").join("config.toml"))}/// Get the path to the global data directory@@ -263,6 +263,38 @@ impl ProjectConfig {}}+/// Action to take on first run based on config/data state.+#[derive(Debug, PartialEq)]+pub enum FirstRunAction {+ /// Config file already exists β nothing to do+ ConfigExists,+ /// Old config was found and migrated to new location+ Migrated,+ /// Existing user (has database) but no config file β save defaults silently+ ExistingUserSaveDefaults,+ /// New user β prompt for agent selection+ NewUserPrompt,+}++/// Determine what first-run action to take.+/// Pure logic β no side effects β so it's easily testable.+pub fn determine_first_run_action(+ config_exists: bool,+ migrated: bool,+ db_exists: bool,+) -> FirstRunAction {+ if config_exists {+ return FirstRunAction::ConfigExists;+ }+ if migrated {+ return FirstRunAction::Migrated;+ }+ if db_exists {+ return FirstRunAction::ExistingUserSaveDefaults;+ }+ FirstRunAction::NewUserPrompt+}+/// Merged configuration (global + project)#[derive(Debug, Clone)]pub struct MergedConfig {diff --git a/src/main.rs b/src/main.rsindex f7baedb..1d5c1e1 100644--- a/src/main.rs+++ b/src/main.rs@@ -1,5 +1,12 @@-use agtx::{git, tui, AppMode};+use agtx::{agent, config::{self, GlobalConfig}, git, tui, AppMode};use anyhow::Result;+use crossterm::{+ cursor,+ event::{self, Event, KeyCode},+ style::{self, Stylize},+ terminal, ExecutableCommand,+};+use std::io::{self, Write};use std::path::PathBuf;#[tokio::main]@@ -22,9 +29,155 @@ async fn main() -> Result<()> {}};+ // First-run: determine action based on config/data state+ let config_path = GlobalConfig::config_path()?;+ let config_exists = config_path.exists();+ let migrated = if !config_exists {+ migrate_old_config(&config_path)+ } else {+ false+ };+ let db_exists = GlobalConfig::data_dir()+ .map(|d| d.join("index.db").exists())+ .unwrap_or(false);++ match config::determine_first_run_action(config_exists, migrated, db_exists) {+ config::FirstRunAction::ConfigExists | config::FirstRunAction::Migrated => {}+ config::FirstRunAction::ExistingUserSaveDefaults => {+ GlobalConfig::default().save()?;+ }+ config::FirstRunAction::NewUserPrompt => {+ let available = agent::detect_available_agents();+ if !available.is_empty() {+ let selected = prompt_agent_selection(&available)?;+ let mut cfg = GlobalConfig::default();+ cfg.default_agent = selected.name.clone();+ cfg.save()?;+ }+ }+ }+// Initialize and run the applet mut app = tui::App::new(mode)?;app.run().await?;Ok(())}++/// Migrate config from the old location (directories crate config_dir) to the new one (~/.config/agtx/).+/// Returns true if migration was performed.+fn migrate_old_config(new_path: &std::path::Path) -> bool {+ let old_path = directories::ProjectDirs::from("", "", "agtx")+ .map(|dirs| dirs.config_dir().join("config.toml"));++ if let Some(old_path) = old_path {+ if old_path != *new_path && old_path.exists() {+ // Create parent directory for new path+ if let Some(parent) = new_path.parent() {+ let _ = std::fs::create_dir_all(parent);+ }+ // Copy old config to new location+ if std::fs::copy(&old_path, new_path).is_ok() {+ // Remove old file after successful copy+ let _ = std::fs::remove_file(&old_path);+ return true;+ }+ }+ }+ false+}++fn prompt_agent_selection(agents: &[agent::Agent]) -> Result<&agent::Agent> {+ let mut stdout = io::stdout();+ let mut selected: usize = 0;++ // Enter raw mode for arrow key handling+ terminal::enable_raw_mode()?;+ stdout.execute(cursor::Hide)?;++ // Print ASCII art banner+ let banner: &[(&str, &str)] = &[+ (" ββββββ βββββββ ββββββββββββ βββ", ""),+ (" ββββββββββββββββ βββββββββββββββββ", ""),+ (" βββββββββββ ββββ βββ ββββββ ", " Autonomous multi-session"),+ (" βββββββββββ βββ βββ ββββββ ", " AI coding in the terminal"),+ (" βββ ββββββββββββ βββ ββββ βββ", ""),+ (" βββ βββ βββββββ βββ βββ βββ", ""),+ ];+ stdout.execute(style::Print("\r\n"))?;+ for (art, tagline) in banner {+ stdout.execute(style::PrintStyledContent((*art).cyan()))?;+ if !tagline.is_empty() {+ stdout.execute(style::PrintStyledContent((*tagline).dark_grey()))?;+ }+ stdout.execute(style::Print("\r\n"))?;+ }+ stdout.execute(style::Print("\r\n"))?;+ stdout.execute(style::Print(" Select your default coding agent "))?;+ stdout.execute(style::PrintStyledContent("(can be changed later via config)\r\n\r\n".dark_grey()))?;++ // Draw the list+ let draw = |stdout: &mut io::Stdout, selected: usize| -> Result<()> {+ for (i, a) in agents.iter().enumerate() {+ if i == selected {+ stdout.execute(style::PrintStyledContent(" > ".cyan()))?;+ stdout.execute(style::PrintStyledContent(a.name.as_str().cyan().bold()))?;+ let desc = format!(" - {}", a.description);+ stdout.execute(style::PrintStyledContent(desc.as_str().dark_grey()))?;+ } else {+ stdout.execute(style::Print(" "))?;+ stdout.execute(style::Print(&a.name))?;+ let desc = format!(" - {}", a.description);+ stdout.execute(style::PrintStyledContent(desc.as_str().dark_grey()))?;+ }+ stdout.execute(style::Print("\r\n"))?;+ }+ stdout.execute(style::Print("\r\n"))?;+ stdout.execute(style::PrintStyledContent("\n".dark_grey()))?;+ stdout.flush()?;+ Ok(())+ };++ draw(&mut stdout, selected)?;++ let result = loop {+ if let Event::Key(key) = event::read()? {+ match key.code {+ KeyCode::Up | KeyCode::Char('k') => {+ if selected > 0 {+ selected -= 1;+ }+ }+ KeyCode::Down | KeyCode::Char('j') => {+ if selected < agents.len() - 1 {+ selected += 1;+ }+ }+ KeyCode::Enter => break Ok(selected),+ KeyCode::Esc | KeyCode::Char('q') => {+ break Err(anyhow::anyhow!("Selection cancelled"));+ }+ KeyCode::Char('c')+ if key.modifiers.contains(event::KeyModifiers::CONTROL) =>+ {+ break Err(anyhow::anyhow!("Selection cancelled"));+ }+ _ => continue,+ }++ // Move cursor back up to redraw+ let lines_to_move_up = agents.len() + 2; // agents + blank + hint+ stdout.execute(cursor::MoveUp(lines_to_move_up as u16))?;+ stdout.execute(cursor::MoveToColumn(0))?;+ draw(&mut stdout, selected)?;+ }+ };++ // Restore terminal+ stdout.execute(cursor::Show)?;+ terminal::disable_raw_mode()?;++ let idx = result?;+ println!("\n Selected: {}\n", agents[idx].name);+ Ok(&agents[idx])+}diff --git a/src/tui/app.rs b/src/tui/app.rsindex 40597d1..ca14193 100644--- a/src/tui/app.rs+++ b/src/tui/app.rs@@ -1760,9 +1760,57 @@ impl App {}fn handle_dashboard_key(&mut self, key: KeyCode) -> Result<()> {- match key {- KeyCode::Char('q') => self.state.should_quit = true,- _ => {}+ if self.state.show_project_list {+ match key {+ KeyCode::Char('q') => self.state.should_quit = true,+ KeyCode::Char('j') | KeyCode::Down => {+ if self.state.selected_project < self.state.projects.len().saturating_sub(1) {+ self.state.selected_project += 1;+ }+ }+ KeyCode::Char('k') | KeyCode::Up => {+ if self.state.selected_project > 0 {+ self.state.selected_project -= 1;+ }+ }+ KeyCode::Enter => {+ if let Some(project) = self.state.projects.get(self.state.selected_project).cloned() {+ self.switch_to_project(&project)?;+ self.state.mode = AppMode::Project(PathBuf::from(&project.path));+ self.state.sidebar_visible = false;+ }+ }+ KeyCode::Esc => {+ self.state.show_project_list = false;+ }+ _ => {}+ }+ } else {+ match key {+ KeyCode::Char('q') => self.state.should_quit = true,+ KeyCode::Char('p') => {+ self.state.show_project_list = true;+ }+ KeyCode::Char('n') => {+ let current_dir = std::env::current_dir()?;+ if crate::git::is_git_repo(¤t_dir) {+ let canonical = current_dir.canonicalize().unwrap_or(current_dir);+ let name = canonical+ .file_name()+ .and_then(|n| n.to_str())+ .unwrap_or("unknown")+ .to_string();+ let project = ProjectInfo {+ name: name.clone(),+ path: canonical.to_string_lossy().to_string(),+ };+ self.switch_to_project(&project)?;+ self.state.mode = AppMode::Project(canonical);+ self.state.sidebar_visible = false;+ }+ }+ _ => {}+ }}Ok(())}diff --git a/tests/agent_tests.rs b/tests/agent_tests.rsnew file mode 100644index 0000000..6d72679--- /dev/null+++ b/tests/agent_tests.rs@@ -0,0 +1,42 @@+use agtx::agent::parse_agent_selection;++#[test]+fn test_parse_agent_selection_empty_defaults_to_first() {+ assert_eq!(parse_agent_selection("", 3), Some(0));+ assert_eq!(parse_agent_selection(" ", 3), Some(0));+ assert_eq!(parse_agent_selection("\n", 3), Some(0));+}++#[test]+fn test_parse_agent_selection_valid_numbers() {+ assert_eq!(parse_agent_selection("1", 3), Some(0));+ assert_eq!(parse_agent_selection("2", 3), Some(1));+ assert_eq!(parse_agent_selection("3", 3), Some(2));+}++#[test]+fn test_parse_agent_selection_trims_whitespace() {+ assert_eq!(parse_agent_selection(" 2 ", 3), Some(1));+ assert_eq!(parse_agent_selection("1\n", 3), Some(0));+}++#[test]+fn test_parse_agent_selection_out_of_range() {+ assert_eq!(parse_agent_selection("0", 3), None);+ assert_eq!(parse_agent_selection("4", 3), None);+ assert_eq!(parse_agent_selection("100", 3), None);+}++#[test]+fn test_parse_agent_selection_invalid_input() {+ assert_eq!(parse_agent_selection("abc", 3), None);+ assert_eq!(parse_agent_selection("-1", 3), None);+ assert_eq!(parse_agent_selection("1.5", 3), None);+}++#[test]+fn test_parse_agent_selection_single_agent() {+ assert_eq!(parse_agent_selection("1", 1), Some(0));+ assert_eq!(parse_agent_selection("2", 1), None);+ assert_eq!(parse_agent_selection("", 1), Some(0));+}diff --git a/tests/config_tests.rs b/tests/config_tests.rsindex 8845817..6603ef7 100644--- a/tests/config_tests.rs+++ b/tests/config_tests.rs@@ -1,4 +1,7 @@-use agtx::config::{GlobalConfig, ProjectConfig, WorktreeConfig, ThemeConfig, MergedConfig};+use agtx::config::{+ determine_first_run_action, FirstRunAction, GlobalConfig, MergedConfig, ProjectConfig,+ ThemeConfig, WorktreeConfig,+};// === ThemeConfig Tests ===@@ -114,3 +117,55 @@ fn test_merged_config_project_overrides() {assert_eq!(merged.copy_files, Some(".env, .env.local".to_string()));assert_eq!(merged.init_script, Some("npm install".to_string()));}++// === FirstRunAction Tests ===++#[test]+fn test_first_run_config_exists() {+ assert_eq!(+ determine_first_run_action(true, false, false),+ FirstRunAction::ConfigExists,+ );+}++#[test]+fn test_first_run_config_exists_ignores_other_flags() {+ // Config exists takes priority over everything+ assert_eq!(+ determine_first_run_action(true, true, true),+ FirstRunAction::ConfigExists,+ );+}++#[test]+fn test_first_run_migrated() {+ assert_eq!(+ determine_first_run_action(false, true, false),+ FirstRunAction::Migrated,+ );+}++#[test]+fn test_first_run_migrated_with_db() {+ // Migration takes priority over DB existence+ assert_eq!(+ determine_first_run_action(false, true, true),+ FirstRunAction::Migrated,+ );+}++#[test]+fn test_first_run_existing_user_save_defaults() {+ assert_eq!(+ determine_first_run_action(false, false, true),+ FirstRunAction::ExistingUserSaveDefaults,+ );+}++#[test]+fn test_first_run_new_user_prompt() {+ assert_eq!(+ determine_first_run_action(false, false, false),+ FirstRunAction::NewUserPrompt,+ );+}