feat: add ctx similar — pre-implementation reuse check#3
Merged
Conversation
Thin wrapper over embedding search scoped to function/method symbols. Each hit reports a one-line doc (brief, falling back to the first sentence of the docstring), the similarity score, and fan-in so an agent can judge whether an established utility already exists. - Kind scoping via over-fetch (limit * 3) and filter; no schema changes - Missing embeddings is an operational error (exit 2) with a hint to run 'ctx embed' or use --keyword - --keyword routes to the FTS5 hybrid_search fallback that needs no embeddings or API key - --json emits the standard envelope (command: similar) with an empty results array when nothing matches
- docs/json-output.md: 'similar' payload, score semantics per mode, and exit-code behavior - README: command reference entry with the agent workflow (run 'ctx similar' before writing a new function; reuse strong matches) - CHANGELOG: Unreleased entry
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 5 of 7 in the Quality Intelligence Suite. Stacked on #2 (
feat/quality-foundation) — will be retargeted tomainonce #2 merges; review only the top 2 commits until then.ctx similar "<description>"command: semantic search scoped to function/method symbols, enriched with fan_in (is this an established utility?) and a one-line brief (falling back to the docstring's first sentence), so a coding agent can decide to reuse instead of rewrite.ctx embed, or use--keyword).--keywordfallback routes to FTS5hybrid_search— works offline with no API key.--jsonemits the standard envelope (docs/json-output.mdupdated with per-mode score semantics); empty results still emit a valid envelope.ctx similarbefore writing a new function).Test plan
callsedges, brief fallback, JSON payloads.cargo test(191 green),clippy -D warnings,fmt --check,--no-default-featuresbuild — all clean; smoke-tested against a scratch project.🤖 Generated with Claude Code