Token-efficient CLI for indexing and searching code symbols (Python-first, designed for minimal LLM/agent context size)
Project description
Sampler
Token-efficient CLI for indexing and searching code symbols across multiple projects.
Current version: 0.2.1
Designed for humans and LLMs/agents: default outputs are compact, single-line, with short paths and no noisy table formatting.
Requirements
- Python 3.11+
- (Optional) Go, if you plan to use Go parser support in the future
Installation
pip install sampler-cli
For development (tests, linters, etc.):
pip install -e '.[dev]'
Quick Start
sampler init
sampler project add myproj /absolute/path/to/project --language python
sampler project list
sampler index myproj
sampler search add --project myproj
sampler overview /absolute/path/to/project/some/file.py
sampler symbols myproj
Examples with Output
List projects (compact):
$ sampler project list
myproj /home/user/projects/myproj
demo ~/work/demo
Search (default compact, LLM-friendly):
$ sampler search worker --project myproj
myproj:src/tasks/celery_app.py:70 function on_worker_ready def on_worker_ready(sender)
List all symbols for a project:
$ sampler symbols myproj --type function --limit 5
myproj:src/utils.py:10 function helper def helper(x)
myproj:src/models.py:25 function validate def validate(data)
...
Overview of a file (supports relative paths):
$ sampler overview src/app.py
12: function main def main()
25: class App class App
If the file has no indexed symbols (or was never indexed):
$ sampler overview nonexistent.py
No symbols found for file: nonexistent.py
Tip: Make sure the project is registered with 'sampler project add' and indexed with 'sampler index <project>'.
The path must match a file that was indexed (relative paths are resolved to absolute).
Why "project add" is required
sampler project add <name> <path>registers the project in~/.sampler/config.yaml.indexlooks up the project there to know the root path and language.- Without it, commands like
index,symbols, and filtered searches will fail with a clear "not found" message and usage hint. - The actual symbol data lives in the SQLite DB (
~/.sampler/graph.db), but registration is the control plane.
You can have data in the DB without the config entry (e.g. after project remove), but you won't be able to re-index or easily manage it.
Relative Paths
overviewnow resolves relative paths against the current working directory (e.g.sampler overview ./src/app.pyorsampler overview ../other/file.py).- Stored paths are absolute (resolved at index time), so the resolution makes overview work naturally.
- Other file-based commands behave similarly where applicable.
Error Messages & Help
We try to give actionable errors:
- Unknown project → tells you the exact
project addcommand to run and suggestsproject list. - File with no symbols → clear "No symbols found" + tips.
- Typer automatically shows command usage and available options on invalid arguments.
Run any command with --help for full details (e.g. sampler search --help, sampler symbols --help).
Current Features
- Global config in
~/.sampler/config.yaml - Project management (
add,list,remove) - Incremental indexing with file hashing (Python AST-based parser)
- Compact, token-efficient output by default (great for LLMs)
- Search with type filters and limits
search-allacross every registered projectsymbols <project>to dump/list symbols for a projectoverview <file>(relative paths supported)- Basic relationship extraction (CALLS, CONTAINS)
Stability Note
- Python parser uses stdlib
ast(we switched from tree-sitter-python after native crashes on macOS ARM during real indexing). - Go and TypeScript/JavaScript parsers are stubs for now (return no symbols).
Project Structure
src/sampler/
├── cli/main.py # Typer commands (search, overview, symbols, index, project ...)
├── config.py # YAML config manager
├── db.py # SQLite layer
├── indexer/
│ ├── builder.py
│ ├── discover.py
│ ├── store.py
│ └── parsers/python.py
└── query/engine.py
Running Tests
pytest -q
Roadmap Highlights (see TODO.md and PLAN.md)
- Cross-file relation improvements
- Better call graph queries (
callers,usages, ...) - Real Go / TypeScript parsers
- Semantic search + MCP server (for agents)
- More context-generation helpers
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sampler_cli-0.2.1.tar.gz.
File metadata
- Download URL: sampler_cli-0.2.1.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
962b75cc69cff752e6528711c79712dc4df8b4c045449c395dc0367f9c94ce7a
|
|
| MD5 |
d071ae44a7eb9233c941f29bf822dda4
|
|
| BLAKE2b-256 |
02097482321f0e8748e6c3ac1be6ca7f1ed31d815008b32a4442d6741088f529
|
Provenance
The following attestation bundles were made for sampler_cli-0.2.1.tar.gz:
Publisher:
publish.yml on SamuelCarmona83/sampler-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sampler_cli-0.2.1.tar.gz -
Subject digest:
962b75cc69cff752e6528711c79712dc4df8b4c045449c395dc0367f9c94ce7a - Sigstore transparency entry: 2038392020
- Sigstore integration time:
-
Permalink:
SamuelCarmona83/sampler-cli@946ee75d4c772bb592cfd25fe4cff48afe17532c -
Branch / Tag:
refs/tags/0.2.1 - Owner: https://github.com/SamuelCarmona83
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@946ee75d4c772bb592cfd25fe4cff48afe17532c -
Trigger Event:
release
-
Statement type:
File details
Details for the file sampler_cli-0.2.1-py3-none-any.whl.
File metadata
- Download URL: sampler_cli-0.2.1-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4661d19d2b17a1d7e887d1ec2d9f6235f5e9cbb69d4a2faa66ba1ea5f9979eb
|
|
| MD5 |
6cbbdc34f2db5c36a933c5d09063f7f7
|
|
| BLAKE2b-256 |
d96a632b9c29b32ddb5d47e4dbccc60f4e6dc4d6b31bc098be39034f702df687
|
Provenance
The following attestation bundles were made for sampler_cli-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on SamuelCarmona83/sampler-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sampler_cli-0.2.1-py3-none-any.whl -
Subject digest:
f4661d19d2b17a1d7e887d1ec2d9f6235f5e9cbb69d4a2faa66ba1ea5f9979eb - Sigstore transparency entry: 2038392046
- Sigstore integration time:
-
Permalink:
SamuelCarmona83/sampler-cli@946ee75d4c772bb592cfd25fe4cff48afe17532c -
Branch / Tag:
refs/tags/0.2.1 - Owner: https://github.com/SamuelCarmona83
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@946ee75d4c772bb592cfd25fe4cff48afe17532c -
Trigger Event:
release
-
Statement type: