Repository navigation
Description
Description
There are two implementations of the session-directory slug, and only one of them is correct.
scripts/lib-memory-dir.sh carries an inline fallback:
# Guard: session_dir_slug may not be defined if detect-tools.sh was
# not sourced yet (e.g. log.sh sourced directly in tests). Define a
# minimal inline fallback so the slug is never silently empty.
if ! type session_dir_slug >/dev/null 2>&1; then
session_dir_slug() {
local _p="$1"
command -v cygpath >/dev/null 2>&1 && _p=$(cygpath -m "$_p")
echo "$_p" | sed 's/[^a-zA-Z0-9]/-/g'
}
fiThat is the pre-#144 implementation, carrying every bug #156 just fixed: no LC_ALL, so byte-wise on Git Bash/MSYS; no UTF-16 handling, so astral characters get one dash instead of two; and echo | sed, so an embedded newline never reaches the substitution.
It is not dead code. scripts/user-prompt-hook.sh sources bootstrap-dirs.sh without sourcing detect-tools.sh first, so for that hook the fallback is what runs.
Impact
Only when data_dir uses the {slug} placeholder (external storage mode — see README "External storage mode"), which is where the slug feeds REMEMBER_DIR rather than the transcript lookup.
In that configuration, on a project whose path contains non-ASCII, user-prompt-hook.sh resolves a different REMEMBER_DIR than every other hook. So one hook reads and writes memory in one directory while the rest use another — a split-brain memory rather than a clean failure, which is harder to notice than the silent no-op of #144.
Also, cygpath -m here versus cygpath -w plus drive-letter lowercasing in the real function is a second, independent divergence on Windows.
Suggested fix
Extract the slug into its own small file — scripts/lib-slug.sh — holding session_dir_slug and its source-time sed construction, and source that from both detect-tools.sh and lib-memory-dir.sh. One implementation, no drift.
Sourcing detect-tools.sh from lib-memory-dir.sh instead is not a safe shortcut: detect-tools.sh runs Python detection at source time and calls exit 1 when it finds none, which would take down whatever sourced it. That is presumably why the inline duplicate exists in the first place.
Alternatively, having user-prompt-hook.sh source detect-tools.sh like the other hooks do would fix the live path, but it leaves the duplicate in place to drift again.
Notes
Found while reviewing #156, which fixes the real session_dir_slug but does not touch this copy. Left out of that PR deliberately: it is a separate code path with its own risk, and the fix is a small refactor of shared plumbing rather than a bug fix.
Activity
fix(slug): one session-directory slug, and make it truncate (#187)
fdaviddpt commentedon Jul 26, 2026
Fixed in #187 (merged as 8eb93b2) — GitHub only auto-closed #157 from that PR's "Closes #157, #158, #174" line, since it parses the first reference only.
The naive inline copy in
lib-memory-dir.shand the codepoint regex inextract.pyare both gone; the slug now lives inpipeline/slug.pyandscripts/lib-slug.sh, andtests/test_slug_parity.pychecks bash and Python against an independent transcription of the shipped CLI's function over ASCII, accents, CJK, emoji, astral kanji, newlines and lengths either side of 200.fix(prompt-hook): stop spawning 19 processes to print a timestamp (#227…
Cache the injected context, flattened config and tool verdicts across…