feat(cli): add adopt replace shortcut - #10
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an explicit tuck adopt --replace workflow to resolve package use real-file conflicts via a target-wins (but still explicit, --apply-gated) reconciliation path, and surfaces that path to users via human and JSON plan conflict hints.
Changes:
- Add
--replacetotuck adopt, enabling safe target-wins replacement of an existing regular package file (including copy-mode cases). - Add optional
hintstrings to plan conflicts and render them in console + JSON output (notably forpackage usereal-file conflicts). - Harden copy-apply behavior around overwrite edge cases (symlink destinations, hardlinks), with added unit/acceptance coverage and a new
misesandbox task.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/plan/model.go | Adds Conflict.Hint field for optional plan conflict hints (JSON). |
| internal/plan/apply.go | Tightens copy destination handling for overwrite and avoids same-file truncation; refactors finish step. |
| internal/plan/apply_test.go | Adds regression tests for overwrite-to-symlink rejection and hardlink same-file behavior. |
| internal/command/planconsole/plan.go | Renders conflict hints in human console output. |
| internal/command/planconsole/plan_test.go | Tests console rendering includes the new conflict hint line. |
| internal/command/pkgcmd/plan_build.go | Adds adopt/replace hint emission for package use real-file conflicts when safe. |
| internal/command/pkgcmd/plan_build_test.go | Tests hint presence/absence for real-file conflicts based on package-path safety. |
| internal/command/filecmd/plan_build.go | Implements adopt --replace planning, including copy-mode/state interactions and unsafe-path rejection. |
| internal/command/filecmd/plan_build_test.go | Adds unit coverage for adopt --replace in symlink and copy modes, incl. state cleanup scenarios. |
| internal/command/filecmd/commands.go | Extends AdoptRequest with Replace. |
| internal/app/file_commands.go | Wires --replace flag into the CLI and request struct. |
| docs/cli-spec.md | Updates CLI spec for adopt --replace semantics and plan conflict hint contract. |
| acceptance/testdata/script/target/target.txtar | Adds acceptance coverage for adopt --replace dry-run/apply, unsafe package paths, and copy-mode config. |
| acceptance/testdata/script/rendering/rendering.txtar | Updates expected human plan rendering to include the new hint line. |
| acceptance/testdata/script/json/json.txtar | Updates expected JSON plan output to include conflicts[].hint. |
| .mise/tasks/sandbox/container | Adds mise run sandbox:container task for manual root-context testing in a Fedora podman sandbox. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tuck adopt --replacetarget-wins reconciliationpackage useconservative while adding human/JSON conflict hintsmise run sandbox:containerfor manual user/root-context testingCloses #8.
Tests
mise run checkUser-visible behavior
package usereal-file conflicts now suggesttuck adopt --replace ...; users can explicitly replace package source from the target while preserving dry-run/--applysemantics.Docs/backlog
Updated
docs/cli-spec.mdforadopt --replace, conflict hints, and JSON conflict hints.AI assistance
Implemented with AI assistance; reviewed and validated by the maintainer.