cxs is a local-first CLI for searching Codex session logs. It is designed for progressive retrieval: find the right session first, then read
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(env): DATA_DIR 默认改 ~/.cache/cxs,允许 CXS_DATA_DIR 覆盖

之前 DATA_DIR = resolve(import.meta.dir, "data") 是 *相对仓库根* 的路径,
对源码 checkout 模式 OK,但对 npm i -g 与 bun build --compile 都炸:

- npm i -g 后 import.meta.dir 指向全局 node_modules/cxs,默认 db 写到
那里,要么权限不够要么污染全局安装目录
- bun build --compile 出来的 binary fs 是只读虚拟 /$bunfs/,
ensureDataDir() 直接 EROFS

改成默认 ~/.cache/cxs (XDG cache 约定),并支持 CXS_DATA_DIR 环境变量
覆盖。源码 dev 模式行为也跟着变 — 现有 ./data/index.sqlite 不再被
默认读到,需要重 sync 一次到新位置 (~75s,幂等)。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Entire-Checkpoint: 8f465c5aec2f

cat aab2153c 5a4cac73

+8 -2
+8 -2
env.ts
··· 2 2 import { homedir } from "node:os"; 3 3 import { resolve } from "node:path"; 4 4 5 - const ROOT = resolve(import.meta.dir); 6 - const DATA_DIR = resolve(ROOT, "data"); 5 + // Why: previously DATA_DIR was resolve(import.meta.dir, "data"), which works 6 + // for dev checkouts but breaks for both `npm i -g cxs` (writes into 7 + // node_modules) and `bun build --compile` (writes into the read-only 8 + // /$bunfs virtual fs). Default to ~/.cache/cxs (XDG cache convention) and 9 + // let CXS_DATA_DIR override. 10 + const DATA_DIR = process.env.CXS_DATA_DIR 11 + ? resolve(process.env.CXS_DATA_DIR) 12 + : resolve(homedir(), ".cache", "cxs"); 7 13 8 14 export const DEFAULT_DB_PATH = resolve(DATA_DIR, "index.sqlite"); 9 15 export const DEFAULT_CODEX_DIR = resolve(homedir(), ".codex", "sessions");