| name | dak-lsp |
| description | Use DelphiAIKit `lsp` for semantic Delphi symbol navigation through `definition`, `hover`, and file-scoped `symbols`, and route non-semantic questions to `deps`, `global-vars`, or text search instead of guessing. Prefer `dak-build` for compiler errors; `lsp` is the semantic enrichment helper, not the primary build signal. |
Delphi LSP
Use DelphiAIKit.exe lsp for one-shot semantic navigation against a real Delphi project context.
If DAK_EXE is missing, use dak-build setup.
Preflight:
test -x "$DAK_EXE" || { echo "DAK_EXE not executable"; exit 1; }
Route The Request
Use this routing before running commands:
| User intent | Use | Notes |
|---|
| "Where is this symbol defined?" | lsp definition --format json | Requires --file, --line, --col |
| "Who references this symbol?" | switch skill | External Delphi 23 and Delphi 13 DelphiLSP.exe do not implement textDocument/references; use deps, global-vars, or rg instead |
| "What does this symbol mean here?" | lsp hover --format json | Use when hover/type text matters |
| "Find symbols matching this name" | lsp symbols --format json | File-scoped on Delphi 23 external DelphiLSP.exe; pass --file, then use --query and optional --limit |
| "A build error needs semantic hints" | dak-build | Let build --ai try best-effort lsp enrichment first; missing or empty LSP data is normal and must not be treated as a new error |
| "What depends on what?" / "Do we have cycles?" | switch skill | dak-project-unit-topology |
| "Who reads or writes this global?" | switch skill | dak-global-vars |
| broad raw text / regex search | text search | use rg, not lsp |
Start with JSON unless the user explicitly wants a quick terminal summary.
Platform/Config
Pass --platform and --config when the target project requires a non-default context. For DelphiAIKit itself, use --platform Win64.
Command Patterns
Definition:
"$DAK_EXE" lsp definition --project "<path-to-project.dproj>" --file "<path-to-unit.pas>" --line 42 --col 17 --format json
Hover:
"$DAK_EXE" lsp hover --project "<path-to-project.dproj>" --file "<path-to-unit.pas>" --line 42 --col 17 --format json
Symbols:
"$DAK_EXE" lsp symbols --project "<path-to-project.dproj>" --file "<path-to-unit.pas>" --query "Customer" --limit 20 --format json
Rules
- Always pass a real Delphi project with
--project/--dproj; lsp is project-context-driven, not file-only.
--line and --col are 1-based.
symbols is file-scoped on Delphi 23 external DelphiLSP.exe; pass --file and read the result as textDocument/documentSymbol, not as workspace-wide search.
- Do not use
lsp for references/usages. External Delphi 23 (23.0) and Delphi 13 (37.0) DelphiLSP.exe do not advertise referencesProvider, and direct textDocument/references requests return -32601 Method not found.
--rsvars and --envoptions are optional advanced overrides. Do not add them unless normal context discovery fails or we need reproducible nonstandard setup.
- DAK owns generated context and logs under sibling
.dak/<ProjectName>/lsp/. Do not create ad hoc .delphilsp.json files beside the source project for normal use.
lsp hard-fails when DAK cannot build a real Delphi semantic context. Do not treat that as equivalent to deps, global-vars, or text search.
hover may return empty content on some positions even when the capability exists. Treat that as a non-answer, not a transport failure.
- When build output already includes compiler diagnostics, use
lsp only as enrichment. Empty, unsupported, or errored semantic lookups should be ignored silently by the build path.
- Current external-server guidance is based on verified Delphi 23 (
23.0) and Delphi 13 (37.0) behavior: definition, hover, and file-scoped documentSymbol work; textDocument/references and workspace/symbol do not.
- Do not emulate raw JSON-RPC or call
DelphiLSP.exe directly when DelphiAIKit.exe lsp can answer the question.
Read The JSON
The important result fields are:
definition: result.locations[]
hover: result.contentsText, optional result.contentsMarkdown, optional result.range
symbols: result.symbols[] from file-scoped documentSymbol output
Use the normalized DAK fields (file, line, col, and related range fields) instead of reasoning about raw LSP URIs or 0-based coordinates.