feat(sdk): add extensions option to both SDKs - #6470
Conversation
Add `extensions` option that maps to CLI's `--extensions` (`-e`) flag, allowing users to specify which extensions to load for a session. Python SDK: - Add `extensions: list[str] | None` to QueryOptions - Map to `--extensions` (comma-separated) in build_cli_arguments TypeScript SDK: - Add `extensions?: string[]` to TransportOptions and QueryOptions - Add to Zod schema - Pass through to ProcessTransport.buildCliArguments
| if options.allowed_tools: | ||
| args.extend(["--allowed-tools", ",".join(options.allowed_tools)]) | ||
|
|
||
| if options.extensions: |
There was a problem hiding this comment.
[Suggestion] The new extensions option is not covered by any test in packages/sdk-python/tests/unit/test_transport.py. The existing test_build_cli_arguments_maps_supported_options test covers all analogous options (core_tools, exclude_tools, allowed_tools) but extensions is absent from both the QueryOptions(...) constructor call and the expected args list.
Consider adding extensions=["ext-a", "ext-b"] to the test's QueryOptions and asserting "--extensions", "ext-a,ext-b" in the expected args, mirroring the pattern used for the other list options.
— qwen3.7-max via Qwen Code /review
| args.push('--allowed-tools', this.options.allowedTools.join(',')); | ||
| } | ||
|
|
||
| if (this.options.extensions && this.options.extensions.length > 0) { |
There was a problem hiding this comment.
[Suggestion] The new extensions option is not covered by any test in packages/sdk-typescript/test/unit/ProcessTransport.test.ts. The existing test that exercises coreTools and excludeTools (around line 194) does not include extensions in the TransportOptions or the expected args.
Consider adding extensions: ['ext-a', 'ext-b'] to the test's TransportOptions and asserting '--extensions', 'ext-a,ext-b' in expect.arrayContaining([...]), mirroring the pattern used for the other list options.
— qwen3.7-max via Qwen Code /review
qwen-code review summaryPR #6470 adds an Findings[Suggestion] Missing test coverage for
Needs Human ReviewPossibly: Argument injection via flag-like extension names — If an SDK consumer passes untrusted extension names (e.g., VerdictComment — Clean, correct implementation. Tests would be nice but aren't blocking. |
💡 Suggestion: Consolidate SDK PRsHi @juhuan, thanks for the comprehensive SDK work! We noticed you have 15 open PRs that all modify the same core files ( The problem
Suggestion: regroup into 2 PRsWe recommend closing the current 15 PRs and reopening them as 2 consolidated PRs: PR 1 — Covers pure SDK-side option additions (~9 current PRs):
PR 2 — Covers features that also involve CLI-side
This keeps a reasonable separation of concerns while eliminating the merge-conflict chain and making review much more manageable. /cc @juhuan |
|
Closing in favor of consolidated PRs (see suggestion comment above). Please reopen as 2 grouped PRs. |
Summary
Add
extensionsoption that maps to CLI's--extensions(-e) flag, allowing users to specify which extensions to load for a session. If not provided, all extensions are used.extensions: list[str] | NoneinQueryOptions, mapped to--extensions(comma-separated)extensions?: string[]inTransportOptionsandQueryOptions, with Zod schema validationTest plan
pytest— 58 passed)tsc --noEmit)vitest run— 1163 passed)