sideby 0.35.7 → 0.35.9

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":"20261109T030142-15900e"}
1
+ {"id":"20261110T040509-f565d3"}
@@ -1,4 +1,4 @@
1
- import { SKILL_UPDATE } from './skill-check.js';
1
+ import { SKILL_INSTALL, SKILL_UPDATE } from './skill-check.js';
2
2
  /**
3
3
  * The skill step the new code runs by name. `--skill` updates only the installed skill: it never installs the CLI,
4
4
  * even when the registry has moved on since the user confirmed.
@@ -12,9 +12,16 @@ export async function runSkillUpdate(m, plan, env, onOutput) {
12
12
  const r = await m
13
13
  .exec(file, args, { env, ...(onOutput ? { onOutput } : {}) })
14
14
  .catch((e) => ({ code: 1, output: e instanceof Error ? e.message : String(e) }));
15
- return r.code === 0
16
- ? { ok: true, message: 'updated the sideby skill' }
17
- : { ok: false, message: `\`${plan.command}\` failed (exit ${r.code}); run it yourself to see why` };
15
+ if (r.code !== 0)
16
+ return { ok: false, message: `\`${plan.command}\` failed (exit ${r.code}); run it yourself to see why` };
17
+ // The skills tool exits 0 when its install record does not list the skill: it changed nothing, and the skill is
18
+ // as old as before.
19
+ if (/No installed skills found/i.test(r.output))
20
+ return {
21
+ ok: false,
22
+ message: `the skills tool does not list the sideby skill as one it installed, so it updated nothing; run \`${SKILL_INSTALL}\` to install the current one`,
23
+ };
24
+ return { ok: true, message: 'updated the sideby skill' };
18
25
  }
19
26
  async function autostartByName(m, home, env) {
20
27
  // Never created here: only a login item `sideby autostart on` wrote is refreshed (ADR-0029).
@@ -62,7 +62,12 @@ export declare function taskStateDir(dir: string): Promise<string>;
62
62
  * `<promptArg>=<prompt>` instead, since its Host refuses a positional prompt.
63
63
  */
64
64
  export declare function taskHostArgs(rt: Runtime, task: TaskFile): Promise<string[]>;
65
- /** `env` with the HOME and XDG folders the task was written under, so the Runtime sees what the Panel saw. */
65
+ /**
66
+ * `env` with the HOME and XDG folders the task was written under, so the Runtime sees what the Panel saw. A folder at
67
+ * its default place under that HOME gets no variable (paths.ts reads an unset one as the default): the whole session
68
+ * inherits this, and other tools change where they keep their files once an XDG variable is set. Only a value the
69
+ * terminal already has for that same folder stays.
70
+ */
66
71
  export declare function taskEnv(task: TaskFile, env: Env): Env;
67
72
  export declare function readTask(id: string, paths?: Pick<Paths, 'stateDir'>): Promise<TaskFile>;
68
73
  export declare function terminals(rt: Runtime): Promise<{
@@ -2,7 +2,7 @@ import { randomBytes } from 'node:crypto';
2
2
  import { constants } from 'node:fs';
3
3
  import { lstat, mkdtemp, open, readdir, realpath, rm, stat, unlink } from 'node:fs/promises';
4
4
  import { userInfo } from 'node:os';
5
- import { dirname, isAbsolute, join, sep } from 'node:path';
5
+ import { dirname, isAbsolute, join, resolve, sep } from 'node:path';
6
6
  import { MODEL_NAME, takeFlag } from '../families/shared/model-args.js';
7
7
  import { AI_TASK_KINDS, stripSecrets, taskPrompt } from '../panel/page-logic.js';
8
8
  import { checkAttachmentFiles, copyAttachments, MAX_ATTACHMENTS, privateDir, removeOldAttachments, stagedAttachments, takeStaged, } from './attachments.js';
@@ -155,15 +155,26 @@ export async function taskHostArgs(rt, task) {
155
155
  const prompt = task.prompt ?? '';
156
156
  return [...images, family?.promptArg ? `${family.promptArg}=${prompt}` : prompt];
157
157
  }
158
- /** `env` with the HOME and XDG folders the task was written under, so the Runtime sees what the Panel saw. */
158
+ /**
159
+ * `env` with the HOME and XDG folders the task was written under, so the Runtime sees what the Panel saw. A folder at
160
+ * its default place under that HOME gets no variable (paths.ts reads an unset one as the default): the whole session
161
+ * inherits this, and other tools change where they keep their files once an XDG variable is set. Only a value the
162
+ * terminal already has for that same folder stays.
163
+ */
159
164
  export function taskEnv(task, env) {
160
165
  if (!task.home || !task.configDir || !task.stateDir)
161
166
  return env;
167
+ const { XDG_CONFIG_HOME: config, XDG_STATE_HOME: state, ...rest } = env;
168
+ const configBase = dirname(task.configDir);
169
+ const stateBase = dirname(task.stateDir);
170
+ // The same folder however the terminal spells it (`…/state/`, `…/./state`), not the same string.
171
+ const sameDir = (a, b) => isAbsolute(a) && resolve(a) === resolve(b);
172
+ const named = (dir, byDefault, had) => !sameDir(byDefault, dir) || (had !== undefined && sameDir(had, dir));
162
173
  return {
163
- ...env,
174
+ ...rest,
164
175
  HOME: task.home,
165
- XDG_CONFIG_HOME: dirname(task.configDir),
166
- XDG_STATE_HOME: dirname(task.stateDir),
176
+ ...(named(configBase, join(task.home, '.config'), config) ? { XDG_CONFIG_HOME: configBase } : {}),
177
+ ...(named(stateBase, join(task.home, '.local', 'state'), state) ? { XDG_STATE_HOME: stateBase } : {}),
167
178
  };
168
179
  }
169
180
  export async function readTask(id, paths = resolvePaths()) {
@@ -52,6 +52,8 @@ export interface Match {
52
52
  id: number;
53
53
  /** Higher is better; 1 for a match that has no FTS rank (short words only). */
54
54
  relevance: number;
55
+ /** The title of the Session the match stands for (the parent's, for a match in a subagent Session). */
56
+ title: string;
55
57
  }
56
58
  export declare class HistoryIndex {
57
59
  #private;
@@ -98,6 +100,8 @@ export declare class HistoryIndex {
98
100
  * shorter ones are matched with LIKE. Subagent Sessions count for their parent (filters then apply to the parent).
99
101
  */
100
102
  match(words: string[], f: Filters): Match[];
103
+ /** The newest subagent Session of `parent` whose own text matches every word: where a snippet comes from then. */
104
+ childMatch(parent: Pick<SessionRow, 'account' | 'sessionId'>, words: string[]): number | undefined;
101
105
  /** Top-level Sessions matching the filters, newest first. */
102
106
  recent(f: Filters, limit: number, offset: number): {
103
107
  rows: SessionRow[];
@@ -7,7 +7,7 @@ import { dirname } from 'node:path';
7
7
  import { cutText } from '../families/shared/history-text.js';
8
8
  import { UserError } from './errors.js';
9
9
  /** Bumped whenever the tables or what a reader stores changes; an older database is dropped and rebuilt. */
10
- const SCHEMA = 3;
10
+ const SCHEMA = 4;
11
11
  let sqlite;
12
12
  /** `node:sqlite` without its experimental warning (ADR-0042); undefined when this Node has none. */
13
13
  function loadSqlite() {
@@ -329,14 +329,9 @@ export class HistoryIndex {
329
329
  parts.push(`${col('script')} = 0`);
330
330
  return { sql: parts.length ? parts.join(' AND ') : '1', args };
331
331
  }
332
- /**
333
- * Sessions that match every word (in title, place, prompts or replies) and the filters. Words of three characters
334
- * or more go through the trigram index and are ranked by bm25 (title and place before prompts before replies);
335
- * shorter ones are matched with LIKE. Subagent Sessions count for their parent (filters then apply to the parent).
336
- */
337
- match(words, f) {
332
+ /** The conditions on `text` that make a row match every word, and the expression that ranks it. */
333
+ #textConds(words) {
338
334
  const longs = words.filter(long);
339
- const shorts = words.filter((w) => !long(w));
340
335
  const args = [];
341
336
  const conds = [];
342
337
  let rank = '1.0';
@@ -345,24 +340,58 @@ export class HistoryIndex {
345
340
  args.push(longs.map(phrase).join(' '));
346
341
  rank = '-bm25(text, 6.0, 4.0, 2.0, 1.0)';
347
342
  }
348
- for (const w of shorts) {
349
- conds.push("(text.title LIKE ? ESCAPE '\\' OR text.place LIKE ? ESCAPE '\\' OR text.prompts LIKE ? ESCAPE '\\' OR text.replies LIKE ? ESCAPE '\\')");
350
- const l = like(w);
351
- args.push(l, l, l, l);
343
+ for (const w of words.filter((x) => !long(x))) {
344
+ // LIKE ignores case for ASCII letters only, so a word without one matches the same rows through instr(),
345
+ // which reads the text about twice as fast.
346
+ if (/[a-z]/i.test(w)) {
347
+ conds.push("(text.title LIKE ? ESCAPE '\\' OR text.place LIKE ? ESCAPE '\\' OR text.prompts LIKE ? ESCAPE '\\' OR text.replies LIKE ? ESCAPE '\\')");
348
+ const l = like(w);
349
+ args.push(l, l, l, l);
350
+ }
351
+ else {
352
+ conds.push('(instr(text.title, ?) OR instr(text.place, ?) OR instr(text.prompts, ?) OR instr(text.replies, ?))');
353
+ args.push(w, w, w, w);
354
+ }
352
355
  }
356
+ return { conds, args, rank };
357
+ }
358
+ /**
359
+ * Sessions that match every word (in title, place, prompts or replies) and the filters. Words of three characters
360
+ * or more go through the trigram index and are ranked by bm25 (title and place before prompts before replies);
361
+ * shorter ones are matched with LIKE. Subagent Sessions count for their parent (filters then apply to the parent).
362
+ */
363
+ match(words, f) {
364
+ const { conds, args, rank } = this.#textConds(words);
353
365
  // Lift a matching subagent Session to its parent, and apply the filters to whichever row stands for it.
354
366
  const where = this.#where(f, (n) => `coalesce(p.${n}, s.${n})`);
355
- return this.#q(`WITH hits(id, rel) AS MATERIALIZED (SELECT text.rowid, ${rank} FROM text WHERE ${conds.join(' AND ') || '1'})
356
- SELECT coalesce(p.id, s.id) AS id, max(h.rel) AS relevance
367
+ const lift = `LEFT JOIN sessions p ON s.parent != '' AND p.account = s.account AND p.session_id = s.parent AND p.parent = ''`;
368
+ // With short words only there is no index to ask, and LIKE reads every row's text: read only the rows the
369
+ // filters keep.
370
+ const scoped = conds.length > 0 && !words.some(long) && where.sql !== '1';
371
+ const scope = scoped ? `text.rowid IN (SELECT s.id FROM sessions s ${lift} WHERE ${where.sql}) AND ` : '';
372
+ return this.#q(`WITH hits(id, rel) AS MATERIALIZED (SELECT text.rowid, ${rank} FROM text WHERE ${scope}${conds.join(' AND ') || '1'})
373
+ SELECT coalesce(p.id, s.id) AS id, max(h.rel) AS relevance, coalesce(p.title, s.title) AS title
357
374
  FROM hits h JOIN sessions s ON s.id = h.id
358
- LEFT JOIN sessions p ON s.parent != '' AND p.account = s.account AND p.session_id = s.parent AND p.parent = ''
375
+ ${lift}
359
376
  WHERE ${where.sql} GROUP BY 1`)
360
- .all(...args, ...where.args)
377
+ .all(...(scoped ? where.args : []), ...args, ...where.args)
361
378
  .map((r) => {
362
379
  const m = r;
363
- return { id: m.id, relevance: Math.max(m.relevance, 1e-6) };
380
+ return { id: m.id, relevance: Math.max(m.relevance, 1e-6), title: m.title };
364
381
  });
365
382
  }
383
+ /** The newest subagent Session of `parent` whose own text matches every word: where a snippet comes from then. */
384
+ childMatch(parent, words) {
385
+ const { conds, args } = this.#textConds(words);
386
+ if (!conds.length)
387
+ return undefined;
388
+ const r = this.#q(
389
+ // CROSS JOIN keeps this order: the few subagent Sessions first, then the text of each.
390
+ `SELECT c.id FROM sessions c CROSS JOIN text
391
+ WHERE c.parent = ? AND c.account = ? AND c.parent != '' AND text.rowid = c.id AND ${conds.join(' AND ')}
392
+ ORDER BY c.updated_at DESC LIMIT 1`).get(parent.sessionId, parent.account, ...args);
393
+ return r?.id;
394
+ }
366
395
  /** Top-level Sessions matching the filters, newest first. */
367
396
  recent(f, limit, offset) {
368
397
  const w = this.#where(f);
@@ -43,7 +43,8 @@ export class ProjectResolver {
43
43
  if (!cwd || !isAbsolute(cwd))
44
44
  return { path: hostRoot ?? cwd ?? '', gone: false };
45
45
  if ((await kind(cwd)) !== 'dir') {
46
- const root = hostRoot && isAbsolute(hostRoot) ? hostRoot : cwd;
46
+ // resolve() drops a trailing separator (Grok records `<repo>/`), so it groups with the live folder's Project.
47
+ const root = resolve(hostRoot && isAbsolute(hostRoot) ? hostRoot : cwd);
47
48
  const main = (await kind(join(root, '.git'))) === 'file' ? await worktreeMain(join(root, '.git')) : undefined;
48
49
  return { path: main ?? root, gone: true };
49
50
  }
@@ -75,10 +76,22 @@ export function projectNames(paths) {
75
76
  }
76
77
  const parts = list.map((p) => p.split(/[\\/]+/).filter(Boolean));
77
78
  const tail = (seg, n) => seg.slice(-n).join('/');
79
+ // How many of these Projects end with each tail of `n` folders, counted once per `n`.
80
+ const tails = new Map();
81
+ const shared = (seg, n) => {
82
+ let count = tails.get(n);
83
+ if (!count) {
84
+ count = new Map();
85
+ for (const o of parts)
86
+ count.set(tail(o, n), (count.get(tail(o, n)) ?? 0) + 1);
87
+ tails.set(n, count);
88
+ }
89
+ return count.get(tail(seg, n)) > 1;
90
+ };
78
91
  for (const [i, p] of list.entries()) {
79
92
  const seg = parts[i];
80
93
  let n = 2;
81
- while (n < seg.length && parts.some((o, j) => j !== i && tail(o, n) === tail(seg, n)))
94
+ while (n < seg.length && shared(seg, n))
82
95
  n++;
83
96
  out.set(p, tail(seg, n));
84
97
  }
@@ -124,8 +124,18 @@ export declare const historyBuilt: (rt: Runtime) => boolean;
124
124
  * `/a/app` beside `/x/a/app`).
125
125
  */
126
126
  export declare function projectsNamed(names: ReadonlyMap<string, string>, p: string): string[];
127
- /** A snippet of `text` around the first of `words` it contains, about 40 characters each side. */
127
+ /**
128
+ * A snippet of `text`, about 40 characters each side of what was searched: the first place where the most of
129
+ * `words` stand within 80 characters of each other, so two words show together when the text has them together.
130
+ */
128
131
  export declare function snippetOf(text: string, words: string[]): string | undefined;
132
+ /**
133
+ * How much a match in the title lifts a Session: the whole query in the title most, then every word, then a share
134
+ * of the words. A title is what people remember a Session by, and bm25 over trigrams hardly tells it from a mention.
135
+ */
136
+ export declare function titleBoost(title: string, words: string[], query: string): number;
137
+ /** The share of a search score a Session keeps at its age: half at 30 days, a third at 60, never nothing. */
138
+ export declare const recency: (ageMs: number) => number;
129
139
  /** The words of a search; `"two words"` in double quotes is one phrase, matched as written. */
130
140
  export declare const splitWords: (q: string | undefined) => string[];
131
141
  /**
@@ -12,7 +12,8 @@ import { HistoryIndex, } from './history-index.js';
12
12
  import { ProjectResolver, projectNames } from './history-project.js';
13
13
  import { accountLabels, hostResumeArgs, liveKey, referenceText } from './live-sessions.js';
14
14
  const DAY = 86_400_000;
15
- const HALF_LIFE = 7 * DAY;
15
+ /** How old a Session is when its age has halved its search score; older ones go on falling, more slowly. */
16
+ const RECENCY = 30 * DAY;
16
17
  const SYNC_EVERY_MS = 5_000;
17
18
  const PARSE_AT_ONCE = 4;
18
19
  const STATES = new Map();
@@ -475,29 +476,69 @@ export function projectsNamed(names, p) {
475
476
  }
476
477
  const SAFE = /^[\w@%+=:,./-]+$/;
477
478
  const shq = (v) => (SAFE.test(v) ? v : `'${v.replaceAll("'", "'\\''")}'`);
478
- /** A snippet of `text` around the first of `words` it contains, about 40 characters each side. */
479
+ const SNIPPET_SPAN = 80;
480
+ /** Occurrences looked at per word: enough to find a place where the words meet, bounded for a long text. */
481
+ const SNIPPET_SEEK = 40;
482
+ /**
483
+ * A snippet of `text`, about 40 characters each side of what was searched: the first place where the most of
484
+ * `words` stand within 80 characters of each other, so two words show together when the text has them together.
485
+ */
479
486
  export function snippetOf(text, words) {
480
487
  if (!text || !words.length)
481
488
  return undefined;
482
- let at = -1;
483
- let len = 0;
484
- for (const w of words) {
485
- // Matched in the text itself: lowercasing can change its length and move every position after it.
486
- const m = new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'iu').exec(text);
487
- if (m && (at < 0 || m.index < at)) {
488
- at = m.index;
489
- len = m[0].length;
489
+ // Matched in the text itself: lowercasing can change its length and move every position after it.
490
+ const found = words.map((w) => {
491
+ const re = new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'giu');
492
+ const at = [];
493
+ // One word needs only its first place.
494
+ const seek = words.length > 1 ? SNIPPET_SEEK : 1;
495
+ for (let m = re.exec(text); m && at.length < seek; m = re.exec(text)) {
496
+ at.push({ index: m.index, end: m.index + m[0].length });
497
+ if (!m[0].length)
498
+ re.lastIndex++;
490
499
  }
500
+ return at;
501
+ });
502
+ let best;
503
+ for (const start of found.flat().sort((x, y) => x.index - y.index)) {
504
+ let n = 0;
505
+ let end = start.end;
506
+ for (const at of found) {
507
+ const near = at.find((o) => o.index >= start.index && o.end <= start.index + SNIPPET_SPAN);
508
+ if (!near)
509
+ continue;
510
+ n++;
511
+ end = Math.max(end, near.end);
512
+ }
513
+ if (!best || n > best.words)
514
+ best = { at: start.index, end, words: n };
515
+ if (n === words.length)
516
+ break;
491
517
  }
492
- if (at < 0)
518
+ if (!best)
493
519
  return undefined;
494
- let start = Math.max(0, at - 40);
520
+ let start = Math.max(0, best.at - 40);
495
521
  if (start > 0 && /[\uDC00-\uDFFF]/.test(text[start]))
496
522
  start--;
497
- const end = start + cutText(text.slice(start), at - start + len + 40).length;
523
+ const end = start + cutText(text.slice(start), best.end - start + 40).length;
498
524
  const body = text.slice(start, end).replace(/\s+/g, ' ').trim();
499
525
  return `${start > 0 ? '…' : ''}${body}${end < text.length ? '…' : ''}`;
500
526
  }
527
+ /**
528
+ * How much a match in the title lifts a Session: the whole query in the title most, then every word, then a share
529
+ * of the words. A title is what people remember a Session by, and bm25 over trigrams hardly tells it from a mention.
530
+ */
531
+ export function titleBoost(title, words, query) {
532
+ const t = title.toLowerCase();
533
+ const n = words.filter((w) => t.includes(w.toLowerCase())).length;
534
+ if (!n)
535
+ return 1;
536
+ if (t.includes(query.trim().toLowerCase()))
537
+ return 8;
538
+ return n === words.length ? 5 : 1 + (2 * n) / words.length;
539
+ }
540
+ /** The share of a search score a Session keeps at its age: half at 30 days, a third at 60, never nothing. */
541
+ export const recency = (ageMs) => 1 / (1 + Math.max(0, ageMs) / RECENCY);
501
542
  const NAMES = new WeakMap();
502
543
  /** Project names, worked out again only after the index changed. */
503
544
  function namesOf(idx) {
@@ -614,7 +655,11 @@ async function search(rt, s, q, opts) {
614
655
  const outline = idx.outlineOf(hits.map((h) => h.id));
615
656
  items = hits.flatMap((h) => {
616
657
  const o = outline.get(h.id);
617
- return o ? [{ ...o, score: h.relevance * 0.5 ** (Math.max(0, now - o.updatedAt) / HALF_LIFE) }] : [];
658
+ if (!o)
659
+ return [];
660
+ return [
661
+ { ...o, score: h.relevance * titleBoost(h.title, words, q.q ?? '') * recency(now - o.updatedAt) },
662
+ ];
618
663
  });
619
664
  }
620
665
  else
@@ -663,8 +708,17 @@ async function search(rt, s, q, opts) {
663
708
  const sessions = rows.map((r) => {
664
709
  let snippet;
665
710
  if (words.length && idx.keepText) {
666
- const t = idx.text(r.id);
667
- snippet = snippetOf(t.prompts, words) ?? snippetOf(t.replies, words);
711
+ const of = (id) => {
712
+ const t = idx.text(id);
713
+ return snippetOf(t.prompts, words) ?? snippetOf(t.replies, words);
714
+ };
715
+ snippet = of(r.id);
716
+ // Matched by a subagent Session only: show what that one said, so the row says why it is listed.
717
+ if (!snippet) {
718
+ const child = idx.childMatch(r, words);
719
+ if (child !== undefined)
720
+ snippet = of(child);
721
+ }
668
722
  }
669
723
  const out = toSession(rt, r, labels, names, {
670
724
  children: children.get(r.id) ?? 0,
@@ -12,9 +12,10 @@ export declare const pkgDir: (d: LocalDirs) => string;
12
12
  export declare const globalPkg: (d: LocalDirs) => string;
13
13
  export declare const devDir: (env: Env) => string;
14
14
  /**
15
- * The environment to ask npm for its global prefix in. A pnpm script gets pnpm's own `--dir` (`pnpm -C <dir> …`) as
16
- * `npm_config_dir` and `npm_config_prefix`, and npm would answer with that directory; npm reads the user's real
17
- * setting from its config files and from `NPM_CONFIG_PREFIX` without them.
15
+ * The environment to ask npm for its global prefix in, and to install a global package in. A pnpm script gets pnpm's
16
+ * own `--dir` (`pnpm -C <dir> …`) as `npm_config_dir` and `npm_config_prefix`, and npm would answer with, and install
17
+ * into, that directory; npm reads the user's real setting from its config files and from `NPM_CONFIG_PREFIX` without
18
+ * them.
18
19
  */
19
20
  export declare function npmEnv(env: Env): Env;
20
21
  /** Where the switch works, with npm's global prefix from `npm prefix -g`; null when npm cannot be asked. */
@@ -16,9 +16,10 @@ export const globalPkg = (d) => join(d.prefix, 'lib', 'node_modules', 'sideby');
16
16
  const globalBin = (d) => join(d.prefix, 'bin', 'sideby');
17
17
  export const devDir = (env) => join(env.XDG_DATA_HOME || join(env.HOME || homedir(), '.local', 'share'), 'sideby-dev');
18
18
  /**
19
- * The environment to ask npm for its global prefix in. A pnpm script gets pnpm's own `--dir` (`pnpm -C <dir> …`) as
20
- * `npm_config_dir` and `npm_config_prefix`, and npm would answer with that directory; npm reads the user's real
21
- * setting from its config files and from `NPM_CONFIG_PREFIX` without them.
19
+ * The environment to ask npm for its global prefix in, and to install a global package in. A pnpm script gets pnpm's
20
+ * own `--dir` (`pnpm -C <dir> …`) as `npm_config_dir` and `npm_config_prefix`, and npm would answer with, and install
21
+ * into, that directory; npm reads the user's real setting from its config files and from `NPM_CONFIG_PREFIX` without
22
+ * them.
22
23
  */
23
24
  export function npmEnv(env) {
24
25
  if (!env.npm_config_user_agent?.startsWith('pnpm/'))
@@ -203,8 +204,9 @@ export async function switchLocal(paths, d, to, env, opts = {}) {
203
204
  else {
204
205
  const want = latest ?? 'latest';
205
206
  await rm(globalPkg(d), { force: true });
207
+ // Without pnpm's `--dir`: from `pnpm -C <checkout> local --off` npm would install into the checkout.
206
208
  const r = await runProgram('npm', ['install', '-g', `sideby@${want}`], {
207
- env,
209
+ env: npmEnv(env),
208
210
  ...(opts.onOutput ? { onOutput: opts.onOutput } : {}),
209
211
  });
210
212
  if (r.code !== 0) {
@@ -1,8 +1,11 @@
1
1
  import type { ProfileAppDef } from '../desktop.ts';
2
2
  /**
3
3
  * Grok Bot (spec §3.20 "Grok Bot 窗口", ADR-0019). It signs in with a Cursor account, apart from every grok Account,
4
- * so its windows are App Profiles. `--user-data-dir` is the app's isolated mode: userData and its data root
5
- * (`<dir>/sand-data`) move there. SAND_DATA_ROOT and SAND_USER_DATA_DIR would override it; all of this is internal to
6
- * the app and may change.
4
+ * so its windows are App Profiles. SAND_USER_DATA_DIR is the app's isolated mode: userData and its data root
5
+ * (`<dir>/sand-data`) move there. Up to 0.71.x `--user-data-dir` did the same; from 0.79.3 the app sets userData
6
+ * back to its default and ignores the flag, so the new instance loses the single-instance lock to the main window
7
+ * and quits at once. `open --env` sets the variable for the app; the flag stays for older versions and because
8
+ * `instanceOf` finds the window by it. The caller's own SAND_DATA_ROOT and SAND_USER_DATA_DIR are cleared so only
9
+ * this folder counts. All of this is internal to the app and may change.
7
10
  */
8
11
  export declare const grokBot: ProfileAppDef;
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * Grok Bot (spec §3.20 "Grok Bot 窗口", ADR-0019). It signs in with a Cursor account, apart from every grok Account,
3
- * so its windows are App Profiles. `--user-data-dir` is the app's isolated mode: userData and its data root
4
- * (`<dir>/sand-data`) move there. SAND_DATA_ROOT and SAND_USER_DATA_DIR would override it; all of this is internal to
5
- * the app and may change.
3
+ * so its windows are App Profiles. SAND_USER_DATA_DIR is the app's isolated mode: userData and its data root
4
+ * (`<dir>/sand-data`) move there. Up to 0.71.x `--user-data-dir` did the same; from 0.79.3 the app sets userData
5
+ * back to its default and ignores the flag, so the new instance loses the single-instance lock to the main window
6
+ * and quits at once. `open --env` sets the variable for the app; the flag stays for older versions and because
7
+ * `instanceOf` finds the window by it. The caller's own SAND_DATA_ROOT and SAND_USER_DATA_DIR are cleared so only
8
+ * this folder counts. All of this is internal to the app and may change.
6
9
  */
7
10
  export const grokBot = {
8
11
  id: 'grok-bot',
@@ -10,7 +13,15 @@ export const grokBot = {
10
13
  bundleId: 'com.anysphere.sand',
11
14
  bundleNames: ['Grok Bot.app'],
12
15
  installUrl: 'https://x.ai/bot/',
13
- openArgs: (app, appData) => ['-n', '-a', app, '--args', `--user-data-dir=${appData}`],
16
+ openArgs: (app, appData) => [
17
+ '-n',
18
+ '-a',
19
+ app,
20
+ '--env',
21
+ `SAND_USER_DATA_DIR=${appData}`,
22
+ '--args',
23
+ `--user-data-dir=${appData}`,
24
+ ],
14
25
  clearVars: ['SAND_DATA_ROOT', 'SAND_USER_DATA_DIR'],
15
26
  mainUserData: 'Library/Application Support/Grok Bot',
16
27
  statusFile: 'desktop-status.json',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.35.7",
3
+ "version": "0.35.9",
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.35.7"
5
+ version: "0.35.9"
6
6
  requires:
7
7
  bins: [sideby, node]
8
8
  cliHelp: sideby --help
@@ -12,7 +12,7 @@ sideby unattended on --until 08:00 --json # or --for 4h; at most 72 hours
12
12
  ```
13
13
 
14
14
  Tell the user, in one line each:
15
- - It covers Claude and Codex sessions sideby starts (`sideby run`, short commands, pick commands, `sideby next`, Auto Handoff, AI Tasks). Running `claude` or `codex` directly, Grok, pi and desktop apps are not covered.
15
+ - It covers Claude and Codex sessions sideby starts (`sideby run`, short commands, pick commands, `sideby next`, Auto Handoff, AI Tasks). Running `claude` or `codex` directly, Grok, pi and desktop apps are not covered. A terminal manager that starts the Host itself (Orca, for example) is covered once its Claude command is `sideby resume claude --` (configuration guide, "Resuming from other tools"); in Orca that is Settings → Agents → Claude → the command field.
16
16
  - Sessions started before the feature was first used have no hook. If `configured` was `false` before this command, the sessions already running are not covered: suggest restarting long tasks with `sideby run <account> --unattended`.
17
17
  - A Codex account runs the hooks only after the user trusts them once: in that account type `/hooks` and trust both `unattended-hook` entries, before a question and at the end of a turn (`coverage.codex` is `needs-trust`).
18
18
  - `sideby unattended off --json` turns it off; inside a Slot it pauses until that Slot ends.