()
| 140 | } |
| 141 | |
| 142 | function main() { |
| 143 | const input = readHookInput(); |
| 144 | const cwd = input.cwd || process.env.CLAUDE_PROJECT_DIR || process.cwd(); |
| 145 | const workspaceRoot = resolveWorkspaceRoot(cwd); |
| 146 | const config = getConfig(workspaceRoot); |
| 147 | |
| 148 | const jobs = sortJobsNewestFirst(filterJobsForCurrentSession(listJobs(workspaceRoot), input)); |
| 149 | const runningJob = jobs.find((job) => job.status === "queued" || job.status === "running"); |
| 150 | const runningTaskNote = runningJob |
| 151 | ? `Codex task ${runningJob.id} is still running. Check /codex:status and use /codex:cancel ${runningJob.id} if you want to stop it before ending the session.` |
| 152 | : null; |
| 153 | |
| 154 | if (!config.stopReviewGate) { |
| 155 | logNote(runningTaskNote); |
| 156 | return; |
| 157 | } |
| 158 | |
| 159 | const setupNote = buildSetupNote(cwd); |
| 160 | if (setupNote) { |
| 161 | logNote(setupNote); |
| 162 | logNote(runningTaskNote); |
| 163 | return; |
| 164 | } |
| 165 | |
| 166 | const review = runStopReview(cwd, input); |
| 167 | if (!review.ok) { |
| 168 | emitDecision({ |
| 169 | decision: "block", |
| 170 | reason: runningTaskNote ? `${runningTaskNote} ${review.reason}` : review.reason |
| 171 | }); |
| 172 | return; |
| 173 | } |
| 174 | |
| 175 | logNote(runningTaskNote); |
| 176 | } |
| 177 | |
| 178 | try { |
| 179 | main(); |
no test coverage detected