#20706: feat(hooks): add outputDir config for session-memory hook
docs
size: S
Adds optional \`outputDir\` config so session summaries can be written outside \`memory/\` (e.g. to \`session-summaries/\`) and stay out of the vector index.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds an optional `outputDir` configuration to the session-memory hook so session summaries can be written to a custom workspace-relative directory (e.g. `session-summaries/`) instead of always going to `memory/`. This allows users to keep session summaries out of the vector memory index while maintaining security by falling back to `memory/` if the configured path would escape the workspace boundary.
**Key changes:**
- Added path validation logic in `handler.ts:188-211` that resolves the configured `outputDir` relative to workspace, checks it stays within workspace bounds using `realpath` and path prefix checking, and falls back to `memory/` with a warning if it would escape
- Updated documentation to explain the new config option and security behavior
- Added comprehensive test coverage for both the happy path (custom directory) and security fallback (path traversal attempts)
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation includes proper security validation to prevent directory traversal attacks, comprehensive test coverage for both normal operation and edge cases, clear documentation, and follows the repository's coding patterns. The path validation logic correctly uses realpath and prefix checking to ensure the output directory stays within workspace boundaries.
- No files require special attention
<sub>Last reviewed commit: a7e2898</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#3392: fix(hooks): remove debug console.log statements from session-memory...
by WinJayX · 2026-01-28
80.1%
#8431: Hooks: add session-graphiti memory feed
by JorgeAlan · 2026-02-04
78.5%
#6858: feat(hooks): improve session-memory with LLM summarization
by alauppe · 2026-02-02
78.3%
#10591: feat(hooks): add session-start-memory bundled hook
by morningstar-daemon · 2026-02-06
77.8%
#14243: fix: fire session-memory hook on auto-resets + topic-aware memory p...
by TheDude135 · 2026-02-11
73.3%
#8244: feat(hooks): add session:before_compact and session:after_compact i...
by kephail · 2026-02-03
72.8%
#9914: fix(hooks): resolve bundled hook dist paths and packaging checks
by zimmra · 2026-02-05
72.5%
#9726: feat: add identityDir config for separate identity file location
by rickburn · 2026-02-05
72.2%
#23763: Hooks: require session key prefixes for request override
by bmendonca3 · 2026-02-22
72.0%
#13032: feat(hooks): add unified session:before_end hook event
by TGambit65 · 2026-02-10
71.9%