CommandCodeAI / CommandCodeAI/command-code

Taste learning silently finds 0 Claude Code sessions when the project path contains spaces (encodeAgentProjectDir mismatch)

Đang mở
#849 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

@saqibameen đang làm issue này rồi.

Từ ngày 16/9/2026.

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
4k
Fork
350
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Summary

Taste onboarding and /learn-taste silently learn zero Claude Code sessions when the project path contains spaces (e.g. .../My Repository/My Works/Startup/WUP). encodeAgentProjectDir() only replaces /, \ and : with -, while Claude Code encodes project directories by replacing every non-alphanumeric character with - (spaces, CJK characters, etc.). Command Code therefore looks up a ~/.claude/projects/<dir> that does not exist, findClaudeCodeSessions() returns [], and nothing is reported to the user — no entry in skippedSessions or failedSessions.

Observed on a fresh v1.53.1 install: onboarding recorded 168 Codex sessions for the project but zero Claude Code sessions, even though 25 Claude Code sessions exist for the very same working directory.

Expected Behavior

For a project at /Users/<user>/Library/CloudStorage/OneDrive-Personal/My Repository/My Works/Startup/WUP, onboarding / /learn-taste should discover the existing ~/.claude/projects/-Users-<user>-Library-CloudStorage-OneDrive-Personal-My-Repository-My-Works-Startup-WUP/ directory (25 .jsonl sessions) and learn from it.

Actual Behavior
  • Command Code computes the lookup path with spaces preserved:
    ~/.claude/projects/-Users-<user>-...-My Repository-My Works-Startup-WUPisDirectory() fails → 0 sessions scanned.
  • Claude Code actually stores those sessions at:
    ~/.claude/projects/-Users-<user>-...-My-Repository-My-Works-Startup-WUP (spaces replaced by -).
  • After onboarding completes, ~/.commandcode/projects/<slug>/config.json contains only:
"tasteOnboarding": {
  "learnedSessions": { "codex": ["... 168 session ids ..."] },
  "skippedSessions": {},
  "failedSessions": {},
  "lastLearningDate": "2026-09-13T17:44:49.082Z",
  "completed": true
}

No claude-code key is created and no warning is surfaced, so it looks as if Claude Code simply had no sessions.

Steps to reproduce the issue
  1. Put a project in a path that contains a space (very common under OneDrive / Google Drive / "My Works"-style folders).
  2. Run Claude Code at least once in that project so ~/.claude/projects/<claude-encoded-dir>/*.jsonl exists (note that Claude Code replaces the spaces with -).
  3. Fresh-install Command Code in the same directory (or run /learn-taste) and let taste onboarding finish.
  4. Inspect ~/.commandcode/projects/<project-slug>/config.json: learnedSessions contains only codex (if anything); the Claude Code sessions were silently ignored.
Root cause / suggested fix

dist/cli.mjs:

function encodeAgentProjectDir(e){ return e.replace(/[/\\:]/g,"-") }
async function findClaudeCodeSessions(e){
  const n = `${t}/.claude/projects/${encodeAgentProjectDir(e.projectPath)}`;
  if (!await isDirectory2({ runtime: e.runtime, path: n })) return [];
  ...
}

Claude Code's own encoding replaces every non-alphanumeric character with -. Verified locally: a path segment 应用 (CJK) renders as two consecutive dashes, e.g. .../Dropbox/应用/Overleaf/...~/.claude/projects/-Users-<user>-Library-CloudStorage-Dropbox----Overleaf-....

Suggested fix:

  • Mirror Claude Code's encoding: e.replace(/[^a-zA-Z0-9]/g, "-").
  • Optionally add a fallback that scans ~/.claude/projects/* and matches the decoded path, so future encoding divergences degrade gracefully.
  • Surface "0 sessions found for claude-code" instead of silently skipping a source, so users can tell that discovery failed.

Related: #438 (non-standard Claude Code config paths), #639 (ENAMETOOLONG on taste learning), #740 (learning from worktree sessions).

Command Code Version

1.53.1 (cmd --version, Homebrew npm global install)

Operating System

macOS

Terminal/IDE

Apple Terminal

Shell

zsh

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.