fix: preserve double-digit command placeholders#280
Open
thedalbee wants to merge 1 commit into
Open
Conversation
Command templates replace numbered placeholders with literal string replacement. Replacing in ascending order lets short placeholders such as $1 consume the prefix of $10 before the intended replacement runs, so templates with double-digit placeholders produce corrupted output. Constraint: Keep existing last-placeholder-captures-rest behavior unchanged Rejected: Regex replacement rewrite | larger change than needed for the prefix-collision bug Confidence: high Scope-risk: narrow Directive: Preserve descending replacement unless the placeholder parser is replaced with token-aware substitution Tested: Docker rust:latest cargo test -p cortex-commands test_substitute_two_digit_placeholders_before_prefixes -- --nocapture Tested: Docker rust:latest cargo test -p cortex-commands substitute -- --nocapture Tested: Docker rust:latest cargo check -p cortex-commands Tested: Docker rust:latest cargo fmt --check --package cortex-commands Tested: git diff --check
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
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
$1no longer corrupts$10,$11, etc.$1and$10.$ARGUMENTShandling and the last-numbered-placeholder captures-rest behavior.Related
Verification
python3 /Users/dalbee/ws/bounty-work/tools/repo_vet.py /Users/dalbee/ws/bounty-work/cortex --format summaryreturned CRITICAL, so project commands were run only in Docker with a read-only source mount copied into the container.docker run --rm --network=bridge -v /Users/dalbee/ws/bounty-work/cortex:/src:ro rust:latest bash -lc 'source /usr/local/cargo/env 2>/dev/null || true; rustup component add rustfmt >/dev/null; mkdir -p /work; cp -a /src /work/cortex; cd /work/cortex; cargo fmt --check --package cortex-commands; cargo test -p cortex-commands test_substitute_two_digit_placeholders_before_prefixes -- --nocapture; cargo test -p cortex-commands substitute -- --nocapture; cargo check -p cortex-commands'git diff --checkAI-assisted with Codex; I reviewed the diff and verification output before submitting.