codex-plugin-cc
codex-plugin-cc copied to clipboard
EISDIR crash in working-tree review when untracked directories exist
Bug
/codex:adversarial-review --scope working-tree (and likely /codex:review --scope working-tree) crashes with EISDIR: illegal operation on a directory, read when the working tree contains untracked directories.
Reproduction
- Have any untracked directory in your repo (e.g.,
.claude/worktrees/agent-*/, or anymkdir foo && git status) - Run:
node scripts/codex-companion.mjs adversarial-review --wait --scope working-tree "any prompt" - Result:
EISDIR: illegal operation on a directory, read
Root Cause
In scripts/lib/git.mjs, formatUntrackedFile() (line ~136) does not check stat.isDirectory() before calling fs.readFileSync():
function formatUntrackedFile(cwd, relativePath) {
const absolutePath = path.join(cwd, relativePath);
const stat = fs.statSync(absolutePath);
if (stat.size > MAX_UNTRACKED_BYTES) {
return `...skipped...`;
}
const buffer = fs.readFileSync(absolutePath); // CRASHES here when absolutePath is a directory
...
}
The untracked file list comes from git ls-files --others --exclude-standard (line ~64), which can return directory paths.
Suggested Fix
Add a directory check before the read:
function formatUntrackedFile(cwd, relativePath) {
const absolutePath = path.join(cwd, relativePath);
const stat = fs.statSync(absolutePath);
if (stat.isDirectory()) {
return `### ${relativePath}\n(skipped: directory)`;
}
// ... rest of function
}
Environment
- codex-plugin-cc 1.0.0
- Codex CLI 0.117.0
- macOS 15 (Darwin 25.3.0)
- Node.js v20.19.0