refactor(sf): rename sift cache env to SIFT_SEARCH_CACHE

Switches the per-project sift warmup runtime dir field from cacheHome
(generic XDG_CACHE_HOME) to searchCache (specific SIFT_SEARCH_CACHE).
Narrower env var only redirects sift's search index, leaving sift's
other XDG_CACHE_HOME consumers (model downloads etc.) on the global
~/.cache/sift path so models are shared across projects.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-02 15:33:41 +02:00
parent c4ac851187
commit a48cf9beb0
2 changed files with 11 additions and 11 deletions

View file

@ -145,12 +145,12 @@ const DEFAULT_SIFT_WARMUP_HARD_TIMEOUT_SEC = 30;
const SIFT_WARMUP_KILL_GRACE_SEC = 10;
function resolveSiftWarmupRuntimeDirs(projectRoot: string): {
cacheHome: string;
searchCache: string;
tmpDir: string;
} {
const runtimeRoot = join(projectRoot, ".sf", "runtime", "sift");
return {
cacheHome: join(runtimeRoot, "xdg-cache"),
searchCache: join(runtimeRoot, "search-cache"),
tmpDir: join(runtimeRoot, "tmp"),
};
}
@ -162,7 +162,7 @@ function buildSiftWarmupEnv(
const dirs = resolveSiftWarmupRuntimeDirs(projectRoot);
return {
...env,
XDG_CACHE_HOME: dirs.cacheHome,
SIFT_SEARCH_CACHE: dirs.searchCache,
TMPDIR: dirs.tmpDir,
};
}
@ -513,7 +513,7 @@ export function ensureSiftIndexWarmup(
try {
const runtimeDirs = resolveSiftWarmupRuntimeDirs(projectRoot);
mkdirSync(join(projectRoot, ".sf", "runtime"), { recursive: true });
mkdirSync(runtimeDirs.cacheHome, { recursive: true });
mkdirSync(runtimeDirs.searchCache, { recursive: true });
mkdirSync(runtimeDirs.tmpDir, { recursive: true });
const childEnv = buildSiftWarmupEnv(projectRoot, env);
writeFileSync(
@ -527,7 +527,7 @@ export function ensureSiftIndexWarmup(
args,
siftBinary: detection.binaryPath,
hardTimeoutSec: wrapper?.timeoutSec ?? null,
cacheHome: runtimeDirs.cacheHome,
searchCache: runtimeDirs.searchCache,
tmpDir: runtimeDirs.tmpDir,
},
null,
@ -820,7 +820,7 @@ function buildSiftContextLines(
'`--strategy path-hybrid` for path-heavy queries, and `sift search <path> --agent "<task>"` for bounded planner-driven exploration.',
);
lines.push(
"- SF runs Sift warmup with project-scoped cache/temp directories under `.sf/runtime/sift/`; " +
"- SF runs Sift warmup with a project-scoped `SIFT_SEARCH_CACHE` under `.sf/runtime/sift/` while leaving model cache shared; " +
"if the CLI is missing or fails, continue with `.sf/CODEBASE.md`, native `grep`/`find`/`ls`, `lsp`, and scout.",
);
} else {
@ -989,7 +989,7 @@ export function formatSiftStatus(
'When configured, agents should use `sift search --json <path> "<query>"`; `page-index-hybrid` is the strongest direct-search preset and `path-hybrid` is best for path-heavy queries.',
);
lines.push(
"SF runs Sift warmup with project-scoped cache/temp directories under .sf/runtime/sift/.",
"SF runs Sift warmup with a project-scoped SIFT_SEARCH_CACHE under .sf/runtime/sift/ while leaving model cache shared.",
);
return lines.join("\n");
}

View file

@ -529,8 +529,8 @@ test("ensureSiftIndexWarmup defaults optional warmup hard cap to 30 seconds", ()
]);
assert.match(result.reason, /hard cap 30s/);
assert.equal(
calls[0].options?.env?.XDG_CACHE_HOME,
join(projectRoot, ".sf", "runtime", "sift", "xdg-cache"),
calls[0].options?.env?.SIFT_SEARCH_CACHE,
join(projectRoot, ".sf", "runtime", "sift", "search-cache"),
);
assert.equal(
calls[0].options?.env?.TMPDIR,
@ -543,8 +543,8 @@ test("ensureSiftIndexWarmup defaults optional warmup hard cap to 30 seconds", ()
),
);
assert.equal(
marker.cacheHome,
join(projectRoot, ".sf", "runtime", "sift", "xdg-cache"),
marker.searchCache,
join(projectRoot, ".sf", "runtime", "sift", "search-cache"),
);
assert.equal(
marker.tmpDir,