Add Bailian CLI token plan usage source - #3080
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 3:43 PM ET / 19:43 UTC. ClawSweeper reviewWhat this changesAdds Bailian CLI quota retrieval as an explicit source and an explicitly selected Auto fallback for Alibaba Token Plan, with source settings, parsing, CLI routing, and regression tests. Merge readinessKeep open: the latest head addresses the prior compatibility and environment-isolation blockers, with no new correctness finding. Owner sign-off is still required because this adds an authenticated third-party CLI path affecting provider privacy behavior. Priority: P2 Review scores
Verification
How this fits togetherCodexBar’s Alibaba Token Plan provider turns configured local sources into quota snapshots used by the menu bar and cross-platform CLI. This PR adds a signed-in Bailian CLI route beside the browser-cookie route and labels the resolved source in those outputs. flowchart LR
A[Provider settings] --> B[Source selection]
B --> C[Browser-cookie route]
B --> D[Bailian CLI route]
C --> E[Quota snapshot]
D --> E
E --> F[Menu bar and CLI output]
Decision needed
Why: The implementation is bounded and the contributor supplied real proof, but VISION.md reserves provider-auth and privacy behavior changes for owner sign-off. Before merge
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: Land the narrow descriptor-based source only after the owner confirms that explicit Web-to-CLI fallback is acceptable, retaining legacy Web-only behavior and the child-environment allowlist. Do we have a high-confidence way to reproduce the issue? Not applicable as a feature request; the contributor nevertheless supplied high-confidence redacted after-fix terminal evidence for explicit CLI mode and Auto fallback. Is this the best way to solve the issue? Yes technically: this follows the existing descriptor, strategy, settings, and test seams without a dependency or new config schema. Product acceptance still requires the VISION.md sign-off for authenticated provider behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f74117aeb7a9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 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. |
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