Time‑to‑Mental‑Model: a local‑first code reading assistant (Phase A)
Project description
ttmm: Time‑to‑Mental‑Model
ttmm is a local‑first code reading assistant designed to reduce the time it takes to load a mental model of a codebase. It provides static indexing, simple call graph navigation, hotspot detection and dynamic tracing. You can use it either from the command line or through a Streamlit web UI.
New: ttmm now supports remote repositories via Git URLs and GitIngest integration, making it easy to analyze any public Python repository without cloning manually.
Key features (Phase A)
- Index your repository – builds a lightweight SQLite database of all Python functions/methods, their definitions, references and coarse call edges using only the standard library.
- Remote repository support – analyze any GitHub, GitLab, or Bitbucket repository directly via URL or GitIngest links without manual cloning.
- Hotspot detection – computes a hotspot score by combining cyclomatic complexity and recent git churn to help you prioritise where to read first.
- Static call graph navigation – shows callers and callees for any symbol using conservative AST analysis. Attribute calls that cannot be resolved are marked as
<unresolved>. - Keyword search – a tiny TF‑IDF engine lets you ask a natural language question and returns a minimal reading set of relevant symbols.
- Dynamic tracing – run a module, function or script with
sys.settraceto capture the actual call sequence executed at runtime and persist it in the database.
Installation
Requirements:
- Python 3.8 or later (except 3.9.7 due to Streamlit compatibility)
- A
gitexecutable in yourPATHif you want churn‑based hotspot scores
Install from PyPI:
pip install zerottmm
Or install in development mode from this repository:
pip install -e .
To enable optional extras:
[ui]– installstreamlitandopenaifor the web UI with AI features[test]– installpytestfor running the test suite[ai]– installopenaifor AI-enhanced analysis
For example:
pip install zerottmm[ui,test]
Command line usage
After installation a zerottmm command will be available:
zerottmm index PATH_OR_URL # index a Python repository (local or remote)
zerottmm hotspots PATH # show the top hotspots (default 10)
zerottmm callers PATH SYMBOL
zerottmm callees PATH SYMBOL
zerottmm trace PATH [--module pkg.mod:func | --script file.py] [-- args...]
zerottmm answer PATH "your question"
- PATH_OR_URL – local repository path, Git URL, or GitIngest URL
- PATH – local repository path that has been indexed previously
- SYMBOL – a fully‑qualified name like
package.module:Class.methodorpackage.module:function. - --module – run a function or module entry point (e.g.
package.module:main) and trace calls within the repository. - --script – run an arbitrary Python script in the repository and trace calls.
Use zerottmm --help for full documentation.
Examples
Here are some examples analyzing popular Python repositories:
Analyze the Python requests library
# Index directly from GitHub
zerottmm index https://github.com/psf/requests.git
# Find hotspots (complex functions with high churn)
zerottmm hotspots /tmp/ttmm_repo_*/
# Output: PreparedRequest.prepare_body, super_len, RequestEncodingMixin._encode_files
# Ask natural language questions
zerottmm answer /tmp/ttmm_repo_*/ "how to make HTTP requests"
# Output: HTTPAdapter.send, Session.request, HTTPAdapter.cert_verify
Analyze a mathematical optimization library
# Index a specialized repo via GitIngest URL
zerottmm index "https://gitingest.com/?url=https://github.com/finite-sample/rank_preserving_calibration"
# Find the main algorithmic components
zerottmm answer /tmp/ttmm_repo_*/ "main calibration algorithm"
# Output: calibrate_dykstra, calibrate_admm, _isotonic_regression
# Explore function relationships
zerottmm callers /tmp/ttmm_repo_*/ "calibrate_dykstra"
# Shows all the places this core algorithm is used
Analyze FastAPI core (subpath example)
# Index just the FastAPI core module using GitIngest subpath
zerottmm index "https://gitingest.com/?url=https://github.com/tiangolo/fastapi&subpath=fastapi"
# Find entry points and main interfaces
zerottmm answer /tmp/ttmm_repo_*/ "main application interface"
Streamlit UI
A simple web UI is provided under app/app.py. To run it locally:
pip install -e .[ui]
streamlit run app/app.py
The app allows you to index repositories (local or remote via GitIngest), explore hotspots, get AI-powered insights, and search interactively. Features include:
- Repository indexing from local paths, Git URLs, or GitIngest links
- Automatic repository summary with key metrics and analysis
- AI-enhanced analysis with OpenAI integration (optional)
- Hotspot detection and complexity analysis
- Natural language search over code symbols
The app is designed to run on Streamlit Community Cloud – simply push this repository to GitHub and deploy the app by pointing to app/app.py. The requirements.txt file ensures all dependencies (including OpenAI) are automatically installed.
Development & tests
Tests live in tests/test_ttmm.py and cover indexing, hotspot scoring and search. To run them:
pip install -e .[test]
pytest -q
Continuous integration is configured via .github/workflows/ci.yml to run the test suite on Python 3.8 through 3.12. If you fork this repository on GitHub the workflow will execute automatically.
Limitations
- Phase A supports Python only and uses conservative static analysis. Many dynamic method calls cannot be resolved statically; these appear as
<unresolved>in the call graph. - Hotspot scores require
gitto compute churn – ifgitis not installed or the directory is not a git repository, churn is assumed to be zero. - Dynamic tracing only captures calls within the repository root. Calls to the standard library or external packages are ignored.
Future phases (not implemented here) would add richer language support, deeper type‑aware call resolution and integration with your editor.
Project details
Release history Release notifications | RSS feed
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 zerottmm-0.1.0.tar.gz.
File metadata
- Download URL: zerottmm-0.1.0.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fae2b7a64027161233a593893f469cf2ca6f62279e37f9d8d60ba9d446cd8caf
|
|
| MD5 |
414811abaf75475259f8efd1d0b4615b
|
|
| BLAKE2b-256 |
dc343b10c7d1ec5418a01aa79423df8daf1b601c350415ce32de573365d69310
|
File details
Details for the file zerottmm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: zerottmm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b5245ea07aed97781ab674c35c7e0e744f98869d3e2f66dc0b03f0ec0130d00
|
|
| MD5 |
3c86f59787e1103eef57df2c68a8bb85
|
|
| BLAKE2b-256 |
c079cb563db504eb352ba2768d07437497da2675f1c061eedd66bb6ca0b4b850
|