Repository navigation
feat(util): add format-aware merge for JSON, TOML, and YAML files - #14011
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 8 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (2)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change adds a public structured-merge module to ChangesStructured Merge
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Merge Risk: ⚪ Minimal · up to The reported merge failures are not present in this change; it is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 2 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Add `mise_util::structured_merge`, which sets some keys of a JSON, TOML, or YAML file and leaves the rest alone, plus a `contains` check that reports whether a file already holds those keys. TOML edits keep comments and key order through `toml_edit`, YAML goes through the new `yaml_merge` helper, and JSON keeps key order and the file's indent. Nested tables merge recursively, arrays and scalars are replaced, and nothing is ever removed. Nothing calls it yet. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M48GXJAJPR0EXQC7G4QNW7WR
Parse and compare TOML as TOML values and YAML as YAML values instead of converting both to JSON. Valid YAML with non-string keys (`on:`, `1:`) and TOML `inf`/`nan` no longer fail when those keys are not owned, and a TOML datetime is no longer treated as the string that prints like it. A TOML value that already matches the source is now compared by value, not by its printed text, so an equal array keeps its spacing and comments when another key changes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M48VH8PA67RA0P4E3S7TN3X4
9982e50 to
4e05f81
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4e05f81. Configure here.
…tables Merging into JSON parsed the whole target into `serde_json::Value` and wrote it back, so an untouched integer past u64 became a rounded float and `1e3` became `1000.0`. Values the source does not touch are now kept as the exact text they were parsed from. `[[array-of-tables]]` items never compared equal to the source's, so they were replaced, with their comments and spacing, whenever another key changed. TOML items are now compared by value for every item kind. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M48XC9HAG8MZ9ZZACCJ0SQGC
Instruction countsNothing was compared, and so nothing was gated. No series appears on both sides: either the base has no measurements recorded, or the two were measured on different runner classes, which are deliberately not comparable — counts shift between machine types by more than a real regression does. New, nothing to compare against: Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.
|
… file (#14012) <!-- entire-trail-link-start --> https://entire.io/gh/jdx/mise/trails/461 <!-- entire-trail-link-end --> Tools like Codex, Claude Code, and oh-my-pi write their own state into the same JSON, TOML, or YAML file that holds your settings. A `symlink` or `copy` dotfile entry fights them for the whole file, and a `block` can't survive an application that rewrites the file. A new `merge` edit entry owns only the keys in its source and leaves the rest to the application: ```toml [dotfiles] "~/.codex/config.toml/shared" = { source = "codex/shared.toml", merge = true } "~/.claude/settings.json/shared" = { source = "claude/shared.json", merge = true } "~/.omp/agent/config.yml/shared" = { source = "omp/shared.yml", merge = true } ``` With `codex/shared.toml` holding `model = "gpt-5"` and `[tui] theme = "light"`, `mise dot apply` sets those two keys in `~/.codex/config.toml` and leaves the app's `[plugins.*]` tables, `notify`, and comments exactly where they were. The format comes from the target's extension, and a missing target is created from the source. - Tables merge recursively; scalars and arrays are replaced. Keys only the target has are never touched, and keys removed from the source are not removed from the target. - `mise dot status` and `mise dot diff` report drift only in owned keys, so keys the application adds never show up. - TOML and YAML keep comments, order, and formatting of untouched keys. JSON keeps key order and indent. A target that does not parse (including JSON with comments) is reported and never overwritten. - `template = "tera"` renders the source first, like other edit entries. `mise dot unapply` leaves merged keys in place because the application may have changed them. Also teaches the whole-file entry parsers (`files.rs`, dotfile groups) that `merge` marks an edit. Without that a merge entry was also read as a whole-file symlink at `~/.codex/config.toml/shared`, which the new e2e test caught. Adds `merge` to `schema/mise.json` and a section to `docs/dotfiles.md`. Open design questions from the discussion, answered conservatively and easy to change: removing a key from the source does not remove it from the target, and arrays are replaced rather than merged. A modify-script entry (chezmoi's `modify_`) is not part of this PR. Verified with the new `e2e/cli/test_dotfiles_merge_edits` (create, drift, in-place apply across all three formats, unapply, bad extension, unparseable target), the existing dotfiles edit/files/groups/absent e2e tests, unit tests, and `cargo clippy --workspace --all-features --all-targets -- -D warnings`. Closes nothing directly; addresses the request in #13986. Stacked on #14011. *AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: 2.1.288.* 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes dotfile apply semantics and writes user config files in place; conflict and parse-failure guards reduce overwrite risk but behavior is new and broadly user-facing. > > **Overview** > Adds **`merge = true`** dotfile edit entries so mise can own only selected keys in JSON, TOML, or YAML targets while apps keep the rest of the file (comments and formatting where supported). > > The edit engine gains **`EditOp::Merge`**, wired through apply/status/diff/unapply: drift is judged on owned keys via `structured_merge`, invalid targets/sources are refused, and **unapply leaves merged keys untouched**. **`structured_merge::conflicts`** detects when multiple entries set the same dotted path to different values; apply also blocks **format mismatches** on the same inode/path (hard links, filtered applies) and skips rendering unselected template siblings for conflict checks. > > Config/schema/docs are updated so `merge` is treated as an edit (not a whole-file entry), with validation on pull and a large e2e suite. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a985977. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Dotfile entries can merge source keys into JSON, TOML, and YAML targets while preserving target-only keys and formatting. * Matching nested objects and tables merge recursively; other source values replace target values. Merge sources can use Tera templates. * Dry runs, status, and diffs report changes to source-owned keys. * **Bug Fixes** * Conflicting values and invalid source or target data are reported without overwriting the target. * Unapply leaves merged keys in place, and changes to unowned keys do not affect sync status. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
<!-- entire-trail-link-start --> https://entire.io/gh/jdx/mise/trails/430 <!-- entire-trail-link-end --> ### 🚀 Features - **(bootstrap)** add a tool-update service that keeps auto_update tools current by @jdx in [#14040](#14040) - **(config)** add global section write targets by @jdx in [#14018](#14018) - **(config)** move mise's auto-update settings under self_update.* by @jdx in [#14038](#14038) - **(dotfiles)** report notification availability and add notify command by @jdx in [#14009](#14009) - **(dotfiles)** add merge entries that own only some keys of a config file by @jdx in [#14012](#14012) - **(http)** add headers option for bearer and API-key auth by @jdx in [#14022](#14022) - **(install)** add an opt-in identity-based install layout by @jdx in [#13951](#13951) - **(install)** keep identity-layout installations in a shorter directory on Windows by @jdx in [#13952](#13952) - **(installs)** list installations and choose the one requests without a lockfile use by @jdx in [#13953](#13953) - **(installs)** move legacy installations into the identity layout by @jdx in [#13955](#13955) - **(lock)** preserve shared lockfile entries on request by @jdx in [#13980](#13980) - **(npm)** install packages from git repositories by @jdx in [#14044](#14044) - **(prune)** add prune.exclude to keep chosen tools from being pruned by @jdx in [#14030](#14030) - **(secrets)** add [secrets.fnox] project config and mise secrets ls by @jdx in [#13967](#13967) - **(secrets)** add --secrets and --secrets-all to mise run and mise x by @jdx in [#13975](#13975) - **(task)** give tasks only the fnox secrets they list by @jdx in [#13974](#13974) - **(task)** allow {{ secrets.X }} in task env values by @jdx in [#13978](#13978) - **(upgrade)** update global tools before they run with auto_update by @jdx in [#14026](#14026) - **(util)** add a comment-preserving YAML merge helper by @jdx in [#14010](#14010) - **(util)** add format-aware merge for JSON, TOML, and YAML files by @jdx in [#14011](#14011) ### 🐛 Bug Fixes - **(backend)** read a repository's packslip release list once per command by @jdx in [#13991](#13991) - **(backend)** only warn about a backend switch when the backend kind changes by @jdx in [#14032](#14032) - **(bootstrap)** don't create history state or fail on its lock unless writing files by @jdx in [#14029](#14029) - **(cargo)** serialize rustup state across cargo install fallbacks by @jdx in [#14042](#14042) - **(config)** keep global config when a project ignore resolves onto it via symlink by @jdx in [#14006](#14006) - **(doctor)** only warn about backend mismatches the registry serves by @jdx in [#14005](#14005) - **(dotenv)** leave a value ending in escaped whitespace unquoted by @jdx in [#13956](#13956) - **(dotfiles)** explain missing sources in conflicting declaration errors by @himkt in [#13973](#13973) - **(dotfiles)** skip legacy link discovery for group entries by @jdx in [#14023](#14023) - **(dotnet)** disable lockfile url enforcement for dotnet tool backend by @james-newell-forge in [#13971](#13971) - **(env)** fully redact secrets when redaction values overlap by @jdx in [#13962](#13962) - **(github)** log partial attestation verification failures by @jdx in [#14035](#14035) - **(github)** warn when attestations are skipped because the Sigstore trust root is unreachable by @jdx in [#14036](#14036) - **(http)** fetch a cached GitHub release once when callers race by @jdx in [#13990](#13990) - **(http)** don't retry a 429 whose Retry-After outlasts the backoff by @jdx in [#14027](#14027) - **(http)** retry downloads when an HTTP/2 stream reset fails the body read by @jdx in [#14049](#14049) - **(install)** switch backends into a new installation, and resolve CLI-named versions without guessing by @jdx in [#13957](#13957) - **(install)** keep a version incomplete until its postinstall hook succeeds by @jdx in [#14037](#14037) - **(install)** keep incomplete-install markers out of the cache by @jdx in [#14051](#14051) - **(mcp)** reject run_task task names that start with a dash by @jdx in [#13961](#13961) - **(oci)** stream large blob uploads in one PATCH by @jdx in [#14017](#14017) - **(outdated)** don't bump vendor-only requests like java@temurin by @jdx in [#14031](#14031) - **(prune)** keep versions that a running process was started from by @jdx in [#14020](#14020) - **(prune)** snapshot what templated tool versions render to in the identity layout by @jdx in [#14025](#14025) - **(pypi)** build uv tool venvs on mise's python by @jdx in [#14024](#14024) - **(pypi)** lock from <root>/simple/ for JSON URLs by @deiga in [#14007](#14007) - **(python)** create the auto uv venv with mise's python during install by @halms in [#13981](#13981) - **(release)** skip the vfox-tiny test fixture when vendoring embedded plugins by @jdx in [#14047](#14047) - **(ruby)** keep Gemfile reload watches out of executable hooks by @DahanItamar in [#13985](#13985) - **(task)** list monorepo subproject tasks in the mise://tasks MCP resource by @jdx in [#14053](#14053) - **(uninstall)** report each version once in a dry run by @jdx in [#13992](#13992) ### 📚 Documentation - **(http)** show a package proxy recipe for url_replacements by @jdx in [#14050](#14050) - **(readme)** add Star History badges by @jdx in [#13968](#13968) - keep code blocks and alert markers out of llms.txt summaries by @DahanItamar in [#14034](#14034) ### ⚡ Performance - **(secrets)** read cached fnox secrets from the fnox daemon by @jdx in [#13979](#13979) ### 🧪 Testing - **(e2e)** stabilize task timing assertions by @jdx in [#13977](#13977) - **(go)** disable minimum_release_age in go install e2e by @jdx in [#13989](#13989) ### 📦️ Dependency Updates - lock file maintenance by @renovate[bot] in [#13963](#13963) - update github actions by @renovate[bot] in [#13994](#13994) - update rust crates by @renovate[bot] in [#13996](#13996) - update rust crate nodejs-semver to v7 by @renovate[bot] in [#13999](#13999) - update jdx/mise-action action to v5 by @renovate[bot] in [#13997](#13997) - update jdx/renovate-config action to v1.0.2 by @renovate[bot] in [#14003](#14003) - update dependency usage to latest by @renovate[bot] in [#14004](#14004) - update jdx crates to v6.12.1 by @renovate[bot] in [#14002](#14002) - update rust crate sigstore-verify to 0.14 by @jdx in [#14019](#14019) - update rattler by @renovate[bot] in [#13998](#13998) - update rust crate clx to v3.0.4 by @renovate[bot] in [#14028](#14028) ### 📦 Registry - update moved plugin references by @jdx in [#13972](#13972) ### Chore - **(ci)** update pr-closer to v1.3.0 by @jdx in [83f3e90](83f3e90) ### Ci - update pr closer action by @jdx in [#13970](#13970) - add manual M4 sandbox pilot by @jdx in [09e8f8f](09e8f8f) ### Security - **(env)** keep secrets inherited from a parent mise out of templates, caches and other tasks by @jdx in [#13966](#13966) ### New Contributors - @DahanItamar made their first contribution in [#14034](#14034) - @deiga made their first contribution in [#14007](#14007) - @james-newell-forge made their first contribution in [#13971](#13971) ## 📦 Aqua Registry Updates ### New Packages (3) - [`editorconfig/editorconfig-core-go`](https://github.com/editorconfig/editorconfig-core-go) - [`jdx/jactionlint`](https://github.com/jdx/jactionlint) - [`tontinton/maki`](https://github.com/tontinton/maki) ### Updated Packages (3) - [`anchore/syft`](https://github.com/anchore/syft) - [`eksctl-io/eksctl`](https://github.com/eksctl-io/eksctl) - [`regclient/regclient/regsync`](https://github.com/regclient/regclient)

https://entire.io/gh/jdx/mise/trails/460
Adds
mise_util::structured_merge, which sets some keys of a JSON, TOML, or YAML file and leaves the rest alone, pluscontains, which reports whether a file already holds those keys. Nothing calls it yet; themergedotfile entries stacked on top use it (#13986).toml_edit: comments, key order, and the formatting of untouched keys survive.yaml_mergehelper from the PR below.containscompares parsed values and looks only at the source's keys, so a target that already satisfies the source is returned byte for byte and keys the application added are not drift.serde_json'spreserve_orderfeature was already enabled workspace-wide through feature unification;mise-utilnow asks for it explicitly.Cargo.lockdoes not change.Verified with unit tests (per-format merges, idempotence, unparseable and non-table input),
cargo clippy --workspace --all-features --all-targets -- -D warnings, andcargo +1.95 check.Stacked on #14010.
AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: 2.1.288.
🤖 Generated with Claude Code
Note
Low Risk
New, unused library code with tests only—no behavior change to existing mise flows until wired in.
Overview
Adds
mise_util::structured_mergeso callers can patch only the keys they own in shared config files (JSON, TOML, YAML) without rewriting the rest.mergeapplies source keys with shared semantics (nested objects merge recursively; scalars and arrays are replaced; extra target keys are never removed), and returns the target byte-for-byte when it already matches.containschecks drift using only the source’s keys.Format-specific writers aim to preserve hand-edited formatting: JSON uses
serde_jsonraw_valueto keep untouched value text, key order, and indent; TOML merges viatoml_editto keep comments and decorations; YAML delegates to the existingyaml_mergehelper.serde_jsoninmise-utilnow explicitly enablespreserve_orderandraw_value. The module is exported fromlib.rsand covered by unit tests; nothing in the repo calls it yet.Reviewed by Cursor Bugbot for commit 44ec1f6. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit