Language Server Protocol - CLI
Tuanjie AI enhances the Agent's code understanding capabilities through LSP (Language Server Protocol). The LSP Server is responsible for parsing project code, maintaining symbol indexes, and providing Tuanjie AI with capabilities such as definition navigation, reference lookup, Hover information, symbol search, implementation lookup, and call hierarchy.
Workflow Diagram
Tuanjie AI Agent / User Commands
-> Tuanjie AI Built-in LSP Client
-> LSP Extension Configuration
-> External LSP Server
-> Project Source Code
Codely CLI includes a universal LSP Client but does not directly include LSP Servers for all languages. To use complete LSP functionality, you also need to download the Extension for the corresponding language from the Tuanjie AI marketplace, as well as the LSP Server for that language. The LSP Extension contains recommended download paths for LSP Servers, which you can manually download.
Preparation Before Use
- Download and install LSP extension
/extensions install <extension_path>
If the Extension is enabled, Tuanjie AI will load the LSP configuration within it and initialize the LSP Manager at startup. Refreshing the Extension will also reload the LSP configuration.
/extensions refresh
You can also download the required LSP Extension from the Tuanjie AI marketplace
/extensions explore
How Agents Use LSP
LSP capabilities are registered in Tuanjie AI's tool system as an lsp tool. When Agents need to understand code structure, they automatically call it to complete the task. In the CLI environment, you usually do not need to manually use LSP functionality. The LSP client provides the following capabilities for Agents:
definitionGo to definition: Find the actual definition location of symbols.refsFind references: Analyze the impact of changes.hoverHover: Read type, documentation, and signature information.symbolsDocument symbols: View structures such as classes, functions, and fields within a single file.ws-symbolWorkspace symbols: Search symbols across the workspace.implFind implementations: Locate implementations of interfaces, abstract classes, or virtual methods.incoming/outgoingCall hierarchy: Analyze a function's incoming and outgoing call relationships.
You can also manually debug the same capabilities through the /lsp command.
/lsp Command
/lsp definition <file> <line> <char>
/lsp refs <file> <line> <char>
/lsp hover <file> <line> <char>
/lsp symbols <file>
/lsp ws-symbol <file> [query]
/lsp impl <file> <line> <char>
/lsp prepare <file> <line> <char>
/lsp incoming <file> <line> <char>
/lsp outgoing <file> <line> <char>
/lsp status
Parameter descriptions:
<file>can be a relative path or an absolute path. Relative paths are resolved relative to the current Codely CLI workspace.- Both
<line>and<char>start counting from1. [query]forws-symbolis optional; an empty query will be sent if not provided.
Examples:
/lsp definition src/index.ts 10 5
/lsp refs src/index.ts 10 5
/lsp hover src/index.ts 10 5
/lsp symbols src/index.ts
/lsp ws-symbol src/index.ts UserService
/lsp impl src/types.ts 8 12
/lsp prepare src/service.ts 20 3
/lsp incoming src/service.ts 20 3
/lsp outgoing src/service.ts 20 3
Troubleshooting
If /lsp status shows No LSP servers configured, it means no Extension containing lspServers is currently enabled.
If the server fails to start, check the following:
- Whether
commandis in thePATHof the current shell. - Whether
argsmatch the startup method of the LSP Server. - Whether
workspaceFolderexists. - Whether
extensionToLanguagecontains the current file extension. - Whether the target file is within the current workspace and the file size does not exceed LSP tool limits.