Skip to main content

Avrae Draconic Alias Language Server

Tests

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!

VS Code extension

  • Install from VSIX: download avrae-ls-client.vsix from the GitHub releases page, then in VS Code run “Extensions: Install from VSIX” and select the file. The VSIX already contains avrae-ls and its runtime dependencies; no uv, pip, or separate server installation is required.
  • Python 3.11 or newer must be available as python3 on macOS/Linux or python on Windows. The extension uses that interpreter only to run its bundled server package.
  • To use a development or custom server instead, set avraeLS.server.path to the absolute path of an avrae-ls executable (for example, a virtual environment's bin/avrae-ls). A configured path takes precedence over the bundled server.
  • Open your alias workspace; commands like Avrae: Show Alias Preview and Avrae: Run Alias will be available.
  • With a .alias-test, .aliastest, .gvar-test, or .gvartest file active, run Avrae: Run Test File from the Command Palette. The extension saves the file, runs that file only, and shows the full report in the Avrae Test Results output window.
  • Files ending with .alias-module are treated as full-file draconic modules under the avrae-module language id (no <drac2> tags; mock run/preview commands stay tied to .alias files).

Install Just the LSP

  • CLI/server via uv tool (preferred): uv tool install avrae-ls then avrae-ls --help to see stdio/TCP options (same as python -m avrae_ls).

Developing locally

  • Prereqs: uv and Node.js.
  • Install deps: uv sync --all-extras then make vscode-deps.
  • Build everything locally: make package (wheel + VSIX in dist/).
  • 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.

How to test

  • Quick check (ruff + pytest): make check (uses uv run ruff and uv run pytest under the hood).
  • Lint only: make lint or uv run ruff check src tests.
  • Tests only (with coverage): make test or uv run pytest tests --cov=src.
  • CLI smoke test without installing: uv run python -m avrae_ls --analyze path/to/alias.txt.

Alias and gvar tests

  • avrae-ls --run-tests [path] discovers both alias tests and gvar tests and exits non-zero on failures; repeat --run-tests to add more scan roots.
  • Alias tests use .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 numbers
    
  • Gvar tests use .gvar-test or .gvartest next to a sibling .gvar file with the same stem. The test body runs after an implicit using(...) import of that module under a sanitized local binding name.
    return my_module.constant
    ---
    expected value
    
  • A gvar named foo-bar.gvar is exposed to tests as foo_bar; a leading digit becomes gvar_<stem>.
  • Multi-case .gvar-test files are supported. Separate cases with a second ---, then a blank line before the next test body. Metadata after the second --- is optional.
  • 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 /.../ (or re:...). 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: Tester
    
    name is a label for reporting, vars are merged into cvars/uvars/svars/gvars, and character keys are deep-merged into the mock character.
  • Gvar tests compare the direct execution result of the test body, not alias preview/embed output.

Config variable substitution

  • .avraels.json values support environment variable substitution with $NAME or ${NAME}. workspaceRoot and workspaceFolder are injected automatically. Missing variables are replaced with an empty string and logged as warnings.

Runtime differences (mock vs. live Avrae)

  • 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 enableGvarFetch is true) and verify_signature; other Avrae/Discord calls are replaced with mocked context data from .avraels.json.
  • get_gvar/using values are pulled from local var files first; remote fetches go to https://api.avrae.io/customizations/gvars/<id> (or your avraeService.baseUrl) using avraeService.token and are cached for the session. In var files, a gvar can be a direct value, a { "value": "..." } object, or a { "filePath": "relative/or/absolute/path" } object (also supports "path"). Add "scriptWritable": true to either object form to allow set_gvar(...) during mock execution.
  • Mock scripting now supports create_gvar(value, script_writable=False) and set_gvar(address, value). Gvar writes only affect the current run; they do not persist to Avrae or local var files.
  • signature() returns a mock string (mock-signature:<int>). verify_signature() POSTs to /bot/signature/verify, reuses the last successful response per signature, and includes avraeService.token if present.

Troubleshooting gvar fetch / verify_signature

  • get_gvar returns None or using(...) raises ModuleNotFoundError: ensure the workspace .avraels.json sets enableGvarFetch: true, includes a valid avraeService.token, or seed the gvar in a var file referenced by varFiles (including filePath gvar entries).
  • HTTP 401/403/404 from fetch/verify calls: check the token (401/403) and the gvar/signature id (404). Override avraeService.baseUrl if you mirror the API.
  • Slow or flaky calls: disable remote fetches by flipping enableGvarFetch off to rely purely on local vars.

Other editors (stdio)

  • Any client can launch the server with stdio: avrae-ls --stdio (flag accepted for client compatibility) or python -m avrae_ls. The server will also auto-discover .avraels.json in 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: Run Test File, Avrae: Show Alias Preview, Avrae: Refresh GVARs, and Avrae: Reload Workspace Config run against the same server binary.

Releasing (maintainers)

  1. Bump pyproject.toml / package.json
  2. Create Github release

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

avrae_ls-0.14.0.tar.gz (116.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

avrae_ls-0.14.0-py3-none-any.whl (136.7 kB view details)

Uploaded Python 3

File details

Details for the file avrae_ls-0.14.0.tar.gz.

File metadata

  • Download URL: avrae_ls-0.14.0.tar.gz
  • Upload date:
  • Size: 116.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for avrae_ls-0.14.0.tar.gz
Algorithm Hash digest
SHA256 a9157c90e4686503fbd1a8a4b906719bd5f3f5eba333f69a1ee31a2ad2eb8976
MD5 8752622f29397294455bd33f3ad11143
BLAKE2b-256 7fec169e38e872cf20b84a80cb6807462a5e38923eb24a428617dd2883d0b210

See more details on using hashes here.

File details

Details for the file avrae_ls-0.14.0-py3-none-any.whl.

File metadata

  • Download URL: avrae_ls-0.14.0-py3-none-any.whl
  • Upload date:
  • Size: 136.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for avrae_ls-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4735c85517959d99785046353179e39b12038a5402ebbc1bfa85b9ef26e2b94
MD5 af741597af7d5972bef26df3c10ecfa4
BLAKE2b-256 c39d3f63dd6b8411625f4dd9173d346995cccc4236b2c92b399d5e75203c7e3d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.14.0 This release

2 files

0.13.1

2 files

0.13.0

2 files

0.12.1

2 files

0.12.0

2 files

0.11.0

2 files

0.10.1

2 files

0.10.0

2 files

0.9.6

2 files

0.9.5

2 files

0.9.4

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.7.1

2 files

0.7.0

2 files

0.6.4

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page