Add Bailian CLI token plan usage source - #3080
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 25, 2026, 8:16 PM ET / August 26, 2026, 00:16 UTC. ClawSweeper reviewWhat this changesThis PR adds Bailian CLI usage retrieval, CLI/Web source selection, bounded subprocess parsing, tests, and documentation for the Alibaba Token Plan provider. Merge readinessKeep open, but do not merge until a maintainer confirms the upgrade policy: existing Alibaba Token Plan configurations without a saved source now run the signed-in Bailian CLI before their established browser-cookie source. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherThe Alibaba Token Plan provider selects a credential source, fetches quota windows, and publishes the normalized result to CodexBar’s menu bar and command-line output. Persisted provider settings determine whether it uses browser cookies or the locally signed-in Bailian CLI. flowchart LR
A[Saved provider settings] --> B[Source-mode resolution]
B --> C[Bailian CLI]
B --> D[Browser cookies]
C --> E[Quota parser]
D --> E
E --> F[Usage snapshot]
F --> G[Menu bar and CLI]
Decision needed
Why: The branch deliberately codifies CLI-first routing for legacy configurations, while the prior behavior and PR compatibility claim point to browser-first behavior; this is an upgrade-policy choice rather than a parser repair. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep absent source values on the established Web path, and reserve CLI-first Auto for an explicit user choice; alternatively, land an intentional, documented migration only after maintainer approval and upgrade-account proof. Do we have a high-confidence way to reproduce the issue? Yes: a provider configuration without Is this the best way to solve the issue? No as submitted: the CLI implementation is bounded and evidenced, but changing saved legacy behavior needs either an opt-in compatibility path or an explicitly approved migration. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 26132179a00a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
Addressed the compatibility finding in commit 1f7ab22:
All 58 Alibaba Token Plan tests and @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Addressed the two blocking review points in
Validation:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Co-authored-by: Joe <asjoehe@gmail.com>
|
Landed as c2eff4c with the maintainer-requested automatic source order restored: signed-in Bailian CLI first, then browser/manual cookies; explicit CLI and Web remain strict. Added live isolated subprocess proof for regional argv, both quota/reset windows, sanitized child environment and cancellation, plus real provider-pipeline fallback to scoped manual cookies. Also fixed pre-existing priority-pricing tests that depended on ambient models.dev caches and caused the first hosted run to fail. Final proof: 933 local selections across 78 groups, zero failures/retries/timeouts; lint, architecture gate, independent review, and hosted CI passed. Thanks @Hek846! |
Summary
bl usage token-plan --output jsonCompatibility and safety
Auto keeps the existing browser-cookie path first and falls back to the signed-in Bailian CLI only when Web fails. Explicit CLI and Web modes remain strict.
The CLI is invoked with an argv array through the existing bounded subprocess runner, with a 15-second timeout and a 64 KiB output cap. Only the four documented quota/reset fields are parsed. Missing CLI, authentication, network, and unsupported-output failures remain sanitized without exposing raw diagnostics or CLI configuration.
Task cancellation remains cancellation rather than being surfaced as an authentication error.
Redacted real behavior proof
Environment: signed-in domestic Personal Token Plan account,
cn-beijing, Bailian CLI 1.16.0. An upgrade to 1.17.0 was attempted, but npm refused to overwrite an existing~/.local/bin/bl; no files or credentials were changed by that attempt.Command:
Redacted observed shape:
{ "per5HourPercentage": "<omitted>", "per5HourResetTime": "<omitted>", "per1WeekPercentage": "<number>", "per1WeekResetTime": "<number>" }This confirms the real CLI may return either window independently.
The built CodexBar CLI consumed the same signed-in session:
Redacted result:
{ "provider": "alibabatokenplan", "source": "cli", "primaryPresent": false, "secondary": { "usedPercent": "<redacted-number>", "resetsAt": "<redacted-ISO8601>", "windowMinutes": 10080 } }A second real run with
--source autoresolved tosource: "cli"with a valid secondary window, demonstrating browser-first Auto successfully falling through to the CLI source on this setup. Focused routing coverage asserts the ordered strategies are Web → CLI and that Web falls back only in Auto mode.Validation
make checkswift test --filter AlibabaTokenPlan— 58 tests in 9 suites passedmake testduring implementation — 906 selections across 76 groups passedgit diff --checkCloses #3020