codespine 0.5.5__tar.gz → 0.5.6__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.
- {codespine-0.5.5 → codespine-0.5.6}/PKG-INFO +38 -1
- {codespine-0.5.5 → codespine-0.5.6}/README.md +37 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/__init__.py +1 -1
- {codespine-0.5.5 → codespine-0.5.6}/codespine/db/store.py +50 -11
- {codespine-0.5.5 → codespine-0.5.6}/codespine.egg-info/PKG-INFO +38 -1
- {codespine-0.5.5 → codespine-0.5.6}/codespine.egg-info/SOURCES.txt +2 -1
- {codespine-0.5.5 → codespine-0.5.6}/pyproject.toml +1 -1
- codespine-0.5.6/tests/test_store_recovery.py +52 -0
- {codespine-0.5.5 → codespine-0.5.6}/LICENSE +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/analysis/__init__.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/analysis/community.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/analysis/context.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/analysis/coupling.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/analysis/crossmodule.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/analysis/deadcode.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/analysis/flow.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/analysis/impact.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/cli.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/config.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/db/__init__.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/db/schema.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/diff/__init__.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/diff/branch_diff.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/indexer/__init__.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/indexer/call_resolver.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/indexer/engine.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/indexer/java_parser.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/indexer/symbol_builder.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/mcp/__init__.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/mcp/server.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/noise/__init__.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/noise/blocklist.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/overlay/__init__.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/overlay/git_state.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/overlay/merge.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/overlay/store.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/search/__init__.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/search/bm25.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/search/fuzzy.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/search/hybrid.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/search/rrf.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/search/vector.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/watch/__init__.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine/watch/watcher.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine.egg-info/dependency_links.txt +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine.egg-info/entry_points.txt +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine.egg-info/requires.txt +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/codespine.egg-info/top_level.txt +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/gindex.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/setup.cfg +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/tests/test_branch_diff_normalize.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/tests/test_call_resolver.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/tests/test_community_detection.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/tests/test_deadcode.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/tests/test_index_and_hybrid.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/tests/test_java_parser.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/tests/test_multimodule_index.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/tests/test_overlay.py +0 -0
- {codespine-0.5.5 → codespine-0.5.6}/tests/test_search_ranking.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codespine
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.6
|
|
4
4
|
Summary: Local Java code intelligence indexer backed by a graph database
|
|
5
5
|
Author: CodeSpine contributors
|
|
6
6
|
License: MIT License
|
|
@@ -70,12 +70,15 @@ Instead of having an agent open dozens of `.java` files to answer one question,
|
|
|
70
70
|
|
|
71
71
|
It indexes classes, methods, calls, type relationships, cross-module links, git coupling, dead-code candidates, and execution flows so agents can work from graph answers first and source files second.
|
|
72
72
|
|
|
73
|
+
It also keeps a separate dirty overlay for uncommitted Java edits, so agents can query current work-in-progress without forcing the committed base index to churn on every save.
|
|
74
|
+
|
|
73
75
|
## Why It Saves Tokens
|
|
74
76
|
|
|
75
77
|
- One MCP call can replace many file opens. `get_symbol_context("PaymentService")` returns a resolved neighborhood instead of forcing the agent to read every caller and callee file manually.
|
|
76
78
|
- Search is structure-aware. Agents can ask for a symbol, concept, impact radius, or dead-code candidate without scanning entire packages.
|
|
77
79
|
- Multi-module repos stay scoped. Project-aware IDs and `project=` parameters reduce noise from unrelated modules and workspaces.
|
|
78
80
|
- Repeat sessions get cheaper. Once indexed, the agent reuses the graph instead of re-discovering the same relationships every turn.
|
|
81
|
+
- Active edits stay smooth. Dirty files are kept in an overlay and merged into fast queries until you commit, instead of hammering the main graph DB on each change.
|
|
79
82
|
|
|
80
83
|
## Install
|
|
81
84
|
|
|
@@ -100,6 +103,32 @@ pip install "codespine[ml]"
|
|
|
100
103
|
- Multi-project and multi-module indexing: workspaces, Maven modules, Gradle subprojects
|
|
101
104
|
- MCP server: structured tools for Claude, Cursor, Cline, Copilot, and similar clients
|
|
102
105
|
|
|
106
|
+
## Editing Without Stale Indexes
|
|
107
|
+
|
|
108
|
+
CodeSpine uses a two-layer model:
|
|
109
|
+
|
|
110
|
+
- Base index: last committed state
|
|
111
|
+
- Dirty overlay: uncommitted Java changes
|
|
112
|
+
|
|
113
|
+
Fast tools read merged `base + overlay` state by default:
|
|
114
|
+
|
|
115
|
+
- `search`
|
|
116
|
+
- `context`
|
|
117
|
+
- `impact`
|
|
118
|
+
- MCP `search_hybrid`
|
|
119
|
+
- MCP `find_symbol`
|
|
120
|
+
- MCP `get_symbol_context`
|
|
121
|
+
- MCP `get_impact`
|
|
122
|
+
|
|
123
|
+
Deep analyses stay committed-only until promotion:
|
|
124
|
+
|
|
125
|
+
- `deadcode`
|
|
126
|
+
- `flow`
|
|
127
|
+
- `community`
|
|
128
|
+
- `coupling`
|
|
129
|
+
|
|
130
|
+
`codespine watch` updates the dirty overlay after a debounce window, then promotes it into the base index when local `HEAD` changes.
|
|
131
|
+
|
|
103
132
|
## Quick Start
|
|
104
133
|
|
|
105
134
|
Index a repo:
|
|
@@ -205,6 +234,7 @@ codespine analyse <path> --full
|
|
|
205
234
|
codespine analyse <path> --deep
|
|
206
235
|
codespine analyse <path> --embed
|
|
207
236
|
codespine watch --path .
|
|
237
|
+
codespine watch --path . --overlay-debounce-ms 1500
|
|
208
238
|
codespine search "query"
|
|
209
239
|
codespine context "symbol"
|
|
210
240
|
codespine impact "symbol"
|
|
@@ -215,6 +245,9 @@ codespine coupling
|
|
|
215
245
|
codespine diff main..feature
|
|
216
246
|
codespine stats
|
|
217
247
|
codespine list
|
|
248
|
+
codespine overlay-status
|
|
249
|
+
codespine overlay-promote
|
|
250
|
+
codespine overlay-clear
|
|
218
251
|
codespine clear-project <project_id>
|
|
219
252
|
codespine clear-index
|
|
220
253
|
```
|
|
@@ -247,6 +280,8 @@ That same project ID can be passed into MCP tools and CLI analysis calls that su
|
|
|
247
280
|
|
|
248
281
|
Use it when you want architecture-level context. Skip it when you just need the graph refreshed for search, context, and impact.
|
|
249
282
|
|
|
283
|
+
When a dirty overlay exists, deep-analysis results intentionally exclude those uncommitted edits until promotion.
|
|
284
|
+
|
|
250
285
|
`--embed` is also optional. Without it, CodeSpine still supports exact, keyword, and fuzzy search. Add embeddings when you need concept-level retrieval.
|
|
251
286
|
|
|
252
287
|
## Runtime Files
|
|
@@ -256,10 +291,12 @@ Use it when you want architecture-level context. Skip it when you just need the
|
|
|
256
291
|
- `~/.codespine.log` - server log
|
|
257
292
|
- `~/.codespine_embedding_cache.json` - embedding cache
|
|
258
293
|
- `~/.codespine_index_meta/` - incremental file metadata cache
|
|
294
|
+
- `~/.codespine_overlay/` - uncommitted dirty overlay state
|
|
259
295
|
|
|
260
296
|
## Notes
|
|
261
297
|
|
|
262
298
|
- `codespine start` launches a background MCP server. Most IDE MCP clients should use `codespine mcp` instead and manage the process themselves.
|
|
299
|
+
- `codespine watch` updates the dirty overlay first; it does not rewrite the committed base index on every save.
|
|
263
300
|
- `codespine clear-index` rebuilds the local index database from scratch.
|
|
264
301
|
- For large Spring or JPA-heavy repos, dead-code results should still be reviewed before deletion. The tool is conservative, not authoritative.
|
|
265
302
|
|
|
@@ -6,12 +6,15 @@ Instead of having an agent open dozens of `.java` files to answer one question,
|
|
|
6
6
|
|
|
7
7
|
It indexes classes, methods, calls, type relationships, cross-module links, git coupling, dead-code candidates, and execution flows so agents can work from graph answers first and source files second.
|
|
8
8
|
|
|
9
|
+
It also keeps a separate dirty overlay for uncommitted Java edits, so agents can query current work-in-progress without forcing the committed base index to churn on every save.
|
|
10
|
+
|
|
9
11
|
## Why It Saves Tokens
|
|
10
12
|
|
|
11
13
|
- One MCP call can replace many file opens. `get_symbol_context("PaymentService")` returns a resolved neighborhood instead of forcing the agent to read every caller and callee file manually.
|
|
12
14
|
- Search is structure-aware. Agents can ask for a symbol, concept, impact radius, or dead-code candidate without scanning entire packages.
|
|
13
15
|
- Multi-module repos stay scoped. Project-aware IDs and `project=` parameters reduce noise from unrelated modules and workspaces.
|
|
14
16
|
- Repeat sessions get cheaper. Once indexed, the agent reuses the graph instead of re-discovering the same relationships every turn.
|
|
17
|
+
- Active edits stay smooth. Dirty files are kept in an overlay and merged into fast queries until you commit, instead of hammering the main graph DB on each change.
|
|
15
18
|
|
|
16
19
|
## Install
|
|
17
20
|
|
|
@@ -36,6 +39,32 @@ pip install "codespine[ml]"
|
|
|
36
39
|
- Multi-project and multi-module indexing: workspaces, Maven modules, Gradle subprojects
|
|
37
40
|
- MCP server: structured tools for Claude, Cursor, Cline, Copilot, and similar clients
|
|
38
41
|
|
|
42
|
+
## Editing Without Stale Indexes
|
|
43
|
+
|
|
44
|
+
CodeSpine uses a two-layer model:
|
|
45
|
+
|
|
46
|
+
- Base index: last committed state
|
|
47
|
+
- Dirty overlay: uncommitted Java changes
|
|
48
|
+
|
|
49
|
+
Fast tools read merged `base + overlay` state by default:
|
|
50
|
+
|
|
51
|
+
- `search`
|
|
52
|
+
- `context`
|
|
53
|
+
- `impact`
|
|
54
|
+
- MCP `search_hybrid`
|
|
55
|
+
- MCP `find_symbol`
|
|
56
|
+
- MCP `get_symbol_context`
|
|
57
|
+
- MCP `get_impact`
|
|
58
|
+
|
|
59
|
+
Deep analyses stay committed-only until promotion:
|
|
60
|
+
|
|
61
|
+
- `deadcode`
|
|
62
|
+
- `flow`
|
|
63
|
+
- `community`
|
|
64
|
+
- `coupling`
|
|
65
|
+
|
|
66
|
+
`codespine watch` updates the dirty overlay after a debounce window, then promotes it into the base index when local `HEAD` changes.
|
|
67
|
+
|
|
39
68
|
## Quick Start
|
|
40
69
|
|
|
41
70
|
Index a repo:
|
|
@@ -141,6 +170,7 @@ codespine analyse <path> --full
|
|
|
141
170
|
codespine analyse <path> --deep
|
|
142
171
|
codespine analyse <path> --embed
|
|
143
172
|
codespine watch --path .
|
|
173
|
+
codespine watch --path . --overlay-debounce-ms 1500
|
|
144
174
|
codespine search "query"
|
|
145
175
|
codespine context "symbol"
|
|
146
176
|
codespine impact "symbol"
|
|
@@ -151,6 +181,9 @@ codespine coupling
|
|
|
151
181
|
codespine diff main..feature
|
|
152
182
|
codespine stats
|
|
153
183
|
codespine list
|
|
184
|
+
codespine overlay-status
|
|
185
|
+
codespine overlay-promote
|
|
186
|
+
codespine overlay-clear
|
|
154
187
|
codespine clear-project <project_id>
|
|
155
188
|
codespine clear-index
|
|
156
189
|
```
|
|
@@ -183,6 +216,8 @@ That same project ID can be passed into MCP tools and CLI analysis calls that su
|
|
|
183
216
|
|
|
184
217
|
Use it when you want architecture-level context. Skip it when you just need the graph refreshed for search, context, and impact.
|
|
185
218
|
|
|
219
|
+
When a dirty overlay exists, deep-analysis results intentionally exclude those uncommitted edits until promotion.
|
|
220
|
+
|
|
186
221
|
`--embed` is also optional. Without it, CodeSpine still supports exact, keyword, and fuzzy search. Add embeddings when you need concept-level retrieval.
|
|
187
222
|
|
|
188
223
|
## Runtime Files
|
|
@@ -192,10 +227,12 @@ Use it when you want architecture-level context. Skip it when you just need the
|
|
|
192
227
|
- `~/.codespine.log` - server log
|
|
193
228
|
- `~/.codespine_embedding_cache.json` - embedding cache
|
|
194
229
|
- `~/.codespine_index_meta/` - incremental file metadata cache
|
|
230
|
+
- `~/.codespine_overlay/` - uncommitted dirty overlay state
|
|
195
231
|
|
|
196
232
|
## Notes
|
|
197
233
|
|
|
198
234
|
- `codespine start` launches a background MCP server. Most IDE MCP clients should use `codespine mcp` instead and manage the process themselves.
|
|
235
|
+
- `codespine watch` updates the dirty overlay first; it does not rewrite the committed base index on every save.
|
|
199
236
|
- `codespine clear-index` rebuilds the local index database from scratch.
|
|
200
237
|
- For large Spring or JPA-heavy repos, dead-code results should still be reviewed before deletion. The tool is conservative, not authoritative.
|
|
201
238
|
|
|
@@ -19,6 +19,15 @@ from codespine.db.schema import ensure_schema
|
|
|
19
19
|
LOGGER = logging.getLogger(__name__)
|
|
20
20
|
|
|
21
21
|
_BUFFER_POOL_SIZE = 512 * 1024 * 1024 # 512 MB – room for large community detection
|
|
22
|
+
_RECOVERABLE_DB_ERROR_MARKERS = (
|
|
23
|
+
"storage version mismatch",
|
|
24
|
+
"catalog version mismatch",
|
|
25
|
+
"database version is not supported",
|
|
26
|
+
"wal version mismatch",
|
|
27
|
+
"corrupt",
|
|
28
|
+
"corrupted",
|
|
29
|
+
"invalid database",
|
|
30
|
+
)
|
|
22
31
|
|
|
23
32
|
|
|
24
33
|
@dataclass
|
|
@@ -32,13 +41,13 @@ class GraphStore:
|
|
|
32
41
|
|
|
33
42
|
self.overlay_store = OverlayStore()
|
|
34
43
|
try:
|
|
35
|
-
self.db = self.
|
|
44
|
+
self.db = self._open_with_recovery(db_path)
|
|
36
45
|
except Exception as exc:
|
|
37
46
|
fallback = os.path.join("/tmp", ".codespine_db")
|
|
38
47
|
LOGGER.warning("Primary DB path failed (%s). Falling back to %s", exc, fallback)
|
|
39
|
-
self.db = self.
|
|
48
|
+
self.db = self._open_with_recovery(fallback)
|
|
40
49
|
if not self.read_only:
|
|
41
|
-
|
|
50
|
+
self._ensure_schema_with_recovery()
|
|
42
51
|
|
|
43
52
|
def _open_db(self, path: str) -> kuzu.Database:
|
|
44
53
|
# Newer Kuzu versions accept read_only; fall back for older ones.
|
|
@@ -47,6 +56,42 @@ class GraphStore:
|
|
|
47
56
|
except TypeError:
|
|
48
57
|
return kuzu.Database(path, buffer_pool_size=_BUFFER_POOL_SIZE)
|
|
49
58
|
|
|
59
|
+
@staticmethod
|
|
60
|
+
def _is_recoverable_db_error(exc: Exception) -> bool:
|
|
61
|
+
message = str(exc).lower()
|
|
62
|
+
return any(marker in message for marker in _RECOVERABLE_DB_ERROR_MARKERS)
|
|
63
|
+
|
|
64
|
+
@staticmethod
|
|
65
|
+
def _remove_db_path(path: str) -> None:
|
|
66
|
+
if os.path.isdir(path):
|
|
67
|
+
shutil.rmtree(path, ignore_errors=True)
|
|
68
|
+
elif os.path.exists(path):
|
|
69
|
+
os.remove(path)
|
|
70
|
+
|
|
71
|
+
def _open_with_recovery(self, path: str) -> kuzu.Database:
|
|
72
|
+
try:
|
|
73
|
+
return self._open_db(path)
|
|
74
|
+
except Exception as exc:
|
|
75
|
+
if not self._is_recoverable_db_error(exc):
|
|
76
|
+
raise
|
|
77
|
+
LOGGER.warning("Removing corrupted or incompatible Kuzu DB at %s: %s", path, exc)
|
|
78
|
+
self._remove_db_path(path)
|
|
79
|
+
self._tls = threading.local()
|
|
80
|
+
return self._open_db(path)
|
|
81
|
+
|
|
82
|
+
def _ensure_schema_with_recovery(self) -> None:
|
|
83
|
+
try:
|
|
84
|
+
ensure_schema(self._conn())
|
|
85
|
+
except Exception as exc:
|
|
86
|
+
path = getattr(self.db, "database_path", SETTINGS.db_path)
|
|
87
|
+
if not self._is_recoverable_db_error(exc):
|
|
88
|
+
raise
|
|
89
|
+
LOGGER.warning("Rebuilding corrupted or incompatible Kuzu DB at %s during schema init: %s", path, exc)
|
|
90
|
+
self._remove_db_path(path)
|
|
91
|
+
self.db = self._open_db(path)
|
|
92
|
+
self._tls = threading.local()
|
|
93
|
+
ensure_schema(self._conn())
|
|
94
|
+
|
|
50
95
|
def _conn(self) -> kuzu.Connection:
|
|
51
96
|
"""Return the per-thread Kuzu connection, creating it lazily."""
|
|
52
97
|
if not hasattr(self._tls, "conn") or self._tls.conn is None:
|
|
@@ -447,16 +492,10 @@ class GraphStore:
|
|
|
447
492
|
self._recycle_conn()
|
|
448
493
|
path = SETTINGS.db_path
|
|
449
494
|
try:
|
|
450
|
-
|
|
451
|
-
shutil.rmtree(path, ignore_errors=True)
|
|
452
|
-
elif os.path.exists(path):
|
|
453
|
-
os.remove(path)
|
|
495
|
+
self._remove_db_path(path)
|
|
454
496
|
except OSError:
|
|
455
497
|
fallback = os.path.join("/tmp", ".codespine_db")
|
|
456
|
-
|
|
457
|
-
shutil.rmtree(fallback, ignore_errors=True)
|
|
458
|
-
elif os.path.exists(fallback):
|
|
459
|
-
os.remove(fallback)
|
|
498
|
+
self._remove_db_path(fallback)
|
|
460
499
|
self.db = self._open_db(fallback)
|
|
461
500
|
else:
|
|
462
501
|
self.db = self._open_db(path)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codespine
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.6
|
|
4
4
|
Summary: Local Java code intelligence indexer backed by a graph database
|
|
5
5
|
Author: CodeSpine contributors
|
|
6
6
|
License: MIT License
|
|
@@ -70,12 +70,15 @@ Instead of having an agent open dozens of `.java` files to answer one question,
|
|
|
70
70
|
|
|
71
71
|
It indexes classes, methods, calls, type relationships, cross-module links, git coupling, dead-code candidates, and execution flows so agents can work from graph answers first and source files second.
|
|
72
72
|
|
|
73
|
+
It also keeps a separate dirty overlay for uncommitted Java edits, so agents can query current work-in-progress without forcing the committed base index to churn on every save.
|
|
74
|
+
|
|
73
75
|
## Why It Saves Tokens
|
|
74
76
|
|
|
75
77
|
- One MCP call can replace many file opens. `get_symbol_context("PaymentService")` returns a resolved neighborhood instead of forcing the agent to read every caller and callee file manually.
|
|
76
78
|
- Search is structure-aware. Agents can ask for a symbol, concept, impact radius, or dead-code candidate without scanning entire packages.
|
|
77
79
|
- Multi-module repos stay scoped. Project-aware IDs and `project=` parameters reduce noise from unrelated modules and workspaces.
|
|
78
80
|
- Repeat sessions get cheaper. Once indexed, the agent reuses the graph instead of re-discovering the same relationships every turn.
|
|
81
|
+
- Active edits stay smooth. Dirty files are kept in an overlay and merged into fast queries until you commit, instead of hammering the main graph DB on each change.
|
|
79
82
|
|
|
80
83
|
## Install
|
|
81
84
|
|
|
@@ -100,6 +103,32 @@ pip install "codespine[ml]"
|
|
|
100
103
|
- Multi-project and multi-module indexing: workspaces, Maven modules, Gradle subprojects
|
|
101
104
|
- MCP server: structured tools for Claude, Cursor, Cline, Copilot, and similar clients
|
|
102
105
|
|
|
106
|
+
## Editing Without Stale Indexes
|
|
107
|
+
|
|
108
|
+
CodeSpine uses a two-layer model:
|
|
109
|
+
|
|
110
|
+
- Base index: last committed state
|
|
111
|
+
- Dirty overlay: uncommitted Java changes
|
|
112
|
+
|
|
113
|
+
Fast tools read merged `base + overlay` state by default:
|
|
114
|
+
|
|
115
|
+
- `search`
|
|
116
|
+
- `context`
|
|
117
|
+
- `impact`
|
|
118
|
+
- MCP `search_hybrid`
|
|
119
|
+
- MCP `find_symbol`
|
|
120
|
+
- MCP `get_symbol_context`
|
|
121
|
+
- MCP `get_impact`
|
|
122
|
+
|
|
123
|
+
Deep analyses stay committed-only until promotion:
|
|
124
|
+
|
|
125
|
+
- `deadcode`
|
|
126
|
+
- `flow`
|
|
127
|
+
- `community`
|
|
128
|
+
- `coupling`
|
|
129
|
+
|
|
130
|
+
`codespine watch` updates the dirty overlay after a debounce window, then promotes it into the base index when local `HEAD` changes.
|
|
131
|
+
|
|
103
132
|
## Quick Start
|
|
104
133
|
|
|
105
134
|
Index a repo:
|
|
@@ -205,6 +234,7 @@ codespine analyse <path> --full
|
|
|
205
234
|
codespine analyse <path> --deep
|
|
206
235
|
codespine analyse <path> --embed
|
|
207
236
|
codespine watch --path .
|
|
237
|
+
codespine watch --path . --overlay-debounce-ms 1500
|
|
208
238
|
codespine search "query"
|
|
209
239
|
codespine context "symbol"
|
|
210
240
|
codespine impact "symbol"
|
|
@@ -215,6 +245,9 @@ codespine coupling
|
|
|
215
245
|
codespine diff main..feature
|
|
216
246
|
codespine stats
|
|
217
247
|
codespine list
|
|
248
|
+
codespine overlay-status
|
|
249
|
+
codespine overlay-promote
|
|
250
|
+
codespine overlay-clear
|
|
218
251
|
codespine clear-project <project_id>
|
|
219
252
|
codespine clear-index
|
|
220
253
|
```
|
|
@@ -247,6 +280,8 @@ That same project ID can be passed into MCP tools and CLI analysis calls that su
|
|
|
247
280
|
|
|
248
281
|
Use it when you want architecture-level context. Skip it when you just need the graph refreshed for search, context, and impact.
|
|
249
282
|
|
|
283
|
+
When a dirty overlay exists, deep-analysis results intentionally exclude those uncommitted edits until promotion.
|
|
284
|
+
|
|
250
285
|
`--embed` is also optional. Without it, CodeSpine still supports exact, keyword, and fuzzy search. Add embeddings when you need concept-level retrieval.
|
|
251
286
|
|
|
252
287
|
## Runtime Files
|
|
@@ -256,10 +291,12 @@ Use it when you want architecture-level context. Skip it when you just need the
|
|
|
256
291
|
- `~/.codespine.log` - server log
|
|
257
292
|
- `~/.codespine_embedding_cache.json` - embedding cache
|
|
258
293
|
- `~/.codespine_index_meta/` - incremental file metadata cache
|
|
294
|
+
- `~/.codespine_overlay/` - uncommitted dirty overlay state
|
|
259
295
|
|
|
260
296
|
## Notes
|
|
261
297
|
|
|
262
298
|
- `codespine start` launches a background MCP server. Most IDE MCP clients should use `codespine mcp` instead and manage the process themselves.
|
|
299
|
+
- `codespine watch` updates the dirty overlay first; it does not rewrite the committed base index on every save.
|
|
263
300
|
- `codespine clear-index` rebuilds the local index database from scratch.
|
|
264
301
|
- For large Spring or JPA-heavy repos, dead-code results should still be reviewed before deletion. The tool is conservative, not authoritative.
|
|
265
302
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
pytest.importorskip("kuzu")
|
|
6
|
+
|
|
7
|
+
from codespine.db.store import GraphStore
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_open_with_recovery_rebuilds_legacy_db(monkeypatch):
|
|
11
|
+
opened: list[str] = []
|
|
12
|
+
removed: list[str] = []
|
|
13
|
+
calls = {"count": 0}
|
|
14
|
+
|
|
15
|
+
def fake_open(self, path: str):
|
|
16
|
+
calls["count"] += 1
|
|
17
|
+
opened.append(path)
|
|
18
|
+
if calls["count"] == 1:
|
|
19
|
+
raise RuntimeError("Storage version mismatch: unsupported database")
|
|
20
|
+
return object()
|
|
21
|
+
|
|
22
|
+
monkeypatch.setattr(GraphStore, "_open_db", fake_open)
|
|
23
|
+
monkeypatch.setattr(GraphStore, "_remove_db_path", staticmethod(lambda path: removed.append(path)))
|
|
24
|
+
|
|
25
|
+
store = GraphStore.__new__(GraphStore)
|
|
26
|
+
store.read_only = False
|
|
27
|
+
store._tls = None
|
|
28
|
+
|
|
29
|
+
db = GraphStore._open_with_recovery(store, "/tmp/test-codespine-db")
|
|
30
|
+
|
|
31
|
+
assert db is not None
|
|
32
|
+
assert opened == ["/tmp/test-codespine-db", "/tmp/test-codespine-db"]
|
|
33
|
+
assert removed == ["/tmp/test-codespine-db"]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_open_with_recovery_does_not_remove_on_permission_error(monkeypatch):
|
|
37
|
+
removed: list[str] = []
|
|
38
|
+
|
|
39
|
+
def fake_open(self, path: str):
|
|
40
|
+
raise RuntimeError("Operation not permitted")
|
|
41
|
+
|
|
42
|
+
monkeypatch.setattr(GraphStore, "_open_db", fake_open)
|
|
43
|
+
monkeypatch.setattr(GraphStore, "_remove_db_path", staticmethod(lambda path: removed.append(path)))
|
|
44
|
+
|
|
45
|
+
store = GraphStore.__new__(GraphStore)
|
|
46
|
+
store.read_only = False
|
|
47
|
+
store._tls = None
|
|
48
|
+
|
|
49
|
+
with pytest.raises(RuntimeError, match="Operation not permitted"):
|
|
50
|
+
GraphStore._open_with_recovery(store, "/tmp/test-codespine-db")
|
|
51
|
+
|
|
52
|
+
assert removed == []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|