codemap-core 0.1.0__py3-none-any.whl

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 (52) hide show
  1. codemap/__init__.py +7 -0
  2. codemap/cli/__init__.py +3 -0
  3. codemap/cli/_common.py +90 -0
  4. codemap/cli/commands/__init__.py +3 -0
  5. codemap/cli/commands/callees.py +102 -0
  6. codemap/cli/commands/callers.py +107 -0
  7. codemap/cli/commands/config.py +78 -0
  8. codemap/cli/commands/diagnostics.py +142 -0
  9. codemap/cli/commands/doctor.py +158 -0
  10. codemap/cli/commands/get.py +93 -0
  11. codemap/cli/commands/index.py +725 -0
  12. codemap/cli/commands/routes.py +104 -0
  13. codemap/cli/commands/search.py +78 -0
  14. codemap/cli/commands/trace.py +179 -0
  15. codemap/cli/main.py +140 -0
  16. codemap/cli/renderers/__init__.py +3 -0
  17. codemap/cli/renderers/json.py +32 -0
  18. codemap/cli/renderers/text.py +24 -0
  19. codemap/config/__init__.py +31 -0
  20. codemap/config/loader.py +96 -0
  21. codemap/config/schema.py +122 -0
  22. codemap/core/__init__.py +7 -0
  23. codemap/core/bridge/__init__.py +8 -0
  24. codemap/core/bridge/base.py +38 -0
  25. codemap/core/bridge/http_route.py +374 -0
  26. codemap/core/bridge/python_cross_module.py +120 -0
  27. codemap/core/bridge/registry.py +117 -0
  28. codemap/core/graph.py +183 -0
  29. codemap/core/models.py +299 -0
  30. codemap/core/store.py +78 -0
  31. codemap/core/symbol.py +314 -0
  32. codemap/diagnostics/__init__.py +3 -0
  33. codemap/diagnostics/exit_codes.py +30 -0
  34. codemap/diagnostics/logging.py +65 -0
  35. codemap/diagnostics/progress.py +68 -0
  36. codemap/indexers/__init__.py +9 -0
  37. codemap/indexers/_example_lang.py +135 -0
  38. codemap/indexers/base.py +77 -0
  39. codemap/indexers/python.py +577 -0
  40. codemap/indexers/registry.py +104 -0
  41. codemap/io/__init__.py +8 -0
  42. codemap/io/atomic.py +97 -0
  43. codemap/io/base.py +12 -0
  44. codemap/io/json_store.py +433 -0
  45. codemap/io/lock.py +87 -0
  46. codemap/io/manifest.py +90 -0
  47. codemap/mcp/__init__.py +3 -0
  48. codemap_core-0.1.0.dist-info/METADATA +480 -0
  49. codemap_core-0.1.0.dist-info/RECORD +52 -0
  50. codemap_core-0.1.0.dist-info/WHEEL +4 -0
  51. codemap_core-0.1.0.dist-info/entry_points.txt +10 -0
  52. codemap_core-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,93 @@
1
+ """``codemap get <symbol-id>`` — fetch symbol details."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Annotated
7
+
8
+ import typer
9
+
10
+ from codemap.cli._common import (
11
+ format_location,
12
+ open_store_or_exit,
13
+ parse_symbol_id_or_exit,
14
+ read_snippet,
15
+ )
16
+ from codemap.cli.renderers import json as json_renderer
17
+ from codemap.cli.renderers import text
18
+ from codemap.diagnostics.exit_codes import ExitCode
19
+
20
+
21
+ def register(app: typer.Typer) -> None:
22
+ @app.command("get")
23
+ def get(
24
+ ctx: typer.Context,
25
+ symbol_id: Annotated[str, typer.Argument(help="Full SCIP SymbolID string.")],
26
+ project: Annotated[
27
+ Path,
28
+ typer.Option(
29
+ "--project",
30
+ "-p",
31
+ file_okay=False,
32
+ dir_okay=True,
33
+ help="Project root containing `.codemap/`.",
34
+ ),
35
+ ] = Path("."),
36
+ ) -> None:
37
+ """Print the definition site and code snippet for one symbol."""
38
+ as_json: bool = ctx.obj["json_output"]
39
+ sid = parse_symbol_id_or_exit(symbol_id)
40
+ with open_store_or_exit(project) as store:
41
+ sym = store.get(sid)
42
+ manifest = store.manifest()
43
+
44
+ if sym is None:
45
+ if as_json:
46
+ json_renderer.emit("get", {"id": symbol_id, "found": False, "symbol": None})
47
+ else:
48
+ text.console(stderr=True).print(f"[yellow]No symbol with id[/yellow] {symbol_id!r}")
49
+ raise typer.Exit(code=int(ExitCode.GENERIC_ERROR))
50
+
51
+ snippet = read_snippet(
52
+ Path(manifest.project_root),
53
+ sym.file,
54
+ sym.range.start_line,
55
+ )
56
+
57
+ if as_json:
58
+ json_renderer.emit(
59
+ "get",
60
+ {
61
+ "id": str(sym.id),
62
+ "found": True,
63
+ "symbol": {
64
+ "kind": sym.kind,
65
+ "language": sym.language,
66
+ "file": str(sym.file),
67
+ "range": {
68
+ "start_line": sym.range.start_line,
69
+ "end_line": sym.range.end_line,
70
+ },
71
+ "signature": sym.signature,
72
+ "doc": sym.doc,
73
+ "confidence": sym.confidence,
74
+ "extra": sym.extra,
75
+ },
76
+ "snippet": snippet,
77
+ },
78
+ )
79
+ return
80
+
81
+ cons = text.console()
82
+ cons.print(f"[bold]{sym.signature or sym.id}[/bold]")
83
+ cons.print(f" kind: {sym.kind}")
84
+ cons.print(f" language: {sym.language}")
85
+ cons.print(f" location: {format_location(sym.file, sym.range.start_line)}")
86
+ if sym.doc:
87
+ cons.print(f" doc: {sym.doc}")
88
+ if snippet:
89
+ cons.print()
90
+ cons.print(f"[dim]{snippet}[/dim]")
91
+
92
+
93
+ __all__ = ["register"]