avrae-ls 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- avrae_ls-0.2.1/LICENSE +21 -0
- avrae_ls-0.2.1/PKG-INFO +46 -0
- avrae_ls-0.2.1/README.md +27 -0
- avrae_ls-0.2.1/pyproject.toml +45 -0
- avrae_ls-0.2.1/setup.cfg +4 -0
- avrae_ls-0.2.1/src/avrae_ls/__init__.py +3 -0
- avrae_ls-0.2.1/src/avrae_ls/__main__.py +24 -0
- avrae_ls-0.2.1/src/avrae_ls/alias_preview.py +180 -0
- avrae_ls-0.2.1/src/avrae_ls/api.py +1911 -0
- avrae_ls-0.2.1/src/avrae_ls/argparser.py +417 -0
- avrae_ls-0.2.1/src/avrae_ls/argument_parsing.py +67 -0
- avrae_ls-0.2.1/src/avrae_ls/completions.py +572 -0
- avrae_ls-0.2.1/src/avrae_ls/config.py +437 -0
- avrae_ls-0.2.1/src/avrae_ls/context.py +150 -0
- avrae_ls-0.2.1/src/avrae_ls/cvars.py +115 -0
- avrae_ls-0.2.1/src/avrae_ls/diagnostics.py +465 -0
- avrae_ls-0.2.1/src/avrae_ls/dice.py +33 -0
- avrae_ls-0.2.1/src/avrae_ls/parser.py +39 -0
- avrae_ls-0.2.1/src/avrae_ls/runtime.py +460 -0
- avrae_ls-0.2.1/src/avrae_ls/server.py +353 -0
- avrae_ls-0.2.1/src/avrae_ls/signature_help.py +147 -0
- avrae_ls-0.2.1/src/avrae_ls/symbols.py +150 -0
- avrae_ls-0.2.1/src/avrae_ls.egg-info/PKG-INFO +46 -0
- avrae_ls-0.2.1/src/avrae_ls.egg-info/SOURCES.txt +46 -0
- avrae_ls-0.2.1/src/avrae_ls.egg-info/dependency_links.txt +1 -0
- avrae_ls-0.2.1/src/avrae_ls.egg-info/entry_points.txt +2 -0
- avrae_ls-0.2.1/src/avrae_ls.egg-info/requires.txt +10 -0
- avrae_ls-0.2.1/src/avrae_ls.egg-info/top_level.txt +2 -0
- avrae_ls-0.2.1/src/draconic/LICENSE +21 -0
- avrae_ls-0.2.1/src/draconic/__init__.py +4 -0
- avrae_ls-0.2.1/src/draconic/exceptions.py +157 -0
- avrae_ls-0.2.1/src/draconic/helpers.py +236 -0
- avrae_ls-0.2.1/src/draconic/interpreter.py +1091 -0
- avrae_ls-0.2.1/src/draconic/string.py +100 -0
- avrae_ls-0.2.1/src/draconic/types.py +364 -0
- avrae_ls-0.2.1/src/draconic/utils.py +78 -0
- avrae_ls-0.2.1/src/draconic/versions.py +4 -0
- avrae_ls-0.2.1/tests/test_alias_preview.py +96 -0
- avrae_ls-0.2.1/tests/test_api.py +50 -0
- avrae_ls-0.2.1/tests/test_argument_parsing.py +11 -0
- avrae_ls-0.2.1/tests/test_completions.py +30 -0
- avrae_ls-0.2.1/tests/test_cvars.py +61 -0
- avrae_ls-0.2.1/tests/test_diagnostics.py +146 -0
- avrae_ls-0.2.1/tests/test_gvars.py +43 -0
- avrae_ls-0.2.1/tests/test_hover.py +112 -0
- avrae_ls-0.2.1/tests/test_runtime.py +326 -0
- avrae_ls-0.2.1/tests/test_runtime_dice.py +37 -0
- avrae_ls-0.2.1/tests/test_symbols.py +21 -0
avrae_ls-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
avrae_ls-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: avrae-ls
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Language server for Avrae draconic aliases
|
|
5
|
+
Author: 1drturtle
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: pygls>=1.3.1
|
|
10
|
+
Requires-Dist: lsprotocol>=2023.0.1
|
|
11
|
+
Requires-Dist: httpx>=0.27
|
|
12
|
+
Requires-Dist: d20>=1.1.2
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest>=8.3; extra == "dev"
|
|
15
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-cov>=7.0.0; extra == "dev"
|
|
17
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# Avrae Draconic Alias Language Server
|
|
21
|
+
|
|
22
|
+
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!
|
|
23
|
+
|
|
24
|
+
## Install (released package)
|
|
25
|
+
|
|
26
|
+
- CLI/server via `uv tool` (preferred): `uv tool install avrae-ls` then `uv tool run avrae-ls --help` to see stdio/TCP options (same as `python -m avrae_ls`). The VS Code extension uses this invocation by default. The draconic interpreter is vendored, so no Git deps are needed.
|
|
27
|
+
|
|
28
|
+
## VS Code extension (released)
|
|
29
|
+
|
|
30
|
+
- 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.
|
|
31
|
+
- Open your alias workspace; commands like `Avrae: Show Alias Preview` and `Avrae: Run Alias` will be available.
|
|
32
|
+
|
|
33
|
+
## Developing locally
|
|
34
|
+
|
|
35
|
+
- Prereqs: [uv](https://github.com/astral-sh/uv) and Node.js.
|
|
36
|
+
- Install deps: `uv sync --all-extras` then `make vscode-deps`.
|
|
37
|
+
- Build everything locally: `make package` (wheel + VSIX in `dist/`).
|
|
38
|
+
- Run tests/lint: `make check`.
|
|
39
|
+
- Run via uv tool from source: `uv tool install --from . avrae-ls`.
|
|
40
|
+
|
|
41
|
+
## Releasing (maintainers)
|
|
42
|
+
|
|
43
|
+
1. Bump `pyproject.toml` version.
|
|
44
|
+
2. `make release` (clean, build, `twine check`, upload to PyPI).
|
|
45
|
+
3. Build and attach the VSIX to the GitHub release (`make vsix`).
|
|
46
|
+
4. Tag and push.
|
avrae_ls-0.2.1/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Avrae Draconic Alias Language Server
|
|
2
|
+
|
|
3
|
+
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!
|
|
4
|
+
|
|
5
|
+
## Install (released package)
|
|
6
|
+
|
|
7
|
+
- CLI/server via `uv tool` (preferred): `uv tool install avrae-ls` then `uv tool run avrae-ls --help` to see stdio/TCP options (same as `python -m avrae_ls`). The VS Code extension uses this invocation by default. The draconic interpreter is vendored, so no Git deps are needed.
|
|
8
|
+
|
|
9
|
+
## VS Code extension (released)
|
|
10
|
+
|
|
11
|
+
- 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.
|
|
12
|
+
- Open your alias workspace; commands like `Avrae: Show Alias Preview` and `Avrae: Run Alias` will be available.
|
|
13
|
+
|
|
14
|
+
## Developing locally
|
|
15
|
+
|
|
16
|
+
- Prereqs: [uv](https://github.com/astral-sh/uv) and Node.js.
|
|
17
|
+
- Install deps: `uv sync --all-extras` then `make vscode-deps`.
|
|
18
|
+
- Build everything locally: `make package` (wheel + VSIX in `dist/`).
|
|
19
|
+
- Run tests/lint: `make check`.
|
|
20
|
+
- Run via uv tool from source: `uv tool install --from . avrae-ls`.
|
|
21
|
+
|
|
22
|
+
## Releasing (maintainers)
|
|
23
|
+
|
|
24
|
+
1. Bump `pyproject.toml` version.
|
|
25
|
+
2. `make release` (clean, build, `twine check`, upload to PyPI).
|
|
26
|
+
3. Build and attach the VSIX to the GitHub release (`make vsix`).
|
|
27
|
+
4. Tag and push.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "avrae-ls"
|
|
7
|
+
version = "0.2.1"
|
|
8
|
+
description = "Language server for Avrae draconic aliases"
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "1drturtle" }
|
|
11
|
+
]
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
requires-python = ">=3.11"
|
|
15
|
+
dependencies = [
|
|
16
|
+
"pygls>=1.3.1",
|
|
17
|
+
"lsprotocol>=2023.0.1",
|
|
18
|
+
"httpx>=0.27",
|
|
19
|
+
"d20>=1.1.2",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
dev = [
|
|
24
|
+
"pytest>=8.3",
|
|
25
|
+
"pytest-asyncio>=0.23",
|
|
26
|
+
"pytest-cov>=7.0.0",
|
|
27
|
+
"ruff>=0.6",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
avrae-ls = "avrae_ls.__main__:main"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools.packages.find]
|
|
34
|
+
where = ["src"]
|
|
35
|
+
|
|
36
|
+
[tool.ruff]
|
|
37
|
+
line-length = 120
|
|
38
|
+
target-version = "py311"
|
|
39
|
+
exclude = [
|
|
40
|
+
"avrae",
|
|
41
|
+
"src/draconic"
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.package-data]
|
|
45
|
+
draconic = ["LICENSE"]
|
avrae_ls-0.2.1/setup.cfg
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
|
|
5
|
+
from .server import create_server
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main(argv: list[str] | None = None) -> None:
|
|
9
|
+
parser = argparse.ArgumentParser(description="Avrae draconic alias language server")
|
|
10
|
+
parser.add_argument("--tcp", action="store_true", help="Run in TCP mode instead of stdio")
|
|
11
|
+
parser.add_argument("--host", default="127.0.0.1", help="TCP host (when --tcp is set)")
|
|
12
|
+
parser.add_argument("--port", type=int, default=2087, help="TCP port (when --tcp is set)")
|
|
13
|
+
parser.add_argument("--stdio", action="store_true", help="Accept stdio flag for VS Code clients (ignored)")
|
|
14
|
+
args = parser.parse_args(argv)
|
|
15
|
+
|
|
16
|
+
server = create_server()
|
|
17
|
+
if args.tcp:
|
|
18
|
+
server.start_tcp(args.host, args.port)
|
|
19
|
+
else:
|
|
20
|
+
server.start_io()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if __name__ == "__main__":
|
|
24
|
+
main()
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import shlex
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Any, Optional, Tuple
|
|
7
|
+
|
|
8
|
+
from .parser import DRACONIC_RE
|
|
9
|
+
from .runtime import ExecutionResult, MockExecutor
|
|
10
|
+
from .context import ContextData, GVarResolver
|
|
11
|
+
from .argument_parsing import apply_argument_parsing
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class RenderedAlias:
|
|
16
|
+
command: str
|
|
17
|
+
stdout: str
|
|
18
|
+
error: Optional[BaseException]
|
|
19
|
+
last_value: Any | None = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _strip_alias_header(text: str) -> str:
|
|
23
|
+
lines = text.splitlines()
|
|
24
|
+
if lines and lines[0].lstrip().startswith("!alias"):
|
|
25
|
+
first = lines[0].lstrip()
|
|
26
|
+
parts = first.split(maxsplit=2)
|
|
27
|
+
remainder = parts[2] if len(parts) > 2 else ""
|
|
28
|
+
body = "\n".join(lines[1:])
|
|
29
|
+
if remainder:
|
|
30
|
+
return remainder + ("\n" + body if body else "")
|
|
31
|
+
return body
|
|
32
|
+
return text
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
async def render_alias_command(
|
|
36
|
+
text: str,
|
|
37
|
+
executor: MockExecutor,
|
|
38
|
+
ctx_data: ContextData,
|
|
39
|
+
resolver: GVarResolver,
|
|
40
|
+
args: list[str] | None = None,
|
|
41
|
+
) -> RenderedAlias:
|
|
42
|
+
"""Replace <drac2> blocks with their evaluated values and return final command."""
|
|
43
|
+
body = _strip_alias_header(text)
|
|
44
|
+
body = apply_argument_parsing(body, args)
|
|
45
|
+
stdout_parts: list[str] = []
|
|
46
|
+
parts: list[str] = []
|
|
47
|
+
last_value = None
|
|
48
|
+
error: BaseException | None = None
|
|
49
|
+
|
|
50
|
+
pos = 0
|
|
51
|
+
for match in DRACONIC_RE.finditer(body):
|
|
52
|
+
parts.append(body[pos: match.start()])
|
|
53
|
+
code = match.group(1)
|
|
54
|
+
result: ExecutionResult = await executor.run(code, ctx_data, resolver)
|
|
55
|
+
if result.stdout:
|
|
56
|
+
stdout_parts.append(result.stdout)
|
|
57
|
+
if result.error:
|
|
58
|
+
error = result.error
|
|
59
|
+
break
|
|
60
|
+
last_value = result.value
|
|
61
|
+
parts.append("" if result.value is None else str(result.value))
|
|
62
|
+
pos = match.end()
|
|
63
|
+
|
|
64
|
+
if error is None:
|
|
65
|
+
parts.append(body[pos:])
|
|
66
|
+
|
|
67
|
+
final_command = "".join(parts)
|
|
68
|
+
return RenderedAlias(command=final_command, stdout="".join(stdout_parts), error=error, last_value=last_value)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def validate_embed_payload(payload: str) -> Tuple[bool, str | None]:
|
|
72
|
+
"""
|
|
73
|
+
Light validation for embed previews using Avrae-style flags.
|
|
74
|
+
|
|
75
|
+
Accepts strings such as "-title Foo -f \"T|Body\"" and validates arguments.
|
|
76
|
+
Returns (is_valid, error_message) without attempting to parse JSON objects.
|
|
77
|
+
"""
|
|
78
|
+
text = payload.strip()
|
|
79
|
+
if not text:
|
|
80
|
+
return False, "Embed payload is empty."
|
|
81
|
+
|
|
82
|
+
return _validate_embed_flags(text)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _validate_embed_flags(text: str) -> Tuple[bool, str | None]:
|
|
86
|
+
"""Validate embed flags according to Avrae's help text."""
|
|
87
|
+
if not text:
|
|
88
|
+
return False, "Embed payload is empty."
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
tokens = shlex.split(text)
|
|
92
|
+
except ValueError as exc: # pragma: no cover - defensive only
|
|
93
|
+
return False, f"Embed payload could not be parsed: {exc}"
|
|
94
|
+
|
|
95
|
+
flag_handlers = {
|
|
96
|
+
"-title": lambda val: _require_value("-title", val),
|
|
97
|
+
"-desc": lambda val: _require_value("-desc", val),
|
|
98
|
+
"-thumb": lambda val: _require_value("-thumb", val),
|
|
99
|
+
"-image": lambda val: _require_value("-image", val),
|
|
100
|
+
"-footer": lambda val: _require_value("-footer", val),
|
|
101
|
+
"-f": _validate_field_arg,
|
|
102
|
+
"-color": _validate_color_arg,
|
|
103
|
+
"-t": _validate_timeout_arg,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
i = 0
|
|
107
|
+
while i < len(tokens):
|
|
108
|
+
tok = tokens[i]
|
|
109
|
+
key = tok.lower()
|
|
110
|
+
if not tok.startswith("-"):
|
|
111
|
+
i += 1
|
|
112
|
+
continue
|
|
113
|
+
if key not in flag_handlers:
|
|
114
|
+
return False, f"Embed payload contains unknown flag '{tok}'."
|
|
115
|
+
next_val = tokens[i + 1] if i + 1 < len(tokens) else None
|
|
116
|
+
ok, err, consumed = flag_handlers[key](next_val)
|
|
117
|
+
if not ok:
|
|
118
|
+
return False, err
|
|
119
|
+
i += consumed + 1
|
|
120
|
+
return True, None
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _require_value(flag: str, value: str | None) -> Tuple[bool, str | None, int]:
|
|
124
|
+
if value is None or value.startswith("-"):
|
|
125
|
+
return False, f"Embed flag '{flag}' requires a value.", 0
|
|
126
|
+
return True, None, 1
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _validate_field_arg(value: str | None) -> Tuple[bool, str | None, int]:
|
|
130
|
+
ok, err, consumed = _require_value("-f", value)
|
|
131
|
+
if not ok:
|
|
132
|
+
return ok, err, consumed
|
|
133
|
+
assert value is not None # for type checker
|
|
134
|
+
parts = value.split("|")
|
|
135
|
+
if len(parts) < 2 or len(parts) > 3:
|
|
136
|
+
return False, "Embed field must be in the form \"Title|Text[|inline]\".", consumed
|
|
137
|
+
if not parts[0] or not parts[1]:
|
|
138
|
+
return False, "Embed field title and text cannot be empty.", consumed
|
|
139
|
+
if len(parts) == 3 and parts[2].lower() not in ("inline", ""):
|
|
140
|
+
return False, "Embed field inline value must be 'inline' or omitted.", consumed
|
|
141
|
+
return True, None, consumed
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def _validate_color_arg(value: str | None) -> Tuple[bool, str | None, int]:
|
|
145
|
+
if value is None or value.startswith("-"):
|
|
146
|
+
# Random color is allowed when omitted
|
|
147
|
+
return True, None, 0
|
|
148
|
+
if not re.match(r"^(?:#|0x)?[0-9a-fA-F]{6}$", value):
|
|
149
|
+
return False, "Embed color must be a 6-hex value (e.g. #ff00ff).", 1
|
|
150
|
+
return True, None, 1
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _validate_timeout_arg(value: str | None) -> Tuple[bool, str | None, int]:
|
|
154
|
+
ok, err, consumed = _require_value("-t", value)
|
|
155
|
+
if not ok:
|
|
156
|
+
return ok, err, consumed
|
|
157
|
+
assert value is not None # for type checker
|
|
158
|
+
try:
|
|
159
|
+
num = int(value)
|
|
160
|
+
except ValueError:
|
|
161
|
+
return False, "Embed timeout (-t) must be an integer.", consumed
|
|
162
|
+
if num < 0 or num > 600:
|
|
163
|
+
return False, "Embed timeout (-t) must be between 0 and 600 seconds.", consumed
|
|
164
|
+
return True, None, consumed
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def simulate_command(command: str) -> tuple[str | None, str | None, str | None]:
|
|
168
|
+
"""Very small shim to preview common commands."""
|
|
169
|
+
text = command.strip()
|
|
170
|
+
if not text:
|
|
171
|
+
return None, None, None
|
|
172
|
+
head, *rest = text.split(maxsplit=1)
|
|
173
|
+
payload = rest[0] if rest else ""
|
|
174
|
+
lowered = head.lower()
|
|
175
|
+
if lowered == "echo":
|
|
176
|
+
return payload, "echo", None
|
|
177
|
+
if lowered == "embed":
|
|
178
|
+
valid, error = validate_embed_payload(payload)
|
|
179
|
+
return payload, "embed", error
|
|
180
|
+
return None, head, None
|