Skip to content

fix(daemon): correct Claude Code --add-dir capability detection (fix …#440

Merged
mrcfps merged 1 commit intonexu-io:mainfrom
1119302165:fix-430-claude-code-add-dirs-detection
May 5, 2026
Merged

fix(daemon): correct Claude Code --add-dir capability detection (fix …#440
mrcfps merged 1 commit intonexu-io:mainfrom
1119302165:fix-430-claude-code-add-dirs-detection

Conversation

@1119302165
Copy link
Copy Markdown
Contributor

Description

This PR fixes issue #430 where Claude Code failed to read skill files due to incorrect directory access policy enforcement.

Root Cause

The Claude Code agent definition was probing global claude --help output for capability flags, but --add-dir and --include-partial-messages are subcommand-specific flags that only appear under claude -p --help, not in the global help output.

This caused:

  1. Capability detection to incorrectly set caps.addDir = false for users with working Claude Code installations
  2. The --add-dir flag was therefore never passed on agent spawn
  3. Claude Code's sandbox enforcement blocked all absolute-path reads outside the project cwd
  4. Skill files, skill assets, and design-system specs could not be read by the agent

Note: The "probing failed / timeout" path already worked correctly, as it fell back to an empty capabilities object {} which defaulted to passing --add-dir. The failure mode only manifested when the help probe actually succeeded.


Impact Analysis

Scope

Aspect Impact
Agents affected Claude Code ONLY. All 12+ other agents (Codex, Cursor, Devin, Gemini, etc.) are completely untouched.
Code change surface 1 line changed in helpArgs + comment. No logic changes to any other agent.
API compatibility No external API changes. helpArgs is stripped before serialization.
Backward compatibility Fully backward compatible. Older Claude Code versions continue to work via fallback mechanism.

Execution Paths Affected

Path Before After
Daemon agent detection execFile('claude', ['--help']) execFile('claude', ['-p', '--help'])
Agent spawn buildArgs --add-dir never passed when probe succeeded --add-dir correctly passed when detected
/api/agents endpoint helpArgs internal-only field stripped No change β€” still stripped

Changes Made

File Change
apps/daemon/src/agents.ts Updated Claude Code helpArgs to probe subcommand help
apps/daemon/tests/agents.test.ts Added 3 regression tests for issue #430

Regression Protection

Tests added:

  1. βœ… Default --add-dir propagation when directories are supplied
  2. βœ… Correct filtering of empty/null directory entries
  3. βœ… Explicit assertion that ['-p', '--help'] is used for probing (prevents regression)

Testing

  1. Before this fix: Running claude --help | grep --add-dir returns no matches
  2. After this fix: Running claude -p --help | grep --add-dir correctly finds the flag
  3. All existing agent tests continue to pass
  4. New regression tests prevent this specific failure mode from recurring

…exu-io#430)

Probe 'claude -p --help' (subcommand help) instead of 'claude --help'
(global help), because --add-dir and --include-partial-messages are
subcommand-specific flags that do not appear in the global help output.

Previously, successful capability probing would set caps.addDir = false
because the flag was not found in global help, causing the daemon to
never pass --add-dir to spawned Claude Code processes. This broke
absolute-path reads for skill seeds and design-system specs, as
Claude Code's sandbox policy blocks access to paths outside the
project cwd unless explicitly allowed via --add-dir.

The probing-failure / timeout path already worked correctly (empty
caps object defaults to passing --add-dir). The failure manifested
only when help probing succeeded and explicitly failed to locate
the subcommand flags.
@lefarcen
Copy link
Copy Markdown
Contributor

lefarcen commented May 4, 2026

Hi @1119302165! πŸŽ‰

Thanks for the contribution β€” this is a precise root-cause fix with thorough testing and impact analysis.

I will run a deep review and get back to you within 24h.

Thanks for making open-design better!
β€” open-design team

Copy link
Copy Markdown
Contributor

@mrcfps mrcfps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1119302165 I reviewed the Claude Code capability-detection change in apps/daemon/src/agents.ts and the added regression coverage in apps/daemon/tests/agents.test.ts. The fix is tightly scoped to probing the claude -p --help subcommand where --add-dir is advertised, and the tests cover the default add-dir behavior, directory filtering, and the root-cause help arguments. I did not find any actionable issues in the changed ranges; thanks for the clear, focused fix and the helpful regression protection. πŸ™Œ

Generated by Looper 0.5.2 Β· runner=reviewer Β· agent=opencode

@lefarcen
Copy link
Copy Markdown
Contributor

lefarcen commented May 4, 2026

I've reviewed the changes as promised. @mrcfps's review above covers all the code correctness and test coverage points comprehensively β€” the fix is tightly scoped and well-protected by regression tests.

No additional actionable issues from my end. Thanks for the clear, focused fix! πŸŽ‰

@mrcfps mrcfps merged commit 0ab98fe into nexu-io:main May 5, 2026
1 check passed
@lefarcen
Copy link
Copy Markdown
Contributor

lefarcen commented May 5, 2026

πŸŽ‰ Merged! Thanks @1119302165 for the precise root-cause fix and thorough regression tests.

The capability detection now correctly probes claude -p --help where --add-dir is actually advertised, and the tests guard against this exact failure mode recurring.

Appreciate the clear analysis and careful implementation! πŸ™

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Fixes an existing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants