feat(related): add semantic similarity discovery command
Implement `lore related` command for discovering semantically similar entities using vector embeddings. Supports two modes: Entity mode: lore related issues 42 # Find entities similar to issue #42 lore related mrs 99 # Find entities similar to MR !99 Query mode: lore related "auth bug" # Find entities matching free text query Key features: - Uses existing embedding infrastructure (nomic-embed-text via Ollama) - Computes shared labels between source and results - Shows similarity scores as percentage (0-100%) - Warns when all results have low similarity (<30%) - Warns for short queries (<=2 words) that may produce noisy results - Filters out discussion/note documents, returning only issues and MRs - Handles orphaned documents gracefully (skips if entity deleted) - Robot mode JSON output with {ok, data, meta} envelope Implementation details: - distance_to_similarity() converts L2 distance to 0-1 score: 1/(1+distance) - Uses saturating_add/saturating_mul for overflow safety on limit parameter - Proper error handling for missing embeddings ("run lore embed first") - Project scoping via -p flag with fuzzy matching CLI integration: - Added to autocorrect.rs command registry - Added Related variant to Commands enum in cli/mod.rs - Wired into main.rs with handle_related() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -293,6 +293,28 @@ pub enum Commands {
|
||||
project: Option<String>,
|
||||
},
|
||||
|
||||
/// Find semantically related entities via vector search
|
||||
#[command(after_help = "\x1b[1mExamples:\x1b[0m
|
||||
lore related issues 42 # Find entities related to issue #42
|
||||
lore related mrs 99 -p group/repo # Related to MR #99 in specific project
|
||||
lore related 'authentication flow' # Find entities matching free text query
|
||||
lore --robot related issues 42 -n 5 # JSON output, limit 5 results")]
|
||||
Related {
|
||||
/// Entity type (issues, mrs) or free text query
|
||||
query_or_type: String,
|
||||
|
||||
/// Entity IID (required when first arg is entity type)
|
||||
iid: Option<i64>,
|
||||
|
||||
/// Maximum results
|
||||
#[arg(short = 'n', long, default_value = "10")]
|
||||
limit: usize,
|
||||
|
||||
/// Scope to project (fuzzy match)
|
||||
#[arg(short, long)]
|
||||
project: Option<String>,
|
||||
},
|
||||
|
||||
/// Manage cron-based automatic syncing
|
||||
#[command(after_help = "\x1b[1mExamples:\x1b[0m
|
||||
lore cron install # Install cron job (every 8 minutes)
|
||||
|
||||
Reference in New Issue
Block a user