codegraph-engine 2.3.0__py3-none-any.whl → 3.0.1__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.
- codegraph/__init__.py +1 -1
- codegraph/__main__.py +7 -0
- codegraph/agent_brain.py +253 -2
- codegraph/agent_capabilities.py +1348 -67
- codegraph/agent_rules.py +2 -1
- codegraph/api_drift.py +455 -0
- codegraph/architecture_rules.py +123 -0
- codegraph/async_queue/__init__.py +50 -0
- codegraph/async_queue/detectors/__init__.py +48 -0
- codegraph/async_queue/detectors/celery.py +160 -0
- codegraph/async_queue/detectors/kafka.py +168 -0
- codegraph/async_queue/detectors/rabbitmq.py +116 -0
- codegraph/async_queue/detectors/redis.py +130 -0
- codegraph/async_queue/detectors/sqs.py +135 -0
- codegraph/async_queue/models.py +161 -0
- codegraph/async_queue/otel_models.py +74 -0
- codegraph/async_queue/otel_parser.py +337 -0
- codegraph/async_queue/reconciler.py +427 -0
- codegraph/async_queue/scanner.py +291 -0
- codegraph/async_queue/traversal.py +447 -0
- codegraph/change_impact.py +320 -110
- codegraph/changelog.py +170 -0
- codegraph/cli.py +1605 -62
- codegraph/cli_output.py +17 -2
- codegraph/context.py +135 -24
- codegraph/context_freshness.py +2 -0
- codegraph/database/__init__.py +14 -0
- codegraph/database/extractor.py +712 -17
- codegraph/database/interrogation.py +388 -2
- codegraph/database/schema_drift.py +862 -0
- codegraph/dataflow_propagation.py +118 -0
- codegraph/dead_code.py +387 -0
- codegraph/epistemic.py +15 -0
- codegraph/evidence_contract.py +34 -3
- codegraph/federation.py +245 -0
- codegraph/frameworks.py +234 -12
- codegraph/frameworks_nestjs.py +502 -0
- codegraph/frameworks_nextjs.py +337 -0
- codegraph/frameworks_react.py +457 -0
- codegraph/freshness.py +2 -0
- codegraph/frontend_html.py +109 -0
- codegraph/git.py +2 -0
- codegraph/git_state.py +2 -0
- codegraph/graph/traversal.py +150 -7
- codegraph/graph_csr.py +218 -0
- codegraph/incremental.py +150 -0
- codegraph/indexing/__init__.py +7 -1
- codegraph/indexing/classifier.py +5 -0
- codegraph/indexing/indexer.py +292 -38
- codegraph/indexing/languages/__init__.py +1 -0
- codegraph/indexing/languages/cpp.py +457 -0
- codegraph/indexing/languages/go.py +459 -0
- codegraph/indexing/languages/jvm.py +583 -0
- codegraph/indexing/languages/rust.py +507 -0
- codegraph/indexing/models.py +15 -1
- codegraph/indexing/parser.py +385 -9
- codegraph/indexing/pool.py +136 -0
- codegraph/indexing/protocols.py +220 -0
- codegraph/indexing/scanner.py +23 -0
- codegraph/indexing/templates.py +418 -0
- codegraph/interrogation.py +207 -39
- codegraph/lsp.py +318 -0
- codegraph/lsp_bridge/__init__.py +16 -0
- codegraph/lsp_bridge/bridge.py +102 -0
- codegraph/lsp_bridge/client.py +207 -0
- codegraph/lsp_bridge/models.py +71 -0
- codegraph/mcp/server.py +502 -29
- codegraph/memory/trajectory.py +282 -0
- codegraph/models.py +7 -0
- codegraph/monorepo.py +3 -0
- codegraph/multi_agent/__init__.py +13 -0
- codegraph/multi_agent/coordinator.py +229 -0
- codegraph/multi_agent/models.py +76 -0
- codegraph/optimizer.py +42 -5
- codegraph/polymorphism.py +95 -0
- codegraph/pr_review.py +296 -0
- codegraph/process_lifecycle.py +50 -12
- codegraph/reachability.py +198 -0
- codegraph/reachability_index.py +74 -0
- codegraph/refactor/__init__.py +48 -0
- codegraph/refactor/models.py +114 -0
- codegraph/refactor/patcher.py +348 -0
- codegraph/refactor/renamer.py +844 -0
- codegraph/refactor/transactions.py +414 -0
- codegraph/repair.py +233 -0
- codegraph/resolver.py +1357 -161
- codegraph/retrieval_policy.py +22 -1
- codegraph/roblox.py +2174 -0
- codegraph/route_composer.py +7 -0
- codegraph/route_topology.py +172 -0
- codegraph/runtime/__init__.py +25 -0
- codegraph/runtime/collector.py +155 -0
- codegraph/runtime/db_watcher.py +191 -0
- codegraph/runtime/ingestor.py +30 -10
- codegraph/runtime/otel_receiver.py +208 -0
- codegraph/runtime/port_inspector.py +304 -0
- codegraph/runtime/runner.py +155 -6
- codegraph/runtime/trace_linker.py +175 -0
- codegraph/sandbox.py +215 -0
- codegraph/search/hybrid.py +26 -0
- codegraph/security/supply_chain.py +188 -0
- codegraph/security/taint.py +421 -0
- codegraph/semantic_decorators.py +34 -3
- codegraph/structural_diff.py +2 -0
- codegraph/styles.py +144 -0
- codegraph/symbol_history.py +2 -0
- codegraph/test_gen.py +437 -0
- codegraph/tsconfig.py +236 -0
- codegraph/ui/__init__.py +6 -0
- codegraph/ui/server.py +876 -0
- codegraph/watcher.py +323 -0
- {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/METADATA +365 -67
- codegraph_engine-3.0.1.dist-info/RECORD +164 -0
- {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/WHEEL +1 -1
- codegraph_engine-2.3.0.dist-info/RECORD +0 -94
- {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/entry_points.txt +0 -0
- {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/licenses/LICENSE +0 -0
- {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""Bridge connecting CodeGraph to local Language Server Protocol (LSP) daemons."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import shutil
|
|
5
|
+
import time
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from .client import LSPClient
|
|
9
|
+
from .models import DiagnosticSeverity, LSPBridgeReport, LSPDiagnostic
|
|
10
|
+
|
|
11
|
+
_SUPPORTED_SERVERS = {
|
|
12
|
+
"python": ["pyright-langserver", "--stdio"],
|
|
13
|
+
"typescript": ["typescript-language-server", "--stdio"],
|
|
14
|
+
"go": ["gopls"],
|
|
15
|
+
"rust": ["rust-analyzer"],
|
|
16
|
+
"cpp": ["clangd"],
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def detect_lsp_servers(workspace: Path | None = None) -> dict[str, str]:
|
|
21
|
+
"""Scan host system for installed language server binaries."""
|
|
22
|
+
found: dict[str, str] = {}
|
|
23
|
+
for lang, cmd_parts in _SUPPORTED_SERVERS.items():
|
|
24
|
+
bin_name = cmd_parts[0]
|
|
25
|
+
path = shutil.which(bin_name)
|
|
26
|
+
if path:
|
|
27
|
+
found[lang] = path
|
|
28
|
+
return found
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def collect_lsp_diagnostics(
|
|
32
|
+
workspace: Path,
|
|
33
|
+
file_path: str | None = None,
|
|
34
|
+
timeout_seconds: float = 3.0,
|
|
35
|
+
) -> LSPBridgeReport:
|
|
36
|
+
"""Collect live compiler and language server diagnostics for files in workspace."""
|
|
37
|
+
t0 = time.perf_counter()
|
|
38
|
+
repo = workspace.resolve()
|
|
39
|
+
discovered = detect_lsp_servers(repo)
|
|
40
|
+
|
|
41
|
+
if not discovered:
|
|
42
|
+
elapsed = (time.perf_counter() - t0) * 1000.0
|
|
43
|
+
return LSPBridgeReport(
|
|
44
|
+
workspace=str(repo),
|
|
45
|
+
status="FALLBACK_STATIC",
|
|
46
|
+
discovered_servers={},
|
|
47
|
+
total_diagnostics=0,
|
|
48
|
+
error_count=0,
|
|
49
|
+
warning_count=0,
|
|
50
|
+
diagnostics=[],
|
|
51
|
+
latency_ms=elapsed,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
all_diagnostics: list[LSPDiagnostic] = []
|
|
55
|
+
|
|
56
|
+
# If specific file given, pick server by extension
|
|
57
|
+
target_langs = list(discovered.keys())
|
|
58
|
+
if file_path:
|
|
59
|
+
ext = Path(file_path).suffix.lower()
|
|
60
|
+
if ext in (".py", ".pyi"):
|
|
61
|
+
target_langs = ["python"] if "python" in discovered else []
|
|
62
|
+
elif ext in (".ts", ".tsx", ".js", ".jsx"):
|
|
63
|
+
target_langs = ["typescript"] if "typescript" in discovered else []
|
|
64
|
+
elif ext == ".go":
|
|
65
|
+
target_langs = ["go"] if "go" in discovered else []
|
|
66
|
+
elif ext == ".rs":
|
|
67
|
+
target_langs = ["rust"] if "rust" in discovered else []
|
|
68
|
+
elif ext in (".c", ".cc", ".cpp", ".h", ".hpp"):
|
|
69
|
+
target_langs = ["cpp"] if "cpp" in discovered else []
|
|
70
|
+
|
|
71
|
+
for lang in target_langs:
|
|
72
|
+
cmd = _SUPPORTED_SERVERS[lang]
|
|
73
|
+
client = LSPClient(cmd, repo, timeout_seconds=timeout_seconds)
|
|
74
|
+
try:
|
|
75
|
+
if client.start() and client.initialize():
|
|
76
|
+
# Open target file or sample files
|
|
77
|
+
if file_path:
|
|
78
|
+
p = repo / file_path
|
|
79
|
+
if p.is_file():
|
|
80
|
+
client.open_document(p, lang, p.read_text(encoding="utf-8", errors="replace"))
|
|
81
|
+
# Short read window
|
|
82
|
+
time.sleep(0.1)
|
|
83
|
+
all_diagnostics.extend(client.get_diagnostics())
|
|
84
|
+
except Exception:
|
|
85
|
+
pass
|
|
86
|
+
finally:
|
|
87
|
+
client.close()
|
|
88
|
+
|
|
89
|
+
errors = sum(1 for d in all_diagnostics if d.severity == DiagnosticSeverity.ERROR)
|
|
90
|
+
warnings = sum(1 for d in all_diagnostics if d.severity == DiagnosticSeverity.WARNING)
|
|
91
|
+
elapsed = (time.perf_counter() - t0) * 1000.0
|
|
92
|
+
|
|
93
|
+
return LSPBridgeReport(
|
|
94
|
+
workspace=str(repo),
|
|
95
|
+
status="READY" if discovered else "FALLBACK_STATIC",
|
|
96
|
+
discovered_servers=discovered,
|
|
97
|
+
total_diagnostics=len(all_diagnostics),
|
|
98
|
+
error_count=errors,
|
|
99
|
+
warning_count=warnings,
|
|
100
|
+
diagnostics=all_diagnostics,
|
|
101
|
+
latency_ms=elapsed,
|
|
102
|
+
)
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"""Process-isolated JSON-RPC 2.0 Language Server Protocol Client for CodeGraph."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
import subprocess
|
|
8
|
+
import time
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any, cast
|
|
11
|
+
|
|
12
|
+
from .models import DiagnosticSeverity, LSPDiagnostic
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger("codegraph.lsp")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class LSPClient:
|
|
18
|
+
"""Manages an isolated language server subprocess via JSON-RPC 2.0 over stdio."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, command: list[str], root_path: Path, timeout_seconds: float = 8.0):
|
|
21
|
+
self.command = command
|
|
22
|
+
self.root_path = root_path.resolve()
|
|
23
|
+
self.timeout = timeout_seconds
|
|
24
|
+
self.proc: subprocess.Popen[bytes] | None = None
|
|
25
|
+
self._request_id = 0
|
|
26
|
+
self._diagnostics_cache: list[LSPDiagnostic] = []
|
|
27
|
+
|
|
28
|
+
def start(self) -> bool:
|
|
29
|
+
"""Start language server subprocess with process group isolation."""
|
|
30
|
+
try:
|
|
31
|
+
self.proc = subprocess.Popen(
|
|
32
|
+
self.command,
|
|
33
|
+
stdin=subprocess.PIPE,
|
|
34
|
+
stdout=subprocess.PIPE,
|
|
35
|
+
stderr=subprocess.PIPE,
|
|
36
|
+
cwd=str(self.root_path),
|
|
37
|
+
)
|
|
38
|
+
return True
|
|
39
|
+
except (FileNotFoundError, PermissionError) as exc:
|
|
40
|
+
logger.debug("Could not spawn LSP server %s: %s", self.command, exc)
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
def close(self) -> None:
|
|
44
|
+
"""Terminate and clean up language server process cleanly without leaking."""
|
|
45
|
+
if self.proc:
|
|
46
|
+
try:
|
|
47
|
+
self.send_notification("exit", {})
|
|
48
|
+
except Exception:
|
|
49
|
+
pass
|
|
50
|
+
try:
|
|
51
|
+
self.proc.terminate()
|
|
52
|
+
self.proc.wait(timeout=1.0)
|
|
53
|
+
except Exception:
|
|
54
|
+
try:
|
|
55
|
+
self.proc.kill()
|
|
56
|
+
except Exception:
|
|
57
|
+
pass
|
|
58
|
+
finally:
|
|
59
|
+
self.proc = None
|
|
60
|
+
|
|
61
|
+
def __enter__(self) -> LSPClient:
|
|
62
|
+
self.start()
|
|
63
|
+
return self
|
|
64
|
+
|
|
65
|
+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
|
|
66
|
+
self.close()
|
|
67
|
+
|
|
68
|
+
def __del__(self) -> None:
|
|
69
|
+
self.close()
|
|
70
|
+
|
|
71
|
+
def send_notification(self, method: str, params: dict[str, Any]) -> None:
|
|
72
|
+
"""Send a one-way JSON-RPC notification."""
|
|
73
|
+
if not self.proc or not self.proc.stdin:
|
|
74
|
+
return
|
|
75
|
+
payload = {
|
|
76
|
+
"jsonrpc": "2.0",
|
|
77
|
+
"method": method,
|
|
78
|
+
"params": params,
|
|
79
|
+
}
|
|
80
|
+
body = json.dumps(payload).encode("utf-8")
|
|
81
|
+
header = f"Content-Length: {len(body)}\r\n\r\n".encode("ascii")
|
|
82
|
+
try:
|
|
83
|
+
self.proc.stdin.write(header + body)
|
|
84
|
+
self.proc.stdin.flush()
|
|
85
|
+
except (BrokenPipeError, OSError):
|
|
86
|
+
pass
|
|
87
|
+
|
|
88
|
+
def send_request(self, method: str, params: dict[str, Any]) -> dict[str, Any] | None:
|
|
89
|
+
"""Send a JSON-RPC request and wait synchronously for the response."""
|
|
90
|
+
if not self.proc or not self.proc.stdin or not self.proc.stdout:
|
|
91
|
+
return None
|
|
92
|
+
self._request_id += 1
|
|
93
|
+
req_id = self._request_id
|
|
94
|
+
payload = {
|
|
95
|
+
"jsonrpc": "2.0",
|
|
96
|
+
"id": req_id,
|
|
97
|
+
"method": method,
|
|
98
|
+
"params": params,
|
|
99
|
+
}
|
|
100
|
+
body = json.dumps(payload).encode("utf-8")
|
|
101
|
+
header = f"Content-Length: {len(body)}\r\n\r\n".encode("ascii")
|
|
102
|
+
try:
|
|
103
|
+
self.proc.stdin.write(header + body)
|
|
104
|
+
self.proc.stdin.flush()
|
|
105
|
+
except (BrokenPipeError, OSError):
|
|
106
|
+
return None
|
|
107
|
+
|
|
108
|
+
# Read response with timeout
|
|
109
|
+
start = time.time()
|
|
110
|
+
while time.time() - start < self.timeout:
|
|
111
|
+
resp = self._read_message()
|
|
112
|
+
if not resp:
|
|
113
|
+
time.sleep(0.02)
|
|
114
|
+
continue
|
|
115
|
+
if resp.get("id") == req_id:
|
|
116
|
+
return resp
|
|
117
|
+
# Handle incoming publishDiagnostics notification
|
|
118
|
+
if resp.get("method") == "textDocument/publishDiagnostics":
|
|
119
|
+
self._parse_diagnostics_notification(resp.get("params", {}))
|
|
120
|
+
|
|
121
|
+
return None
|
|
122
|
+
|
|
123
|
+
def _read_message(self) -> dict[str, Any] | None:
|
|
124
|
+
"""Read a framed JSON-RPC message from stdout."""
|
|
125
|
+
if not self.proc or not self.proc.stdout:
|
|
126
|
+
return None
|
|
127
|
+
try:
|
|
128
|
+
# Read header
|
|
129
|
+
line = self.proc.stdout.readline()
|
|
130
|
+
if not line:
|
|
131
|
+
return None
|
|
132
|
+
line_str = line.decode("ascii", errors="replace")
|
|
133
|
+
content_length = 0
|
|
134
|
+
if line_str.startswith("Content-Length:"):
|
|
135
|
+
content_length = int(line_str.split(":")[1].strip())
|
|
136
|
+
# Read empty line delimiter
|
|
137
|
+
self.proc.stdout.readline()
|
|
138
|
+
# Read body
|
|
139
|
+
body_bytes = self.proc.stdout.read(content_length)
|
|
140
|
+
return cast(dict[str, Any], json.loads(body_bytes.decode("utf-8", errors="replace")))
|
|
141
|
+
except Exception:
|
|
142
|
+
return None
|
|
143
|
+
return None
|
|
144
|
+
|
|
145
|
+
def initialize(self) -> bool:
|
|
146
|
+
"""Send LSP initialize request and wait for server capabilities."""
|
|
147
|
+
res = self.send_request(
|
|
148
|
+
"initialize",
|
|
149
|
+
{
|
|
150
|
+
"processId": os.getpid(),
|
|
151
|
+
"rootUri": self.root_path.as_uri(),
|
|
152
|
+
"capabilities": {
|
|
153
|
+
"textDocument": {
|
|
154
|
+
"publishDiagnostics": {"relatedInformation": True},
|
|
155
|
+
"definition": {"dynamicRegistration": True},
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
)
|
|
160
|
+
if res and "result" in res:
|
|
161
|
+
self.send_notification("initialized", {})
|
|
162
|
+
return True
|
|
163
|
+
return False
|
|
164
|
+
|
|
165
|
+
def open_document(self, file_path: Path, language_id: str, content: str) -> None:
|
|
166
|
+
"""Notify LSP of an opened document to trigger diagnostics."""
|
|
167
|
+
self.send_notification(
|
|
168
|
+
"textDocument/didOpen",
|
|
169
|
+
{
|
|
170
|
+
"textDocument": {
|
|
171
|
+
"uri": file_path.resolve().as_uri(),
|
|
172
|
+
"languageId": language_id,
|
|
173
|
+
"version": 1,
|
|
174
|
+
"text": content,
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
def _parse_diagnostics_notification(self, params: dict[str, Any]) -> None:
|
|
180
|
+
uri = params.get("uri", "")
|
|
181
|
+
raw_diags = params.get("diagnostics", [])
|
|
182
|
+
for d in raw_diags:
|
|
183
|
+
rng = d.get("range", {})
|
|
184
|
+
start = rng.get("start", {})
|
|
185
|
+
end = rng.get("end", {})
|
|
186
|
+
sev_num = d.get("severity", 1)
|
|
187
|
+
sev = (
|
|
188
|
+
DiagnosticSeverity.ERROR if sev_num == 1
|
|
189
|
+
else (DiagnosticSeverity.WARNING if sev_num == 2
|
|
190
|
+
else (DiagnosticSeverity.INFORMATION if sev_num == 3 else DiagnosticSeverity.HINT))
|
|
191
|
+
)
|
|
192
|
+
self._diagnostics_cache.append(
|
|
193
|
+
LSPDiagnostic(
|
|
194
|
+
file_path=uri.replace("file://", ""),
|
|
195
|
+
line=start.get("line", 0) + 1,
|
|
196
|
+
column=start.get("character", 0) + 1,
|
|
197
|
+
end_line=end.get("line", 0) + 1,
|
|
198
|
+
end_column=end.get("character", 0) + 1,
|
|
199
|
+
severity=sev,
|
|
200
|
+
message=d.get("message", ""),
|
|
201
|
+
code=str(d.get("code", "")),
|
|
202
|
+
source=str(d.get("source", "LSP")),
|
|
203
|
+
)
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
def get_diagnostics(self) -> list[LSPDiagnostic]:
|
|
207
|
+
return list(self._diagnostics_cache)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Data models for Language Server Protocol (LSP) Bridge."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from dataclasses import asdict, dataclass, field
|
|
5
|
+
from enum import StrEnum
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DiagnosticSeverity(StrEnum):
|
|
10
|
+
ERROR = "ERROR"
|
|
11
|
+
WARNING = "WARNING"
|
|
12
|
+
INFORMATION = "INFORMATION"
|
|
13
|
+
HINT = "HINT"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True)
|
|
17
|
+
class LSPDiagnostic:
|
|
18
|
+
"""A compiler or language server diagnostic finding."""
|
|
19
|
+
|
|
20
|
+
file_path: str
|
|
21
|
+
line: int
|
|
22
|
+
column: int
|
|
23
|
+
end_line: int
|
|
24
|
+
end_column: int
|
|
25
|
+
severity: DiagnosticSeverity
|
|
26
|
+
message: str
|
|
27
|
+
code: str = ""
|
|
28
|
+
source: str = ""
|
|
29
|
+
|
|
30
|
+
def as_dict(self) -> dict[str, Any]:
|
|
31
|
+
d = asdict(self)
|
|
32
|
+
d["severity"] = self.severity.value
|
|
33
|
+
return d
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass(frozen=True)
|
|
37
|
+
class LSPLocation:
|
|
38
|
+
"""Definition or reference location resolved by LSP."""
|
|
39
|
+
|
|
40
|
+
file_path: str
|
|
41
|
+
line: int
|
|
42
|
+
column: int
|
|
43
|
+
|
|
44
|
+
def as_dict(self) -> dict[str, Any]:
|
|
45
|
+
return asdict(self)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass
|
|
49
|
+
class LSPBridgeReport:
|
|
50
|
+
"""Consolidated status and diagnostic report across language servers."""
|
|
51
|
+
|
|
52
|
+
workspace: str
|
|
53
|
+
status: str # READY | FALLBACK_STATIC | NOT_INSTALLED | ERROR
|
|
54
|
+
discovered_servers: dict[str, str] = field(default_factory=dict)
|
|
55
|
+
total_diagnostics: int = 0
|
|
56
|
+
error_count: int = 0
|
|
57
|
+
warning_count: int = 0
|
|
58
|
+
diagnostics: list[LSPDiagnostic] = field(default_factory=list)
|
|
59
|
+
latency_ms: float = 0.0
|
|
60
|
+
|
|
61
|
+
def as_dict(self) -> dict[str, Any]:
|
|
62
|
+
return {
|
|
63
|
+
"workspace": self.workspace,
|
|
64
|
+
"status": self.status,
|
|
65
|
+
"discovered_servers": self.discovered_servers,
|
|
66
|
+
"total_diagnostics": self.total_diagnostics,
|
|
67
|
+
"error_count": self.error_count,
|
|
68
|
+
"warning_count": self.warning_count,
|
|
69
|
+
"diagnostics": [d.as_dict() for d in self.diagnostics],
|
|
70
|
+
"latency_ms": round(self.latency_ms, 2),
|
|
71
|
+
}
|