mirror of
https://github.com/aaddrick/claude-desktop-debian.git
synced 2026-05-17 08:36:35 +03:00
cleanSpawnArgs only translated --add-dir and --plugin-dir flag pairs.
The Electron app emits permission patterns like
Edit(//sessions/{name}/mnt/.auto-memory/**) and Write(...) inside the
single comma-separated --allowedTools value, and those reached the
spawned `claude` CLI verbatim. Permission rules referencing
non-existent guest paths cannot match the real on-disk locations, so
auto-memory grants silently no-op even after #389 made the underlying
path resolvable and #392 fixed the cwd resolution.
This adds two helpers and wires them into cleanSpawnArgs:
splitToolList(csv):
Paren-aware split so "Bash(npm test, npm build)" is one entry
rather than two. Returns an array of raw entries.
translateEmbeddedGuestPaths(csv, mountMap):
Walks each entry. "Tool" is passed through. "Tool(pattern)" is
translated when the pattern looks like a /sessions/ guest path.
Defensively normalizes leading "//" (the Electron app emits double
slashes via path.join('/', '/sessions/...')). Entries whose mount
cannot be resolved are dropped from the CSV; the flag itself is
kept (a permission rule that can never match is worse than absent).
cleanSpawnArgs now recognizes --allowedTools and --disallowedTools as
"tool-list flags" alongside the existing single-path flags. Single-path
behavior is unchanged.
BATS coverage in tests/cowork-path-translation.bats covers
splitToolList (paren handling, empty/null), translateEmbeddedGuestPaths
(passthrough, double/single-slash translation, drop-on-miss, host-path
passthrough, mcp__ tool names, empty/null), and the cleanSpawnArgs
integration for both new flag types.
Refs: #245 (umbrella), #389 (memory env translation), #392 (cwd fix).
Co-authored-by: Claude Opus 4 <noreply@anthropic.com>