Skip to content

nmem t save fails on non-ASCII project directories (CJK / Unicode characters) #221

@moon09300731

Description

@moon09300731

Bug: nmem t save fails on non-ASCII project directories (CJK / Unicode characters)

Environment

  • nowledge-mem CLI: 0.8.3
  • Claude Code plugin: 0.7.7
  • OS: macOS (Darwin 25.4.0)
  • Project directory example: ~/Desktop/退役军人查询项目 (contains CJK characters)

Actual behavior

When Claude Code triggers the Stop hook (nmem-hook-save.py --event stop), the script calls:

nmem t save --from claude-code --session-id <sid> --project <cwd>

If cwd contains non-ASCII characters, the save fails with:

{
  "status": "error",
  "error": "Claude Code session directory not found for project: /Users/liangxinyu/Desktop/退役军人查询项目",
  "hint": "Make sure Claude Code has created sessions for this project (expected under /Users/liangxinyu/.claude/projects/-Users-liangxinyu-Desktop-退役军人查询项目)"
}

As a result, nmem t list shows 0 threads — the conversation is never automatically captured.

Root cause

Claude Code sanitizes project directory names when placing transcripts under ~/.claude/projects/. Its algorithm replaces every non-ASCII character with -:

/Users/liangxinyu/Desktop/退役军人查询项目
→ ~/.claude/projects/-Users-liangxinyu-Desktop---------

However, nmem t save only replaces / with -, and expects:

~/.claude/projects/-Users-liangxinyu-Desktop-退役军人查询项目

The mismatch causes the transcript lookup to fail.

Reproduction steps

  1. Create a project directory with CJK characters:
    mkdir -p ~/Desktop/中文项目
  2. cd ~/Desktop/中文项目
  3. Open Claude Code in that directory.
  4. Have any conversation (so a transcript .jsonl is generated).
  5. Trigger the Stop hook manually (or let Claude Code stop a turn):
    echo '{"session_id":"...","cwd":"/Users/<you>/Desktop/中文项目","transcript_path":"..."}' \
      | python3 ~/.claude/plugins/cache/nowledge-community/nowledge-mem/0.7.7/scripts/nmem-hook-save.py --event stop
  6. Observe Claude Code session directory not found for project: ....

Temporary workaround (local patch)

We patched ~/.claude/plugins/cache/nowledge-community/nowledge-mem/0.7.7/scripts/nmem-hook-save.py to:

  1. Detect non-ASCII characters in cwd.
  2. Create an ASCII symlink alias in the parent directory (e.g., ~/Desktop/-------- → ~/Desktop/中文项目).
  3. Pass the alias path to --project, so that nmem's sanitized output (-Users-liangxinyu-Desktop---------) matches Claude Code's actual directory.

Drawbacks:

  • Leaves an ASCII-dashed symlink in the parent directory.
  • Patch is lost on plugin upgrade (0.7.7 → 0.8.0).

Suggested fix

Option A — Update nmem t save's directory-name sanitization to match Claude Code's behavior (replace non-ASCII characters with -).

Option B — Allow nmem t save to accept an explicit --session-dir or --transcript-dir parameter, bypassing the cwd-based sanitization entirely.

Related files

  • Claude Code transcript layout: ~/.claude/projects/<sanitized-name>/<session-id>.jsonl
  • Hook script: ~/.claude/plugins/cache/nowledge-community/nowledge-mem/0.7.7/scripts/nmem-hook-save.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions