codemesh 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 (71) hide show
  1. codemesh-0.1.1/.github/ISSUE_TEMPLATE/bug_report.yml +29 -0
  2. codemesh-0.1.1/.github/ISSUE_TEMPLATE/feature_request.yml +20 -0
  3. codemesh-0.1.1/.github/workflows/ci.yml +39 -0
  4. codemesh-0.1.1/.github/workflows/publish.yml +24 -0
  5. codemesh-0.1.1/.gitignore +233 -0
  6. codemesh-0.1.1/CHANGELOG.md +7 -0
  7. codemesh-0.1.1/CONTRIBUTING.md +102 -0
  8. codemesh-0.1.1/LICENSE +21 -0
  9. codemesh-0.1.1/Makefile +28 -0
  10. codemesh-0.1.1/PKG-INFO +337 -0
  11. codemesh-0.1.1/README.md +301 -0
  12. codemesh-0.1.1/codemesh/__init__.py +5 -0
  13. codemesh-0.1.1/codemesh/__main__.py +8 -0
  14. codemesh-0.1.1/codemesh/cli/__init__.py +3 -0
  15. codemesh-0.1.1/codemesh/cli/init.py +208 -0
  16. codemesh-0.1.1/codemesh/cli/install_cmd.py +208 -0
  17. codemesh-0.1.1/codemesh/cli/main.py +469 -0
  18. codemesh-0.1.1/codemesh/context/__init__.py +3 -0
  19. codemesh-0.1.1/codemesh/context/builder.py +388 -0
  20. codemesh-0.1.1/codemesh/db/__init__.py +3 -0
  21. codemesh-0.1.1/codemesh/db/connection.py +66 -0
  22. codemesh-0.1.1/codemesh/db/queries.py +696 -0
  23. codemesh-0.1.1/codemesh/db/schema.py +125 -0
  24. codemesh-0.1.1/codemesh/embedding/__init__.py +3 -0
  25. codemesh-0.1.1/codemesh/extraction/__init__.py +7 -0
  26. codemesh-0.1.1/codemesh/extraction/languages/__init__.py +95 -0
  27. codemesh-0.1.1/codemesh/extraction/languages/c_family.py +614 -0
  28. codemesh-0.1.1/codemesh/extraction/languages/go.py +397 -0
  29. codemesh-0.1.1/codemesh/extraction/languages/java.py +603 -0
  30. codemesh-0.1.1/codemesh/extraction/languages/python.py +718 -0
  31. codemesh-0.1.1/codemesh/extraction/languages/rust.py +435 -0
  32. codemesh-0.1.1/codemesh/extraction/languages/swift.py +464 -0
  33. codemesh-0.1.1/codemesh/extraction/languages/typescript.py +1222 -0
  34. codemesh-0.1.1/codemesh/extraction/orchestrator.py +218 -0
  35. codemesh-0.1.1/codemesh/graph/__init__.py +8 -0
  36. codemesh-0.1.1/codemesh/graph/query_manager.py +117 -0
  37. codemesh-0.1.1/codemesh/graph/traverser.py +107 -0
  38. codemesh-0.1.1/codemesh/indexer.py +240 -0
  39. codemesh-0.1.1/codemesh/mcp/__init__.py +3 -0
  40. codemesh-0.1.1/codemesh/mcp/server.py +60 -0
  41. codemesh-0.1.1/codemesh/mcp/tools.py +605 -0
  42. codemesh-0.1.1/codemesh/querier.py +269 -0
  43. codemesh-0.1.1/codemesh/resolution/__init__.py +7 -0
  44. codemesh-0.1.1/codemesh/resolution/frameworks/__init__.py +15 -0
  45. codemesh-0.1.1/codemesh/resolution/frameworks/django.py +30 -0
  46. codemesh-0.1.1/codemesh/resolution/frameworks/fastapi.py +23 -0
  47. codemesh-0.1.1/codemesh/resolution/import_resolver.py +69 -0
  48. codemesh-0.1.1/codemesh/resolution/name_matcher.py +30 -0
  49. codemesh-0.1.1/codemesh/resolution/resolver.py +268 -0
  50. codemesh-0.1.1/codemesh/retrieval/__init__.py +7 -0
  51. codemesh-0.1.1/codemesh/search/__init__.py +3 -0
  52. codemesh-0.1.1/codemesh/sync/__init__.py +3 -0
  53. codemesh-0.1.1/codemesh/sync/watcher.py +135 -0
  54. codemesh-0.1.1/codemesh/types.py +148 -0
  55. codemesh-0.1.1/codemesh/viz/__init__.py +0 -0
  56. codemesh-0.1.1/codemesh/viz/graph_builder.py +162 -0
  57. codemesh-0.1.1/codemesh/viz/server.py +122 -0
  58. codemesh-0.1.1/codemesh/viz/templates/index.html +359 -0
  59. codemesh-0.1.1/pyproject.toml +80 -0
  60. codemesh-0.1.1/tests/__init__.py +3 -0
  61. codemesh-0.1.1/tests/conftest.py +108 -0
  62. codemesh-0.1.1/tests/fixtures/__init__.py +3 -0
  63. codemesh-0.1.1/tests/test_adversarial.py +220 -0
  64. codemesh-0.1.1/tests/test_benchmark_repoqa.py +182 -0
  65. codemesh-0.1.1/tests/test_embedding_e2e.py +319 -0
  66. codemesh-0.1.1/tests/test_extraction.py +66 -0
  67. codemesh-0.1.1/tests/test_integration.py +61 -0
  68. codemesh-0.1.1/tests/test_llm_judge.py +240 -0
  69. codemesh-0.1.1/tests/test_performance.py +178 -0
  70. codemesh-0.1.1/tests/test_viz.py +366 -0
  71. codemesh-0.1.1/uv.lock +1319 -0
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: Bug report
3
+ about: Report a bug in CodeMesh
4
+ title: "[BUG] "
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce:
15
+ 1. Run `codemesh index` on ...
16
+ 2. Run `codemesh query "..."` ...
17
+ 3. See error
18
+
19
+ **Expected behavior**
20
+ What you expected to happen.
21
+
22
+ **Environment**
23
+ - OS: [e.g. macOS 14, Ubuntu 24.04]
24
+ - Python: [e.g. 3.12.5]
25
+ - CodeMesh: [e.g. 0.1.0]
26
+ - Repo size: [e.g. ~500 files, 50K LOC]
27
+
28
+ **Additional context**
29
+ Any other context, screenshots, or logs.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest a feature for CodeMesh
4
+ title: "[FEATURE] "
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem?**
11
+ A clear description of the problem. E.g. "I can't index PHP projects..."
12
+
13
+ **Describe the solution you'd like**
14
+ What you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ Any alternative solutions or workarounds.
18
+
19
+ **Additional context**
20
+ Add any other context, examples, or screenshots.
@@ -0,0 +1,39 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: astral-sh/setup-uv@v4
15
+ - run: uv run --with ".[dev]" ruff check .
16
+ - run: uv run --with ".[dev]" ruff format --check
17
+
18
+ typecheck:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: astral-sh/setup-uv@v4
23
+ - run: uv run --with ".[dev]" mypy codemesh/ --ignore-missing-imports || true
24
+
25
+ test:
26
+ runs-on: ubuntu-latest
27
+ strategy:
28
+ matrix:
29
+ python-version: ["3.12", "3.13"]
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ - uses: astral-sh/setup-uv@v4
33
+ with:
34
+ python-version: ${{ matrix.python-version }}
35
+ - run: uv run --with ".[dev]" pytest tests/ -v --cov=codemesh --cov-report=xml --ignore=tests/test_embedding_e2e.py --ignore=tests/test_viz.py
36
+ - uses: codecov/codecov-action@v4
37
+ if: matrix.python-version == '3.12'
38
+ with:
39
+ file: coverage.xml
@@ -0,0 +1,24 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ environment: pypi
11
+ permissions:
12
+ id-token: write # Required for trusted publishing
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: astral-sh/setup-uv@v4
17
+ with:
18
+ python-version: "3.12"
19
+
20
+ - name: Build package
21
+ run: uv build
22
+
23
+ - name: Publish to PyPI
24
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,233 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ *.py.cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+ cover/
51
+
52
+ # Translations
53
+ *.mo
54
+ *.pot
55
+
56
+ # Django stuff:
57
+ *.log
58
+ local_settings.py
59
+ db.sqlite3
60
+ db.sqlite3-journal
61
+
62
+ # Flask stuff:
63
+ instance/
64
+ .webassets-cache
65
+
66
+ # Scrapy stuff:
67
+ .scrapy
68
+
69
+ # Sphinx documentation
70
+ docs/_build/
71
+
72
+ # PyBuilder
73
+ .pybuilder/
74
+ target/
75
+
76
+ # Jupyter Notebook
77
+ .ipynb_checkpoints
78
+
79
+ # IPython
80
+ profile_default/
81
+ ipython_config.py
82
+
83
+ # pyenv
84
+ # .python-version
85
+
86
+ # pipenv
87
+ # Pipfile.lock
88
+
89
+ # UV
90
+ # uv.lock
91
+
92
+ # poetry
93
+ # poetry.lock
94
+ # poetry.toml
95
+
96
+ # pdm
97
+ # pdm.lock
98
+ # pdm.toml
99
+ .pdm-python
100
+ .pdm-build/
101
+
102
+ # pixi
103
+ # pixi.lock
104
+ .pixi
105
+
106
+ # PEP 582
107
+ __pypackages__/
108
+
109
+ # Celery stuff
110
+ celerybeat-schedule
111
+ celerybeat.pid
112
+
113
+ # Environments
114
+ .env
115
+ .envrc
116
+ .venv
117
+ env/
118
+ venv/
119
+ ENV/
120
+ env.bak/
121
+ venv.bak/
122
+
123
+ # Spyder project settings
124
+ .spyderproject
125
+ .spyproject
126
+
127
+ # Rope project settings
128
+ .ropeproject
129
+
130
+ # mkdocs documentation
131
+ /site
132
+
133
+ # mypy
134
+ .mypy_cache/
135
+ .dmypy.json
136
+ dmypy.json
137
+
138
+ # Pyre type checker
139
+ .pyre/
140
+
141
+ # pytype static type analyzer
142
+ .pytype/
143
+
144
+ # Cython debug symbols
145
+ cython_debug/
146
+
147
+ # PyCharm / JetBrains
148
+ .idea/
149
+
150
+ # Visual Studio Code
151
+ .vscode/
152
+ *.swp
153
+ *.swo
154
+
155
+ # Ruff
156
+ .ruff_cache/
157
+
158
+ # PyPI configuration file
159
+ .pypirc
160
+
161
+ # Marimo
162
+ marimo/_static/
163
+ marimo/_lsp/
164
+ __marimo__/
165
+
166
+ # Streamlit
167
+ .streamlit/secrets.toml
168
+
169
+ # =============================================================================
170
+ # AI Agent / LLM Internal Working Files
171
+ # These files are for developer tooling (Claude Code, Hermes Agent, etc.)
172
+ # and are NOT part of the CodeMesh project functionality.
173
+ # =============================================================================
174
+
175
+ # Claude Code
176
+ .claude/
177
+ CLAUDE.md
178
+ AGENTS.md
179
+
180
+ # Hermes Agent
181
+ .hermes/
182
+ hermes.yaml
183
+ hermes.yml
184
+ .hermesagent/
185
+ .hacfg
186
+
187
+ # OpenCode
188
+ .opencode/
189
+
190
+ # Cursor
191
+ .cursor/
192
+ .cursorrules
193
+
194
+ # Continue.dev
195
+ .continue/
196
+
197
+ # GitHub Copilot
198
+ .copilot/
199
+
200
+ # =============================================================================
201
+ # =============================================================================
202
+
203
+ # OS
204
+ .DS_Store
205
+ Thumbs.db
206
+ Thumbs.db:encryptable
207
+ *.stackdump
208
+ [Cc]rash[Rr]eports/
209
+ retirejs.json
210
+
211
+ # Project specific
212
+ *.db
213
+ *.sqlite
214
+ *.sqlite3
215
+ .codemesh/
216
+ codemesh.egg-info/
217
+
218
+ # Model cache (downloaded embedding/reranker models)
219
+ .models/
220
+ *.onnx
221
+ *.bin
222
+ *.safetensors
223
+
224
+ # Temporary files
225
+ *.tmp
226
+ *.bak
227
+ *~
228
+ \\#*\\#
229
+
230
+ # Benchmark comparison files (internal use, not for publication)
231
+ codemesh/benchmark/
232
+ docs/docs/
233
+ docs/
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2026-05-24
4
+
5
+ ### Added
6
+ - Initial project skeleton
7
+ - Hybrid structural+semantic code RAG architecture
@@ -0,0 +1,102 @@
1
+ # Contributing to CodeMesh
2
+
3
+ ## Getting Started
4
+
5
+ ```bash
6
+ git clone https://github.com/gkatte/codemesh.git
7
+ cd codemesh
8
+ uv pip install -e ".[dev]"
9
+ ```
10
+
11
+ ## Running Tests
12
+
13
+ ```bash
14
+ # Run all tests (fast)
15
+ pytest tests/ -x -q
16
+
17
+ # Run with coverage
18
+ pytest tests/ -v --cov=codemesh --cov-report=html
19
+
20
+ # Skip slow/integration tests
21
+ pytest tests/ -x -q -m "not slow"
22
+ ```
23
+
24
+ Tests must pass before every commit.
25
+
26
+ ```bash
27
+ ruff check . --fix && ruff format .
28
+ ```
29
+
30
+ ## Project Structure
31
+
32
+ ```
33
+ codemesh/
34
+ ├── cli/ # Typer CLI commands (init, index, query, etc.)
35
+ ├── db/ # SQLite schema, connections, queries
36
+ ├── extraction/ # tree-sitter AST extraction + language-specific extractors
37
+ ├── resolution/ # Reference resolution + type inference
38
+ ├── search/ # BM25 keyword search (3-tier: FTS5, LIKE, fuzzy)
39
+ ├── graph/ # Graph walk (BFS), traversal, impact analysis
40
+ ├── context/ # Context builder (token-budget-aware XML output)
41
+ ├── mcp/ # MCP server (stdio/SSE transport)
42
+ └── types.py # Shared types: Node, Edge, EdgeKind, NodeKind
43
+ ```
44
+
45
+ ## Supported Languages
46
+
47
+ | Language | tree-sitter package | File Extensions |
48
+ |-------------|-----------------------------|--------------------------|
49
+ | Python | `tree-sitter-python` | `.py` |
50
+ | TypeScript | `tree-sitter-typescript` | `.ts`, `.tsx` |
51
+ | JavaScript | `tree-sitter-typescript` | `.js`, `.jsx` |
52
+ | Rust | `tree-sitter-rust` | `.rs` |
53
+ | Go | `tree-sitter-go` | `.go` |
54
+ | Java | `tree-sitter-java` | `.java` |
55
+ | Kotlin | `tree-sitter-kotlin` | `.kt`, `.kts` |
56
+ | Swift | `tree-sitter-swift` | `.swift` |
57
+ | C | `tree-sitter-c` | `.c`, `.h` |
58
+ | C++ | `tree-sitter-cpp` | `.cpp`, `.hpp`, `.cc` |
59
+
60
+ ## Adding a New Language
61
+
62
+ 1. **Add the tree-sitter dependency** to `pyproject.toml`:
63
+ ```toml
64
+ "tree-sitter-mylang>=0.5",
65
+ ```
66
+
67
+ 2. **Create a new extractor** in `codemesh/extraction/extractors/mylang.py`:
68
+ - Use `tree-sitter` to parse source files
69
+ - Define AST query patterns for the language (functions, classes, methods, imports)
70
+ - Extract nodes (`Node` objects) and edges (`Edge` objects)
71
+ - Register in the `extractor_for_ext()` dispatcher
72
+
73
+ 3. **Add file extensions** to the `EXTRACTOR_MAP` or equivalent dispatcher in the extraction module.
74
+
75
+ 4. **Add a test** in `tests/test_extraction.py` covering:
76
+ - Node extraction accuracy
77
+ - Edge extraction (calls, imports, contains)
78
+ - Integration test with the full pipeline
79
+
80
+ 5. **Update this file** — add the language to the table above.
81
+
82
+ 6. **Update `codemesh/cli/init.py`** — add the language's agent instruction template.
83
+
84
+ ## Adding a New Edge Kind
85
+
86
+ 1. Add the variant to the `EdgeKind` enum in `codemesh/types.py`
87
+ 2. Update all extractors that should produce this edge kind
88
+ 3. Add a partial index in `codemesh/db/schema.py` for query performance
89
+
90
+ ## Code Style
91
+
92
+ - Modern Python: `from __future__ import annotations`, dataclasses, `pathlib`, match statements
93
+ - Every module and public function gets a docstring
94
+ - No dead code — delete orphaned helpers
95
+ - Schema changes: add columns with defaults (never breaking)
96
+
97
+ ## Commit Rules
98
+
99
+ - One logical change per commit
100
+ - Write meaningful commit messages describing WHAT and WHY
101
+ - Run `ruff check . --fix && ruff format .` before committing
102
+ - Tests must pass before committing
codemesh-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CodeMesh Developer
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,28 @@
1
+ .PHONY: help install dev lint typecheck test test-cov clean
2
+
3
+ help: ## Show this help
4
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
5
+ awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
6
+
7
+ install: ## Install production dependencies
8
+ uv pip install -e .
9
+
10
+ dev: ## Install with dev dependencies
11
+ uv pip install -e ".[dev]"
12
+
13
+ lint: ## Run ruff linter + formatter
14
+ ruff check . --fix
15
+ ruff format .
16
+
17
+ typecheck: ## Run mypy type checker
18
+ mypy codemesh/
19
+
20
+ test: ## Run tests
21
+ pytest tests/ -v
22
+
23
+ test-cov: ## Run tests with coverage
24
+ pytest tests/ -v --cov=codemesh --cov-report=term-missing
25
+
26
+ clean: ## Clean build artifacts
27
+ rm -rf build/ dist/ *.egg-info .pytest_cache .mypy_cache .ruff_cache
28
+ find . -type d -name __pycache__ -exec rm -rf {} +