/** * @file Centralized Codex home directory path management. Resolves the Codex * home directory, project-level Codex surfaces, and project roots. Supports a * custom root via the CODEX_HOME environment variable so the dashboard can * track non-standard Codex installations. * @author Nguyễn Ngọc Trí Vĩ */ const path = require("node:path"); const os = require("node:os"); /** * The Codex home directory. Resolves to $CODEX_HOME if set, else * ~/.codex. Always reads process.env at call time so tests can inject. * * @returns {string} Absolute path to the Codex home directory. */ function getCodexHome() { return process.env.CODEX_HOME || path.join(os.homedir(), ".codex"); } /** * The directory where Codex stores per-project surfaces (rollout journals, * SQLite mirrors, etc.) for a project at the given working directory. * * @param {string} cwd Absolute path to a project root. * @returns {string} Absolute path to /.codex. */ function getProjectCodexDir(cwd) { return path.join(cwd, ".codex"); } /** * The project root. For now, this is just an identity function — cwd is * the project root. Exists as a contract for consistency with claude-home.js * and to anchor the path-resolution hierarchy. * * @param {string} cwd Absolute path to a project root (where AGENTS.md lives). * @returns {string} The same cwd. */ function getProjectRoot(cwd) { return cwd; } module.exports = { getCodexHome, getProjectCodexDir, getProjectRoot, };