srcodex 0.2.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.
- srcodex-0.2.0/.env.example +27 -0
- srcodex-0.2.0/LICENSE +21 -0
- srcodex-0.2.0/MANIFEST.in +14 -0
- srcodex-0.2.0/PKG-INFO +170 -0
- srcodex-0.2.0/README.md +142 -0
- srcodex-0.2.0/pyproject.toml +47 -0
- srcodex-0.2.0/setup.cfg +4 -0
- srcodex-0.2.0/srcodex/__init__.py +0 -0
- srcodex-0.2.0/srcodex/backend/__init__.py +0 -0
- srcodex-0.2.0/srcodex/backend/chat.py +79 -0
- srcodex-0.2.0/srcodex/backend/main.py +98 -0
- srcodex-0.2.0/srcodex/backend/services/__init__.py +0 -0
- srcodex-0.2.0/srcodex/backend/services/claude_service.py +754 -0
- srcodex-0.2.0/srcodex/backend/services/config_loader.py +113 -0
- srcodex-0.2.0/srcodex/backend/services/file_access_tools.py +279 -0
- srcodex-0.2.0/srcodex/backend/services/file_tree.py +480 -0
- srcodex-0.2.0/srcodex/backend/services/graph_tools.py +874 -0
- srcodex-0.2.0/srcodex/backend/services/logger_setup.py +91 -0
- srcodex-0.2.0/srcodex/backend/services/session_manager.py +81 -0
- srcodex-0.2.0/srcodex/backend/services/status_tracker.py +91 -0
- srcodex-0.2.0/srcodex/cli.py +255 -0
- srcodex-0.2.0/srcodex/core/__init__.py +0 -0
- srcodex-0.2.0/srcodex/core/config.py +113 -0
- srcodex-0.2.0/srcodex/core/logger.py +23 -0
- srcodex-0.2.0/srcodex/indexer/__init__.py +0 -0
- srcodex-0.2.0/srcodex/indexer/cscope_client.py +183 -0
- srcodex-0.2.0/srcodex/indexer/ctags_compat.py +223 -0
- srcodex-0.2.0/srcodex/indexer/ctags_parser.py +456 -0
- srcodex-0.2.0/srcodex/indexer/explorer.py +135 -0
- srcodex-0.2.0/srcodex/indexer/field_access_analyzer.py +436 -0
- srcodex-0.2.0/srcodex/indexer/indexer.py +664 -0
- srcodex-0.2.0/srcodex/indexer/reference_ingestor.py +293 -0
- srcodex-0.2.0/srcodex/indexer/reference_resolver.py +544 -0
- srcodex-0.2.0/srcodex/tui/__init__.py +0 -0
- srcodex-0.2.0/srcodex/tui/app.py +103 -0
- srcodex-0.2.0/srcodex/tui/app.tcss +24 -0
- srcodex-0.2.0/srcodex/tui/components/__init__.py +0 -0
- srcodex-0.2.0/srcodex/tui/components/bars/__init__.py +0 -0
- srcodex-0.2.0/srcodex/tui/components/bars/chat_header.py +48 -0
- srcodex-0.2.0/srcodex/tui/components/bars/code_tab_bar.py +157 -0
- srcodex-0.2.0/srcodex/tui/components/bars/footer_bar.py +128 -0
- srcodex-0.2.0/srcodex/tui/components/bars/left_tab.py +54 -0
- srcodex-0.2.0/srcodex/tui/components/logger.py +57 -0
- srcodex-0.2.0/srcodex/tui/components/panels/__init__.py +0 -0
- srcodex-0.2.0/srcodex/tui/components/panels/chat_panel.py +523 -0
- srcodex-0.2.0/srcodex/tui/components/panels/code_panel.py +229 -0
- srcodex-0.2.0/srcodex/tui/components/panels/side_panel.py +128 -0
- srcodex-0.2.0/srcodex/tui/components/views/__init__.py +0 -0
- srcodex-0.2.0/srcodex/tui/components/views/explorer_view.py +20 -0
- srcodex-0.2.0/srcodex/tui/components/views/search_view.py +148 -0
- srcodex-0.2.0/srcodex/tui/components/widgets/__init__.py +0 -0
- srcodex-0.2.0/srcodex/tui/components/widgets/file_browser.py +16 -0
- srcodex-0.2.0/srcodex/tui/components/widgets/find_box.py +85 -0
- srcodex-0.2.0/srcodex.egg-info/PKG-INFO +170 -0
- srcodex-0.2.0/srcodex.egg-info/SOURCES.txt +57 -0
- srcodex-0.2.0/srcodex.egg-info/dependency_links.txt +1 -0
- srcodex-0.2.0/srcodex.egg-info/entry_points.txt +2 -0
- srcodex-0.2.0/srcodex.egg-info/requires.txt +7 -0
- srcodex-0.2.0/srcodex.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# srcodex Environment Configuration
|
|
2
|
+
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Claude API Configuration
|
|
5
|
+
# =============================================================================
|
|
6
|
+
|
|
7
|
+
# Public Anthropic API (default)
|
|
8
|
+
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
9
|
+
ANTHROPIC_BASE_URL=https://api.anthropic.com
|
|
10
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-20250514
|
|
11
|
+
|
|
12
|
+
# =============================================================================
|
|
13
|
+
# Enterprise Gateway Support (AMD/Google/NVIDIA internal users)
|
|
14
|
+
# =============================================================================
|
|
15
|
+
# If your organization uses an LLM gateway, configure accordingly:
|
|
16
|
+
|
|
17
|
+
# Example: Internal gateway with subscription key
|
|
18
|
+
# AMD_LLM_API_KEY=your-subscription-key
|
|
19
|
+
# ANTHROPIC_BASE_URL=https://your-gateway.company.com/Anthropic
|
|
20
|
+
# ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4.5
|
|
21
|
+
|
|
22
|
+
# =============================================================================
|
|
23
|
+
# Notes
|
|
24
|
+
# =============================================================================
|
|
25
|
+
# - Public users: Set ANTHROPIC_API_KEY
|
|
26
|
+
# - Enterprise users: Set your company's gateway key (e.g., AMD_LLM_API_KEY)
|
|
27
|
+
# - The service auto-detects which mode to use based on available keys
|
srcodex-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jonathan L'Work
|
|
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,14 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include pyproject.toml
|
|
4
|
+
include .env.example
|
|
5
|
+
|
|
6
|
+
# Include CSS files for TUI
|
|
7
|
+
recursive-include srcodex/tui *.tcss
|
|
8
|
+
|
|
9
|
+
# Exclude development files
|
|
10
|
+
exclude STATUS.md
|
|
11
|
+
exclude WORKFLOW.md
|
|
12
|
+
global-exclude __pycache__
|
|
13
|
+
global-exclude *.py[co]
|
|
14
|
+
global-exclude .DS_Store
|
srcodex-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: srcodex
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Semantic code explorer with AI-powered search and analysis
|
|
5
|
+
Author-email: Jonathan Antoun <jonathan.antoun@amd.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Jonathan03ant/srcodex
|
|
8
|
+
Project-URL: Repository, https://github.com/Jonathan03ant/srcodex
|
|
9
|
+
Project-URL: Issues, https://github.com/Jonathan03ant/srcodex/issues
|
|
10
|
+
Keywords: code-search,semantic-analysis,ai,llm,code-exploration
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: click>=8.1.0
|
|
21
|
+
Requires-Dist: textual[syntax]>=0.47.0
|
|
22
|
+
Requires-Dist: fastapi>=0.100.0
|
|
23
|
+
Requires-Dist: uvicorn>=0.23.0
|
|
24
|
+
Requires-Dist: anthropic>=0.7.0
|
|
25
|
+
Requires-Dist: httpx>=0.24.0
|
|
26
|
+
Requires-Dist: tqdm>=4.66.0
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# srcodex
|
|
30
|
+
|
|
31
|
+
**Semantic code explorer with AI-powered search and analysis**
|
|
32
|
+
|
|
33
|
+
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.
|
|
34
|
+
|
|
35
|
+
## Why srcodex?
|
|
36
|
+
|
|
37
|
+
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:
|
|
38
|
+
|
|
39
|
+
| Question | Generic Assistant | srcodex |
|
|
40
|
+
|----------|------------------|---------|
|
|
41
|
+
| "Who calls function X?" | Grep entire codebase (20K tokens) | `get_callers('X')` (200 tokens) |
|
|
42
|
+
| "Show call chain A→B" | Read multiple files, manual tracing | Graph query (500 tokens) |
|
|
43
|
+
| "Find all ioctls" | Grep + read matches (15K tokens) | Database search (300 tokens) |
|
|
44
|
+
| "Explain module Y" | Read 10+ files (30K tokens) | Aggregate query (2K tokens) |
|
|
45
|
+
|
|
46
|
+
**Result:** 90% more token-efficient, instant relationship queries, and unique capabilities impossible for file-based tools (call chains, data flow analysis, architecture visualization).
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **Semantic Indexing**: Builds a persistent graph of symbols, functions, types, and their relationships
|
|
51
|
+
- **AI-Powered Search**: Ask questions in natural language about your code
|
|
52
|
+
- **Call Graph Analysis**: Trace function calls, dependencies, and execution paths
|
|
53
|
+
- **Terminal UI**: Beautiful terminal interface with file browser and AI chat
|
|
54
|
+
- **Multi-Language**: Supports C, C++, Python, and more
|
|
55
|
+
- **Fast**: SQLite-backed graph queries with intelligent caching
|
|
56
|
+
- **Portable**: `.srcodex/` directory makes indexed projects shareable
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install srcodex
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Index your codebase (first time)
|
|
68
|
+
cd /path/to/your/project
|
|
69
|
+
srcodex
|
|
70
|
+
|
|
71
|
+
# Output:
|
|
72
|
+
# No .srcodex/ found. Index this directory? (y/n) y
|
|
73
|
+
# [Indexing happens...]
|
|
74
|
+
# [TUI launches]
|
|
75
|
+
|
|
76
|
+
# Next time - instant launch
|
|
77
|
+
srcodex
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
Once indexed, use the TUI to:
|
|
83
|
+
- Browse files and symbols
|
|
84
|
+
- Search across your codebase
|
|
85
|
+
- Chat with AI about your code architecture
|
|
86
|
+
- Trace call chains and dependencies
|
|
87
|
+
|
|
88
|
+
### Example AI Queries
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
"What does the init_system function do?"
|
|
92
|
+
"Show me all functions that call malloc"
|
|
93
|
+
"Trace the execution path from main to shutdown"
|
|
94
|
+
"What structs are defined in config.h?"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Configuration
|
|
98
|
+
|
|
99
|
+
Copy `.env.example` to `.env` and configure your API key:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Public Anthropic API
|
|
103
|
+
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
104
|
+
|
|
105
|
+
# Or enterprise gateway (if applicable)
|
|
106
|
+
AMD_LLM_API_KEY=your-subscription-key
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Requirements
|
|
110
|
+
|
|
111
|
+
- Python 3.9+
|
|
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)
|
|
115
|
+
|
|
116
|
+
## How It Works
|
|
117
|
+
|
|
118
|
+
1. **Indexing**: Extracts symbols, relationships, and metadata using CTags and Cscope
|
|
119
|
+
2. **Graph Building**: Creates semantic graph with typed edges (CALLS, INCLUDES, ACCESSES)
|
|
120
|
+
3. **AI Integration**: Claude queries the graph using specialized tools (not reading full files)
|
|
121
|
+
4. **Token Efficiency**: **99%+ reduction** in tokens vs. traditional code assistants
|
|
122
|
+
- **Breakthrough caching architecture**: 25-100 tokens per query after initial cache build
|
|
123
|
+
- Aggressive parallel tool batching (20-40 tools per iteration)
|
|
124
|
+
- 3-iteration cache strategy: iterations 1-3 cached, iteration 4 answers with cached data
|
|
125
|
+
- Semantic graph queries instead of file reads (10-100x more efficient)
|
|
126
|
+
- **Real example**: 500 input tokens vs 60,000+ for traditional file-based approaches
|
|
127
|
+
- Cache persists across queries - subsequent questions cost nearly nothing!
|
|
128
|
+
|
|
129
|
+
## Project Structure
|
|
130
|
+
|
|
131
|
+
After indexing, your project will have:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
your-project/
|
|
135
|
+
├── .srcodex/
|
|
136
|
+
│ ├── metadata.json # Project stats
|
|
137
|
+
│ ├── config.toml # Indexing config
|
|
138
|
+
│ ├── data/
|
|
139
|
+
│ │ └── project.db # Semantic graph
|
|
140
|
+
│ └── logs/ # Debug logs
|
|
141
|
+
└── [your source files...]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Development
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Clone repository
|
|
148
|
+
git clone https://github.com/Jonathan03ant/srcodex.git
|
|
149
|
+
cd srcodex
|
|
150
|
+
|
|
151
|
+
# Install in development mode
|
|
152
|
+
pip install -e .
|
|
153
|
+
|
|
154
|
+
# Run tests
|
|
155
|
+
pytest
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT License - see LICENSE file for details
|
|
161
|
+
|
|
162
|
+
## Contributing
|
|
163
|
+
|
|
164
|
+
Contributions welcome! Please open an issue or pull request.
|
|
165
|
+
|
|
166
|
+
## Links
|
|
167
|
+
|
|
168
|
+
- [GitHub Repository](https://github.com/Jonathan03ant/srcodex)
|
|
169
|
+
- [Issue Tracker](https://github.com/Jonathan03ant/srcodex/issues)
|
|
170
|
+
- [Documentation](https://github.com/Jonathan03ant/srcodex/wiki)
|
srcodex-0.2.0/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
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)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "srcodex"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Semantic code explorer with AI-powered search and analysis"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Jonathan Antoun", email = "jonathan.antoun@amd.com"}
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"code-search",
|
|
17
|
+
"semantic-analysis",
|
|
18
|
+
"ai",
|
|
19
|
+
"llm",
|
|
20
|
+
"code-exploration"
|
|
21
|
+
]
|
|
22
|
+
classifiers = [
|
|
23
|
+
"Development Status :: 3 - Alpha",
|
|
24
|
+
"Intended Audience :: Developers",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Programming Language :: Python :: 3.9",
|
|
27
|
+
"Programming Language :: Python :: 3.10",
|
|
28
|
+
"Programming Language :: Python :: 3.11",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
dependencies = [
|
|
32
|
+
"click>=8.1.0",
|
|
33
|
+
"textual[syntax]>=0.47.0",
|
|
34
|
+
"fastapi>=0.100.0",
|
|
35
|
+
"uvicorn>=0.23.0",
|
|
36
|
+
"anthropic>=0.7.0",
|
|
37
|
+
"httpx>=0.24.0",
|
|
38
|
+
"tqdm>=4.66.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.scripts]
|
|
42
|
+
srcodex = "srcodex.cli:main"
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://github.com/Jonathan03ant/srcodex"
|
|
46
|
+
Repository = "https://github.com/Jonathan03ant/srcodex"
|
|
47
|
+
Issues = "https://github.com/Jonathan03ant/srcodex/issues"
|
srcodex-0.2.0/setup.cfg
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from fastapi import FastAPI, HTTPException
|
|
2
|
+
from pydantic import BaseModel
|
|
3
|
+
from .services.claude_service import ClaudeService
|
|
4
|
+
from .services.logger_setup import setup_backend_logging
|
|
5
|
+
from fastapi.responses import StreamingResponse
|
|
6
|
+
import json
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
setup_backend_logging()
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
app = FastAPI()
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
claude_service = ClaudeService()
|
|
17
|
+
except ValueError as e:
|
|
18
|
+
print(f"Warning: {e}")
|
|
19
|
+
claude_service = None
|
|
20
|
+
|
|
21
|
+
class ChatRequest(BaseModel):
|
|
22
|
+
"""Request body for chat endpoint"""
|
|
23
|
+
message: str
|
|
24
|
+
conversation_history: list = []
|
|
25
|
+
|
|
26
|
+
class ChatResponse(BaseModel):
|
|
27
|
+
"""Response body for chat endpoint"""
|
|
28
|
+
response: str
|
|
29
|
+
|
|
30
|
+
@app.post("/api/chat", response_model=ChatResponse)
|
|
31
|
+
async def chat(request: ChatRequest):
|
|
32
|
+
"""
|
|
33
|
+
Chat endpoint - sends message to Claude and returns response
|
|
34
|
+
Example:
|
|
35
|
+
POST /api/chat
|
|
36
|
+
{"message": "What does functionX do?"}
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
{"response": "FunctionX is a function that..."}
|
|
40
|
+
"""
|
|
41
|
+
if not claude_service:
|
|
42
|
+
raise HTTPException(status_code=500, detail="Claude service not initialized - check API key")
|
|
43
|
+
|
|
44
|
+
if not request.message.strip():
|
|
45
|
+
raise HTTPException(status_code=400, detail="Message cannot be empty")
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
logger.info(f"Chat request: {request.message[:100]}...")
|
|
49
|
+
response = claude_service.send_message_with_tools(request.message, request.conversation_history)
|
|
50
|
+
logger.info(f"Chat response: {len(response)} chars")
|
|
51
|
+
return ChatResponse(response=response)
|
|
52
|
+
except Exception as e:
|
|
53
|
+
logger.error(f"Claude API error: {str(e)}")
|
|
54
|
+
raise HTTPException(status_code=500, detail=f"Claude API error: {str(e)}")
|
|
55
|
+
|
|
56
|
+
@app.post("/api/chat/stream")
|
|
57
|
+
async def chat_stream(request: ChatRequest):
|
|
58
|
+
"""
|
|
59
|
+
Streaming chat endpoint - streams Claude's response in real-time
|
|
60
|
+
|
|
61
|
+
Streams newline-delimited JSON objects:
|
|
62
|
+
- Text chunks: {"type": "text", "content": "..."}
|
|
63
|
+
- Token metadata: {"type": "tokens", "input": 1234, "output": 56, "total": 1290}
|
|
64
|
+
"""
|
|
65
|
+
if not claude_service:
|
|
66
|
+
raise HTTPException(status_code=500, detail="Claude service not initialized")
|
|
67
|
+
|
|
68
|
+
if not request.message.strip():
|
|
69
|
+
raise HTTPException(status_code=400, detail="Message cannot be empty")
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
def generate():
|
|
73
|
+
for chunk in claude_service.stream_message_with_tools(request.message, request.conversation_history):
|
|
74
|
+
# Stream as newline-delimited JSON
|
|
75
|
+
yield json.dumps(chunk) + "\n"
|
|
76
|
+
|
|
77
|
+
return StreamingResponse(generate(), media_type="application/x-ndjson")
|
|
78
|
+
except Exception as e:
|
|
79
|
+
raise HTTPException(status_code=500, detail=f"Claude API error: {str(e)}")
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""
|
|
2
|
+
srcodex Backend - Semantic Graph API
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from fastapi import FastAPI
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Dict, List, Any
|
|
8
|
+
import sys
|
|
9
|
+
sys.path.insert(0, str(Path(__file__).parent))
|
|
10
|
+
from services.file_tree import FileTreeService
|
|
11
|
+
DB_PATH = Path(__file__).parent.parent / "data" / "pmfw_main.db" ##Database path
|
|
12
|
+
|
|
13
|
+
app = FastAPI(title="srcodex API", version="0.1.0")
|
|
14
|
+
file_tree_service = FileTreeService(str(DB_PATH))
|
|
15
|
+
|
|
16
|
+
@app.get("/")
|
|
17
|
+
async def root() -> Dict[str, str]:
|
|
18
|
+
""" API Root, returns basic information """
|
|
19
|
+
return {
|
|
20
|
+
"name": "srcodex API",
|
|
21
|
+
"version": "0.1.0"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@app.get("/projects/{project_id}/root")
|
|
25
|
+
async def get_project_root(project_id: str) -> Dict[str, Any]:
|
|
26
|
+
"""
|
|
27
|
+
Get Project root metadata
|
|
28
|
+
Example: GET /projects/pmfw_main/root
|
|
29
|
+
"""
|
|
30
|
+
if project_id != Path(DB_PATH).stem:
|
|
31
|
+
return {"error": f"Project '{project_id}' not found!"}, 404
|
|
32
|
+
|
|
33
|
+
return file_tree_service.get_root()
|
|
34
|
+
|
|
35
|
+
@app.get("/projects/{project_id}/children")
|
|
36
|
+
def get_children(project_id: str, path: str = "") -> List[Dict[str, Any]]:
|
|
37
|
+
"""
|
|
38
|
+
Get Immediate children of a directory.
|
|
39
|
+
Examples:
|
|
40
|
+
GET /projects/pmfw_main/children?path=
|
|
41
|
+
→ Returns root children: [mp1/, mpccx/, common/, test/]
|
|
42
|
+
GET /projects/pmfw_main/children?path=mp1/src/app/
|
|
43
|
+
→ Returns contents of mp1/src/app/
|
|
44
|
+
"""
|
|
45
|
+
if project_id != Path(DB_PATH).stem:
|
|
46
|
+
return {"error": f"Project '{project_id}' not found!"}, 404
|
|
47
|
+
|
|
48
|
+
return file_tree_service.get_children(path)
|
|
49
|
+
|
|
50
|
+
@app.get("/projects/{project_id}/search/files")
|
|
51
|
+
def search_file(project_id: str, q: str = "") -> List[Dict[str, Any]]:
|
|
52
|
+
"""
|
|
53
|
+
Search for files by name or path (like Ctrl+P in VSCode).
|
|
54
|
+
Examples:
|
|
55
|
+
GET /projects/pmfw_main/search/files?q=msg
|
|
56
|
+
→ Returns files matching "msg": [msg.c, msg.h, ...]
|
|
57
|
+
GET /projects/pmfw_main/search/files?q=app/pow
|
|
58
|
+
→ Returns files in "app" matching "pow": [mp1/src/app/power.c, ...]
|
|
59
|
+
"""
|
|
60
|
+
if project_id != Path(DB_PATH).stem:
|
|
61
|
+
return {"error": f"Project '{project_id}' not found!"}, 404
|
|
62
|
+
|
|
63
|
+
return file_tree_service.search_file(q)
|
|
64
|
+
|
|
65
|
+
@app.get("/projects/{project_id}/search/symbols")
|
|
66
|
+
def search_symbol_global(project_id: str, q: str = "") -> List[Dict[str, Any]]:
|
|
67
|
+
"""
|
|
68
|
+
Search for symbols globally across entire codebase (like Ctrl+Shift+F in VSCode).
|
|
69
|
+
Examples:
|
|
70
|
+
GET /projects/pmfw_main/search/symbols?q=voltage
|
|
71
|
+
→ Returns all voltage-related symbols (variables, macros, structs, ...)
|
|
72
|
+
GET /projects/pmfw_main/search/symbols?q=Init
|
|
73
|
+
→ Returns all initialization functions
|
|
74
|
+
"""
|
|
75
|
+
if project_id != Path(DB_PATH).stem:
|
|
76
|
+
return {"error": f"Project '{project_id}' not found!"}, 404
|
|
77
|
+
|
|
78
|
+
return file_tree_service.search_symbol_global(q)
|
|
79
|
+
|
|
80
|
+
@app.get("/projects/{project_id}/files/{file_path:path}/symbols")
|
|
81
|
+
def search_symbol_infile(project_id: str, file_path: str, q: str = "") -> List[Dict[str, Any]]:
|
|
82
|
+
"""
|
|
83
|
+
Search symbols within a specific file (like Ctrl+F in VSCode on open file).
|
|
84
|
+
Examples:
|
|
85
|
+
GET /projects/pmfw_main/files/mp1/src/app/msg.c/symbols?q=Isr
|
|
86
|
+
→ Returns all symbols matching "Isr" in msg.c: [IsrHostMsg, IsrBiosMsg, ...]
|
|
87
|
+
GET /projects/pmfw_main/files/mp1/src/app/power.c/symbols?q=Init
|
|
88
|
+
→ Returns all Init functions in power.c
|
|
89
|
+
"""
|
|
90
|
+
if project_id != Path(DB_PATH).stem:
|
|
91
|
+
return {"error": f"Project '{project_id}' not found!"}, 404
|
|
92
|
+
|
|
93
|
+
return file_tree_service.search_symbol_infile(q, file_path)
|
|
94
|
+
|
|
95
|
+
if __name__ == "__main__":
|
|
96
|
+
import uvicorn
|
|
97
|
+
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
|
|
98
|
+
|
|
File without changes
|