avrae-ls 0.7.1__py3-none-any.whl → 0.8.1__py3-none-any.whl

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/context.py CHANGED
@@ -14,6 +14,7 @@ from .config import AvraeLSConfig, ContextProfile, VarSources
14
14
  from .cvars import derive_character_cvars
15
15
 
16
16
  log = logging.getLogger(__name__)
17
+ _SKIP_GVAR = object()
17
18
 
18
19
 
19
20
  @dataclass
@@ -63,7 +64,7 @@ class ContextBuilder:
63
64
  data = _read_json_file(path)
64
65
  if data is None:
65
66
  continue
66
- merged = merged.merge(VarSources.from_data(data))
67
+ merged = merged.merge(_var_sources_from_file(path, data))
67
68
  return merged
68
69
 
69
70
  def _merge_character_cvars(self, character: Dict[str, Any], vars: VarSources) -> VarSources:
@@ -366,3 +367,49 @@ def _read_json_file(path: Path) -> Dict[str, Any] | None:
366
367
  except json.JSONDecodeError as exc:
367
368
  log.warning("Failed to parse var file %s: %s", path, exc)
368
369
  return None
370
+
371
+
372
+ def _var_sources_from_file(path: Path, data: Dict[str, Any]) -> VarSources:
373
+ parsed = VarSources.from_data(data)
374
+ return VarSources(
375
+ cvars=parsed.cvars,
376
+ uvars=parsed.uvars,
377
+ svars=parsed.svars,
378
+ gvars=_resolve_gvar_file_refs(path, parsed.gvars),
379
+ )
380
+
381
+
382
+ def _resolve_gvar_file_refs(var_file: Path, gvars: Dict[str, Any]) -> Dict[str, Any]:
383
+ resolved: dict[str, Any] = {}
384
+ for key, value in gvars.items():
385
+ parsed = _parse_gvar_value(var_file, key, value)
386
+ if parsed is _SKIP_GVAR:
387
+ continue
388
+ resolved[str(key)] = parsed
389
+ return resolved
390
+
391
+
392
+ def _parse_gvar_value(var_file: Path, key: Any, value: Any) -> Any:
393
+ if not isinstance(value, dict):
394
+ return value
395
+
396
+ file_path = value.get("filePath")
397
+ if file_path is None:
398
+ file_path = value.get("path")
399
+ if file_path is None:
400
+ return value
401
+ if not isinstance(file_path, str) or not file_path.strip():
402
+ log.warning("Invalid gvar file path for '%s' in %s; expected a non-empty string.", key, var_file)
403
+ return _SKIP_GVAR
404
+
405
+ gvar_path = Path(file_path)
406
+ if not gvar_path.is_absolute():
407
+ gvar_path = var_file.parent / gvar_path
408
+ try:
409
+ return gvar_path.read_text()
410
+ except FileNotFoundError:
411
+ log.warning("Gvar content file not found for '%s': %s", key, gvar_path)
412
+ return _SKIP_GVAR
413
+ except OSError as exc:
414
+ log.warning("Failed to read gvar content file for '%s' (%s): %s", key, gvar_path, exc)
415
+ return _SKIP_GVAR
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: avrae-ls
3
- Version: 0.7.1
3
+ Version: 0.8.1
4
4
  Summary: Language server for Avrae draconic aliases
5
5
  Author: 1drturtle
6
6
  License: MIT License
@@ -40,6 +40,8 @@ Description-Content-Type: text/markdown
40
40
 
41
41
  # Avrae Draconic Alias Language Server
42
42
 
43
+ [![Tests](https://github.com/1drturtle/avrae-ls/actions/workflows/ci.yml/badge.svg)](https://github.com/1drturtle/avrae-ls/actions/workflows/ci.yml)
44
+
43
45
  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!
44
46
 
45
47
  ## Install (released package)
@@ -105,12 +107,12 @@ Language Server Protocol (LSP) implementation targeting Avrae-style draconic ali
105
107
 
106
108
  - Mock execution never writes back to Avrae: cvar/uvar/gvar mutations only live for the current run and reset before the next.
107
109
  - 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`.
108
- - `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.
110
+ - `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 or a `{ "filePath": "relative/or/absolute/path" }` object (also supports `"path"`) that loads file contents as the gvar value.
109
111
  - `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.
110
112
 
111
113
  ## Troubleshooting gvar fetch / verify_signature
112
114
 
113
- - `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`.
115
+ - `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).
114
116
  - 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.
115
117
  - Slow or flaky calls: disable remote fetches by flipping `enableGvarFetch` off to rely purely on local vars.
116
118
 
@@ -10,7 +10,7 @@ avrae_ls/code_actions.py,sha256=MLZ5euETh2G4lRO33QkHnIwWPt-XlXMCqy-BlRXz0pk,9562
10
10
  avrae_ls/codes.py,sha256=iPRPQ6i9DZheae4_ra1y29vCw3Y4SEu6Udf5WiZj_RY,136
11
11
  avrae_ls/completions.py,sha256=YJNK85MkFRJAf7IzltdcWnoKv3jMtFEoIsJwt-hnXJM,25062
12
12
  avrae_ls/config.py,sha256=PJakf5JF7dbq1NbSFkoobgjKLzazyyMCyfveoqKzoLU,16810
13
- avrae_ls/context.py,sha256=0IrGNqZH1hJF7o4f8TfJNzpWURtgYB7y_0UvZhWRxeo,13732
13
+ avrae_ls/context.py,sha256=gsSi2ExDVRItzuWoMgRhUf2FqqlkxATFDXgPOF-VcoE,15298
14
14
  avrae_ls/cvars.py,sha256=0tcVbUHx_CKJ6aou3kEsKX37LRWAjkUWlqqIuSRFlXk,3197
15
15
  avrae_ls/diagnostics.py,sha256=7B5rL_zu3UByPD1GrGFK5cr6dOQYXz2b362x9MZgUEk,26990
16
16
  avrae_ls/dice.py,sha256=DY7V7L-EwAXaCgddgVe9xU1s9lVtiw5Zc2reipNgdTk,874
@@ -32,8 +32,8 @@ draconic/string.py,sha256=kGrRc6wNHRq1y5xw8Os-fBhfINDtIY2nBWQWkyLSfQI,2858
32
32
  draconic/types.py,sha256=1Lsr6z8bW5agglGI4hLt_nPtYuZOIf_ueSpPDB4WDrs,13686
33
33
  draconic/utils.py,sha256=D4vJ-txqS2-rlqsEpXAC46_j1sZX4UjY-9zIgElo96k,3122
34
34
  draconic/versions.py,sha256=CUEsgUWjAmjez0432WwiBwZlIzWPIObwZUf8Yld18EE,84
35
- avrae_ls-0.7.1.dist-info/METADATA,sha256=2opuMIj8XeU1LZTgKhHLNwObrVojcrQ04BaPhlMnX-o,7624
36
- avrae_ls-0.7.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
37
- avrae_ls-0.7.1.dist-info/entry_points.txt,sha256=OtYXipMQzqmxpMoApgo0MeJYFmMbkbFN51Ibhpb8hF4,52
38
- avrae_ls-0.7.1.dist-info/licenses/LICENSE,sha256=O-0zMbcEi6wXz1DiSdVgzMlQjJcNqNe5KDv08uYzqR0,1055
39
- avrae_ls-0.7.1.dist-info/RECORD,,
35
+ avrae_ls-0.8.1.dist-info/METADATA,sha256=HmuearSQW6CJEYhxN-qz-MSGvDhh_4Q_KhAVwtd7hiw,7980
36
+ avrae_ls-0.8.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
37
+ avrae_ls-0.8.1.dist-info/entry_points.txt,sha256=OtYXipMQzqmxpMoApgo0MeJYFmMbkbFN51Ibhpb8hF4,52
38
+ avrae_ls-0.8.1.dist-info/licenses/LICENSE,sha256=O-0zMbcEi6wXz1DiSdVgzMlQjJcNqNe5KDv08uYzqR0,1055
39
+ avrae_ls-0.8.1.dist-info/RECORD,,