Address PR review:
- hoist the recognised true/false token sets to module-level Sets instead
of allocating an array on every boolean-flag parse
- accept common spellings (true/1/yes/on, false/0/no/off; case- and
whitespace-insensitive) and throw a clear error for an unrecognised
explicit value (e.g. `--flag=maybe`, `--flag=`) so a typo cannot
silently enable a flag, consistent with numeric-flag validation
- expand tests to cover no/off, case/whitespace, true-like values, and the
rejection path
parseFlags set a boolean flag to `true` as soon as it matched the flag,
before inspecting an inline `=value`. So `--flag=false` (or `--flag=0`)
was silently set to `true` -- the opposite of what the user typed -- and
the value was discarded.
Honor an explicit value: `--flag=false`/`0`/`no`/`off` -> false; a bare
`--flag` and `--flag=true` (or any other value) stay true, so there is no
behavior change for existing usage.
Adds parseFlags tests for the bare-flag and explicit-value cases.
The /v1/token_plan/remains endpoint returns two signals the renderer
ignored:
- weekly_boost_permille (千分制, e.g. 1500 ⇒ ×1.5 ⇒ display up to 150%)
- current_weekly_status === 3 ⇒ weekly quota is unlimited
Previously, the weekly row always used the raw remaining percent, so
a 1.5x boost plan showed 100% instead of 150%, and an unlimited plan
was visually indistinguishable from a normal 100% account.
Changes:
- api.ts: add weekly_boost_permille?, current_interval_status?,
current_weekly_status? to QuotaModelRemain
- quota-table.ts: multiply weekly percent by boost_permille/1000,
render '无限' / 'unlimited' for status=3, raise display ceiling to
200% to accommodate boosted values
- quota-table.test.ts: cover 150% boost, 200% clamp, unlimited CN/EN
quotaEndpoint() ignored its baseUrl argument and rebuilt the host from a
`baseUrl.includes('minimaxi.com')` check, which broke `--base-url` /
custom gateways — it was the only endpoint in the file not using the
passed baseUrl. It also pointed at the legacy
`/v1/api/openplatform/coding_plan/remains` path; the server now serves
the quota under `/v1/token_plan/remains` (matching the Token Plan
naming). With a line-matched API key the old path returns
"cookie is missing, log in again" while the new path works.
- quotaEndpoint: return `${baseUrl}/v1/token_plan/remains`, dropping the
host rewrite (REGIONS base URLs are already api-subdomain hosts).
- detect-region: probe the same new path.
- update endpoint/sdk/timeout mocks and add a custom-base-URL test.
Verified live on both lines: `quota show` renders quota over
GET .../v1/token_plan/remains for global and cn.
- switch quota calls to the coding plan remains endpoint because the usage page now exposes aggregated resources through that API
- render current and weekly remaining quota in a compact single-line layout so terminal users can scan the new response shape quickly
- add regression coverage for coding plan remaining percentages and updated quota endpoint paths
Review feedback on #158 (thanks @NianJiuZst): the error path needs to
tear the writer down BEFORE unlinking dest, otherwise the writer's
buffered bytes can race the unlink and leave a partial file in the
pagecache. And the function still had no test coverage, so the
`finish`/`drain`/cleanup/`releaseLock()` behaviour could regress
silently.
Changes:
* `downloadFile`: on error, `writer.destroy()` and await `'close'`
before calling `unlinkSync(dest)`. Skip the wait when the writer
is already torn down so the rejection's exception isn't masked.
* Export `downloadFile` from `src/update/self-update.ts` so unit
tests can drive it directly (still not part of the public CLI
surface — callers go through `applySelfUpdate`).
* Add `test/update/self-update.test.ts` with three tests, matching
the existing `test/files/download.test.ts` style:
- mid-stream `ReadableStream` error path: rejects, dest gone,
tempdir empty (the case the reviewer specifically asked for)
- happy path: payload written, dest exists
- 4xx response: rejects with CLIError, dest not created
`npx tsc --noEmit` passes.
- fix test isolation: support MMX_CONFIG_DIR env for config path override
- remove free-tier music models (music-2.6-free, music-cover-free), default to music-2.6 / music-cover
- improve auth login prompt: show region info for API key option