Extends the CLI with six new commands that complete the search pipeline: - lore search <QUERY>: Hybrid search with mode selection (lexical, hybrid, semantic), rich filtering (--type, --author, --project, --label, --path, --after, --updated-after), result limits, and optional explain mode showing RRF score breakdowns. Safe FTS mode sanitizes user input; raw mode passes through for power users. - lore stats: Document and index statistics with optional --check for integrity verification and --repair to fix inconsistencies (orphaned documents, missing FTS entries, stale dirty queue items). - lore embed: Generate vector embeddings via Ollama. Supports --retry-failed to re-attempt previously failed embeddings. - lore generate-docs: Drain the dirty queue to regenerate documents. --full seeds all entities for complete rebuild. --project scopes to a single project. - lore sync: Full pipeline orchestration (ingest issues + MRs, generate-docs, embed) with --no-embed and --no-docs flags for partial runs. Reports per-stage results and total elapsed time. - lore health: Quick pre-flight check (config exists, DB exists, schema current). Returns exit code 1 if unhealthy. Designed for agent pre-flight scripts. - lore robot-docs: Machine-readable command manifest for agent self-discovery. Returns all commands, flags, examples, exit codes, and recommended workflows as structured JSON. Also enhances lore init with --gitlab-url, --token-env-var, and --projects flags for fully non-interactive robot-mode initialization. Fixes init's force/non-interactive precedence logic and adds JSON output for robot mode. Updates all command files for the GiError -> LoreError rename. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
//! Auth test command - verify GitLab authentication.
|
|
|
|
use crate::core::config::Config;
|
|
use crate::core::error::{LoreError, Result};
|
|
use crate::gitlab::GitLabClient;
|
|
|
|
/// Result of successful auth test.
|
|
pub struct AuthTestResult {
|
|
pub username: String,
|
|
pub name: String,
|
|
pub base_url: String,
|
|
}
|
|
|
|
/// Run the auth-test command.
|
|
pub async fn run_auth_test(config_path: Option<&str>) -> Result<AuthTestResult> {
|
|
// 1. Load config
|
|
let config = Config::load(config_path)?;
|
|
|
|
// 2. Get token from environment
|
|
let token = std::env::var(&config.gitlab.token_env_var)
|
|
.map(|t| t.trim().to_string())
|
|
.map_err(|_| LoreError::TokenNotSet {
|
|
env_var: config.gitlab.token_env_var.clone(),
|
|
})?;
|
|
|
|
if token.is_empty() {
|
|
return Err(LoreError::TokenNotSet {
|
|
env_var: config.gitlab.token_env_var.clone(),
|
|
});
|
|
}
|
|
|
|
// 3. Create client and test auth
|
|
let client = GitLabClient::new(&config.gitlab.base_url, &token, None);
|
|
|
|
// 4. Get current user
|
|
let user = client.get_current_user().await?;
|
|
|
|
Ok(AuthTestResult {
|
|
username: user.username,
|
|
name: user.name,
|
|
base_url: config.gitlab.base_url,
|
|
})
|
|
}
|