feat: add vector-space code indexing and semantic search support
🚀 Feature Request
📌 Problem
The Codex CLI currently provides powerful completions via the Completions API, but it lacks semantic code search. Developers must fall back to grep or file-name heuristics, which:
• Miss semantically similar code when names differ
• Are brittle across large or polyglot codebases
• Don’t leverage project-specific patterns or style
💡 Proposed Solution
Introduce first-class support for vector embeddings and approximate-nearest-neighbor search:
- New CLI Commands
Build/update a vector index over your code
codex index --vector [--db faiss|pinecone|qdrant] [--src PATH]
Perform semantic search by intent
codex search --vector "<natural language query>" [--top K] [--filter EXT|PATH|TAG]
- Indexing Behavior
• Walk the source tree (default .)
• Split files into logical chunks (functions, classes)
• Call the OpenAI Embeddings API (e.g. ada-code-002)
• Bulk-load vectors + metadata (file paths, byte offsets) into the chosen vector store
- Search Behavior
• Embed the user’s query
• Run an ANN lookup (cosine similarity or L2)
• Return the top-K snippets with file paths, line ranges, and relevance scores
- Configuration
• New settings in ~/.codex/config.json for API key, embedding model, vector-db connection, and default chunk size
• Sensible defaults: in-process FAISS for small repos
🔧 Alternatives Considered
• External scripts using the OpenAI client + vector-db libraries
• Keyword-based grepping via codex grep or shell pipelines
• Manual code navigation in IDEs without semantic awareness
📝 Additional Context & Use Cases
• Improved Completions: Retrieve project-specific helpers before calling the Completions API, reducing prompt noise.
• “Related Code” Sidebar: IDE plugins (VS Code, IntelliJ, Neovim) can call codex search --vector under the hood to power a live “Related Code” panel.
• Duplication Detection: Find near-duplicate functions or patterns for refactoring.
• RAG Workflows: Enable retrieval-augmented generation using your own code as context.
⸻
I’m happy to contribute a PR that scaffolds the new CLI commands and demonstrates basic FAISS integration. Please let me know if there’s interest in adding this feature!
5 Comments
I'd love to see this implemented. for now here is an alternative: https://github.com/qdrant/mcp-server-qdrant
Hey! Thank you for the feature suggestion. This is not currently on our roadmap, and in order to keep our open list of issues maintainable, we'll close this for now. Appreciate the input!
@dedrisian-oai Is it possible to share your thinking behind it? I.e. why vectors search wouldn't help much or why is it hard to implement?
I'm also curious. This is probably the only thing keeping me going back to Cursor.
Definitely needed for large code bases