intentumdiff-python 0.0.2b2__py3-none-win_arm64.whl → 0.0.3b1__py3-none-win_arm64.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 +7 -0
- intentumdiff/_differ_gate.py +0 -136
- intentumdiff/_differ_presentation.py +1 -72
- intentumdiff/_differ_runtime.py +0 -17
- intentumdiff/analysis/cross_file.py +21 -21
- intentumdiff/analysis/diagnostics.py +1 -164
- intentumdiff/analysis/guardrail_reports.py +24 -28
- intentumdiff/analysis/guardrails.py +2 -67
- intentumdiff/analysis/schema_resolver.py +23 -87
- intentumdiff/analysis/user_schemas.py +2 -17
- intentumdiff/cli/_commands.py +70 -71
- intentumdiff/cli/_parser.py +40 -55
- intentumdiff/cli/_shared.py +55 -4
- intentumdiff/core/commit_differ.py +65 -99
- intentumdiff/core/indexer.py +0 -1
- intentumdiff/core/models.py +226 -69
- intentumdiff/differ.py +125 -432
- intentumdiff/github_app.py +5 -8
- intentumdiff/intentumdiff_rust_core/intentumdiff_rust_core.dll +0 -0
- intentumdiff/live_server.py +17 -17
- intentumdiff/lsp/client.py +42 -42
- intentumdiff/lsp/servers.py +10 -11
- intentumdiff/lsp_server/_handlers.py +1 -1
- intentumdiff/lsp_server/server.py +0 -1
- intentumdiff/plugins/exceptions.py +24 -0
- intentumdiff/plugins/hub.py +38 -41
- intentumdiff/plugins/registry.py +10 -10
- intentumdiff/plugins/registry.schema.json +156 -15
- intentumdiff/plugins/registry_schema.py +47 -140
- intentumdiff/rust_core.py +112 -775
- intentumdiff/serve/_app.py +23 -25
- intentumdiff/sources/git_source.py +0 -183
- intentumdiff/vcs/git_cli.py +0 -47
- 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/cpp_parser.wasm +0 -0
- intentumdiff/wasm/csharp_parser.wasm +0 -0
- intentumdiff/wasm/databricks_parser.wasm +0 -0
- intentumdiff/wasm/dax_parser.wasm +0 -0
- intentumdiff/wasm/dockerfile_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/graphql_parser.wasm +0 -0
- intentumdiff/wasm/groovy_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/make_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/perl_parser.wasm +0 -0
- intentumdiff/wasm/php_parser.wasm +0 -0
- intentumdiff/wasm/plsql_parser.wasm +0 -0
- intentumdiff/wasm/postscript_parser.wasm +0 -0
- intentumdiff/wasm/powershell_parser.wasm +0 -0
- intentumdiff/wasm/python_parser.wasm +0 -0
- intentumdiff/wasm/qsharp_parser.wasm +0 -0
- intentumdiff/wasm/reasonml_parser.wasm +0 -0
- intentumdiff/wasm/rust_parser.wasm +0 -0
- intentumdiff/wasm/sas_parser.wasm +0 -0
- intentumdiff/wasm/sql_parser.wasm +0 -0
- intentumdiff/wasm/svelte_parser.wasm +0 -0
- intentumdiff/wasm/swift_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 +219 -219
- intentumdiff/wasm/wat_parser.wasm +0 -0
- intentumdiff/wasm/yaml_parser.wasm +0 -0
- intentumdiff/watcher.py +15 -17
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/METADATA +38 -6
- intentumdiff_python-0.0.3b1.dist-info/RECORD +164 -0
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/sboms/intentumdiff-rust-core.cyclonedx.json +2 -2
- intentumdiff/analysis/invariances.py +0 -208
- intentumdiff/analysis/keyed_profiles.py +0 -25
- intentumdiff/analysis/resource_profiles.py +0 -14
- intentumdiff/analysis/text_review.py +0 -47
- intentumdiff/invariances/__init__.py +0 -2
- intentumdiff/invariances/rules.schema.json +0 -283
- intentumdiff/invariances/rules.yaml +0 -349
- intentumdiff_python-0.0.2b2.dist-info/RECORD +0 -171
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/WHEEL +0 -0
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/entry_points.txt +0 -0
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/licenses/LICENSE +0 -0
intentumdiff/cli/_parser.py
CHANGED
|
@@ -119,29 +119,28 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
119
119
|
git_p = sub.add_parser("git", help="Diff a file between two git commits.")
|
|
120
120
|
git_p.set_defaults(repo=".", file=None)
|
|
121
121
|
git_p.add_argument(
|
|
122
|
-
"_git_pos", nargs="*", action=_GitPositionalsAction,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"Omit FILE to diff all changed files; omit REPO to use current directory.",
|
|
122
|
+
"_git_pos", nargs="*", action=_GitPositionalsAction, metavar="[[REPO] FILE]",
|
|
123
|
+
help="FILE to review (one positional), or REPO FILE (two). With no positional every "
|
|
124
|
+
"changed file is reviewed; use --repo for a repository other than the current one.",
|
|
126
125
|
)
|
|
127
126
|
git_p.add_argument(
|
|
128
|
-
"--
|
|
129
|
-
help=(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
),
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
127
|
+
"--repo", dest="repo_option", default=None, metavar="REPO",
|
|
128
|
+
help="Repository to review (default: current directory); all changed files without FILE.",
|
|
129
|
+
)
|
|
130
|
+
git_p.add_argument("--old", default=None, metavar="REF", help=(
|
|
131
|
+
"Old git ref to compare from. "
|
|
132
|
+
"Defaults to HEAD when --new is the working tree (default mode) or a scope flag, "
|
|
133
|
+
"and to HEAD~1 when --new is an explicit commit ref."))
|
|
134
|
+
# One new side only: --staged/--unpushed/--new silently overrode each other (#319).
|
|
135
|
+
git_scope = git_p.add_mutually_exclusive_group()
|
|
136
|
+
git_scope.add_argument("--new", default="", metavar="REF", help=(
|
|
137
|
+
"New git ref (default: working tree; HEAD plus staged). "
|
|
138
|
+
"Pass a commit ref to do commit-to-commit diff."))
|
|
139
|
+
git_scope.add_argument(
|
|
141
140
|
"--staged", action="store_true", default=False,
|
|
142
141
|
help="Diff HEAD against the git index (staged files only).",
|
|
143
142
|
)
|
|
144
|
-
|
|
143
|
+
git_scope.add_argument(
|
|
145
144
|
"--unpushed", action="store_true", default=False,
|
|
146
145
|
help="Diff the remote tracking branch against HEAD (commits not yet pushed).",
|
|
147
146
|
)
|
|
@@ -241,7 +240,7 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
241
240
|
file_p.add_argument(
|
|
242
241
|
"--stream",
|
|
243
242
|
action="store_true",
|
|
244
|
-
help="
|
|
243
|
+
help="Print changes one by one (the full diff is computed first; not incremental).",
|
|
245
244
|
)
|
|
246
245
|
file_p.set_defaults(func=_cmd_file)
|
|
247
246
|
|
|
@@ -322,7 +321,7 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
322
321
|
"--strict",
|
|
323
322
|
action="store_true",
|
|
324
323
|
default=False,
|
|
325
|
-
help="Exit 2 when
|
|
324
|
+
help="Exit 2 when any guardrail violation (important or immutable) is found.",
|
|
326
325
|
)
|
|
327
326
|
_add_fuel_arg(check_p)
|
|
328
327
|
check_p.add_argument(
|
|
@@ -395,20 +394,14 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
395
394
|
"--allow-source-plugin", dest="allow_source_plugin", action="store_true",
|
|
396
395
|
help="Allow installing from VCS/local/direct-URL sources (disables binary-only check).",
|
|
397
396
|
)
|
|
398
|
-
pl_add.add_argument(
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
"Recommended for CI and production environments."
|
|
404
|
-
),
|
|
405
|
-
)
|
|
397
|
+
pl_add.add_argument("--yes", action="store_true", help="Confirm --skip-verify (#314).")
|
|
398
|
+
pl_add.add_argument("--strict-registry", dest="strict_registry", action="store_true", help=(
|
|
399
|
+
"Require the official registry ref to be a full 40-character commit SHA. "
|
|
400
|
+
"Rejects mutable refs (branch names, tags) for reproducible, tamper-evident installs. "
|
|
401
|
+
"Recommended for CI and production environments."))
|
|
406
402
|
pl_add.set_defaults(
|
|
407
|
-
save=True,
|
|
408
|
-
|
|
409
|
-
allow_source_plugin=False,
|
|
410
|
-
strict_registry=False,
|
|
411
|
-
func=_cmd_plugins_add,
|
|
403
|
+
save=True, skip_verify=False, allow_source_plugin=False, strict_registry=False,
|
|
404
|
+
yes=False, func=_cmd_plugins_add,
|
|
412
405
|
)
|
|
413
406
|
|
|
414
407
|
# plugins install
|
|
@@ -432,19 +425,11 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
432
425
|
"--allow-source-plugin", dest="allow_source_plugin", action="store_true",
|
|
433
426
|
help="Allow installing from VCS/local/direct-URL sources (disables binary-only check).",
|
|
434
427
|
)
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
"Require the official registry ref to be a full 40-character commit SHA. "
|
|
439
|
-
"Rejects mutable refs for reproducible, tamper-evident installs. "
|
|
440
|
-
"Recommended for CI and production environments."
|
|
441
|
-
),
|
|
442
|
-
)
|
|
428
|
+
# No --strict-registry here: install reads manifest pins and never consults the registry,
|
|
429
|
+
# so the flag had no effect (#314). Pins are checked by `plugins add --strict-registry`.
|
|
430
|
+
pl_install.add_argument("--yes", action="store_true", help="Confirm --skip-verify.")
|
|
443
431
|
pl_install.set_defaults(
|
|
444
|
-
skip_verify=False,
|
|
445
|
-
allow_source_plugin=False,
|
|
446
|
-
strict_registry=False,
|
|
447
|
-
func=_cmd_plugins_install,
|
|
432
|
+
skip_verify=False, allow_source_plugin=False, yes=False, func=_cmd_plugins_install,
|
|
448
433
|
)
|
|
449
434
|
|
|
450
435
|
# plugins remove
|
|
@@ -495,15 +480,15 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
495
480
|
# ── index ─────────────────────────────────────────────────────────────
|
|
496
481
|
index_p = sub.add_parser(
|
|
497
482
|
"index",
|
|
498
|
-
help="Pre-index a git repository to warm the parse
|
|
483
|
+
help="Pre-index a git repository to warm the parse cache.",
|
|
499
484
|
description=(
|
|
500
485
|
"Walk every text file in the repository at the given ref, "
|
|
501
486
|
"parse each one, and store the results in the local cache "
|
|
502
487
|
"directory. Subsequent diff calls will be faster because the "
|
|
503
488
|
"Wasm parse step is skipped for already-cached files.\n\n"
|
|
504
|
-
"
|
|
505
|
-
"
|
|
506
|
-
"
|
|
489
|
+
"Only the parse cache is reused: the symbol index is rebuilt on every "
|
|
490
|
+
"run (a cached index is never trusted without proof that it is "
|
|
491
|
+
"complete for the commit), so a repeated call re-indexes."
|
|
507
492
|
),
|
|
508
493
|
)
|
|
509
494
|
index_p.add_argument(
|
|
@@ -530,7 +515,7 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
530
515
|
"--force",
|
|
531
516
|
action="store_true",
|
|
532
517
|
default=False,
|
|
533
|
-
help="
|
|
518
|
+
help="Accepted for compatibility; the symbol index is always rebuilt.",
|
|
534
519
|
)
|
|
535
520
|
index_p.add_argument(
|
|
536
521
|
"--fuel",
|
|
@@ -709,7 +694,7 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
709
694
|
description=(
|
|
710
695
|
"Re-diffs each changed file against its last committed state "
|
|
711
696
|
"(WorkingTreeSource) whenever the file is modified on disk. "
|
|
712
|
-
"Uses
|
|
697
|
+
"Uses watchdog file-system events; a deleted file is reported, not reviewed. "
|
|
713
698
|
"Press Ctrl+C to stop."
|
|
714
699
|
),
|
|
715
700
|
)
|
|
@@ -777,8 +762,8 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
777
762
|
action="store_true",
|
|
778
763
|
default=False,
|
|
779
764
|
help=(
|
|
780
|
-
"Send
|
|
781
|
-
"
|
|
765
|
+
"Send ChangeStreamEvent responses instead of a single SemanticDiff "
|
|
766
|
+
"per request (events follow the completed diff; not incremental)."
|
|
782
767
|
),
|
|
783
768
|
)
|
|
784
769
|
watch_p.set_defaults(func=_cmd_watch)
|
|
@@ -831,7 +816,7 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
831
816
|
"--stream",
|
|
832
817
|
action="store_true",
|
|
833
818
|
default=False,
|
|
834
|
-
help="
|
|
819
|
+
help="Send ChangeStreamEvents (after the completed diff) by default for diff requests.",
|
|
835
820
|
)
|
|
836
821
|
_add_fuel_arg(live_p)
|
|
837
822
|
live_p.set_defaults(func=_cmd_live_server)
|
|
@@ -1012,7 +997,7 @@ if _CLICK_RUNTIME_AVAILABLE:
|
|
|
1012
997
|
("guardrails", "Check protected config guardrail policy."),
|
|
1013
998
|
("plugins", "Manage parser and renderer plugins."),
|
|
1014
999
|
("security-check", "Check installed packages against OSV advisories."),
|
|
1015
|
-
("index", "Pre-index a git repository to warm
|
|
1000
|
+
("index", "Pre-index a git repository to warm the parse cache."),
|
|
1016
1001
|
("cache", "Inspect or manage the local cache database."),
|
|
1017
1002
|
("diagnostics", "Query local DuckDB fuel diagnostics."),
|
|
1018
1003
|
("watch", "Watch files/directories and show semantic diffs on save."),
|
intentumdiff/cli/_shared.py
CHANGED
|
@@ -23,6 +23,7 @@ import os
|
|
|
23
23
|
import shlex
|
|
24
24
|
import sys
|
|
25
25
|
import time
|
|
26
|
+
import webbrowser
|
|
26
27
|
from collections.abc import Callable
|
|
27
28
|
from contextlib import suppress
|
|
28
29
|
from pathlib import Path
|
|
@@ -38,7 +39,6 @@ except ModuleNotFoundError: # pragma: no cover - exercised only in minimal dev
|
|
|
38
39
|
from rich import box
|
|
39
40
|
from rich.console import Console
|
|
40
41
|
from rich.panel import Panel
|
|
41
|
-
from rich.table import Table
|
|
42
42
|
from rich.text import Text
|
|
43
43
|
|
|
44
44
|
from intentumdiff import (
|
|
@@ -363,9 +363,9 @@ def _render_text(diff: SemanticDiff, fmt: str, fuel: int | None = None) -> str:
|
|
|
363
363
|
|
|
364
364
|
try:
|
|
365
365
|
diff_json = diff.model_dump_json()
|
|
366
|
+
from intentumdiff.rust_core import fuel_budget # core's policy: -1 stays -1 (#308)
|
|
366
367
|
plugin_fuel = fuel if fuel is not None else 100_000_000
|
|
367
|
-
|
|
368
|
-
pl = load_plugin(candidates[0], adaptive_fuel)
|
|
368
|
+
pl = load_plugin(candidates[0], fuel_budget(plugin_fuel, len(diff_json.encode("utf-8"))))
|
|
369
369
|
return pl.call_render(diff_json)
|
|
370
370
|
except Exception as exc:
|
|
371
371
|
_err.print(f"[red]Renderer error: {exc}[/red]")
|
|
@@ -407,6 +407,56 @@ def _render_with_profile(
|
|
|
407
407
|
started = time.perf_counter()
|
|
408
408
|
_render(diff, args.format, args.output, fuel=fuel)
|
|
409
409
|
_emit_phase_profiles(diff, render_ms=(time.perf_counter() - started) * 1000)
|
|
410
|
+
_offer_incomplete_reports([diff], args)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
# Fixed CLI wording around core's report (core #252). Everything else the report flow
|
|
414
|
+
# prints is core-authored text (message, title, body_markdown); nothing local is added.
|
|
415
|
+
_REPORT_PREVIEW_HEADER = "Bug report preview (nothing has been sent):"
|
|
416
|
+
_REPORT_TRUNCATED_NOTE = ("The pre-filled issue URL was shortened to fit. The full report body "
|
|
417
|
+
"is printed above: paste it into the issue.")
|
|
418
|
+
_REPORT_PROMPT = "Open this pre-filled GitHub issue in your browser? [y/N] "
|
|
419
|
+
_REPORT_NOT_OPENED = "Nothing was opened."
|
|
420
|
+
_REPORT_HOW_TO = ("No terminal is attached, so nothing was opened. To preview and report this "
|
|
421
|
+
"bug, rerun the command in a terminal with --report-bug.")
|
|
422
|
+
_REPORT_HINT = "To preview a pre-filled bug report, rerun the command with --report-bug."
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
def _offer_incomplete_reports(diffs: list[SemanticDiff], args: argparse.Namespace) -> None:
|
|
426
|
+
"""Offer core's bug report for incomplete reviews; open the URL only on an explicit yes.
|
|
427
|
+
|
|
428
|
+
Writes to stderr only, so stdout (and JSON, which carries ``completeness`` and
|
|
429
|
+
``incomplete`` as core sent them) is untouched. Without a TTY nothing is opened.
|
|
430
|
+
"""
|
|
431
|
+
interactive = sys.stdin.isatty() and sys.stdout.isatty()
|
|
432
|
+
opted_in = bool(getattr(args, "report_bug", False))
|
|
433
|
+
offer = opted_in or (interactive and args.format == "terminal")
|
|
434
|
+
for diff in diffs:
|
|
435
|
+
if diff.completeness != "incomplete" or diff.incomplete is None:
|
|
436
|
+
continue
|
|
437
|
+
report = diff.incomplete.report
|
|
438
|
+
_write_stderr(diff.incomplete.message)
|
|
439
|
+
if not offer:
|
|
440
|
+
_write_stderr(_REPORT_HOW_TO if not interactive else _REPORT_HINT)
|
|
441
|
+
continue
|
|
442
|
+
_write_stderr(_REPORT_PREVIEW_HEADER, report.title, report.body_markdown)
|
|
443
|
+
if report.truncated:
|
|
444
|
+
_write_stderr(_REPORT_TRUNCATED_NOTE)
|
|
445
|
+
if not interactive:
|
|
446
|
+
_write_stderr(_REPORT_HOW_TO)
|
|
447
|
+
continue
|
|
448
|
+
sys.stderr.write(_REPORT_PROMPT)
|
|
449
|
+
sys.stderr.flush()
|
|
450
|
+
if sys.stdin.readline().strip().lower() in ("y", "yes"):
|
|
451
|
+
webbrowser.open(report.issue_url)
|
|
452
|
+
else:
|
|
453
|
+
_write_stderr(_REPORT_NOT_OPENED)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
def _write_stderr(*blocks: str) -> None:
|
|
457
|
+
"""Write text literally (no Rich markup: core's Markdown may contain brackets)."""
|
|
458
|
+
sys.stderr.write("".join(f"{block}\n" for block in blocks if block))
|
|
459
|
+
sys.stderr.flush()
|
|
410
460
|
|
|
411
461
|
|
|
412
462
|
def _combine_html_reviews(pages: list[tuple[str, str]]) -> str:
|
|
@@ -470,6 +520,7 @@ def _render_many_with_profile(
|
|
|
470
520
|
_write_output(_combine_html_reviews(list(zip(labels, parts, strict=True))), args.output)
|
|
471
521
|
else:
|
|
472
522
|
_write_output("\n".join(parts), args.output)
|
|
523
|
+
_offer_incomplete_reports(diffs, args)
|
|
473
524
|
|
|
474
525
|
|
|
475
526
|
def _has_immutable_guardrail(diff: SemanticDiff) -> bool:
|
|
@@ -527,7 +578,7 @@ def _emit_guardrail_reports(
|
|
|
527
578
|
def _exit_if_guardrail_result_fails(result: GuardrailCheckResult) -> None:
|
|
528
579
|
if result.passed:
|
|
529
580
|
return
|
|
530
|
-
_err.print("[bold red]
|
|
581
|
+
_err.print("[bold red]Guardrail check failed: protected semantic change detected.[/bold red]")
|
|
531
582
|
sys.exit(2)
|
|
532
583
|
|
|
533
584
|
|
|
@@ -10,11 +10,12 @@ level:
|
|
|
10
10
|
1. Runs ``SemanticDiffer.diff_commit()`` to get per-file ``SemanticDiff``
|
|
11
11
|
objects for every changed file.
|
|
12
12
|
2. Parses all changed files (old and new versions) into ``SemanticNode``
|
|
13
|
-
trees
|
|
14
|
-
3.
|
|
15
|
-
``MOVE_TO_MODULE`` / ``SPLIT_MODULE`` /
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
trees (or records the parse-failure text for a side).
|
|
14
|
+
3. Hands them to core's ``commit_cross_file_index`` (core #298), which builds
|
|
15
|
+
the symbol tables, detects ``MOVE_TO_MODULE`` / ``SPLIT_MODULE`` /
|
|
16
|
+
``CROSS_FILE_RENAME`` changes and reports unindexed files.
|
|
17
|
+
4. Returns a ``CommitDiff`` with the per-file diffs, the cross-file changes and
|
|
18
|
+
core's index completeness fields.
|
|
18
19
|
|
|
19
20
|
Usage::
|
|
20
21
|
|
|
@@ -32,17 +33,16 @@ Usage::
|
|
|
32
33
|
|
|
33
34
|
from __future__ import annotations
|
|
34
35
|
|
|
35
|
-
import json
|
|
36
36
|
import logging
|
|
37
37
|
import os
|
|
38
38
|
from dataclasses import dataclass
|
|
39
39
|
from typing import TYPE_CHECKING, Callable, Iterator
|
|
40
40
|
|
|
41
|
-
from intentumdiff.core.models import CommitDiff,
|
|
41
|
+
from intentumdiff.core.models import CommitDiff, DiffConfig, SemanticDiff
|
|
42
42
|
from intentumdiff.differ import SemanticDiffer
|
|
43
|
-
from intentumdiff.analysis.cross_file import
|
|
44
|
-
from intentumdiff.core.index import SemanticIndex
|
|
43
|
+
from intentumdiff.analysis.cross_file import cross_file_change_from_core
|
|
45
44
|
from intentumdiff.plugins.exceptions import PluginError, PluginNotFoundError
|
|
45
|
+
from intentumdiff.rust_core import commit_cross_file_index
|
|
46
46
|
from intentumdiff.sources.git_source import iter_changed_sources
|
|
47
47
|
from intentumdiff.vcs.base import VcsBackend
|
|
48
48
|
from intentumdiff.vcs.git_cli import resolve_repo_root
|
|
@@ -216,8 +216,8 @@ class CommitDiffer:
|
|
|
216
216
|
|
|
217
217
|
def finalize_commit_diff(
|
|
218
218
|
self,
|
|
219
|
-
results: list[FileDiffResult],
|
|
220
|
-
errors: list[FileDiffError],
|
|
219
|
+
results: list[FileDiffResult | FileDiffError],
|
|
220
|
+
errors: list[FileDiffError] | None = None,
|
|
221
221
|
*,
|
|
222
222
|
old_ref: str,
|
|
223
223
|
new_ref: str,
|
|
@@ -230,13 +230,17 @@ class CommitDiffer:
|
|
|
230
230
|
terminal ``CommitDiff``. This is the counterpart to
|
|
231
231
|
:meth:`iter_file_diffs`.
|
|
232
232
|
"""
|
|
233
|
-
|
|
233
|
+
successful = [item for item in results if isinstance(item, FileDiffResult)]
|
|
234
|
+
collected_errors = [item for item in results if isinstance(item, FileDiffError)]
|
|
235
|
+
collected_errors.extend(errors or [])
|
|
236
|
+
changed_file_count = len(successful) + len(collected_errors)
|
|
234
237
|
return self._finalize_commit_diff(
|
|
235
|
-
results=
|
|
236
|
-
errors=
|
|
238
|
+
results=successful,
|
|
239
|
+
errors=collected_errors,
|
|
237
240
|
changed_file_count=changed_file_count,
|
|
238
241
|
old_ref=old_ref,
|
|
239
242
|
new_ref=new_ref,
|
|
243
|
+
allow_partial_errors=True,
|
|
240
244
|
)
|
|
241
245
|
|
|
242
246
|
def _collect_file_diffs(
|
|
@@ -302,19 +306,16 @@ class CommitDiffer:
|
|
|
302
306
|
changed_file_count: int,
|
|
303
307
|
old_ref: str,
|
|
304
308
|
new_ref: str,
|
|
309
|
+
allow_partial_errors: bool = False,
|
|
305
310
|
) -> CommitDiff:
|
|
306
311
|
"""Assemble the terminal CommitDiff from per-file results + errors."""
|
|
307
312
|
file_diffs = [result.file_diff for result in results]
|
|
308
|
-
parse_errors = [
|
|
309
|
-
f"{error.old_path}: {error.reason}"
|
|
310
|
-
for error in errors
|
|
311
|
-
if error.kind == "pipeline_error"
|
|
312
|
-
]
|
|
313
|
+
parse_errors = [f"{error.old_path}: {error.reason}" for error in errors]
|
|
313
314
|
|
|
314
315
|
self._raise_if_all_parsers_failed(
|
|
315
316
|
changed_file_count, file_diffs, parse_errors, file_errors=errors
|
|
316
317
|
)
|
|
317
|
-
if errors:
|
|
318
|
+
if errors and not allow_partial_errors:
|
|
318
319
|
details = "; ".join(
|
|
319
320
|
f"{err.old_path}: {err.kind}: {err.reason}" for err in errors
|
|
320
321
|
)
|
|
@@ -322,29 +323,10 @@ class CommitDiffer:
|
|
|
322
323
|
f"Commit diff incomplete ({len(errors)} of {changed_file_count} text files failed): "
|
|
323
324
|
f"{details}"
|
|
324
325
|
)
|
|
325
|
-
|
|
326
|
-
#
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
for result in results
|
|
330
|
-
]
|
|
331
|
-
new_file_contents = [
|
|
332
|
-
(result.new_path, result.file_diff.language, result.new_content)
|
|
333
|
-
for result in results
|
|
334
|
-
]
|
|
335
|
-
cross_file_changes: list[CrossFileChange] = []
|
|
336
|
-
if old_file_contents:
|
|
337
|
-
old_index = self._build_index(old_file_contents)
|
|
338
|
-
new_index = self._build_index(new_file_contents)
|
|
339
|
-
# Both source sets are nonempty. An absent index means incomplete
|
|
340
|
-
# cross-file semantics, not an honest "no cross-file changes" result.
|
|
341
|
-
if old_index is None or new_index is None:
|
|
342
|
-
raise RuntimeError(
|
|
343
|
-
"Commit semantic index incomplete: missing old or new index "
|
|
344
|
-
"for changed text files"
|
|
345
|
-
)
|
|
346
|
-
cross_file_changes = self._detect_cross_file(old_index, new_index)
|
|
347
|
-
|
|
326
|
+
# Core owns commit-wide cross-file indexing and its completeness policy (#298):
|
|
327
|
+
# the host only parses each changed file (plugin dispatch) and hands core the
|
|
328
|
+
# trees, or the parse-failure text for a side it could not parse.
|
|
329
|
+
index = commit_cross_file_index([self._index_input(result) for result in results])
|
|
348
330
|
return CommitDiff(
|
|
349
331
|
old_ref=old_ref,
|
|
350
332
|
new_ref=new_ref,
|
|
@@ -354,8 +336,14 @@ class CommitDiffer:
|
|
|
354
336
|
for violation in file_diff.guardrail_violations
|
|
355
337
|
],
|
|
356
338
|
file_diffs=file_diffs,
|
|
357
|
-
cross_file_changes=
|
|
339
|
+
cross_file_changes=[
|
|
340
|
+
cross_file_change_from_core(item) for item in index["cross_file_changes"]
|
|
341
|
+
],
|
|
358
342
|
parse_errors=parse_errors,
|
|
343
|
+
cross_file_index_status=index["cross_file_index_status"],
|
|
344
|
+
cross_file_index_complete=index["cross_file_index_complete"],
|
|
345
|
+
indexed_file_count=index["indexed_file_count"],
|
|
346
|
+
index_errors=index["index_errors"],
|
|
359
347
|
)
|
|
360
348
|
|
|
361
349
|
# ------------------------------------------------------------------
|
|
@@ -403,7 +391,7 @@ class CommitDiffer:
|
|
|
403
391
|
file_errors: list[FileDiffError] | None = None,
|
|
404
392
|
) -> None:
|
|
405
393
|
"""Fail loudly when changed files exist but no parser plugin loaded."""
|
|
406
|
-
if changed_file_count <= 0 or file_diffs
|
|
394
|
+
if changed_file_count <= 0 or file_diffs:
|
|
407
395
|
return
|
|
408
396
|
summary_fn = getattr(self._differ._registry, "parser_load_failure_summary", None)
|
|
409
397
|
if not callable(summary_fn):
|
|
@@ -422,60 +410,38 @@ class CommitDiffer:
|
|
|
422
410
|
"Commit diff incomplete: no parser succeeded for changed text files" + details
|
|
423
411
|
)
|
|
424
412
|
|
|
425
|
-
def
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
def _detect_cross_file(
|
|
459
|
-
self, old_index: SemanticIndex, new_index: SemanticIndex
|
|
460
|
-
) -> list[CrossFileChange]:
|
|
461
|
-
"""Detect cross-file changes between two indexes via the Rust core."""
|
|
462
|
-
return detect_cross_file_changes(old_index, new_index)
|
|
463
|
-
|
|
464
|
-
def _parse_to_tree(
|
|
465
|
-
self, filename: str, language: str, content: str
|
|
466
|
-
) -> "SemanticNode | None":
|
|
467
|
-
"""
|
|
468
|
-
Parse *content* to a SemanticNode tree.
|
|
469
|
-
|
|
470
|
-
Re-uses the ``SemanticDiffer`` FullParse parser pipeline for
|
|
471
|
-
commit-wide symbol indexing. Missing parsers must propagate to the
|
|
472
|
-
caller so a complete commit review cannot silently omit a text file.
|
|
473
|
-
"""
|
|
474
|
-
# Match the existing source-diff and native Rust empty-side contract. Some
|
|
475
|
-
# parsers reject empty input; that is not a missing symbol-table failure.
|
|
476
|
-
if not content:
|
|
477
|
-
from intentumdiff._differ_presentation import _empty_semantic_tree
|
|
478
|
-
return _empty_semantic_tree(language)
|
|
413
|
+
def _index_input(self, result: FileDiffResult) -> dict[str, object]:
|
|
414
|
+
"""Marshal one changed file for core's ``commit_cross_file_index``."""
|
|
415
|
+
language = result.file_diff.language
|
|
416
|
+
entry: dict[str, object] = {
|
|
417
|
+
"old_filename": result.old_path,
|
|
418
|
+
"new_filename": result.new_path,
|
|
419
|
+
"language": language,
|
|
420
|
+
}
|
|
421
|
+
for side, filename, content in (
|
|
422
|
+
("old", result.old_path, result.old_content),
|
|
423
|
+
("new", result.new_path, result.new_content),
|
|
424
|
+
):
|
|
425
|
+
tree, error = None, None
|
|
426
|
+
if content:
|
|
427
|
+
try:
|
|
428
|
+
tree = self._parse_to_tree(filename, language, content).model_dump(
|
|
429
|
+
mode="json"
|
|
430
|
+
)
|
|
431
|
+
except PluginNotFoundError as exc:
|
|
432
|
+
# A missing parser component is not a per-file index failure (core #298).
|
|
433
|
+
raise RuntimeError(
|
|
434
|
+
f"Commit semantic index unavailable for {filename!r}: {exc}"
|
|
435
|
+
) from exc
|
|
436
|
+
except (PluginError, ValueError, RuntimeError) as exc:
|
|
437
|
+
# Transport the parse failure; core decides how it affects the index.
|
|
438
|
+
error = str(exc) or type(exc).__name__
|
|
439
|
+
entry[f"{side}_tree"] = tree
|
|
440
|
+
entry[f"{side}_error"] = error
|
|
441
|
+
return entry
|
|
442
|
+
|
|
443
|
+
def _parse_to_tree(self, filename: str, language: str, content: str) -> "SemanticNode":
|
|
444
|
+
"""Parse *content* with the ``SemanticDiffer`` FullParse parser pipeline."""
|
|
479
445
|
tree, _language = self._differ.parse(
|
|
480
446
|
content,
|
|
481
447
|
filename,
|
intentumdiff/core/indexer.py
CHANGED
|
@@ -51,7 +51,6 @@ from intentumdiff.rust_core import attach_lsp_type_map
|
|
|
51
51
|
|
|
52
52
|
if TYPE_CHECKING:
|
|
53
53
|
from intentumdiff.core.index import SemanticIndex
|
|
54
|
-
from intentumdiff.core.models import SemanticNode
|
|
55
54
|
from intentumdiff.differ import SemanticDiffer
|
|
56
55
|
|
|
57
56
|
logger = logging.getLogger(__name__)
|