intentumdiff-python 0.0.1__py3-none-manylinux_2_39_x86_64.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 +134 -0
- intentumdiff/_differ_gate.py +210 -0
- intentumdiff/_differ_presentation.py +786 -0
- intentumdiff/_differ_runtime.py +320 -0
- intentumdiff/analysis/__init__.py +1 -0
- intentumdiff/analysis/compile_commands.py +151 -0
- intentumdiff/analysis/cross_file.py +71 -0
- intentumdiff/analysis/diagnostics.py +309 -0
- intentumdiff/analysis/guardrail_reports.py +254 -0
- intentumdiff/analysis/guardrails.py +318 -0
- intentumdiff/analysis/invariances.py +1207 -0
- intentumdiff/analysis/keyed_profiles.py +25 -0
- intentumdiff/analysis/resource_profiles.py +14 -0
- intentumdiff/analysis/schema_resolver.py +816 -0
- intentumdiff/analysis/text_review.py +46 -0
- intentumdiff/analysis/user_schemas.py +430 -0
- intentumdiff/assets.py +45 -0
- intentumdiff/cache/__init__.py +37 -0
- intentumdiff/cache/duckdb_store.py +98 -0
- intentumdiff/cache/sqlite_store.py +149 -0
- intentumdiff/cache/store.py +190 -0
- intentumdiff/cli/__init__.py +199 -0
- intentumdiff/cli/_commands.py +2141 -0
- intentumdiff/cli/_parser.py +1061 -0
- intentumdiff/cli/_shared.py +644 -0
- intentumdiff/content_type.py +59 -0
- intentumdiff/core/__init__.py +1 -0
- intentumdiff/core/commit_differ.py +599 -0
- intentumdiff/core/config.py +51 -0
- intentumdiff/core/cst_serializer.py +101 -0
- intentumdiff/core/diffignore.py +87 -0
- intentumdiff/core/index.py +189 -0
- intentumdiff/core/indexer.py +792 -0
- intentumdiff/core/models.py +837 -0
- intentumdiff/differ.py +2195 -0
- intentumdiff/github_app.py +287 -0
- intentumdiff/intentumdiff_rust_core/__init__.py +7 -0
- intentumdiff/intentumdiff_rust_core/ffi.py +8 -0
- intentumdiff/intentumdiff_rust_core/libintentumdiff_rust_core.so +0 -0
- intentumdiff/invariances/__init__.py +2 -0
- intentumdiff/invariances/rules.schema.json +283 -0
- intentumdiff/invariances/rules.yaml +349 -0
- intentumdiff/live_server.py +1314 -0
- intentumdiff/lsp/__init__.py +67 -0
- intentumdiff/lsp/client.py +544 -0
- intentumdiff/lsp/config.py +96 -0
- intentumdiff/lsp/enricher.py +227 -0
- intentumdiff/lsp/exceptions.py +27 -0
- intentumdiff/lsp/launcher.py +273 -0
- intentumdiff/lsp/servers.py +356 -0
- intentumdiff/lsp_server/__init__.py +14 -0
- intentumdiff/lsp_server/_codelens.py +67 -0
- intentumdiff/lsp_server/_diagnostics.py +62 -0
- intentumdiff/lsp_server/_handlers.py +175 -0
- intentumdiff/lsp_server/server.py +205 -0
- intentumdiff/plugins/__init__.py +1 -0
- intentumdiff/plugins/adapter.py +397 -0
- intentumdiff/plugins/builtins.py +323 -0
- intentumdiff/plugins/exceptions.py +93 -0
- intentumdiff/plugins/hub.py +1155 -0
- intentumdiff/plugins/language_metadata.py +250 -0
- intentumdiff/plugins/loader.py +1252 -0
- intentumdiff/plugins/registry.py +1079 -0
- intentumdiff/plugins/registry.schema.json +99 -0
- intentumdiff/plugins/registry_schema.py +280 -0
- intentumdiff/plugins/wit/plugin.wit +351 -0
- intentumdiff/rust_core.py +2370 -0
- intentumdiff/serve/__init__.py +19 -0
- intentumdiff/serve/_app.py +485 -0
- intentumdiff/serve/_static/index.html +326 -0
- intentumdiff/serve/_static/playground.js +567 -0
- intentumdiff/sources/__init__.py +1 -0
- intentumdiff/sources/base.py +28 -0
- intentumdiff/sources/file_source.py +48 -0
- intentumdiff/sources/git_source.py +375 -0
- intentumdiff/sources/live_buffer_source.py +113 -0
- intentumdiff/sources/patch_source.py +126 -0
- intentumdiff/sources/string_source.py +44 -0
- intentumdiff/testing.py +165 -0
- intentumdiff/vcs/__init__.py +37 -0
- intentumdiff/vcs/_safe_path.py +50 -0
- intentumdiff/vcs/base.py +136 -0
- intentumdiff/vcs/git_backend.py +97 -0
- intentumdiff/vcs/git_cli.py +100 -0
- intentumdiff/vcs/hg_backend.py +94 -0
- intentumdiff/vcs/perforce_backend.py +109 -0
- intentumdiff/vcs/svn_backend.py +105 -0
- intentumdiff/wasm/.gitkeep +2 -0
- 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/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/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 +590 -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/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/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 +259 -0
- intentumdiff_python-0.0.1.dist-info/METADATA +112 -0
- intentumdiff_python-0.0.1.dist-info/RECORD +165 -0
- intentumdiff_python-0.0.1.dist-info/WHEEL +4 -0
- intentumdiff_python-0.0.1.dist-info/entry_points.txt +80 -0
- intentumdiff_python-0.0.1.dist-info/licenses/LICENSE +21 -0
- intentumdiff_python-0.0.1.dist-info/sboms/intentumdiff-rust-core.cyclonedx.json +10968 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""
|
|
2
|
+
intentumdiff.cache.sqlite_store
|
|
3
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
4
|
+
|
|
5
|
+
SQLite-backed cache for parse trees and diff results — a thin delegator over the
|
|
6
|
+
native Rust store (#101, A2.2).
|
|
7
|
+
|
|
8
|
+
The schema, gzip-compressed BLOB values, WAL mode, TTL + size-based eviction,
|
|
9
|
+
per-table hit/miss metrics, and B608-safe dynamic SQL all live in the core
|
|
10
|
+
(``crates/rust-core-host/src/cache.rs``). Python keeps only the CacheStore-shaped
|
|
11
|
+
API and the JSON marshalling for the compound return types. The deterministic key
|
|
12
|
+
methods (``parse_key`` / ``diff_key`` / ``hover_map_key``) are inherited from
|
|
13
|
+
``CacheStore`` (also Rust-backed).
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import json
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
from intentumdiff.cache.store import CacheStore
|
|
22
|
+
from intentumdiff.rust_core import sqlite_cache_store
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class SqliteCacheStore(CacheStore):
|
|
26
|
+
"""
|
|
27
|
+
Disk-persistent cache backed by a local SQLite database (native Rust store).
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
path:
|
|
32
|
+
Path to the ``.db`` file. Parent directories are created if needed.
|
|
33
|
+
ttl_days:
|
|
34
|
+
Entries older than this many days are deleted on construction.
|
|
35
|
+
max_mb:
|
|
36
|
+
When the combined compressed size exceeds this limit the oldest ~20 %
|
|
37
|
+
of rows are evicted.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def __init__(self, path: Path | str, ttl_days: int = 30, max_mb: int = 500) -> None:
|
|
41
|
+
self._rust = sqlite_cache_store(str(path), ttl_days, max_mb)
|
|
42
|
+
|
|
43
|
+
# ── Parse / diff cache ────────────────────────────────────────────────
|
|
44
|
+
|
|
45
|
+
def get_parse(self, key: str) -> str | None:
|
|
46
|
+
return self._rust.get_parse(key)
|
|
47
|
+
|
|
48
|
+
def put_parse(self, key: str, value: str, grammar_id: str = "") -> None:
|
|
49
|
+
self._rust.put_parse(key, value, grammar_id)
|
|
50
|
+
|
|
51
|
+
def get_diff(self, key: str) -> str | None:
|
|
52
|
+
return self._rust.get_diff(key)
|
|
53
|
+
|
|
54
|
+
def put_diff(
|
|
55
|
+
self,
|
|
56
|
+
key: str,
|
|
57
|
+
value: str,
|
|
58
|
+
language: str = "",
|
|
59
|
+
old_filename: str = "",
|
|
60
|
+
new_filename: str = "",
|
|
61
|
+
) -> None:
|
|
62
|
+
self._rust.put_diff(key, value, language, old_filename, new_filename)
|
|
63
|
+
|
|
64
|
+
# ── Symbol-index cache ────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
def get_symbol_index(self, cache_key: str) -> tuple[str, str] | None:
|
|
67
|
+
return self._rust.get_symbol_index(cache_key)
|
|
68
|
+
|
|
69
|
+
def put_symbol_index(
|
|
70
|
+
self, cache_key: str, symbols_json: str, refs_json: str, file_count: int = 0
|
|
71
|
+
) -> None:
|
|
72
|
+
self._rust.put_symbol_index(cache_key, symbols_json, refs_json, file_count)
|
|
73
|
+
|
|
74
|
+
# ── Hover-map cache ───────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
def get_hover_map(self, key: str) -> dict[str, str] | None:
|
|
77
|
+
raw = self._rust.get_hover_map(key)
|
|
78
|
+
return json.loads(raw) if raw is not None else None
|
|
79
|
+
|
|
80
|
+
def put_hover_map(self, key: str, value: dict[str, str]) -> None:
|
|
81
|
+
self._rust.put_hover_map(key, json.dumps(value))
|
|
82
|
+
|
|
83
|
+
# ── Administrative ────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
def stats(self) -> dict:
|
|
86
|
+
return json.loads(self._rust.stats())
|
|
87
|
+
|
|
88
|
+
def metrics(self) -> dict:
|
|
89
|
+
return json.loads(self._rust.metrics())
|
|
90
|
+
|
|
91
|
+
def list_entries(
|
|
92
|
+
self,
|
|
93
|
+
table: str,
|
|
94
|
+
*,
|
|
95
|
+
language: str | None = None,
|
|
96
|
+
file_glob: str | None = None,
|
|
97
|
+
since: int | None = None,
|
|
98
|
+
before: int | None = None,
|
|
99
|
+
min_size: int | None = None,
|
|
100
|
+
max_size: int | None = None,
|
|
101
|
+
limit: int = 50,
|
|
102
|
+
) -> list[dict]:
|
|
103
|
+
"""Metadata rows (no BLOBs) with optional filters. The ``file_glob`` filter
|
|
104
|
+
is applied here (fnmatch) over an over-fetched result set, matching the
|
|
105
|
+
retired Python behaviour and keeping the glob off the SQL surface."""
|
|
106
|
+
# Validate before crossing the FFI boundary so a bad limit is a ValueError
|
|
107
|
+
# (matching the retired Python), not a pyo3 TypeError on the i64 argument.
|
|
108
|
+
if not isinstance(limit, int) or limit < 1:
|
|
109
|
+
raise ValueError("limit must be a positive integer")
|
|
110
|
+
raw = self._rust.list_entries(
|
|
111
|
+
table, language, since, before, min_size, max_size, limit, file_glob is not None
|
|
112
|
+
)
|
|
113
|
+
entries = json.loads(raw)
|
|
114
|
+
if file_glob and table == "diff_cache":
|
|
115
|
+
import fnmatch # noqa: PLC0415
|
|
116
|
+
|
|
117
|
+
filtered: list[dict] = []
|
|
118
|
+
for entry in entries:
|
|
119
|
+
if fnmatch.fnmatch(
|
|
120
|
+
entry.get("old_filename", ""), file_glob
|
|
121
|
+
) or fnmatch.fnmatch(entry.get("new_filename", ""), file_glob):
|
|
122
|
+
filtered.append(entry)
|
|
123
|
+
if len(filtered) >= limit:
|
|
124
|
+
break
|
|
125
|
+
return filtered
|
|
126
|
+
return entries[:limit]
|
|
127
|
+
|
|
128
|
+
def get_entry_metadata(self, key: str, table: str) -> dict | None:
|
|
129
|
+
raw = self._rust.get_entry_metadata(key, table)
|
|
130
|
+
return json.loads(raw) if raw is not None else None
|
|
131
|
+
|
|
132
|
+
def get_entry_payload(self, key: str, table: str) -> str | None:
|
|
133
|
+
return self._rust.get_entry_payload(key, table)
|
|
134
|
+
|
|
135
|
+
def export_entries(self, table: str):
|
|
136
|
+
"""Yield ``{table, key, ...metadata, payload}`` dicts for every entry."""
|
|
137
|
+
yield from json.loads(self._rust.export_entries(table))
|
|
138
|
+
|
|
139
|
+
def clear(
|
|
140
|
+
self,
|
|
141
|
+
parse: bool = True,
|
|
142
|
+
diff: bool = True,
|
|
143
|
+
index: bool = True,
|
|
144
|
+
hover: bool = True,
|
|
145
|
+
) -> None:
|
|
146
|
+
self._rust.clear(parse, diff, index, hover)
|
|
147
|
+
|
|
148
|
+
def close(self) -> None:
|
|
149
|
+
self._rust.close()
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""
|
|
2
|
+
intentumdiff.cache.store
|
|
3
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
4
|
+
|
|
5
|
+
Abstract base class for cache stores and shared key-generation utilities.
|
|
6
|
+
|
|
7
|
+
Key generation is Rust-authoritative (#101, A2.2): the deterministic, length-prefixed
|
|
8
|
+
SHA-256 cache keys are computed in the core (``cache.rs``), so every binding — and the
|
|
9
|
+
native SqliteCacheStore — agree on the exact key for a given input.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from abc import ABC, abstractmethod
|
|
15
|
+
|
|
16
|
+
from intentumdiff.rust_core import (
|
|
17
|
+
cache_diff_key,
|
|
18
|
+
cache_hover_map_key,
|
|
19
|
+
cache_make_key,
|
|
20
|
+
cache_parse_key,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _make_key(*parts: str) -> str:
|
|
25
|
+
"""
|
|
26
|
+
SHA-256 hex digest of length-prefixed parts (Rust-authoritative, #101).
|
|
27
|
+
|
|
28
|
+
Each part is encoded as ``<4-byte little-endian length><utf-8 bytes>``, making
|
|
29
|
+
the encoding injective — ``_make_key("a\\x00b")`` and ``_make_key("a", "b")``
|
|
30
|
+
hash differently even though both contain a null byte.
|
|
31
|
+
"""
|
|
32
|
+
return cache_make_key(list(parts))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class CacheStore(ABC):
|
|
36
|
+
"""
|
|
37
|
+
Abstract cache store for parse trees and diff results.
|
|
38
|
+
|
|
39
|
+
Subclasses must implement the four read/write methods. The
|
|
40
|
+
``record_diff`` hook is optional — the default is a no-op so that the
|
|
41
|
+
SQLite store can be used without DuckDB.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
# ── Key construction (Rust-authoritative) ─────────────────────────────
|
|
45
|
+
|
|
46
|
+
def parse_key(self, filtered_cst_or_content: str, grammar_id: str, wasm_hash: str) -> str:
|
|
47
|
+
"""
|
|
48
|
+
Cache key for a single-file parser result.
|
|
49
|
+
|
|
50
|
+
*filtered_cst_or_content* is the exact bytes fed to the plugin's
|
|
51
|
+
``process()`` call (trivia-stripped CST JSON for interpret-cst parsers,
|
|
52
|
+
raw source for full-parse parsers).
|
|
53
|
+
"""
|
|
54
|
+
return cache_parse_key(filtered_cst_or_content, grammar_id, wasm_hash)
|
|
55
|
+
|
|
56
|
+
def diff_key(
|
|
57
|
+
self,
|
|
58
|
+
old_preprocessed: str,
|
|
59
|
+
new_preprocessed: str,
|
|
60
|
+
grammar_id: str,
|
|
61
|
+
wasm_hash: str,
|
|
62
|
+
) -> str:
|
|
63
|
+
"""
|
|
64
|
+
Cache key for a full-pipeline SemanticDiff result.
|
|
65
|
+
|
|
66
|
+
Uses the preprocessed (but not trivia-stripped) source so that the
|
|
67
|
+
key can be computed before the expensive parse steps.
|
|
68
|
+
"""
|
|
69
|
+
return cache_diff_key(old_preprocessed, new_preprocessed, grammar_id, wasm_hash)
|
|
70
|
+
|
|
71
|
+
# ── Parse cache ───────────────────────────────────────────────────────
|
|
72
|
+
|
|
73
|
+
@abstractmethod
|
|
74
|
+
def get_parse(self, key: str) -> str | None:
|
|
75
|
+
"""Return cached SemanticNode JSON string or ``None`` on miss."""
|
|
76
|
+
|
|
77
|
+
@abstractmethod
|
|
78
|
+
def put_parse(self, key: str, value: str, grammar_id: str = "") -> None:
|
|
79
|
+
"""Store SemanticNode JSON string under *key*."""
|
|
80
|
+
|
|
81
|
+
# ── Diff cache ────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
@abstractmethod
|
|
84
|
+
def get_diff(self, key: str) -> str | None:
|
|
85
|
+
"""Return cached SemanticDiff JSON string or ``None`` on miss."""
|
|
86
|
+
|
|
87
|
+
@abstractmethod
|
|
88
|
+
def put_diff(
|
|
89
|
+
self,
|
|
90
|
+
key: str,
|
|
91
|
+
value: str,
|
|
92
|
+
language: str = "",
|
|
93
|
+
old_filename: str = "",
|
|
94
|
+
new_filename: str = "",
|
|
95
|
+
) -> None:
|
|
96
|
+
"""Store SemanticDiff JSON string under *key*."""
|
|
97
|
+
|
|
98
|
+
# ── Symbol-index cache ────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
def get_symbol_index(self, cache_key: str) -> tuple[str, str] | None:
|
|
101
|
+
"""
|
|
102
|
+
Return ``(symbols_json, refs_json)`` for a previously stored index,
|
|
103
|
+
or ``None`` on a cache miss.
|
|
104
|
+
|
|
105
|
+
The default implementation is a no-op (always returns ``None``).
|
|
106
|
+
"""
|
|
107
|
+
return None
|
|
108
|
+
|
|
109
|
+
def put_symbol_index(
|
|
110
|
+
self,
|
|
111
|
+
cache_key: str,
|
|
112
|
+
symbols_json: str,
|
|
113
|
+
refs_json: str,
|
|
114
|
+
file_count: int = 0,
|
|
115
|
+
) -> None:
|
|
116
|
+
"""
|
|
117
|
+
Persist a built symbol index keyed by *cache_key*.
|
|
118
|
+
|
|
119
|
+
The default implementation is a no-op.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
# ── Hover-map cache ───────────────────────────────────────────────────
|
|
123
|
+
|
|
124
|
+
def hover_map_key(self, content: str, language: str) -> str:
|
|
125
|
+
"""
|
|
126
|
+
Cache key for the LSP hover-type map of a single file.
|
|
127
|
+
|
|
128
|
+
Keyed by the SHA-256 of the file *content* and its *language* so that
|
|
129
|
+
an unchanged file always hits the same cache entry regardless of path.
|
|
130
|
+
"""
|
|
131
|
+
return cache_hover_map_key(content, language)
|
|
132
|
+
|
|
133
|
+
def get_hover_map(self, key: str) -> dict[str, str] | None:
|
|
134
|
+
"""
|
|
135
|
+
Return the cached ``{node_id: type_string}`` mapping or ``None``.
|
|
136
|
+
|
|
137
|
+
The default implementation is a no-op (always returns ``None``).
|
|
138
|
+
"""
|
|
139
|
+
return None
|
|
140
|
+
|
|
141
|
+
def put_hover_map(self, key: str, value: dict[str, str]) -> None:
|
|
142
|
+
"""
|
|
143
|
+
Persist a hover-type map keyed by *key*.
|
|
144
|
+
|
|
145
|
+
The default implementation is a no-op.
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
# ── Administrative ────────────────────────────────────────────────────
|
|
149
|
+
|
|
150
|
+
def stats(self) -> dict:
|
|
151
|
+
"""
|
|
152
|
+
Return a dict with cache statistics (row counts and sizes per table).
|
|
153
|
+
|
|
154
|
+
The default implementation returns an empty dict.
|
|
155
|
+
"""
|
|
156
|
+
return {}
|
|
157
|
+
|
|
158
|
+
def clear(
|
|
159
|
+
self,
|
|
160
|
+
parse: bool = True,
|
|
161
|
+
diff: bool = True,
|
|
162
|
+
index: bool = True,
|
|
163
|
+
) -> None:
|
|
164
|
+
"""
|
|
165
|
+
Delete cached entries, optionally scoped to individual tables.
|
|
166
|
+
|
|
167
|
+
The default implementation is a no-op.
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
# ── Analytics hook ────────────────────────────────────────────────────
|
|
171
|
+
|
|
172
|
+
def record_diff(self, diff_json: str) -> None:
|
|
173
|
+
"""
|
|
174
|
+
Record a completed SemanticDiff for historical analytics.
|
|
175
|
+
|
|
176
|
+
The default implementation is a no-op. Override in stores that
|
|
177
|
+
support analytics (e.g. ``DuckDBAnalyticsStore``).
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
# ── Lifecycle ─────────────────────────────────────────────────────────
|
|
181
|
+
|
|
182
|
+
@abstractmethod
|
|
183
|
+
def close(self) -> None:
|
|
184
|
+
"""Release any held resources (connections, file handles, etc.)."""
|
|
185
|
+
|
|
186
|
+
def __enter__(self) -> "CacheStore":
|
|
187
|
+
return self
|
|
188
|
+
|
|
189
|
+
def __exit__(self, *_: object) -> None:
|
|
190
|
+
self.close()
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"""
|
|
2
|
+
intentumdiff.cli
|
|
3
|
+
~~~~~~~~~~~~~~~~~~~~~
|
|
4
|
+
|
|
5
|
+
Command-line interface for IntentumDiff.
|
|
6
|
+
|
|
7
|
+
Usage
|
|
8
|
+
-----
|
|
9
|
+
intentumdiff git <repo> <file> [--old REF] [--new REF] [--format FORMAT] [--output FILE]
|
|
10
|
+
intentumdiff file <old-file> <new-file> [--format FORMAT] [--output FILE]
|
|
11
|
+
intentumdiff patch [PATCH_FILE] [--base BASE_FILE]
|
|
12
|
+
intentumdiff string <old> <new> [--lang LANG]
|
|
13
|
+
intentumdiff plugins List installed parser and renderer plugins
|
|
14
|
+
|
|
15
|
+
Formats: terminal (default), terminal-color, json, patch, html, llm
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
from typing import NoReturn
|
|
21
|
+
|
|
22
|
+
from intentumdiff.cli._commands import ( # noqa: F401
|
|
23
|
+
_add_asset_diff_args,
|
|
24
|
+
_add_diagnostics_arg,
|
|
25
|
+
_add_diagnostics_db_arg,
|
|
26
|
+
_add_fuel_arg,
|
|
27
|
+
_add_guardrail_args,
|
|
28
|
+
_add_output_args,
|
|
29
|
+
_add_profile_phases_arg,
|
|
30
|
+
_add_resolve_references_arg,
|
|
31
|
+
_cmd_assets_diff,
|
|
32
|
+
_cmd_assets_git,
|
|
33
|
+
_cmd_cache_clear,
|
|
34
|
+
_cmd_cache_export,
|
|
35
|
+
_cmd_cache_inspect,
|
|
36
|
+
_cmd_cache_list,
|
|
37
|
+
_cmd_cache_stats,
|
|
38
|
+
_cmd_diagnostics_hotspots,
|
|
39
|
+
_cmd_diagnostics_query,
|
|
40
|
+
_cmd_diagnostics_summary,
|
|
41
|
+
_cmd_file,
|
|
42
|
+
_cmd_gist_diff,
|
|
43
|
+
_cmd_git,
|
|
44
|
+
_cmd_github_pr,
|
|
45
|
+
_cmd_guardrails_check,
|
|
46
|
+
_cmd_index,
|
|
47
|
+
_cmd_live_server,
|
|
48
|
+
_cmd_lsp_server,
|
|
49
|
+
_cmd_patch,
|
|
50
|
+
_cmd_plugins_add,
|
|
51
|
+
_cmd_plugins_install,
|
|
52
|
+
_cmd_plugins_list,
|
|
53
|
+
_cmd_plugins_remove,
|
|
54
|
+
_cmd_security_check,
|
|
55
|
+
_cmd_serve,
|
|
56
|
+
_cmd_string,
|
|
57
|
+
_cmd_watch,
|
|
58
|
+
_diagnostics_store,
|
|
59
|
+
_emit_rows,
|
|
60
|
+
_GitPositionalsAction,
|
|
61
|
+
_human_duration,
|
|
62
|
+
_parse_date_arg,
|
|
63
|
+
_parse_megapixels,
|
|
64
|
+
_print_index_result,
|
|
65
|
+
)
|
|
66
|
+
from intentumdiff.cli._parser import ( # noqa: F401
|
|
67
|
+
_build_parser,
|
|
68
|
+
_legacy_click_main,
|
|
69
|
+
_normalize_argv,
|
|
70
|
+
)
|
|
71
|
+
from intentumdiff.cli._shared import ( # noqa: F401
|
|
72
|
+
_MACHINE_OUTPUT_FORMATS,
|
|
73
|
+
_MACHINE_PROTOCOL_COMMANDS,
|
|
74
|
+
_NO_BANNER_ENV,
|
|
75
|
+
_asset_options_from_args,
|
|
76
|
+
_banner_disabled_by_env,
|
|
77
|
+
_cmd_shell,
|
|
78
|
+
_console,
|
|
79
|
+
_differ,
|
|
80
|
+
_emit_asset_payload,
|
|
81
|
+
_emit_guardrail_reports,
|
|
82
|
+
_emit_phase_profiles,
|
|
83
|
+
_err,
|
|
84
|
+
_exit_if_guardrail_result_fails,
|
|
85
|
+
_exit_if_guardrails_strict,
|
|
86
|
+
_guardrail_result,
|
|
87
|
+
_has_immutable_guardrail,
|
|
88
|
+
_is_machine_output,
|
|
89
|
+
_json_default,
|
|
90
|
+
_load_cli_config,
|
|
91
|
+
_maybe_render_cli_banner,
|
|
92
|
+
_parse_fuel,
|
|
93
|
+
_print_asset_result,
|
|
94
|
+
_print_shell_help,
|
|
95
|
+
_record_diagnostics_db,
|
|
96
|
+
_render,
|
|
97
|
+
_render_cli_banner,
|
|
98
|
+
_render_terminal,
|
|
99
|
+
_render_with_profile,
|
|
100
|
+
_resolve_repo_root,
|
|
101
|
+
_run_parsed_command,
|
|
102
|
+
_run_shell_line,
|
|
103
|
+
_should_show_cli_banner,
|
|
104
|
+
_version_text,
|
|
105
|
+
_warn_if_unlimited_fuel,
|
|
106
|
+
_write_output,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
__all__ = [
|
|
110
|
+
"_GitPositionalsAction",
|
|
111
|
+
"_MACHINE_OUTPUT_FORMATS",
|
|
112
|
+
"_MACHINE_PROTOCOL_COMMANDS",
|
|
113
|
+
"_NO_BANNER_ENV",
|
|
114
|
+
"_add_asset_diff_args",
|
|
115
|
+
"_add_diagnostics_arg",
|
|
116
|
+
"_add_diagnostics_db_arg",
|
|
117
|
+
"_add_fuel_arg",
|
|
118
|
+
"_add_guardrail_args",
|
|
119
|
+
"_add_output_args",
|
|
120
|
+
"_add_profile_phases_arg",
|
|
121
|
+
"_add_resolve_references_arg",
|
|
122
|
+
"_asset_options_from_args",
|
|
123
|
+
"_banner_disabled_by_env",
|
|
124
|
+
"_build_parser",
|
|
125
|
+
"_cmd_assets_diff",
|
|
126
|
+
"_cmd_assets_git",
|
|
127
|
+
"_cmd_cache_clear",
|
|
128
|
+
"_cmd_cache_export",
|
|
129
|
+
"_cmd_cache_inspect",
|
|
130
|
+
"_cmd_cache_list",
|
|
131
|
+
"_cmd_cache_stats",
|
|
132
|
+
"_cmd_diagnostics_hotspots",
|
|
133
|
+
"_cmd_diagnostics_query",
|
|
134
|
+
"_cmd_diagnostics_summary",
|
|
135
|
+
"_cmd_file",
|
|
136
|
+
"_cmd_gist_diff",
|
|
137
|
+
"_cmd_git",
|
|
138
|
+
"_cmd_github_pr",
|
|
139
|
+
"_cmd_guardrails_check",
|
|
140
|
+
"_cmd_index",
|
|
141
|
+
"_cmd_live_server",
|
|
142
|
+
"_cmd_lsp_server",
|
|
143
|
+
"_cmd_patch",
|
|
144
|
+
"_cmd_plugins_add",
|
|
145
|
+
"_cmd_plugins_install",
|
|
146
|
+
"_cmd_plugins_list",
|
|
147
|
+
"_cmd_plugins_remove",
|
|
148
|
+
"_cmd_security_check",
|
|
149
|
+
"_cmd_serve",
|
|
150
|
+
"_cmd_shell",
|
|
151
|
+
"_cmd_string",
|
|
152
|
+
"_cmd_watch",
|
|
153
|
+
"_console",
|
|
154
|
+
"_diagnostics_store",
|
|
155
|
+
"_differ",
|
|
156
|
+
"_emit_asset_payload",
|
|
157
|
+
"_emit_guardrail_reports",
|
|
158
|
+
"_emit_phase_profiles",
|
|
159
|
+
"_emit_rows",
|
|
160
|
+
"_err",
|
|
161
|
+
"_exit_if_guardrail_result_fails",
|
|
162
|
+
"_exit_if_guardrails_strict",
|
|
163
|
+
"_guardrail_result",
|
|
164
|
+
"_has_immutable_guardrail",
|
|
165
|
+
"_human_duration",
|
|
166
|
+
"_is_machine_output",
|
|
167
|
+
"_json_default",
|
|
168
|
+
"_legacy_click_main",
|
|
169
|
+
"_load_cli_config",
|
|
170
|
+
"_maybe_render_cli_banner",
|
|
171
|
+
"_normalize_argv",
|
|
172
|
+
"_parse_date_arg",
|
|
173
|
+
"_parse_fuel",
|
|
174
|
+
"_parse_megapixels",
|
|
175
|
+
"_print_asset_result",
|
|
176
|
+
"_print_index_result",
|
|
177
|
+
"_print_shell_help",
|
|
178
|
+
"_record_diagnostics_db",
|
|
179
|
+
"_render",
|
|
180
|
+
"_render_cli_banner",
|
|
181
|
+
"_render_terminal",
|
|
182
|
+
"_render_with_profile",
|
|
183
|
+
"_resolve_repo_root",
|
|
184
|
+
"_run_parsed_command",
|
|
185
|
+
"_run_shell_line",
|
|
186
|
+
"_should_show_cli_banner",
|
|
187
|
+
"_version_text",
|
|
188
|
+
"_warn_if_unlimited_fuel",
|
|
189
|
+
"_write_output",
|
|
190
|
+
"main",
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def main(argv: list[str] | None = None) -> NoReturn:
|
|
195
|
+
_legacy_click_main(argv)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
if __name__ == "__main__":
|
|
199
|
+
main()
|