mirror of
https://github.com/anthropics/claude-code-sdk-python.git
synced 2025-12-23 09:19:52 +00:00
Support --add-dir flag (#104)
This commit is contained in:
parent
fbda510ee4
commit
0cb5efa923
4 changed files with 29 additions and 0 deletions
|
|
@ -1,5 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
## 0.0.19
|
||||
|
||||
- Add `ClaudeCodeOptions.add_dirs` for `--add-dir`
|
||||
- Fix ClaudeCodeSDK hanging when MCP servers log to Claude Code stderr
|
||||
|
||||
## 0.0.18
|
||||
|
||||
- Add `ClaudeCodeOptions.settings` for `--settings`
|
||||
|
|
|
|||
|
|
@ -124,6 +124,11 @@ class SubprocessCLITransport(Transport):
|
|||
if self._options.settings:
|
||||
cmd.extend(["--settings", self._options.settings])
|
||||
|
||||
if self._options.add_dirs:
|
||||
# Convert all paths to strings and add each directory
|
||||
for directory in self._options.add_dirs:
|
||||
cmd.extend(["--add-dir", str(directory)])
|
||||
|
||||
if self._options.mcp_servers:
|
||||
cmd.extend(
|
||||
["--mcp-config", json.dumps({"mcpServers": self._options.mcp_servers})]
|
||||
|
|
|
|||
|
|
@ -128,3 +128,4 @@ class ClaudeCodeOptions:
|
|||
permission_prompt_tool_name: str | None = None
|
||||
cwd: str | Path | None = None
|
||||
settings: str | None = None
|
||||
add_dirs: list[str | Path] = field(default_factory=list)
|
||||
|
|
|
|||
|
|
@ -79,6 +79,24 @@ class TestSubprocessCLITransport:
|
|||
assert "--max-turns" in cmd
|
||||
assert "5" in cmd
|
||||
|
||||
def test_build_command_with_add_dirs(self):
|
||||
"""Test building CLI command with add_dirs option."""
|
||||
from pathlib import Path
|
||||
|
||||
transport = SubprocessCLITransport(
|
||||
prompt="test",
|
||||
options=ClaudeCodeOptions(
|
||||
add_dirs=["/path/to/dir1", Path("/path/to/dir2")]
|
||||
),
|
||||
cli_path="/usr/bin/claude",
|
||||
)
|
||||
|
||||
cmd = transport._build_command()
|
||||
cmd_str = " ".join(cmd)
|
||||
|
||||
# Check that the command string contains the expected --add-dir flags
|
||||
assert "--add-dir /path/to/dir1 --add-dir /path/to/dir2" in cmd_str
|
||||
|
||||
def test_session_continuation(self):
|
||||
"""Test session continuation options."""
|
||||
transport = SubprocessCLITransport(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue