refactor: extract doctor command#162
refactor: extract doctor command#162ndycode wants to merge 2 commits intorefactor/pr1-best-commandfrom
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
codex auth doctorimplementation into a dedicated command moduleWhat Changed
lib/codex-manager/commands/doctor.tsfor doctor diagnostics, file checks, summary generation, and fix-mode reportinglib/codex-manager.tssorunDoctor(...)delegates to the extracted doctor command module through injected dependenciestest/codex-manager-doctor-command.test.tsfor command-level coverageValidation
npm run test -- test/codex-manager-doctor-command.test.ts test/codex-manager-cli.test.tsnpm run lintnpm run typechecknpm run buildRisk and Rollback
81fd616to restore the inline doctor implementationAdditional Notes
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
this PR extracts the inline
runDoctorimplementation fromlib/codex-manager.tsinto a dedicatedlib/codex-manager/commands/doctor.tscommand module, continuing the manager split pattern established bybest,check,forecast, andreport. the two regressions flagged in the previous round (fix-mode token refresh+sync being dropped, and the null guard on auth-file parse) are both correctly implemented in the new module.runDoctorCommandcorrectly carries forward all fix-mode behavior:applyDoctorFixes,queuedRefresh,setCodexCliActiveSelection, and the single-callsaveAccountsguard (storageNeedsSave && !options.dryRun)DoctorFixActioninterface was not cleaned up fromcodex-manager.ts— a local non-exported copy remains alongside the canonical exported one indoctor.ts, creating a structural duplicate that could silently divergermSyncwhich violates the project's windows filesystem safety anti-pattern;test/helpers/remove-with-retry.tsshould be used insteadqueuedRefreshfailure path — both touch windows token-file write branchesConfidence Score: 4/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant CLI as codex-manager.ts<br/>runDoctor() participant CMD as doctor.ts<br/>runDoctorCommand() participant FS as node:fs<br/>(existsSync / stat / readFile) participant DEPS as injected deps<br/>(loadAccounts / queuedRefresh / etc.) CLI->>CMD: runDoctorCommand(args, deps) CMD->>CMD: parse args / help check CMD->>FS: existsSync(storagePath) CMD->>FS: existsSync(codexAuthPath) CMD->>FS: readFile(codexAuthPath) → null-guard parse CMD->>DEPS: loadCodexCliState() CMD->>DEPS: loadAccounts() alt options.fix && accounts exist CMD->>DEPS: applyDoctorFixes(storage) alt !hasUsableAccessToken && !dryRun CMD->>DEPS: queuedRefresh(refreshToken) DEPS-->>CMD: TokenResult end alt !dryRun CMD->>DEPS: setCodexCliActiveSelection(...) end end alt storageNeedsSave && !dryRun CMD->>DEPS: saveAccounts(storage) end CMD-->>CLI: exit code (0 / 1)Prompt To Fix All With AI
Last reviewed commit: "fix: sync doctor act..."
Context used (4)