Skip to content

fix: preserve double-digit command placeholders#280

Open
thedalbee wants to merge 1 commit into
CortexLM:mainfrom
thedalbee:codex/placeholder-order-53172
Open

fix: preserve double-digit command placeholders#280
thedalbee wants to merge 1 commit into
CortexLM:mainfrom
thedalbee:codex/placeholder-order-53172

Conversation

@thedalbee
Copy link
Copy Markdown

Summary

  • Replace numbered command placeholders in descending order so $1 no longer corrupts $10, $11, etc.
  • Add regression coverage for a template containing both $1 and $10.
  • Preserve existing $ARGUMENTS handling 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 summary returned 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 --check

AI-assisted with Codex; I reviewed the diff and verification output before submitting.

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
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant