Skip to content

fix: multiple --add-dir flags overwrite instead of combining#1221

Open
jakeefr wants to merge 1 commit intoanthropics:mainfrom
jakeefr:fix/add-dir-accumulation
Open

fix: multiple --add-dir flags overwrite instead of combining#1221
jakeefr wants to merge 1 commit intoanthropics:mainfrom
jakeefr:fix/add-dir-accumulation

Conversation

@jakeefr
Copy link
Copy Markdown

@jakeefr jakeefr commented Apr 15, 2026

Fixes #1215. The --add-dir flag was typed as a regular (non-accumulating) flag, causing each subsequent --add-dir to overwrite the previous one. Only the last value was used.

What changed

  • parse-sdk-options.ts: Added "add-dir" to ACCUMULATING_FLAGS. After parsing, the accumulated values are extracted from extraArgs, split, and placed into sdkOptions.additionalDirectories (a first-class SDK array property). This follows the same pattern used for allowedTools and disallowedTools.
  • parse-sdk-options.test.ts: Added 4 tests covering single --add-dir, multiple --add-dir, mixed with other flags, and absent --add-dir.

How it works

Before: --add-dir "/a" --add-dir "/b"extraArgs["add-dir"] = "/b" (overwritten)

After: --add-dir "/a" --add-dir "/b"sdkOptions.additionalDirectories = ["/a", "/b"] → SDK emits --add-dir /a --add-dir /b

Test plan

  • All 31 parse-sdk-options tests pass (27 existing + 4 new)
  • Full test suite — only pre-existing Windows path-separator failures, none related to this change

Add "add-dir" to ACCUMULATING_FLAGS so multiple --add-dir flags
accumulate instead of each overwriting the previous. Extract the
accumulated values into sdkOptions.additionalDirectories (a first-class
SDK property) so the SDK emits separate --add-dir flags for each path.

Fixes anthropics#1215

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

When passing multiple --add-dir flags, the last silently overwrites instead of being combined

1 participant