npx claudepluginhub Tylerbryy/ospackSemantic context packer - combines import resolution with semantic search
Combines import resolution with BM25+ search to build optimal code context.
pip install ospack
# Pack context from a file + its imports
ospack pack --focus src/auth.py
# Search for code by keywords
ospack search "user authentication"
# Combine both
ospack pack --focus src/api.py --query "error handling"
| Command | Description |
|---|---|
ospack pack | Pack context from focus file and/or query |
ospack search | Quick BM25+ search |
ospack grep | Exact pattern search (preserves punctuation) |
ospack map | Generate repo structure map with signatures |
ospack index | Build/rebuild the search index |
ospack info | Show index status |
-f, --focus FILE Entry point for import resolution
-q, --query TEXT BM25+ search query
-m, --max-files N Max files to include (default: 10)
-d, --import-depth N Import traversal depth (default: 2)
-o, --format FORMAT Output: xml, compact, or chunks
-S, --skeleton Collapse non-focus function bodies to save tokens
-F, --focus-only Skip search, only use import resolution (fast)
-m, --max-sigs N Max signatures per file (default: unlimited)
--no-signatures Show only file tree, no code signatures
-E, --regex Treat pattern as regular expression
-l, --limit N Max results to return (default: 20)
# Add the ospack marketplace
/plugin marketplace add tylerbryy/ospack
# Install the plugin
/plugin install ospack@ospack
The plugin provides:
/pack - Pack context command/search - BM25+ search command# Start MCP server for AI agents
ospack mcp
Or add to your MCP config:
{
"mcpServers": {
"ospack": {
"command": "ospack",
"args": ["mcp"]
}
}
}
Available MCP Tools:
| Tool | Description |
|---|---|
ospack_pack | Pack context with imports + BM25+ search |
ospack_search | BM25+ code search |
ospack_grep | Exact/regex pattern search (preserves punctuation) |
ospack_map | Generate repo structure map |
ospack_index | Build/rebuild search index |
ospack_probe | Detect missing symbols and suggest follow-up queries |
ospack_impact | Find files affected by changes (reverse dependency analysis) |
ospack_audit | Dry-run pack to check token costs before loading content |
# Collapse non-focus function bodies to save tokens
ospack pack --focus src/api.py --skeleton --max-files 5
# Fast mode: only follow imports, skip search entirely
ospack pack --focus src/api.py --focus-only --skeleton
Skeletonization collapses function bodies to signatures in non-focus files, saving tokens while preserving class/function structure.
# Get a bird's-eye view of the codebase
ospack map --max-sigs 10
# Output shows hierarchy with methods under classes:
# ├── src/
# │ ├── auth.py
# │ │ class AuthService:
# │ │ def login(self, user, password):
# │ │ def logout(self):
# │ │ ... (5 more)
Use ospack_probe to iteratively build complete context:
ospack_pack(focus="auth.py") → get initial contextospack_probe(content=...) → find missing UserModel, TokenServiceospack_pack(query="UserModel definition") → fetch missing piecesospack is inspired by osgrep. Both use tree-sitter for parsing, but serve different purposes:
| ospack | osgrep | |
|---|---|---|
| Purpose | Context packing for AI prompts | Semantic grep replacement |
| Key feature | Import resolution + BM25+ search | Live server with file watching |
| Output | Packed context (XML/markdown) | Search results |
| Language | Python | TypeScript |
When to use osgrep: "Find code about X" — fast semantic search tool.