Skip to content

feat(cli): /open <path> opens an existing file in $EDITOR/$VISUAL#208

Merged
emal-avala merged 1 commit intomainfrom
feat/open-file
Apr 23, 2026
Merged

feat(cli): /open <path> opens an existing file in $EDITOR/$VISUAL#208
emal-avala merged 1 commit intomainfrom
feat/open-file

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

Adds `/open ` to edit an existing file from the REPL. Complements `/editor`, which is for composing a new scratch prompt.

  • `/open src/main.rs` — opens the file in the configured editor
  • `/open notes/new.md --create` — creates an empty file (with any missing parent dirs) and opens it

Uses the same editor resolver as `/editor`: `$VISUAL` → `$EDITOR` → fallback to `vim`, `vi`, or `nano` if found on PATH.

Why

Users already have `/files` to list session files and `/editor` to compose prompts, but no quick way to open a file the agent just mentioned. Adding a first-class `/open` closes that gap.

Test plan

  • `cargo fmt --all`
  • `cargo clippy -p agent-code --all-targets -- -D warnings`
  • `cargo test -p agent-code --bin agent` (94 passed)
  • New tests:
    • `parse_open_args_accepts_bare_path`
    • `parse_open_args_recognizes_create_before_path` / `_after_path`
    • `parse_open_args_rejects_multiple_paths`
    • `parse_open_args_returns_none_for_empty_flags_only`
    • `resolve_path_against_cwd_joins_relative` / `_preserves_absolute`

Adds a small companion to /editor. Where /editor composes a scratch
prompt, /open opens the file you point at:

  /open src/main.rs              edit an existing file
  /open notes/new.md --create    make an empty file, then edit

Reuses the same resolver as /editor (\$VISUAL, then \$EDITOR, then
falls back to vim/vi/nano). Errors clearly when the path is a dir,
the file is missing, or no editor is configured.
@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 9913437 into main Apr 23, 2026
14 checks passed
@emal-avala emal-avala deleted the feat/open-file branch April 23, 2026 08:08
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