Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

ContextSearch only ever searches one project dir — every session run inside a code repo is unrecallable

Open christauff opened this issue 4 months ago • 1 comments

Version: v7.1.1 (verified against 03a969dd96dc7ff701d92dbc8a8b8d6db4728834)

What happens

ContextSearch builds its transcript-search root from ~/.claude alone, so it only ever looks inside the single project dir that corresponds to ~/.claude. Claude Code writes one project dir per cwd. Any session run in any other directory — i.e. every session run inside a code repo — is invisible to recall, by construction.

Repro (30 seconds)

ls ~/.claude/projects/          # one dir per cwd you've worked in

On this machine that lists 11 dirs. ContextSearch searches exactly one of them.

Run a memorable session inside any code repo, then try to recall it with ContextSearch. It will not be found — not because the ranking missed it, but because the file was never a candidate.

Cause

https://github.com/danielmiessler/LifeOS/blob/03a969dd96dc7ff701d92dbc8a8b8d6db4728834/LifeOS/install/skills/ContextSearch/Tools/ContextSearch.ts#L9-L15

const LIFEOS_DIR = join(HOME, ".claude");
const PROJECT_SLUG = LIFEOS_DIR.replace(/[/.]/g, "-");
const JSONL_DIR = join(LIFEOS_DIR, "Projects", PROJECT_SLUG);

JSONL_DIR is pinned to the ~/.claude slug. The containment guard in searchJsonl then re-asserts that same single-slug root:

https://github.com/danielmiessler/LifeOS/blob/03a969dd96dc7ff701d92dbc8a8b8d6db4728834/LifeOS/install/skills/ContextSearch/Tools/ContextSearch.ts#L353-L355

There is a second, independent consequence at the UUID join:

https://github.com/danielmiessler/LifeOS/blob/03a969dd96dc7ff701d92dbc8a8b8d6db4728834/LifeOS/install/skills/ContextSearch/Tools/ContextSearch.ts#L243

const jsonlPath = join(JSONL_DIR, `${uuid}.jsonl`);

A transcript actually lives at projects/<cwd-slug>/<uuid>.jsonl, and the slug varies by the cwd the session ran in — so a UUID cannot be joined onto one slug. Once the root is corrected this join must resolve across project dirs, or it breaks.

Fix

Point at the projects root and let ripgrep recurse; resolve UUIDs across project dirs.

const JSONL_DIR = join(HOME, ".claude", "projects");

function findTranscriptByUuid(uuid: string): string | null {
  try {
    for (const d of readdirSync(JSONL_DIR, { withFileTypes: true })) {
      if (!d.isDirectory()) continue;
      const p = join(JSONL_DIR, d.name, `${uuid}.jsonl`);
      if (existsSync(p)) return p;
    }
  } catch {}
  return null;
}
  • searchJsonl containment guard becomes realDir.startsWith(join(HOME, ".claude", "projects")) — still contained, now to all cwds rather than one slug.
  • The :243 join becomes findTranscriptByUuid(uuid).

Separately, searchIsaBodies globs *ISA.md only. Native sessions produce a SESSION.md durable record, so the artifact layer indexes Algorithm-mode sessions exclusively. Adding --glob *SESSION.md makes native work findable. Happy to split that into its own issue if you'd rather keep this one to the scope fix.

I have this working locally and will open a PR against main if you want it.

christauff avatar Jul 14 '26 20:07 christauff

Fixed in source. Transcript search now sweeps every directory under ~/.claude/projects/ — one dir per cwd, all of them candidates — and the session-name UUID join uses a cross-dir index. Sessions run inside code repos are recallable. (Your report also flushed out a Projects vs projects casing bug that macOS was masking and Linux would have broken on — fixed in the same pass.) Ships next release.

danielmiessler avatar Jul 16 '26 21:07 danielmiessler