Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/cortex-cli/src/agent_cmd/handlers/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ use crate::agent_cmd::utils::matches_pattern;

/// List agents command.
pub async fn run_list(args: ListArgs) -> Result<()> {
tracing::debug!(
all = args.all,
primary = args.primary,
subagents = args.subagents,
remote = args.remote,
filter = ?args.filter,
"listing agents"
);

// Validate mutually exclusive flags
if args.primary && args.subagents {
bail!(
Expand All @@ -31,6 +40,7 @@ pub async fn run_list(args: ListArgs) -> Result<()> {
}

let agents = load_all_agents()?;
tracing::debug!(total_agents = agents.len(), "loaded agent definitions");

// Filter agents
let mut filtered: Vec<_> = agents
Expand All @@ -56,6 +66,7 @@ pub async fn run_list(args: ListArgs) -> Result<()> {
true
})
.collect();
tracing::debug!(filtered_agents = filtered.len(), "filtered agent list");

// Sort by display_name (if present) or name for user-friendly ordering
// This ensures agents are listed in the order users expect (by visible name)
Expand Down
16 changes: 16 additions & 0 deletions src/cortex-cli/src/github_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ fn get_help_message() -> String {
/// Check GitHub Actions installation status.
async fn run_status(args: StatusArgs) -> Result<()> {
let repo_path = args.path.unwrap_or_else(|| PathBuf::from("."));
tracing::debug!(
path = %repo_path.display(),
json = args.json,
"checking GitHub Actions installation status"
);

let mut status = InstallationStatus::default();

Expand All @@ -601,6 +606,10 @@ async fn run_status(args: StatusArgs) -> Result<()> {
if content.contains("Cortex") {
status.workflow_installed = true;
status.workflow_path = Some(path.clone());
tracing::debug!(
workflow_path = %path.display(),
"found Cortex workflow"
);

// Check workflow features
if content.contains("issue_comment") {
Expand All @@ -623,6 +632,13 @@ async fn run_status(args: StatusArgs) -> Result<()> {

// Check if we're in a git repo
status.is_git_repo = repo_path.join(".git").exists();
tracing::debug!(
is_git_repo = status.is_git_repo,
github_dir_exists = status.github_dir_exists,
workflow_installed = status.workflow_installed,
features = ?status.features,
"computed GitHub Actions installation status"
);

if args.json {
let json = serde_json::to_string_pretty(&status)?;
Expand Down
102 changes: 102 additions & 0 deletions src/cortex-cli/tests/verbose_output.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
use std::fs;
use std::process::Command;

use tempfile::tempdir;

fn combined_output(output: &std::process::Output) -> String {
format!(
"{}{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
)
}

#[test]
fn verbose_agent_list_adds_diagnostics() {
let home_dir = tempdir().unwrap();

let normal = Command::new(env!("CARGO_BIN_EXE_Cortex"))
.args(["agent", "list"])
.env("HOME", home_dir.path())
.env_remove("CORTEX_HOME")
.output()
.unwrap();
assert!(
normal.status.success(),
"normal agent list failed:\n{}",
combined_output(&normal)
);

let verbose = Command::new(env!("CARGO_BIN_EXE_Cortex"))
.args(["--verbose", "agent", "list"])
.env("HOME", home_dir.path())
.env_remove("CORTEX_HOME")
.output()
.unwrap();
assert!(
verbose.status.success(),
"verbose agent list failed:\n{}",
combined_output(&verbose)
);

let normal_output = combined_output(&normal);
let verbose_output = combined_output(&verbose);
assert_ne!(normal_output, verbose_output);
assert!(verbose_output.contains("listing agents"));
}

#[test]
fn verbose_github_status_adds_diagnostics() {
let repo = tempdir().unwrap();
fs::create_dir(repo.path().join(".git")).unwrap();
let workflows_dir = repo.path().join(".github").join("workflows");
fs::create_dir_all(&workflows_dir).unwrap();
fs::write(
workflows_dir.join("Cortex.yml"),
r#"# Cortex CI/CD Automation
# Generated by: cortex github install

name: Cortex

on:
workflow_dispatch:

jobs:
cortex:
runs-on: ubuntu-latest
steps: []
"#,
)
.unwrap();

let normal = Command::new(env!("CARGO_BIN_EXE_Cortex"))
.args(["github", "status", "--path", repo.path().to_str().unwrap()])
.output()
.unwrap();
assert!(
normal.status.success(),
"normal github status failed:\n{}",
combined_output(&normal)
);

let verbose = Command::new(env!("CARGO_BIN_EXE_Cortex"))
.args([
"--verbose",
"github",
"status",
"--path",
repo.path().to_str().unwrap(),
])
.output()
.unwrap();
assert!(
verbose.status.success(),
"verbose github status failed:\n{}",
combined_output(&verbose)
);

let normal_output = combined_output(&normal);
let verbose_output = combined_output(&verbose);
assert_ne!(normal_output, verbose_output);
assert!(verbose_output.contains("checking GitHub Actions installation status"));
}