refactor: split forecast and report cli flows#143
refactor: split forecast and report cli flows#143ndycode wants to merge 1 commit intoplan/02-cli-help-and-login-splitfrom
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
auth forecastandauth reportinto a dedicated command module.What Changed
lib/codex-manager/forecast-report-commands.tsfor forecast/report argument parsing, JSON serialization, live quota probe flow, and report file output.lib/codex-manager.tsfocused on dispatch plus shared dependency wiring for the extracted commands.Validation
npm run lintnpm run typechecknpm testnpm test -- test/documentation.test.tsnpm run buildDocs and Governance Checklist
docs/getting-started.mdupdated (if onboarding flow changed) - not needed; onboarding behavior unchangeddocs/features.mdupdated (if capability surface changed) - not needed; capability surface unchangeddocs/reference/*pages updated (if commands/settings/paths changed) - not needed; command behavior unchangeddocs/upgrade.mdupdated (if migration behavior changed) - not needed; no migration changeSECURITY.mdandCONTRIBUTING.mdreviewed for alignmentRisk and Rollback
d1d2a7a.Additional Notes
plan/02-cli-help-and-login-split).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
auth forecastandauth reportCLI flows from the monolithiclib/codex-manager.tsinto a dedicatedlib/codex-manager/forecast-report-commands.tsmodule, following the same dependency-injection pattern already used byauth-commands.ts. behavior is preserved: theriskTone/availabilityTonehelpers are correctly inlined as ternaries, and thejoinStyledSegmentsreplacement (rowParts.join(deps.stylePromptText(" | ", "muted"))) is functionally identical sincejoinStyledSegmentsalso joined with" | ".key concerns:
parseForecastArgs,parseReportArgs,runForecast, andrunReportare all individually testable now but have no dedicated test file — this leaves the extracted logic uncovered by unit tests.PromptTone,QuotaEmailFallbackState,QuotaCacheAccountRef) are copied fromcodex-manager.tsinstead of being moved to a shared types file; silent drift risk if upstream definitions change.--outvalue is resolved directly viaresolve(process.cwd(), outPath)with no cwd-boundary check; a relative traversal path (../../etc/foo) will silently write outside the working directory on any platform.runReport(live mode) always callsqueuedRefreshfor every account without first checkinghasUsableAccessToken, unlikerunForecastwhich guards the refresh. this is not a regression introduced here, but now that the code is isolated and unit-testable it's a good time to align the two.Confidence Score: 4/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant CLI as runCodexMultiAuthCli participant CM as codex-manager.ts participant FRC as forecast-report-commands.ts participant Storage as storage.js participant Refresh as refresh-queue.js participant Quota as quota-probe.js participant Cache as quota-cache.js CLI->>CM: auth forecast / auth report CM->>FRC: runForecastCommand(args, deps) FRC->>Storage: setStoragePath(null) + loadAccounts() Storage-->>FRC: AccountStorageV3 alt --live flag set FRC->>Cache: loadQuotaCache() Cache-->>FRC: QuotaCacheData loop each enabled account FRC->>Refresh: queuedRefresh(refreshToken) Refresh-->>FRC: TokenResult FRC->>Quota: fetchCodexQuotaSnapshot(accountId, accessToken, model) Quota-->>FRC: QuotaSnapshot FRC->>Cache: updateQuotaCacheForAccount(...) end FRC->>Cache: saveQuotaCache(workingCache) end FRC->>FRC: evaluateForecastAccounts(inputs) FRC->>FRC: summarizeForecast + recommendForecastAccount alt --json flag FRC->>CLI: console.log(JSON) else --out path (report only) FRC->>Storage: fs.writeFile(outputPath, JSON) FRC->>CLI: console.log(human summary) else human output FRC->>CLI: console.log(styled rows) endPrompt To Fix All With AI
Last reviewed commit: "refactor: split fore..."