srcodex 0.2.0__tar.gz → 0.2.1__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.
- {srcodex-0.2.0 → srcodex-0.2.1}/MANIFEST.in +3 -0
- {srcodex-0.2.0/srcodex.egg-info → srcodex-0.2.1}/PKG-INFO +100 -41
- srcodex-0.2.1/README.md +201 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/pyproject.toml +5 -2
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/cli.py +7 -4
- srcodex-0.2.1/srcodex/indexer/db_schema.sql +123 -0
- {srcodex-0.2.0 → srcodex-0.2.1/srcodex.egg-info}/PKG-INFO +100 -41
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex.egg-info/SOURCES.txt +1 -0
- srcodex-0.2.0/README.md +0 -142
- {srcodex-0.2.0 → srcodex-0.2.1}/.env.example +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/LICENSE +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/setup.cfg +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/chat.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/main.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/services/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/services/claude_service.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/services/config_loader.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/services/file_access_tools.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/services/file_tree.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/services/graph_tools.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/services/logger_setup.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/services/session_manager.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/backend/services/status_tracker.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/core/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/core/config.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/core/logger.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/indexer/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/indexer/cscope_client.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/indexer/ctags_compat.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/indexer/ctags_parser.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/indexer/explorer.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/indexer/field_access_analyzer.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/indexer/indexer.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/indexer/reference_ingestor.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/indexer/reference_resolver.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/app.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/app.tcss +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/bars/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/bars/chat_header.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/bars/code_tab_bar.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/bars/footer_bar.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/bars/left_tab.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/logger.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/panels/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/panels/chat_panel.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/panels/code_panel.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/panels/side_panel.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/views/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/views/explorer_view.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/views/search_view.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/widgets/__init__.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/widgets/file_browser.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex/tui/components/widgets/find_box.py +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex.egg-info/dependency_links.txt +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex.egg-info/entry_points.txt +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex.egg-info/requires.txt +0 -0
- {srcodex-0.2.0 → srcodex-0.2.1}/srcodex.egg-info/top_level.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: srcodex
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Semantic code explorer with AI-powered search and analysis
|
|
5
|
-
Author
|
|
5
|
+
Author: Jonathan L'Work
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/Jonathan03ant/srcodex
|
|
8
8
|
Project-URL: Repository, https://github.com/Jonathan03ant/srcodex
|
|
@@ -43,28 +43,67 @@ Unlike generic code assistants (Claude CLI, GitHub Copilot, etc.) that read enti
|
|
|
43
43
|
| "Find all ioctls" | Grep + read matches (15K tokens) | Database search (300 tokens) |
|
|
44
44
|
| "Explain module Y" | Read 10+ files (30K tokens) | Aggregate query (2K tokens) |
|
|
45
45
|
|
|
46
|
-
**Result:**
|
|
46
|
+
**Result:** 99% more token-efficient, instant relationship queries, and unique capabilities impossible for file-based tools (call chains, data flow analysis, architecture visualization).
|
|
47
47
|
|
|
48
|
-
## Features
|
|
48
|
+
## Key Features
|
|
49
49
|
|
|
50
|
-
- **Semantic Indexing**:
|
|
51
|
-
- **AI-Powered
|
|
52
|
-
- **Call Graph Analysis**: Trace function calls,
|
|
53
|
-
- **Terminal UI**:
|
|
54
|
-
- **Multi-Language**:
|
|
55
|
-
- **
|
|
56
|
-
- **Portable**: `.srcodex/` directory makes indexed projects shareable
|
|
50
|
+
- **Semantic Indexing Engine**: Extracts symbols, relationships, and cross-references from source code
|
|
51
|
+
- **AI-Powered Chat**: Natural language queries about your codebase architecture
|
|
52
|
+
- **Call Graph Analysis**: Trace function calls, caller chains, and dependency paths
|
|
53
|
+
- **Terminal UI**: Full-featured TUI with file browser, search, and AI chat interface
|
|
54
|
+
- **Multi-Language Support**: C, C++, Python, JavaScript, Go, Rust, and more
|
|
55
|
+
- **Persistent Graph Database**: SQLite-backed semantic graph with relationship edges
|
|
56
|
+
- **Portable**: `.srcodex/` directory makes indexed projects shareable across teams
|
|
57
|
+
- **Token Efficient**: 99% reduction in API costs via semantic queries and intelligent caching
|
|
57
58
|
|
|
58
59
|
## Installation
|
|
59
60
|
|
|
61
|
+
### From PyPI (Recommended)
|
|
62
|
+
|
|
60
63
|
```bash
|
|
61
64
|
pip install srcodex
|
|
62
65
|
```
|
|
63
66
|
|
|
67
|
+
### From Source
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git clone https://github.com/Jonathan03ant/srcodex.git
|
|
71
|
+
cd srcodex
|
|
72
|
+
pip install -e .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Prerequisites
|
|
76
|
+
|
|
77
|
+
Before installing srcodex, you need these system tools:
|
|
78
|
+
|
|
79
|
+
**Ubuntu/Debian:**
|
|
80
|
+
```bash
|
|
81
|
+
sudo apt install universal-ctags cscope
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**macOS:**
|
|
85
|
+
```bash
|
|
86
|
+
brew install universal-ctags cscope
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Arch Linux:**
|
|
90
|
+
```bash
|
|
91
|
+
sudo pacman -S ctags cscope
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Other systems:** Install Universal CTags from https://github.com/universal-ctags/ctags
|
|
95
|
+
|
|
64
96
|
## Quick Start
|
|
65
97
|
|
|
66
98
|
```bash
|
|
67
|
-
#
|
|
99
|
+
# 1. Install srcodex
|
|
100
|
+
pip install srcodex
|
|
101
|
+
|
|
102
|
+
# 2. Configure API key
|
|
103
|
+
export ANTHROPIC_API_KEY="your-api-key"
|
|
104
|
+
# Or create .env file with ANTHROPIC_API_KEY=...
|
|
105
|
+
|
|
106
|
+
# 3. Index your codebase (first time)
|
|
68
107
|
cd /path/to/your/project
|
|
69
108
|
srcodex
|
|
70
109
|
|
|
@@ -73,7 +112,7 @@ srcodex
|
|
|
73
112
|
# [Indexing happens...]
|
|
74
113
|
# [TUI launches]
|
|
75
114
|
|
|
76
|
-
# Next time - instant launch
|
|
115
|
+
# 4. Next time - instant launch (uses cached index)
|
|
77
116
|
srcodex
|
|
78
117
|
```
|
|
79
118
|
|
|
@@ -96,51 +135,71 @@ Once indexed, use the TUI to:
|
|
|
96
135
|
|
|
97
136
|
## Configuration
|
|
98
137
|
|
|
99
|
-
|
|
138
|
+
srcodex requires a Claude API key from Anthropic.
|
|
100
139
|
|
|
140
|
+
**Option 1: Environment Variable**
|
|
101
141
|
```bash
|
|
102
|
-
|
|
103
|
-
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
104
|
-
|
|
105
|
-
# Or enterprise gateway (if applicable)
|
|
106
|
-
AMD_LLM_API_KEY=your-subscription-key
|
|
142
|
+
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
|
|
107
143
|
```
|
|
108
144
|
|
|
109
|
-
|
|
145
|
+
**Option 2: .env File**
|
|
146
|
+
Create a `.env` file in your project directory:
|
|
147
|
+
```bash
|
|
148
|
+
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
149
|
+
```
|
|
110
150
|
|
|
111
|
-
|
|
112
|
-
- Universal CTags (`brew install universal-ctags` or `apt install universal-ctags`)
|
|
113
|
-
- Cscope (optional, for call graph)
|
|
114
|
-
- Claude API key (Anthropic or enterprise gateway)
|
|
151
|
+
Get your API key from https://console.anthropic.com/
|
|
115
152
|
|
|
116
153
|
## How It Works
|
|
117
154
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
155
|
+
**Indexing Phase:**
|
|
156
|
+
1. Analyzes source code to extract symbols, functions, types, and relationships
|
|
157
|
+
2. Builds a semantic graph database with typed edges (function calls, includes, data access)
|
|
158
|
+
3. Stores everything in a persistent SQLite database
|
|
159
|
+
|
|
160
|
+
**Query Phase:**
|
|
161
|
+
1. You ask questions in natural language via the terminal UI
|
|
162
|
+
2. Claude queries the semantic graph database using specialized tools
|
|
163
|
+
3. Returns targeted answers without reading entire files
|
|
164
|
+
|
|
165
|
+
**Why This Is Efficient:**
|
|
166
|
+
- Traditional code assistants: Read full files (20K-60K tokens per query)
|
|
167
|
+
- srcodex: Semantic graph queries (100-500 tokens per query)
|
|
168
|
+
- Intelligent caching: First query builds cache, subsequent queries reuse it
|
|
169
|
+
- Result: 99% reduction in API costs
|
|
128
170
|
|
|
129
171
|
## Project Structure
|
|
130
172
|
|
|
131
|
-
After indexing, your project
|
|
173
|
+
After indexing, srcodex creates a `.srcodex/` directory in your project:
|
|
132
174
|
|
|
133
175
|
```
|
|
134
176
|
your-project/
|
|
135
177
|
├── .srcodex/
|
|
136
|
-
│ ├── metadata.json # Project
|
|
137
|
-
│ ├── config.toml # Indexing config
|
|
178
|
+
│ ├── metadata.json # Project statistics
|
|
138
179
|
│ ├── data/
|
|
139
|
-
│ │ └── project.db # Semantic graph
|
|
140
|
-
│
|
|
180
|
+
│ │ └── project.db # Semantic graph database
|
|
181
|
+
│ ├── conversations/ # Chat history
|
|
182
|
+
│ └── .debug/ # Debug logs
|
|
141
183
|
└── [your source files...]
|
|
142
184
|
```
|
|
143
185
|
|
|
186
|
+
The `.srcodex/` directory is portable - you can commit it to git or share it with your team to avoid re-indexing.
|
|
187
|
+
|
|
188
|
+
## Performance
|
|
189
|
+
|
|
190
|
+
**Indexing Speed** (varies by codebase size):
|
|
191
|
+
- Small projects (< 100 files): 2-5 seconds
|
|
192
|
+
- Medium projects (100-1000 files): 5-20 seconds
|
|
193
|
+
- Large projects (1000+ files): 20-60 seconds
|
|
194
|
+
|
|
195
|
+
**Query Speed:**
|
|
196
|
+
- Database queries: < 100ms
|
|
197
|
+
- AI responses: 2-10 seconds (depends on complexity)
|
|
198
|
+
|
|
199
|
+
**Token Usage:**
|
|
200
|
+
- First query: 500-2000 tokens (builds cache)
|
|
201
|
+
- Subsequent queries: 25-200 tokens (uses cache)
|
|
202
|
+
|
|
144
203
|
## Development
|
|
145
204
|
|
|
146
205
|
```bash
|
|
@@ -151,8 +210,8 @@ cd srcodex
|
|
|
151
210
|
# Install in development mode
|
|
152
211
|
pip install -e .
|
|
153
212
|
|
|
154
|
-
#
|
|
155
|
-
|
|
213
|
+
# Index and run on srcodex itself
|
|
214
|
+
srcodex .
|
|
156
215
|
```
|
|
157
216
|
|
|
158
217
|
## License
|
srcodex-0.2.1/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# srcodex
|
|
2
|
+
|
|
3
|
+
**Semantic code explorer with AI-powered search and analysis**
|
|
4
|
+
|
|
5
|
+
srcodex builds a semantic graph of your codebase and provides AI-powered exploration through natural language queries. Think of it as an intelligent code search that understands relationships, call graphs, and architecture.
|
|
6
|
+
|
|
7
|
+
## Why srcodex?
|
|
8
|
+
|
|
9
|
+
Unlike generic code assistants (Claude CLI, GitHub Copilot, etc.) that read entire files to answer questions, srcodex uses a **semantic graph database** to understand your code:
|
|
10
|
+
|
|
11
|
+
| Question | Generic Assistant | srcodex |
|
|
12
|
+
|----------|------------------|---------|
|
|
13
|
+
| "Who calls function X?" | Grep entire codebase (20K tokens) | `get_callers('X')` (200 tokens) |
|
|
14
|
+
| "Show call chain A→B" | Read multiple files, manual tracing | Graph query (500 tokens) |
|
|
15
|
+
| "Find all ioctls" | Grep + read matches (15K tokens) | Database search (300 tokens) |
|
|
16
|
+
| "Explain module Y" | Read 10+ files (30K tokens) | Aggregate query (2K tokens) |
|
|
17
|
+
|
|
18
|
+
**Result:** 99% more token-efficient, instant relationship queries, and unique capabilities impossible for file-based tools (call chains, data flow analysis, architecture visualization).
|
|
19
|
+
|
|
20
|
+
## Key Features
|
|
21
|
+
|
|
22
|
+
- **Semantic Indexing Engine**: Extracts symbols, relationships, and cross-references from source code
|
|
23
|
+
- **AI-Powered Chat**: Natural language queries about your codebase architecture
|
|
24
|
+
- **Call Graph Analysis**: Trace function calls, caller chains, and dependency paths
|
|
25
|
+
- **Terminal UI**: Full-featured TUI with file browser, search, and AI chat interface
|
|
26
|
+
- **Multi-Language Support**: C, C++, Python, JavaScript, Go, Rust, and more
|
|
27
|
+
- **Persistent Graph Database**: SQLite-backed semantic graph with relationship edges
|
|
28
|
+
- **Portable**: `.srcodex/` directory makes indexed projects shareable across teams
|
|
29
|
+
- **Token Efficient**: 99% reduction in API costs via semantic queries and intelligent caching
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
### From PyPI (Recommended)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install srcodex
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### From Source
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/Jonathan03ant/srcodex.git
|
|
43
|
+
cd srcodex
|
|
44
|
+
pip install -e .
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Prerequisites
|
|
48
|
+
|
|
49
|
+
Before installing srcodex, you need these system tools:
|
|
50
|
+
|
|
51
|
+
**Ubuntu/Debian:**
|
|
52
|
+
```bash
|
|
53
|
+
sudo apt install universal-ctags cscope
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**macOS:**
|
|
57
|
+
```bash
|
|
58
|
+
brew install universal-ctags cscope
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Arch Linux:**
|
|
62
|
+
```bash
|
|
63
|
+
sudo pacman -S ctags cscope
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Other systems:** Install Universal CTags from https://github.com/universal-ctags/ctags
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# 1. Install srcodex
|
|
72
|
+
pip install srcodex
|
|
73
|
+
|
|
74
|
+
# 2. Configure API key
|
|
75
|
+
export ANTHROPIC_API_KEY="your-api-key"
|
|
76
|
+
# Or create .env file with ANTHROPIC_API_KEY=...
|
|
77
|
+
|
|
78
|
+
# 3. Index your codebase (first time)
|
|
79
|
+
cd /path/to/your/project
|
|
80
|
+
srcodex
|
|
81
|
+
|
|
82
|
+
# Output:
|
|
83
|
+
# No .srcodex/ found. Index this directory? (y/n) y
|
|
84
|
+
# [Indexing happens...]
|
|
85
|
+
# [TUI launches]
|
|
86
|
+
|
|
87
|
+
# 4. Next time - instant launch (uses cached index)
|
|
88
|
+
srcodex
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Usage
|
|
92
|
+
|
|
93
|
+
Once indexed, use the TUI to:
|
|
94
|
+
- Browse files and symbols
|
|
95
|
+
- Search across your codebase
|
|
96
|
+
- Chat with AI about your code architecture
|
|
97
|
+
- Trace call chains and dependencies
|
|
98
|
+
|
|
99
|
+
### Example AI Queries
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
"What does the init_system function do?"
|
|
103
|
+
"Show me all functions that call malloc"
|
|
104
|
+
"Trace the execution path from main to shutdown"
|
|
105
|
+
"What structs are defined in config.h?"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Configuration
|
|
109
|
+
|
|
110
|
+
srcodex requires a Claude API key from Anthropic.
|
|
111
|
+
|
|
112
|
+
**Option 1: Environment Variable**
|
|
113
|
+
```bash
|
|
114
|
+
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Option 2: .env File**
|
|
118
|
+
Create a `.env` file in your project directory:
|
|
119
|
+
```bash
|
|
120
|
+
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Get your API key from https://console.anthropic.com/
|
|
124
|
+
|
|
125
|
+
## How It Works
|
|
126
|
+
|
|
127
|
+
**Indexing Phase:**
|
|
128
|
+
1. Analyzes source code to extract symbols, functions, types, and relationships
|
|
129
|
+
2. Builds a semantic graph database with typed edges (function calls, includes, data access)
|
|
130
|
+
3. Stores everything in a persistent SQLite database
|
|
131
|
+
|
|
132
|
+
**Query Phase:**
|
|
133
|
+
1. You ask questions in natural language via the terminal UI
|
|
134
|
+
2. Claude queries the semantic graph database using specialized tools
|
|
135
|
+
3. Returns targeted answers without reading entire files
|
|
136
|
+
|
|
137
|
+
**Why This Is Efficient:**
|
|
138
|
+
- Traditional code assistants: Read full files (20K-60K tokens per query)
|
|
139
|
+
- srcodex: Semantic graph queries (100-500 tokens per query)
|
|
140
|
+
- Intelligent caching: First query builds cache, subsequent queries reuse it
|
|
141
|
+
- Result: 99% reduction in API costs
|
|
142
|
+
|
|
143
|
+
## Project Structure
|
|
144
|
+
|
|
145
|
+
After indexing, srcodex creates a `.srcodex/` directory in your project:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
your-project/
|
|
149
|
+
├── .srcodex/
|
|
150
|
+
│ ├── metadata.json # Project statistics
|
|
151
|
+
│ ├── data/
|
|
152
|
+
│ │ └── project.db # Semantic graph database
|
|
153
|
+
│ ├── conversations/ # Chat history
|
|
154
|
+
│ └── .debug/ # Debug logs
|
|
155
|
+
└── [your source files...]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The `.srcodex/` directory is portable - you can commit it to git or share it with your team to avoid re-indexing.
|
|
159
|
+
|
|
160
|
+
## Performance
|
|
161
|
+
|
|
162
|
+
**Indexing Speed** (varies by codebase size):
|
|
163
|
+
- Small projects (< 100 files): 2-5 seconds
|
|
164
|
+
- Medium projects (100-1000 files): 5-20 seconds
|
|
165
|
+
- Large projects (1000+ files): 20-60 seconds
|
|
166
|
+
|
|
167
|
+
**Query Speed:**
|
|
168
|
+
- Database queries: < 100ms
|
|
169
|
+
- AI responses: 2-10 seconds (depends on complexity)
|
|
170
|
+
|
|
171
|
+
**Token Usage:**
|
|
172
|
+
- First query: 500-2000 tokens (builds cache)
|
|
173
|
+
- Subsequent queries: 25-200 tokens (uses cache)
|
|
174
|
+
|
|
175
|
+
## Development
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Clone repository
|
|
179
|
+
git clone https://github.com/Jonathan03ant/srcodex.git
|
|
180
|
+
cd srcodex
|
|
181
|
+
|
|
182
|
+
# Install in development mode
|
|
183
|
+
pip install -e .
|
|
184
|
+
|
|
185
|
+
# Index and run on srcodex itself
|
|
186
|
+
srcodex .
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
MIT License - see LICENSE file for details
|
|
192
|
+
|
|
193
|
+
## Contributing
|
|
194
|
+
|
|
195
|
+
Contributions welcome! Please open an issue or pull request.
|
|
196
|
+
|
|
197
|
+
## Links
|
|
198
|
+
|
|
199
|
+
- [GitHub Repository](https://github.com/Jonathan03ant/srcodex)
|
|
200
|
+
- [Issue Tracker](https://github.com/Jonathan03ant/srcodex/issues)
|
|
201
|
+
- [Documentation](https://github.com/Jonathan03ant/srcodex/wiki)
|
|
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "srcodex"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "Semantic code explorer with AI-powered search and analysis"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
11
11
|
license = {text = "MIT"}
|
|
12
12
|
authors = [
|
|
13
|
-
{name = "Jonathan
|
|
13
|
+
{name = "Jonathan L'Work"}
|
|
14
14
|
]
|
|
15
15
|
keywords = [
|
|
16
16
|
"code-search",
|
|
@@ -45,3 +45,6 @@ srcodex = "srcodex.cli:main"
|
|
|
45
45
|
Homepage = "https://github.com/Jonathan03ant/srcodex"
|
|
46
46
|
Repository = "https://github.com/Jonathan03ant/srcodex"
|
|
47
47
|
Issues = "https://github.com/Jonathan03ant/srcodex/issues"
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.package-data]
|
|
50
|
+
srcodex = ["indexer/*.sql", "tui/*.tcss"]
|
|
@@ -17,6 +17,7 @@ from srcodex.indexer.indexer import Indexer
|
|
|
17
17
|
from srcodex.indexer.field_access_analyzer import FieldAccessAnalyzer
|
|
18
18
|
from srcodex.indexer.reference_ingestor import ReferenceIngestor
|
|
19
19
|
from srcodex.indexer.reference_resolver import ReferenceResolver
|
|
20
|
+
from importlib.metadata import version as get_version
|
|
20
21
|
|
|
21
22
|
@click.command()
|
|
22
23
|
@click.argument('path', default='.', type=click.Path(exists=True))
|
|
@@ -25,15 +26,17 @@ from srcodex.indexer.reference_resolver import ReferenceResolver
|
|
|
25
26
|
def main(path, reindex, debug):
|
|
26
27
|
"""
|
|
27
28
|
Launch srcodex TUI
|
|
28
|
-
|
|
29
29
|
EXAMPLES:
|
|
30
30
|
srcodex # Index current directory and launch
|
|
31
31
|
srcodex /path/to/code # Index specific directory
|
|
32
32
|
srcodex --reindex # Force re-index and launch
|
|
33
33
|
"""
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
try:
|
|
36
|
+
pkg_version = get_version("srcodex")
|
|
37
|
+
except Exception:
|
|
38
|
+
pkg_version = "dev"
|
|
39
|
+
click.echo(f"srcodex v{pkg_version} - Semantic code explorer")
|
|
37
40
|
|
|
38
41
|
project_path = Path(path).resolve()
|
|
39
42
|
srcodex_dir = project_path / ".srcodex"
|
|
@@ -62,7 +65,7 @@ def main(path, reindex, debug):
|
|
|
62
65
|
click.echo("\nError: No API key found!", err=True)
|
|
63
66
|
click.echo("Please set either:")
|
|
64
67
|
click.echo(" - ANTHROPIC_API_KEY (for public API)")
|
|
65
|
-
click.echo(" - AMD_LLM_API_KEY (for enterprise gateway)")
|
|
68
|
+
click.echo(" - AMD_LLM_API_KEY (for AMD enterprise gateway)")
|
|
66
69
|
click.echo("\nSee .env.example for configuration details")
|
|
67
70
|
sys.exit(1)
|
|
68
71
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
-- SQLite database for storing symbols, references, and file contents
|
|
2
|
+
-- Symbols (function/variable/struct/macro definitions)
|
|
3
|
+
-- is the universal entity that represents anything that can be tracked in code.
|
|
4
|
+
CREATE TABLE IF NOT EXISTS symbols (
|
|
5
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
6
|
+
name TEXT NOT NULL,
|
|
7
|
+
type TEXT NOT NULL, -- Normalized: function, struct, variable, macro, typedef, enum, etc.
|
|
8
|
+
kind_raw TEXT, -- Raw ctags kind: prototype, function, variable, member, etc.
|
|
9
|
+
file_path TEXT NOT NULL,
|
|
10
|
+
line_number INTEGER NOT NULL,
|
|
11
|
+
signature TEXT, -- Raw signature from ctags (e.g., "(uint32_t intr_sts, uint8_t device)"), NULL if not available
|
|
12
|
+
typeref TEXT, -- Raw typeref from ctags (e.g., "typename:void"), NULL if not available
|
|
13
|
+
scope TEXT, -- global, extern (deprecated - use is_file_scope instead)
|
|
14
|
+
scope_kind TEXT, -- struct, union, enum, class (parent scope type)
|
|
15
|
+
scope_name TEXT, -- PowerState, Dummy, etc. (parent scope name)
|
|
16
|
+
is_file_scope INTEGER, -- 1 if file-local (static in C), 0 if not, NULL if unknown
|
|
17
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
-- Create indexes for fast lookup
|
|
21
|
+
CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
|
|
22
|
+
CREATE INDEX IF NOT EXISTS idx_symbols_file ON symbols(file_path);
|
|
23
|
+
CREATE INDEX IF NOT EXISTS idx_symbols_type ON symbols(type);
|
|
24
|
+
CREATE INDEX IF NOT EXISTS idx_symbols_kind_raw ON symbols(kind_raw);
|
|
25
|
+
CREATE INDEX IF NOT EXISTS idx_symbols_scope ON symbols(scope_kind, scope_name);
|
|
26
|
+
CREATE INDEX IF NOT EXISTS idx_symbols_file_scope ON symbols(is_file_scope);
|
|
27
|
+
|
|
28
|
+
-- Files (source file metadata - content NOT stored for performance/size)
|
|
29
|
+
CREATE TABLE IF NOT EXISTS files (
|
|
30
|
+
path TEXT PRIMARY KEY, -- Relative path from source_root
|
|
31
|
+
size INTEGER NOT NULL,
|
|
32
|
+
language TEXT, -- c, h, python, makefile, etc.
|
|
33
|
+
sha1 TEXT, -- SHA1 hash for change detection
|
|
34
|
+
last_modified REAL, -- mtime for change detection
|
|
35
|
+
last_indexed TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
CREATE INDEX IF NOT EXISTS idx_files_language ON files(language);
|
|
39
|
+
CREATE INDEX IF NOT EXISTS idx_files_sha1 ON files(sha1);
|
|
40
|
+
|
|
41
|
+
-- Full-text search for symbols (FTS5 for fast text search)
|
|
42
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS symbols_fts USING fts5(
|
|
43
|
+
name,
|
|
44
|
+
file_path,
|
|
45
|
+
signature,
|
|
46
|
+
content=symbols,
|
|
47
|
+
content_rowid=id
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
-- Triggers to keep FTS table in sync with symbols table
|
|
51
|
+
CREATE TRIGGER IF NOT EXISTS symbols_ai AFTER INSERT ON symbols BEGIN
|
|
52
|
+
INSERT INTO symbols_fts(rowid, name, file_path, signature)
|
|
53
|
+
VALUES (new.id, new.name, new.file_path, new.signature);
|
|
54
|
+
END;
|
|
55
|
+
|
|
56
|
+
CREATE TRIGGER IF NOT EXISTS symbols_ad AFTER DELETE ON symbols BEGIN
|
|
57
|
+
DELETE FROM symbols_fts WHERE rowid = old.id;
|
|
58
|
+
END;
|
|
59
|
+
|
|
60
|
+
CREATE TRIGGER IF NOT EXISTS symbols_au AFTER UPDATE ON symbols BEGIN
|
|
61
|
+
DELETE FROM symbols_fts WHERE rowid = old.id;
|
|
62
|
+
INSERT INTO symbols_fts(rowid, name, file_path, signature)
|
|
63
|
+
VALUES (new.id, new.name, new.file_path, new.signature);
|
|
64
|
+
END;
|
|
65
|
+
|
|
66
|
+
-- Metadata table for tracking indexing status
|
|
67
|
+
CREATE TABLE IF NOT EXISTS metadata (
|
|
68
|
+
key TEXT PRIMARY KEY,
|
|
69
|
+
value TEXT,
|
|
70
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
-- Raw references (untrusted cscope output, stored verbatim for debugging/replay)
|
|
74
|
+
-- This is the ingestion layer: what cscope actually said, before semantic resolution
|
|
75
|
+
CREATE TABLE IF NOT EXISTS raw_references (
|
|
76
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
77
|
+
query_type TEXT NOT NULL, -- 'callees', 'callers', 'includes', 'symbol'
|
|
78
|
+
query_symbol TEXT NOT NULL, -- what we asked cscope for (function/header name)
|
|
79
|
+
source_file TEXT NOT NULL, -- file from cscope output (relative POSIX path)
|
|
80
|
+
source_function TEXT, -- function from cscope output (may be NULL for includes)
|
|
81
|
+
line_number INTEGER NOT NULL, -- line number from cscope output
|
|
82
|
+
line_text TEXT, -- raw line content from cscope
|
|
83
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
-- Indexes for raw_references (query patterns: by type/symbol, by source location)
|
|
87
|
+
CREATE INDEX IF NOT EXISTS idx_raw_refs_query ON raw_references(query_type, query_symbol);
|
|
88
|
+
CREATE INDEX IF NOT EXISTS idx_raw_refs_source ON raw_references(source_file, source_function);
|
|
89
|
+
|
|
90
|
+
-- Symbol edges (trusted semantic graph: resolved symbol_id → symbol_id relationships)
|
|
91
|
+
-- This is the semantic layer: machine-readable typed edges between symbols
|
|
92
|
+
CREATE TABLE IF NOT EXISTS symbol_edges (
|
|
93
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
94
|
+
edge_type TEXT NOT NULL, -- 'CALLS', 'INCLUDES' (later: 'USES', 'DEFINES')
|
|
95
|
+
src_symbol_id INTEGER NOT NULL, -- source symbol (who calls/includes)
|
|
96
|
+
dst_symbol_id INTEGER NOT NULL, -- destination symbol (what is called/included)
|
|
97
|
+
source_file TEXT NOT NULL, -- where the edge occurs (file path)
|
|
98
|
+
line_number INTEGER, -- where the edge occurs (line number)
|
|
99
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
100
|
+
FOREIGN KEY(src_symbol_id) REFERENCES symbols(id) ON DELETE CASCADE,
|
|
101
|
+
FOREIGN KEY(dst_symbol_id) REFERENCES symbols(id) ON DELETE CASCADE,
|
|
102
|
+
UNIQUE(edge_type, src_symbol_id, dst_symbol_id, source_file, line_number)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
-- Indexes for symbol_edges (query patterns: find edges by type and direction)
|
|
106
|
+
CREATE INDEX IF NOT EXISTS idx_edges_src ON symbol_edges(edge_type, src_symbol_id);
|
|
107
|
+
CREATE INDEX IF NOT EXISTS idx_edges_dst ON symbol_edges(edge_type, dst_symbol_id);
|
|
108
|
+
|
|
109
|
+
-- File edges (file-to-file relationships: includes, imports, etc.)
|
|
110
|
+
-- This is separate from symbol_edges because files are not symbols
|
|
111
|
+
CREATE TABLE IF NOT EXISTS file_edges (
|
|
112
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
113
|
+
edge_type TEXT NOT NULL, -- 'INCLUDES' (later: 'IMPORTS' for Python/JS)
|
|
114
|
+
src_file TEXT NOT NULL, -- includer (repo-relative POSIX path)
|
|
115
|
+
dst_file TEXT NOT NULL, -- included (repo-relative POSIX path)
|
|
116
|
+
line_number INTEGER, -- where the include occurs
|
|
117
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
118
|
+
UNIQUE(edge_type, src_file, dst_file, line_number)
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
-- Indexes for file_edges (query patterns: find dependencies by direction)
|
|
122
|
+
CREATE INDEX IF NOT EXISTS idx_file_edges_src ON file_edges(edge_type, src_file);
|
|
123
|
+
CREATE INDEX IF NOT EXISTS idx_file_edges_dst ON file_edges(edge_type, dst_file);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: srcodex
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Semantic code explorer with AI-powered search and analysis
|
|
5
|
-
Author
|
|
5
|
+
Author: Jonathan L'Work
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/Jonathan03ant/srcodex
|
|
8
8
|
Project-URL: Repository, https://github.com/Jonathan03ant/srcodex
|
|
@@ -43,28 +43,67 @@ Unlike generic code assistants (Claude CLI, GitHub Copilot, etc.) that read enti
|
|
|
43
43
|
| "Find all ioctls" | Grep + read matches (15K tokens) | Database search (300 tokens) |
|
|
44
44
|
| "Explain module Y" | Read 10+ files (30K tokens) | Aggregate query (2K tokens) |
|
|
45
45
|
|
|
46
|
-
**Result:**
|
|
46
|
+
**Result:** 99% more token-efficient, instant relationship queries, and unique capabilities impossible for file-based tools (call chains, data flow analysis, architecture visualization).
|
|
47
47
|
|
|
48
|
-
## Features
|
|
48
|
+
## Key Features
|
|
49
49
|
|
|
50
|
-
- **Semantic Indexing**:
|
|
51
|
-
- **AI-Powered
|
|
52
|
-
- **Call Graph Analysis**: Trace function calls,
|
|
53
|
-
- **Terminal UI**:
|
|
54
|
-
- **Multi-Language**:
|
|
55
|
-
- **
|
|
56
|
-
- **Portable**: `.srcodex/` directory makes indexed projects shareable
|
|
50
|
+
- **Semantic Indexing Engine**: Extracts symbols, relationships, and cross-references from source code
|
|
51
|
+
- **AI-Powered Chat**: Natural language queries about your codebase architecture
|
|
52
|
+
- **Call Graph Analysis**: Trace function calls, caller chains, and dependency paths
|
|
53
|
+
- **Terminal UI**: Full-featured TUI with file browser, search, and AI chat interface
|
|
54
|
+
- **Multi-Language Support**: C, C++, Python, JavaScript, Go, Rust, and more
|
|
55
|
+
- **Persistent Graph Database**: SQLite-backed semantic graph with relationship edges
|
|
56
|
+
- **Portable**: `.srcodex/` directory makes indexed projects shareable across teams
|
|
57
|
+
- **Token Efficient**: 99% reduction in API costs via semantic queries and intelligent caching
|
|
57
58
|
|
|
58
59
|
## Installation
|
|
59
60
|
|
|
61
|
+
### From PyPI (Recommended)
|
|
62
|
+
|
|
60
63
|
```bash
|
|
61
64
|
pip install srcodex
|
|
62
65
|
```
|
|
63
66
|
|
|
67
|
+
### From Source
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git clone https://github.com/Jonathan03ant/srcodex.git
|
|
71
|
+
cd srcodex
|
|
72
|
+
pip install -e .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Prerequisites
|
|
76
|
+
|
|
77
|
+
Before installing srcodex, you need these system tools:
|
|
78
|
+
|
|
79
|
+
**Ubuntu/Debian:**
|
|
80
|
+
```bash
|
|
81
|
+
sudo apt install universal-ctags cscope
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**macOS:**
|
|
85
|
+
```bash
|
|
86
|
+
brew install universal-ctags cscope
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Arch Linux:**
|
|
90
|
+
```bash
|
|
91
|
+
sudo pacman -S ctags cscope
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Other systems:** Install Universal CTags from https://github.com/universal-ctags/ctags
|
|
95
|
+
|
|
64
96
|
## Quick Start
|
|
65
97
|
|
|
66
98
|
```bash
|
|
67
|
-
#
|
|
99
|
+
# 1. Install srcodex
|
|
100
|
+
pip install srcodex
|
|
101
|
+
|
|
102
|
+
# 2. Configure API key
|
|
103
|
+
export ANTHROPIC_API_KEY="your-api-key"
|
|
104
|
+
# Or create .env file with ANTHROPIC_API_KEY=...
|
|
105
|
+
|
|
106
|
+
# 3. Index your codebase (first time)
|
|
68
107
|
cd /path/to/your/project
|
|
69
108
|
srcodex
|
|
70
109
|
|
|
@@ -73,7 +112,7 @@ srcodex
|
|
|
73
112
|
# [Indexing happens...]
|
|
74
113
|
# [TUI launches]
|
|
75
114
|
|
|
76
|
-
# Next time - instant launch
|
|
115
|
+
# 4. Next time - instant launch (uses cached index)
|
|
77
116
|
srcodex
|
|
78
117
|
```
|
|
79
118
|
|
|
@@ -96,51 +135,71 @@ Once indexed, use the TUI to:
|
|
|
96
135
|
|
|
97
136
|
## Configuration
|
|
98
137
|
|
|
99
|
-
|
|
138
|
+
srcodex requires a Claude API key from Anthropic.
|
|
100
139
|
|
|
140
|
+
**Option 1: Environment Variable**
|
|
101
141
|
```bash
|
|
102
|
-
|
|
103
|
-
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
104
|
-
|
|
105
|
-
# Or enterprise gateway (if applicable)
|
|
106
|
-
AMD_LLM_API_KEY=your-subscription-key
|
|
142
|
+
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
|
|
107
143
|
```
|
|
108
144
|
|
|
109
|
-
|
|
145
|
+
**Option 2: .env File**
|
|
146
|
+
Create a `.env` file in your project directory:
|
|
147
|
+
```bash
|
|
148
|
+
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
149
|
+
```
|
|
110
150
|
|
|
111
|
-
|
|
112
|
-
- Universal CTags (`brew install universal-ctags` or `apt install universal-ctags`)
|
|
113
|
-
- Cscope (optional, for call graph)
|
|
114
|
-
- Claude API key (Anthropic or enterprise gateway)
|
|
151
|
+
Get your API key from https://console.anthropic.com/
|
|
115
152
|
|
|
116
153
|
## How It Works
|
|
117
154
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
155
|
+
**Indexing Phase:**
|
|
156
|
+
1. Analyzes source code to extract symbols, functions, types, and relationships
|
|
157
|
+
2. Builds a semantic graph database with typed edges (function calls, includes, data access)
|
|
158
|
+
3. Stores everything in a persistent SQLite database
|
|
159
|
+
|
|
160
|
+
**Query Phase:**
|
|
161
|
+
1. You ask questions in natural language via the terminal UI
|
|
162
|
+
2. Claude queries the semantic graph database using specialized tools
|
|
163
|
+
3. Returns targeted answers without reading entire files
|
|
164
|
+
|
|
165
|
+
**Why This Is Efficient:**
|
|
166
|
+
- Traditional code assistants: Read full files (20K-60K tokens per query)
|
|
167
|
+
- srcodex: Semantic graph queries (100-500 tokens per query)
|
|
168
|
+
- Intelligent caching: First query builds cache, subsequent queries reuse it
|
|
169
|
+
- Result: 99% reduction in API costs
|
|
128
170
|
|
|
129
171
|
## Project Structure
|
|
130
172
|
|
|
131
|
-
After indexing, your project
|
|
173
|
+
After indexing, srcodex creates a `.srcodex/` directory in your project:
|
|
132
174
|
|
|
133
175
|
```
|
|
134
176
|
your-project/
|
|
135
177
|
├── .srcodex/
|
|
136
|
-
│ ├── metadata.json # Project
|
|
137
|
-
│ ├── config.toml # Indexing config
|
|
178
|
+
│ ├── metadata.json # Project statistics
|
|
138
179
|
│ ├── data/
|
|
139
|
-
│ │ └── project.db # Semantic graph
|
|
140
|
-
│
|
|
180
|
+
│ │ └── project.db # Semantic graph database
|
|
181
|
+
│ ├── conversations/ # Chat history
|
|
182
|
+
│ └── .debug/ # Debug logs
|
|
141
183
|
└── [your source files...]
|
|
142
184
|
```
|
|
143
185
|
|
|
186
|
+
The `.srcodex/` directory is portable - you can commit it to git or share it with your team to avoid re-indexing.
|
|
187
|
+
|
|
188
|
+
## Performance
|
|
189
|
+
|
|
190
|
+
**Indexing Speed** (varies by codebase size):
|
|
191
|
+
- Small projects (< 100 files): 2-5 seconds
|
|
192
|
+
- Medium projects (100-1000 files): 5-20 seconds
|
|
193
|
+
- Large projects (1000+ files): 20-60 seconds
|
|
194
|
+
|
|
195
|
+
**Query Speed:**
|
|
196
|
+
- Database queries: < 100ms
|
|
197
|
+
- AI responses: 2-10 seconds (depends on complexity)
|
|
198
|
+
|
|
199
|
+
**Token Usage:**
|
|
200
|
+
- First query: 500-2000 tokens (builds cache)
|
|
201
|
+
- Subsequent queries: 25-200 tokens (uses cache)
|
|
202
|
+
|
|
144
203
|
## Development
|
|
145
204
|
|
|
146
205
|
```bash
|
|
@@ -151,8 +210,8 @@ cd srcodex
|
|
|
151
210
|
# Install in development mode
|
|
152
211
|
pip install -e .
|
|
153
212
|
|
|
154
|
-
#
|
|
155
|
-
|
|
213
|
+
# Index and run on srcodex itself
|
|
214
|
+
srcodex .
|
|
156
215
|
```
|
|
157
216
|
|
|
158
217
|
## License
|
|
@@ -30,6 +30,7 @@ srcodex/indexer/__init__.py
|
|
|
30
30
|
srcodex/indexer/cscope_client.py
|
|
31
31
|
srcodex/indexer/ctags_compat.py
|
|
32
32
|
srcodex/indexer/ctags_parser.py
|
|
33
|
+
srcodex/indexer/db_schema.sql
|
|
33
34
|
srcodex/indexer/explorer.py
|
|
34
35
|
srcodex/indexer/field_access_analyzer.py
|
|
35
36
|
srcodex/indexer/indexer.py
|
srcodex-0.2.0/README.md
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# srcodex
|
|
2
|
-
|
|
3
|
-
**Semantic code explorer with AI-powered search and analysis**
|
|
4
|
-
|
|
5
|
-
srcodex builds a semantic graph of your codebase and provides AI-powered exploration through natural language queries. Think of it as an intelligent code search that understands relationships, call graphs, and architecture.
|
|
6
|
-
|
|
7
|
-
## Why srcodex?
|
|
8
|
-
|
|
9
|
-
Unlike generic code assistants (Claude CLI, GitHub Copilot, etc.) that read entire files to answer questions, srcodex uses a **semantic graph database** to understand your code:
|
|
10
|
-
|
|
11
|
-
| Question | Generic Assistant | srcodex |
|
|
12
|
-
|----------|------------------|---------|
|
|
13
|
-
| "Who calls function X?" | Grep entire codebase (20K tokens) | `get_callers('X')` (200 tokens) |
|
|
14
|
-
| "Show call chain A→B" | Read multiple files, manual tracing | Graph query (500 tokens) |
|
|
15
|
-
| "Find all ioctls" | Grep + read matches (15K tokens) | Database search (300 tokens) |
|
|
16
|
-
| "Explain module Y" | Read 10+ files (30K tokens) | Aggregate query (2K tokens) |
|
|
17
|
-
|
|
18
|
-
**Result:** 90% more token-efficient, instant relationship queries, and unique capabilities impossible for file-based tools (call chains, data flow analysis, architecture visualization).
|
|
19
|
-
|
|
20
|
-
## Features
|
|
21
|
-
|
|
22
|
-
- **Semantic Indexing**: Builds a persistent graph of symbols, functions, types, and their relationships
|
|
23
|
-
- **AI-Powered Search**: Ask questions in natural language about your code
|
|
24
|
-
- **Call Graph Analysis**: Trace function calls, dependencies, and execution paths
|
|
25
|
-
- **Terminal UI**: Beautiful terminal interface with file browser and AI chat
|
|
26
|
-
- **Multi-Language**: Supports C, C++, Python, and more
|
|
27
|
-
- **Fast**: SQLite-backed graph queries with intelligent caching
|
|
28
|
-
- **Portable**: `.srcodex/` directory makes indexed projects shareable
|
|
29
|
-
|
|
30
|
-
## Installation
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
pip install srcodex
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Quick Start
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
# Index your codebase (first time)
|
|
40
|
-
cd /path/to/your/project
|
|
41
|
-
srcodex
|
|
42
|
-
|
|
43
|
-
# Output:
|
|
44
|
-
# No .srcodex/ found. Index this directory? (y/n) y
|
|
45
|
-
# [Indexing happens...]
|
|
46
|
-
# [TUI launches]
|
|
47
|
-
|
|
48
|
-
# Next time - instant launch
|
|
49
|
-
srcodex
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Usage
|
|
53
|
-
|
|
54
|
-
Once indexed, use the TUI to:
|
|
55
|
-
- Browse files and symbols
|
|
56
|
-
- Search across your codebase
|
|
57
|
-
- Chat with AI about your code architecture
|
|
58
|
-
- Trace call chains and dependencies
|
|
59
|
-
|
|
60
|
-
### Example AI Queries
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
"What does the init_system function do?"
|
|
64
|
-
"Show me all functions that call malloc"
|
|
65
|
-
"Trace the execution path from main to shutdown"
|
|
66
|
-
"What structs are defined in config.h?"
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Configuration
|
|
70
|
-
|
|
71
|
-
Copy `.env.example` to `.env` and configure your API key:
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# Public Anthropic API
|
|
75
|
-
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
76
|
-
|
|
77
|
-
# Or enterprise gateway (if applicable)
|
|
78
|
-
AMD_LLM_API_KEY=your-subscription-key
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Requirements
|
|
82
|
-
|
|
83
|
-
- Python 3.9+
|
|
84
|
-
- Universal CTags (`brew install universal-ctags` or `apt install universal-ctags`)
|
|
85
|
-
- Cscope (optional, for call graph)
|
|
86
|
-
- Claude API key (Anthropic or enterprise gateway)
|
|
87
|
-
|
|
88
|
-
## How It Works
|
|
89
|
-
|
|
90
|
-
1. **Indexing**: Extracts symbols, relationships, and metadata using CTags and Cscope
|
|
91
|
-
2. **Graph Building**: Creates semantic graph with typed edges (CALLS, INCLUDES, ACCESSES)
|
|
92
|
-
3. **AI Integration**: Claude queries the graph using specialized tools (not reading full files)
|
|
93
|
-
4. **Token Efficiency**: **99%+ reduction** in tokens vs. traditional code assistants
|
|
94
|
-
- **Breakthrough caching architecture**: 25-100 tokens per query after initial cache build
|
|
95
|
-
- Aggressive parallel tool batching (20-40 tools per iteration)
|
|
96
|
-
- 3-iteration cache strategy: iterations 1-3 cached, iteration 4 answers with cached data
|
|
97
|
-
- Semantic graph queries instead of file reads (10-100x more efficient)
|
|
98
|
-
- **Real example**: 500 input tokens vs 60,000+ for traditional file-based approaches
|
|
99
|
-
- Cache persists across queries - subsequent questions cost nearly nothing!
|
|
100
|
-
|
|
101
|
-
## Project Structure
|
|
102
|
-
|
|
103
|
-
After indexing, your project will have:
|
|
104
|
-
|
|
105
|
-
```
|
|
106
|
-
your-project/
|
|
107
|
-
├── .srcodex/
|
|
108
|
-
│ ├── metadata.json # Project stats
|
|
109
|
-
│ ├── config.toml # Indexing config
|
|
110
|
-
│ ├── data/
|
|
111
|
-
│ │ └── project.db # Semantic graph
|
|
112
|
-
│ └── logs/ # Debug logs
|
|
113
|
-
└── [your source files...]
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Development
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
# Clone repository
|
|
120
|
-
git clone https://github.com/Jonathan03ant/srcodex.git
|
|
121
|
-
cd srcodex
|
|
122
|
-
|
|
123
|
-
# Install in development mode
|
|
124
|
-
pip install -e .
|
|
125
|
-
|
|
126
|
-
# Run tests
|
|
127
|
-
pytest
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## License
|
|
131
|
-
|
|
132
|
-
MIT License - see LICENSE file for details
|
|
133
|
-
|
|
134
|
-
## Contributing
|
|
135
|
-
|
|
136
|
-
Contributions welcome! Please open an issue or pull request.
|
|
137
|
-
|
|
138
|
-
## Links
|
|
139
|
-
|
|
140
|
-
- [GitHub Repository](https://github.com/Jonathan03ant/srcodex)
|
|
141
|
-
- [Issue Tracker](https://github.com/Jonathan03ant/srcodex/issues)
|
|
142
|
-
- [Documentation](https://github.com/Jonathan03ant/srcodex/wiki)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|