mirror of
https://github.com/Yeachan-Heo/oh-my-claudecode.git
synced 2026-09-03 06:25:33 +08:00
* fix(session-search): encode underscores (and all non-alphanumerics) in project dir name encodeProjectPath replaced only / \ . : , leaving underscores intact. Claude Code names ~/.claude/projects/<dir> by replacing every non-alphanumeric char with '-', so any project whose path contained '_' was looked up under a dir that never existed -> session_search returned 0 matches in 'current' scope (project: 'all' was unaffected). Widen the class to [^a-zA-Z0-9], a superset that still covers the path-separator/dot/drive-colon cases. Mirror the change in the hook-runtime .mjs copy and add regression tests. Fixes #3329 * docs: clarify Claude Code path encoding scope --------- Co-authored-by: Yeachan-Heo <hurrc04@gmail.com> Co-authored-by: Codex Review <codex-review@example.com>
29 lines
1.4 KiB
JavaScript
29 lines
1.4 KiB
JavaScript
/**
|
|
* Claude Code project-directory character sanitization (hook-runtime mirror).
|
|
*
|
|
* Mirror of `src/utils/encode-project-path.ts` — keep the two in sync. The TS
|
|
* helper is the source of truth; this `.mjs` copy exists because the hook
|
|
* runtime loads raw scripts and cannot import the compiled `dist/` util.
|
|
*
|
|
* Claude Code stores a project's transcripts under
|
|
* `~/.claude/projects/<encoded>`. For normal-length project paths, this helper
|
|
* mirrors Claude Code's character replacement step: every character that is not
|
|
* an ASCII letter or digit is replaced by `-` (path separators, dots, the
|
|
* Windows drive colon, and also underscores, spaces, and non-ASCII characters).
|
|
* For example:
|
|
*
|
|
* POSIX: /home/me/proj -> -home-me-proj
|
|
* POSIX: /home/me/my.proj -> -home-me-my-proj
|
|
* POSIX: /home/me/00_proj -> -home-me-00-proj
|
|
* Windows: C:\Users\me\proj -> C--Users-me-proj
|
|
*
|
|
* Any character left unsanitized produces a name that never matches the real
|
|
* directory, so any lookup keyed on the encoded name silently finds nothing.
|
|
* This helper intentionally mirrors only Claude Code's normal-length character
|
|
* replacement/sanitization step, not its full long-path contract (which also
|
|
* truncates very long encoded names and appends a hash).
|
|
*/
|
|
export function encodeProjectPath(projectPath) {
|
|
return projectPath.replace(/[^a-zA-Z0-9]/g, '-');
|
|
}
|