sideby 0.31.3 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +4 -4
  2. package/dist/build.json +1 -1
  3. package/dist/src/cli/commands.js +27 -11
  4. package/dist/src/cli/format.js +3 -2
  5. package/dist/src/cli/json-schemas.js +25 -5
  6. package/dist/src/core/ask.js +6 -1
  7. package/dist/src/core/handoff-rules.js +5 -5
  8. package/dist/src/core/handoff-select.js +6 -6
  9. package/dist/src/core/handoff.d.ts +36 -3
  10. package/dist/src/core/handoff.js +57 -18
  11. package/dist/src/core/pick-commands.d.ts +19 -4
  12. package/dist/src/core/pick-commands.js +19 -5
  13. package/dist/src/core/quota-levels.d.ts +67 -4
  14. package/dist/src/core/quota-levels.js +82 -6
  15. package/dist/src/families/claude/index.js +3 -0
  16. package/dist/src/families/claude/quota-fetch.d.ts +26 -0
  17. package/dist/src/families/claude/quota-fetch.js +236 -0
  18. package/dist/src/menubar/script.js +62 -12
  19. package/dist/src/menubar/snapshot.d.ts +9 -5
  20. package/dist/src/menubar/snapshot.js +37 -24
  21. package/dist/src/menubar/strings.d.ts +6 -4
  22. package/dist/src/menubar/strings.js +6 -4
  23. package/dist/src/panel/handler.js +7 -3
  24. package/dist/src/panel/i18n.d.ts +1 -0
  25. package/dist/src/panel/i18n.js +8 -6
  26. package/dist/src/panel/page-logic.d.ts +32 -8
  27. package/dist/src/panel/page-logic.js +43 -16
  28. package/dist/src/panel/page-script.js +12 -9
  29. package/dist/src/panel/page.js +3 -1
  30. package/dist/src/runtime.d.ts +2 -1
  31. package/dist/src/runtime.js +10 -4
  32. package/dist/testing/index.d.ts +5 -0
  33. package/dist/testing/index.js +2 -0
  34. package/package.json +2 -2
  35. package/schemas/menubar-snapshot.json +3 -3
  36. package/schemas/next.json +57 -4
  37. package/skills/sideby/SKILL.md +2 -2
  38. package/skills/sideby/references/accounts.md +1 -1
  39. package/skills/sideby/references/ai-tasks.md +2 -2
  40. package/skills/sideby/references/diagnose.md +1 -1
  41. package/skills/sideby/references/handoff.md +12 -8
  42. package/skills/sideby/references/panel.md +1 -1
  43. package/skills/sideby/references/quota.md +9 -3
@@ -5,7 +5,7 @@ import { createHash } from 'node:crypto';
5
5
  import { FAVICON_SVG, MARK_SVG } from '../core/brand-mark.js';
6
6
  import { commandListForPage } from '../core/cli-commands.js';
7
7
  import { ALIAS_NAME, RESERVED_ALIASES } from '../core/config.js';
8
- import { QUOTA_FAIL_PERCENT, QUOTA_WARN_PERCENT, USAGE_DAYS } from '../core/quota-levels.js';
8
+ import { QUOTA_FAIL_PERCENT, QUOTA_LONG_FAIL_PERCENT, QUOTA_LONG_WARN_PERCENT, QUOTA_WARN_PERCENT, USAGE_DAYS, } from '../core/quota-levels.js';
9
9
  import { COMMON_ENTRIES, SEARCH_CATALOG } from '../core/search-catalog.js';
10
10
  import { REPO_URL, SKILL_INSTALL } from '../core/skill-check.js';
11
11
  import { MESSAGES } from './i18n.js';
@@ -59,6 +59,8 @@ export function renderPage(opts) {
59
59
  },
60
60
  warn: QUOTA_WARN_PERCENT,
61
61
  fail: QUOTA_FAIL_PERCENT,
62
+ longWarn: QUOTA_LONG_WARN_PERCENT,
63
+ longFail: QUOTA_LONG_FAIL_PERCENT,
62
64
  usageDays: USAGE_DAYS,
63
65
  // The alias rules of the config, so the new-account dialog checks a short command as sideby will.
64
66
  aliasPattern: ALIAS_NAME.source,
@@ -357,7 +357,8 @@ export interface Runtime {
357
357
  /** Puts back what `remoteControlOff` or `remoteControlOn` replaced, only where the key still holds what it wrote. */
358
358
  remoteControlUndo(): Promise<RemoteControlChange>;
359
359
  /**
360
- * Which Account of a Family to move on to (spec §3.13). Throws a UserError with code `no-quota-source`
360
+ * Which Account of a Family to move on to (spec §3.13), for a start the user asks for: past the Takeover Limit it
361
+ * falls back to the least used Account under 100% (`tight`). Throws a UserError with code `no-quota-source`
361
362
  * when the Family cannot tell, `no-accounts` when it has none.
362
363
  */
363
364
  handoff(familyId: string, opts?: {
@@ -19,7 +19,7 @@ import { resolvePaths } from './core/paths.js';
19
19
  import { choosePick, suggestPickName } from './core/pick-commands.js';
20
20
  import { categoryReader } from './core/project-categories.js';
21
21
  import { fetchedQuota, quotaCheckOff, shownQuota } from './core/quota-fetch.js';
22
- import { takeoverLimit } from './core/quota-levels.js';
22
+ import { takeoverLimits } from './core/quota-levels.js';
23
23
  import { remoteControlGroups, turnRemoteControlOff, turnRemoteControlOn, undoRemoteControlOff, } from './core/remote-control.js';
24
24
  import { findResumeRoute } from './core/resume.js';
25
25
  import { SAME_LOGIN_FAMILIES, sameLoginGroups, sharedQuota } from './core/same-login.js';
@@ -985,9 +985,15 @@ export async function createRuntime(opts = {}) {
985
985
  // The current Account: the one sideby started this process from, when it belongs to this Family.
986
986
  const current = env.SIDEBY_ACCOUNT;
987
987
  const from = current && list.some((a) => a.ref === current) ? current : undefined;
988
- // The Takeover Limit follows the user's Handoff Threshold, so `sideby next` and Auto Handoff agree on "full".
989
- const fullAt = takeoverLimit(handoffSettings(config).threshold);
990
- return planHandoff(f.id, candidates, readContext().now, { ...o, fullAt, ...(from ? { from } : {}) });
988
+ // The Takeover Limits follow the user's Handoff Threshold, so `sideby next` and Auto Handoff agree on "full".
989
+ // A start the user asks for may still go past them (a Last Resort, spec §3.13); Auto Handoff never does.
990
+ const limits = takeoverLimits(handoffSettings(config).threshold);
991
+ return planHandoff(f.id, candidates, readContext().now, {
992
+ ...o,
993
+ limits,
994
+ lastResort: true,
995
+ ...(from ? { from } : {}),
996
+ });
991
997
  },
992
998
  handoffSettings: () => handoffSettings(config),
993
999
  async handoffDecision(origin, used, opts = {}) {
@@ -27,6 +27,11 @@ export interface FakeHostOptions {
27
27
  * without a start record either way; left out, it prints nothing, as a Host whose version cannot be told.
28
28
  */
29
29
  version?: string;
30
+ /**
31
+ * Treat a quota question (`claude -p /usage`, spec §3.26) like any start: record it and run `onStart`. Left out,
32
+ * the fake exits at once without a record or an answer, as a check that starts no session.
33
+ */
34
+ quota?: boolean;
30
35
  }
31
36
  /**
32
37
  * Installs a fake Host executable named `name` that appends its argv, selected env and received signals
@@ -62,6 +62,8 @@ if (process.argv.length === 3 && process.argv[2] === '--version') {
62
62
  process.stdout.write(${JSON.stringify(opts.version ? `${opts.version}\n` : '')})
63
63
  process.exit(0)
64
64
  }
65
+ // A quota question (\`claude -p /usage\`, spec §3.26) starts no session either: no record, and no answer.
66
+ ${opts.quota ? '' : "if (process.argv[2] === '-p' && process.argv[3] === '/usage') process.exit(0)"}
65
67
  // Handlers first: tests signal the Host as soon as the start record appears.
66
68
  for (const s of ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGQUIT']) process.on(s, () => { rec({ signal: s }); process.exit(${opts.sleep ? 100 : 0}) })
67
69
  rec({ argv: process.argv.slice(2), env: process.env, pid: process.pid })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.31.3",
3
+ "version": "0.32.1",
4
4
  "description": "Run work, personal and API-key accounts at the same time, without their configs drifting apart.",
5
5
  "license": "MIT",
6
6
  "author": "Adonis0123 (https://github.com/Adonis0123)",
@@ -85,5 +85,5 @@
85
85
  },
86
86
  "packageManager": "pnpm@10.15.0",
87
87
  "readmeFilename": "README.md",
88
- "readme": "<p align=\"center\">\n <img alt=\"sideby: work, personal and API-key accounts, one terminal each, one shared config\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/banner.jpg\" width=\"880\">\n</p>\n\n<p align=\"center\">\n <b>Run work, personal and API-key accounts at the same time, without their configs drifting apart.</b><br>\n Each account is its own directory and its own terminal. Skills, hooks and settings stay linked to your main account. Claude Code, Codex, Grok Build and pi.\n</p>\n\n<p align=\"center\">\n <a href=\"https://www.npmjs.com/package/sideby\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/sideby\"></a>\n <a href=\"https://github.com/Adonis0123/sideby/actions/workflows/ci.yml\"><img alt=\"CI\" src=\"https://github.com/Adonis0123/sideby/actions/workflows/ci.yml/badge.svg\"></a>\n <img alt=\"Node 22.18+\" src=\"https://img.shields.io/badge/node-%E2%89%A522.18-339933\">\n <a href=\"LICENSE\"><img alt=\"MIT\" src=\"https://img.shields.io/badge/license-MIT-blue\"></a>\n</p>\n\n<p align=\"center\">English | <a href=\"README.zh-CN.md\">中文</a></p>\n\n## Quick start\n\nRequires Node 22.18+ and at least one Host CLI (Claude Code, Codex, Grok Build or pi) installed. AI agents: follow the setup steps in [`llms.txt`](llms.txt) (\"Set up sideby for a user\") instead.\n\n```sh\nnpm i -g sideby\nsideby new claude work # create ~/.claude-work, sharing ~/.claude's skills and hooks\nsideby login claude:work # sign in once\nsideby run work # Claude Code on the work account\nsideby quota setup claude --yes # Claude quota in the panel; undo: sideby quota teardown claude\nsideby ui --background # every account's quota at http://127.0.0.1:17420, still there after you close the terminal\n```\n\n`sideby app install` adds a Dock icon that opens the panel, and `sideby autostart on` has it ready each time you log in. `sideby update` installs a newer sideby when there is one; sideby says so after a command and in the panel. `sideby run claude:main` keeps using `~/.claude` in another terminal at the same time. Arguments after `--` go to the Host: `sideby run work -- --resume`. To try it without installing, run `npx sideby`.\n\n## Set up with your AI agent\n\nPaste this into Claude Code, Codex or any coding agent:\n\n```text\nInstall the sideby CLI (npm package `sideby`) and its agent skill, then set up a second Claude Code account for me.\nFollow \"Set up sideby for a user\" in https://raw.githubusercontent.com/Adonis0123/sideby/main/llms.txt\n```\n\nThe agent checks Node and your Host CLIs, installs sideby and the skill, creates the account, tells you what it shares with your main one and makes its short command work. You sign in once in your browser; the agent gives you that one command. Once the skill is installed, short requests work too: \"add another Claude account, cc008\", \"what do my Codex accounts share?\", \"which account still has quota?\".\n\n## What it looks like\n\nThe 25-second story: one account buried in tasks, then accounts side by side sharing one setup, and a task moving on when one runs out.\n\nhttps://github.com/user-attachments/assets/d1d7e8dd-1df1-4881-ac88-e468c2dd4a1d\n\n<img alt=\"Two terminals: the personal account and the work account running at the same time, both linked to the main account's skills and settings, then the local quota panel, and at 95% Auto Handoff moving work's session to the next account\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/demo.gif\" width=\"1280\">\n\n<picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel-dark.png\">\n <source media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel.png\">\n <img alt=\"sideby panel: every account's 5h and 7d quota, 7-day token usage and health in one page\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel.png\" width=\"1280\">\n</picture>\n\nOn macOS, the same quota sits in the menu bar (`sideby menubar on`): click or press `⌥X` to open it, and click an account to start it in the terminal.\n\n<picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar-dark.png\">\n <source media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar.png\">\n <img alt=\"sideby macOS menu bar dropdown: a status card, each tool with 5-hour and weekly quota bars, reset times, and the suggested account marked\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar.png\" width=\"468\">\n</picture>\n\n## Why not just an alias?\n\n`CLAUDE_CONFIG_DIR` plus a shell alias already starts a second account. It does not keep skills and settings in one place, and it does not show quota for every account. [Does this break a provider's terms?](docs/guide/faq.md#terms)\n\n| | At the same time | Skills, hooks, settings | Quota and usage | Setup |\n|---|---|---|---|---|\n| `CLAUDE_CONFIG_DIR` and an alias | Yes. Each terminal exports the variable. | Each directory is its own copy. They drift unless you symlink by hand. | That session's status line | One alias per account |\n| [cc-switch](https://github.com/farion1231/cc-switch) | Enabling a provider writes the host's live config, so open sessions share that switch. | Plugin settings are copied across providers as a separate step. | The active provider, from its quota endpoint | Install the desktop app |\n| sideby | Yes. `sideby run` selects the directory for that process and leaves your shell alone. | Linked to the main account. `sideby doctor --fix` repairs copies. Sign-in and sessions stay separate. | Every account, from local files. Claude needs `quota setup`. | `npm i -g sideby`, then `sideby new` and sign in |\n\ncc-switch's docs describe that switch: it writes the live settings file ([README](https://github.com/farion1231/cc-switch#readme)). [#1105](https://github.com/farion1231/cc-switch/issues/1105) and [#2908](https://github.com/farion1231/cc-switch/issues/2908) ask for several sessions at once. [#1106](https://github.com/farion1231/cc-switch/issues/1106) is closed; the maintainer says Claude Code's \"open terminal\" can start one provider without changing the global config.\n\n## What else it does\n\n| You want to | Run | Guide |\n|---|---|---|\n| Find any past session of any account by what you remember, grouped by project, read it and continue it where it was | **Sessions › History** in the panel, or `sideby history \"fix login\" --project .` | [History](docs/guide/panel.md#history) |\n| See what every account is running right now and copy one session for another AI | **Sessions › Running** in the panel, or `sideby sessions` | [Sessions](docs/guide/panel.md#sessions) |\n| Send a running session a message, screenshots included | **Send to it** on a running session, or `sideby send claude:work \"run the tests\"` | [Send to a session](docs/guide/panel.md#send-to-a-session) |\n| Hand a task to your own AI from the panel: set up an account, fix a problem, support a new tool | **Let AI do it** in the panel, or `sideby ask` | [Let AI do it](docs/guide/panel.md#let-ai-do-it) |\n| See quota at a glance in the macOS menu bar | **Settings › Startup** in the panel, or `sideby menubar on` | [Quota in the menu bar](docs/guide/usage.md#quota-in-the-menu-bar) |\n| Have the panel ready in the background whenever you log in | **Settings › Startup** in the panel, or `sideby autostart on` | [Start at login](docs/guide/usage.md#start-at-login) |\n| Add an API key account (DeepSeek, a gateway, …) | `sideby new claude deepseek --api` | [API accounts](docs/guide/usage.md#api-accounts) |\n| Find and fix config drift between accounts | `sideby doctor --fix` | [Doctor](docs/guide/usage.md#doctor) |\n| See Claude quota (Codex needs no setup) | `sideby quota setup claude --yes` | [Claude quota](docs/guide/usage.md#claude-quota) |\n| Find the cheapest auto-compact size from your own sessions, and use it in one click | `sideby tune` (or the panel's Context tuning tab) | [Context tuning](docs/guide/usage.md#context-tuning) |\n| See each account's model and effort, and set them per account | `sideby model <account>` (or click the model in the panel) | [Model and effort](docs/guide/usage.md#model-and-effort) |\n| Stop Claude and Codex when your requests would leave from a country you did not allow, for example when the proxy stopped | **Settings › Network check** in the panel, or `sideby network on` | [Network check](docs/guide/usage.md#network-check) |\n| Choose whether Claude sessions connect to claude.ai by themselves (Remote Control), for every account at once | `sideby remote-control off` or `on` (or the panel's Settings) | [Remote Control](docs/guide/usage.md#remote-control) |\n| Pin the accounts you use most, put tools and accounts in your own order, and hide the ones you never use | `sideby pin claude:work`, `sideby order`, `sideby hide grok` (or the panel's Settings) | [Your own order](docs/guide/usage.md#your-own-order) |\n| Give the panel other colors: five built-in Themes, your own color, or one your AI writes | **Settings › Theme** in the panel, or `sideby theme use leaf` | [Themes](docs/guide/panel.md#themes) |\n| Move on when an account hits its limit | `sideby next claude` | [Handoff](docs/guide/usage.md#when-an-account-hits-its-limit) |\n| Let a running task move to the next account by itself when quota runs low (off by default; see the risk) | `sideby handoff enable` (or the panel) | [Auto Handoff](docs/guide/usage.md#auto-handoff) |\n| Short commands such as `ccw` | `sideby alias add ccw claude:work` | [Shell functions](docs/guide/configuration.md#shell-functions) |\n| Reopen a session from Orca and the like in the account that holds it | `\"resumeRouting\": true` in config | [Resuming from other tools](docs/guide/configuration.md#resuming-from-other-tools) |\n| Open Claude Desktop or the Codex app as one account, several side by side (macOS) | `sideby desktop claude:work` (or the panel) | [Desktop apps](docs/guide/usage.md#desktop-apps) |\n| Keep several Grok Bot windows open, each signed in to its own account (macOS) | `sideby desktop grok-bot:002` (or the panel) | [Grok Bot windows](docs/guide/usage.md#grok-bot-windows) |\n| Open the panel from the Dock or app menu | `sideby app install` | [Panel app](docs/guide/panel.md#panel-app) |\n| Show the panel inside your own local page | `createPanelHandler()` | [Embed the panel](docs/guide/panel.md#embed-the-panel) |\n| Add a Host, a pre-launch check, or your own project categories for History | a local plugin | [Plugins](docs/guide/plugins.md) |\n\n## Supported hosts\n\n| Host | Account directories | Sign-in | Quota | Usage (7 days) |\n|---|---|---|---|---|\n| Claude Code | `~/.claude`, `~/.claude-<name>` | `claude auth login` | ✓ after `quota setup claude` | ✓ |\n| Codex CLI | `~/.codex`, `~/.codex-<name>` | `codex login` | ✓ | ✓ |\n| Grok Build | `~/.grok`, `~/.grok-<name>` | `grok login` | weekly, asked from the `grok` CLI | no public source |\n| pi | `~/.pi/agent`, `~/.pi-<name>/agent` | `/login` inside pi | no public source | no public source |\n| Antigravity CLI | `~/.gemini/antigravity-cli` (main account only) | sign in with Google inside `agy` | 5-hour and weekly per model group, asked from the `agy` CLI | no public source |\n\nsideby starts the official binary on your `PATH` and never patches it. Tested versions and per-Host notes are in the [guide](docs/guide/usage.md#host-notes).\n\n## Platforms\n\nmacOS and Linux. CI runs the suite on `ubuntu-latest` and `macos-latest`, Node 22 and 24. **Windows is untested.** `sideby app` only installs a launcher on macOS and Linux. Linked items are symlinks, `sideby shell-init` prints bash and zsh functions, and the Claude quota wrapper runs `/bin/sh`.\n\n## Roadmap\n\n**Gemini CLI.** Gemini can point at another config directory with `GEMINI_CONFIG_DIR`. Older docs use `GEMINI_CLI_HOME`; current builds treat that name as deprecated, and exit on startup if it is set together with an exact directory override. A sideby family still needs a tested Gemini version, a login check that does not read tokens, and a list of which files to link or copy. That is more than a small patch, so it is not in this version.\n\n## Safe by design\n\n- It never edits a Host's global config to switch accounts. It moves a task to another account only when you turn on Auto Handoff, and never proxies requests or pools logins.\n- It never reads, prints or sends a credential value. Nothing about your accounts leaves your machine: the only request sideby makes on its own is a daily check of the npm registry for its newest version (off with `NO_UPDATE_NOTIFIER=1`; see [Updates](docs/guide/configuration.md#updates)).\n- `doctor --fix` never replaces a real file and never changes where a link points.\n- The panel answers only on `127.0.0.1` and refuses web pages from other sites, but it trusts every user of this computer. On a shared Mac, do not leave it running in the background ([details](docs/guide/panel.md#who-can-reach-the-panel)).\n\nDetails and the terms-of-service question are in the [FAQ](docs/guide/faq.md).\n\nUsage questions and ideas go in [Discussions](https://github.com/Adonis0123/sideby/discussions).\n\n## Docs\n\n- [Using sideby](docs/guide/usage.md): accounts, API accounts, Doctor, quota, Handoff, Host notes\n- [Commands](docs/guide/commands.md): every command, exit codes and `--json`\n- [Configuration](docs/guide/configuration.md): `config.json`, aliases, shell functions\n- [Panel](docs/guide/panel.md): the panel, sessions and their history, panel app and embedding\n- [Plugins](docs/guide/plugins.md): write your own Family, launch hook or project categories\n- [FAQ](docs/guide/faq.md): terms of service, data locations, alternatives, uninstall\n- [Changelog](https://github.com/Adonis0123/sideby/releases)\n\n## For AI agents\n\n- [`llms.txt`](llms.txt): setup steps, commands, JSON contract and plugin API in one index. `sideby families --json` states what each Host's accounts share.\n- [`skills/sideby/SKILL.md`](skills/sideby/SKILL.md): one Agent Skill for seeing, repairing and creating accounts and for moving on when one hits its limit. Install with `npx skills add Adonis0123/sideby -g`; `sideby doctor` warns when the installed copy is for another sideby version.\n- [`AGENTS.md`](AGENTS.md): rules for agents working on this repository.\n\n## License\n\n[MIT](LICENSE)\n"
88
+ "readme": "<p align=\"center\">\n <img alt=\"sideby: work, personal and API-key accounts, one terminal each, one shared config\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/banner.jpg\" width=\"880\">\n</p>\n\n<p align=\"center\">\n <b>Run work, personal and API-key accounts at the same time, without their configs drifting apart.</b><br>\n Each account is its own directory and its own terminal. Skills, hooks and settings stay linked to your main account. Claude Code, Codex, Grok Build and pi.\n</p>\n\n<p align=\"center\">\n <a href=\"https://www.npmjs.com/package/sideby\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/sideby\"></a>\n <a href=\"https://github.com/Adonis0123/sideby/actions/workflows/ci.yml\"><img alt=\"CI\" src=\"https://github.com/Adonis0123/sideby/actions/workflows/ci.yml/badge.svg\"></a>\n <img alt=\"Node 22.18+\" src=\"https://img.shields.io/badge/node-%E2%89%A522.18-339933\">\n <a href=\"LICENSE\"><img alt=\"MIT\" src=\"https://img.shields.io/badge/license-MIT-blue\"></a>\n</p>\n\n<p align=\"center\">English | <a href=\"README.zh-CN.md\">中文</a></p>\n\n## Quick start\n\nRequires Node 22.18+ and at least one Host CLI (Claude Code, Codex, Grok Build or pi) installed. AI agents: follow the setup steps in [`llms.txt`](llms.txt) (\"Set up sideby for a user\") instead.\n\n```sh\nnpm i -g sideby\nsideby new claude work # create ~/.claude-work, sharing ~/.claude's skills and hooks\nsideby login claude:work # sign in once\nsideby run work # Claude Code on the work account\nsideby quota setup claude --yes # optional: live Claude quota while a session runs; undo: sideby quota teardown claude\nsideby ui --background # every account's quota at http://127.0.0.1:17420, still there after you close the terminal\n```\n\n`sideby app install` adds a Dock icon that opens the panel, and `sideby autostart on` has it ready each time you log in. `sideby update` installs a newer sideby when there is one; sideby says so after a command and in the panel. `sideby run claude:main` keeps using `~/.claude` in another terminal at the same time. Arguments after `--` go to the Host: `sideby run work -- --resume`. To try it without installing, run `npx sideby`.\n\n## Set up with your AI agent\n\nPaste this into Claude Code, Codex or any coding agent:\n\n```text\nInstall the sideby CLI (npm package `sideby`) and its agent skill, then set up a second Claude Code account for me.\nFollow \"Set up sideby for a user\" in https://raw.githubusercontent.com/Adonis0123/sideby/main/llms.txt\n```\n\nThe agent checks Node and your Host CLIs, installs sideby and the skill, creates the account, tells you what it shares with your main one and makes its short command work. You sign in once in your browser; the agent gives you that one command. Once the skill is installed, short requests work too: \"add another Claude account, cc008\", \"what do my Codex accounts share?\", \"which account still has quota?\".\n\n## What it looks like\n\nThe 25-second story: one account buried in tasks, then accounts side by side sharing one setup, and a task moving on when one runs out.\n\nhttps://github.com/user-attachments/assets/d1d7e8dd-1df1-4881-ac88-e468c2dd4a1d\n\n<img alt=\"Two terminals: the personal account and the work account running at the same time, both linked to the main account's skills and settings, then the local quota panel, and at 95% Auto Handoff moving work's session to the next account\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/demo.gif\" width=\"1280\">\n\n<picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel-dark.png\">\n <source media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel.png\">\n <img alt=\"sideby panel: every account's 5h and 7d quota, 7-day token usage and health in one page\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel.png\" width=\"1280\">\n</picture>\n\nOn macOS, the same quota sits in the menu bar (`sideby menubar on`): click or press `⌥X` to open it, and click an account to start it in the terminal.\n\n<picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar-dark.png\">\n <source media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar.png\">\n <img alt=\"sideby macOS menu bar dropdown: a status card, each tool with 5-hour and weekly quota bars, reset times, and the suggested account marked\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar.png\" width=\"468\">\n</picture>\n\n## Why not just an alias?\n\n`CLAUDE_CONFIG_DIR` plus a shell alias already starts a second account. It does not keep skills and settings in one place, and it does not show quota for every account. [Does this break a provider's terms?](docs/guide/faq.md#terms)\n\n| | At the same time | Skills, hooks, settings | Quota and usage | Setup |\n|---|---|---|---|---|\n| `CLAUDE_CONFIG_DIR` and an alias | Yes. Each terminal exports the variable. | Each directory is its own copy. They drift unless you symlink by hand. | That session's status line | One alias per account |\n| [cc-switch](https://github.com/farion1231/cc-switch) | Enabling a provider writes the host's live config, so open sessions share that switch. | Plugin settings are copied across providers as a separate step. | The active provider, from its quota endpoint | Install the desktop app |\n| sideby | Yes. `sideby run` selects the directory for that process and leaves your shell alone. | Linked to the main account. `sideby doctor --fix` repairs copies. Sign-in and sessions stay separate. | Every account, from local files and each tool's own CLI. | `npm i -g sideby`, then `sideby new` and sign in |\n\ncc-switch's docs describe that switch: it writes the live settings file ([README](https://github.com/farion1231/cc-switch#readme)). [#1105](https://github.com/farion1231/cc-switch/issues/1105) and [#2908](https://github.com/farion1231/cc-switch/issues/2908) ask for several sessions at once. [#1106](https://github.com/farion1231/cc-switch/issues/1106) is closed; the maintainer says Claude Code's \"open terminal\" can start one provider without changing the global config.\n\n## What else it does\n\n| You want to | Run | Guide |\n|---|---|---|\n| Find any past session of any account by what you remember, grouped by project, read it and continue it where it was | **Sessions › History** in the panel, or `sideby history \"fix login\" --project .` | [History](docs/guide/panel.md#history) |\n| See what every account is running right now and copy one session for another AI | **Sessions › Running** in the panel, or `sideby sessions` | [Sessions](docs/guide/panel.md#sessions) |\n| Send a running session a message, screenshots included | **Send to it** on a running session, or `sideby send claude:work \"run the tests\"` | [Send to a session](docs/guide/panel.md#send-to-a-session) |\n| Hand a task to your own AI from the panel: set up an account, fix a problem, support a new tool | **Let AI do it** in the panel, or `sideby ask` | [Let AI do it](docs/guide/panel.md#let-ai-do-it) |\n| See quota at a glance in the macOS menu bar | **Settings › Startup** in the panel, or `sideby menubar on` | [Quota in the menu bar](docs/guide/usage.md#quota-in-the-menu-bar) |\n| Have the panel ready in the background whenever you log in | **Settings › Startup** in the panel, or `sideby autostart on` | [Start at login](docs/guide/usage.md#start-at-login) |\n| Add an API key account (DeepSeek, a gateway, …) | `sideby new claude deepseek --api` | [API accounts](docs/guide/usage.md#api-accounts) |\n| Find and fix config drift between accounts | `sideby doctor --fix` | [Doctor](docs/guide/usage.md#doctor) |\n| See every account's quota (no setup) | `sideby quota` | [Claude quota](docs/guide/usage.md#claude-quota) |\n| Find the cheapest auto-compact size from your own sessions, and use it in one click | `sideby tune` (or the panel's Context tuning tab) | [Context tuning](docs/guide/usage.md#context-tuning) |\n| See each account's model and effort, and set them per account | `sideby model <account>` (or click the model in the panel) | [Model and effort](docs/guide/usage.md#model-and-effort) |\n| Stop Claude and Codex when your requests would leave from a country you did not allow, for example when the proxy stopped | **Settings › Network check** in the panel, or `sideby network on` | [Network check](docs/guide/usage.md#network-check) |\n| Choose whether Claude sessions connect to claude.ai by themselves (Remote Control), for every account at once | `sideby remote-control off` or `on` (or the panel's Settings) | [Remote Control](docs/guide/usage.md#remote-control) |\n| Pin the accounts you use most, put tools and accounts in your own order, and hide the ones you never use | `sideby pin claude:work`, `sideby order`, `sideby hide grok` (or the panel's Settings) | [Your own order](docs/guide/usage.md#your-own-order) |\n| Give the panel other colors: five built-in Themes, your own color, or one your AI writes | **Settings › Theme** in the panel, or `sideby theme use leaf` | [Themes](docs/guide/panel.md#themes) |\n| Move on when an account hits its limit | `sideby next claude` | [Handoff](docs/guide/usage.md#when-an-account-hits-its-limit) |\n| Let a running task move to the next account by itself when quota runs low (off by default; see the risk) | `sideby handoff enable` (or the panel) | [Auto Handoff](docs/guide/usage.md#auto-handoff) |\n| Short commands such as `ccw` | `sideby alias add ccw claude:work` | [Shell functions](docs/guide/configuration.md#shell-functions) |\n| Reopen a session from Orca and the like in the account that holds it | `\"resumeRouting\": true` in config | [Resuming from other tools](docs/guide/configuration.md#resuming-from-other-tools) |\n| Open Claude Desktop or the Codex app as one account, several side by side (macOS) | `sideby desktop claude:work` (or the panel) | [Desktop apps](docs/guide/usage.md#desktop-apps) |\n| Keep several Grok Bot windows open, each signed in to its own account (macOS) | `sideby desktop grok-bot:002` (or the panel) | [Grok Bot windows](docs/guide/usage.md#grok-bot-windows) |\n| Open the panel from the Dock or app menu | `sideby app install` | [Panel app](docs/guide/panel.md#panel-app) |\n| Show the panel inside your own local page | `createPanelHandler()` | [Embed the panel](docs/guide/panel.md#embed-the-panel) |\n| Add a Host, a pre-launch check, or your own project categories for History | a local plugin | [Plugins](docs/guide/plugins.md) |\n\n## Supported hosts\n\n| Host | Account directories | Sign-in | Quota | Usage (7 days) |\n|---|---|---|---|---|\n| Claude Code | `~/.claude`, `~/.claude-<name>` | `claude auth login` | ✓ | ✓ |\n| Codex CLI | `~/.codex`, `~/.codex-<name>` | `codex login` | ✓ | ✓ |\n| Grok Build | `~/.grok`, `~/.grok-<name>` | `grok login` | weekly, asked from the `grok` CLI | no public source |\n| pi | `~/.pi/agent`, `~/.pi-<name>/agent` | `/login` inside pi | no public source | no public source |\n| Antigravity CLI | `~/.gemini/antigravity-cli` (main account only) | sign in with Google inside `agy` | 5-hour and weekly per model group, asked from the `agy` CLI | no public source |\n\nsideby starts the official binary on your `PATH` and never patches it. Tested versions and per-Host notes are in the [guide](docs/guide/usage.md#host-notes).\n\n## Platforms\n\nmacOS and Linux. CI runs the suite on `ubuntu-latest` and `macos-latest`, Node 22 and 24. **Windows is untested.** `sideby app` only installs a launcher on macOS and Linux. Linked items are symlinks, `sideby shell-init` prints bash and zsh functions, and the Claude quota wrapper runs `/bin/sh`.\n\n## Roadmap\n\n**Gemini CLI.** Gemini can point at another config directory with `GEMINI_CONFIG_DIR`. Older docs use `GEMINI_CLI_HOME`; current builds treat that name as deprecated, and exit on startup if it is set together with an exact directory override. A sideby family still needs a tested Gemini version, a login check that does not read tokens, and a list of which files to link or copy. That is more than a small patch, so it is not in this version.\n\n## Safe by design\n\n- It never edits a Host's global config to switch accounts. It moves a task to another account only when you turn on Auto Handoff, and never proxies requests or pools logins.\n- It never reads, prints or sends a credential value. Nothing about your accounts leaves your machine: the only request sideby makes on its own is a daily check of the npm registry for its newest version (off with `NO_UPDATE_NOTIFIER=1`; see [Updates](docs/guide/configuration.md#updates)).\n- `doctor --fix` never replaces a real file and never changes where a link points.\n- The panel answers only on `127.0.0.1` and refuses web pages from other sites, but it trusts every user of this computer. On a shared Mac, do not leave it running in the background ([details](docs/guide/panel.md#who-can-reach-the-panel)).\n\nDetails and the terms-of-service question are in the [FAQ](docs/guide/faq.md).\n\nUsage questions and ideas go in [Discussions](https://github.com/Adonis0123/sideby/discussions).\n\n## Docs\n\n- [Using sideby](docs/guide/usage.md): accounts, API accounts, Doctor, quota, Handoff, Host notes\n- [Commands](docs/guide/commands.md): every command, exit codes and `--json`\n- [Configuration](docs/guide/configuration.md): `config.json`, aliases, shell functions\n- [Panel](docs/guide/panel.md): the panel, sessions and their history, panel app and embedding\n- [Plugins](docs/guide/plugins.md): write your own Family, launch hook or project categories\n- [FAQ](docs/guide/faq.md): terms of service, data locations, alternatives, uninstall\n- [Changelog](https://github.com/Adonis0123/sideby/releases)\n\n## For AI agents\n\n- [`llms.txt`](llms.txt): setup steps, commands, JSON contract and plugin API in one index. `sideby families --json` states what each Host's accounts share.\n- [`skills/sideby/SKILL.md`](skills/sideby/SKILL.md): one Agent Skill for seeing, repairing and creating accounts and for moving on when one hits its limit. Install with `npx skills add Adonis0123/sideby -g`; `sideby doctor` warns when the installed copy is for another sideby version.\n- [`AGENTS.md`](AGENTS.md): rules for agents working on this repository.\n\n## License\n\n[MIT](LICENSE)\n"
89
89
  }
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "title": {
24
24
  "type": "string",
25
- "description": "The words next to the icon, such as `Codex 62%`, once the tightest tool reaches 60%; empty otherwise."
25
+ "description": "The words next to the icon, such as `Codex 62%`, once the tightest tool reaches its warning level (60% of a 5-hour window, 85% of a longer one); empty otherwise."
26
26
  },
27
27
  "level": {
28
28
  "anyOf": [
@@ -563,7 +563,7 @@
563
563
  },
564
564
  "reset": {
565
565
  "type": "string",
566
- "description": "Until the fullest window resets, such as `4d 17h`; empty when nothing is used."
566
+ "description": "Which window resets and how long until it does, such as `7d · in 4d 17h`: the window closest to its own red level (85% for 5 hours, 95% for longer windows). Empty when nothing is used."
567
567
  },
568
568
  "note": {
569
569
  "type": "string",
@@ -891,7 +891,7 @@
891
891
  },
892
892
  "reset": {
893
893
  "type": "string",
894
- "description": "Until the fullest window resets, such as `4d 17h`; empty when nothing is used."
894
+ "description": "Which window resets and how long until it does, such as `7d · in 4d 17h`: the window closest to its own red level (85% for 5 hours, 95% for longer windows). Empty when nothing is used."
895
895
  },
896
896
  "note": {
897
897
  "type": "string",
package/schemas/next.json CHANGED
@@ -40,7 +40,8 @@
40
40
  "ref",
41
41
  "kind",
42
42
  "state",
43
- "pressure"
43
+ "pressure",
44
+ "limitUse"
44
45
  ],
45
46
  "properties": {
46
47
  "ref": {
@@ -81,7 +82,7 @@
81
82
  "const": "logged-out"
82
83
  }
83
84
  ],
84
- "description": "ready and unknown can be picked; api only with --include-api; full and logged-out never."
85
+ "description": "ready and unknown can be picked; api only with --include-api; logged-out never. full (a window at or past its own Takeover Limit: 5-hour windows the handoff threshold - 10, windows longer than a day the threshold) only as a Last Resort: when no subscription account is ready or unknown, the one with the lowest limitUse and no window used up, and `tight` is set."
85
86
  },
86
87
  "pressure": {
87
88
  "anyOf": [
@@ -94,9 +95,43 @@
94
95
  ],
95
96
  "description": "Used percent of the fullest window not reset yet; null without quota."
96
97
  },
98
+ "limitUse": {
99
+ "anyOf": [
100
+ {
101
+ "type": "number"
102
+ },
103
+ {
104
+ "type": "null"
105
+ }
106
+ ],
107
+ "description": "Limit Use: the percent of its own Takeover Limit that the closest window has used (a weekly 87% under 95 is 91.6); null without quota. Ready accounts rank by it, lowest first."
108
+ },
109
+ "window": {
110
+ "type": "object",
111
+ "required": [
112
+ "label",
113
+ "usedPercent",
114
+ "limit"
115
+ ],
116
+ "properties": {
117
+ "label": {
118
+ "type": "string",
119
+ "description": "Such as `5h` or `7d`."
120
+ },
121
+ "usedPercent": {
122
+ "type": "number",
123
+ "description": "Rounded."
124
+ },
125
+ "limit": {
126
+ "type": "number",
127
+ "description": "This window's Takeover Limit in percent."
128
+ }
129
+ },
130
+ "description": "The window closest to its own Takeover Limit; absent when none is open."
131
+ },
97
132
  "resetsAt": {
98
133
  "type": "string",
99
- "description": "For full: when its last full window resets."
134
+ "description": "For full: when it is usable again. With a window used up, when those windows reset; otherwise when every window is under its Takeover Limit again."
100
135
  },
101
136
  "observedAt": {
102
137
  "type": "string",
@@ -118,6 +153,24 @@
118
153
  "type": "boolean",
119
154
  "description": "False when no account has quota data: the pick is then a guess, and `sideby next` does not start it (exit 1)."
120
155
  },
156
+ "tight": {
157
+ "type": "object",
158
+ "required": [
159
+ "limit",
160
+ "longLimit"
161
+ ],
162
+ "properties": {
163
+ "limit": {
164
+ "type": "number",
165
+ "description": "The Takeover Limit of 5-hour windows in percent (handoff threshold - 10)."
166
+ },
167
+ "longLimit": {
168
+ "type": "number",
169
+ "description": "The Takeover Limit of windows longer than a day in percent (the handoff threshold)."
170
+ }
171
+ },
172
+ "description": "Set when the pick is a Last Resort: every subscription account has a window at or past its Takeover Limit, and the pick is the one with the lowest limitUse and no window used up."
173
+ },
121
174
  "earliestReset": {
122
175
  "type": "object",
123
176
  "required": [
@@ -132,7 +185,7 @@
132
185
  "type": "string"
133
186
  }
134
187
  },
135
- "description": "Set when nothing can be picked and some accounts are full: the first to come back."
188
+ "description": "Set when nothing can be picked and some accounts are full (every one has a window used up): the first to come back."
136
189
  },
137
190
  "_notice": {
138
191
  "type": "object",
@@ -2,7 +2,7 @@
2
2
  name: sideby
3
3
  description: Use when the user runs, or wants to run, several AI coding accounts (Claude Code, Codex, Grok Build, pi) side by side. Covers installing sideby and setting up a new account ("install sideby", "set up another Claude account", "add cc008", "配置一个 cc00x", "再加一个 Codex 账号"), explaining what accounts share and what stays separate ("what do my accounts share?", "这些账号共享了什么"), showing which account a session is ("show [cc001] in the status line", "加上账号标识"), finding a past session of any account ("找一下我上周改登录页的那个会话"), telling another running session something, in any account ("告诉 cc002 ……", "给跑构建的那个会话发消息"; Claude Code's own SendMessage reaches only sessions of the same account), seeing accounts, quota and usage, moving on when one hits its 5-hour or weekly limit, moving the current task to another account ("用 cc008 继续", "交回 cc008"), adding a short command (alias) or a pick command that starts whichever account has the most quota ("加个 cc"), adding an API account from a vendor's docs ("加一个 DeepSeek API 账号"), supporting a new tool, and repairing drifted account directories (skills, hooks, rules or settings not shared, wrong symlinks, credential file permissions). Drives the `sideby` CLI with `--json`; the agent does every step except browser sign-in, filling in secrets and starting interactive sessions, which it hands to the user as one command (inside an Auto Handoff session, `sideby handoff ready --to` moves the task itself).
4
4
  metadata:
5
- version: "0.31.3"
5
+ version: "0.32.1"
6
6
  requires:
7
7
  bins: [sideby, node]
8
8
  cliHelp: sideby --help
@@ -76,7 +76,7 @@ Account refs are `<family>:<name>`; a bare `<name>` works only when it is unique
76
76
  | Stop Claude sessions from connecting to claude.ai / the Claude app by themselves ("关闭 remote control", "别让别人远程看到对话") for every account | `sideby remote-control --json`, then `sideby remote-control off` (exits 10 with the change; rerun with `--yes` after they agree); `sideby remote-control undo` puts it back; `sideby remote-control on` turns it back on the same way (only when they ask for it) | — |
77
77
  | Stop Claude and Codex when the network is wrong ("网络不对时别让 Claude 用", "代理断了就拦住", "only allow US and Japan", "开网络检查"), see where requests leave from now, or a session says it was blocked | `sideby network --json`, `sideby network check --json`, `sideby network allow <CC>... --json` and `sideby network on --json` (each exits 10 first; rerun with `--yes` after they agree) | `references/network.md` |
78
78
  | Leave sessions running with nobody there ("挂机", "无人值守", "今晚自己跑完", "设个时间段别问我", "keep going while I sleep"), set a nightly Schedule, or see what was left for the user | `sideby unattended on [--until 08:00] --json` (run it yourself when they say they are leaving), `sideby unattended schedule preset weeknights --json`, `sideby unattended --json`, `sideby unattended pending --json`; inside a session refused a question: `sideby unattended defer "<one sentence>"` | `references/unattended.md` |
79
- | See Claude quota (it shows `not-enabled`) | `sideby quota setup claude` (exits 10) | `references/quota.md` |
79
+ | See Claude quota, refresh it, or turn on live quota for Auto Handoff | `sideby quota claude --refresh --json` (no setup); `sideby quota setup claude` (exits 10) for Auto Handoff | `references/quota.md` |
80
80
  | Update sideby or its skill ("is there a new version", "更新 sideby"), or an output has `_notice` | `sideby update --json` (exits 10 first) | `references/update.md` |
81
81
  | See everything at once | `sideby ui` (local panel on `127.0.0.1:17420`; `--no-open` prints the address) | — |
82
82
  | Start an account | give them `sideby run <ref> [-- host args]` | — |
@@ -44,7 +44,7 @@ To start one account with fixed Host arguments, such as another model, put them
44
44
 
45
45
  ## Pick commands (start the account with the most room)
46
46
 
47
- A pick command is a short command bound to a tool (Family), not to one account: each run starts the account of that tool `sideby next` would pick, the one with the lowest Quota Pressure, and prints which (`cc → claude:work (12% used, the most room)`). When no account of the tool has quota data yet it starts the main account and says so; when every account is full or signed out it starts nothing and says which comes back first. API accounts are never picked.
47
+ A pick command is a short command bound to a tool (Family), not to one account: each run starts the account of that tool `sideby next` would pick, the one furthest from its limits, and prints which (`cc → claude:work (5h 12% used, the most room)`). When no account of the tool has quota data yet it starts the main account and says so. When every account is past its Takeover Limit (by default 85% of a 5-hour window, 95% of a weekly one) it still starts the one with the most left under 100% and says so (`cc → claude:008 (every claude account is past its limit, 85% of a 5-hour window or 95% of a weekly one; this one has the most left, 5h 88% used)`); only when every account has a window used up or is signed out does it start nothing and say which comes back first. API accounts are never picked.
48
48
 
49
49
  - Add: `sideby alias add <short> --pick <family> --json` exits 10 with `status: "confirm"` and writes nothing; tell the user what it adds, then run it again with `--yes`. Then make sure new terminals load it: `sideby shell-init setup --json` (see `setup.md` step 7). Offer `cc` for Claude, `cx` for Codex, `gk` for Grok, or the letters the user's numbered short commands share (`cc001`, `cc008` → `cc`); pi gets none, since `pi` is the tool itself. `sideby new` offers one (`pickCommandOffer`) when a tool gets its second subscription account.
50
50
  - With `shadows` in that answer, the name hides a command on PATH (for example `/usr/bin/cc`, the C compiler on macOS). Tell the user that typing the name would start the tool instead, and run again with `--yes` only after they agree to that, or pick another name.
@@ -42,7 +42,7 @@ The prompt lists the Findings (`code`, account, message). Run `sideby doctor <re
42
42
 
43
43
  ## quota: an account shows no quota or an error
44
44
 
45
- The prompt names the account and the reason. Run `sideby quota <ref> --json` and relay what it says. Common answers: Claude needs `sideby quota setup claude` (exit 10 first); a signed-out account needs the user to sign in; Grok's quota check may be off (`sideby quota check grok on`); pi and API accounts have no public quota source, which is not an error.
45
+ The prompt names the account and the reason. Run `sideby quota <ref> --json` and relay what it says. Common answers: Claude's or Grok's quota check may be off (`sideby quota check claude on`, `sideby quota check grok on`) or failed (relay `detail`); a signed-out account needs the user to sign in; pi and API accounts have no public quota source, which is not an error.
46
46
 
47
47
  ## account: add an account
48
48
 
@@ -113,7 +113,7 @@ The prompt gives Auto Handoff as it is now, in the words of `sideby handoff stat
113
113
 
114
114
  1. Run `sideby handoff status --json` and `sideby quota --json` to see the facts as they are now.
115
115
  2. Recommend, with a reason the user can follow: a `threshold` (the quota percentage at which a session hands over; leave room before 100 so the session can finish its turn) and a `prepareAt` below it; an order per Family (`pressure`, the least used first, or a fixed `order` of accounts); and whether `sameFamily` should be on. Accounts signed in as the same login share one quota and never hand over to each other.
116
- 3. Put accounts without quota data last, and tell the user how to make them show it (`sideby quota setup claude`, signing in, `sideby quota check grok on`).
116
+ 3. Put accounts without quota data last, and tell the user how to make them show it (signing in, `sideby quota check <family> on`). For Auto Handoff from Claude, also `sideby quota setup claude` (exit 10 first), which it reads during a session.
117
117
  4. Change settings only with `sideby handoff enable [--same-family] [--order <family>=<acct,…>] [--threshold n] [--prepare-at n]` or `sideby config set handoff.<key> <value>`. Both show the change first and exit 10; add `--yes` only after the user agrees.
118
118
  5. Run `sideby handoff status --json` again and tell the user what is still missing (`nextSteps`).
119
119
 
@@ -27,7 +27,7 @@ Shared Items the Main Account does not have are skipped: no Finding, not counted
27
27
  | name looks like a backup (`bak`, `backup`, `old`, `tmp`) | A stray directory was picked up as an account | Suggest adding its ref to `ignore` in `${XDG_CONFIG_HOME:-~/.config}/sideby/config.json` |
28
28
  | `login: "not-needed"` (`key` in `sideby list`) | API account; it authenticates with `proxy.env` | Nothing to do |
29
29
  | `problems` on an account in `list --json` | A plugin failed while reading it (for example a settings file that is not valid JSON) | Show the message; the account itself still works |
30
- | quota `unavailable` / `not-enabled` | Claude quota source is off | Offer `sideby quota setup claude` |
30
+ | quota `unavailable` / `not-enabled` | Quota checks for that tool are off (config `quota.check.<family>: false`) or it runs in CI | Offer `sideby quota check <family> on` |
31
31
  | quota `unavailable` / `no-session` | No session since the source was enabled | Ask the user to start one session with that account |
32
32
  | quota `unavailable` / `no-source` | pi: the Host has no public source | Nothing to fix |
33
33
  | quota `unavailable` / `fetch-failed` | Grok: its CLI could not get the quota | Follow `detail` (update Grok, `sideby login grok:<name>`), then `sideby quota grok --refresh` |
@@ -1,6 +1,6 @@
1
1
  # Handoff: keep working on another account
2
2
 
3
- Use this when the user says an account hit its 5-hour or weekly limit ("usage limit reached", "rate limited", "resets at …") and wants to keep working, or asks which account has room. sideby recommends the account of the same family with the lowest Quota Pressure (the fullest window that has not reset yet), and the user starts it. Only Auto Handoff, which the user turns on in the config, moves a running task by itself (see below).
3
+ Use this when the user says an account hit its 5-hour or weekly limit ("usage limit reached", "rate limited", "resets at …") and wants to keep working, or asks which account has room. sideby recommends the account of the same family that is furthest from its limits (lowest `limitUse`), and the user starts it. Only Auto Handoff, which the user turns on in the config, moves a running task by itself (see below).
4
4
 
5
5
  ## Steps
6
6
 
@@ -9,12 +9,16 @@ Use this when the user says an account hit its 5-hour or weekly limit ("usage li
9
9
 
10
10
  | `state` | Meaning | Can be picked |
11
11
  |---|---|---|
12
- | `ready` | Subscription account with room; `pressure` is its fullest live window in percent | Yes, lowest `pressure` first |
13
- | `unknown` | No quota data yet (no session since quota was turned on, or Claude quota is off) | Yes, after `ready` |
12
+ | `ready` | Subscription account with every live window under its own limit. `pressure` is its fullest live window in percent; `limitUse` is the percent of its own limit that its closest window has used, and `window` names that window (`label`, `usedPercent`, `limit`) | Yes, lowest `limitUse` first |
13
+ | `unknown` | No quota data yet (not asked yet, quota checks are off, or the ask failed) | Yes, after `ready` |
14
14
  | `api` | API account, pay per use | Only with `--include-api` |
15
- | `full` | A live window is more than 10 points below the Auto Handoff threshold (85% with the default 95%); `resetsAt` is when it is usable again | No |
15
+ | `full` | A live window is at or past its own Takeover Limit: a 5-hour window at the Auto Handoff threshold − 10 (85% by default), a weekly or longer window at the threshold (95% by default); `resetsAt` is when it is usable again | Only as a last resort, see below |
16
16
  | `logged-out` | Needs `sideby login <ref>` | No |
17
17
 
18
+ When no subscription account is `ready` or `unknown`, the pick is the `full` one with no window used up (`pressure` under 100%) and the lowest `limitUse`, ahead of API accounts, and the plan has `tight: { limit, longLimit }` (the 5-hour and the weekly limit). Tell the user every account is past its limit and the pick has the most left (for example "every claude account is past its limit; claude:008 has the most left, its 5-hour window at 88%"), so they know it may run out soon. Auto Handoff never does this.
19
+
20
+ The two limits differ because one full 5-hour window costs only about a fifth of a week: a week at 87% is still `ready` and yellow, not red. When the user asks why such an account was picked, say that.
21
+
18
22
  Each entry's `observedAt` says when its quota was recorded (`quotaFrom` when it was read from another account of the same login). An entry with `sameLoginAs` is signed in as the same login as the account you run in: it shares that quota and is never picked. If `hasQuota` is `false`, no account has quota data: the pick is only a guess, so say so and suggest turning quota on (see the routing table in SKILL.md) or letting the user choose.
19
23
  3. Give the user the command to run in their own terminal: `sideby next <family>` (starts the pick) or `sideby run <pick>`. Host arguments go after `--`. Do not run it yourself.
20
24
  4. Offer a handoff note: the new session starts empty, because each account keeps its own sessions. Write a short note the user can paste into it: the goal, what is done, what is in progress, the files involved, and the next step.
@@ -23,7 +27,7 @@ Use this when the user says an account hit its 5-hour or weekly limit ("usage li
23
27
 
24
28
  `pick` is `null` and the exit code is 1:
25
29
 
26
- - Every account `full`: tell the user `earliestReset.ref` comes back at `earliestReset.at`.
30
+ - Every signed-in account has a window used up (100%): tell the user `earliestReset.ref` comes back at `earliestReset.at`.
27
31
  - Accounts `logged-out`: the user can sign in with `sideby login <ref>`.
28
32
  - Only `api` left: ask whether they want to pay per use before suggesting `sideby next <family> --include-api`.
29
33
 
@@ -31,9 +35,9 @@ Use this when the user says an account hit its 5-hour or weekly limit ("usage li
31
35
 
32
36
  - Error `code: "no-quota-source"` (pi, or a plugin family without quota): the Host publishes no quota. The message lists the family's accounts; let the user choose one for `sideby run <ref>`.
33
37
  - Error `code: "no-accounts"`: the family has no account yet; see creating accounts.
34
- - Many `unknown` Claude accounts: Claude quota may be off. `sideby quota --json` shows `not-enabled`; the one-time setup turns it on.
38
+ - Many `unknown` Claude accounts: Claude quota checks may be off or failing. `sideby quota claude --json` shows `not-enabled` (turn them on with `sideby quota check claude on`) or `fetch-failed` with the next step in `detail`.
35
39
  - Host arguments the user wants (another model, say) go after `--`: `sideby next claude -- --model opus`.
36
- - Quota is only as fresh as each account's last session. Do not promise an account has room; say what the data shows and when it was recorded.
40
+ - Quota is only as fresh as its `observedAt`. Do not promise an account has room; say what the data shows and when it was recorded.
37
41
 
38
42
  ## Auto Handoff (the user turns it on)
39
43
 
@@ -42,7 +46,7 @@ With config `"handoff": { "auto": true }`, a session sideby started hands its ta
42
46
  - When sideby tells you the quota is at 80%, write the handoff brief at the path it names and keep it current (do not tell the user that another account will take over; sideby decides that and says so itself): the goal, what is done, the remaining steps, key decisions and why, the files that matter. Reference specs, ADRs, commits and diffs by path; list the skills the next agent should use; never include keys, passwords or personal data.
43
47
  - When it says a window is about to run out (the message names it, such as "weekly (7d) quota is at 98%"; each window hands over at its own pace, ADR-0032), finish the current step, update the brief, and end your turn. sideby starts the next account from it.
44
48
  - End the brief with the line `<!-- handoff brief complete -->` once it is complete. Without it sideby asks once more, then adds its own records under what you wrote.
45
- - When a user asks why a session handed over "with 95% left": the 5-hour and weekly windows are separate, and the fullest one decides. Run `sideby quota` and read both windows.
49
+ - When a user asks why a session handed over "with 95% left": the 5-hour and weekly windows are separate, and the fullest one decides when to hand over. Run `sideby quota` and read both windows. Which account takes over is judged per window: a 5-hour window stops it at 85%, a weekly one at 95% (with the default threshold).
46
50
  - When the user asks to hand over now, update the brief, run `sideby handoff ready` (add `--brief <file>` when the user's own handoff tool wrote one), and end your turn. Tell the user the account it prints, not what `sideby next` says: the chain goes back to an account it already used only once the quota window that account handed over for has reset, or, for an account handed over from by hand, once its own quota shows room (not while its quota is unknown). When the user names an account ("go back to cc008"), run `sideby handoff ready --to <account>`; it works for an account this chain already used. When the quota is about to run out and sideby says the session will wait for the reset, the user can move on at once by typing `! sideby handoff ready` in the session (the model cannot answer at the limit); the same works when the session hit its limit and no account could take over then, once one can. Tell them so if they ask why nothing moved.
47
51
 
48
52
  ### Turning it on for the user
@@ -74,6 +74,6 @@ To turn it on ("start sideby at login", "开机启动"), run `sideby autostart o
74
74
 
75
75
  `sideby menubar --json` returns the same fields as `autostart` (`supported`, `state`, `path`, `current`, `missing?`), plus `loaded` and `hotkey`, for the Menu Bar Item, the sideby icon in the macOS menu bar. To turn it on ("show my quota in the menu bar", "状态栏显示额度"), run `sideby menubar on --json`: exit 10 shows the file (`~/Library/LaunchAgents/dev.sideby.menubar.plist`, which runs the system's `osascript` with the whole menu script and this sideby). Tell the user it adds a login item that shows quota in the menu bar from now on, and run `sideby menubar on --yes --json` after they agree; `sideby menubar off --yes` removes it. The same refusals as `autostart` apply (`unsupported`, `foreign`, `npx-cache`, `temp-dir`, `unsafe-path`), and `sideby update` keeps it pointing at the new version.
76
76
 
77
- The icon stands alone while every tool has quota left. In each tool sideby takes how much the account `sideby next` would pick has used; when the highest of those reaches 60% (orange; red from 85%), the title shows that tool and percent, such as `Codex 61%`. The menu's first line (`headline`) names that account either way. `sideby menubar snapshot --json` prints what the menu shows (`title`, `level`, `headline`, `sections[].rows[]` with `bars`, `reset`, `note` and `recommended`, and `sections[].more` for API key and signed-out accounts); use it to answer "what does my menu bar say". Clicking an account runs `sideby menubar start <account>`, which opens it in the Preferred Terminal. ⌥X opens and closes the menu from anywhere; it needs no macOS permission. To change it ("换个快捷键", "change the menu bar shortcut"), run `sideby menubar hotkey <keys> --json`: `cmd` or `ctrl`, any of `opt` and `shift`, and one letter or digit, such as `ctrl+opt+s`; `off` turns it off, `default` goes back to ⌥X, and a running menu bar item takes it within seconds without a restart (`nudged`). A refusal says why in `code`: `hotkey.reserved` (macOS and most apps use it, such as ⌘Q), `hotkey.needs-modifier` (no opt, cmd or ctrl), `hotkey.invalid`. `sideby menubar hotkey --json` shows it: `registered: false` means macOS did not accept the key, so suggest another. macOS does not tell when another app uses the same keys (both may be accepted), so when the user says the shortcut does nothing, suggest another one too. The Panel has the same as a list (⌥X, ⌥Z, ⌥⌘S, ⌃⌥S, Off, Custom…) in **Menu bar icon ›** under the menu bar switch, with "Can't see the icon?" and "Let AI check it" (`sideby ask --task menubar`).
77
+ The icon stands alone while every tool has quota left. In each tool sideby takes how much the account `sideby next` would pick has used; when the tightest of those reaches its warning level, the title shows that tool and percent, such as `Codex 61%`: a 5-hour window turns orange at 60% and red at 85%, a weekly one orange at 85% and red at 95% (ADR-0062). Each row's `reset` names the window that runs out first and when it resets (`7d · in 4d 17h`). The menu's first line (`headline`) names that account either way. `sideby menubar snapshot --json` prints what the menu shows (`title`, `level`, `headline`, `sections[].rows[]` with `bars`, `reset`, `note` and `recommended`, and `sections[].more` for API key and signed-out accounts); use it to answer "what does my menu bar say". Clicking an account runs `sideby menubar start <account>`, which opens it in the Preferred Terminal. ⌥X opens and closes the menu from anywhere; it needs no macOS permission. To change it ("换个快捷键", "change the menu bar shortcut"), run `sideby menubar hotkey <keys> --json`: `cmd` or `ctrl`, any of `opt` and `shift`, and one letter or digit, such as `ctrl+opt+s`; `off` turns it off, `default` goes back to ⌥X, and a running menu bar item takes it within seconds without a restart (`nudged`). A refusal says why in `code`: `hotkey.reserved` (macOS and most apps use it, such as ⌘Q), `hotkey.needs-modifier` (no opt, cmd or ctrl), `hotkey.invalid`. `sideby menubar hotkey --json` shows it: `registered: false` means macOS did not accept the key, so suggest another. macOS does not tell when another app uses the same keys (both may be accepted), so when the user says the shortcut does nothing, suggest another one too. The Panel has the same as a list (⌥X, ⌥Z, ⌥⌘S, ⌃⌥S, Off, Custom…) in **Menu bar icon ›** under the menu bar switch, with "Can't see the icon?" and "Let AI check it" (`sideby ask --task menubar`).
78
78
 
79
79
  When the user cannot see the icon ("状态栏没有图标", "the menu bar icon is gone"), read `sideby menubar --json` first. `state: "off"`: it was turned off, often with the menu's "Hide from Menu Bar…"; offer `sideby menubar on --yes`. `state: "on"` with `loaded: false`: on but not running (macOS let it go, for example after an update); `sideby menubar on --yes --json` starts it again without changing the file. `loaded: true`: it runs but is hidden. `icon.visible: false` says so for certain: the menu bar is full and macOS put it behind « (click « to see it, or set it to always show in System Settings › Menu Bar). Otherwise check System Settings › Menu Bar (osascript turned off) and menu bar organizers such as Ice or Bartender.
@@ -1,6 +1,10 @@
1
1
  # Claude quota
2
2
 
3
- Claude quota needs a one-time change to `~/.claude/settings.json`: the status line command becomes `sideby statusline-tap --orig-b64 <base64 of the original command>`. Claude Code then hands each refresh's official `rate_limits` (5-hour and 7-day used percent and reset time) to sideby, which caches them per account. Nothing is sent anywhere.
3
+ Claude quota needs no setup: sideby asks Claude Code itself (ADR-0063). For each signed-in subscription account it runs `claude -p /usage --no-session-persistence --output-format json` with that account's config directory, with the user's hooks and MCP servers off, at most every 15 minutes. Claude Code answers with its own sign-in and starts no model turn (tried with Claude Code 2.1.314 on 2026-10-30); sideby reads no credential and keeps only the 5-hour, weekly and per-model weekly windows. `sideby quota claude --refresh` asks again now. `sideby quota check claude off --json` (config `quota.check.claude: false`) turns it off, as does CI. On `reason: "fetch-failed"`, relay the next step in `detail` (update Claude Code or sideby, or `sideby login <ref>`). A window with a model `name` (Claude Code's `Current week (<model>)`) covers only that model: show it, but it does not decide which account is picked.
4
+
5
+ ## Live quota for Auto Handoff (the status line tap)
6
+
7
+ While a session runs, Claude Code also hands each reply's official `rate_limits` (5-hour and 7-day used percent and reset time) to its status line command; sideby shows the newer of that and the `/usage` answer. Auto Handoff reads only this one, so it needs a one-time change to `~/.claude/settings.json`: the status line command becomes `sideby statusline-tap --orig-b64 <base64 of the original command>`, and sideby caches the readings per account. Nothing is sent anywhere. Offer it when the user turns on Auto Handoff, not just to see quota.
4
8
 
5
9
  1. sideby must be installed globally (`npm i -g sideby`), because Claude Code runs the wrapper on every status line refresh. Setup is refused when `sideby` is missing from PATH or comes from the npx cache; tell the user to install it rather than working around it.
6
10
  2. Run `sideby quota setup claude`. It prints the diff, changes nothing and exits **10**: show the diff to the user.
@@ -9,9 +13,9 @@ Claude quota needs a one-time change to `~/.claude/settings.json`: the status li
9
13
 
10
14
  Setup also sets `statusLine.refreshInterval: 30` (kept if the user set one), so the quota stays current while a session waits on background agents. When `sideby handoff status` or `sideby doctor` (`handoff.quota-refresh`) asks for it, the status line was wrapped by an older sideby: run `sideby quota setup claude` again; the plan has `upgrade: true` and adds only that key. Ask before `--yes` as above.
11
15
 
12
- Accounts with their own (not linked) `settings.json` show quota `not-enabled` until that file's status line is wrapped the same way; tell the user instead of editing it.
16
+ Accounts with their own (not linked) `settings.json` get no status line readings until that file's status line is wrapped the same way; they still show the `/usage` answer. Tell the user instead of editing it.
13
17
 
14
- After setup, each account shows quota once it has had one session with a reply. Codex quota needs no setup: sideby asks the official `codex app-server` every 15 minutes, without a conversation. `sideby quota codex --refresh --json` asks now; `sideby quota check codex off --json` disables querying, as does CI. Local session records are a fallback only until the first successful query; they cannot overwrite fetched quota afterward. On failure, relay `fetchError` and `observedAt`, never call old numbers current. The menu's checked time is separate from each row's `observedAt` and `stale`; readings older than one hour or with a query failure show as older readings, except a reading over an hour old whose login has had no local session since (it stays current; use on the web or other computers is not seen). Claude Code quota cannot be refreshed on demand: tell the user it updates when a session runs in that account. Tested with Codex CLI 0.163.0.
18
+ Codex quota needs no setup: sideby asks the official `codex app-server` every 15 minutes, without a conversation. `sideby quota codex --refresh --json` asks now; `sideby quota check codex off --json` disables querying, as does CI. Local session records are a fallback only until the first successful query; they cannot overwrite fetched quota afterward. On failure, relay `fetchError` and `observedAt`, never call old numbers current. The menu's checked time is separate from each row's `observedAt` and `stale`; readings older than one hour or with a query failure show as older readings, except a reading over an hour old whose login has had no local session since (it stays current; use on the web or other computers is not seen). Claude Code quota refreshes on demand the same way (`sideby quota claude --refresh`). Tested with Codex CLI 0.163.0.
15
19
 
16
20
  Two accounts of one tool signed in as the same login (Claude: same email and organization; Codex and Grok also compare the workspace or team; `sameLogin` in `sideby list --json`) share one quota: both show the freshest reading, and `quota.from` names the account it was read from. Explain that to the user rather than calling the numbers wrong; usage stays per account, and sideby never merges or deletes either directory.
17
21
 
@@ -21,6 +25,8 @@ Antigravity CLI (`agy`, main account only) quota also needs no setup: sideby run
21
25
 
22
26
  A window with a `name` (a plugin's Cursor "Other models") covers only some models: show it, but it does not make the account full.
23
27
 
28
+ Colors depend on the window's length (ADR-0062): a 5-hour (or any one-day-or-shorter) window is yellow from 60% and red from 85%; a weekly or longer window is yellow from 85% and red from 95%. One full 5-hour window costs only about a fifth of a week, so a week at 87% still leaves several 5-hour windows of work. When the user asks why a weekly 87% is not red, or why such an account was still picked, say that.
29
+
24
30
  Usage (7-day tokens) is read by sideby itself from Claude Code and Codex local records; no ccusage is needed. Grok and pi have no usage source; pi has no quota either.
25
31
 
26
32
  ## Quota checks and refresh