AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
fix(autoindex): a usage error prints the error and one --help pointer, not the help page (#1586) (#1592)
ordinary beinge0dd8922b4f9
diff --git a/engine/crates/xerj-autoindex/src/lib.rs b/engine/crates/xerj-autoindex/src/lib.rsindex bbb167eb3..4e85db9bd 100644--- a/engine/crates/xerj-autoindex/src/lib.rs+++ b/engine/crates/xerj-autoindex/src/lib.rs@@ -1653,8 +1653,12 @@ pub fn run_cli() -> i32 {let cmd = match cli::parse(args) {Ok(c) => c,Err(e) => {- eprintln!("error: {e}\n");- cli::print_help();+ // #1586: a usage error is the error plus one pointer line. The+ // 390-line help page used to follow on stdout, which buried the+ // error for anyone reading stdout or the tail of combined output —+ // an agent saw help and concluded the run had done something.+ eprintln!("error: {e}");+ eprintln!("run `xerj autoindex --help` for usage.");return 2;}};diff --git a/engine/crates/xerj-server/tests/autoindex_usage_error.rs b/engine/crates/xerj-server/tests/autoindex_usage_error.rsnew file mode 100644index 000000000..82fc4f79a--- /dev/null+++ b/engine/crates/xerj-server/tests/autoindex_usage_error.rs@@ -0,0 +1,50 @@+//! #1586: a usage error is the error plus one line pointing at `--help`,+//! never the help page itself.+//!+//! Before this, any `xerj autoindex` usage error wrote one throwaway line to+//! stderr and the 390-line help page to stdout. An agent that reads stdout, or+//! the tail of combined output, saw only help — nothing said the run had done+//! nothing, and the field report's agent concluded the first folder had been+//! indexed.+//!+//! This test drives the real binary: the exit code, the empty stdout, and the+//! two-line stderr are the contract. It uses `--approve full` (a value error)+//! so it does not depend on the second-folder message from the sibling PR.++use std::process::Command;++#[test]+fn autoindex_usage_error_prints_the_error_and_one_help_pointer() {+ let out = Command::new(env!("CARGO_BIN_EXE_xerj"))+ .args(["autoindex", "--approve", "full"])+ .output()+ .expect("run the xerj binary");++ assert_eq!(out.status.code(), Some(2), "usage errors exit 2");++ let stdout = String::from_utf8_lossy(&out.stdout);+ assert!(+ stdout.is_empty(),+ "a usage error must not write the help page to stdout:\n{stdout}"+ );++ let stderr = String::from_utf8_lossy(&out.stderr);+ let lines: Vec<&str> = stderr.lines().collect();+ assert_eq!(+ lines.len(),+ 2,+ "the whole stderr is the error and one pointer, got:\n{stderr}"+ );+ assert!(+ lines[0].starts_with("error: "),+ "first line must be the error: {stderr}"+ );+ assert!(+ lines[0].contains("--approve full is not one of"),+ "the actual usage error must survive: {stderr}"+ );+ assert!(+ lines[1].contains("xerj autoindex --help"),+ "second line must point at the full help: {stderr}"+ );+}