#2884: fix: Create memory directory and symlink identity files during workspace setup
agents
## Summary
- Creates `memory/` directory during workspace setup when `ensureBootstrapFiles` is true
- Symlinks identity files (SOUL.md, USER.md, AGENTS.md, IDENTITY.md) into `memory/` so they are indexed by memory search
- Gracefully handles symlink failures on Windows and preserves existing files
## Problem
The memory search system looks for files in `~/clawd/memory/` but workspace setup only created identity files at the workspace root. This caused:
- `clawdbot memory status` to report "no memory files found"
- The AI to incorrectly claim "I have no memories" despite having identity files
- Users having to manually create the `memory/` directory and copy/symlink files
## Solution
During `ensureAgentWorkspace()` with `ensureBootstrapFiles: true`:
1. Create `memory/` subdirectory
2. Symlink identity files into it so memory search can index them
3. Skip if files already exist (preserves user customizations)
4. Gracefully handle symlink failures (e.g., Windows without privileges)
## Test plan
- [x] Added unit tests for memory directory creation
- [x] Added test for symlink creation
- [x] Added test for not overwriting existing files
- [x] All 6 workspace tests pass
- [x] Lint passes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates workspace bootstrapping (`src/agents/workspace.ts`) to create a `memory/` subdirectory during `ensureAgentWorkspace({ ensureBootstrapFiles: true })` and attempts to symlink the identity/bootstrap files (SOUL/USER/AGENTS/IDENTITY) into that directory so the memory search subsystem can index them. It also adds unit coverage in `src/agents/workspace.test.ts` for directory creation, symlink creation, and non-overwrite behavior.
Overall, the change aligns workspace setup with other parts of the codebase (e.g., the memory CLI and internal scanner) which look for `memory/` under the workspace directory. The main risks are around cross-platform symlink behavior and the fact that the new `memory/` directory is created unconditionally whenever `ensureBootstrapFiles` is enabled.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge, but has cross-platform test fragility and some silent-failure behavior worth addressing.
- Core logic is straightforward (mkdir + best-effort symlinks) and scoped to workspace bootstrapping, but the new tests assume symlinks always work and the implementation suppresses all symlink-related errors, which can hide real failures and cause CI issues on Windows or restricted environments.
- src/agents/workspace.test.ts (symlink assertions on Windows), src/agents/workspace.ts (error swallowing / unconditional mkdir behavior)
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#9726: feat: add identityDir config for separate identity file location
by rickburn · 2026-02-05
81.5%
#12939: fix(memory): strip null bytes from workspace paths causing ENOTDIR
by omair445 · 2026-02-09
81.2%
#4386: fix(memory): persist dirty flag to prevent false positive on status
by Iamadig · 2026-01-30
80.4%
#11761: fix(gateway): expose memory/ directory files in agents.files RPC
by advaitpaliwal · 2026-02-08
79.0%
#6060: feat(onboarding): add Memory Optimization step to onboarding wizard
by GodsBoy · 2026-02-01
78.4%
#21217: fix: memory prune command to prevent unbounded MEMORY.md growth
by theognis1002 · 2026-02-19
78.2%
#10591: feat(hooks): add session-start-memory bundled hook
by morningstar-daemon · 2026-02-06
77.4%
#20267: feat: workspace-aware post-compaction context
by nickjlamb · 2026-02-18
77.2%
#23085: fix(workspace): respect OPENCLAW_STATE_DIR for workspace paths, fix...
by charojo · 2026-02-22
77.1%
#13497: fix(docker): normalize workspace paths for container compatibility
by janckerchen · 2026-02-10
77.0%