Skip to content

feat(cli): add /add-dir to track extra directories alongside cwd#155

Merged
emal-avala merged 6 commits intomainfrom
feat/cmd-add-dir
Apr 22, 2026
Merged

feat(cli): add /add-dir to track extra directories alongside cwd#155
emal-avala merged 6 commits intomainfrom
feat/cmd-add-dir

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

Adds `/add-dir` — lets the user extend the session's working set beyond `cwd` without restarting. Tracked dirs are surfaced in the system prompt so the agent knows it's allowed to read and edit there without re-asking on every cross-directory operation.

Forms:

  • `/add-dir` — list tracked extras
  • `/add-dir ` — add one (path must exist; stored canonicalized)
  • `/add-dir --remove ` — remove one
  • `/add-dir --clear` — remove all

Also surfaces the list in `/context`.

Why

Today, when you're working on a mono-repo worktree and want the agent to reference a sibling worktree (or a standalone package outside the repo), you either have to restart in the new dir or hand-wave file paths at the agent. This makes the boundary explicit.

Implementation

  • New `additional_dirs: Vec` on `AppState` (session-scoped, not persisted)
  • `build_system_prompt` injects the list under `# Environment` when non-empty
  • Paths are canonicalized on add so the agent sees unambiguous absolute paths

Test plan

  • `cargo check` passes
  • `cargo clippy --no-deps` clean
  • `cargo test -p agent-code-lib --lib query` (2 new tests: prompt omits block when empty, lists entries when populated)
  • `cargo test -p agent-code-lib --lib state` (default assertion added)
  • Manual: `/add-dir /tmp` adds and shows in `/context`
  • Manual: `/add-dir /nonexistent` errors cleanly
  • Manual: `/add-dir --remove /tmp` removes, `--clear` empties

\`/add-dir <path>\` appends a directory to the session's working set.
The system prompt lists tracked extras so the agent knows it's
allowed to read and edit files there without re-asking for permission
on every cross-directory operation.

Forms:
  /add-dir              list tracked extras
  /add-dir <path>       add (path must exist; canonicalized before store)
  /add-dir --remove <p> remove one
  /add-dir --clear      remove all

Not persisted — session-scoped. /context displays the current list.
@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.

# Conflicts:
#	crates/cli/src/commands/mod.rs
# Conflicts:
#	crates/cli/src/commands/mod.rs
# Conflicts:
#	crates/cli/src/commands/mod.rs
#	crates/lib/src/state/mod.rs
# Conflicts:
#	crates/cli/src/commands/mod.rs
@emal-avala emal-avala merged commit d509c55 into main Apr 22, 2026
13 of 14 checks passed
@emal-avala emal-avala deleted the feat/cmd-add-dir branch April 22, 2026 22:55
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