Skip to content

feat(cli): @path tab-completion in REPL input#198

Merged
emal-avala merged 1 commit intomainfrom
feat/at-file-tab-completion
Apr 23, 2026
Merged

feat(cli): @path tab-completion in REPL input#198
emal-avala merged 1 commit intomainfrom
feat/at-file-tab-completion

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

@path expansion on submit has worked for a while — typing @src/foo.rs in a prompt inlines the file's contents. But users had to type the full path. This PR adds tab-completion for @ paths anywhere in the input line.

> explain @src/m<TAB>
> explain @src/main.rs                 ← after tab

Rules

  • The @ must be at the start of the line or preceded by whitespace, so user@example.com doesn't accidentally trigger path completion mid-word
  • Directories are listed first with a trailing / so Tab-tab descends into them
  • Dotfiles are hidden unless the partial starts with . (matches shell convention)
  • Absolute paths and .. components are rejected — stays within cwd
  • Up to 50 candidates returned; ordering: dirs alphabetical, then files alphabetical
  • Multiple @ tokens on a line — only the one the cursor is in completes

Display format:

  • Files: src/main.rs
  • Directories: src/ (dir)

Interaction with existing completers

Slash-command completion (the fuzzy scorer from #195) is unchanged. @ completion only fires when the cursor is in an @ context — slash completion handles everything else. The @ expansion on submit path (from #…) is also unchanged; this PR just makes it easier to produce a valid @path in the first place.

Test plan

  • cargo fmt --all — clean
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo test -p agent-code --bin agent at_completion_tests — 13/13 pass
    • Context detection: start of line, after whitespace, rejected mid-word, multi-@, whitespace in partial, no @, empty partial (7 tests)
    • Path completion: listing, prefix filter, subdir descent, dotfile gating, traversal rejection, missing dir (6 tests)
  • Manual: explain @s<TAB> lists src/, sdks/, etc.; explain @src/m<TAB> expands to @src/main.rs

`@path` expansion on submit has worked for a while, but users had to
type the full path. Tab-completion now works anywhere in the input
line whenever the cursor is inside an `@token`:

  > explain @src/m<TAB>
  > explain @src/main.rs                ← after tab

Rules:

  * The `@` must be at the start of the line or preceded by whitespace
    (so `user@example.com` doesn't accidentally trigger path completion)
  * Directories are listed first with a trailing `/` so Tab-tab descends
  * Dotfiles are hidden unless the partial starts with `.`
  * Absolute paths and `..` components are rejected (stays within cwd)
  * Up to 50 candidates returned; ordering: dirs alpha, then files alpha
  * Multiple `@` tokens on a line — only the one the cursor is in
    completes

Display format: `src/main.rs` for files, `src/  (dir)` for directories.

Slash-command completion is unchanged; `@` completion only fires when
the cursor is in an `@` context, slash completion handles everything
else.

Tests: 13 unit tests covering context detection (start of line, after
whitespace, rejected mid-word, multi-@, whitespace in partial, no @,
empty partial) and path completion (listing, prefix filter, subdir
descent, dotfile gating, traversal rejection, missing dir).
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@emal-avala emal-avala merged commit 94ebfd3 into main Apr 23, 2026
14 checks passed
@emal-avala emal-avala deleted the feat/at-file-tab-completion branch April 23, 2026 05:29
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