repolens-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- repolens_cli-0.1.0/.env.example +34 -0
- repolens_cli-0.1.0/.github/workflows/release.yml +26 -0
- repolens_cli-0.1.0/.gitignore +16 -0
- repolens_cli-0.1.0/Formula/repolens.rb +157 -0
- repolens_cli-0.1.0/LICENSE +21 -0
- repolens_cli-0.1.0/PKG-INFO +88 -0
- repolens_cli-0.1.0/README.md +60 -0
- repolens_cli-0.1.0/main.py +124 -0
- repolens_cli-0.1.0/pyproject.toml +42 -0
- repolens_cli-0.1.0/repolens/__init__.py +1 -0
- repolens_cli-0.1.0/repolens/ai_client.py +230 -0
- repolens_cli-0.1.0/repolens/analyzer.py +242 -0
- repolens_cli-0.1.0/repolens/cli.py +117 -0
- repolens_cli-0.1.0/repolens/fetcher.py +198 -0
- repolens_cli-0.1.0/repolens/graph.py +126 -0
- repolens_cli-0.1.0/repolens/models.py +52 -0
- repolens_cli-0.1.0/repolens/scanner.py +69 -0
- repolens_cli-0.1.0/repolens/tui/__init__.py +0 -0
- repolens_cli-0.1.0/repolens/tui/app.py +951 -0
- repolens_cli-0.1.0/requirements.txt +4 -0
- repolens_cli-0.1.0/uv.lock +499 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# RepoLens — AI provider configuration
|
|
2
|
+
# Copy this file to .env and fill in your key.
|
|
3
|
+
# Only ONE provider needs to be configured.
|
|
4
|
+
|
|
5
|
+
# ── Gemini (Google) ─────────────────────────────────────────────────────────
|
|
6
|
+
GEMINI_API_KEY=your_gemini_key_here
|
|
7
|
+
# REPOLENS_AI_PROVIDER=gemini # auto-detected from GEMINI_API_KEY
|
|
8
|
+
# REPOLENS_AI_MODEL=gemini-2.5-flash # default (1M context window)
|
|
9
|
+
|
|
10
|
+
# ── OpenAI ───────────────────────────────────────────────────────────────────
|
|
11
|
+
# OPENAI_API_KEY=your_openai_key_here
|
|
12
|
+
# REPOLENS_AI_PROVIDER=openai
|
|
13
|
+
# REPOLENS_AI_MODEL=gpt-4o # default
|
|
14
|
+
|
|
15
|
+
# ── Groq (fast open-source models) ───────────────────────────────────────────
|
|
16
|
+
# GROQ_API_KEY=your_groq_key_here
|
|
17
|
+
# REPOLENS_AI_PROVIDER=groq
|
|
18
|
+
# REPOLENS_AI_MODEL=llama-3.3-70b-versatile # default
|
|
19
|
+
|
|
20
|
+
# ── Ollama (local, no key needed) ────────────────────────────────────────────
|
|
21
|
+
# REPOLENS_AI_PROVIDER=ollama
|
|
22
|
+
# REPOLENS_AI_BASE_URL=http://localhost:11434/v1
|
|
23
|
+
# REPOLENS_AI_MODEL=llama3.2
|
|
24
|
+
|
|
25
|
+
# ── Anthropic ────────────────────────────────────────────────────────────────
|
|
26
|
+
# ANTHROPIC_API_KEY=your_anthropic_key_here
|
|
27
|
+
# REPOLENS_AI_PROVIDER=anthropic
|
|
28
|
+
# REPOLENS_AI_MODEL=claude-sonnet-4-6
|
|
29
|
+
|
|
30
|
+
# ── Any other OpenAI-compatible provider ─────────────────────────────────────
|
|
31
|
+
# REPOLENS_AI_PROVIDER=custom
|
|
32
|
+
# REPOLENS_AI_API_KEY=your_key
|
|
33
|
+
# REPOLENS_AI_BASE_URL=https://your-provider.com/v1
|
|
34
|
+
# REPOLENS_AI_MODEL=your-model-name
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
name: Publish to PyPI
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- uses: astral-sh/setup-uv@v3
|
|
17
|
+
with:
|
|
18
|
+
version: "latest"
|
|
19
|
+
|
|
20
|
+
- name: Build
|
|
21
|
+
run: uv build
|
|
22
|
+
|
|
23
|
+
- name: Publish to PyPI
|
|
24
|
+
run: uv publish
|
|
25
|
+
env:
|
|
26
|
+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
class Repolens < Formula
|
|
2
|
+
include Language::Python::Virtualenv
|
|
3
|
+
|
|
4
|
+
desc "Instant clarity on any codebase — navigate imports, trace functions, and get AI answers in one terminal view"
|
|
5
|
+
homepage "https://github.com/Satyam12singh/repolens"
|
|
6
|
+
url "https://files.pythonhosted.org/packages/source/r/repolens/repolens-0.1.0.tar.gz"
|
|
7
|
+
sha256 "FILL_IN_AFTER_PYPI_PUBLISH"
|
|
8
|
+
license "MIT"
|
|
9
|
+
|
|
10
|
+
depends_on "python@3.12"
|
|
11
|
+
|
|
12
|
+
# Run this once after publishing to PyPI to auto-generate these resource blocks:
|
|
13
|
+
# pip install homebrew-pypi-poet
|
|
14
|
+
# poet repolens
|
|
15
|
+
resource "annotated-types" do
|
|
16
|
+
url "https://files.pythonhosted.org/packages/source/a/annotated_types/annotated_types-0.7.0.tar.gz"
|
|
17
|
+
sha256 "FILL_IN"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
resource "anyio" do
|
|
21
|
+
url "https://files.pythonhosted.org/packages/source/a/anyio/anyio-4.9.0.tar.gz"
|
|
22
|
+
sha256 "FILL_IN"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
resource "certifi" do
|
|
26
|
+
url "https://files.pythonhosted.org/packages/source/c/certifi/certifi-2025.1.31.tar.gz"
|
|
27
|
+
sha256 "FILL_IN"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
resource "charset-normalizer" do
|
|
31
|
+
url "https://files.pythonhosted.org/packages/source/c/charset_normalizer/charset_normalizer-3.4.1.tar.gz"
|
|
32
|
+
sha256 "FILL_IN"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
resource "distro" do
|
|
36
|
+
url "https://files.pythonhosted.org/packages/source/d/distro/distro-1.9.0.tar.gz"
|
|
37
|
+
sha256 "FILL_IN"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
resource "h11" do
|
|
41
|
+
url "https://files.pythonhosted.org/packages/source/h/h11/h11-0.14.0.tar.gz"
|
|
42
|
+
sha256 "FILL_IN"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
resource "httpcore" do
|
|
46
|
+
url "https://files.pythonhosted.org/packages/source/h/httpcore/httpcore-1.0.7.tar.gz"
|
|
47
|
+
sha256 "FILL_IN"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
resource "httpx" do
|
|
51
|
+
url "https://files.pythonhosted.org/packages/source/h/httpx/httpx-0.28.1.tar.gz"
|
|
52
|
+
sha256 "FILL_IN"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
resource "idna" do
|
|
56
|
+
url "https://files.pythonhosted.org/packages/source/i/idna/idna-3.10.tar.gz"
|
|
57
|
+
sha256 "FILL_IN"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
resource "jiter" do
|
|
61
|
+
url "https://files.pythonhosted.org/packages/source/j/jiter/jiter-0.8.2.tar.gz"
|
|
62
|
+
sha256 "FILL_IN"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
resource "linkify-it-py" do
|
|
66
|
+
url "https://files.pythonhosted.org/packages/source/l/linkify_it_py/linkify_it_py-2.0.3.tar.gz"
|
|
67
|
+
sha256 "FILL_IN"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
resource "markdown-it-py" do
|
|
71
|
+
url "https://files.pythonhosted.org/packages/source/m/markdown_it_py/markdown_it_py-3.0.0.tar.gz"
|
|
72
|
+
sha256 "FILL_IN"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
resource "mdit-py-plugins" do
|
|
76
|
+
url "https://files.pythonhosted.org/packages/source/m/mdit_py_plugins/mdit_py_plugins-0.4.2.tar.gz"
|
|
77
|
+
sha256 "FILL_IN"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
resource "mdurl" do
|
|
81
|
+
url "https://files.pythonhosted.org/packages/source/m/mdurl/mdurl-0.1.2.tar.gz"
|
|
82
|
+
sha256 "FILL_IN"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
resource "openai" do
|
|
86
|
+
url "https://files.pythonhosted.org/packages/source/o/openai/openai-1.59.9.tar.gz"
|
|
87
|
+
sha256 "FILL_IN"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
resource "pydantic" do
|
|
91
|
+
url "https://files.pythonhosted.org/packages/source/p/pydantic/pydantic-2.10.5.tar.gz"
|
|
92
|
+
sha256 "FILL_IN"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
resource "pydantic-core" do
|
|
96
|
+
url "https://files.pythonhosted.org/packages/source/p/pydantic_core/pydantic_core-2.27.2.tar.gz"
|
|
97
|
+
sha256 "FILL_IN"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
resource "pygments" do
|
|
101
|
+
url "https://files.pythonhosted.org/packages/source/p/pygments/pygments-2.19.1.tar.gz"
|
|
102
|
+
sha256 "FILL_IN"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
resource "python-dotenv" do
|
|
106
|
+
url "https://files.pythonhosted.org/packages/source/p/python_dotenv/python_dotenv-1.0.1.tar.gz"
|
|
107
|
+
sha256 "FILL_IN"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
resource "requests" do
|
|
111
|
+
url "https://files.pythonhosted.org/packages/source/r/requests/requests-2.32.3.tar.gz"
|
|
112
|
+
sha256 "FILL_IN"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
resource "rich" do
|
|
116
|
+
url "https://files.pythonhosted.org/packages/source/r/rich/rich-13.9.4.tar.gz"
|
|
117
|
+
sha256 "FILL_IN"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
resource "sniffio" do
|
|
121
|
+
url "https://files.pythonhosted.org/packages/source/s/sniffio/sniffio-1.3.1.tar.gz"
|
|
122
|
+
sha256 "FILL_IN"
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
resource "textual" do
|
|
126
|
+
url "https://files.pythonhosted.org/packages/source/t/textual/textual-2.1.2.tar.gz"
|
|
127
|
+
sha256 "FILL_IN"
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
resource "tqdm" do
|
|
131
|
+
url "https://files.pythonhosted.org/packages/source/t/tqdm/tqdm-4.67.1.tar.gz"
|
|
132
|
+
sha256 "FILL_IN"
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
resource "typing-extensions" do
|
|
136
|
+
url "https://files.pythonhosted.org/packages/source/t/typing_extensions/typing_extensions-4.12.2.tar.gz"
|
|
137
|
+
sha256 "FILL_IN"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
resource "uc-micro-py" do
|
|
141
|
+
url "https://files.pythonhosted.org/packages/source/u/uc_micro_py/uc_micro_py-1.0.3.tar.gz"
|
|
142
|
+
sha256 "FILL_IN"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
resource "urllib3" do
|
|
146
|
+
url "https://files.pythonhosted.org/packages/source/u/urllib3/urllib3-2.3.0.tar.gz"
|
|
147
|
+
sha256 "FILL_IN"
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def install
|
|
151
|
+
virtualenv_install_with_resources
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
test do
|
|
155
|
+
assert_match "RepoLens", shell_output("#{bin}/repolens --help")
|
|
156
|
+
end
|
|
157
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Satyam Singh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: repolens-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Instant clarity on any codebase. Navigate imports, trace functions, and get AI answers — all in one terminal view.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Satyam12singh/repolens
|
|
6
|
+
Project-URL: Repository, https://github.com/Satyam12singh/repolens
|
|
7
|
+
Project-URL: Issues, https://github.com/Satyam12singh/repolens/issues
|
|
8
|
+
Author-email: Satyam Singh <satyam.singh@whyminds.ai>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,cli,codebase,developer-tools,terminal,tui
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development
|
|
21
|
+
Classifier: Topic :: Utilities
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: openai>=1.30.0
|
|
24
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
25
|
+
Requires-Dist: requests>=2.31.0
|
|
26
|
+
Requires-Dist: textual>=0.47.0
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# RepoLens
|
|
30
|
+
|
|
31
|
+
Instant clarity on any codebase. Navigate imports, trace functions, and get AI answers — all in one terminal view.
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
brew tap satyam12singh/tap
|
|
37
|
+
brew install repolens
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
repolens . # scan current directory
|
|
44
|
+
repolens ~/my-repo # scan any directory
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## AI Configuration
|
|
48
|
+
|
|
49
|
+
RepoLens supports multiple AI providers. Set **one** of the following in your environment (or in a `.env` file in the directory you're scanning):
|
|
50
|
+
|
|
51
|
+
| Provider | Environment Variable | Default Model |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| Gemini (Google) | `GEMINI_API_KEY` | `gemini-2.5-flash` |
|
|
54
|
+
| OpenAI | `OPENAI_API_KEY` | `gpt-4o` |
|
|
55
|
+
| Groq | `GROQ_API_KEY` | `llama-3.3-70b-versatile` |
|
|
56
|
+
| Anthropic | `ANTHROPIC_API_KEY` | `claude-sonnet-4-6` |
|
|
57
|
+
| Ollama (local) | `REPOLENS_AI_PROVIDER=ollama` | `llama3.2` |
|
|
58
|
+
|
|
59
|
+
Override any default with:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
REPOLENS_AI_MODEL=gemini-2.5-pro repolens .
|
|
63
|
+
REPOLENS_AI_BASE_URL=http://localhost:11434/v1 repolens . # custom endpoint
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
If no key is set, the file tree and dependency graphs still work — only the AI features (Ask AI, Onboard) are disabled.
|
|
67
|
+
|
|
68
|
+
## Key Bindings
|
|
69
|
+
|
|
70
|
+
| Key | Action |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `1` | Dependencies tab |
|
|
73
|
+
| `2` | Call graph tab |
|
|
74
|
+
| `3` | Full graph tab |
|
|
75
|
+
| `a` | Ask AI a question about the codebase |
|
|
76
|
+
| `o` | Generate onboarding guide |
|
|
77
|
+
| `f` | Toggle focus between file tree and content |
|
|
78
|
+
| `[` / `]` | Resize sidebar |
|
|
79
|
+
| `j` / `k` | Scroll |
|
|
80
|
+
| `q` | Quit |
|
|
81
|
+
|
|
82
|
+
## Supported Languages
|
|
83
|
+
|
|
84
|
+
Python, JavaScript, TypeScript, Go, Rust
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
MIT
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# RepoLens
|
|
2
|
+
|
|
3
|
+
Instant clarity on any codebase. Navigate imports, trace functions, and get AI answers — all in one terminal view.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
brew tap satyam12singh/tap
|
|
9
|
+
brew install repolens
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
repolens . # scan current directory
|
|
16
|
+
repolens ~/my-repo # scan any directory
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## AI Configuration
|
|
20
|
+
|
|
21
|
+
RepoLens supports multiple AI providers. Set **one** of the following in your environment (or in a `.env` file in the directory you're scanning):
|
|
22
|
+
|
|
23
|
+
| Provider | Environment Variable | Default Model |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| Gemini (Google) | `GEMINI_API_KEY` | `gemini-2.5-flash` |
|
|
26
|
+
| OpenAI | `OPENAI_API_KEY` | `gpt-4o` |
|
|
27
|
+
| Groq | `GROQ_API_KEY` | `llama-3.3-70b-versatile` |
|
|
28
|
+
| Anthropic | `ANTHROPIC_API_KEY` | `claude-sonnet-4-6` |
|
|
29
|
+
| Ollama (local) | `REPOLENS_AI_PROVIDER=ollama` | `llama3.2` |
|
|
30
|
+
|
|
31
|
+
Override any default with:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
REPOLENS_AI_MODEL=gemini-2.5-pro repolens .
|
|
35
|
+
REPOLENS_AI_BASE_URL=http://localhost:11434/v1 repolens . # custom endpoint
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If no key is set, the file tree and dependency graphs still work — only the AI features (Ask AI, Onboard) are disabled.
|
|
39
|
+
|
|
40
|
+
## Key Bindings
|
|
41
|
+
|
|
42
|
+
| Key | Action |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `1` | Dependencies tab |
|
|
45
|
+
| `2` | Call graph tab |
|
|
46
|
+
| `3` | Full graph tab |
|
|
47
|
+
| `a` | Ask AI a question about the codebase |
|
|
48
|
+
| `o` | Generate onboarding guide |
|
|
49
|
+
| `f` | Toggle focus between file tree and content |
|
|
50
|
+
| `[` / `]` | Resize sidebar |
|
|
51
|
+
| `j` / `k` | Scroll |
|
|
52
|
+
| `q` | Quit |
|
|
53
|
+
|
|
54
|
+
## Supported Languages
|
|
55
|
+
|
|
56
|
+
Python, JavaScript, TypeScript, Go, Rust
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
MIT
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""RepoLens CLI — `repolens [path]`"""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main() -> None:
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
prog="repolens",
|
|
13
|
+
description="RepoLens — AI-native codebase intelligence",
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument(
|
|
16
|
+
"path",
|
|
17
|
+
nargs="?",
|
|
18
|
+
default=".",
|
|
19
|
+
help="Directory to analyse (default: current directory)",
|
|
20
|
+
)
|
|
21
|
+
parser.add_argument(
|
|
22
|
+
"--no-ai",
|
|
23
|
+
action="store_true",
|
|
24
|
+
help="Skip AI features (no ANTHROPIC_API_KEY needed)",
|
|
25
|
+
)
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
"--max-files",
|
|
28
|
+
type=int,
|
|
29
|
+
default=2000,
|
|
30
|
+
help="Max source files to scan (default: 2000)",
|
|
31
|
+
)
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
"--json",
|
|
34
|
+
action="store_true",
|
|
35
|
+
help="Output analysis as JSON instead of launching TUI",
|
|
36
|
+
)
|
|
37
|
+
args = parser.parse_args()
|
|
38
|
+
|
|
39
|
+
root = Path(args.path).resolve()
|
|
40
|
+
if not root.is_dir():
|
|
41
|
+
print(f"Error: {root} is not a directory.", file=sys.stderr)
|
|
42
|
+
sys.exit(1)
|
|
43
|
+
|
|
44
|
+
print(f"RepoLens scanning {root} …")
|
|
45
|
+
|
|
46
|
+
# Load .env if present
|
|
47
|
+
try:
|
|
48
|
+
from dotenv import load_dotenv
|
|
49
|
+
load_dotenv()
|
|
50
|
+
except ImportError:
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
from repolens.scanner import scan
|
|
54
|
+
from repolens.analyzer import analyze_all
|
|
55
|
+
from repolens.graph import build_graph
|
|
56
|
+
from repolens.models import RepoAnalysis
|
|
57
|
+
|
|
58
|
+
print(" Walking directory tree…")
|
|
59
|
+
files = scan(str(root), max_files=args.max_files)
|
|
60
|
+
print(f" Found {len(files)} source files.")
|
|
61
|
+
|
|
62
|
+
print(" Analysing imports and functions…")
|
|
63
|
+
file_analyses = analyze_all(files)
|
|
64
|
+
print(f" Analysed {len(file_analyses)} files.")
|
|
65
|
+
|
|
66
|
+
print(" Building dependency and call graphs…")
|
|
67
|
+
stats = build_graph(file_analyses)
|
|
68
|
+
|
|
69
|
+
analysis = RepoAnalysis(
|
|
70
|
+
root=str(root),
|
|
71
|
+
files=files,
|
|
72
|
+
file_analyses=file_analyses,
|
|
73
|
+
stats=stats,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
n_cycles = len(stats.circular_deps)
|
|
77
|
+
print(f" Done. {len(stats.functions)} functions · {n_cycles} circular dep(s)")
|
|
78
|
+
|
|
79
|
+
if args.json:
|
|
80
|
+
_print_json(analysis)
|
|
81
|
+
return
|
|
82
|
+
|
|
83
|
+
if args.no_ai:
|
|
84
|
+
import os
|
|
85
|
+
os.environ.setdefault("ANTHROPIC_API_KEY", "")
|
|
86
|
+
|
|
87
|
+
print(" Launching TUI…\n")
|
|
88
|
+
from repolens.tui.app import RepoLensApp
|
|
89
|
+
app = RepoLensApp(analysis)
|
|
90
|
+
app.run()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _print_json(analysis: "RepoAnalysis") -> None:
|
|
94
|
+
import json
|
|
95
|
+
|
|
96
|
+
stats = analysis.stats
|
|
97
|
+
output = {
|
|
98
|
+
"root": analysis.root,
|
|
99
|
+
"total_files": len(analysis.files),
|
|
100
|
+
"files": [
|
|
101
|
+
{"path": f.path, "language": f.language, "size": f.size}
|
|
102
|
+
for f in analysis.files
|
|
103
|
+
],
|
|
104
|
+
"import_graph": {k: v for k, v in stats.import_edges.items() if v},
|
|
105
|
+
"circular_deps": stats.circular_deps,
|
|
106
|
+
"hub_files": [{"path": p, "in_degree": d} for p, d in stats.hub_files],
|
|
107
|
+
"entry_points": stats.entry_points,
|
|
108
|
+
"functions": [
|
|
109
|
+
{
|
|
110
|
+
"id": fid,
|
|
111
|
+
"name": fn.name,
|
|
112
|
+
"file": fn.file_path,
|
|
113
|
+
"line": fn.line_start,
|
|
114
|
+
"calls": fn.calls,
|
|
115
|
+
"callers": fn.callers,
|
|
116
|
+
}
|
|
117
|
+
for fid, fn in stats.functions.items()
|
|
118
|
+
],
|
|
119
|
+
}
|
|
120
|
+
print(json.dumps(output, indent=2))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
main()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "repolens-cli"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Instant clarity on any codebase. Navigate imports, trace functions, and get AI answers — all in one terminal view."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = { text = "MIT" }
|
|
7
|
+
requires-python = ">=3.11"
|
|
8
|
+
authors = [{ name = "Satyam Singh", email = "satyam.singh@whyminds.ai" }]
|
|
9
|
+
keywords = ["codebase", "tui", "developer-tools", "ai", "terminal", "cli"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 4 - Beta",
|
|
12
|
+
"Environment :: Console",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Topic :: Software Development",
|
|
20
|
+
"Topic :: Utilities",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"textual>=0.47.0",
|
|
24
|
+
"openai>=1.30.0",
|
|
25
|
+
"python-dotenv>=1.0.0",
|
|
26
|
+
"requests>=2.31.0",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/Satyam12singh/repolens"
|
|
31
|
+
Repository = "https://github.com/Satyam12singh/repolens"
|
|
32
|
+
Issues = "https://github.com/Satyam12singh/repolens/issues"
|
|
33
|
+
|
|
34
|
+
[project.scripts]
|
|
35
|
+
repolens = "repolens.cli:main"
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["hatchling"]
|
|
39
|
+
build-backend = "hatchling.build"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["repolens"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""RepoLens — AI-native codebase intelligence."""
|