sideby 0.42.1 → 0.42.2

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.
package/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"id":"20261121T042926-e2cf4d"}
1
+ {"id":"20261122T154741-dff236"}
@@ -650,6 +650,15 @@ export async function confirmLogin(rt, account, io) {
650
650
  }
651
651
  /** A Pick Command (spec §3.13, ADR-0035): start the Account with the most room, else the Main Account, and say which. */
652
652
  async function runPick(rt, name, args, io, opts = {}) {
653
+ const pickFamily = rt.pickCommandFamily(name);
654
+ // A resumed session lives in one Account only, so it starts there whatever the Quota (spec §3.13 "按 id 恢复").
655
+ const target = pickFamily === undefined ? null : await rt.resumeTarget(pickFamily, args);
656
+ if (target) {
657
+ io.err(c.dim(target.newSession
658
+ ? `sideby: session ${target.sessionId} was never saved; starting a new session in ${target.account.ref}`
659
+ : `sideby: session ${target.sessionId} is in ${target.account.ref}; starting it there`));
660
+ return runAccount(rt, target.account.ref, target.args, io, opts);
661
+ }
653
662
  const { choice, family } = await rt.pickChoice(name);
654
663
  if (choice.ref === null) {
655
664
  const now = rt.readContext().now;
@@ -48,6 +48,14 @@ export interface ResumeLaunch {
48
48
  args: string[];
49
49
  };
50
50
  }
51
+ /** The Account a by-id resume starts in, and the Host arguments to start it with (`Runtime.resumeTarget`). */
52
+ export interface ResumeTarget {
53
+ sessionId: string;
54
+ account: Account;
55
+ args: string[];
56
+ /** The session was never saved: `args` start a new session instead (ADR-0009). */
57
+ newSession?: true;
58
+ }
51
59
  /** What happened to the alias asked for with a new Account. */
52
60
  export interface AliasResult {
53
61
  name: string;
@@ -328,6 +336,12 @@ export interface Runtime {
328
336
  ignoreNetwork?: boolean;
329
337
  unattended?: boolean;
330
338
  }): Promise<ResumeLaunch>;
339
+ /**
340
+ * Where the Host arguments' by-id resume belongs (spec §3.13 "按 id 恢复", §3.15): the Account that holds the session
341
+ * (main included) with the arguments unchanged, or the one that started a never-saved session with the resume taken
342
+ * out; null when they resume nothing by id, the Family cannot route, or no Account has the session.
343
+ */
344
+ resumeTarget(familyId: string, userArgs: readonly string[]): Promise<ResumeTarget | null>;
331
345
  /**
332
346
  * The Account's Quota. For an Account of a Same Login (spec §3.21) it is the group's freshest reading, with `from`
333
347
  * naming the Account it was read from when that is another one.
@@ -1,4 +1,4 @@
1
- // The one service layer the CLI and the Panel share. Frozen contract for v0.1 (plan: 审核修订).
1
+ // The one service layer the CLI and the Panel share.
2
2
  import { aliasesByAccount, discoverAccounts, mainDirOf, resolveRef, startArgsOf, } from './core/accounts.js';
3
3
  import { advisorStatus, checkAdvisorAccount, setAdvisor, setAdvisorUnlock, undoAdvisor, } from './core/advisor.js';
4
4
  import { claudeLiveRuns, mainMemoryFindings, memoryFindings, memoryHookPart, memorySettingsLine, memorySkipLine, memoryStatus, memoryTarget, readFolds, systemTrash, } from './core/claude-memory.js';
@@ -1231,6 +1231,24 @@ export async function createRuntime(opts = {}) {
1231
1231
  account: route.account,
1232
1232
  };
1233
1233
  },
1234
+ async resumeTarget(familyId, userArgs) {
1235
+ const family = familyOf(familyId);
1236
+ if (!family.resumedSession || !family.sessionWrittenAt)
1237
+ return null;
1238
+ const route = await findResumeRoute(family, await accounts(), userArgs);
1239
+ if (!route.sessionId || !route.account)
1240
+ return null;
1241
+ if (!route.neverSaved)
1242
+ return { sessionId: route.sessionId, account: route.account, args: [...userArgs] };
1243
+ if (!family.withoutResume)
1244
+ return null;
1245
+ return {
1246
+ sessionId: route.sessionId,
1247
+ account: route.account,
1248
+ args: family.withoutResume(userArgs),
1249
+ newSession: true,
1250
+ };
1251
+ },
1234
1252
  async quota(account, o = {}) {
1235
1253
  const peers = await peersOf(account);
1236
1254
  if (!peers.length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.42.1",
3
+ "version": "0.42.2",
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)",
@@ -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.42.1"
5
+ version: "0.42.2"
6
6
  requires:
7
7
  bins: [sideby, node]
8
8
  cliHelp: sideby --help
@@ -101,7 +101,7 @@ Read only the reference the task needs.
101
101
 
102
102
  `eval "$(sideby shell-init zsh)"` defines one function per account (`sideby-claude-work`) plus the config `aliases` and `pickCommands`. Users who source a file instead set config `shellInitFile` (for example `{ "zsh": "~/.config/sideby/shell-init.zsh" }`); `new` and `alias add|rename|rm` keep it current, and `sideby shell-init zsh --write` rewrites it. Open terminals pick up the change at their next prompt.
103
103
 
104
- When a terminal manager such as Orca reopens a pane with a bare `claude --resume <id>` (or `codex resume <id>`, `grok --resume <id>`) and the Host says `No conversation found`, the session lives in another account. Suggest config `"resumeRouting": true` followed by `sideby shell-init --write` (or a new shell with `eval`): `shell-init` then defines Host-named functions that call `sideby resume <family>`, which starts the account holding that session. For a one-off, find it with `ls -d ~/.claude*/projects/*/<id>.jsonl` and run `sideby run <ref> -- --resume <id>`. When no account has that file, the session was opened but never got a message, so there is nothing to resume: `ls -d ~/.claude*/session-env/<id>` names the account that started it, and with routing on `sideby resume` starts a new session there by itself.
104
+ A pick command (`cc --resume <id>`) already starts the account holding the session. When a terminal manager such as Orca reopens a pane with a bare `claude --resume <id>` (or `codex resume <id>`, `grok --resume <id>`) and the Host says `No conversation found`, the session lives in another account. Suggest config `"resumeRouting": true` followed by `sideby shell-init --write` (or a new shell with `eval`): `shell-init` then defines Host-named functions that call `sideby resume <family>`, which starts the account holding that session. For a one-off, find it with `ls -d ~/.claude*/projects/*/<id>.jsonl` and run `sideby run <ref> -- --resume <id>`. When no account has that file, the session was opened but never got a message, so there is nothing to resume: `ls -d ~/.claude*/session-env/<id>` names the account that started it, and with routing on `sideby resume` starts a new session there by itself.
105
105
 
106
106
  To open Claude Desktop or the Codex app as one account (macOS, subscription accounts), run `sideby desktop <ref> --json` yourself: it opens a new window for that account, or brings its open window to the front, and never closes anything. Relay its `notices`: the first Claude Desktop sign-in should happen while other Claude Desktop windows are closed, and a sign-in screen that suggests the main account ("Welcome back" in the Codex app) must not be used for another account.
107
107
 
@@ -65,7 +65,7 @@ To start one account with fixed Host arguments, such as another model, put them
65
65
 
66
66
  ## Pick commands (start the account with the most room)
67
67
 
68
- 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.
68
+ 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. Given a session to resume by id (`cc --resume <id>`), it skips the quota and starts the account that holds the session (`sideby: session <id> is in claude:work; starting it there`), or a new session where a never-saved one started.
69
69
 
70
70
  - 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.
71
71
  - 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.