Repository navigation
Conversation
plugin-dir was not in ACCUMULATING_FLAGS, so each repeated --plugin-dir in claude_args overwrote the previous one and only the last plugin reached the CLI, with no warning. The CLI documents the flag as repeatable. Accumulating the values is not enough on its own: extraArgs holds one value per flag and the SDK passes that value through as a single argv entry, so a NUL-joined value makes the spawn throw ERR_INVALID_ARG_VALUE. Map the values to the SDK's plugins option instead, which emits one --plugin-dir per entry, mirroring the existing add-dir handling. A bare --plugin-dir is still passed through, so the CLI keeps rejecting it instead of the plugin being skipped silently.
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1728
Summary
--plugin-dirflags parsed fromclaude_args.pluginsoption ({ type: "local", path }), which emits one--plugin-dirper entry. Same approach as the--add-dirfix in fix: preserve repeated add-dir flags in claude args #1256.plugin-dirfromextraArgs, except for a bare--plugin-dir(e.g. from an unset variable): that one still reaches the CLI, so it keeps failing withoption '--plugin-dir <path>' argument missinginstead of the plugin being skipped silently.Root Cause
plugin-dirwasn't inACCUMULATING_FLAGS, so each occurrence overwrote the previous one and only the last plugin was loaded, with no warning, although the CLI documents the flag as repeatable.Adding it to the set alone isn't enough: accumulated values are joined with
\x00, and the SDK turns eachextraArgsentry into exactly one argv element, so the spawn throws(SDK 0.3.274, same on node 24 and bun 1.3). #1736 and #1816 only add the flag to the set, and their tests assert the joined value left in
extraArgs, sobun testpasses but the actual run would fail on the first job with two plugin dirs. Thanks to @farmer-data, whose review on #1736 spotted theERR_INVALID_ARG_VALUEand pointed at thepluginsoption.Validation
bun test test/parse-sdk-options.test.ts: 46 pass (5 new: repeated flags across lines and with other flags in between, a single flag, a bare flag, other flags preserved, and a parser-wide check that noextraArgsvalue contains\x00, which fails against the accumulate-only change)bun test: 971 passbun run typecheck,bun run format:check: clean--plugin-dir A --plugin-dir Blists both plugins and their commands; onmainonly B is loaded.Notes
--plugin-urlhas no SDK option, so a repeated space-separated--plugin-urlstill keeps only the last value; not changed here. The inline--plugin-url=A --plugin-url=Bform already passes through as is.--plugin-dir-no-mcp(hidden, the SDK emits it forskipMcpDiscovery) is left as is. Happy to map it toskipMcpDiscoveryin this PR if you'd like.