Language Server Protocol (LSP) implementation targeting Avrae-style draconic aliases. It provides syntax/semantic diagnostics, a mocked execution command, and a thin configuration layer driven by a workspace .avraels.json file. Credit to Avrae team for all code yoinked!
- CLI/server via
uv tool(preferred):uv tool install avrae-lsthenavrae-ls --helpto see stdio/TCP options (same aspython -m avrae_ls). The VS Code extension uses this invocation by default. The draconic interpreter is vendored, so no Git deps are needed.
- Install from VSIX: download
avrae-ls-client.vsixfrom the GitHub releases page, then in VS Code run “Extensions: Install from VSIX” and select the file. - Open your alias workspace; commands like
Avrae: Show Alias PreviewandAvrae: Run Aliaswill be available. - Files ending with
.alias-moduleare treated as full-file draconic modules under theavrae-modulelanguage id (no<drac2>tags; mock run/preview commands stay tied to.aliasfiles).
- Prereqs: uv and Node.js.
- Install deps:
uv sync --all-extrasthenmake vscode-deps. - Build everything locally:
make package(wheel + VSIX indist/). - Run tests/lint:
make check. - Run via uv tool from source:
uv tool install --from . avrae-ls. - Run diagnostics for a single file (stdout + stderr logs):
avrae-ls --analyze path/to/alias.txt --log-level DEBUG.
- Quick check (ruff + pytest):
make check(usesuv run ruffanduv run pytestunder the hood). - Lint only:
make lintoruv run ruff check src tests. - Tests only (with coverage):
make testoruv run pytest tests --cov=src. - CLI smoke test without installing:
uv run python -m avrae_ls --analyze path/to/alias.txt.
- Create files ending with
.alias-test(or.aliastest) next to your alias file. Each test starts with an invocation, followed by---and the expected result; you can stack multiple tests in one file by repeating this pattern (optional metadata after a second---per test).!my-alias -b example args --- expected text or number - For embed aliases, put a YAML/JSON dictionary after the separator to compare against the embed preview (partial dictionaries are allowed).
!embedtest --- title: Hello description: World - Embed fields lists can be partial: only the listed fields (in order) are matched; extra fields in the alias do not fail the test.
- Use regex expectations by wrapping strings in
/.../(orre:...). You can also mix literals with regex segments (e.g.,Hello /world.*/) so only the delimited part is treated as regex. - Optional second
---section can carry metadata:name: critical-hit vars: cvars: hp: 12 character: name: Testernameis a label for reporting,varsare merged into cvars/uvars/svars/gvars, andcharacterkeys are deep-merged into the mock character. - Run them with
avrae-ls --run-tests [path](defaults to the current directory); non-zero exit codes indicate failures.
.avraels.jsonvalues support environment variable substitution with$NAMEor${NAME}.workspaceRootandworkspaceFolderare injected automatically. Missing variables are replaced with an empty string and logged as warnings.
- Mock execution never writes back to Avrae: cvar/uvar/gvar mutations only live for the current run and reset before the next.
- Network is limited to gvar fetches (when
enableGvarFetchis true) andverify_signature; other Avrae/Discord calls are replaced with mocked context data from.avraels.json. get_gvar/usingvalues are pulled from local var files first; remote fetches go tohttps://api.avrae.io/customizations/gvars/<id>(or youravraeService.baseUrl) usingavraeService.tokenand are cached for the session.signature()returns a mock string (mock-signature:<int>).verify_signature()POSTs to/bot/signature/verify, reuses the last successful response per signature, and includesavraeService.tokenif present.
get_gvarreturnsNoneorusing(...)raisesModuleNotFoundError: ensure the workspace.avraels.jsonsetsenableGvarFetch: true, includes a validavraeService.token, or seed the gvar in a var file referenced byvarFiles.- HTTP 401/403/404 from fetch/verify calls: check the token (401/403) and the gvar/signature id (404). Override
avraeService.baseUrlif you mirror the API. - Slow or flaky calls: disable remote fetches by flipping
enableGvarFetchoff to rely purely on local vars.
- Any client can launch the server with stdio:
avrae-ls --stdio(flag accepted for client compatibility) orpython -m avrae_ls. The server will also auto-discover.avraels.jsonin parent folders. - Neovim (nvim-lspconfig example):
require("lspconfig").avraels.setup({ cmd = { "avrae-ls", "--stdio" }, filetypes = { "avrae" }, root_dir = require("lspconfig.util").root_pattern(".avraels.json", ".git"), })
- Emacs (lsp-mode snippet):
(lsp-register-client (make-lsp-client :new-connection (lsp-stdio-connection '("avrae-ls" "--stdio")) :major-modes '(fundamental-mode) ;; bind to your Avrae alias mode :server-id 'avrae-ls))
- VS Code commands to mirror:
Avrae: Run Alias (Mock),Avrae: Show Alias Preview,Avrae: Refresh GVARs, andAvrae: Reload Workspace Configrun against the same server binary.
- Bump
pyproject.toml/package.json - Create Github release