neurocode-ai 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.
Files changed (37) hide show
  1. neurocode_ai-0.1.0/LICENSE +21 -0
  2. neurocode_ai-0.1.0/PKG-INFO +193 -0
  3. neurocode_ai-0.1.0/README.md +176 -0
  4. neurocode_ai-0.1.0/neurocode_ai.egg-info/PKG-INFO +193 -0
  5. neurocode_ai-0.1.0/neurocode_ai.egg-info/SOURCES.txt +35 -0
  6. neurocode_ai-0.1.0/neurocode_ai.egg-info/dependency_links.txt +1 -0
  7. neurocode_ai-0.1.0/neurocode_ai.egg-info/entry_points.txt +4 -0
  8. neurocode_ai-0.1.0/neurocode_ai.egg-info/requires.txt +6 -0
  9. neurocode_ai-0.1.0/neurocode_ai.egg-info/top_level.txt +1 -0
  10. neurocode_ai-0.1.0/pyproject.toml +29 -0
  11. neurocode_ai-0.1.0/setup.cfg +4 -0
  12. neurocode_ai-0.1.0/src/__init__.py +0 -0
  13. neurocode_ai-0.1.0/src/agent/llm_interface.py +62 -0
  14. neurocode_ai-0.1.0/src/agent/patcher.py +124 -0
  15. neurocode_ai-0.1.0/src/benchmark/create_thumbnail.py +64 -0
  16. neurocode_ai-0.1.0/src/benchmark/end_to_end_benchmark.py +638 -0
  17. neurocode_ai-0.1.0/src/benchmark/evaluator.py +124 -0
  18. neurocode_ai-0.1.0/src/benchmark/generate_4x3_figures.py +259 -0
  19. neurocode_ai-0.1.0/src/benchmark/mlsys_microbenchmarks.py +351 -0
  20. neurocode_ai-0.1.0/src/benchmark/plot_ablation.py +96 -0
  21. neurocode_ai-0.1.0/src/benchmark/plot_architecture.py +79 -0
  22. neurocode_ai-0.1.0/src/benchmark/plot_empirical_fig1.py +97 -0
  23. neurocode_ai-0.1.0/src/benchmark/run_ablation_study.py +205 -0
  24. neurocode_ai-0.1.0/src/benchmark/run_code_benchmarks.py +181 -0
  25. neurocode_ai-0.1.0/src/benchmark/run_comprehensive_10_tests.py +424 -0
  26. neurocode_ai-0.1.0/src/benchmark/run_dense_vector_rag_benchmark.py +271 -0
  27. neurocode_ai-0.1.0/src/benchmark/run_ephemeral_swebench.py +474 -0
  28. neurocode_ai-0.1.0/src/benchmark/run_hardware_cliff_test.py +341 -0
  29. neurocode_ai-0.1.0/src/benchmark/swebench_evaluator.py +147 -0
  30. neurocode_ai-0.1.0/src/cli.py +298 -0
  31. neurocode_ai-0.1.0/src/graph/__init__.py +0 -0
  32. neurocode_ai-0.1.0/src/graph/builder.py +124 -0
  33. neurocode_ai-0.1.0/src/graph/parser.py +175 -0
  34. neurocode_ai-0.1.0/src/graph/slicer.py +202 -0
  35. neurocode_ai-0.1.0/src/mcp_server.py +370 -0
  36. neurocode_ai-0.1.0/tests/test_graph.py +104 -0
  37. neurocode_ai-0.1.0/tests/test_multi_hop.py +73 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Deepak R.
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,193 @@
1
+ Metadata-Version: 2.4
2
+ Name: neurocode-ai
3
+ Version: 0.1.0
4
+ Summary: Heterogeneous Code-Graph Slicing for On-Device Autonomous SWE Agents
5
+ Author: Deepak R.
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: tree-sitter>=0.22.0
11
+ Requires-Dist: tree-sitter-python>=0.21.0
12
+ Requires-Dist: networkx>=3.0
13
+ Requires-Dist: datasets>=2.18.0
14
+ Requires-Dist: matplotlib>=3.8.0
15
+ Requires-Dist: transformers>=4.40.0
16
+ Dynamic: license-file
17
+
18
+ # NeuroCode: Heterogeneous Code-Graph Slicing for On-Device Autonomous Software Engineering
19
+
20
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
21
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
22
+ [![Hardware: 4GB GPU](https://img.shields.io/badge/Hardware-4GB%20VRAM%20Verified-brightgreen.svg)]()
23
+ [![Model Context Protocol](https://img.shields.io/badge/MCP-2024--11--05%20Stdio-blueviolet.svg)](https://modelcontextprotocol.io)
24
+ [![Ollama Integration](https://img.shields.io/badge/Ollama-Offline%20Native-orange.svg)](https://ollama.ai)
25
+ [![Kaggle: Verified](https://img.shields.io/badge/Kaggle-Notebook%20Live-20beff.svg)](https://www.kaggle.com/code/deepark121/neurocode-heterogeneous-graph-sliced-swe-agent)
26
+
27
+ **NeuroCode** is a lightweight, heterogeneous neuro-symbolic framework and **Model Context Protocol (MCP)** server that enables small, local language models (1.5B–14B parameters) to fix multi-file software engineering bugs on consumer laptops (e.g., 4GB–8GB VRAM) without cloud API dependency or Out-of-Memory (OOM) crashes.
28
+
29
+ ---
30
+
31
+ ## 🏛️ System Architecture
32
+
33
+ ![System Architecture](paper/figures/fig2_system_architecture.png)
34
+
35
+ Unlike traditional coding agents that dump entire raw files into context windows (causing severe VRAM OOMs) or get trapped in multi-turn exploratory shell loops (`grep`, `find`, `cat`), **NeuroCode divides cognitive labor across the PC hardware boundary**:
36
+
37
+ 1. **Host CPU & RAM (Deterministic Graph Engine)**:
38
+ - Uses Tree-sitter and NetworkX to build an in-memory Code Property Graph (CPG) in milliseconds.
39
+ - Computes a topological $k$-hop reachability closure around fault candidates.
40
+ - Solves a bounded 0/1 knapsack optimization problem to select high-relevance AST subtrees strictly under the model's token limit ($B \le 1,200$ tokens).
41
+ 2. **Device GPU (Neural Synthesis Engine)**:
42
+ - Ingests only the bounded sliced context across PCIe.
43
+ - Generates single-turn `SEARCH/REPLACE` diff patches with zero exploratory token waste.
44
+ - Completely prevents KV-cache quadratic blowup and GPU OOM cliff failure.
45
+
46
+ ---
47
+
48
+ ## 📊 Comprehensive Empirical Evaluation (5-Benchmark Suite)
49
+
50
+ NeuroCode was evaluated across 5 comprehensive benchmark tracks spanning real-world repository repair, standalone algorithm synthesis, multi-file cross-boundary retrieval, and low-level hardware telemetry.
51
+
52
+ | Benchmark Suite | Metric | Baseline / BM25 | NeuroCode (Ours) | Advantage |
53
+ | :--- | :--- | :--- | :--- | :--- |
54
+ | **SWE-bench Lite** ($N=300$) | Resolve Rate (Pass@1) | 0.0% (OOM on 4GB) | **41.4%** (Local) / **21.1%** (14B) | Prevents OOM cliff; +14.2% over BM25 |
55
+ | **HumanEval** ($N=164$) | Pass@1 | 80.5% | **86.0%** (141/164) | +5.5% via syntax-aware graph repair |
56
+ | **MBPP** ($N=100$) | Pass@1 | 81.0% | **87.0%** (87/100) | +6.0% algorithmic verification |
57
+ | **RepoBench-R** ($N=150$) | Recall@1 / Token Budget | 18.0% (745 tokens) | **100.0%** (**428 tokens**) | **-42.6% tokens**, perfect cross-file retrieval |
58
+ | **Host Systems Telemetry** | Active VRAM / Slice Latency | 14.2 GB (OOM) | **961.2 MB** / **1.09 ms** | **93.2% VRAM reduction**, 0 OOMs |
59
+
60
+ ### 💻 Physical Laptop Edge Validation (NVIDIA RTX 3050 Laptop GPU)
61
+ Tested live on an everyday developer laptop (AMD Ryzen 7 7435HS + NVIDIA RTX 3050 Laptop GPU, 4.0 GB VRAM):
62
+ - **Peak Active VRAM**: **961.2 MB** (Only 25.5% GPU capacity, leaving 2.54 GB buffer for system desktop UI).
63
+ - **Throughput**: **15.8 tokens/second** locally.
64
+ - **Host Slicing Overhead**: **0.04 ms** on CPU.
65
+ - **Disk SSD Wear**: **0.0 GB** (100% in-memory ephemeral RAM execution via `/dev/shm`).
66
+
67
+ ---
68
+
69
+ ## 🔌 Model Context Protocol (MCP) Integration
70
+
71
+ NeuroCode provides an official stdio **Model Context Protocol (MCP)** server conforming to specification `2024-11-05`. Connect NeuroCode directly to Claude Desktop, Cursor, Continue.dev, or VS Code!
72
+
73
+ ### Native MCP Tools Exposed:
74
+ 1. `neurocode_slice`: In-memory CPG reachability slicing bounded under token budget ($B \le 1,200$).
75
+ 2. `neurocode_seeds`: Static root-cause candidate entity discovery in $<2$ ms.
76
+ 3. `neurocode_repair_ollama`: Single-turn patch generation streaming to local Ollama daemon (`http://localhost:11434`).
77
+ 4. `neurocode_hardware_health`: Reports GPU VRAM headroom, CPU cores, and `/dev/shm` tmpfs zero-wear status.
78
+
79
+ ### 1. Claude Desktop Setup
80
+ Add the following to your Claude Desktop configuration file:
81
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
82
+ - **Linux**: `~/.config/Claude/claude_desktop_config.json`
83
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "neurocode": {
89
+ "command": "/absolute/path/to/neurocode/.venv/bin/neurocode-mcp",
90
+ "args": []
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ ### 2. Cursor IDE Setup
97
+ Add to `.cursor/mcp.json` or your Cursor settings:
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "neurocode": {
102
+ "command": "neurocode-mcp",
103
+ "args": []
104
+ }
105
+ }
106
+ }
107
+ ```
108
+
109
+ ### 3. Continue.dev Setup
110
+ Add to your `~/.continue/config.json`:
111
+ ```json
112
+ {
113
+ "experimental": {
114
+ "modelContextProtocolServers": [
115
+ {
116
+ "name": "neurocode",
117
+ "command": "neurocode-mcp",
118
+ "args": []
119
+ }
120
+ ]
121
+ }
122
+ }
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 🚀 Quickstart & CLI Usage
128
+
129
+ ### 1. Installation
130
+ ```bash
131
+ git clone https://github.com/Arkz-Deepak/neurocode.git
132
+ cd neurocode
133
+ python3 -m venv .venv
134
+ source .venv/bin/activate
135
+ pip install -e .
136
+ ```
137
+
138
+ ### 2. Extract Token-Bounded Slice for Any Issue
139
+ ```bash
140
+ # Slices your codebase into a tight, bug-focused prompt under 1200 tokens
141
+ neurocode slice --repo /path/to/repo --issue "Fix ZeroDivisionError in matrix normalization" --budget 1200
142
+ ```
143
+
144
+ ### 3. Repair Code via Local Ollama Daemon (Zero Cloud API)
145
+ ```bash
146
+ # Runs full repair using local Qwen2.5-Coder model via Ollama
147
+ neurocode repair --repo /path/to/repo \
148
+ --issue "Fix ZeroDivisionError in matrix normalization" \
149
+ --provider ollama \
150
+ --model qwen2.5-coder:7b \
151
+ --apply
152
+ ```
153
+
154
+ ### 4. Interactive Copilot Direct on Laptop GPU
155
+ ```bash
156
+ neurocode-copilot
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 👤 Author & Affiliation
162
+
163
+ - **Author**: **Deepak R.**
164
+ - **Affiliation**: Department of Robotics & Automation Engineering, Dhaanish Ahmed College of Engineering (Affiliated with Anna University), Chennai, India
165
+ - **Portfolio**: [https://deepak-arkz.me](https://deepak-arkz.me)
166
+ - **Email**: [`wssedd18@gmail.com`](mailto:wssedd18@gmail.com) / [`deepak121289@outlook.com`](mailto:deepak121289@outlook.com)
167
+ - **GitHub**: [@Arkz-Deepak](https://github.com/Arkz-Deepak)
168
+
169
+ ---
170
+
171
+ ## 📄 Publications & Preprints
172
+
173
+ - **IEEE Transactions on Software Engineering (TSE)**: [`paper_ieee_tse/neurocode_tse.tex`](paper_ieee_tse/neurocode_tse.tex)
174
+ - **IEEE Conference Modular Package**: [`paper_modular_ieee/neurocode_modular_paper.tex`](paper_modular_ieee/neurocode_modular_paper.tex)
175
+ - **MLSys Conference Format**: [`paper_mlsys/neurocode_mlsys.tex`](paper_mlsys/neurocode_mlsys.tex)
176
+ - **Kaggle Competition Executable Notebook**: [Kaggle Notebook Live](https://www.kaggle.com/code/deepark121/neurocode-heterogeneous-graph-sliced-swe-agent)
177
+
178
+ ### Citation
179
+ ```bibtex
180
+ @article{deepak2026neurocode,
181
+ title={NeuroCode: Budget-Constrained Heterogeneous Code-Graph Slicing for Local Software Repair},
182
+ author={Deepak, R.},
183
+ journal={IEEE Transactions on Software Engineering},
184
+ institution={Dhaanish Ahmed College of Engineering, Anna University},
185
+ year={2026},
186
+ url={https://github.com/Arkz-Deepak/neurocode}
187
+ }
188
+ ```
189
+
190
+ ---
191
+
192
+ ## 📜 License
193
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,176 @@
1
+ # NeuroCode: Heterogeneous Code-Graph Slicing for On-Device Autonomous Software Engineering
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
5
+ [![Hardware: 4GB GPU](https://img.shields.io/badge/Hardware-4GB%20VRAM%20Verified-brightgreen.svg)]()
6
+ [![Model Context Protocol](https://img.shields.io/badge/MCP-2024--11--05%20Stdio-blueviolet.svg)](https://modelcontextprotocol.io)
7
+ [![Ollama Integration](https://img.shields.io/badge/Ollama-Offline%20Native-orange.svg)](https://ollama.ai)
8
+ [![Kaggle: Verified](https://img.shields.io/badge/Kaggle-Notebook%20Live-20beff.svg)](https://www.kaggle.com/code/deepark121/neurocode-heterogeneous-graph-sliced-swe-agent)
9
+
10
+ **NeuroCode** is a lightweight, heterogeneous neuro-symbolic framework and **Model Context Protocol (MCP)** server that enables small, local language models (1.5B–14B parameters) to fix multi-file software engineering bugs on consumer laptops (e.g., 4GB–8GB VRAM) without cloud API dependency or Out-of-Memory (OOM) crashes.
11
+
12
+ ---
13
+
14
+ ## 🏛️ System Architecture
15
+
16
+ ![System Architecture](paper/figures/fig2_system_architecture.png)
17
+
18
+ Unlike traditional coding agents that dump entire raw files into context windows (causing severe VRAM OOMs) or get trapped in multi-turn exploratory shell loops (`grep`, `find`, `cat`), **NeuroCode divides cognitive labor across the PC hardware boundary**:
19
+
20
+ 1. **Host CPU & RAM (Deterministic Graph Engine)**:
21
+ - Uses Tree-sitter and NetworkX to build an in-memory Code Property Graph (CPG) in milliseconds.
22
+ - Computes a topological $k$-hop reachability closure around fault candidates.
23
+ - Solves a bounded 0/1 knapsack optimization problem to select high-relevance AST subtrees strictly under the model's token limit ($B \le 1,200$ tokens).
24
+ 2. **Device GPU (Neural Synthesis Engine)**:
25
+ - Ingests only the bounded sliced context across PCIe.
26
+ - Generates single-turn `SEARCH/REPLACE` diff patches with zero exploratory token waste.
27
+ - Completely prevents KV-cache quadratic blowup and GPU OOM cliff failure.
28
+
29
+ ---
30
+
31
+ ## 📊 Comprehensive Empirical Evaluation (5-Benchmark Suite)
32
+
33
+ NeuroCode was evaluated across 5 comprehensive benchmark tracks spanning real-world repository repair, standalone algorithm synthesis, multi-file cross-boundary retrieval, and low-level hardware telemetry.
34
+
35
+ | Benchmark Suite | Metric | Baseline / BM25 | NeuroCode (Ours) | Advantage |
36
+ | :--- | :--- | :--- | :--- | :--- |
37
+ | **SWE-bench Lite** ($N=300$) | Resolve Rate (Pass@1) | 0.0% (OOM on 4GB) | **41.4%** (Local) / **21.1%** (14B) | Prevents OOM cliff; +14.2% over BM25 |
38
+ | **HumanEval** ($N=164$) | Pass@1 | 80.5% | **86.0%** (141/164) | +5.5% via syntax-aware graph repair |
39
+ | **MBPP** ($N=100$) | Pass@1 | 81.0% | **87.0%** (87/100) | +6.0% algorithmic verification |
40
+ | **RepoBench-R** ($N=150$) | Recall@1 / Token Budget | 18.0% (745 tokens) | **100.0%** (**428 tokens**) | **-42.6% tokens**, perfect cross-file retrieval |
41
+ | **Host Systems Telemetry** | Active VRAM / Slice Latency | 14.2 GB (OOM) | **961.2 MB** / **1.09 ms** | **93.2% VRAM reduction**, 0 OOMs |
42
+
43
+ ### 💻 Physical Laptop Edge Validation (NVIDIA RTX 3050 Laptop GPU)
44
+ Tested live on an everyday developer laptop (AMD Ryzen 7 7435HS + NVIDIA RTX 3050 Laptop GPU, 4.0 GB VRAM):
45
+ - **Peak Active VRAM**: **961.2 MB** (Only 25.5% GPU capacity, leaving 2.54 GB buffer for system desktop UI).
46
+ - **Throughput**: **15.8 tokens/second** locally.
47
+ - **Host Slicing Overhead**: **0.04 ms** on CPU.
48
+ - **Disk SSD Wear**: **0.0 GB** (100% in-memory ephemeral RAM execution via `/dev/shm`).
49
+
50
+ ---
51
+
52
+ ## 🔌 Model Context Protocol (MCP) Integration
53
+
54
+ NeuroCode provides an official stdio **Model Context Protocol (MCP)** server conforming to specification `2024-11-05`. Connect NeuroCode directly to Claude Desktop, Cursor, Continue.dev, or VS Code!
55
+
56
+ ### Native MCP Tools Exposed:
57
+ 1. `neurocode_slice`: In-memory CPG reachability slicing bounded under token budget ($B \le 1,200$).
58
+ 2. `neurocode_seeds`: Static root-cause candidate entity discovery in $<2$ ms.
59
+ 3. `neurocode_repair_ollama`: Single-turn patch generation streaming to local Ollama daemon (`http://localhost:11434`).
60
+ 4. `neurocode_hardware_health`: Reports GPU VRAM headroom, CPU cores, and `/dev/shm` tmpfs zero-wear status.
61
+
62
+ ### 1. Claude Desktop Setup
63
+ Add the following to your Claude Desktop configuration file:
64
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
65
+ - **Linux**: `~/.config/Claude/claude_desktop_config.json`
66
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
67
+
68
+ ```json
69
+ {
70
+ "mcpServers": {
71
+ "neurocode": {
72
+ "command": "/absolute/path/to/neurocode/.venv/bin/neurocode-mcp",
73
+ "args": []
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### 2. Cursor IDE Setup
80
+ Add to `.cursor/mcp.json` or your Cursor settings:
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "neurocode": {
85
+ "command": "neurocode-mcp",
86
+ "args": []
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ ### 3. Continue.dev Setup
93
+ Add to your `~/.continue/config.json`:
94
+ ```json
95
+ {
96
+ "experimental": {
97
+ "modelContextProtocolServers": [
98
+ {
99
+ "name": "neurocode",
100
+ "command": "neurocode-mcp",
101
+ "args": []
102
+ }
103
+ ]
104
+ }
105
+ }
106
+ ```
107
+
108
+ ---
109
+
110
+ ## 🚀 Quickstart & CLI Usage
111
+
112
+ ### 1. Installation
113
+ ```bash
114
+ git clone https://github.com/Arkz-Deepak/neurocode.git
115
+ cd neurocode
116
+ python3 -m venv .venv
117
+ source .venv/bin/activate
118
+ pip install -e .
119
+ ```
120
+
121
+ ### 2. Extract Token-Bounded Slice for Any Issue
122
+ ```bash
123
+ # Slices your codebase into a tight, bug-focused prompt under 1200 tokens
124
+ neurocode slice --repo /path/to/repo --issue "Fix ZeroDivisionError in matrix normalization" --budget 1200
125
+ ```
126
+
127
+ ### 3. Repair Code via Local Ollama Daemon (Zero Cloud API)
128
+ ```bash
129
+ # Runs full repair using local Qwen2.5-Coder model via Ollama
130
+ neurocode repair --repo /path/to/repo \
131
+ --issue "Fix ZeroDivisionError in matrix normalization" \
132
+ --provider ollama \
133
+ --model qwen2.5-coder:7b \
134
+ --apply
135
+ ```
136
+
137
+ ### 4. Interactive Copilot Direct on Laptop GPU
138
+ ```bash
139
+ neurocode-copilot
140
+ ```
141
+
142
+ ---
143
+
144
+ ## 👤 Author & Affiliation
145
+
146
+ - **Author**: **Deepak R.**
147
+ - **Affiliation**: Department of Robotics & Automation Engineering, Dhaanish Ahmed College of Engineering (Affiliated with Anna University), Chennai, India
148
+ - **Portfolio**: [https://deepak-arkz.me](https://deepak-arkz.me)
149
+ - **Email**: [`wssedd18@gmail.com`](mailto:wssedd18@gmail.com) / [`deepak121289@outlook.com`](mailto:deepak121289@outlook.com)
150
+ - **GitHub**: [@Arkz-Deepak](https://github.com/Arkz-Deepak)
151
+
152
+ ---
153
+
154
+ ## 📄 Publications & Preprints
155
+
156
+ - **IEEE Transactions on Software Engineering (TSE)**: [`paper_ieee_tse/neurocode_tse.tex`](paper_ieee_tse/neurocode_tse.tex)
157
+ - **IEEE Conference Modular Package**: [`paper_modular_ieee/neurocode_modular_paper.tex`](paper_modular_ieee/neurocode_modular_paper.tex)
158
+ - **MLSys Conference Format**: [`paper_mlsys/neurocode_mlsys.tex`](paper_mlsys/neurocode_mlsys.tex)
159
+ - **Kaggle Competition Executable Notebook**: [Kaggle Notebook Live](https://www.kaggle.com/code/deepark121/neurocode-heterogeneous-graph-sliced-swe-agent)
160
+
161
+ ### Citation
162
+ ```bibtex
163
+ @article{deepak2026neurocode,
164
+ title={NeuroCode: Budget-Constrained Heterogeneous Code-Graph Slicing for Local Software Repair},
165
+ author={Deepak, R.},
166
+ journal={IEEE Transactions on Software Engineering},
167
+ institution={Dhaanish Ahmed College of Engineering, Anna University},
168
+ year={2026},
169
+ url={https://github.com/Arkz-Deepak/neurocode}
170
+ }
171
+ ```
172
+
173
+ ---
174
+
175
+ ## 📜 License
176
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,193 @@
1
+ Metadata-Version: 2.4
2
+ Name: neurocode-ai
3
+ Version: 0.1.0
4
+ Summary: Heterogeneous Code-Graph Slicing for On-Device Autonomous SWE Agents
5
+ Author: Deepak R.
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: tree-sitter>=0.22.0
11
+ Requires-Dist: tree-sitter-python>=0.21.0
12
+ Requires-Dist: networkx>=3.0
13
+ Requires-Dist: datasets>=2.18.0
14
+ Requires-Dist: matplotlib>=3.8.0
15
+ Requires-Dist: transformers>=4.40.0
16
+ Dynamic: license-file
17
+
18
+ # NeuroCode: Heterogeneous Code-Graph Slicing for On-Device Autonomous Software Engineering
19
+
20
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
21
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
22
+ [![Hardware: 4GB GPU](https://img.shields.io/badge/Hardware-4GB%20VRAM%20Verified-brightgreen.svg)]()
23
+ [![Model Context Protocol](https://img.shields.io/badge/MCP-2024--11--05%20Stdio-blueviolet.svg)](https://modelcontextprotocol.io)
24
+ [![Ollama Integration](https://img.shields.io/badge/Ollama-Offline%20Native-orange.svg)](https://ollama.ai)
25
+ [![Kaggle: Verified](https://img.shields.io/badge/Kaggle-Notebook%20Live-20beff.svg)](https://www.kaggle.com/code/deepark121/neurocode-heterogeneous-graph-sliced-swe-agent)
26
+
27
+ **NeuroCode** is a lightweight, heterogeneous neuro-symbolic framework and **Model Context Protocol (MCP)** server that enables small, local language models (1.5B–14B parameters) to fix multi-file software engineering bugs on consumer laptops (e.g., 4GB–8GB VRAM) without cloud API dependency or Out-of-Memory (OOM) crashes.
28
+
29
+ ---
30
+
31
+ ## 🏛️ System Architecture
32
+
33
+ ![System Architecture](paper/figures/fig2_system_architecture.png)
34
+
35
+ Unlike traditional coding agents that dump entire raw files into context windows (causing severe VRAM OOMs) or get trapped in multi-turn exploratory shell loops (`grep`, `find`, `cat`), **NeuroCode divides cognitive labor across the PC hardware boundary**:
36
+
37
+ 1. **Host CPU & RAM (Deterministic Graph Engine)**:
38
+ - Uses Tree-sitter and NetworkX to build an in-memory Code Property Graph (CPG) in milliseconds.
39
+ - Computes a topological $k$-hop reachability closure around fault candidates.
40
+ - Solves a bounded 0/1 knapsack optimization problem to select high-relevance AST subtrees strictly under the model's token limit ($B \le 1,200$ tokens).
41
+ 2. **Device GPU (Neural Synthesis Engine)**:
42
+ - Ingests only the bounded sliced context across PCIe.
43
+ - Generates single-turn `SEARCH/REPLACE` diff patches with zero exploratory token waste.
44
+ - Completely prevents KV-cache quadratic blowup and GPU OOM cliff failure.
45
+
46
+ ---
47
+
48
+ ## 📊 Comprehensive Empirical Evaluation (5-Benchmark Suite)
49
+
50
+ NeuroCode was evaluated across 5 comprehensive benchmark tracks spanning real-world repository repair, standalone algorithm synthesis, multi-file cross-boundary retrieval, and low-level hardware telemetry.
51
+
52
+ | Benchmark Suite | Metric | Baseline / BM25 | NeuroCode (Ours) | Advantage |
53
+ | :--- | :--- | :--- | :--- | :--- |
54
+ | **SWE-bench Lite** ($N=300$) | Resolve Rate (Pass@1) | 0.0% (OOM on 4GB) | **41.4%** (Local) / **21.1%** (14B) | Prevents OOM cliff; +14.2% over BM25 |
55
+ | **HumanEval** ($N=164$) | Pass@1 | 80.5% | **86.0%** (141/164) | +5.5% via syntax-aware graph repair |
56
+ | **MBPP** ($N=100$) | Pass@1 | 81.0% | **87.0%** (87/100) | +6.0% algorithmic verification |
57
+ | **RepoBench-R** ($N=150$) | Recall@1 / Token Budget | 18.0% (745 tokens) | **100.0%** (**428 tokens**) | **-42.6% tokens**, perfect cross-file retrieval |
58
+ | **Host Systems Telemetry** | Active VRAM / Slice Latency | 14.2 GB (OOM) | **961.2 MB** / **1.09 ms** | **93.2% VRAM reduction**, 0 OOMs |
59
+
60
+ ### 💻 Physical Laptop Edge Validation (NVIDIA RTX 3050 Laptop GPU)
61
+ Tested live on an everyday developer laptop (AMD Ryzen 7 7435HS + NVIDIA RTX 3050 Laptop GPU, 4.0 GB VRAM):
62
+ - **Peak Active VRAM**: **961.2 MB** (Only 25.5% GPU capacity, leaving 2.54 GB buffer for system desktop UI).
63
+ - **Throughput**: **15.8 tokens/second** locally.
64
+ - **Host Slicing Overhead**: **0.04 ms** on CPU.
65
+ - **Disk SSD Wear**: **0.0 GB** (100% in-memory ephemeral RAM execution via `/dev/shm`).
66
+
67
+ ---
68
+
69
+ ## 🔌 Model Context Protocol (MCP) Integration
70
+
71
+ NeuroCode provides an official stdio **Model Context Protocol (MCP)** server conforming to specification `2024-11-05`. Connect NeuroCode directly to Claude Desktop, Cursor, Continue.dev, or VS Code!
72
+
73
+ ### Native MCP Tools Exposed:
74
+ 1. `neurocode_slice`: In-memory CPG reachability slicing bounded under token budget ($B \le 1,200$).
75
+ 2. `neurocode_seeds`: Static root-cause candidate entity discovery in $<2$ ms.
76
+ 3. `neurocode_repair_ollama`: Single-turn patch generation streaming to local Ollama daemon (`http://localhost:11434`).
77
+ 4. `neurocode_hardware_health`: Reports GPU VRAM headroom, CPU cores, and `/dev/shm` tmpfs zero-wear status.
78
+
79
+ ### 1. Claude Desktop Setup
80
+ Add the following to your Claude Desktop configuration file:
81
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
82
+ - **Linux**: `~/.config/Claude/claude_desktop_config.json`
83
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "neurocode": {
89
+ "command": "/absolute/path/to/neurocode/.venv/bin/neurocode-mcp",
90
+ "args": []
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ ### 2. Cursor IDE Setup
97
+ Add to `.cursor/mcp.json` or your Cursor settings:
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "neurocode": {
102
+ "command": "neurocode-mcp",
103
+ "args": []
104
+ }
105
+ }
106
+ }
107
+ ```
108
+
109
+ ### 3. Continue.dev Setup
110
+ Add to your `~/.continue/config.json`:
111
+ ```json
112
+ {
113
+ "experimental": {
114
+ "modelContextProtocolServers": [
115
+ {
116
+ "name": "neurocode",
117
+ "command": "neurocode-mcp",
118
+ "args": []
119
+ }
120
+ ]
121
+ }
122
+ }
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 🚀 Quickstart & CLI Usage
128
+
129
+ ### 1. Installation
130
+ ```bash
131
+ git clone https://github.com/Arkz-Deepak/neurocode.git
132
+ cd neurocode
133
+ python3 -m venv .venv
134
+ source .venv/bin/activate
135
+ pip install -e .
136
+ ```
137
+
138
+ ### 2. Extract Token-Bounded Slice for Any Issue
139
+ ```bash
140
+ # Slices your codebase into a tight, bug-focused prompt under 1200 tokens
141
+ neurocode slice --repo /path/to/repo --issue "Fix ZeroDivisionError in matrix normalization" --budget 1200
142
+ ```
143
+
144
+ ### 3. Repair Code via Local Ollama Daemon (Zero Cloud API)
145
+ ```bash
146
+ # Runs full repair using local Qwen2.5-Coder model via Ollama
147
+ neurocode repair --repo /path/to/repo \
148
+ --issue "Fix ZeroDivisionError in matrix normalization" \
149
+ --provider ollama \
150
+ --model qwen2.5-coder:7b \
151
+ --apply
152
+ ```
153
+
154
+ ### 4. Interactive Copilot Direct on Laptop GPU
155
+ ```bash
156
+ neurocode-copilot
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 👤 Author & Affiliation
162
+
163
+ - **Author**: **Deepak R.**
164
+ - **Affiliation**: Department of Robotics & Automation Engineering, Dhaanish Ahmed College of Engineering (Affiliated with Anna University), Chennai, India
165
+ - **Portfolio**: [https://deepak-arkz.me](https://deepak-arkz.me)
166
+ - **Email**: [`wssedd18@gmail.com`](mailto:wssedd18@gmail.com) / [`deepak121289@outlook.com`](mailto:deepak121289@outlook.com)
167
+ - **GitHub**: [@Arkz-Deepak](https://github.com/Arkz-Deepak)
168
+
169
+ ---
170
+
171
+ ## 📄 Publications & Preprints
172
+
173
+ - **IEEE Transactions on Software Engineering (TSE)**: [`paper_ieee_tse/neurocode_tse.tex`](paper_ieee_tse/neurocode_tse.tex)
174
+ - **IEEE Conference Modular Package**: [`paper_modular_ieee/neurocode_modular_paper.tex`](paper_modular_ieee/neurocode_modular_paper.tex)
175
+ - **MLSys Conference Format**: [`paper_mlsys/neurocode_mlsys.tex`](paper_mlsys/neurocode_mlsys.tex)
176
+ - **Kaggle Competition Executable Notebook**: [Kaggle Notebook Live](https://www.kaggle.com/code/deepark121/neurocode-heterogeneous-graph-sliced-swe-agent)
177
+
178
+ ### Citation
179
+ ```bibtex
180
+ @article{deepak2026neurocode,
181
+ title={NeuroCode: Budget-Constrained Heterogeneous Code-Graph Slicing for Local Software Repair},
182
+ author={Deepak, R.},
183
+ journal={IEEE Transactions on Software Engineering},
184
+ institution={Dhaanish Ahmed College of Engineering, Anna University},
185
+ year={2026},
186
+ url={https://github.com/Arkz-Deepak/neurocode}
187
+ }
188
+ ```
189
+
190
+ ---
191
+
192
+ ## 📜 License
193
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,35 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ neurocode_ai.egg-info/PKG-INFO
5
+ neurocode_ai.egg-info/SOURCES.txt
6
+ neurocode_ai.egg-info/dependency_links.txt
7
+ neurocode_ai.egg-info/entry_points.txt
8
+ neurocode_ai.egg-info/requires.txt
9
+ neurocode_ai.egg-info/top_level.txt
10
+ src/__init__.py
11
+ src/cli.py
12
+ src/mcp_server.py
13
+ src/agent/llm_interface.py
14
+ src/agent/patcher.py
15
+ src/benchmark/create_thumbnail.py
16
+ src/benchmark/end_to_end_benchmark.py
17
+ src/benchmark/evaluator.py
18
+ src/benchmark/generate_4x3_figures.py
19
+ src/benchmark/mlsys_microbenchmarks.py
20
+ src/benchmark/plot_ablation.py
21
+ src/benchmark/plot_architecture.py
22
+ src/benchmark/plot_empirical_fig1.py
23
+ src/benchmark/run_ablation_study.py
24
+ src/benchmark/run_code_benchmarks.py
25
+ src/benchmark/run_comprehensive_10_tests.py
26
+ src/benchmark/run_dense_vector_rag_benchmark.py
27
+ src/benchmark/run_ephemeral_swebench.py
28
+ src/benchmark/run_hardware_cliff_test.py
29
+ src/benchmark/swebench_evaluator.py
30
+ src/graph/__init__.py
31
+ src/graph/builder.py
32
+ src/graph/parser.py
33
+ src/graph/slicer.py
34
+ tests/test_graph.py
35
+ tests/test_multi_hop.py
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ neurocode = src.cli:main
3
+ neurocode-copilot = code_assistant:main
4
+ neurocode-mcp = src.mcp_server:main
@@ -0,0 +1,6 @@
1
+ tree-sitter>=0.22.0
2
+ tree-sitter-python>=0.21.0
3
+ networkx>=3.0
4
+ datasets>=2.18.0
5
+ matplotlib>=3.8.0
6
+ transformers>=4.40.0
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "neurocode-ai"
7
+ version = "0.1.0"
8
+ description = "Heterogeneous Code-Graph Slicing for On-Device Autonomous SWE Agents"
9
+ readme = "README.md"
10
+ authors = [{ name = "Deepak R." }]
11
+ license = { text = "MIT" }
12
+ requires-python = ">=3.10"
13
+ dependencies = [
14
+ "tree-sitter>=0.22.0",
15
+ "tree-sitter-python>=0.21.0",
16
+ "networkx>=3.0",
17
+ "datasets>=2.18.0",
18
+ "matplotlib>=3.8.0",
19
+ "transformers>=4.40.0"
20
+ ]
21
+
22
+ [project.scripts]
23
+ neurocode = "src.cli:main"
24
+ neurocode-mcp = "src.mcp_server:main"
25
+ neurocode-copilot = "code_assistant:main"
26
+
27
+ [tool.setuptools.packages.find]
28
+ where = ["."]
29
+ include = ["src*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes