Skip to content

A Context-aware, low-latency command-line autocomplete shell integration powered by Trie, FAISS, and LLMs.

Notifications You must be signed in to change notification settings

dm4p385/shell-sage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– ShellSage

✨ Context-aware, low-latency command-line autocomplete powered by Trie, FAISS, and LLMs.

ShellSage is my attempt at an intelligent autocomplete engine for your terminal that combines the speed of Trie-based search, the semantic understanding of FAISS, and the reasoning capabilities of LLMs to provide blazing-fast, contextually relevant command suggestions.

NOTE: This is only supported in fish at the moment


πŸš€ Features

  • ⚑ Low-latency Suggestions using Trie prefix search
  • 🧠 Context-aware Search using FAISS semantic embeddings
  • πŸ€– LLM-Powered Completions to refine and personalize suggestions
  • πŸ“š User Command History Integration
  • πŸ“ƒοΈ Hybrid Ranking Engine combining all sources
  • 🧡 gRPC-based Streaming API for interactive clients
  • πŸ’Ύ FAISS Cache to reuse LLM results and reduce API latency
  • πŸ” Modular, extensible engine built in Python

πŸ—οΈ Architecture

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚   Terminal  β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
               gRPC backend client
                        β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   ShellSage Core  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”‚β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚             β”‚              β”‚              β”‚
TrieSearch   FaissSearch   LLMCompletion   FaissCache
(prefix)     (semantic)     (GPT-like)     (embedding cache)

βš™οΈ Installation

# Clone the repo
git clone https://github.com/your-username/shellsage.git
cd shellsage

# Set up virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Install ollama
<install ollama>

# Pull mistral
ollama pull mistral

πŸ₯ͺ Running the Server

python -m src.api.server

This will start the gRPC server on localhost:50051. It uses a thread pool executor and gracefully handles streamed prompts from clients.


🧠 Core Components

Component Description
TrieSearch Fast prefix matching from shell history
FaissSearch Vector search using sentence embeddings
LLMCompletion Calls local AI model to refine suggestions
FaissCache Embedding-keyed cache to avoid redundant LLM calls
Ranker Combines and scores all results
gRPC Server Streams back autocomplete results to clients

πŸ“ Project Structure

src/
β”œβ”€β”€ api/                 # gRPC server & protobufs
β”œβ”€β”€ prediction_engine/   # Core engine components
β”‚   β”œβ”€β”€ core/            # Trie, FAISS, LLM logic
β”‚   β”œβ”€β”€ data/            # History loader
β”‚   └── ranking/         # Result ranking strategy
β”œβ”€β”€ utils/               # Logging, helpers
β”œβ”€β”€ protobuf/            # Generated gRPC code

πŸ“ TODO

  • Shell plugin for Bash/Zsh/Fish autocompletion
  • Persistent command history across sessions
  • Create a proper RAG for LLM (might increase latency)
  • Session-aware completions

πŸ“„ License

MIT License Β© 2025 Harsh S.

About

A Context-aware, low-latency command-line autocomplete shell integration powered by Trie, FAISS, and LLMs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •