diffctx 1.18.1__tar.gz → 1.18.2__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.
- {diffctx-1.18.1 → diffctx-1.18.2}/CHANGELOG.md +48 -1
- {diffctx-1.18.1 → diffctx-1.18.2}/Cargo.lock +1 -1
- {diffctx-1.18.1 → diffctx-1.18.2}/PKG-INFO +1 -1
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/Cargo.toml +1 -1
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/hook.rs +92 -11
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/impact.rs +99 -4
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/pybridge.rs +31 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/pyproject.toml +1 -1
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/_diffctx.pyi +1 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/cli.py +29 -0
- diffctx-1.18.2/src/diffctx/version.py +1 -0
- diffctx-1.18.1/src/diffctx/version.py +0 -1
- {diffctx-1.18.1 → diffctx-1.18.2}/Cargo.toml +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/LICENSE +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/README.md +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/README.md +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/analytics.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/candidate_files.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/change_class.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/analytics.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/bm25.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/budget.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/category_weights.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/edge_weights.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/env_overrides.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/extensions.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/filtering.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/fragmentation.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/git.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/graph_filtering.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/importance.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/limits.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/mode.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/needs.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/parsers.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/render.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/scoring.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/selection.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/tokenization.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/config/weights.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/core.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/discovery.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/base.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/config_edges/build_system.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/config_edges/cicd.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/config_edges/docker.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/config_edges/generic.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/config_edges/helm.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/config_edges/kubernetes.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/config_edges/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/document/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/history/cochange.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/history/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/ansible.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/bazel.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/c_family.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/cargo_edges.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/clojure.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/css.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/dart.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/dbt.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/dotnet.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/elixir.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/erlang.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/go.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/graphql.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/haskell.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/javascript.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/julia.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/jvm.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/latex.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/lua.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/nim.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/nix.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/ocaml.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/openapi.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/perl.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/php.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/prisma.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/protobuf.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/python.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/r_lang.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/ruby.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/rust_lang.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/shell.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/sql.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/swift.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/tags.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/terraform.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/semantic/zig.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/similarity/lexical.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/similarity/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/structural/containment.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/structural/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/structural/sibling.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/structural/testing.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/effective_config.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/excerpt.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/facts/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/facts/scala.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/filtering.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/fragmentation.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/git.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/graph.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/graph_export.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/in_memory_harness.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/interval.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/languages.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/lib.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/locate.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/main.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/mode.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/parsers/config_parser.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/parsers/generic.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/parsers/markdown.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/parsers/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/parsers/tree_sitter_strategy.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/paths.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/peak_rss.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/pipeline.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/postpass.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/ppr.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/project_graph.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/provenance.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/render.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/resource.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/run_provenance.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/sanitize.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/scoring.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/select.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/signatures.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/stopwords/code.txt +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/stopwords/docs.txt +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/stopwords.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/test_rng.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/testfiles.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/token_corpus.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/tokenizer.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/types.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/utility/boltzmann.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/utility/importance.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/utility/mod.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/utility/needs.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/utility/objective.rs +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/rust-toolchain.toml +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/__init__.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/__main__.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/_app.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/_native/__init__.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/_native/graph_analytics.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/_native/graph_export.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/_native/pipeline.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/_native/project_graph.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/clipboard.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/ignore.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/logger.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/mcp/__init__.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/mcp/__main__.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/mcp/fetch.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/mcp/legacy.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/mcp/security.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/mcp/server.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/py.typed +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/tokens.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/tree.py +0 -0
- {diffctx-1.18.1 → diffctx-1.18.2}/src/diffctx/writer.py +0 -0
|
@@ -7,6 +7,52 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.18.2] - 2026-10-01
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **The Claude plugin no longer downloads anything but its pinned package.**
|
|
15
|
+
The directory runs only code from the reviewed repository or a package
|
|
16
|
+
pinned to an exact version, and refused 1.18.1 for fetching the release
|
|
17
|
+
binary at session start. The git hooks now run `diffctx hook <event>` from
|
|
18
|
+
`uvx diffctx[mcp]==<version>` — the MCP server's own pinned launch, so the
|
|
19
|
+
environment its start cached is the one the hook finds, `--offline` on the
|
|
20
|
+
commit path. The session start only warms that cache in the background and
|
|
21
|
+
names the command; `diffctx-install.sh` and `plugin/checksums.json` are
|
|
22
|
+
gone. The PyPI package gains the `diffctx hook` subcommand the native
|
|
23
|
+
binary had. The skills' no-MCP fallback names the same exact version
|
|
24
|
+
instead of a `<version>` placeholder, and the release bumps it.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- 1.18.1's impact listed every resource cap as a limit, so the fragment and
|
|
29
|
+
edge caps nearly every repository hits printed `(partial: …)` and made the
|
|
30
|
+
hook speak on every commit; only the deadline, a truncated reverse
|
|
31
|
+
discovery and a capped candidate universe can lose a caller, and only those
|
|
32
|
+
are listed (#306).
|
|
33
|
+
- A test file named for a schema (`test_context_schema.py`) is no longer
|
|
34
|
+
reported as a schema contract.
|
|
35
|
+
- Impact: a changed module-level `export const f = (…) => …` is a changed
|
|
36
|
+
symbol whose importers are its callers; it used to read "Nothing outside the
|
|
37
|
+
diff depends on this change" (#324).
|
|
38
|
+
- Impact: "Contracts changed" lists an exported symbol only when its
|
|
39
|
+
declaration moved; a body-only edit is what its callers already say (#325).
|
|
40
|
+
A decorated export (`@Component({…}) export class …`) is public, and its
|
|
41
|
+
decorator is not mistaken for the declaration.
|
|
42
|
+
- The hook's "already reviewed" markers are per session: a change one session
|
|
43
|
+
was shown used to be silence for every other session for a day. A manual
|
|
44
|
+
`--mode impact` run still silences the hook on the same content, for 15
|
|
45
|
+
minutes (#323).
|
|
46
|
+
- `diffctx hook` from the PyPI package writes its answer as UTF-8: Windows'
|
|
47
|
+
cp1252 stdout turned the answer's dashes into bytes Claude Code cannot
|
|
48
|
+
read, and a character cp1252 lacks made the hook silent.
|
|
49
|
+
- `uv.lock`: urllib3 2.8.0 (GHSA-gh4c-6fx4-qh6g, GHSA-vxq7-64xx-v4gw,
|
|
50
|
+
GHSA-8988-9cw3-xx77) and virtualenv 21.14.1 (GHSA-94p9-xgh2-xp45,
|
|
51
|
+
GHSA-9h9j-4vrj-gf7g), both development-only.
|
|
52
|
+
- The hook no longer guesses the repository behind `cd $VAR`, `cd ~/…` or
|
|
53
|
+
`git -C "$REPO"`: a directory only the shell can expand is skipped instead
|
|
54
|
+
of reviewing whatever repository the agent's cwd is.
|
|
55
|
+
|
|
10
56
|
## [1.18.1] - 2026-09-30
|
|
11
57
|
|
|
12
58
|
### Fixed
|
|
@@ -1716,7 +1762,8 @@ Earlier releases shipped as `treemapper`; see
|
|
|
1716
1762
|
<https://github.com/nikolay-e/diffctx/releases> for the corresponding GitHub
|
|
1717
1763
|
release notes (`1.0.0` through `1.6.1`).
|
|
1718
1764
|
|
|
1719
|
-
[Unreleased]: https://github.com/nikolay-e/diffctx/compare/v1.18.
|
|
1765
|
+
[Unreleased]: https://github.com/nikolay-e/diffctx/compare/v1.18.2...HEAD
|
|
1766
|
+
[1.18.2]: https://github.com/nikolay-e/diffctx/compare/v1.18.1...v1.18.2
|
|
1720
1767
|
[1.18.1]: https://github.com/nikolay-e/diffctx/compare/v1.18.0...v1.18.1
|
|
1721
1768
|
[1.18.0]: https://github.com/nikolay-e/diffctx/compare/v1.17.0...v1.18.0
|
|
1722
1769
|
[1.17.0]: https://github.com/nikolay-e/diffctx/compare/v1.16.0...v1.17.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "diffctx"
|
|
3
|
-
version = "1.18.
|
|
3
|
+
version = "1.18.2"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
rust-version = "1.85"
|
|
6
6
|
description = "Selects the minimum code an LLM needs to review a git diff: walks the dependency graph outward from changed lines and stops when extra context stops paying for itself"
|
|
@@ -30,6 +30,11 @@ const MAX_CONTEXT_CHARS: usize = 9_000;
|
|
|
30
30
|
/// review, a fix and the push that follows; short enough that the same
|
|
31
31
|
/// change revisited tomorrow gets its impact again.
|
|
32
32
|
const SEEN_TTL: Duration = Duration::from_secs(24 * 60 * 60);
|
|
33
|
+
/// How long a manual `--mode impact` run silences the hook on the same
|
|
34
|
+
/// content. It is not tied to a session, so it must not outlive the moment:
|
|
35
|
+
/// a run just before the commit counts, another session hours later does
|
|
36
|
+
/// not inherit it (#323).
|
|
37
|
+
const MANUAL_SEEN_TTL: Duration = Duration::from_secs(15 * 60);
|
|
33
38
|
|
|
34
39
|
/// The hook's own wall-clock ceiling. Claude Code kills a hook at its
|
|
35
40
|
/// configured timeout and treats the kill as "no output", so this only has to
|
|
@@ -187,6 +192,10 @@ fn statements(command: &str) -> Vec<(String, Option<String>, Vec<String>)> {
|
|
|
187
192
|
let ws = words(command);
|
|
188
193
|
let mut found = Vec::new();
|
|
189
194
|
let mut cwd: Option<String> = None;
|
|
195
|
+
// Set once a `cd` names a directory the line alone cannot resolve
|
|
196
|
+
// (`cd $R`, `cd ~/x`); git statements under it are skipped rather than
|
|
197
|
+
// reviewed against whatever repository the agent's cwd happens to be.
|
|
198
|
+
let mut lost = false;
|
|
190
199
|
let mut i = 0;
|
|
191
200
|
while i < ws.len() {
|
|
192
201
|
let prog = Path::new(&ws[i])
|
|
@@ -198,7 +207,12 @@ fn statements(command: &str) -> Vec<(String, Option<String>, Vec<String>)> {
|
|
|
198
207
|
.get(i + 1)
|
|
199
208
|
.filter(|w| !is_operator(w) && !w.starts_with('-'))
|
|
200
209
|
{
|
|
201
|
-
|
|
210
|
+
if is_unresolvable(target) {
|
|
211
|
+
lost = true;
|
|
212
|
+
} else if is_absolute_dir(target) || !lost {
|
|
213
|
+
cwd = Some(join_dir(cwd.as_deref(), target));
|
|
214
|
+
lost = false;
|
|
215
|
+
}
|
|
202
216
|
}
|
|
203
217
|
i += 1;
|
|
204
218
|
continue;
|
|
@@ -206,11 +220,21 @@ fn statements(command: &str) -> Vec<(String, Option<String>, Vec<String>)> {
|
|
|
206
220
|
if prog == "git" || prog == "gh" {
|
|
207
221
|
let mut j = i + 1;
|
|
208
222
|
let mut dir = cwd.clone();
|
|
223
|
+
let mut dir_lost = lost;
|
|
209
224
|
let mut verb = None;
|
|
210
225
|
while j < ws.len() && !is_operator(&ws[j]) {
|
|
211
226
|
let w = &ws[j];
|
|
212
227
|
if prog == "git" && w == "-C" {
|
|
213
|
-
|
|
228
|
+
if let Some(d) = ws.get(j + 1) {
|
|
229
|
+
if is_unresolvable(d) {
|
|
230
|
+
dir_lost = true;
|
|
231
|
+
} else if is_absolute_dir(d) {
|
|
232
|
+
dir = Some(d.clone());
|
|
233
|
+
dir_lost = false;
|
|
234
|
+
} else {
|
|
235
|
+
dir = Some(join_dir(cwd.as_deref(), d));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
214
238
|
j += 2;
|
|
215
239
|
continue;
|
|
216
240
|
}
|
|
@@ -231,7 +255,7 @@ fn statements(command: &str) -> Vec<(String, Option<String>, Vec<String>)> {
|
|
|
231
255
|
args.push(ws[j].clone());
|
|
232
256
|
j += 1;
|
|
233
257
|
}
|
|
234
|
-
if let Some(verb) = verb {
|
|
258
|
+
if let Some(verb) = verb.filter(|_| !dir_lost) {
|
|
235
259
|
found.push((
|
|
236
260
|
if prog == "gh" {
|
|
237
261
|
format!("gh {verb}")
|
|
@@ -250,6 +274,12 @@ fn statements(command: &str) -> Vec<(String, Option<String>, Vec<String>)> {
|
|
|
250
274
|
found
|
|
251
275
|
}
|
|
252
276
|
|
|
277
|
+
/// A directory only the shell could expand: a variable, a command
|
|
278
|
+
/// substitution, a home-relative path.
|
|
279
|
+
fn is_unresolvable(dir: &str) -> bool {
|
|
280
|
+
dir.contains('$') || dir.contains('`') || dir.starts_with('~')
|
|
281
|
+
}
|
|
282
|
+
|
|
253
283
|
/// A directory as the shell line spelled it: `/r` is absolute on every
|
|
254
284
|
/// platform here, and the join keeps the line's own separator.
|
|
255
285
|
fn is_absolute_dir(dir: &str) -> bool {
|
|
@@ -463,6 +493,10 @@ fn marker(key: &str) -> Option<PathBuf> {
|
|
|
463
493
|
}
|
|
464
494
|
|
|
465
495
|
pub fn is_seen(key: &str) -> bool {
|
|
496
|
+
is_seen_within(key, SEEN_TTL)
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
fn is_seen_within(key: &str, ttl: Duration) -> bool {
|
|
466
500
|
let Some(path) = marker(key) else {
|
|
467
501
|
return false;
|
|
468
502
|
};
|
|
@@ -472,7 +506,24 @@ pub fn is_seen(key: &str) -> bool {
|
|
|
472
506
|
meta.modified()
|
|
473
507
|
.ok()
|
|
474
508
|
.and_then(|m| SystemTime::now().duration_since(m).ok())
|
|
475
|
-
.is_some_and(|age| age <
|
|
509
|
+
.is_some_and(|age| age < ttl)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/// The hook's own markers are per session: the payload names it, and a
|
|
513
|
+
/// change one session was shown is news to the next (#323). Only what a
|
|
514
|
+
/// file name can carry is kept of the id.
|
|
515
|
+
fn session_key(key: &str, session: Option<&str>) -> String {
|
|
516
|
+
let session: String = session
|
|
517
|
+
.unwrap_or("")
|
|
518
|
+
.chars()
|
|
519
|
+
.filter(|c| c.is_ascii_alphanumeric() || *c == '-')
|
|
520
|
+
.take(64)
|
|
521
|
+
.collect();
|
|
522
|
+
if session.is_empty() {
|
|
523
|
+
key.to_string()
|
|
524
|
+
} else {
|
|
525
|
+
format!("{key}.{session}")
|
|
526
|
+
}
|
|
476
527
|
}
|
|
477
528
|
|
|
478
529
|
pub fn mark_seen(key: &str) {
|
|
@@ -509,6 +560,7 @@ struct Prepared {
|
|
|
509
560
|
root: PathBuf,
|
|
510
561
|
range: String,
|
|
511
562
|
key: String,
|
|
563
|
+
session: Option<String>,
|
|
512
564
|
}
|
|
513
565
|
|
|
514
566
|
fn prepare(event: Event, stdin_json: &str) -> Option<Prepared> {
|
|
@@ -528,14 +580,21 @@ fn prepare(event: Event, stdin_json: &str) -> Option<Prepared> {
|
|
|
528
580
|
};
|
|
529
581
|
let root = crate::git::find_toplevel(&root)?;
|
|
530
582
|
let range = range_for(&root, &detected.trigger)?;
|
|
531
|
-
let
|
|
532
|
-
|
|
583
|
+
let content = content_key(&root, &range)?;
|
|
584
|
+
let session = payload["session_id"].as_str().map(str::to_string);
|
|
585
|
+
let key = session_key(&content, session.as_deref());
|
|
586
|
+
if is_seen(&key) || is_seen_within(&content, MANUAL_SEEN_TTL) {
|
|
533
587
|
return None;
|
|
534
588
|
}
|
|
535
|
-
Some(Prepared {
|
|
589
|
+
Some(Prepared {
|
|
590
|
+
root,
|
|
591
|
+
range,
|
|
592
|
+
key,
|
|
593
|
+
session,
|
|
594
|
+
})
|
|
536
595
|
}
|
|
537
596
|
|
|
538
|
-
fn impact_context(event: Event, root: &Path, range: &str) -> Option<String> {
|
|
597
|
+
fn impact_context(event: Event, root: &Path, range: &str, session: Option<&str>) -> Option<String> {
|
|
539
598
|
let scoring = ScoringMode::from_str(DEFAULT_SCORING).ok()?;
|
|
540
599
|
let output = crate::pipeline::build_diff_context_impact(
|
|
541
600
|
root,
|
|
@@ -555,7 +614,7 @@ fn impact_context(event: Event, root: &Path, range: &str) -> Option<String> {
|
|
|
555
614
|
// is the symbols and their callers, and a substance already shown this
|
|
556
615
|
// day is not shown again (#314).
|
|
557
616
|
let substance = serde_json::to_string(&output.changed).unwrap_or_default();
|
|
558
|
-
let answer_key = text_key(root, &substance);
|
|
617
|
+
let answer_key = session_key(&text_key(root, &substance), session);
|
|
559
618
|
if is_seen(&answer_key) {
|
|
560
619
|
return None;
|
|
561
620
|
}
|
|
@@ -595,7 +654,12 @@ fn hook_json(event: Event, context: &str, gate: bool) -> String {
|
|
|
595
654
|
/// every push that follows.
|
|
596
655
|
pub fn respond(event: Event, stdin_json: &str, gate: bool) -> Option<String> {
|
|
597
656
|
let prepared = prepare(event, stdin_json)?;
|
|
598
|
-
let context = impact_context(
|
|
657
|
+
let context = impact_context(
|
|
658
|
+
event,
|
|
659
|
+
&prepared.root,
|
|
660
|
+
&prepared.range,
|
|
661
|
+
prepared.session.as_deref(),
|
|
662
|
+
);
|
|
599
663
|
mark_seen(&prepared.key);
|
|
600
664
|
context.map(|c| hook_json(event, &c, gate))
|
|
601
665
|
}
|
|
@@ -609,7 +673,12 @@ pub fn respond_within_deadline(event: Event, stdin_json: String, gate: bool) ->
|
|
|
609
673
|
let key = prepared.key.clone();
|
|
610
674
|
let (tx, rx) = std::sync::mpsc::channel();
|
|
611
675
|
std::thread::spawn(move || {
|
|
612
|
-
let _ = tx.send(impact_context(
|
|
676
|
+
let _ = tx.send(impact_context(
|
|
677
|
+
event,
|
|
678
|
+
&prepared.root,
|
|
679
|
+
&prepared.range,
|
|
680
|
+
prepared.session.as_deref(),
|
|
681
|
+
));
|
|
613
682
|
});
|
|
614
683
|
let left = Duration::from_secs(HOOK_DEADLINE_SECS).saturating_sub(started.elapsed());
|
|
615
684
|
let answer = match rx.recv_timeout(left) {
|
|
@@ -703,6 +772,18 @@ mod tests {
|
|
|
703
772
|
.dir,
|
|
704
773
|
Some("/r/sub".to_string())
|
|
705
774
|
);
|
|
775
|
+
// A directory only the shell can expand is not guessed at: the
|
|
776
|
+
// agent's cwd may be another repository entirely.
|
|
777
|
+
assert!(pre("cd $R && git commit -qm init").is_none());
|
|
778
|
+
assert!(pre("cd ~/x && git commit -m x").is_none());
|
|
779
|
+
assert!(pre("git -C \"$REPO\" commit -m x").is_none());
|
|
780
|
+
assert!(pre("cd $R && cd sub && git commit -m x").is_none());
|
|
781
|
+
assert_eq!(
|
|
782
|
+
detect(Event::PreToolUse, "cd $R && cd /abs && git commit -m x")
|
|
783
|
+
.unwrap()
|
|
784
|
+
.dir,
|
|
785
|
+
Some("/abs".to_string())
|
|
786
|
+
);
|
|
706
787
|
}
|
|
707
788
|
|
|
708
789
|
#[test]
|
|
@@ -28,6 +28,14 @@ const MAX_CALLERS_SHOWN_PER_FILE: usize = 3;
|
|
|
28
28
|
/// Contracts are a list of facts the reader can grep for; past this many the
|
|
29
29
|
/// list is the diff's own `pub` lines read back.
|
|
30
30
|
const MAX_CONTRACTS: usize = 12;
|
|
31
|
+
/// A declaration longer than this many lines before its body opens is
|
|
32
|
+
/// compared on its first lines only.
|
|
33
|
+
const MAX_SIGNATURE_LINES: usize = 12;
|
|
34
|
+
const CALLER_LOSING_LIMITS: &[crate::resource::LimitReason] = &[
|
|
35
|
+
crate::resource::LimitReason::Deadline,
|
|
36
|
+
crate::resource::LimitReason::DiscoveryTruncated,
|
|
37
|
+
crate::resource::LimitReason::CandidateLimit,
|
|
38
|
+
];
|
|
31
39
|
/// Paths listed before the rest fold into a count: the reader has the diff.
|
|
32
40
|
const MAX_CHANGED_FILES_LISTED: usize = 24;
|
|
33
41
|
|
|
@@ -81,8 +89,11 @@ pub struct ImpactOutput {
|
|
|
81
89
|
/// Contracts beyond `MAX_CONTRACTS`, schema changes never among them.
|
|
82
90
|
#[serde(default, skip_serializing_if = "crate::render::is_zero")]
|
|
83
91
|
pub contracts_omitted: usize,
|
|
84
|
-
/// The run stopped at a limit
|
|
85
|
-
///
|
|
92
|
+
/// The run stopped at a limit that can lose a caller — the deadline, a
|
|
93
|
+
/// truncated reverse discovery, a capped candidate universe — and `empty`
|
|
94
|
+
/// is never claimed while this is set. Caps every real repository trips
|
|
95
|
+
/// (a large lockfile, the fragment or edge cap) are not listed: they
|
|
96
|
+
/// fired on every run and made the hook speak on every commit (#306).
|
|
86
97
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
|
87
98
|
pub limits: Vec<crate::resource::LimitReason>,
|
|
88
99
|
/// Whether any test file was in view. Without one, an absent `tested_by`
|
|
@@ -333,6 +344,12 @@ fn named_container_of<'a>(core: &'a Fragment, all: &'a [Fragment]) -> Option<&'a
|
|
|
333
344
|
&& f.id != core.id
|
|
334
345
|
})
|
|
335
346
|
.min_by_key(|f| f.line_count())
|
|
347
|
+
// A module-level `export const f = (…) => …` is a definition in all
|
|
348
|
+
// but kind: nothing encloses it, and its importers are its callers
|
|
349
|
+
// (#324). Inside a function a variable is the function's business.
|
|
350
|
+
.or_else(|| {
|
|
351
|
+
(core.kind == FragmentKind::Variable && core.symbol_name.is_some()).then_some(core)
|
|
352
|
+
})
|
|
336
353
|
}
|
|
337
354
|
|
|
338
355
|
/// Of fragments nested in one another (a method and its impl, a function
|
|
@@ -382,6 +399,10 @@ fn is_public(path: &str, symbol: Option<&str>, content: &str) -> bool {
|
|
|
382
399
|
}
|
|
383
400
|
|
|
384
401
|
fn is_schema_file(path: &str) -> bool {
|
|
402
|
+
// A test named for the schema it checks is not a schema.
|
|
403
|
+
if crate::testfiles::is_test_path(Path::new(path)) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
385
406
|
let lower = path.to_lowercase();
|
|
386
407
|
SCHEMA_FILE_EXTENSIONS
|
|
387
408
|
.iter()
|
|
@@ -389,6 +410,72 @@ fn is_schema_file(path: &str) -> bool {
|
|
|
389
410
|
|| SCHEMA_FILE_MARKERS.iter().any(|m| lower.contains(m))
|
|
390
411
|
}
|
|
391
412
|
|
|
413
|
+
/// The revision a change is measured against: the left side of a range, a
|
|
414
|
+
/// lone revision itself, HEAD for the working tree.
|
|
415
|
+
fn base_revision(diff_range: Option<&str>) -> String {
|
|
416
|
+
match diff_range.map(crate::git::split_diff_range) {
|
|
417
|
+
Some((Some(base), _)) => base,
|
|
418
|
+
_ => diff_range.unwrap_or("HEAD").to_string(),
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/// A fragment without its decorators. The decorator belongs to the fragment
|
|
423
|
+
/// (Python `@app.route(…, methods={"GET"})`, a TS `@Component({…})`) but not
|
|
424
|
+
/// to the declaration: `export` comes after it, and a `{` in it would end the
|
|
425
|
+
/// declaration's head before the signature began.
|
|
426
|
+
fn without_decorators(content: &str) -> &str {
|
|
427
|
+
let mut rest = content;
|
|
428
|
+
while let Some(line) = rest.lines().next() {
|
|
429
|
+
let t = line.trim_start();
|
|
430
|
+
if !(t.is_empty() || t.starts_with('@')) {
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
rest = rest.get(line.len() + 1..).unwrap_or("");
|
|
434
|
+
}
|
|
435
|
+
rest
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/// The declaration a caller depends on: from the definition's first line
|
|
439
|
+
/// through the one that opens its body (`{`, `=>`, a trailing `:`), cut
|
|
440
|
+
/// there, so a body on the same line is not part of it.
|
|
441
|
+
fn declaration_head(content: &str) -> String {
|
|
442
|
+
let mut head = Vec::new();
|
|
443
|
+
for line in without_decorators(content)
|
|
444
|
+
.lines()
|
|
445
|
+
.take(MAX_SIGNATURE_LINES)
|
|
446
|
+
{
|
|
447
|
+
if let Some(at) = line.find("=>") {
|
|
448
|
+
head.push(&line[..at + 2]);
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
if let Some(at) = line.find('{') {
|
|
452
|
+
head.push(&line[..=at]);
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
head.push(line);
|
|
456
|
+
if line.trim_end().ends_with(':') || line.trim_end().ends_with(';') {
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
head.join("\n")
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/// Whether an exported symbol's declaration moved: its head is looked for in
|
|
464
|
+
/// the file at the base revision, whitespace-insensitively. A body-only edit
|
|
465
|
+
/// is what the callers list already says, and a contracts section repeated
|
|
466
|
+
/// on every refactor teaches the reader to skip it (#325). A file the base
|
|
467
|
+
/// does not have is new, and every export in it is a new contract.
|
|
468
|
+
fn signature_changed(state: &ScoredState, base: &str, core: &Fragment) -> bool {
|
|
469
|
+
let rel_path = rel(state, core.path());
|
|
470
|
+
let Ok(old) = crate::git::show_file_at_revision(&state.root_dir, base, Path::new(&rel_path))
|
|
471
|
+
else {
|
|
472
|
+
return true;
|
|
473
|
+
};
|
|
474
|
+
let squash = |s: &str| s.split_whitespace().collect::<Vec<_>>().join(" ");
|
|
475
|
+
let head = squash(&declaration_head(&core.content));
|
|
476
|
+
head.is_empty() || !squash(&old).contains(&head)
|
|
477
|
+
}
|
|
478
|
+
|
|
392
479
|
/// `(base, head)` for blame: a two-sided range as given, a single revision
|
|
393
480
|
/// against HEAD (its commits are `rev..HEAD`), nothing for the working tree.
|
|
394
481
|
fn commit_bounds(diff_range: Option<&str>) -> Option<(String, String)> {
|
|
@@ -526,6 +613,7 @@ pub fn build_impact(
|
|
|
526
613
|
cores.dedup_by(|a, b| a.id == b.id);
|
|
527
614
|
|
|
528
615
|
let bounds = commit_bounds(diff_range).filter(|_| state.commit_count >= 2);
|
|
616
|
+
let base = base_revision(diff_range);
|
|
529
617
|
|
|
530
618
|
let mut changed: Vec<ChangedSymbol> = Vec::new();
|
|
531
619
|
// Schema changes first, then the public symbols something calls, then
|
|
@@ -664,7 +752,9 @@ pub fn build_impact(
|
|
|
664
752
|
(Some((base, head)), true) => commits_touching(state, base, head, core),
|
|
665
753
|
_ => 0,
|
|
666
754
|
};
|
|
667
|
-
if is_public(core.path(), symbol, &core.content)
|
|
755
|
+
if is_public(core.path(), symbol, without_decorators(&core.content))
|
|
756
|
+
&& signature_changed(state, &base, core)
|
|
757
|
+
{
|
|
668
758
|
public_api.push((
|
|
669
759
|
callers.is_empty(),
|
|
670
760
|
Contract {
|
|
@@ -717,7 +807,12 @@ pub fn build_impact(
|
|
|
717
807
|
contracts.extend(public_api.into_iter().map(|(_, c)| c));
|
|
718
808
|
let contracts_omitted = contracts.len().saturating_sub(MAX_CONTRACTS);
|
|
719
809
|
contracts.truncate(MAX_CONTRACTS);
|
|
720
|
-
let limits = state
|
|
810
|
+
let limits: Vec<crate::resource::LimitReason> = state
|
|
811
|
+
.run
|
|
812
|
+
.reasons()
|
|
813
|
+
.into_iter()
|
|
814
|
+
.filter(|r| CALLER_LOSING_LIMITS.contains(r))
|
|
815
|
+
.collect();
|
|
721
816
|
let empty = changed.is_empty() && contracts.is_empty() && limits.is_empty();
|
|
722
817
|
let mut output = ImpactOutput {
|
|
723
818
|
schema: IMPACT_SCHEMA,
|
|
@@ -154,6 +154,36 @@ fn build_impact(
|
|
|
154
154
|
.map_err(|e| pyo3::exceptions::PyRuntimeError::new_err(e.to_string()))
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/// `diffctx hook <event>` for installs that reach diffctx through the PyPI
|
|
158
|
+
/// package (the Claude plugin runs it pinned under uvx): the JSON answer, or
|
|
159
|
+
/// `None` for silence. A panic is silence too — the hook contract is that a
|
|
160
|
+
/// failure never blocks the agent's tool call.
|
|
161
|
+
#[pyfunction]
|
|
162
|
+
#[pyo3(signature = (event, stdin_json, gate = false))]
|
|
163
|
+
fn hook_respond(
|
|
164
|
+
py: Python<'_>,
|
|
165
|
+
event: &str,
|
|
166
|
+
stdin_json: String,
|
|
167
|
+
gate: bool,
|
|
168
|
+
) -> PyResult<Option<String>> {
|
|
169
|
+
let kind = match event {
|
|
170
|
+
"pretooluse" => crate::hook::Event::PreToolUse,
|
|
171
|
+
"posttooluse" => crate::hook::Event::PostToolUse,
|
|
172
|
+
other => {
|
|
173
|
+
return Err(pyo3::exceptions::PyValueError::new_err(format!(
|
|
174
|
+
"unknown hook event {other:?}: pretooluse or posttooluse"
|
|
175
|
+
)));
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
Ok(py.detach(move || {
|
|
179
|
+
std::panic::catch_unwind(move || {
|
|
180
|
+
crate::hook::respond_within_deadline(kind, stdin_json, gate)
|
|
181
|
+
})
|
|
182
|
+
.ok()
|
|
183
|
+
.flatten()
|
|
184
|
+
}))
|
|
185
|
+
}
|
|
186
|
+
|
|
157
187
|
fn diff_range_or_head(diff_range: &str) -> &str {
|
|
158
188
|
if diff_range.is_empty() {
|
|
159
189
|
"HEAD"
|
|
@@ -681,6 +711,7 @@ pub fn _diffctx(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
|
681
711
|
m.add_function(wrap_pyfunction!(build_diff_context, m)?)?;
|
|
682
712
|
m.add_function(wrap_pyfunction!(build_locate, m)?)?;
|
|
683
713
|
m.add_function(wrap_pyfunction!(build_impact, m)?)?;
|
|
714
|
+
m.add_function(wrap_pyfunction!(hook_respond, m)?)?;
|
|
684
715
|
m.add_function(wrap_pyfunction!(compute_scored_state, m)?)?;
|
|
685
716
|
m.add_function(wrap_pyfunction!(select_with_params, m)?)?;
|
|
686
717
|
m.add_class::<PyScoredState>()?;
|
|
@@ -334,12 +334,41 @@ def main() -> None:
|
|
|
334
334
|
if sys.argv[1:2] == ["mcp"]:
|
|
335
335
|
_run_mcp_server()
|
|
336
336
|
return
|
|
337
|
+
if sys.argv[1:2] == ["hook"]:
|
|
338
|
+
_run_hook(sys.argv[2:])
|
|
337
339
|
|
|
338
340
|
from ._app import run
|
|
339
341
|
|
|
340
342
|
run()
|
|
341
343
|
|
|
342
344
|
|
|
345
|
+
_HOOK_USAGE = "usage: diffctx hook {pretooluse [--gate] | posttooluse} < event.json"
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def _run_hook(argv: list[str]) -> NoReturn:
|
|
349
|
+
# Claude Code's contract, as in the native binary: exit 0 with the JSON
|
|
350
|
+
# answer or nothing. A non-zero exit blocks the agent's tool call, so
|
|
351
|
+
# everything past argument parsing is silence on failure.
|
|
352
|
+
event, flags = (argv[0], argv[1:]) if argv else ("", [])
|
|
353
|
+
if event not in ("pretooluse", "posttooluse") or any(f != "--gate" for f in flags):
|
|
354
|
+
_exit_usage_error(_HOOK_USAGE)
|
|
355
|
+
if flags and event != "pretooluse":
|
|
356
|
+
_exit_usage_error(_HOOK_USAGE)
|
|
357
|
+
try:
|
|
358
|
+
from ._diffctx import hook_respond
|
|
359
|
+
|
|
360
|
+
payload = sys.stdin.buffer.read().decode("utf-8", "replace")
|
|
361
|
+
answer = hook_respond(event, payload, bool(flags))
|
|
362
|
+
if answer:
|
|
363
|
+
# Claude Code reads UTF-8; Windows' default stdout is cp1252, which
|
|
364
|
+
# mangles the answer's dashes and cannot encode some of it at all.
|
|
365
|
+
sys.stdout.buffer.write((answer + "\n").encode("utf-8"))
|
|
366
|
+
sys.stdout.buffer.flush()
|
|
367
|
+
except Exception:
|
|
368
|
+
pass
|
|
369
|
+
raise SystemExit(0)
|
|
370
|
+
|
|
371
|
+
|
|
343
372
|
def _run_mcp_server() -> None:
|
|
344
373
|
# MCP clients that resolve the executable from the published package name
|
|
345
374
|
# land on this entry point rather than diffctx-mcp; without this branch they
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.18.2"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.18.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/config_edges/build_system.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{diffctx-1.18.1 → diffctx-1.18.2}/crates/diffctx-native/src/edges/config_edges/kubernetes.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|