codespine 0.4.1__tar.gz → 0.4.3__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.4.1 → codespine-0.4.3}/PKG-INFO +2 -2
- {codespine-0.4.1 → codespine-0.4.3}/codespine/__init__.py +1 -1
- {codespine-0.4.1 → codespine-0.4.3}/codespine/analysis/deadcode.py +49 -18
- {codespine-0.4.1 → codespine-0.4.3}/codespine/analysis/flow.py +22 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/analysis/impact.py +58 -1
- {codespine-0.4.1 → codespine-0.4.3}/codespine/mcp/server.py +47 -10
- {codespine-0.4.1 → codespine-0.4.3}/codespine/search/hybrid.py +17 -4
- {codespine-0.4.1 → codespine-0.4.3}/codespine.egg-info/PKG-INFO +2 -2
- {codespine-0.4.1 → codespine-0.4.3}/codespine.egg-info/requires.txt +1 -1
- {codespine-0.4.1 → codespine-0.4.3}/pyproject.toml +2 -2
- {codespine-0.4.1 → codespine-0.4.3}/LICENSE +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/README.md +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/analysis/__init__.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/analysis/community.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/analysis/context.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/analysis/coupling.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/cli.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/config.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/db/__init__.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/db/schema.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/db/store.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/diff/__init__.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/diff/branch_diff.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/indexer/__init__.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/indexer/call_resolver.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/indexer/engine.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/indexer/java_parser.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/indexer/symbol_builder.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/mcp/__init__.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/noise/__init__.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/noise/blocklist.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/search/__init__.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/search/bm25.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/search/fuzzy.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/search/rrf.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/search/vector.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/watch/__init__.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine/watch/watcher.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine.egg-info/SOURCES.txt +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine.egg-info/dependency_links.txt +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine.egg-info/entry_points.txt +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/codespine.egg-info/top_level.txt +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/gindex.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/setup.cfg +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/tests/test_branch_diff_normalize.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/tests/test_call_resolver.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/tests/test_index_and_hybrid.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/tests/test_java_parser.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/tests/test_multimodule_index.py +0 -0
- {codespine-0.4.1 → codespine-0.4.3}/tests/test_search_ranking.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codespine
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
4
4
|
Summary: Local Java code intelligence indexer backed by a graph database
|
|
5
5
|
Author: CodeSpine contributors
|
|
6
6
|
License: MIT License
|
|
@@ -46,7 +46,7 @@ Requires-Dist: click
|
|
|
46
46
|
Requires-Dist: kuzu
|
|
47
47
|
Requires-Dist: tree-sitter
|
|
48
48
|
Requires-Dist: tree-sitter-java
|
|
49
|
-
Requires-Dist: fastmcp
|
|
49
|
+
Requires-Dist: fastmcp>=2.3.0
|
|
50
50
|
Requires-Dist: psutil
|
|
51
51
|
Requires-Dist: watchfiles
|
|
52
52
|
Provides-Extra: ml
|
|
@@ -74,8 +74,17 @@ def _modifier_tokens(modifiers) -> set[str]:
|
|
|
74
74
|
return {str(m).strip() for m in modifiers}
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
def detect_dead_code(store, limit: int = 200, project: str | None = None) -> list[dict]:
|
|
78
|
-
"""Java-aware dead code detection with exemption passes.
|
|
77
|
+
def detect_dead_code(store, limit: int = 200, project: str | None = None) -> list[dict] | None:
|
|
78
|
+
"""Java-aware dead code detection with exemption passes.
|
|
79
|
+
|
|
80
|
+
Returns a list of dead method dicts, each with:
|
|
81
|
+
method_id, name, signature, class_fqcn, file_path, reason.
|
|
82
|
+
|
|
83
|
+
The return value is augmented with a ``_stats`` entry (a sentinel dict
|
|
84
|
+
with key ``_stats``) containing pre/post-exemption counts so callers can
|
|
85
|
+
show users that the exemption logic is actually working:
|
|
86
|
+
candidates_with_no_callers, exempted, dead_returned
|
|
87
|
+
"""
|
|
79
88
|
if project:
|
|
80
89
|
candidates = store.query_records(
|
|
81
90
|
"""
|
|
@@ -88,16 +97,17 @@ def detect_dead_code(store, limit: int = 200, project: str | None = None) -> lis
|
|
|
88
97
|
m.modifiers as modifiers,
|
|
89
98
|
c.fqcn as class_fqcn,
|
|
90
99
|
m.is_constructor as is_constructor,
|
|
91
|
-
m.is_test as is_test
|
|
100
|
+
m.is_test as is_test,
|
|
101
|
+
f.path as file_path
|
|
92
102
|
LIMIT $limit
|
|
93
103
|
""",
|
|
94
|
-
{"limit": int(limit *
|
|
104
|
+
{"limit": int(limit * 5), "proj": project},
|
|
95
105
|
)
|
|
96
106
|
else:
|
|
97
107
|
candidates = store.query_records(
|
|
98
108
|
"""
|
|
99
|
-
MATCH (m:Method), (c:Class)
|
|
100
|
-
WHERE m.class_id = c.id
|
|
109
|
+
MATCH (m:Method), (c:Class), (f:File)
|
|
110
|
+
WHERE m.class_id = c.id AND c.file_id = f.id
|
|
101
111
|
AND NOT EXISTS { MATCH (:Method)-[:CALLS]->(m) }
|
|
102
112
|
RETURN m.id as method_id,
|
|
103
113
|
m.name as name,
|
|
@@ -105,15 +115,17 @@ def detect_dead_code(store, limit: int = 200, project: str | None = None) -> lis
|
|
|
105
115
|
m.modifiers as modifiers,
|
|
106
116
|
c.fqcn as class_fqcn,
|
|
107
117
|
m.is_constructor as is_constructor,
|
|
108
|
-
m.is_test as is_test
|
|
118
|
+
m.is_test as is_test,
|
|
119
|
+
f.path as file_path
|
|
109
120
|
LIMIT $limit
|
|
110
121
|
""",
|
|
111
|
-
{"limit": int(limit *
|
|
122
|
+
{"limit": int(limit * 5)},
|
|
112
123
|
)
|
|
113
124
|
|
|
114
125
|
if not candidates:
|
|
115
126
|
return []
|
|
116
127
|
|
|
128
|
+
n_candidates = len(candidates)
|
|
117
129
|
exempt: set[str] = set()
|
|
118
130
|
|
|
119
131
|
# Exempt constructors, test methods, and Java main entrypoints.
|
|
@@ -138,22 +150,19 @@ def detect_dead_code(store, limit: int = 200, project: str | None = None) -> lis
|
|
|
138
150
|
if name in {"valueOf", "fromString", "builder"}:
|
|
139
151
|
exempt.add(c["method_id"])
|
|
140
152
|
|
|
141
|
-
# Exempt override
|
|
153
|
+
# Exempt methods that DIRECTLY override another method (precise: only the
|
|
154
|
+
# specific overriding method is exempted, not the entire implementing class).
|
|
155
|
+
# NOTE: we intentionally do NOT use the class-level IMPLEMENTS relation here
|
|
156
|
+
# because that would exempt ALL methods of every class that implements ANY
|
|
157
|
+
# interface — in a typical Spring project that wipes out almost everything
|
|
158
|
+
# and produces 0 dead code results.
|
|
142
159
|
override_methods = store.query_records(
|
|
143
160
|
"""
|
|
144
161
|
MATCH (m:Method)-[:OVERRIDES]->(:Method)
|
|
145
162
|
RETURN DISTINCT m.id as method_id
|
|
146
163
|
"""
|
|
147
164
|
)
|
|
148
|
-
interface_methods = store.query_records(
|
|
149
|
-
"""
|
|
150
|
-
MATCH (c:Class)-[:IMPLEMENTS]->(:Class), (m:Method)
|
|
151
|
-
WHERE m.class_id = c.id
|
|
152
|
-
RETURN DISTINCT m.id as method_id
|
|
153
|
-
"""
|
|
154
|
-
)
|
|
155
165
|
exempt.update(r["method_id"] for r in override_methods)
|
|
156
|
-
exempt.update(r["method_id"] for r in interface_methods)
|
|
157
166
|
|
|
158
167
|
dead = []
|
|
159
168
|
for c in candidates:
|
|
@@ -164,8 +173,30 @@ def detect_dead_code(store, limit: int = 200, project: str | None = None) -> lis
|
|
|
164
173
|
"method_id": c["method_id"],
|
|
165
174
|
"name": c.get("name"),
|
|
166
175
|
"signature": c.get("signature"),
|
|
176
|
+
"class_fqcn": c.get("class_fqcn"),
|
|
177
|
+
"file_path": c.get("file_path"),
|
|
167
178
|
"reason": "no_incoming_calls_after_exemptions",
|
|
168
179
|
}
|
|
169
180
|
)
|
|
170
181
|
|
|
171
|
-
|
|
182
|
+
result = dead[:limit]
|
|
183
|
+
|
|
184
|
+
# Append stats as a sentinel entry so the MCP layer can surface them
|
|
185
|
+
# without changing the return type. Callers should strip entries that
|
|
186
|
+
# have a "_stats" key when iterating over method results.
|
|
187
|
+
result.append({
|
|
188
|
+
"_stats": {
|
|
189
|
+
"candidates_with_no_callers": n_candidates,
|
|
190
|
+
"exempted": len(exempt),
|
|
191
|
+
"dead_returned": len(result),
|
|
192
|
+
"note": (
|
|
193
|
+
"Exemptions cover: constructors, test methods, main(), "
|
|
194
|
+
"toString/hashCode/equals/compareTo, public getters/setters, "
|
|
195
|
+
"methods with DI/framework annotations, and direct method overrides. "
|
|
196
|
+
"The class-level IMPLEMENTS exemption has been removed — only "
|
|
197
|
+
"methods with direct OVERRIDES relations are now exempted."
|
|
198
|
+
),
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
return result
|
|
@@ -2,6 +2,8 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from collections import defaultdict, deque
|
|
4
4
|
|
|
5
|
+
from codespine.analysis.impact import _resolve_method_metadata
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
def _entry_methods(store, project: str | None = None) -> list[str]:
|
|
7
9
|
if project:
|
|
@@ -108,4 +110,24 @@ def trace_execution_flows(store, entry_symbol: str | None = None, max_depth: int
|
|
|
108
110
|
}
|
|
109
111
|
)
|
|
110
112
|
|
|
113
|
+
# ------------------------------------------------------------------ #
|
|
114
|
+
# Enrich every node with human-readable metadata so AI agents don't
|
|
115
|
+
# need a second round-trip to resolve raw method ID hashes.
|
|
116
|
+
# Collect all unique IDs across all flows, resolve in one bulk query.
|
|
117
|
+
# ------------------------------------------------------------------ #
|
|
118
|
+
all_ids = list({node["symbol"] for flow in flows for node in flow["nodes"]})
|
|
119
|
+
meta = _resolve_method_metadata(store, all_ids)
|
|
120
|
+
|
|
121
|
+
for flow in flows:
|
|
122
|
+
entry_m = meta.get(flow["entry"], {})
|
|
123
|
+
flow["entry_name"] = entry_m.get("name")
|
|
124
|
+
flow["entry_fqname"] = entry_m.get("fqname")
|
|
125
|
+
flow["entry_file_path"] = entry_m.get("file_path")
|
|
126
|
+
for node in flow["nodes"]:
|
|
127
|
+
m = meta.get(node["symbol"], {})
|
|
128
|
+
node["name"] = m.get("name")
|
|
129
|
+
node["fqname"] = m.get("fqname")
|
|
130
|
+
node["file_path"] = m.get("file_path")
|
|
131
|
+
node["project_id"] = m.get("project_id")
|
|
132
|
+
|
|
111
133
|
return flows
|
|
@@ -21,6 +21,27 @@ def _resolve_symbol_ids(store, symbol_query: str, project: str | None = None) ->
|
|
|
21
21
|
return [r["id"] for r in recs]
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
def _resolve_method_metadata(store, method_ids: list[str]) -> dict[str, dict]:
|
|
25
|
+
"""Bulk-resolve method IDs to human-readable metadata in a single query.
|
|
26
|
+
|
|
27
|
+
Returns a dict keyed by method ID with fields:
|
|
28
|
+
name, fqname (= m.signature), class_fqcn, file_path, project_id.
|
|
29
|
+
Any ID not found in the graph is silently omitted.
|
|
30
|
+
"""
|
|
31
|
+
if not method_ids:
|
|
32
|
+
return {}
|
|
33
|
+
recs = store.query_records(
|
|
34
|
+
"""
|
|
35
|
+
MATCH (m:Method), (c:Class), (f:File)
|
|
36
|
+
WHERE m.id IN $ids AND m.class_id = c.id AND c.file_id = f.id
|
|
37
|
+
RETURN m.id as id, m.name as name, m.signature as fqname,
|
|
38
|
+
c.fqcn as class_fqcn, f.path as file_path, f.project_id as project_id
|
|
39
|
+
""",
|
|
40
|
+
{"ids": method_ids},
|
|
41
|
+
)
|
|
42
|
+
return {r["id"]: r for r in recs}
|
|
43
|
+
|
|
44
|
+
|
|
24
45
|
def analyze_impact(store, symbol_query: str, max_depth: int = 4, project: str | None = None) -> dict:
|
|
25
46
|
target_symbol_ids = _resolve_symbol_ids(store, symbol_query, project=project)
|
|
26
47
|
if not target_symbol_ids:
|
|
@@ -85,9 +106,45 @@ def analyze_impact(store, symbol_query: str, max_depth: int = 4, project: str |
|
|
|
85
106
|
depth_groups["3+"].append(item)
|
|
86
107
|
queue.append((src, next_depth, path + [src]))
|
|
87
108
|
|
|
109
|
+
# ------------------------------------------------------------------ #
|
|
110
|
+
# Enrich every caller entry with human-readable metadata so AI agents
|
|
111
|
+
# don't need a second round-trip to resolve raw ID hashes.
|
|
112
|
+
# A single bulk query resolves all collected method IDs at once.
|
|
113
|
+
# ------------------------------------------------------------------ #
|
|
114
|
+
all_caller_ids = [item["symbol"] for items in depth_groups.values() for item in items]
|
|
115
|
+
meta = _resolve_method_metadata(store, all_caller_ids)
|
|
116
|
+
|
|
117
|
+
for items in depth_groups.values():
|
|
118
|
+
for item in items:
|
|
119
|
+
m = meta.get(item["symbol"], {})
|
|
120
|
+
item["name"] = m.get("name")
|
|
121
|
+
item["fqname"] = m.get("fqname")
|
|
122
|
+
item["file_path"] = m.get("file_path")
|
|
123
|
+
item["project_id"] = m.get("project_id")
|
|
124
|
+
item["class_fqcn"] = m.get("class_fqcn")
|
|
125
|
+
# Convert the call-path from a list of raw IDs to human-readable names
|
|
126
|
+
# so an agent can read the chain without additional lookups.
|
|
127
|
+
item["path"] = [
|
|
128
|
+
meta.get(pid, {}).get("name") or pid
|
|
129
|
+
for pid in item["path"]
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
# Also enrich the targets_resolved list for context
|
|
133
|
+
target_meta = _resolve_method_metadata(store, target_method_ids)
|
|
134
|
+
resolved_targets = [
|
|
135
|
+
{
|
|
136
|
+
"id": mid,
|
|
137
|
+
"name": target_meta.get(mid, {}).get("name"),
|
|
138
|
+
"fqname": target_meta.get(mid, {}).get("fqname"),
|
|
139
|
+
"file_path": target_meta.get(mid, {}).get("file_path"),
|
|
140
|
+
"class_fqcn": target_meta.get(mid, {}).get("class_fqcn"),
|
|
141
|
+
}
|
|
142
|
+
for mid in target_method_ids
|
|
143
|
+
]
|
|
144
|
+
|
|
88
145
|
return {
|
|
89
146
|
"target": symbol_query,
|
|
90
|
-
"targets_resolved":
|
|
147
|
+
"targets_resolved": resolved_targets,
|
|
91
148
|
"depth_groups": depth_groups,
|
|
92
149
|
"summary": {
|
|
93
150
|
"direct": len(depth_groups["1"]),
|
|
@@ -253,11 +253,31 @@ def build_mcp_server(store, repo_path_provider):
|
|
|
253
253
|
"""
|
|
254
254
|
Detect methods with no incoming calls (after Java-aware exemptions).
|
|
255
255
|
Pass project to scope to a single module.
|
|
256
|
+
|
|
257
|
+
Returns dead_code list, count, and an exemption_stats dict showing
|
|
258
|
+
how many candidates were found and how many were filtered out by the
|
|
259
|
+
exemption rules — useful for validating that the feature is working
|
|
260
|
+
even when the dead list is empty.
|
|
256
261
|
"""
|
|
257
|
-
|
|
258
|
-
if
|
|
262
|
+
raw = detect_dead_code_analysis(store, limit=limit, project=project)
|
|
263
|
+
if raw is None:
|
|
259
264
|
return _no_symbols_response()
|
|
260
|
-
|
|
265
|
+
|
|
266
|
+
# Separate the sentinel stats entry appended by the analysis function.
|
|
267
|
+
stats: dict = {}
|
|
268
|
+
dead = []
|
|
269
|
+
for entry in raw:
|
|
270
|
+
if "_stats" in entry:
|
|
271
|
+
stats = entry["_stats"]
|
|
272
|
+
else:
|
|
273
|
+
dead.append(entry)
|
|
274
|
+
|
|
275
|
+
return {
|
|
276
|
+
"available": True,
|
|
277
|
+
"dead_code": dead,
|
|
278
|
+
"count": len(dead),
|
|
279
|
+
"exemption_stats": stats,
|
|
280
|
+
}
|
|
261
281
|
|
|
262
282
|
@mcp.tool()
|
|
263
283
|
def trace_execution_flows(entry_symbol: str | None = None, max_depth: int = 6, project: str | None = None):
|
|
@@ -273,7 +293,10 @@ def build_mcp_server(store, repo_path_provider):
|
|
|
273
293
|
@mcp.tool()
|
|
274
294
|
def get_symbol_community(symbol: str):
|
|
275
295
|
"""Return the architectural community cluster a symbol belongs to."""
|
|
276
|
-
detect_communities(
|
|
296
|
+
# NOTE: do NOT call detect_communities() here — the MCP server opens the
|
|
297
|
+
# graph DB read-only, so any write attempt raises "Cannot execute write
|
|
298
|
+
# operations in a read-only database!". Communities are computed once
|
|
299
|
+
# during 'codespine analyse --deep' and persisted; we just read them.
|
|
277
300
|
result = symbol_community(store, symbol)
|
|
278
301
|
if not result.get("matches"):
|
|
279
302
|
return {"available": False, "note": "No community data yet. Run 'codespine analyse --deep'."}
|
|
@@ -507,7 +530,7 @@ def build_mcp_server(store, repo_path_provider):
|
|
|
507
530
|
MATCH (c:Class), (f:File)
|
|
508
531
|
WHERE c.file_id = f.id {project_clause}
|
|
509
532
|
RETURN c.package as package, f.project_id as project_id, count(c) as class_count
|
|
510
|
-
ORDER BY
|
|
533
|
+
ORDER BY project_id, package
|
|
511
534
|
LIMIT $lim
|
|
512
535
|
""",
|
|
513
536
|
params,
|
|
@@ -586,11 +609,24 @@ def build_mcp_server(store, repo_path_provider):
|
|
|
586
609
|
}
|
|
587
610
|
|
|
588
611
|
@mcp.tool()
|
|
589
|
-
def compare_branches(base_ref: str, head_ref: str):
|
|
590
|
-
"""
|
|
591
|
-
|
|
612
|
+
def compare_branches(base_ref: str, head_ref: str, project: str | None = None):
|
|
613
|
+
"""
|
|
614
|
+
Symbol-level diff between two git refs (branches, tags, commits).
|
|
615
|
+
Pass project=<project_id> so the tool can resolve the correct git
|
|
616
|
+
repository root from the indexed project path rather than relying on
|
|
617
|
+
the MCP server's working directory (which may point to the graph DB
|
|
618
|
+
location, not the source tree).
|
|
619
|
+
"""
|
|
620
|
+
repo = _resolve_repo_path(store, project, repo_path_provider)
|
|
592
621
|
if not _git_available(repo):
|
|
593
|
-
return {
|
|
622
|
+
return {
|
|
623
|
+
"available": False,
|
|
624
|
+
"note": (
|
|
625
|
+
"Not a git repository (or git not installed). "
|
|
626
|
+
"Pass project=<project_id> so the tool can resolve the repo "
|
|
627
|
+
"from the indexed project path. Use list_projects() to see available IDs."
|
|
628
|
+
),
|
|
629
|
+
}
|
|
594
630
|
result = compare_branches_analysis(repo, base_ref, head_ref)
|
|
595
631
|
return {"available": True, **result}
|
|
596
632
|
|
|
@@ -978,6 +1014,7 @@ def build_mcp_server(store, repo_path_provider):
|
|
|
978
1014
|
@mcp.tool()
|
|
979
1015
|
def run_cypher(query: str):
|
|
980
1016
|
"""Run a raw Cypher query against the graph. For advanced exploration."""
|
|
981
|
-
|
|
1017
|
+
records = store.query_records(query)
|
|
1018
|
+
return {"available": True, "records": records, "count": len(records)}
|
|
982
1019
|
|
|
983
1020
|
return mcp
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from codespine.search.bm25 import rank_bm25
|
|
4
4
|
from codespine.search.fuzzy import rank_fuzzy
|
|
5
5
|
from codespine.search.rrf import reciprocal_rank_fusion
|
|
6
|
-
from codespine.search.vector import rank_semantic
|
|
6
|
+
from codespine.search.vector import _load_model, rank_semantic
|
|
7
7
|
|
|
8
8
|
_LOW_CONFIDENCE_THRESHOLD = 0.05
|
|
9
9
|
|
|
@@ -95,14 +95,27 @@ def hybrid_search(store, query: str, k: int = 20, project: str | None = None) ->
|
|
|
95
95
|
item["context"] = ctx
|
|
96
96
|
|
|
97
97
|
# Warn when all scores are near zero — the results are likely noise.
|
|
98
|
+
# The threshold 0.05 is calibrated for embedding mode. Without sentence-
|
|
99
|
+
# transformers the hash-fallback vector and BM25/fuzzy signals produce lower
|
|
100
|
+
# RRF scores, so the warning fires on nearly every query. Make the note
|
|
101
|
+
# context-aware so the agent understands whether this is a calibration issue
|
|
102
|
+
# or a genuine low-relevance result.
|
|
98
103
|
if top_k and top_k[0]["score"] < _LOW_CONFIDENCE_THRESHOLD:
|
|
104
|
+
has_model = _load_model() is not None
|
|
99
105
|
for item in top_k:
|
|
100
106
|
item["low_confidence"] = True
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
if has_model:
|
|
108
|
+
note = (
|
|
103
109
|
"Low confidence results — all scores below threshold. "
|
|
104
110
|
"If searching for an exact class or method name, use find_symbol instead."
|
|
105
111
|
)
|
|
106
|
-
|
|
112
|
+
else:
|
|
113
|
+
note = (
|
|
114
|
+
"Low confidence results — scores are lower in BM25/fuzzy-only mode "
|
|
115
|
+
"(no embedding model detected). "
|
|
116
|
+
"This is expected without 'codespine[ml]' installed; results may still be correct. "
|
|
117
|
+
"For exact name matches, use find_symbol instead."
|
|
118
|
+
)
|
|
119
|
+
top_k.append({"note": note})
|
|
107
120
|
|
|
108
121
|
return top_k
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codespine
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
4
4
|
Summary: Local Java code intelligence indexer backed by a graph database
|
|
5
5
|
Author: CodeSpine contributors
|
|
6
6
|
License: MIT License
|
|
@@ -46,7 +46,7 @@ Requires-Dist: click
|
|
|
46
46
|
Requires-Dist: kuzu
|
|
47
47
|
Requires-Dist: tree-sitter
|
|
48
48
|
Requires-Dist: tree-sitter-java
|
|
49
|
-
Requires-Dist: fastmcp
|
|
49
|
+
Requires-Dist: fastmcp>=2.3.0
|
|
50
50
|
Requires-Dist: psutil
|
|
51
51
|
Requires-Dist: watchfiles
|
|
52
52
|
Provides-Extra: ml
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "codespine"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.3"
|
|
8
8
|
description = "Local Java code intelligence indexer backed by a graph database"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -30,7 +30,7 @@ dependencies = [
|
|
|
30
30
|
"kuzu",
|
|
31
31
|
"tree-sitter",
|
|
32
32
|
"tree-sitter-java",
|
|
33
|
-
"fastmcp",
|
|
33
|
+
"fastmcp>=2.3.0",
|
|
34
34
|
"psutil",
|
|
35
35
|
"watchfiles"
|
|
36
36
|
]
|
|
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
|