refactor(codex): give the CODEX_HOME lookup its own module
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const os = require("node:os");
|
||||
const { getCodexHome } = require("./codex-home");
|
||||
|
||||
// `*** Update File: <path>` lines inside an apply_patch heredoc.
|
||||
const PATCH_FILE_RE = /^\*\*\* (Add|Update|Delete) File: (.+)$/gm;
|
||||
@@ -98,10 +99,6 @@ function eventsFromPayload(payload) {
|
||||
return [{ tool_name: "Bash", tool_input: { command: commandFromPayload(payload, text) } }];
|
||||
}
|
||||
|
||||
function codexHome() {
|
||||
return process.env.CODEX_HOME || path.join(os.homedir(), ".codex");
|
||||
}
|
||||
|
||||
/** Every rollout journal under sessions/, newest mtime first, capped at MAX_FILES. */
|
||||
function rolloutFiles() {
|
||||
const out = [];
|
||||
@@ -126,7 +123,7 @@ function rolloutFiles() {
|
||||
}
|
||||
}
|
||||
};
|
||||
walk(path.join(codexHome(), "sessions"), 0);
|
||||
walk(path.join(getCodexHome(), "sessions"), 0);
|
||||
return out.sort((a, b) => b.mtime - a.mtime).slice(0, MAX_FILES);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user