intentumdiff-python 0.0.1__py3-none-win_amd64.whl → 0.0.3b1__py3-none-win_amd64.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.
- intentumdiff/__init__.py +9 -0
- intentumdiff/__main__.py +12 -0
- intentumdiff/_differ_gate.py +0 -136
- intentumdiff/_differ_presentation.py +17 -735
- intentumdiff/_differ_runtime.py +13 -64
- intentumdiff/analysis/compile_commands.py +26 -141
- intentumdiff/analysis/cross_file.py +23 -25
- intentumdiff/analysis/diagnostics.py +1 -164
- intentumdiff/analysis/guardrail_reports.py +31 -33
- intentumdiff/analysis/guardrails.py +111 -188
- intentumdiff/analysis/schema_resolver.py +72 -360
- intentumdiff/analysis/user_schemas.py +57 -254
- intentumdiff/api.py +21 -0
- intentumdiff/cache/sqlite_store.py +5 -23
- intentumdiff/cli/__init__.py +59 -0
- intentumdiff/cli/_commands.py +243 -137
- intentumdiff/cli/_parser.py +51 -56
- intentumdiff/cli/_shared.py +151 -116
- intentumdiff/content_type.py +13 -30
- intentumdiff/core/commit_differ.py +137 -286
- intentumdiff/core/diffignore.py +28 -34
- intentumdiff/core/index.py +16 -18
- intentumdiff/core/indexer.py +148 -169
- intentumdiff/core/models.py +279 -83
- intentumdiff/differ.py +366 -1000
- intentumdiff/github_app.py +40 -27
- intentumdiff/intentumdiff_rust_core/intentumdiff_rust_core.dll +0 -0
- intentumdiff/live_server.py +197 -34
- intentumdiff/lsp/client.py +49 -43
- intentumdiff/lsp/enricher.py +19 -119
- intentumdiff/lsp/exceptions.py +6 -7
- intentumdiff/lsp/servers.py +10 -11
- intentumdiff/lsp_server/_codelens.py +24 -57
- intentumdiff/lsp_server/_diagnostics.py +23 -51
- intentumdiff/lsp_server/_handlers.py +67 -9
- intentumdiff/lsp_server/server.py +28 -8
- intentumdiff/plugins/adapter.py +5 -0
- intentumdiff/plugins/builtins.py +7 -14
- intentumdiff/plugins/exceptions.py +28 -0
- intentumdiff/plugins/hub.py +39 -43
- intentumdiff/plugins/loader.py +229 -215
- intentumdiff/plugins/registry.py +259 -207
- intentumdiff/plugins/registry.schema.json +156 -15
- intentumdiff/plugins/registry_schema.py +47 -140
- intentumdiff/rust_core.py +623 -1326
- intentumdiff/serve/_app.py +26 -35
- intentumdiff/sources/base.py +24 -0
- intentumdiff/sources/file_source.py +15 -2
- intentumdiff/sources/git_source.py +64 -185
- intentumdiff/sources/live_buffer_source.py +45 -5
- intentumdiff/sources/patch_source.py +36 -109
- intentumdiff/vcs/_safe_path.py +7 -0
- intentumdiff/vcs/base.py +6 -0
- intentumdiff/vcs/git_backend.py +1 -1
- intentumdiff/vcs/git_cli.py +0 -27
- intentumdiff/vcs/hg_backend.py +1 -1
- intentumdiff/vcs/perforce_backend.py +7 -1
- intentumdiff/vcs/svn_backend.py +1 -1
- intentumdiff/wasm/abap_parser.wasm +0 -0
- intentumdiff/wasm/adf_parser.wasm +0 -0
- intentumdiff/wasm/asciidoc_parser.wasm +0 -0
- intentumdiff/wasm/asm_parser.wasm +0 -0
- intentumdiff/wasm/assemblyscript_parser.wasm +0 -0
- intentumdiff/wasm/astro_parser.wasm +0 -0
- intentumdiff/wasm/bash_parser.wasm +0 -0
- intentumdiff/wasm/clojure_parser.wasm +0 -0
- intentumdiff/wasm/cmake_parser.wasm +0 -0
- intentumdiff/wasm/cpp_parser.wasm +0 -0
- intentumdiff/wasm/csharp_parser.wasm +0 -0
- intentumdiff/wasm/css_parser.wasm +0 -0
- intentumdiff/wasm/dart_parser.wasm +0 -0
- intentumdiff/wasm/databricks_parser.wasm +0 -0
- intentumdiff/wasm/dax_parser.wasm +0 -0
- intentumdiff/wasm/delphi_parser.wasm +0 -0
- intentumdiff/wasm/dockerfile_parser.wasm +0 -0
- intentumdiff/wasm/elixir_parser.wasm +0 -0
- intentumdiff/wasm/freebasic_parser.wasm +0 -0
- intentumdiff/wasm/generic_parser.wasm +0 -0
- intentumdiff/wasm/gitignore_parser.wasm +0 -0
- intentumdiff/wasm/go_parser.wasm +0 -0
- intentumdiff/wasm/gomod_parser.wasm +0 -0
- intentumdiff/wasm/graphql_parser.wasm +0 -0
- intentumdiff/wasm/groovy_parser.wasm +0 -0
- intentumdiff/wasm/haskell_parser.wasm +0 -0
- intentumdiff/wasm/html_parser.wasm +0 -0
- intentumdiff/wasm/html_renderer.wasm +0 -0
- intentumdiff/wasm/ini_parser.wasm +0 -0
- intentumdiff/wasm/java_parser.wasm +0 -0
- intentumdiff/wasm/js_ts_parser.wasm +0 -0
- intentumdiff/wasm/json_parser.wasm +0 -0
- intentumdiff/wasm/kotlin_parser.wasm +0 -0
- intentumdiff/wasm/latex_parser.wasm +0 -0
- intentumdiff/wasm/llm_renderer.wasm +0 -0
- intentumdiff/wasm/lua_parser.wasm +0 -0
- intentumdiff/wasm/make_parser.wasm +0 -0
- intentumdiff/wasm/markdown_parser.wasm +0 -0
- intentumdiff/wasm/mdx_parser.wasm +0 -0
- intentumdiff/wasm/ocaml_parser.wasm +0 -0
- intentumdiff/wasm/odin_parser.wasm +0 -0
- intentumdiff/wasm/parser_manifest.json +81 -2
- intentumdiff/wasm/patch_renderer.wasm +0 -0
- intentumdiff/wasm/perl_parser.wasm +0 -0
- intentumdiff/wasm/php_parser.wasm +0 -0
- intentumdiff/wasm/plsql_parser.wasm +0 -0
- intentumdiff/wasm/po_parser.wasm +0 -0
- intentumdiff/wasm/postscript_parser.wasm +0 -0
- intentumdiff/wasm/powershell_parser.wasm +0 -0
- intentumdiff/wasm/proto_parser.wasm +0 -0
- intentumdiff/wasm/puppet_parser.wasm +0 -0
- intentumdiff/wasm/python_parser.wasm +0 -0
- intentumdiff/wasm/qsharp_parser.wasm +0 -0
- intentumdiff/wasm/r_parser.wasm +0 -0
- intentumdiff/wasm/reasonml_parser.wasm +0 -0
- intentumdiff/wasm/ruby_parser.wasm +0 -0
- intentumdiff/wasm/rust_parser.wasm +0 -0
- intentumdiff/wasm/sas_parser.wasm +0 -0
- intentumdiff/wasm/scala_parser.wasm +0 -0
- intentumdiff/wasm/scss_parser.wasm +0 -0
- intentumdiff/wasm/sql_parser.wasm +0 -0
- intentumdiff/wasm/squirrel_parser.wasm +0 -0
- intentumdiff/wasm/svelte_parser.wasm +0 -0
- intentumdiff/wasm/swift_parser.wasm +0 -0
- intentumdiff/wasm/terminal_renderer.wasm +0 -0
- intentumdiff/wasm/terraform_parser.wasm +0 -0
- intentumdiff/wasm/toml_parser.wasm +0 -0
- intentumdiff/wasm/tsql_parser.wasm +0 -0
- intentumdiff/wasm/vbnet_parser.wasm +0 -0
- intentumdiff/wasm/vue_parser.wasm +0 -0
- intentumdiff/wasm/wasm_provenance.json +884 -0
- intentumdiff/wasm/wat_parser.wasm +0 -0
- intentumdiff/wasm/xml_parser.wasm +0 -0
- intentumdiff/wasm/yaml_parser.wasm +0 -0
- intentumdiff/wasm/zig_parser.wasm +0 -0
- intentumdiff/watcher.py +15 -17
- intentumdiff_python-0.0.3b1.dist-info/METADATA +188 -0
- intentumdiff_python-0.0.3b1.dist-info/RECORD +164 -0
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.3b1.dist-info}/WHEEL +1 -1
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.3b1.dist-info}/sboms/intentumdiff-rust-core.cyclonedx.json +905 -379
- intentumdiff/analysis/invariances.py +0 -1207
- intentumdiff/analysis/keyed_profiles.py +0 -25
- intentumdiff/analysis/resource_profiles.py +0 -14
- intentumdiff/analysis/text_review.py +0 -46
- intentumdiff/core/cst_serializer.py +0 -101
- intentumdiff/invariances/__init__.py +0 -2
- intentumdiff/invariances/rules.schema.json +0 -283
- intentumdiff/invariances/rules.yaml +0 -349
- intentumdiff_python-0.0.1.dist-info/METADATA +0 -112
- intentumdiff_python-0.0.1.dist-info/RECORD +0 -165
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.3b1.dist-info}/entry_points.txt +0 -0
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.3b1.dist-info}/licenses/LICENSE +0 -0
|
@@ -30,12 +30,12 @@ except ImportError:
|
|
|
30
30
|
from intentumdiff.core.models import DiffConfig
|
|
31
31
|
from intentumdiff.differ import SemanticDiffer
|
|
32
32
|
from intentumdiff.lsp_server._codelens import semantic_diff_to_codelens
|
|
33
|
-
from intentumdiff.lsp_server._diagnostics import semantic_diff_to_diagnostics
|
|
34
33
|
from intentumdiff.lsp_server._handlers import (
|
|
35
34
|
_ServerState,
|
|
36
35
|
_do_diff,
|
|
37
36
|
schedule_diff,
|
|
38
37
|
uri_to_path,
|
|
38
|
+
WorkspaceContainmentError,
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
log = logging.getLogger(__name__)
|
|
@@ -117,6 +117,7 @@ def create_server(
|
|
|
117
117
|
def _did_close(params: lsp_types.DidCloseTextDocumentParams) -> None:
|
|
118
118
|
uri = params.text_document.uri
|
|
119
119
|
state.diff_cache.pop(uri, None)
|
|
120
|
+
state.source_cache.pop(uri, None)
|
|
120
121
|
task = state.pending_tasks.pop(uri, None)
|
|
121
122
|
if task is not None and not task.done():
|
|
122
123
|
task.cancel()
|
|
@@ -134,7 +135,20 @@ def create_server(
|
|
|
134
135
|
diff = state.diff_cache.get(uri)
|
|
135
136
|
if diff is None:
|
|
136
137
|
return []
|
|
137
|
-
|
|
138
|
+
sources = state.source_cache.get(uri)
|
|
139
|
+
if sources is None:
|
|
140
|
+
from intentumdiff.lsp_server._handlers import _invalidate_failed_review
|
|
141
|
+
_invalidate_failed_review(server, state, uri)
|
|
142
|
+
return []
|
|
143
|
+
try:
|
|
144
|
+
return semantic_diff_to_codelens(
|
|
145
|
+
diff, old_source=sources[0], new_source=sources[1],
|
|
146
|
+
)
|
|
147
|
+
except Exception as exc:
|
|
148
|
+
log.warning("intentumdiff: Rust CodeLens mapping failed for %s: %s", uri, exc)
|
|
149
|
+
from intentumdiff.lsp_server._handlers import _invalidate_failed_review
|
|
150
|
+
_invalidate_failed_review(server, state, uri)
|
|
151
|
+
return []
|
|
138
152
|
|
|
139
153
|
# ------------------------------------------------------------------
|
|
140
154
|
# Custom request: intentumdiff/semanticDiff
|
|
@@ -168,7 +182,7 @@ def create_server(
|
|
|
168
182
|
diff = _do_diff(state, server, new_uri, content)
|
|
169
183
|
else:
|
|
170
184
|
# Different URIs — read both from disk and compare.
|
|
171
|
-
from intentumdiff.sources.
|
|
185
|
+
from intentumdiff.sources.file_source import FileSource
|
|
172
186
|
|
|
173
187
|
# Derive workspace root for containment check.
|
|
174
188
|
workspace_root: Path | None = None
|
|
@@ -184,11 +198,9 @@ def create_server(
|
|
|
184
198
|
|
|
185
199
|
old_path = uri_to_path(old_uri, workspace_root=workspace_root)
|
|
186
200
|
new_path = uri_to_path(new_uri, workspace_root=workspace_root)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
old_content=old_content,
|
|
191
|
-
new_content=new_content,
|
|
201
|
+
source = FileSource(
|
|
202
|
+
old_path=old_path,
|
|
203
|
+
new_path=new_path,
|
|
192
204
|
filename=new_path.name,
|
|
193
205
|
)
|
|
194
206
|
diff = state.differ.diff(source)
|
|
@@ -198,6 +210,14 @@ def create_server(
|
|
|
198
210
|
|
|
199
211
|
return json.loads(diff.model_dump_json())
|
|
200
212
|
|
|
213
|
+
except WorkspaceContainmentError as exc:
|
|
214
|
+
# A refusal, not a fault. Logged distinctly so an operator can tell "someone asked
|
|
215
|
+
# for a path outside the workspace and we blocked it" from "the engine threw" -
|
|
216
|
+
# previously both produced the same line at the same level, which made the audit
|
|
217
|
+
# trail for a path-traversal attempt indistinguishable from routine noise.
|
|
218
|
+
log.warning("intentumdiff/semanticDiff refused (workspace containment): %s", exc)
|
|
219
|
+
return {"error": str(exc), "code": "workspace_containment"}
|
|
220
|
+
|
|
201
221
|
except Exception as exc: # noqa: BLE001
|
|
202
222
|
log.warning("intentumdiff/semanticDiff error: %s", exc)
|
|
203
223
|
return {"error": str(exc)}
|
intentumdiff/plugins/adapter.py
CHANGED
|
@@ -142,6 +142,11 @@ class ParserAdapter:
|
|
|
142
142
|
"""Filesystem path of the backing ``.wasm`` file."""
|
|
143
143
|
return self._plugin.wasm_path
|
|
144
144
|
|
|
145
|
+
@property
|
|
146
|
+
def compiled_wasm_sha256(self) -> str | None:
|
|
147
|
+
"""Identity of the exact compiled Wasm buffer, supplied by the loader."""
|
|
148
|
+
return self._plugin.compiled_wasm_sha256
|
|
149
|
+
|
|
145
150
|
@property
|
|
146
151
|
def is_trusted(self) -> bool:
|
|
147
152
|
return self._plugin.trusted
|
intentumdiff/plugins/builtins.py
CHANGED
|
@@ -20,13 +20,6 @@ def _wasm(name: str) -> str:
|
|
|
20
20
|
return str(_WASM_DIR / name)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def _wasm_or_generic(name: str) -> str:
|
|
24
|
-
path = _WASM_DIR / name
|
|
25
|
-
if path.exists():
|
|
26
|
-
return str(path)
|
|
27
|
-
return _wasm("generic_parser.wasm")
|
|
28
|
-
|
|
29
|
-
|
|
30
23
|
# ── Parser entry points ──────────────────────────────────────────────────────
|
|
31
24
|
|
|
32
25
|
def python_parser_entry() -> str:
|
|
@@ -42,31 +35,31 @@ def generic_parser_entry() -> str:
|
|
|
42
35
|
|
|
43
36
|
|
|
44
37
|
def graphql_parser_entry() -> str:
|
|
45
|
-
return
|
|
38
|
+
return _wasm("graphql_parser.wasm")
|
|
46
39
|
|
|
47
40
|
|
|
48
41
|
def gitignore_parser_entry() -> str:
|
|
49
|
-
return
|
|
42
|
+
return _wasm("gitignore_parser.wasm")
|
|
50
43
|
|
|
51
44
|
|
|
52
45
|
def ocaml_parser_entry() -> str:
|
|
53
|
-
return
|
|
46
|
+
return _wasm("ocaml_parser.wasm")
|
|
54
47
|
|
|
55
48
|
|
|
56
49
|
def reasonml_parser_entry() -> str:
|
|
57
|
-
return
|
|
50
|
+
return _wasm("reasonml_parser.wasm")
|
|
58
51
|
|
|
59
52
|
|
|
60
53
|
def latex_parser_entry() -> str:
|
|
61
|
-
return
|
|
54
|
+
return _wasm("latex_parser.wasm")
|
|
62
55
|
|
|
63
56
|
|
|
64
57
|
def asciidoc_parser_entry() -> str:
|
|
65
|
-
return
|
|
58
|
+
return _wasm("asciidoc_parser.wasm")
|
|
66
59
|
|
|
67
60
|
|
|
68
61
|
def po_parser_entry() -> str:
|
|
69
|
-
return
|
|
62
|
+
return _wasm("po_parser.wasm")
|
|
70
63
|
|
|
71
64
|
|
|
72
65
|
def js_ts_parser_entry() -> str:
|
|
@@ -91,3 +91,31 @@ class PluginLoadError(PluginError):
|
|
|
91
91
|
def __init__(self, wasm_path: str, detail: str) -> None:
|
|
92
92
|
self.wasm_path = wasm_path
|
|
93
93
|
super().__init__(f"Failed to load plugin from {wasm_path!r}: {detail}")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class PluginSecurityError(PluginLoadError):
|
|
97
|
+
"""A security gate denied loading; parser fallback must not bypass the denial."""
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class RegistryManifestError(RuntimeError):
|
|
101
|
+
"""The plugin registry manifest is not valid YAML or fails core's validator (#309, #329).
|
|
102
|
+
|
|
103
|
+
A ``RuntimeError``, the error :func:`~intentumdiff.plugins.hub.fetch_official_registry`
|
|
104
|
+
documents for a registry it cannot fetch or parse. The message lists every violation;
|
|
105
|
+
``errors`` carries core's ``validate_registry_manifest`` errors unchanged, each a
|
|
106
|
+
``{"path": <RFC 6901 pointer>, "message": str}`` dict (empty for a YAML/JSON error).
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
def __init__(self, message: str, errors: list[dict[str, str]] | None = None) -> None:
|
|
110
|
+
super().__init__(message)
|
|
111
|
+
self.errors: list[dict[str, str]] = list(errors or [])
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class RegistryManifestWarning(UserWarning):
|
|
115
|
+
"""Core's validator rejected part of the plugin registry manifest; loading continued (#309).
|
|
116
|
+
|
|
117
|
+
Entries core reports under ``/plugins/<name>`` are skipped and every other entry loads; a
|
|
118
|
+
manifest whose top level is unusable (core errors at ``/`` or ``/plugins``) loads none. The
|
|
119
|
+
message lists core's ``"<pointer>: <message>"`` errors and names the entries not loaded.
|
|
120
|
+
Strict tooling uses :func:`~intentumdiff.plugins.registry_schema.check_registry_manifest`.
|
|
121
|
+
"""
|
intentumdiff/plugins/hub.py
CHANGED
|
@@ -20,8 +20,7 @@ Plugins can be installed from two sources:
|
|
|
20
20
|
|
|
21
21
|
For official plugins (no ``repo``), the short name is expanded to the
|
|
22
22
|
full package in the ``buchochelliq-labs`` GitHub org:
|
|
23
|
-
``dbt`` -> ``intentumdiff-dbt``
|
|
24
|
-
-> ``https://github.com/buchochelliq-labs/intentumdiff-dbt``
|
|
23
|
+
``dbt`` -> package ``intentumdiff-dbt`` in that org
|
|
25
24
|
|
|
26
25
|
Security model
|
|
27
26
|
--------------
|
|
@@ -77,6 +76,7 @@ from __future__ import annotations
|
|
|
77
76
|
|
|
78
77
|
import hashlib
|
|
79
78
|
import importlib.metadata as _meta
|
|
79
|
+
import json
|
|
80
80
|
import logging
|
|
81
81
|
import re
|
|
82
82
|
import ssl
|
|
@@ -84,10 +84,14 @@ import subprocess
|
|
|
84
84
|
import sys
|
|
85
85
|
import urllib.error
|
|
86
86
|
import urllib.request
|
|
87
|
+
import warnings
|
|
87
88
|
from dataclasses import dataclass, field
|
|
88
89
|
from pathlib import Path, PurePosixPath, PureWindowsPath
|
|
89
90
|
from typing import Any
|
|
90
91
|
|
|
92
|
+
from intentumdiff.plugins.exceptions import RegistryManifestError, RegistryManifestWarning
|
|
93
|
+
from intentumdiff.plugins.registry_schema import format_manifest_error, registry_manifest_errors
|
|
94
|
+
|
|
91
95
|
logger = logging.getLogger(__name__)
|
|
92
96
|
|
|
93
97
|
# ---------------------------------------------------------------------------
|
|
@@ -387,32 +391,12 @@ def fetch_official_registry(
|
|
|
387
391
|
strict: bool = False,
|
|
388
392
|
timeout: int = 15,
|
|
389
393
|
) -> dict[str, RegistryEntry]:
|
|
390
|
-
"""
|
|
391
|
-
Fetch and parse the official plugin registry manifest.
|
|
392
|
-
|
|
393
|
-
Parameters
|
|
394
|
-
----------
|
|
395
|
-
ref:
|
|
396
|
-
Git ref (branch, tag, or commit SHA) of the registry repo to fetch
|
|
397
|
-
from. Default ``"main"``. **Pin to a commit SHA in production for
|
|
398
|
-
reproducible, tamper-evident installs.**
|
|
399
|
-
strict:
|
|
400
|
-
When ``True``, *ref* must be a full 40-character commit SHA. This
|
|
401
|
-
enforces the production/CI policy: mutable refs (branch names, tags)
|
|
402
|
-
are rejected. Pass ``strict=True`` via the ``--strict-registry`` CLI
|
|
403
|
-
flag.
|
|
404
|
-
timeout:
|
|
405
|
-
HTTP timeout in seconds.
|
|
406
|
-
|
|
407
|
-
Returns
|
|
408
|
-
-------
|
|
409
|
-
dict[str, RegistryEntry]
|
|
410
|
-
Mapping of short plugin name → registry entry.
|
|
394
|
+
"""Fetch the official registry manifest at *ref* and parse it into ``{name -> entry}``.
|
|
411
395
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
396
|
+
Pin *ref* to a commit SHA in production; ``strict=True`` (``--strict-registry``) requires a
|
|
397
|
+
full 40-character SHA. Raises ``RuntimeError`` when the registry cannot be fetched and
|
|
398
|
+
:class:`RegistryManifestError` when it is not YAML or has no JSON form; core-rejected
|
|
399
|
+
entries are skipped with a :class:`RegistryManifestWarning` (#309).
|
|
416
400
|
"""
|
|
417
401
|
_validate_registry_ref(ref, strict=strict)
|
|
418
402
|
url = f"{OFFICIAL_REGISTRY_RAW_URL}/{ref}/registry.yaml"
|
|
@@ -424,26 +408,41 @@ def fetch_official_registry(
|
|
|
424
408
|
with urllib.request.urlopen(url, timeout=timeout, context=ctx) as resp: # nosemgrep: python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected -- scheme asserted https above; base is a fixed constant + validated ref. noqa: S310 # nosec B310 - https scheme asserted above
|
|
425
409
|
content = resp.read().decode("utf-8")
|
|
426
410
|
except urllib.error.URLError as exc:
|
|
427
|
-
raise RuntimeError(
|
|
428
|
-
|
|
429
|
-
f"Check your internet connection. Detail: {exc}"
|
|
430
|
-
) from exc
|
|
431
|
-
|
|
411
|
+
raise RuntimeError(f"Could not fetch the official plugin registry from {url}.\n"
|
|
412
|
+
f"Check your internet connection. Detail: {exc}") from exc
|
|
432
413
|
return parse_registry_manifest(content)
|
|
433
414
|
|
|
434
415
|
|
|
435
416
|
def parse_registry_manifest(content: str) -> dict[str, RegistryEntry]:
|
|
436
417
|
"""Parse a registry manifest (YAML text) into ``{short name -> RegistryEntry}``.
|
|
437
418
|
|
|
438
|
-
|
|
439
|
-
|
|
419
|
+
Core's validator judges every entry (#309, #329) without blocking the load: entries it
|
|
420
|
+
rejects are skipped (none load if the top level is) with a :class:`RegistryManifestWarning`.
|
|
440
421
|
"""
|
|
441
422
|
yaml = _require_yaml()
|
|
442
|
-
|
|
443
|
-
|
|
423
|
+
try:
|
|
424
|
+
data = yaml.safe_load(content)
|
|
425
|
+
except yaml.YAMLError as exc:
|
|
426
|
+
raise RegistryManifestError(f"plugin registry manifest is not YAML: {exc}") from exc
|
|
427
|
+
errors = registry_manifest_errors(data)
|
|
428
|
+
data = json.loads(json.dumps(data)) # the document core judged (keys are JSON strings)
|
|
429
|
+
tokens = [error["path"].split("/")[1:] for error in errors] # RFC 6901 reference tokens
|
|
430
|
+
skipped = {t[1].replace("~1", "/").replace("~0", "~") for t in tokens if len(t) > 1
|
|
431
|
+
and t[0] == "plugins"}
|
|
432
|
+
plugins = data.get("plugins") if isinstance(data, dict) else None
|
|
433
|
+
unusable = not isinstance(plugins, dict) or any(t in ([], [""], ["plugins"]) for t in tokens)
|
|
434
|
+
if unusable:
|
|
435
|
+
skipped, plugins = set(), {}
|
|
436
|
+
if errors or unusable:
|
|
437
|
+
names = ", ".join(sorted(skipped & set(plugins))) or "none"
|
|
438
|
+
outcome = "no entries were loaded" if unusable else f"skipped entries: {names}"
|
|
439
|
+
problems = "; ".join(map(format_manifest_error, errors)) or "no usable plugins mapping"
|
|
440
|
+
message = f"invalid plugin registry manifest ({problems}); {outcome}"
|
|
441
|
+
logger.warning("%s", message)
|
|
442
|
+
warnings.warn(message, RegistryManifestWarning, stacklevel=2)
|
|
444
443
|
entries: dict[str, RegistryEntry] = {}
|
|
445
|
-
for plugin_name, entry_data in
|
|
446
|
-
if
|
|
444
|
+
for plugin_name, entry_data in plugins.items():
|
|
445
|
+
if plugin_name in skipped:
|
|
447
446
|
continue
|
|
448
447
|
entries[plugin_name] = RegistryEntry(
|
|
449
448
|
name=plugin_name,
|
|
@@ -471,10 +470,8 @@ def _require_yaml() -> Any:
|
|
|
471
470
|
import yaml # type: ignore[import-untyped]
|
|
472
471
|
return yaml
|
|
473
472
|
except ImportError as exc:
|
|
474
|
-
raise ImportError(
|
|
475
|
-
|
|
476
|
-
"Install it with: pip install pyyaml"
|
|
477
|
-
) from exc
|
|
473
|
+
raise ImportError("pyyaml is required to read/write intentumdiff_plugins.yaml. "
|
|
474
|
+
"Install it with: pip install pyyaml") from exc
|
|
478
475
|
|
|
479
476
|
|
|
480
477
|
def load_plugins_file(path: Path) -> list[PluginSpec]:
|
|
@@ -987,7 +984,6 @@ def inspect_wasm_in_wheel(
|
|
|
987
984
|
|
|
988
985
|
The wheel is not installed — no Python code from the plugin is executed.
|
|
989
986
|
"""
|
|
990
|
-
import io
|
|
991
987
|
import zipfile
|
|
992
988
|
|
|
993
989
|
checksums: dict[str, str] = {}
|