[Feature] Additional working directories: --add-dir flag and /add-dir command
Description
File tools and @file mentions are confined to a single project root. There is no way to give a session access to a second directory, such as a sibling repo, a shared library, a docs checkout or a generated-code folder. Path validation in source/utils/fs/path-validation.ts rejects relative escapes and, for absolute paths, accepts only those inside one containmentRoot. A search for add-dir or additional directory settings finds nothing.
Use Case
Working on a service that depends on a library in the next folder over, or a frontend and backend that live in separate repositories. The model needs to read (and sometimes edit) both. Codex CLI offers --add-dir, and Gemini CLI offers --include-directories and a /directory add command for exactly this. Today a nanocoder user must start the session in a common parent and accept that the project root, AGENTS.md, git tools and trust prompts now refer to the wrong folder.
Proposed Solution
- A repeatable
--add-dir <path>flag and ananocoder.additionalDirectoriesconfig list. - A
/add-dir <path>command to add one mid-session, and/statuslisting the active roots. - Each added directory goes through the existing directory trust check before it becomes readable or writable, and a read-only option (
--add-dir-roor amodefield) so reference material cannot be edited. - File tools,
search_file_contents,find_files,@filecompletion and the ignore rules treat every root consistently; relative paths still resolve against the primary root.
Alternatives Considered
- Symlink the other directory into the project. It works but pollutes the repo, and symlink targets outside the project are intentionally rejected by path validation.
- Start in the parent directory. Breaks project root detection,
AGENTS.mdlookup and git context.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] This feature aligns with the project's goals (local-first AI assistance)
Implementation Notes (optional)
validatePath already takes a containmentRoot argument. Changing it to accept a list of roots (primary plus added) is the core change; the trust record in preferences needs one entry per added directory.
id like to work on this issue, please assign me this issue.