github thedotmack/claude-mem v5.4.2
v5.4.2: CWD Spatial Awareness Fix

latest releases: v10.1.0, v10.0.8, v10.0.7...
3 months ago

v5.4.2 (2025-11-10)

Bugfix Release: CWD spatial awareness for SDK agent

What's Fixed

  • CWD Context Propagation: SDK agent now receives current working directory (CWD) context from tool executions
  • Spatial Awareness: Prevents false "file not found" reports when working across multiple repositories
  • Observer Guidance: Agent prompts now include tool_cwd XML elements with spatial awareness instructions

Technical Details

Data Flow:

  1. Hook extracts CWD from PostToolUseInput (hookInput.result.tool_cwd)
  2. Worker service receives CWD in PendingMessage and ObservationData interfaces
  3. SessionManager passes CWD to SDKAgent's addObservation method
  4. SDK agent includes CWD in tool observation objects sent to Claude API
  5. Prompts conditionally render tool_cwd XML with spatial awareness guidance

Implementation:

  • Optional CWD fields throughout for backward compatibility
  • Defaults to empty string when CWD is missing
  • CWD treated as read-only display context, not for file operations
  • Complete propagation chain from hook → worker → SDK → prompts

Test Coverage:

  • 8 comprehensive tests validating CWD propagation
  • Tests cover hook extraction, worker forwarding, SDK inclusion, and prompt rendering
  • All tests pass with tsx TypeScript loader

Security:

  • Zero vulnerabilities introduced
  • CodeQL analysis: No alerts
  • Read-only context display (no file operation changes)
  • Input validation and sanitization maintained

Files Changed

Source Files:

  • src/hooks/save-hook.ts - Extract CWD from PostToolUseInput
  • src/services/worker-types.ts - Add optional CWD fields to interfaces
  • src/services/worker-service.ts - Forward CWD in message handling
  • src/services/worker/SessionManager.ts - Pass CWD to SDK agent
  • src/services/worker/SDKAgent.ts - Include CWD in tool observations
  • src/sdk/prompts.ts - Render tool_cwd XML with spatial guidance

Built Artifacts:

  • plugin/scripts/save-hook.js - Compiled hook with CWD extraction
  • plugin/scripts/worker-service.cjs - Compiled worker with CWD handling

Tests & Documentation:

  • tests/cwd-propagation.test.ts - Comprehensive test suite (8 tests)
  • context/CWD_CONTEXT_FIX.md - Technical implementation documentation
  • PR_SUMMARY.md - Pull request summary and rationale
  • SECURITY_SUMMARY.md - Security analysis and review
  • CHANGELOG.md - Version history entry

Installation

# Update to latest version
/plugin update claude-mem

Or restart Claude Code to auto-update.

Upgrade Notes

  • Backward Compatible: No breaking changes
  • No Action Required: CWD propagation works automatically
  • Existing Sessions: Will benefit from improved spatial awareness

Full Changelog: v5.4.1...v5.4.2

Don't miss a new claude-mem release

NewReleases is sending notifications on new releases.