mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-27 04:20:09 +00:00
Mirrors hanzoai/mcp's Rust `lsp` exactly: one tool, two planes, picked by data
the caller already has. `file` names the file; `repo` (a git.hanzo.ai slug,
optional `rev`) says which world it lives in. Without `repo` nothing changes —
the same language server on the same tree. With it, the question goes to the
indexed corpus behind /v1/code/lsp, which reaches across a repo's dependencies
without checking anything out.
One table maps actions onto ops: locate carries a relation (definition|
reference|type|implementation) because "where is X" is one question with four
answers, not four routes; hover, symbols, diagnostics and complete stand on
their own. The body is {repo, rev?, path, line, character, relation?} in LSP's
own frame — 0-based line, UTF-16 character — shifted from the tool's 1-based
`line` by the same expression the local plane uses.
The call goes through the shared HanzoCloud client hanzo-tools-code and
hanzo-tools-net already compose, so there is no second client and no second
lsp tool. Actions a plane cannot serve say so up front rather than spawning a
server or calling out.
test_lsp_tools.py asked for a class named `LspTool`; the class is `LSPTool`,
so those two never ran. One name, and they run.
Co-authored-by: Hanzo Dev <[email protected]>
36 lines
684 B
Python
36 lines
684 B
Python
"""Tests for hanzo-tools-lsp."""
|
|
|
|
import pytest
|
|
|
|
|
|
class TestImports:
|
|
"""Test that all modules can be imported."""
|
|
|
|
def test_import_package(self):
|
|
from hanzo_tools import lsp
|
|
|
|
assert lsp is not None
|
|
|
|
def test_import_tools(self):
|
|
from hanzo_tools.lsp import TOOLS
|
|
|
|
assert len(TOOLS) > 0
|
|
|
|
def test_import_lsp_tool(self):
|
|
from hanzo_tools.lsp import LSPTool
|
|
|
|
assert LSPTool.name == "lsp"
|
|
|
|
|
|
class TestLSPTool:
|
|
"""Tests for LSPTool."""
|
|
|
|
@pytest.fixture
|
|
def tool(self):
|
|
from hanzo_tools.lsp import LSPTool
|
|
|
|
return LSPTool()
|
|
|
|
def test_has_description(self, tool):
|
|
assert tool.description
|