SDK for interacting with lsproxy container
Project description
lsproxy SDK
A Python SDK for interacting with the lsproxy container, providing language-server protocol functionality for code analysis across multiple languages.
Features
- Symbol definition lookup
- Reference lookup across files
- Support for analyzing Python, TypeScript/JavaScript, and Rust
- Pydantic models for type safety
Try it out!
If you just want to get a feel for lsproxy try out the tutorial at demo.lsproxy.dev
Installation
pip install lsproxy-sdk
Usage
You can use lsproxy either by running a local server or using Modal cloud infrastructure.
Using Modal
First, install the Modal dependencies:
pip install 'lsproxy-sdk[modal]'
Then use the SDK:
from lsproxy import Lsproxy
# Synchronous usage
lsp = Lsproxy.initialize_with_modal(
repo_url="https://github.com/username/repo",
git_token="your-github-token", # Optional, for private repos
)
# Async usage
from lsproxy import AsyncLsproxy
import asyncio
async def main():
lsp = await AsyncLsproxy.initialize_with_modal(
repo_url="https://github.com/username/repo"
)
try:
files = await lsp.list_files()
finally:
await lsp.close()
asyncio.run(main())
Using Local Server
- Start the LSProxy container:
docker run --rm -d -p 4444:4444 -v "/path/to/your/code:/mnt/workspace" -e USE_AUTH=false --name lsproxy agenticlabs/lsproxy:0.3.5
- Use the SDK:
# Synchronous usage
from lsproxy import Lsproxy
lsp = Lsproxy()
# Async usage
from lsproxy import AsyncLsproxy
import asyncio
async def main():
async with AsyncLsproxy() as lsp:
# Use async methods
files = await lsp.list_files()
# Run the async code
asyncio.run(main())
List all files in the workspace
lsp.list_files()
Get symbols in a file
lsp.definitions_in_file(path="path/to/file.py")
Get references to a symbol
# Find all references to a symbol at a specific position
references = lsp.find_references(
GetReferencesRequest(
identifier_position=FilePosition(
file_path="path/to/file.py",
line=10,
character=15
),
include_code_context_lines=2, # Show 2 lines of context around each reference
include_declaration=True # Include the original declaration
)
)
# Print found references
for ref in references.references:
print(f"Reference in {ref.file_path} at line {ref.range.start.line}")
if ref.code_context:
print(ref.code_context)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lsproxy_sdk-0.3.1.tar.gz.
File metadata
- Download URL: lsproxy_sdk-0.3.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae6fb01e1891455a8cded009739245bcbdf8129fcb063e8c510b710ee18cf7e5
|
|
| MD5 |
e0a066bf664fcb19cfb9446901228804
|
|
| BLAKE2b-256 |
7a55b47720c5f28d854ba329bcc826cd7403afbb1465ab2048f3ef839f63a814
|
File details
Details for the file lsproxy_sdk-0.3.1-py3-none-any.whl.
File metadata
- Download URL: lsproxy_sdk-0.3.1-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56962e37a14773f0db55fde70a26aa526b80faa1ef25554f98446c405ba055f4
|
|
| MD5 |
1b44e56c189aeef431bbf1d13336387f
|
|
| BLAKE2b-256 |
9cca37faf59b4d7a09766e9f4c4c1f942460489aa50bc069e1cff56b18d983e0
|