codespine 0.6.3__tar.gz → 0.7.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 (60) hide show
  1. {codespine-0.6.3 → codespine-0.7.1}/PKG-INFO +125 -36
  2. {codespine-0.6.3 → codespine-0.7.1}/README.md +125 -36
  3. {codespine-0.6.3 → codespine-0.7.1}/codespine/__init__.py +1 -1
  4. {codespine-0.6.3 → codespine-0.7.1}/codespine/cli.py +12 -0
  5. codespine-0.7.1/codespine/guide.py +169 -0
  6. {codespine-0.6.3 → codespine-0.7.1}/codespine/mcp/server.py +16 -0
  7. {codespine-0.6.3 → codespine-0.7.1}/codespine.egg-info/PKG-INFO +125 -36
  8. {codespine-0.6.3 → codespine-0.7.1}/codespine.egg-info/SOURCES.txt +1 -0
  9. {codespine-0.6.3 → codespine-0.7.1}/pyproject.toml +1 -1
  10. {codespine-0.6.3 → codespine-0.7.1}/LICENSE +0 -0
  11. {codespine-0.6.3 → codespine-0.7.1}/codespine/analysis/__init__.py +0 -0
  12. {codespine-0.6.3 → codespine-0.7.1}/codespine/analysis/community.py +0 -0
  13. {codespine-0.6.3 → codespine-0.7.1}/codespine/analysis/context.py +0 -0
  14. {codespine-0.6.3 → codespine-0.7.1}/codespine/analysis/coupling.py +0 -0
  15. {codespine-0.6.3 → codespine-0.7.1}/codespine/analysis/crossmodule.py +0 -0
  16. {codespine-0.6.3 → codespine-0.7.1}/codespine/analysis/deadcode.py +0 -0
  17. {codespine-0.6.3 → codespine-0.7.1}/codespine/analysis/flow.py +0 -0
  18. {codespine-0.6.3 → codespine-0.7.1}/codespine/analysis/impact.py +0 -0
  19. {codespine-0.6.3 → codespine-0.7.1}/codespine/config.py +0 -0
  20. {codespine-0.6.3 → codespine-0.7.1}/codespine/db/__init__.py +0 -0
  21. {codespine-0.6.3 → codespine-0.7.1}/codespine/db/schema.py +0 -0
  22. {codespine-0.6.3 → codespine-0.7.1}/codespine/db/store.py +0 -0
  23. {codespine-0.6.3 → codespine-0.7.1}/codespine/diff/__init__.py +0 -0
  24. {codespine-0.6.3 → codespine-0.7.1}/codespine/diff/branch_diff.py +0 -0
  25. {codespine-0.6.3 → codespine-0.7.1}/codespine/indexer/__init__.py +0 -0
  26. {codespine-0.6.3 → codespine-0.7.1}/codespine/indexer/call_resolver.py +0 -0
  27. {codespine-0.6.3 → codespine-0.7.1}/codespine/indexer/engine.py +0 -0
  28. {codespine-0.6.3 → codespine-0.7.1}/codespine/indexer/java_parser.py +0 -0
  29. {codespine-0.6.3 → codespine-0.7.1}/codespine/indexer/symbol_builder.py +0 -0
  30. {codespine-0.6.3 → codespine-0.7.1}/codespine/mcp/__init__.py +0 -0
  31. {codespine-0.6.3 → codespine-0.7.1}/codespine/noise/__init__.py +0 -0
  32. {codespine-0.6.3 → codespine-0.7.1}/codespine/noise/blocklist.py +0 -0
  33. {codespine-0.6.3 → codespine-0.7.1}/codespine/overlay/__init__.py +0 -0
  34. {codespine-0.6.3 → codespine-0.7.1}/codespine/overlay/git_state.py +0 -0
  35. {codespine-0.6.3 → codespine-0.7.1}/codespine/overlay/merge.py +0 -0
  36. {codespine-0.6.3 → codespine-0.7.1}/codespine/overlay/store.py +0 -0
  37. {codespine-0.6.3 → codespine-0.7.1}/codespine/search/__init__.py +0 -0
  38. {codespine-0.6.3 → codespine-0.7.1}/codespine/search/bm25.py +0 -0
  39. {codespine-0.6.3 → codespine-0.7.1}/codespine/search/fuzzy.py +0 -0
  40. {codespine-0.6.3 → codespine-0.7.1}/codespine/search/hybrid.py +0 -0
  41. {codespine-0.6.3 → codespine-0.7.1}/codespine/search/rrf.py +0 -0
  42. {codespine-0.6.3 → codespine-0.7.1}/codespine/search/vector.py +0 -0
  43. {codespine-0.6.3 → codespine-0.7.1}/codespine/watch/__init__.py +0 -0
  44. {codespine-0.6.3 → codespine-0.7.1}/codespine/watch/watcher.py +0 -0
  45. {codespine-0.6.3 → codespine-0.7.1}/codespine.egg-info/dependency_links.txt +0 -0
  46. {codespine-0.6.3 → codespine-0.7.1}/codespine.egg-info/entry_points.txt +0 -0
  47. {codespine-0.6.3 → codespine-0.7.1}/codespine.egg-info/requires.txt +0 -0
  48. {codespine-0.6.3 → codespine-0.7.1}/codespine.egg-info/top_level.txt +0 -0
  49. {codespine-0.6.3 → codespine-0.7.1}/gindex.py +0 -0
  50. {codespine-0.6.3 → codespine-0.7.1}/setup.cfg +0 -0
  51. {codespine-0.6.3 → codespine-0.7.1}/tests/test_branch_diff_normalize.py +0 -0
  52. {codespine-0.6.3 → codespine-0.7.1}/tests/test_call_resolver.py +0 -0
  53. {codespine-0.6.3 → codespine-0.7.1}/tests/test_community_detection.py +0 -0
  54. {codespine-0.6.3 → codespine-0.7.1}/tests/test_deadcode.py +0 -0
  55. {codespine-0.6.3 → codespine-0.7.1}/tests/test_index_and_hybrid.py +0 -0
  56. {codespine-0.6.3 → codespine-0.7.1}/tests/test_java_parser.py +0 -0
  57. {codespine-0.6.3 → codespine-0.7.1}/tests/test_multimodule_index.py +0 -0
  58. {codespine-0.6.3 → codespine-0.7.1}/tests/test_overlay.py +0 -0
  59. {codespine-0.6.3 → codespine-0.7.1}/tests/test_search_ranking.py +0 -0
  60. {codespine-0.6.3 → codespine-0.7.1}/tests/test_store_recovery.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codespine
3
- Version: 0.6.3
3
+ Version: 0.7.1
4
4
  Summary: Local Java code intelligence indexer backed by a graph database
5
5
  Author: CodeSpine contributors
6
6
  License: MIT License
@@ -223,45 +223,134 @@ If the client launches the wrong Python environment, use the absolute binary pat
223
223
  }
224
224
  ```
225
225
 
226
- Common MCP tools:
226
+ ### Agent Onboarding
227
227
 
228
- - `search_hybrid(query, k, project)`
229
- - `find_symbol(name, kind, project, limit)`
230
- - `get_symbol_context(query, max_depth, project)`
231
- - `get_impact(symbol, max_depth, project)`
232
- - `detect_dead_code(limit, project, strict)`
233
- - `trace_execution_flows(entry_symbol, max_depth, project)`
234
- - `get_symbol_community(symbol)`
235
- - `get_change_coupling(months, min_strength, min_cochanges, project)`
236
- - `compare_branches(base_ref, head_ref)`
237
- - `get_codebase_stats()`
228
+ When an agent connects to CodeSpine for the first time, it should call:
238
229
 
239
- ## CLI
230
+ 1. **`guide()`** — returns a structured catalog of every tool, organized by category, with recommended workflows and tips.
231
+ 2. **`get_capabilities()`** — returns what is indexed right now, which features are ready, and what's missing.
240
232
 
241
- Core commands:
233
+ The same information is available from the CLI:
242
234
 
243
235
  ```bash
244
- codespine analyse <path>
245
- codespine analyse <path> --full
246
- codespine analyse <path> --deep
247
- codespine analyse <path> --embed
248
- codespine watch --path .
249
- codespine watch --path . --overlay-debounce-ms 1500
250
- codespine search "query"
251
- codespine context "symbol"
252
- codespine impact "symbol"
253
- codespine deadcode
254
- codespine flow
255
- codespine community
256
- codespine coupling
257
- codespine diff main..feature
258
- codespine stats
259
- codespine list
260
- codespine overlay-status
261
- codespine overlay-promote
262
- codespine overlay-clear
263
- codespine clear-project <project_id>
264
- codespine clear-index
236
+ codespine guide # tool catalog, workflows, tips
237
+ codespine guide --json # structured JSON for tooling
238
+ ```
239
+
240
+ ### MCP Tools
241
+
242
+ **Discovery & Status**
243
+
244
+ | Tool | Description |
245
+ |------|-------------|
246
+ | `guide()` | Tool catalog, workflows, and tips. Call first if new to CodeSpine. |
247
+ | `get_capabilities()` | What is indexed and which features are available right now. |
248
+ | `list_projects()` | All indexed projects with symbol/file counts. |
249
+ | `get_codebase_stats()` | Per-project stats: files, classes, methods, call edges, embeddings. |
250
+ | `list_packages(project)` | Java packages in the index. |
251
+ | `ping()` | Verify the MCP server is alive. |
252
+
253
+ **Search & Lookup**
254
+
255
+ | Tool | Description |
256
+ |------|-------------|
257
+ | `search_hybrid(query, k, project)` | Ranked symbol search (BM25 + vector + fuzzy via RRF). |
258
+ | `find_symbol(name, kind, project, limit)` | Exact/prefix name lookup across all projects. |
259
+ | `get_symbol_context(query, max_depth, project)` | One-shot deep context: search + impact + community + flows. |
260
+ | `get_neighborhood(symbol, project)` | Callers, callees, siblings, and override/implements. |
261
+
262
+ **Analysis**
263
+
264
+ | Tool | Description |
265
+ |------|-------------|
266
+ | `get_impact(symbol, max_depth, project)` | Caller-tree impact analysis with confidence scores. |
267
+ | `detect_dead_code(limit, project, strict)` | Methods with no callers (Java-aware exemptions). |
268
+ | `trace_execution_flows(entry_symbol, max_depth, project)` | Execution paths from entry points. |
269
+ | `get_symbol_community(symbol)` | Architectural community cluster for a symbol. |
270
+ | `get_change_coupling(months, min_strength, min_cochanges)` | Files that historically change together. |
271
+
272
+ **Git**
273
+
274
+ | Tool | Description |
275
+ |------|-------------|
276
+ | `git_log(file_path, limit, project)` | Recent git commits. |
277
+ | `git_diff(ref, file_path, project)` | Git diff (working tree vs ref, or between refs). |
278
+ | `compare_branches(base_ref, head_ref, project)` | Symbol-level diff between two git refs. |
279
+
280
+ **Indexing & Watch**
281
+
282
+ | Tool | Description |
283
+ |------|-------------|
284
+ | `analyse_project(path, full, deep, embed)` | Index a Java project (background job). |
285
+ | `get_analyse_status()` | Poll analysis progress. |
286
+ | `reindex_file(file_path, project)` | Re-index a single `.java` file (<1 s). |
287
+ | `start_watch(path)` | Watch for `.java` changes and update overlay in real time. |
288
+ | `stop_watch()` | Stop the background watch process. |
289
+ | `get_watch_status()` | Watch mode status: running, path, uptime. |
290
+
291
+ **Overlay**
292
+
293
+ | Tool | Description |
294
+ |------|-------------|
295
+ | `get_overlay_status(project)` | Uncommitted overlay state by project/module. |
296
+ | `promote_overlay(project)` | Commit dirty overlay into the base index. |
297
+ | `clear_overlay(project)` | Discard dirty overlay without changing the base. |
298
+
299
+ **Reset**
300
+
301
+ | Tool | Description |
302
+ |------|-------------|
303
+ | `reset_project(project_id)` | Remove all data for one project. |
304
+ | `reset_index()` | Remove ALL data across every project. |
305
+ | `force_reset_index()` | Emergency: delete data files when normal reset fails. |
306
+
307
+ **Advanced**
308
+
309
+ | Tool | Description |
310
+ |------|-------------|
311
+ | `run_cypher(query)` | Run a raw Cypher query against the graph DB. |
312
+
313
+ ## CLI
314
+
315
+ ```bash
316
+ # Indexing
317
+ codespine analyse <path> # incremental index
318
+ codespine analyse <path> --full # full re-index
319
+ codespine analyse <path> --deep # + communities, flows, dead code, coupling
320
+ codespine analyse <path> --embed # + vector embeddings
321
+ codespine watch --path . # live re-index on file changes
322
+
323
+ # Search & Analysis
324
+ codespine search "query" # hybrid search
325
+ codespine context "symbol" # one-shot deep context
326
+ codespine impact "symbol" # caller-tree impact
327
+ codespine deadcode # dead code candidates
328
+ codespine flow # execution flows
329
+ codespine community # architectural clusters
330
+ codespine coupling # git change coupling
331
+ codespine diff main..feature # symbol-level branch diff
332
+
333
+ # Status & Info
334
+ codespine stats # per-project statistics
335
+ codespine list # indexed projects
336
+ codespine status # service and database status
337
+ codespine guide # tool catalog and workflows
338
+
339
+ # Overlay
340
+ codespine overlay-status # dirty overlay state
341
+ codespine overlay-promote # commit overlay to base
342
+ codespine overlay-clear # discard overlay
343
+
344
+ # Server Management
345
+ codespine start # launch background MCP server
346
+ codespine stop # stop background MCP server
347
+ codespine mcp # foreground MCP (stdio, for IDE)
348
+
349
+ # Cleanup & Reset
350
+ codespine clear-project <project_id> # remove one project
351
+ codespine clear-index # remove all indexed data
352
+ codespine force-reset # emergency: delete all data files
353
+ codespine setup # check dependencies
265
354
  ```
266
355
 
267
356
  `analyse` defaults to incremental mode. Repeat runs are designed to be fast when files have not changed.
@@ -323,8 +412,8 @@ Running `codespine analyse --deep --embed` on one project while querying a diffe
323
412
  - `codespine start` launches a background MCP server. Most IDE MCP clients should use `codespine mcp` instead and manage the process themselves.
324
413
  - `codespine watch` updates the dirty overlay first; it does not rewrite the committed base index on every save.
325
414
  - `codespine clear-index` rebuilds the local index database from scratch. This also removes the read replica; run `analyse` again to republish it.
415
+ - `codespine force-reset` is the nuclear option — it deletes all data files without going through the DB engine. Use it when `clear-index` fails due to DB corruption.
326
416
  - For large Spring or JPA-heavy repos, dead-code results should still be reviewed before deletion. The tool is conservative, not authoritative.
327
- - The first run after upgrading to v0.5.7 will not have a read replica yet. Run `codespine analyse` once to create it.
328
417
 
329
418
  ## Project Docs
330
419
 
@@ -159,45 +159,134 @@ If the client launches the wrong Python environment, use the absolute binary pat
159
159
  }
160
160
  ```
161
161
 
162
- Common MCP tools:
163
-
164
- - `search_hybrid(query, k, project)`
165
- - `find_symbol(name, kind, project, limit)`
166
- - `get_symbol_context(query, max_depth, project)`
167
- - `get_impact(symbol, max_depth, project)`
168
- - `detect_dead_code(limit, project, strict)`
169
- - `trace_execution_flows(entry_symbol, max_depth, project)`
170
- - `get_symbol_community(symbol)`
171
- - `get_change_coupling(months, min_strength, min_cochanges, project)`
172
- - `compare_branches(base_ref, head_ref)`
173
- - `get_codebase_stats()`
162
+ ### Agent Onboarding
174
163
 
175
- ## CLI
164
+ When an agent connects to CodeSpine for the first time, it should call:
165
+
166
+ 1. **`guide()`** — returns a structured catalog of every tool, organized by category, with recommended workflows and tips.
167
+ 2. **`get_capabilities()`** — returns what is indexed right now, which features are ready, and what's missing.
176
168
 
177
- Core commands:
169
+ The same information is available from the CLI:
178
170
 
179
171
  ```bash
180
- codespine analyse <path>
181
- codespine analyse <path> --full
182
- codespine analyse <path> --deep
183
- codespine analyse <path> --embed
184
- codespine watch --path .
185
- codespine watch --path . --overlay-debounce-ms 1500
186
- codespine search "query"
187
- codespine context "symbol"
188
- codespine impact "symbol"
189
- codespine deadcode
190
- codespine flow
191
- codespine community
192
- codespine coupling
193
- codespine diff main..feature
194
- codespine stats
195
- codespine list
196
- codespine overlay-status
197
- codespine overlay-promote
198
- codespine overlay-clear
199
- codespine clear-project <project_id>
200
- codespine clear-index
172
+ codespine guide # tool catalog, workflows, tips
173
+ codespine guide --json # structured JSON for tooling
174
+ ```
175
+
176
+ ### MCP Tools
177
+
178
+ **Discovery & Status**
179
+
180
+ | Tool | Description |
181
+ |------|-------------|
182
+ | `guide()` | Tool catalog, workflows, and tips. Call first if new to CodeSpine. |
183
+ | `get_capabilities()` | What is indexed and which features are available right now. |
184
+ | `list_projects()` | All indexed projects with symbol/file counts. |
185
+ | `get_codebase_stats()` | Per-project stats: files, classes, methods, call edges, embeddings. |
186
+ | `list_packages(project)` | Java packages in the index. |
187
+ | `ping()` | Verify the MCP server is alive. |
188
+
189
+ **Search & Lookup**
190
+
191
+ | Tool | Description |
192
+ |------|-------------|
193
+ | `search_hybrid(query, k, project)` | Ranked symbol search (BM25 + vector + fuzzy via RRF). |
194
+ | `find_symbol(name, kind, project, limit)` | Exact/prefix name lookup across all projects. |
195
+ | `get_symbol_context(query, max_depth, project)` | One-shot deep context: search + impact + community + flows. |
196
+ | `get_neighborhood(symbol, project)` | Callers, callees, siblings, and override/implements. |
197
+
198
+ **Analysis**
199
+
200
+ | Tool | Description |
201
+ |------|-------------|
202
+ | `get_impact(symbol, max_depth, project)` | Caller-tree impact analysis with confidence scores. |
203
+ | `detect_dead_code(limit, project, strict)` | Methods with no callers (Java-aware exemptions). |
204
+ | `trace_execution_flows(entry_symbol, max_depth, project)` | Execution paths from entry points. |
205
+ | `get_symbol_community(symbol)` | Architectural community cluster for a symbol. |
206
+ | `get_change_coupling(months, min_strength, min_cochanges)` | Files that historically change together. |
207
+
208
+ **Git**
209
+
210
+ | Tool | Description |
211
+ |------|-------------|
212
+ | `git_log(file_path, limit, project)` | Recent git commits. |
213
+ | `git_diff(ref, file_path, project)` | Git diff (working tree vs ref, or between refs). |
214
+ | `compare_branches(base_ref, head_ref, project)` | Symbol-level diff between two git refs. |
215
+
216
+ **Indexing & Watch**
217
+
218
+ | Tool | Description |
219
+ |------|-------------|
220
+ | `analyse_project(path, full, deep, embed)` | Index a Java project (background job). |
221
+ | `get_analyse_status()` | Poll analysis progress. |
222
+ | `reindex_file(file_path, project)` | Re-index a single `.java` file (<1 s). |
223
+ | `start_watch(path)` | Watch for `.java` changes and update overlay in real time. |
224
+ | `stop_watch()` | Stop the background watch process. |
225
+ | `get_watch_status()` | Watch mode status: running, path, uptime. |
226
+
227
+ **Overlay**
228
+
229
+ | Tool | Description |
230
+ |------|-------------|
231
+ | `get_overlay_status(project)` | Uncommitted overlay state by project/module. |
232
+ | `promote_overlay(project)` | Commit dirty overlay into the base index. |
233
+ | `clear_overlay(project)` | Discard dirty overlay without changing the base. |
234
+
235
+ **Reset**
236
+
237
+ | Tool | Description |
238
+ |------|-------------|
239
+ | `reset_project(project_id)` | Remove all data for one project. |
240
+ | `reset_index()` | Remove ALL data across every project. |
241
+ | `force_reset_index()` | Emergency: delete data files when normal reset fails. |
242
+
243
+ **Advanced**
244
+
245
+ | Tool | Description |
246
+ |------|-------------|
247
+ | `run_cypher(query)` | Run a raw Cypher query against the graph DB. |
248
+
249
+ ## CLI
250
+
251
+ ```bash
252
+ # Indexing
253
+ codespine analyse <path> # incremental index
254
+ codespine analyse <path> --full # full re-index
255
+ codespine analyse <path> --deep # + communities, flows, dead code, coupling
256
+ codespine analyse <path> --embed # + vector embeddings
257
+ codespine watch --path . # live re-index on file changes
258
+
259
+ # Search & Analysis
260
+ codespine search "query" # hybrid search
261
+ codespine context "symbol" # one-shot deep context
262
+ codespine impact "symbol" # caller-tree impact
263
+ codespine deadcode # dead code candidates
264
+ codespine flow # execution flows
265
+ codespine community # architectural clusters
266
+ codespine coupling # git change coupling
267
+ codespine diff main..feature # symbol-level branch diff
268
+
269
+ # Status & Info
270
+ codespine stats # per-project statistics
271
+ codespine list # indexed projects
272
+ codespine status # service and database status
273
+ codespine guide # tool catalog and workflows
274
+
275
+ # Overlay
276
+ codespine overlay-status # dirty overlay state
277
+ codespine overlay-promote # commit overlay to base
278
+ codespine overlay-clear # discard overlay
279
+
280
+ # Server Management
281
+ codespine start # launch background MCP server
282
+ codespine stop # stop background MCP server
283
+ codespine mcp # foreground MCP (stdio, for IDE)
284
+
285
+ # Cleanup & Reset
286
+ codespine clear-project <project_id> # remove one project
287
+ codespine clear-index # remove all indexed data
288
+ codespine force-reset # emergency: delete all data files
289
+ codespine setup # check dependencies
201
290
  ```
202
291
 
203
292
  `analyse` defaults to incremental mode. Repeat runs are designed to be fast when files have not changed.
@@ -259,8 +348,8 @@ Running `codespine analyse --deep --embed` on one project while querying a diffe
259
348
  - `codespine start` launches a background MCP server. Most IDE MCP clients should use `codespine mcp` instead and manage the process themselves.
260
349
  - `codespine watch` updates the dirty overlay first; it does not rewrite the committed base index on every save.
261
350
  - `codespine clear-index` rebuilds the local index database from scratch. This also removes the read replica; run `analyse` again to republish it.
351
+ - `codespine force-reset` is the nuclear option — it deletes all data files without going through the DB engine. Use it when `clear-index` fails due to DB corruption.
262
352
  - For large Spring or JPA-heavy repos, dead-code results should still be reviewed before deletion. The tool is conservative, not authoritative.
263
- - The first run after upgrading to v0.5.7 will not have a read replica yet. Run `codespine analyse` once to create it.
264
353
 
265
354
  ## Project Docs
266
355
 
@@ -1,4 +1,4 @@
1
1
  """CodeSpine package."""
2
2
 
3
3
  __all__ = ["__version__"]
4
- __version__ = "0.6.3"
4
+ __version__ = "0.7.1"
@@ -852,6 +852,18 @@ def force_reset_cmd(force: bool) -> None:
852
852
  click.secho("Nothing to remove — already clean.", fg="yellow")
853
853
 
854
854
 
855
+ @main.command()
856
+ @click.option("--json", "as_json", is_flag=True, help="Output as JSON.")
857
+ def guide(as_json: bool) -> None:
858
+ """Show what CodeSpine can do: tool catalog, workflows, and tips."""
859
+ from codespine.guide import GUIDE_SECTIONS, format_guide_terminal
860
+
861
+ if as_json:
862
+ _echo_json({"sections": GUIDE_SECTIONS}, as_json=True)
863
+ else:
864
+ click.echo(format_guide_terminal())
865
+
866
+
855
867
  @main.command()
856
868
  def setup() -> None:
857
869
  """Print local setup checks and next steps."""
@@ -0,0 +1,169 @@
1
+ """CodeSpine guide – single source of truth for MCP + CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from codespine import __version__
6
+
7
+ GUIDE_SECTIONS: list[dict] = [
8
+ {
9
+ "id": "overview",
10
+ "title": "What is CodeSpine?",
11
+ "body": (
12
+ "CodeSpine is a Java code-intelligence engine. It parses Java source "
13
+ "into a graph database (Kuzu) and exposes hybrid search, impact analysis, "
14
+ "dead-code detection, execution-flow tracing, community detection, and "
15
+ "git change-coupling -- all via MCP tools or CLI commands.\n"
16
+ "Language: Java. Layouts: single-module, multi-module (Maven/Gradle), workspaces."
17
+ ),
18
+ },
19
+ {
20
+ "id": "quickstart",
21
+ "title": "Recommended First Steps",
22
+ "body": (
23
+ "1. Call get_capabilities() to see what is indexed and which features are ready.\n"
24
+ "2. If nothing is indexed: call analyse_project(path) with the Java project root.\n"
25
+ " Poll with get_analyse_status() until it finishes.\n"
26
+ "3. Once indexed: use search_hybrid(query) to find symbols, then drill in with\n"
27
+ " get_impact(), get_symbol_context(), or get_neighborhood().\n"
28
+ "4. For active development: call start_watch(path) to keep the index fresh\n"
29
+ " as files change on disk."
30
+ ),
31
+ },
32
+ # ── Tool catalog ──────────────────────────────────────────────
33
+ {
34
+ "id": "tools_discovery",
35
+ "title": "Discovery & Status",
36
+ "tools": [
37
+ {"name": "get_capabilities", "one_liner": "What is indexed and which features are available right now. Call this first."},
38
+ {"name": "list_projects", "one_liner": "All indexed projects with symbol/file counts."},
39
+ {"name": "get_codebase_stats", "one_liner": "Per-project stats: files, classes, methods, call edges, embeddings."},
40
+ {"name": "list_packages", "one_liner": "Java packages in the index (optional project= filter)."},
41
+ {"name": "ping", "one_liner": "Verify the MCP server is alive."},
42
+ ],
43
+ },
44
+ {
45
+ "id": "tools_search",
46
+ "title": "Search & Lookup",
47
+ "tools": [
48
+ {"name": "search_hybrid", "one_liner": "Ranked symbol search (BM25 + vector + fuzzy via RRF). Start here."},
49
+ {"name": "find_symbol", "one_liner": "Exact/prefix name lookup. Use to resolve ambiguity or list overloads."},
50
+ {"name": "get_symbol_context", "one_liner": "One-shot deep context: search + impact + community + flows in one call."},
51
+ {"name": "get_neighborhood", "one_liner": "Callers, callees, siblings, and override/implements for a symbol."},
52
+ ],
53
+ },
54
+ {
55
+ "id": "tools_analysis",
56
+ "title": "Analysis",
57
+ "body": "Some analyses require 'analyse_project(path, deep=True)' to populate data.",
58
+ "tools": [
59
+ {"name": "get_impact", "one_liner": "Caller-tree impact analysis grouped by depth with confidence scores."},
60
+ {"name": "detect_dead_code", "one_liner": "Methods with no callers (Java-aware exemptions). strict=True for thorough audit."},
61
+ {"name": "trace_execution_flows", "one_liner": "Execution paths from entry points (main methods, tests, controllers)."},
62
+ {"name": "get_symbol_community", "one_liner": "Architectural community cluster a symbol belongs to."},
63
+ {"name": "get_change_coupling", "one_liner": "Files that historically change together (git co-change analysis)."},
64
+ ],
65
+ },
66
+ {
67
+ "id": "tools_git",
68
+ "title": "Git Integration",
69
+ "tools": [
70
+ {"name": "git_log", "one_liner": "Recent git commits for a project or a specific file."},
71
+ {"name": "git_diff", "one_liner": "Git diff (working tree vs ref, or between two refs)."},
72
+ {"name": "compare_branches", "one_liner": "Symbol-level diff between two git refs (branches/tags/commits)."},
73
+ ],
74
+ },
75
+ {
76
+ "id": "tools_indexing",
77
+ "title": "Indexing & Watch",
78
+ "tools": [
79
+ {"name": "analyse_project", "one_liner": "Index a Java project (background). Poll get_analyse_status() for progress."},
80
+ {"name": "get_analyse_status", "one_liner": "Status of current/recent background analysis job."},
81
+ {"name": "reindex_file", "one_liner": "Re-index a single .java file via overlay (<1 s)."},
82
+ {"name": "start_watch", "one_liner": "Watch a directory for .java changes; updates overlay in real time."},
83
+ {"name": "stop_watch", "one_liner": "Stop the background watch process."},
84
+ {"name": "get_watch_status", "one_liner": "Is watch mode running? Path, uptime."},
85
+ ],
86
+ },
87
+ {
88
+ "id": "tools_overlay",
89
+ "title": "Overlay (Dirty-State Tracking)",
90
+ "body": (
91
+ "The overlay tracks uncommitted file changes separately from the base index.\n"
92
+ "search_hybrid and find_symbol merge both layers automatically.\n"
93
+ "Deep analyses (dead code, flows, communities) use the committed base only."
94
+ ),
95
+ "tools": [
96
+ {"name": "get_overlay_status", "one_liner": "Uncommitted overlay state by project/module."},
97
+ {"name": "promote_overlay", "one_liner": "Commit dirty overlay into the base index immediately."},
98
+ {"name": "clear_overlay", "one_liner": "Discard dirty overlay without changing the base index."},
99
+ ],
100
+ },
101
+ {
102
+ "id": "tools_reset",
103
+ "title": "Index Reset",
104
+ "tools": [
105
+ {"name": "reset_project", "one_liner": "Remove all data for one project. Re-index with analyse_project()."},
106
+ {"name": "reset_index", "one_liner": "Remove ALL data across every project (clean slate)."},
107
+ {"name": "force_reset_index", "one_liner": "Emergency: delete data files when normal reset fails (OOM/corruption)."},
108
+ ],
109
+ },
110
+ {
111
+ "id": "tools_advanced",
112
+ "title": "Advanced",
113
+ "tools": [
114
+ {"name": "run_cypher", "one_liner": "Run a raw Cypher query against the graph DB."},
115
+ ],
116
+ },
117
+ # ── Workflows ─────────────────────────────────────────────────
118
+ {
119
+ "id": "workflows",
120
+ "title": "Common Workflows",
121
+ "body": (
122
+ "Understand a symbol:\n"
123
+ " search_hybrid('PaymentService') -> get_impact('processPayment') -> get_neighborhood('processPayment')\n"
124
+ "\n"
125
+ "Find dead code:\n"
126
+ " detect_dead_code(strict=True) -> get_impact(candidate) to verify each hit\n"
127
+ "\n"
128
+ "Review a branch:\n"
129
+ " compare_branches('main', 'feature-x') -> get_impact() on each changed symbol\n"
130
+ "\n"
131
+ "Active development:\n"
132
+ " analyse_project(path) -> start_watch(path) -> search/analyse as needed\n"
133
+ "\n"
134
+ "Explore architecture:\n"
135
+ " list_packages() -> get_symbol_community(symbol) -> trace_execution_flows()"
136
+ ),
137
+ },
138
+ {
139
+ "id": "tips",
140
+ "title": "Tips",
141
+ "body": (
142
+ "- Most tools accept an optional project= parameter to scope results.\n"
143
+ " Use list_projects() to see available project IDs.\n"
144
+ "- Multi-module projects use IDs like 'myapp::core', 'myapp::web'.\n"
145
+ "- get_symbol_context() is the best single call for understanding any symbol.\n"
146
+ "- For git tools, pass project= so the correct repo root is resolved.\n"
147
+ "- BM25 + fuzzy search works without embeddings. Semantic search needs\n"
148
+ " 'pip install codespine[ml]' and 'analyse_project(path, embed=True)'.\n"
149
+ "- If community/flow/coupling data is missing, re-run:\n"
150
+ " analyse_project(path, deep=True)"
151
+ ),
152
+ },
153
+ ]
154
+
155
+
156
+ def format_guide_terminal() -> str:
157
+ """Render GUIDE_SECTIONS as formatted terminal text."""
158
+ lines: list[str] = [f"CodeSpine v{__version__} -- Guide\n"]
159
+ for section in GUIDE_SECTIONS:
160
+ lines.append(f"{'=' * 64}")
161
+ lines.append(f" {section['title']}")
162
+ lines.append(f"{'=' * 64}")
163
+ if "body" in section:
164
+ lines.append(section["body"])
165
+ if "tools" in section:
166
+ for t in section["tools"]:
167
+ lines.append(f" {t['name']:<28} {t['one_liner']}")
168
+ lines.append("")
169
+ return "\n".join(lines)
@@ -362,6 +362,22 @@ def build_mcp_server(store, repo_path_provider):
362
362
  "notes": notes,
363
363
  }
364
364
 
365
+ # ------------------------------------------------------------------
366
+ # Guide – static tool catalog + workflows for agents
367
+ # ------------------------------------------------------------------
368
+
369
+ @mcp.tool()
370
+ def guide():
371
+ """
372
+ How to use CodeSpine: system overview, tool catalog, recommended
373
+ workflows, and tips. Call this FIRST if you have never used
374
+ CodeSpine before. For live index state (what is indexed right now),
375
+ call get_capabilities() instead.
376
+ """
377
+ from codespine.guide import GUIDE_SECTIONS
378
+
379
+ return _json({"version": __version__, "sections": GUIDE_SECTIONS})
380
+
365
381
  # ------------------------------------------------------------------
366
382
  # Project listing
367
383
  # ------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codespine
3
- Version: 0.6.3
3
+ Version: 0.7.1
4
4
  Summary: Local Java code intelligence indexer backed by a graph database
5
5
  Author: CodeSpine contributors
6
6
  License: MIT License
@@ -223,45 +223,134 @@ If the client launches the wrong Python environment, use the absolute binary pat
223
223
  }
224
224
  ```
225
225
 
226
- Common MCP tools:
226
+ ### Agent Onboarding
227
227
 
228
- - `search_hybrid(query, k, project)`
229
- - `find_symbol(name, kind, project, limit)`
230
- - `get_symbol_context(query, max_depth, project)`
231
- - `get_impact(symbol, max_depth, project)`
232
- - `detect_dead_code(limit, project, strict)`
233
- - `trace_execution_flows(entry_symbol, max_depth, project)`
234
- - `get_symbol_community(symbol)`
235
- - `get_change_coupling(months, min_strength, min_cochanges, project)`
236
- - `compare_branches(base_ref, head_ref)`
237
- - `get_codebase_stats()`
228
+ When an agent connects to CodeSpine for the first time, it should call:
238
229
 
239
- ## CLI
230
+ 1. **`guide()`** — returns a structured catalog of every tool, organized by category, with recommended workflows and tips.
231
+ 2. **`get_capabilities()`** — returns what is indexed right now, which features are ready, and what's missing.
240
232
 
241
- Core commands:
233
+ The same information is available from the CLI:
242
234
 
243
235
  ```bash
244
- codespine analyse <path>
245
- codespine analyse <path> --full
246
- codespine analyse <path> --deep
247
- codespine analyse <path> --embed
248
- codespine watch --path .
249
- codespine watch --path . --overlay-debounce-ms 1500
250
- codespine search "query"
251
- codespine context "symbol"
252
- codespine impact "symbol"
253
- codespine deadcode
254
- codespine flow
255
- codespine community
256
- codespine coupling
257
- codespine diff main..feature
258
- codespine stats
259
- codespine list
260
- codespine overlay-status
261
- codespine overlay-promote
262
- codespine overlay-clear
263
- codespine clear-project <project_id>
264
- codespine clear-index
236
+ codespine guide # tool catalog, workflows, tips
237
+ codespine guide --json # structured JSON for tooling
238
+ ```
239
+
240
+ ### MCP Tools
241
+
242
+ **Discovery & Status**
243
+
244
+ | Tool | Description |
245
+ |------|-------------|
246
+ | `guide()` | Tool catalog, workflows, and tips. Call first if new to CodeSpine. |
247
+ | `get_capabilities()` | What is indexed and which features are available right now. |
248
+ | `list_projects()` | All indexed projects with symbol/file counts. |
249
+ | `get_codebase_stats()` | Per-project stats: files, classes, methods, call edges, embeddings. |
250
+ | `list_packages(project)` | Java packages in the index. |
251
+ | `ping()` | Verify the MCP server is alive. |
252
+
253
+ **Search & Lookup**
254
+
255
+ | Tool | Description |
256
+ |------|-------------|
257
+ | `search_hybrid(query, k, project)` | Ranked symbol search (BM25 + vector + fuzzy via RRF). |
258
+ | `find_symbol(name, kind, project, limit)` | Exact/prefix name lookup across all projects. |
259
+ | `get_symbol_context(query, max_depth, project)` | One-shot deep context: search + impact + community + flows. |
260
+ | `get_neighborhood(symbol, project)` | Callers, callees, siblings, and override/implements. |
261
+
262
+ **Analysis**
263
+
264
+ | Tool | Description |
265
+ |------|-------------|
266
+ | `get_impact(symbol, max_depth, project)` | Caller-tree impact analysis with confidence scores. |
267
+ | `detect_dead_code(limit, project, strict)` | Methods with no callers (Java-aware exemptions). |
268
+ | `trace_execution_flows(entry_symbol, max_depth, project)` | Execution paths from entry points. |
269
+ | `get_symbol_community(symbol)` | Architectural community cluster for a symbol. |
270
+ | `get_change_coupling(months, min_strength, min_cochanges)` | Files that historically change together. |
271
+
272
+ **Git**
273
+
274
+ | Tool | Description |
275
+ |------|-------------|
276
+ | `git_log(file_path, limit, project)` | Recent git commits. |
277
+ | `git_diff(ref, file_path, project)` | Git diff (working tree vs ref, or between refs). |
278
+ | `compare_branches(base_ref, head_ref, project)` | Symbol-level diff between two git refs. |
279
+
280
+ **Indexing & Watch**
281
+
282
+ | Tool | Description |
283
+ |------|-------------|
284
+ | `analyse_project(path, full, deep, embed)` | Index a Java project (background job). |
285
+ | `get_analyse_status()` | Poll analysis progress. |
286
+ | `reindex_file(file_path, project)` | Re-index a single `.java` file (<1 s). |
287
+ | `start_watch(path)` | Watch for `.java` changes and update overlay in real time. |
288
+ | `stop_watch()` | Stop the background watch process. |
289
+ | `get_watch_status()` | Watch mode status: running, path, uptime. |
290
+
291
+ **Overlay**
292
+
293
+ | Tool | Description |
294
+ |------|-------------|
295
+ | `get_overlay_status(project)` | Uncommitted overlay state by project/module. |
296
+ | `promote_overlay(project)` | Commit dirty overlay into the base index. |
297
+ | `clear_overlay(project)` | Discard dirty overlay without changing the base. |
298
+
299
+ **Reset**
300
+
301
+ | Tool | Description |
302
+ |------|-------------|
303
+ | `reset_project(project_id)` | Remove all data for one project. |
304
+ | `reset_index()` | Remove ALL data across every project. |
305
+ | `force_reset_index()` | Emergency: delete data files when normal reset fails. |
306
+
307
+ **Advanced**
308
+
309
+ | Tool | Description |
310
+ |------|-------------|
311
+ | `run_cypher(query)` | Run a raw Cypher query against the graph DB. |
312
+
313
+ ## CLI
314
+
315
+ ```bash
316
+ # Indexing
317
+ codespine analyse <path> # incremental index
318
+ codespine analyse <path> --full # full re-index
319
+ codespine analyse <path> --deep # + communities, flows, dead code, coupling
320
+ codespine analyse <path> --embed # + vector embeddings
321
+ codespine watch --path . # live re-index on file changes
322
+
323
+ # Search & Analysis
324
+ codespine search "query" # hybrid search
325
+ codespine context "symbol" # one-shot deep context
326
+ codespine impact "symbol" # caller-tree impact
327
+ codespine deadcode # dead code candidates
328
+ codespine flow # execution flows
329
+ codespine community # architectural clusters
330
+ codespine coupling # git change coupling
331
+ codespine diff main..feature # symbol-level branch diff
332
+
333
+ # Status & Info
334
+ codespine stats # per-project statistics
335
+ codespine list # indexed projects
336
+ codespine status # service and database status
337
+ codespine guide # tool catalog and workflows
338
+
339
+ # Overlay
340
+ codespine overlay-status # dirty overlay state
341
+ codespine overlay-promote # commit overlay to base
342
+ codespine overlay-clear # discard overlay
343
+
344
+ # Server Management
345
+ codespine start # launch background MCP server
346
+ codespine stop # stop background MCP server
347
+ codespine mcp # foreground MCP (stdio, for IDE)
348
+
349
+ # Cleanup & Reset
350
+ codespine clear-project <project_id> # remove one project
351
+ codespine clear-index # remove all indexed data
352
+ codespine force-reset # emergency: delete all data files
353
+ codespine setup # check dependencies
265
354
  ```
266
355
 
267
356
  `analyse` defaults to incremental mode. Repeat runs are designed to be fast when files have not changed.
@@ -323,8 +412,8 @@ Running `codespine analyse --deep --embed` on one project while querying a diffe
323
412
  - `codespine start` launches a background MCP server. Most IDE MCP clients should use `codespine mcp` instead and manage the process themselves.
324
413
  - `codespine watch` updates the dirty overlay first; it does not rewrite the committed base index on every save.
325
414
  - `codespine clear-index` rebuilds the local index database from scratch. This also removes the read replica; run `analyse` again to republish it.
415
+ - `codespine force-reset` is the nuclear option — it deletes all data files without going through the DB engine. Use it when `clear-index` fails due to DB corruption.
326
416
  - For large Spring or JPA-heavy repos, dead-code results should still be reviewed before deletion. The tool is conservative, not authoritative.
327
- - The first run after upgrading to v0.5.7 will not have a read replica yet. Run `codespine analyse` once to create it.
328
417
 
329
418
  ## Project Docs
330
419
 
@@ -5,6 +5,7 @@ pyproject.toml
5
5
  codespine/__init__.py
6
6
  codespine/cli.py
7
7
  codespine/config.py
8
+ codespine/guide.py
8
9
  codespine.egg-info/PKG-INFO
9
10
  codespine.egg-info/SOURCES.txt
10
11
  codespine.egg-info/dependency_links.txt
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "codespine"
7
- version = "0.6.3"
7
+ version = "0.7.1"
8
8
  description = "Local Java code intelligence indexer backed by a graph database"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
File without changes
File without changes
File without changes
File without changes