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(cli): version 用 build-time JSON import,兼容 standalone binary

之前 cli.ts 的 readPackageVersion() 用 readFileSync(new URL("./package.json",
import.meta.url)),源码 / npm 装都能 work,但 bun build --compile 出来
的 standalone binary 在虚拟 /$bunfs/root/ 下找不到 package.json
(JSON 没被 bundle),启动直接 ENOENT。

改成 import packageJson from "./package.json" with { type: "json" } —
bundler 把 JSON 内联进 binary,运行时不再读 fs。源码模式 / npm 模式 /
binary 模式三者都 OK。

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

cat c2569cdc aab2153c

+3 -11
+3 -11
cli.ts
··· 1 1 #!/usr/bin/env bun 2 2 3 - import { existsSync, readFileSync } from "node:fs"; 3 + import { existsSync } from "node:fs"; 4 4 import { Command } from "commander"; 5 + import packageJson from "./package.json" with { type: "json" }; 5 6 import { DEFAULT_CODEX_STATE_DB_PATH, DEFAULT_DB_PATH, resolveCodexDir } from "./env"; 6 7 import { 7 8 printCurrentSessions, ··· 30 31 program 31 32 .name("cxs") 32 33 .description("Codex sessions 渐进式检索 CLI") 33 - .version(readPackageVersion()); 34 + .version(packageJson.version); 34 35 35 36 program 36 37 .command("current") ··· 234 235 function normalizeListSort(value: string | undefined): SessionListSort { 235 236 if (value === "started" || value === "messages") return value; 236 237 return "ended"; 237 - } 238 - 239 - function readPackageVersion(): string { 240 - const raw = readFileSync(new URL("./package.json", import.meta.url), "utf8"); 241 - const parsed = JSON.parse(raw) as { version?: unknown }; 242 - if (typeof parsed.version !== "string" || !parsed.version) { 243 - throw new Error("package.json version is missing"); 244 - } 245 - return parsed.version; 246 238 } 247 239 248 240 function emitCurrentError(error: CurrentStateDbError, jsonMode: boolean): void {