Repository navigation
fix(init): preserve user prose during uninstall - #4405
Conversation
📊 Automated PR Analysis
SummaryFixes two bugs in RTK init/uninstall logic: the RTK block end-marker search is now anchored to search only after the start marker (preventing a stray earlier closing marker from corrupting content), and @RTK.md reference removal now requires an exact trimmed line match instead of a prefix match (preventing deletion of user prose lines that merely start with @RTK.md). Adds regression tests covering malformed markers, repeated cleanup, whitespace-padded references, real uninstall behavior, and dr… Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
A closing marker the user quotes after the RTK block must not extend the removal over their prose. Co-Authored-By: Claude Opus 5.5 <[email protected]>
KuSh
left a comment
There was a problem hiding this comment.
Round 1 — APPROVED, follow-ups filed
Claim: remove_rtk_block pairs the opening marker with a closing marker found after it, and Claude uninstall removes only lines whose trimmed text is exactly @RTK.md.
Scope: accept. #4425 changes the same lines of remove_rtk_block; this PR came first and is narrower, so it lands first and #4425's anchoring hunk becomes a no-op on rebase.
Ran: rtk init -g with --uninstall, --uninstall --dry-run, --auto-patch (install migration), --copilot --uninstall and --codex --uninstall, over 13 instruction files (prose starting with @RTK.md, a whitespace-padded reference, CRLF prose with no reference, a closing marker quoted before the block, after the block, and before both the block and a reference, an opening marker quoted before the block, install followed by uninstall, and two uninstalls in a row), on develop e542dca and on ff4ec6e, in an isolated HOME. Invariants: non-default targets (Copilot, Codex, install migration); under the hook (rtk rewrite leaves these commands unchanged); every decision. Savings: n/a (not a filter).
Pins: 4 decisions, 7 mutations, 1 survived the suite: pairing with the last closing marker instead of the first, on the line this PR rewrites. Develop already picks the first, so this is not new behaviour; the fixup below pins it.
Matrix: executed this round; pin check: executed this round.
CI @ff4ec6e1f: all green; @b15136a13 (fixup): all green.
Blocks merge (0, frozen at round 1)
Filed as follow-ups
- #4650: install and
init --showstill treat any mention of@RTK.mdas the reference line. Claude install adds nothing yet reports "reference added", Codex install rewrites the user's prose to an absolute path, and a BOM-prefixed reference line survives uninstall. All of this is outside this PR's hunks and behaves the same on develop; filed. - #3403: an opening marker quoted above the block still makes
remove_rtk_blockdelete the user's text from the quote to the end of the block, with the same output on develop; comment added with the repro. #3403's line-ending item is also still open, as the PR says.
Checked and correct — no need to re-verify
- Closing marker quoted before the block: develop duplicated the span and left the block installed, and a second uninstall duplicated it again; here the block is removed and a second run is a no-op. The same holds on install migration and in the Copilot and Codex uninstall paths, which all go through
remove_rtk_block. - A closing marker with no opening marker after it leaves the file unchanged and returns
false. - Prose lines that start with or contain
@RTK.mdare kept, and both the bare and the whitespace-padded reference lines are removed. - A CRLF file with prose but no reference line is left byte-identical. Develop rewrote it to LF and deleted a line.
--dry-runleaves the file untouched.- The new uninstall tests go through the real
uninstall()with an isolated Claude dir. Each mutation of the uninstall gate and filter (contains,starts_with, no trim,trim_end, always true) turns one of them red. - The
src/llm_proxy.rshunk removes a duplicated, identical#[cfg(feature = "engine")]attribute; no effect.
Your questions
None asked.
Next
Fixup b15136a pushed, code-reviewed: it adds test_remove_rtk_block_stops_at_first_end_marker, which fails when the closing marker is searched with rfind (a closing marker quoted after the block would otherwise swallow the prose before it). Approving.
Rounds: 1. Threads: 0 open, 0 resolved this round.
Summary
@RTK.mdreference lines during Claude uninstall. Preserve user prose, similarly named files, and files with no actual RTK reference.Related to #3403. This is a partial fix for the marker-pairing and prefix-match defects. Line-ending and blank-line normalization when removing an actual artifact remain unchanged, so this PR does not resolve the whole issue.
Test plan
cargo test --locked hooks::init::(313 passed).cargo fmt --all --check.cargo clippy --locked --all-targets.cargo test --locked --all(4,095 passed, 0 failed, 8 ignored).git diff --check.Validated on Linux with Rust 1.91.0. Uninstall tests use isolated temporary agent/home directories.