codebrain 0.1.0__tar.gz → 0.1.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.
Files changed (96) hide show
  1. codebrain-0.1.1/PKG-INFO +388 -0
  2. codebrain-0.1.1/README.md +339 -0
  3. codebrain-0.1.1/codebrain.egg-info/PKG-INFO +388 -0
  4. {codebrain-0.1.0 → codebrain-0.1.1}/pyproject.toml +19 -3
  5. codebrain-0.1.0/PKG-INFO +0 -360
  6. codebrain-0.1.0/README.md +0 -316
  7. codebrain-0.1.0/codebrain.egg-info/PKG-INFO +0 -360
  8. {codebrain-0.1.0 → codebrain-0.1.1}/LICENSE +0 -0
  9. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/__init__.py +0 -0
  10. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/__main__.py +0 -0
  11. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/agent_bridge.py +0 -0
  12. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/analyzer.py +0 -0
  13. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/api.py +0 -0
  14. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/api_models.py +0 -0
  15. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/cli.py +0 -0
  16. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/comprehension.py +0 -0
  17. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/config.py +0 -0
  18. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/context.py +0 -0
  19. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/export.py +0 -0
  20. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/graph/__init__.py +0 -0
  21. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/graph/query.py +0 -0
  22. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/graph/schema.py +0 -0
  23. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/graph/store.py +0 -0
  24. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/hook_runner.py +0 -0
  25. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/hooks.py +0 -0
  26. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/indexer.py +0 -0
  27. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/llm.py +0 -0
  28. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/logging.py +0 -0
  29. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/mcp_server.py +0 -0
  30. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/memory/__init__.py +0 -0
  31. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/memory/store.py +0 -0
  32. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/parser/__init__.py +0 -0
  33. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/parser/base.py +0 -0
  34. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/parser/config_parser.py +0 -0
  35. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/parser/models.py +0 -0
  36. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/parser/python_parser.py +0 -0
  37. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/parser/registry.py +0 -0
  38. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/parser/typescript_parser.py +0 -0
  39. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/parser/typescript_treesitter.py +0 -0
  40. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/py.typed +0 -0
  41. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/resolver.py +0 -0
  42. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/settings.py +0 -0
  43. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/utils.py +0 -0
  44. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/validator.py +0 -0
  45. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/watcher/__init__.py +0 -0
  46. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain/watcher/file_watcher.py +0 -0
  47. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain.egg-info/SOURCES.txt +0 -0
  48. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain.egg-info/dependency_links.txt +0 -0
  49. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain.egg-info/entry_points.txt +0 -0
  50. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain.egg-info/requires.txt +0 -0
  51. {codebrain-0.1.0 → codebrain-0.1.1}/codebrain.egg-info/top_level.txt +0 -0
  52. {codebrain-0.1.0 → codebrain-0.1.1}/setup.cfg +0 -0
  53. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_agent_bridge.py +0 -0
  54. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_analyzer.py +0 -0
  55. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_api.py +0 -0
  56. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_ci.py +0 -0
  57. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_cli.py +0 -0
  58. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_comprehension.py +0 -0
  59. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_context.py +0 -0
  60. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_contracts_real.py +0 -0
  61. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_dataflow.py +0 -0
  62. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_dead_code_confidence.py +0 -0
  63. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_error_recovery.py +0 -0
  64. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_export.py +0 -0
  65. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_hooks.py +0 -0
  66. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_indexer.py +0 -0
  67. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_install.py +0 -0
  68. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_integration.py +0 -0
  69. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_jyotishyamitra.py +0 -0
  70. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_llm.py +0 -0
  71. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_mcp_server.py +0 -0
  72. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_memory.py +0 -0
  73. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_multi_project_cli.py +0 -0
  74. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_narratives.py +0 -0
  75. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_parser.py +0 -0
  76. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_plugin_system.py +0 -0
  77. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_production_hardening.py +0 -0
  78. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_query.py +0 -0
  79. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_real_world.py +0 -0
  80. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_resolver.py +0 -0
  81. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_scale.py +0 -0
  82. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_scale_optimizations.py +0 -0
  83. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_scale_real.py +0 -0
  84. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_schema.py +0 -0
  85. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_settings.py +0 -0
  86. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_store.py +0 -0
  87. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_ts_ast_parser.py +0 -0
  88. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_ts_parser_enhanced.py +0 -0
  89. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_typescript_parser.py +0 -0
  90. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_utils.py +0 -0
  91. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_validation_narratives.py +0 -0
  92. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_validator.py +0 -0
  93. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_validator_scenarios.py +0 -0
  94. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_watch_validate.py +0 -0
  95. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_watcher.py +0 -0
  96. {codebrain-0.1.0 → codebrain-0.1.1}/tests/test_zoom.py +0 -0
@@ -0,0 +1,388 @@
1
+ Metadata-Version: 2.4
2
+ Name: codebrain
3
+ Version: 0.1.1
4
+ Summary: Know what breaks before you break it. Structural knowledge graph for codebases — impact analysis, dead code detection, health scores. No LLM required.
5
+ Author: CodeBrain Contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/monk0062006/CodeBrain
8
+ Project-URL: Repository, https://github.com/monk0062006/CodeBrain
9
+ Project-URL: Issues, https://github.com/monk0062006/CodeBrain/issues
10
+ Keywords: code-analysis,static-analysis,knowledge-graph,impact-analysis,dead-code,codebase-health,mcp,ai-coding,structural-analysis,refactoring
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Topic :: Software Development :: Testing
21
+ Classifier: Environment :: Console
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: click>=8.1
28
+ Requires-Dist: watchdog>=3.0
29
+ Requires-Dist: mcp<1.20,>=1.0
30
+ Requires-Dist: jinja2>=3.1
31
+ Provides-Extra: api
32
+ Requires-Dist: fastapi>=0.110; extra == "api"
33
+ Requires-Dist: uvicorn>=0.27; extra == "api"
34
+ Provides-Extra: llm
35
+ Requires-Dist: httpx>=0.27; extra == "llm"
36
+ Provides-Extra: ts
37
+ Requires-Dist: tree-sitter>=0.21; extra == "ts"
38
+ Requires-Dist: tree-sitter-languages>=1.10; extra == "ts"
39
+ Provides-Extra: dev
40
+ Requires-Dist: pytest>=7.0; extra == "dev"
41
+ Requires-Dist: pytest-tmp-files>=0.0.2; extra == "dev"
42
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
43
+ Requires-Dist: mypy>=1.8; extra == "dev"
44
+ Requires-Dist: ruff>=0.3; extra == "dev"
45
+ Requires-Dist: httpx>=0.27; extra == "dev"
46
+ Provides-Extra: all
47
+ Requires-Dist: codebrain[api,llm,ts]; extra == "all"
48
+ Dynamic: license-file
49
+
50
+ # CodeBrain
51
+
52
+ **Know what breaks before you break it.**
53
+
54
+ CodeBrain builds a structural knowledge graph of your codebase — every function, class, import, and call chain — stored locally in SQLite. No cloud. No LLM required. Just deterministic structural analysis.
55
+
56
+ ```bash
57
+ pip install codebrain
58
+ cd your-project
59
+ brain init
60
+ ```
61
+
62
+ That's it. Now you can:
63
+
64
+ ```bash
65
+ brain impact my_function # What breaks if I change this?
66
+ brain health # Codebase health score (0-100)
67
+ brain hotspots # Riskiest symbols in the codebase
68
+ brain deadcode # Unused functions with confidence levels
69
+ brain coupling # Which files are too tightly coupled?
70
+ brain zoom # Google Maps-style navigation of your architecture
71
+ ```
72
+
73
+ ## Why CodeBrain?
74
+
75
+ AI coding agents (Claude Code, Cursor, Copilot) generate code faster than you can review it. They apply local fixes without understanding global structure. When an agent removes a function, it doesn't know 3 other files call it.
76
+
77
+ CodeBrain knows. It maintains a persistent knowledge graph of every symbol and relationship in your codebase, and can tell you exactly what would break before any change is made.
78
+
79
+ **No API keys. No cloud. No LLM. Everything runs locally on your machine.**
80
+
81
+ ## Features
82
+
83
+ ### Impact Analysis
84
+
85
+ ```
86
+ $ brain impact getAstroData
87
+ Impact of changing predictions_api.py::getAstroData:
88
+ [1] Ascendant.py::compileAstroDetails (CALLS)
89
+ [1] AsthaKoota.py::getNakAndRasi (CALLS)
90
+ [2] ProfileBuilder.py::buildProfile (CALLS via compileAstroDetails)
91
+ ... 48 dependents across 69 files
92
+ ```
93
+
94
+ ### Health Score
95
+
96
+ ```
97
+ $ brain health
98
+ Codebase Health
99
+ Score: 93/100 (A)
100
+ [##################--]
101
+ Dead code: 517 symbols (4.2%) score 79/100
102
+ Import cycles: 0 score 100/100
103
+ Coupling: 3 hotspot(s) score 94/100
104
+ ```
105
+
106
+ ### Risk Hotspots
107
+
108
+ ```
109
+ $ brain hotspots
110
+ Risk hotspots (top 5):
111
+ Score Type Name Deps Files
112
+ 48.2 function getAstroData 48 69
113
+ 35.1 function compileAstroDetails 35 52
114
+ 28.7 class ProfileBuilder 28 41
115
+ ```
116
+
117
+ ### Dead Code Detection
118
+
119
+ Finds unused symbols with confidence levels:
120
+ - **High** — truly unreferenced, safe to delete
121
+ - **Medium** — file uses dynamic patterns (callbacks, registries)
122
+ - **Low** — might be used via reflection or external entry points
123
+
124
+ ### Implicit Contracts
125
+
126
+ ```
127
+ $ brain contracts
128
+ Implicit contracts (12):
129
+ [co_import ] (100%) 'Colors' and 'Spacing' are imported together in 141/141 files
130
+ [co_import ] (98%) 'Spacing' and 'react-native' are imported together in 138/141 files
131
+ ```
132
+
133
+ ### Module Coupling
134
+
135
+ ```
136
+ $ brain coupling
137
+ Most coupled file pairs:
138
+ 140 logger.py <-> main.py
139
+ 101 ForeignSettlementProfile.py <-> ForeignSettlementProfiling.py
140
+ ```
141
+
142
+ ### Architectural Layers
143
+
144
+ ```
145
+ $ brain layers
146
+ Layer 0 — foundation (deepest dependencies)
147
+ utils/logger.py
148
+ utils/constants.py
149
+ Layer 1 — core
150
+ core/engine.py
151
+ core/models.py
152
+ ```
153
+
154
+ ### Multi-Resolution Zoom
155
+
156
+ Navigate your codebase like Google Maps — zoom from system level to package to file to symbol:
157
+
158
+ ```
159
+ $ brain zoom
160
+ System: 1328 files, 17756 symbols across 5 packages
161
+ Backbone: debug_astrodata.py, debug_dasha_data.py, debug_house_data.py
162
+
163
+ $ brain zoom backend
164
+ Package: backend (978 files, 14794 symbols)
165
+ Top modules: ProfileAPI/main.py (429 symbols), test_subscription_tiers.py (210 symbols)
166
+
167
+ $ brain zoom backend/vedic-profiles/ProfileAPI/main.py
168
+ Module: main.py — 429 symbols, 15853 lines. Isolated (no dependents).
169
+ ```
170
+
171
+ ## AI Agent Integration
172
+
173
+ ### Claude Code (MCP)
174
+
175
+ ```bash
176
+ brain agent # auto-generates CLAUDE.md + MCP config
177
+ ```
178
+
179
+ Or add manually to your MCP config:
180
+
181
+ ```json
182
+ {
183
+ "mcpServers": {
184
+ "codebrain": {
185
+ "command": "python",
186
+ "args": ["-m", "codebrain.mcp_server"],
187
+ "cwd": "/path/to/your/repo"
188
+ }
189
+ }
190
+ }
191
+ ```
192
+
193
+ 22 MCP tools available including:
194
+
195
+ | Tool | Purpose |
196
+ |------|---------|
197
+ | `propose_change` | Validate before writing — the structural safety gate |
198
+ | `impact_analysis` | Trace transitive dependents of any symbol |
199
+ | `ask_codebase` | Natural language questions about the codebase |
200
+ | `validate_change` | Check if a file change would break callers |
201
+ | `risk_hotspots` | Find structurally dangerous symbols |
202
+ | `find_dead_code` | Unused symbols with confidence levels |
203
+ | `codebase_overview` | System-level architecture summary |
204
+
205
+ ### Structural Safety Gate
206
+
207
+ The `propose_change` MCP tool validates changes **before** the AI writes them. When a change would remove a function that other files call, or change a signature that callers depend on, CodeBrain blocks it and tells the agent exactly what would break.
208
+
209
+ ## All CLI Commands
210
+
211
+ | Command | Description |
212
+ |---------|-------------|
213
+ | `brain init` | Index the current repository |
214
+ | `brain status` | Show index statistics |
215
+ | `brain search <query>` | Find symbols by name |
216
+ | `brain impact <name>` | What breaks if this changes? |
217
+ | `brain trace <name>` | Forward call chain from a symbol |
218
+ | `brain deps <name>` | Dependencies of a symbol or file |
219
+ | `brain deadcode` | Find unused functions/classes |
220
+ | `brain cycles` | Detect import cycles |
221
+ | `brain health` | Codebase health score (0-100) |
222
+ | `brain hotspots` | Riskiest symbols by structural exposure |
223
+ | `brain coupling` | Module coupling analysis |
224
+ | `brain contracts` | Implicit contract detection |
225
+ | `brain layers` | Architectural layer inference |
226
+ | `brain zoom [target]` | Multi-resolution navigation |
227
+ | `brain overview` | System-level codebase overview |
228
+ | `brain module <file>` | Module-level view |
229
+ | `brain context <name>` | LLM-optimized symbol context |
230
+ | `brain validate <file>` | Check if a file change is safe |
231
+ | `brain ci --base main` | CI validation for pull requests |
232
+ | `brain watch` | File watcher daemon (re-index on save) |
233
+ | `brain hook install` | Install pre-commit validation hook |
234
+ | `brain reindex` | Force a full rebuild |
235
+ | `brain doctor` | Diagnostic health check |
236
+ | `brain serve` | Start REST API server |
237
+
238
+ All commands support `--json` for machine-readable output, `--repo <path>` for different repos, `--timeout N` for analysis timeout (default: 120s), and `--verbose` for debug logging.
239
+
240
+ ## Configuration
241
+
242
+ Create `.codebrain.toml` in your repo root (optional):
243
+
244
+ ```toml
245
+ [codebrain]
246
+ skip_dirs = ["__pycache__", ".git", "node_modules", "vendor"]
247
+ extensions = [".py", ".ts", ".tsx", ".js", ".jsx"]
248
+ max_file_size_kb = 1024
249
+ cli_timeout = 120
250
+ ```
251
+
252
+ Or use environment variables:
253
+
254
+ | Variable | Description |
255
+ |----------|-------------|
256
+ | `CODEBRAIN_SKIP_DIRS` | Comma-separated directories to skip |
257
+ | `CODEBRAIN_EXTENSIONS` | Comma-separated file extensions to index |
258
+ | `CODEBRAIN_CLI_TIMEOUT` | Analysis timeout in seconds (default: 120) |
259
+ | `CODEBRAIN_MAX_WORKERS` | Max parallel worker processes |
260
+
261
+ ## Language Support
262
+
263
+ | Language | Parser | Quality |
264
+ |----------|--------|---------|
265
+ | Python | AST (stdlib) | Full — functions, classes, imports, calls, dataflow |
266
+ | TypeScript/JSX | tree-sitter | Full — requires `pip install codebrain[ts]` |
267
+ | JavaScript/JSX | tree-sitter | Full — requires `pip install codebrain[ts]` |
268
+ | TypeScript (fallback) | regex | Experimental — used when tree-sitter not installed |
269
+
270
+ ### Adding Languages
271
+
272
+ Implement `BaseParser` and register via entry points:
273
+
274
+ ```python
275
+ from codebrain.parser.base import BaseParser
276
+ from codebrain.parser.models import ParsedFile
277
+
278
+ class RustParser(BaseParser):
279
+ def extensions(self) -> frozenset[str]:
280
+ return frozenset({".rs"})
281
+
282
+ def parse(self, path, repo_root) -> ParsedFile:
283
+ ... # parse and return nodes + edges
284
+ ```
285
+
286
+ ```toml
287
+ # pyproject.toml
288
+ [project.entry-points."codebrain.parsers"]
289
+ rust = "your_package.parser:RustParser"
290
+ ```
291
+
292
+ ## CI Integration
293
+
294
+ ### Pre-commit Hook
295
+
296
+ ```bash
297
+ brain hook install # validates staged files before every commit
298
+ brain hook uninstall # remove the hook
299
+ ```
300
+
301
+ ### GitHub Action
302
+
303
+ ```yaml
304
+ name: CodeBrain Validation
305
+ on: [pull_request]
306
+ jobs:
307
+ validate:
308
+ runs-on: ubuntu-latest
309
+ steps:
310
+ - uses: actions/checkout@v4
311
+ with:
312
+ fetch-depth: 0
313
+ - uses: actions/setup-python@v5
314
+ with:
315
+ python-version: '3.11'
316
+ - run: pip install codebrain
317
+ - run: brain ci --base origin/main --json
318
+ ```
319
+
320
+ ## Optional Extras
321
+
322
+ ```bash
323
+ pip install codebrain[ts] # TypeScript/JavaScript tree-sitter parser
324
+ pip install codebrain[api] # REST API server (FastAPI)
325
+ pip install codebrain[llm] # LLM-enhanced explanations (optional, requires API key)
326
+ pip install codebrain[all] # Everything
327
+ ```
328
+
329
+ **The core tool requires no extras.** Python parsing, impact analysis, health scores, dead code detection, coupling analysis — all work out of the box with just `pip install codebrain`.
330
+
331
+ ## How It Works
332
+
333
+ ```
334
+ Source Files --> Parser (Python AST / tree-sitter) --> Nodes + Edges
335
+ |
336
+ GraphStore (SQLite)
337
+ |
338
+ QueryEngine
339
+ |
340
+ CLI / MCP Server / REST API / VS Code Extension
341
+ ```
342
+
343
+ - **Node** — a code symbol (function, class, method, variable, file)
344
+ - **Edge** — a relationship (CALLS, IMPORTS, CONTAINS, EXTENDS, DATAFLOW)
345
+ - **GraphStore** — persistent SQLite database with WAL mode, lives in `.codebrain/graph.db`
346
+ - **QueryEngine** — BFS/DFS traversal for impact analysis, call chains, dead code, cycle detection
347
+
348
+ Everything is local. The database is a single SQLite file in your repo's `.codebrain/` directory (auto-gitignored).
349
+
350
+ ## Real-World Validation
351
+
352
+ Tested on a 1,328-file mixed Python + TypeScript production codebase:
353
+
354
+ | Metric | Result |
355
+ |--------|--------|
356
+ | Files indexed | 1,328 (zero errors) |
357
+ | Symbols extracted | 17,756 |
358
+ | Relationships mapped | 111,793 |
359
+ | Indexing time | 135 seconds |
360
+ | Health score | 93/100 |
361
+ | Impact analysis | 48 dependents traced across 69 files |
362
+ | Implicit contracts | Found co-import pattern in 141/141 files |
363
+ | Tests passing | 794 |
364
+
365
+ ## Requirements
366
+
367
+ - Python 3.11+
368
+ - No internet connection required
369
+ - No API keys required
370
+ - No LLM required
371
+ - Works on Windows, macOS, and Linux
372
+
373
+ ## Development
374
+
375
+ ```bash
376
+ git clone https://github.com/monk0062006/CodeBrain.git
377
+ cd CodeBrain
378
+ pip install -e ".[dev]"
379
+
380
+ pytest tests/ -v # Run tests
381
+ mypy codebrain/ # Type checking
382
+ ruff check codebrain/ # Linting
383
+ pytest --cov=codebrain # Coverage
384
+ ```
385
+
386
+ ## License
387
+
388
+ MIT