Skip to content

fix: centralize .remember/ bootstrap + portability fixes (Windows, macOS, Haiku)#33

Merged
fdaviddpt merged 5 commits intomainfrom
fix/bootstrap-dirs-and-tmpdir
Apr 25, 2026
Merged

fix: centralize .remember/ bootstrap + portability fixes (Windows, macOS, Haiku)#33
fdaviddpt merged 5 commits intomainfrom
fix/bootstrap-dirs-and-tmpdir

Conversation

@fdaviddpt
Copy link
Copy Markdown
Contributor

@fdaviddpt fdaviddpt commented Apr 25, 2026

Summary

Five independent fixes shipped as separate commits, addressing portability bugs reported by the community. Each commit is self-contained with its own tests.

Commit 1: Centralize .remember/ directory bootstrap

Problem: hooks.json redirected stderr via 2>> to .remember/logs/hook-errors.log. Bash opens the redirect target before the script runs, so on fresh projects where .remember/logs/ doesn't exist, the redirect fails and the hook never executes. Four users reported this (#23, #27, #31, #32).

Fix: New scripts/bootstrap-dirs.sh — single source of truth for the .remember/ directory layout. Every hook script sources it after resolve-paths.sh. Creates tmp/, logs/, logs/autonomous/, .gitignore, and redirects stderr via exec 2>> (guarded for read-only filesystems). hooks.json commands are now clean one-liners.

17 new tests: bug reproduction, fresh project, partial state, spaces/unicode in paths, read-only filesystem, idempotency, git worktrees, concurrent sessions, source ordering.

Closes #23, #27, #31, #32Supersedes #21

Commit 2: Centralize SYS_TMPDIR for Windows portability

Hardcoded /tmp/ fails on Windows (Git Bash). bootstrap-dirs.sh now exports SYS_TMPDIR. Fixed user-prompt-hook.sh and 7 mktemp calls in run-tests.sh. Guard test prevents future regressions.

Inspired by @evikzub PR #28.

Commit 3: README Windows prerequisites

Documents Git Bash/MSYS2/WSL requirements and jq/coreutils dependencies. Based on @evikzub PR #28.

Commit 4: BSD mktemp compatibility (macOS)

BSD mktemp treats chars after XXXXXX as literal — creates a file with no randomization. Removed extensions from all 11 mktemp calls. Guard test prevents regressions.

Inspired by @josemoreno801-netizen PR #30. Closes #30 scope.

Commit 5: Prevent Haiku from inventing unknown header

When previous entries showed unknown, Haiku mimicked that instead of using computed TIME/BRANCH values. Added explicit prompt instruction + expanded placeholder guard to full-file grep.

Inspired by @cyanprot PR #22. Closes #24.

Test coverage

24 new tests across 3 test classes. Full suite: 210 passed, 0 failed.

Related PRs

Florian DAVID added 3 commits April 25, 2026 16:46
… redirect

The SessionStart and PostToolUse hook commands in hooks.json redirected
stderr to .remember/logs/hook-errors.log via 2>>. Bash opens the redirect
target before running the script, so on fresh projects where .remember/logs/
does not exist, the redirect fails and the hook script never executes.

Four independent users reported this (issues #23, #27, #31, #32).

Fix: introduce scripts/bootstrap-dirs.sh as the single source of truth
for the .remember/ directory layout. Every hook script sources it after
resolve-paths.sh. It creates tmp/, logs/, logs/autonomous/, .gitignore,
and redirects stderr via exec 2>> (guarded by -d check for read-only
filesystems). hooks.json commands are now clean one-liners with no
inline redirects.

- New: scripts/bootstrap-dirs.sh (dir creation + stderr redirect)
- session-start-hook.sh: source bootstrap-dirs.sh, remove duplicate mkdir
- post-tool-hook.sh: source bootstrap-dirs.sh
- hooks.json: remove 2>> redirects from both commands
- 17 new tests covering: bug reproduction, fresh project, partial state,
  spaces/unicode in paths, read-only filesystem, idempotency, git
  worktrees, concurrent sessions, source ordering

Closes #23, #27, #31, #32
Supersedes #21

Co-Authored-By: Max <noreply>
Hardcoded /tmp/ paths fail on Windows where /tmp doesn't exist but
$TMPDIR does (set by Git Bash/MSYS2). Centralize the fix:

- bootstrap-dirs.sh: export SYS_TMPDIR="${TMPDIR:-/tmp}" so every
  script that sources bootstrap gets it for free
- user-prompt-hook.sh: use $SYS_TMPDIR for claude-ctx-pct file,
  also source bootstrap-dirs.sh for consistent setup
- run-tests.sh: replace 7 hardcoded mktemp /tmp/ calls with $SYS_TMPDIR
- New test: guard against hardcoded /tmp/ in all production scripts

Inspired by evikzub's PR #28 (Windows bootstrap fix).

Co-Authored-By: Max <noreply>
Windows users need Git Bash/MSYS2 or WSL for bash scripts.
Also documents jq and coreutils dependencies that were implicit.

Based on evikzub's contribution in PR #28.

Co-Authored-By: Max <noreply>
Florian DAVID added 2 commits April 25, 2026 17:05
BSD mktemp (macOS) treats characters after XXXXXX as literal — it
creates a file named exactly 'foo-XXXXXX.txt' with no randomization.
The first call succeeds silently, the second fails with 'File exists'.
This is both a collision bug and a security issue (predictable names).

Remove .txt/.json/.md extensions from all 11 mktemp calls in
save-session.sh (5) and run-tests.sh (6). Added tests: BSD mktemp
reproduction, guard against future extensions in scripts.

Inspired by josemoreno801-netizen's PR #30.
Closes #30 scope.

Co-Authored-By: Max <noreply>
…er guard

Two related issues in the save-session pipeline:

1. When a previous entry's header showed 'unknown' (e.g., from git
   rev-parse in a non-repo cwd), Haiku occasionally mimicked that
   header instead of using the {{TIME}} | {{BRANCH}} values.
   Fix: explicit prompt instruction to copy header verbatim and
   never invent 'unknown | unknown'.

2. The placeholder guard only checked the first line (head -1) for
   {{TIME}} and {{BRANCH}}. If body placeholders ({{LAST_ENTRY}},
   {{EXTRACT}}) were unsubstituted, the broken prompt was sent to
   Haiku anyway.
   Fix: grep the entire prompt file for all 4 placeholders.

Tests: prompt content assertions, guard coverage check, head -1 guard.

Inspired by cyanprot's PR #22. Closes #24.

Co-Authored-By: Max <noreply>
@fdaviddpt fdaviddpt changed the title fix: centralize .remember/ bootstrap + Windows TMPDIR portability fix: centralize .remember/ bootstrap + portability fixes (Windows, macOS, Haiku) Apr 25, 2026
@fdaviddpt fdaviddpt self-assigned this Apr 25, 2026
@fdaviddpt fdaviddpt merged commit b094862 into main Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Haiku from inventing 'unknown' header and fix no-op placeholder

1 participant