sideby 0.41.2 → 0.42.0

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 (53) hide show
  1. package/dist/build.json +1 -1
  2. package/dist/src/cli/commands.d.ts +2 -0
  3. package/dist/src/cli/commands.js +263 -32
  4. package/dist/src/cli/json-schemas.js +85 -4
  5. package/dist/src/cli/main.js +49 -7
  6. package/dist/src/core/claude-memory.d.ts +236 -0
  7. package/dist/src/core/claude-memory.js +937 -0
  8. package/dist/src/core/cli-commands.js +16 -3
  9. package/dist/src/core/config.d.ts +17 -0
  10. package/dist/src/core/config.js +266 -43
  11. package/dist/src/core/history-project.d.ts +14 -0
  12. package/dist/src/core/history-project.js +42 -12
  13. package/dist/src/core/history.d.ts +4 -6
  14. package/dist/src/core/history.js +5 -15
  15. package/dist/src/core/local-build.d.ts +12 -0
  16. package/dist/src/core/local-build.js +32 -0
  17. package/dist/src/core/search-catalog.js +49 -0
  18. package/dist/src/core/session-hooks.d.ts +12 -2
  19. package/dist/src/core/session-hooks.js +12 -8
  20. package/dist/src/core/unattended-followup.d.ts +62 -0
  21. package/dist/src/core/unattended-followup.js +205 -0
  22. package/dist/src/core/unattended-pending.d.ts +11 -3
  23. package/dist/src/core/unattended-pending.js +34 -8
  24. package/dist/src/families/claude/history.js +9 -1
  25. package/dist/src/families/claude/layout.d.ts +7 -0
  26. package/dist/src/families/claude/layout.js +17 -0
  27. package/dist/src/families/claude/live-sessions.js +2 -1
  28. package/dist/src/families/history.d.ts +22 -2
  29. package/dist/src/families/history.js +55 -0
  30. package/dist/src/handoff/messages.js +1 -1
  31. package/dist/src/panel/handler.d.ts +22 -4
  32. package/dist/src/panel/handler.js +71 -25
  33. package/dist/src/panel/i18n.d.ts +35 -1
  34. package/dist/src/panel/i18n.js +72 -4
  35. package/dist/src/panel/page-logic.d.ts +53 -0
  36. package/dist/src/panel/page-logic.js +96 -0
  37. package/dist/src/panel/page-script.js +174 -36
  38. package/dist/src/panel/page-styles.js +18 -0
  39. package/dist/src/runtime.d.ts +30 -0
  40. package/dist/src/runtime.js +85 -1
  41. package/dist/src/unattended/hook.d.ts +10 -5
  42. package/dist/src/unattended/hook.js +17 -12
  43. package/package.json +1 -1
  44. package/schemas/config.json +5 -1
  45. package/schemas/memory-set.json +117 -0
  46. package/schemas/memory.json +210 -0
  47. package/schemas/unattended-pending.json +156 -56
  48. package/skills/sideby/SKILL.md +3 -1
  49. package/skills/sideby/references/diagnose.md +1 -0
  50. package/skills/sideby/references/handoff.md +1 -1
  51. package/skills/sideby/references/panel.md +1 -1
  52. package/skills/sideby/references/sharing.md +23 -1
  53. package/skills/sideby/references/unattended.md +16 -5
package/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"id":"20261119T151949-9d2d80"}
1
+ {"id":"20261121T033317-cb060f"}
@@ -198,6 +198,8 @@ export declare function cmdProgress(a: ParsedArgs, io: Io): Promise<number>;
198
198
  * back; each shows the change first and exits 10 until `--yes`.
199
199
  */
200
200
  export declare function cmdTrust(a: ParsedArgs, io: Io): Promise<number>;
201
+ /** `sideby memory [status|on|off]` (spec §3.44, ADR-0081): Shared Project Memory between Claude accounts. */
202
+ export declare function cmdMemory(a: ParsedArgs, io: Io): Promise<number>;
201
203
  /** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
202
204
  export declare function cmdUnattended(a: ParsedArgs, io: Io): Promise<number>;
203
205
  export declare function cmdCommands(a: ParsedArgs, io: Io): number;
@@ -7,7 +7,7 @@ import { ADVISOR_UNLOCK_VAR, advisorGroupsToUndo, advisorNothingToDo, advisorPla
7
7
  import { listAppProfiles, openAppProfile, parseProfileRef, removeAppProfile } from '../core/app-profiles.js';
8
8
  import { browserReport, openInBrowser, openVendorPage, setBrowserChoice, setBrowserSignIns, } from '../core/browser-profiles.js';
9
9
  import { CLI_COMMANDS, COMMAND_GROUPS, commonCommands } from '../core/cli-commands.js';
10
- import { aiTaskPermissions, aliasAccount, aliasArgs, aliasRefs, EDITORS, editConfigAskPermissions, editConfigUpdate, loadConfig, } from '../core/config.js';
10
+ import { aiTaskPermissions, aliasAccount, aliasArgs, aliasRefs, EDITORS, editConfigAskPermissions, editConfigUpdate, loadConfig, readConfig, unknownConfigKeyNote, } from '../core/config.js';
11
11
  import { openDesktopApp, withDesktopApps } from '../core/desktop-app.js';
12
12
  import { EDITOR_APPS, editSettings, isEditor } from '../core/edit-settings.js';
13
13
  import { UserError } from '../core/errors.js';
@@ -32,7 +32,7 @@ import { MODEL_NAME } from '../families/shared/model-args.js';
32
32
  import { AI_TASK_KINDS, hiddenIn, inDisplayOrder, pinnedIn, resetWhen, suggestAlias, suggestName, vendorAlias, withPinned, } from '../panel/page-logic.js';
33
33
  import { createRuntime, UnknownFamilyError } from '../runtime.js';
34
34
  import { UsageError } from './args.js';
35
- import { c, clock, compactNumber, quotaText, table, truncate, tuningLines, usageText } from './format.js';
35
+ import { ago, c, clock, compactNumber, quotaText, table, truncate, tuningLines, usageText } from './format.js';
36
36
  /** Runs `fn` while a record under the state directory says a Host runs (also for `login`), so an Auto Update waits (spec §3.23). */
37
37
  async function whileRunning(rt, fn) {
38
38
  const { markRunning } = await import('../core/update.js');
@@ -426,8 +426,21 @@ export async function cmdList(a, io) {
426
426
  io.err(c.yellow(`${s.ref}: ${p}`));
427
427
  for (const e of rt.pluginErrors)
428
428
  io.err(c.yellow(`plugin ${e.where}: ${e.message}`));
429
+ for (const note of await unknownConfigNotes(rt.paths.configFile))
430
+ io.err(c.yellow(`sideby: ${note}`));
429
431
  return 0;
430
432
  }
433
+ /**
434
+ * One line per config key this sideby does not know (ADR-0080), for the commands a person reads: `sideby list` and
435
+ * `sideby doctor`. Never from hooks or `--json` output on stdout.
436
+ */
437
+ async function unknownConfigNotes(file) {
438
+ const read = await readConfig(file).catch(() => null);
439
+ if (!read?.unknownKeys.length)
440
+ return [];
441
+ const { packageVersion } = await import('../core/version.js');
442
+ return read.unknownKeys.map((k) => unknownConfigKeyNote(k, packageVersion()));
443
+ }
431
444
  /**
432
445
  * `new --next` and `new --vendor`: the name (the next one of the Family with `--next`), and a short command from the
433
446
  * same helpers the Panel uses (spec §3.16). A Subscription Account follows the pattern of the Family's aliases
@@ -796,6 +809,8 @@ export async function cmdDoctor(a, io) {
796
809
  const home = rt.paths.home;
797
810
  for (const f of report.fixes)
798
811
  io.out(`${f.ok ? c.green('fixed') : c.red('not fixed')} ${f.account} ${f.item}: ${f.message}`);
812
+ for (const note of await unknownConfigNotes(rt.paths.configFile))
813
+ io.out(`${c.yellow('!')} ${note}`);
799
814
  for (const f of report.general)
800
815
  io.out(`${f.level === 'fail' ? c.red('✗') : c.yellow('!')} ${tilde(f.message, home)}${f.hint ? c.dim(` — ${f.hint}`) : ''}`);
801
816
  for (const acc of report.accounts) {
@@ -4977,6 +4992,106 @@ export async function cmdTrust(a, io) {
4977
4992
  io.out(c.dim('Turning it off keeps what was copied; `sideby trust undo` takes it back.'));
4978
4993
  return 0;
4979
4994
  }
4995
+ /** `sideby memory [status|on|off]` (spec §3.44, ADR-0081): Shared Project Memory between Claude accounts. */
4996
+ export async function cmdMemory(a, io) {
4997
+ const [sub, ...rest] = a.positionals;
4998
+ const asJson = a.flags.has('json');
4999
+ const usage = 'usage: sideby memory [--dir <path>] | sideby memory on|off [--yes]';
5000
+ if (rest.length || a.rest.length || (sub !== undefined && !['status', 'on', 'off'].includes(sub)))
5001
+ throw new UsageError(usage);
5002
+ const status = sub === undefined || sub === 'status';
5003
+ for (const k of a.flags.keys())
5004
+ if (k !== 'json' && !(k === 'dir' && status) && !(k === 'yes' && !status))
5005
+ throw new UsageError(`--${k} does not go with \`sideby memory ${sub ?? ''}\`; ${usage}`);
5006
+ const rt = await createRuntime();
5007
+ const home = rt.paths.home;
5008
+ // Inside text too: a reason names a path in the middle of a sentence.
5009
+ const show = (p) => tilde(p, home);
5010
+ const what = "Every Claude session sideby starts in another account reads and writes the main account's memory for its project, so what one account learned about a project the next one knows. `sideby doctor --fix` moves memory an account wrote on its own (sessions sideby did not start) into the main account.";
5011
+ const offNote = 'Turning it off stops sharing from the next session on; the memory already in the main account stays there.';
5012
+ if (sub === 'on' || sub === 'off') {
5013
+ const r = await rt.memorySet(sub === 'on', { apply: a.flags.has('yes') });
5014
+ if (asJson) {
5015
+ json(io, {
5016
+ action: sub,
5017
+ on: r.applied ? r.after : r.before,
5018
+ changed: r.changed,
5019
+ applied: r.applied,
5020
+ before: r.before,
5021
+ after: r.after,
5022
+ file: show(r.file),
5023
+ });
5024
+ }
5025
+ else if (!r.changed)
5026
+ io.out(`Shared memory was already ${sub}.`);
5027
+ else if (!r.applied) {
5028
+ io.out(`Change to ${show(r.file)}: claude.shareMemory ${r.before} → ${r.after}`);
5029
+ io.out(c.dim(sub === 'on' ? what : offNote));
5030
+ io.out(c.cyan(`Apply it with \`sideby memory ${sub} --yes\`.`));
5031
+ }
5032
+ else {
5033
+ io.out(`${c.green('✓')} Shared memory is ${sub}.`);
5034
+ io.out(c.dim(sub === 'on'
5035
+ ? `${what} Run \`sideby doctor --fix\` to move what your accounts already wrote.`
5036
+ : offNote));
5037
+ }
5038
+ return r.changed && !r.applied ? 10 : 0;
5039
+ }
5040
+ const dirFlag = a.flags.get('dir');
5041
+ if (dirFlag === true)
5042
+ throw new UsageError(`--dir takes a folder; ${usage}`);
5043
+ const dir = typeof dirFlag === 'string' ? resolve(dirFlag) : process.cwd();
5044
+ const st = await rt.memoryStatus(dir);
5045
+ if (asJson) {
5046
+ json(io, {
5047
+ action: 'status',
5048
+ on: st.on,
5049
+ main: show(st.main),
5050
+ folded: st.folded,
5051
+ ...(st.dir
5052
+ ? {
5053
+ dir: {
5054
+ path: show(st.dir.path),
5055
+ ...(st.dir.name ? { name: st.dir.name } : {}),
5056
+ ...(st.dir.memory ? { memory: show(st.dir.memory) } : {}),
5057
+ ...(st.dir.why ? { why: show(st.dir.why) } : {}),
5058
+ },
5059
+ }
5060
+ : {}),
5061
+ ...(st.projects ? { projects: st.projects } : {}),
5062
+ });
5063
+ return 0;
5064
+ }
5065
+ io.out(`Shared memory between Claude accounts: ${st.on ? c.green('on') : c.dim('off')}`);
5066
+ if (!st.on) {
5067
+ io.out(c.dim(what));
5068
+ io.out(c.cyan('Turn it on with `sideby memory on`.'));
5069
+ }
5070
+ else {
5071
+ if (st.dir)
5072
+ io.out(st.dir.memory
5073
+ ? `Folder: ${show(st.dir.path)} → memory in ${show(st.dir.memory)}`
5074
+ : `Folder: ${show(st.dir.path)} → ${c.dim(`keeps each account's own memory (${show(st.dir.why ?? 'sideby cannot tell')})`)}`);
5075
+ const pending = (st.projects ?? []).filter((p) => p.pending.length);
5076
+ const shared = (st.projects ?? []).filter((p) => p.main > 0).length;
5077
+ io.out(`Projects with shared memory: ${shared}${c.dim(` (in ${show(st.main)})`)}`);
5078
+ if (pending.length) {
5079
+ io.out(`Waiting to be moved into the main account (${pending.length}):`);
5080
+ for (const p of pending.slice(0, 20))
5081
+ io.out(` ${p.name} ${c.dim(p.pending.map((x) => `${x.account} ${x.files}`).join(', '))}`);
5082
+ if (pending.length > 20)
5083
+ io.out(c.dim(` … and ${pending.length - 20} more`));
5084
+ io.out(c.cyan('Move them with `sideby doctor --fix`.'));
5085
+ }
5086
+ }
5087
+ if (st.folded.length) {
5088
+ const files = st.folded.reduce((n, f) => n + f.files, 0);
5089
+ io.out(`Moved by Doctor: ${files} ${files === 1 ? 'file' : 'files'} from ${st.folded.length} ${st.folded.length === 1 ? 'project folder' : 'project folders'}`);
5090
+ }
5091
+ if (st.on)
5092
+ io.out(c.dim(offNote));
5093
+ return 0;
5094
+ }
4980
5095
  /** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
4981
5096
  export async function cmdUnattended(a, io) {
4982
5097
  const [sub, ...rest] = a.positionals;
@@ -5139,56 +5254,172 @@ export async function cmdUnattended(a, io) {
5139
5254
  return show(change, change.changed ? said : `It was already set. ${said}`);
5140
5255
  }
5141
5256
  if (sub === 'pending') {
5142
- const { listPendingDecisions, markPendingDone } = await import('../core/unattended-pending.js');
5257
+ const { findPendingDecision, listPendingDecisions, markPendingDone, reopenPendingDecisions } = await import('../core/unattended-pending.js');
5258
+ const { pendingOverview, pendingProjectsNamed } = await import('../core/unattended-followup.js');
5259
+ const { uaGroupByProject } = await import('../panel/page-logic.js');
5143
5260
  const [action, ...args] = rest;
5261
+ const overview = async (all) => pendingOverview({
5262
+ decisions: await listPendingDecisions(paths.stateDir, { all, now: now() }),
5263
+ accounts: await rt.accounts(),
5264
+ stateDir: paths.stateDir,
5265
+ });
5266
+ // `--project <name>`: one Project, as `sideby history --project` reads a name; an unknown or unclear one names
5267
+ // the choices.
5268
+ const projectFlag = a.flags.get('project');
5269
+ if (a.flags.has('project') && (typeof projectFlag !== 'string' || !projectFlag.trim()))
5270
+ throw new UsageError('--project takes a project name, such as --project shop (`sideby unattended pending` shows them)');
5271
+ const projectOf = async (o) => {
5272
+ if (typeof projectFlag !== 'string')
5273
+ return undefined;
5274
+ const hit = await pendingProjectsNamed(o.projects, projectFlag, paths.home);
5275
+ const choices = o.projects
5276
+ .filter((p) => p.project)
5277
+ .map((p) => p.projectName)
5278
+ .join(', ');
5279
+ if (hit.length === 1)
5280
+ return hit[0];
5281
+ throw new UsageError(hit.length
5282
+ ? `"${projectFlag}" names ${hit.length} projects (${hit.map((p) => tildify(p, paths.home)).join(', ')}); give more of its path`
5283
+ : `no project named "${projectFlag}" has a Pending Decision${choices ? `; the projects are: ${choices}` : ''}`);
5284
+ };
5285
+ // `--ids a,b`: whole ids, as `sideby unattended pending` prints them.
5286
+ const idList = () => {
5287
+ if (!a.flags.has('ids'))
5288
+ return undefined;
5289
+ const v = a.flags.get('ids');
5290
+ const list = typeof v === 'string'
5291
+ ? [
5292
+ ...new Set(v
5293
+ .split(',')
5294
+ .map((x) => x.trim())
5295
+ .filter(Boolean)),
5296
+ ]
5297
+ : [];
5298
+ if (!list.length)
5299
+ throw new UsageError('--ids takes ids separated by commas, such as --ids <id>,<id> (`sideby unattended pending` shows them)');
5300
+ return list;
5301
+ };
5302
+ // What is still open afterwards: the full list for --json, else only how many (no session record is read).
5303
+ const left = async (key, ids) => {
5304
+ if (asJson) {
5305
+ const o = await overview(false);
5306
+ json(io, { [key]: ids, pending: o.rows, projects: o.projects });
5307
+ return undefined;
5308
+ }
5309
+ return (await listPendingDecisions(paths.stateDir, { now: now() })).length;
5310
+ };
5144
5311
  if (action === 'done') {
5145
- allow('all');
5312
+ allow('all', 'replied', 'project', 'ids');
5146
5313
  const all = a.flags.has('all');
5147
- if (all === Boolean(args.length) || args.length > 1)
5148
- throw new UsageError('usage: sideby unattended pending done <id> | --all (the id is in `sideby unattended pending`)');
5314
+ const replied = a.flags.has('replied');
5315
+ const byProject = a.flags.has('project');
5316
+ const ids = idList();
5317
+ const usage = 'usage: sideby unattended pending done <id> | --ids <a,b> | --all | --replied [--project <name>] | --project <name> (ids and projects are in `sideby unattended pending`)';
5318
+ const ways = [all, args.length > 0, ids !== undefined, replied || byProject].filter(Boolean).length;
5319
+ if (ways !== 1 || args.length > 1)
5320
+ throw new UsageError(usage);
5149
5321
  let done;
5322
+ let picked = ids;
5323
+ if (replied || byProject) {
5324
+ const o = await overview(false);
5325
+ const project = await projectOf(o);
5326
+ picked = o.rows
5327
+ .filter((r) => (!replied || r.state === 'replied') && (project === undefined || r.project === project))
5328
+ .map((r) => r.id);
5329
+ }
5150
5330
  try {
5151
- done = await markPendingDone(paths.stateDir, all ? 'all' : args[0], now());
5331
+ done =
5332
+ picked === undefined
5333
+ ? await markPendingDone(paths.stateDir, all ? 'all' : args[0], now())
5334
+ : await markPendingDone(paths.stateDir, picked, now());
5152
5335
  }
5153
5336
  catch (err) {
5154
5337
  throw new UserError(err.message, { code: 'no-pending' });
5155
5338
  }
5156
- const pending = await listPendingDecisions(paths.stateDir, { now: now() });
5157
- if (asJson)
5158
- json(io, { done: done.map((d) => d.id), pending });
5339
+ const open = await left('done', done.map((d) => d.id));
5340
+ if (open === undefined)
5341
+ return 0;
5342
+ if (!done.length)
5343
+ io.out(picked === undefined
5344
+ ? `Nothing to mark: it is done already. ${open} still open.`
5345
+ : ids
5346
+ ? `Nothing to mark: those are done already. ${open} still open.`
5347
+ : `Nothing to mark: ${replied ? 'you wrote in the session after none of the open ones' : 'no open decision'}${byProject ? ' in that project' : ''}. ${open} still open.`);
5159
5348
  else
5160
- io.out(`${c.green('✓')} marked ${done.length === 1 ? '1 decision' : `${done.length} decisions`} done; ${pending.length} still open.`);
5349
+ io.out(`${c.green('✓')} marked ${done.length === 1 ? '1 decision' : `${done.length} decisions`} done; ${open} still open. Marked one by mistake? \`sideby unattended pending reopen <id>\` puts it back.`);
5161
5350
  return 0;
5162
5351
  }
5163
- allow('all');
5352
+ if (action === 'reopen') {
5353
+ allow('ids');
5354
+ const ids = idList();
5355
+ if ([args.length > 0, ids !== undefined].filter(Boolean).length !== 1 || args.length > 1)
5356
+ throw new UsageError('usage: sideby unattended pending reopen <id> | --ids <a,b> (`sideby unattended pending --all` lists the done ones too)');
5357
+ let reopened;
5358
+ try {
5359
+ // One id may be a start of it, as with `done`; it is whole when nothing else starts the same way.
5360
+ const one = args[0] && (await findPendingDecision(paths.stateDir, args[0]))?.id;
5361
+ reopened = await reopenPendingDecisions(paths.stateDir, ids ?? [one || args[0]]);
5362
+ }
5363
+ catch (err) {
5364
+ throw new UserError(err.message, { code: 'no-pending' });
5365
+ }
5366
+ const open = await left('reopened', reopened.map((d) => d.id));
5367
+ if (open === undefined)
5368
+ return 0;
5369
+ io.out(reopened.length
5370
+ ? `${c.green('✓')} reopened ${reopened.length === 1 ? '1 decision' : `${reopened.length} decisions`}; ${open} open.`
5371
+ : `Nothing to reopen: ${ids && ids.length > 1 ? 'none of them is' : 'it is not'} marked done. ${open} open.`);
5372
+ return 0;
5373
+ }
5374
+ allow('all', 'project');
5164
5375
  if (action !== undefined)
5165
- throw new UsageError('usage: sideby unattended pending [--all] | pending done <id>|--all');
5166
- const pending = await listPendingDecisions(paths.stateDir, { all: a.flags.has('all'), now: now() });
5376
+ throw new UsageError('usage: sideby unattended pending [--all] [--project <name>] | pending done <id> | --ids <a,b> | --all | --replied [--project <name>] | --project <name> | pending reopen <id> | --ids <a,b>');
5377
+ const o = await overview(a.flags.has('all'));
5378
+ const project = await projectOf(o);
5379
+ const rows = project === undefined ? o.rows : o.rows.filter((r) => r.project === project);
5380
+ const projects = project === undefined ? o.projects : o.projects.filter((p) => p.project === project);
5167
5381
  if (asJson) {
5168
- json(io, { pending });
5382
+ json(io, { pending: rows, projects });
5169
5383
  return 0;
5170
5384
  }
5171
- if (!pending.length) {
5385
+ if (!rows.length) {
5172
5386
  io.out('Nothing is waiting for you.');
5173
5387
  return 0;
5174
5388
  }
5175
- for (const d of pending) {
5176
- const where = [
5177
- d.account ?? d.family,
5178
- d.kind === 'question' ? 'question' : d.kind === 'permission' ? 'needed your OK' : 'left undone',
5179
- d.waited ? `no answer for ${d.waited} min` : '',
5180
- d.agentType ? `subagent ${d.agentType}` : '',
5181
- d.doneAt ? 'done' : '',
5182
- ]
5183
- .filter(Boolean)
5184
- .join(' · ');
5185
- io.out(`${c.bold(d.id)} ${clock2(d.at, now())} ${c.dim(where)}`);
5186
- for (const line of d.text.split('\n'))
5187
- io.out(` ${line}`);
5188
- if (d.sessionId)
5189
- io.out(c.dim(` session ${d.sessionId}${d.cwd ? ` in ${tildify(d.cwd, paths.home)}` : ''}`));
5389
+ const counts = (g) => [
5390
+ g.open ? `${g.open} untouched` : '',
5391
+ g.replied ? `${g.replied} you wrote in afterwards` : '',
5392
+ g.done ? `${g.done} done` : '',
5393
+ ]
5394
+ .filter(Boolean)
5395
+ .join(' · ');
5396
+ for (const g of uaGroupByProject(rows)) {
5397
+ io.out(`${c.bold(g.project ? g.name : 'Other (no folder)')} ${c.dim(counts(g))}`);
5398
+ // Within a Project: what nobody touched first, then what was replied to, then the done ones.
5399
+ const items = g.sessions.flatMap((s) => s.items);
5400
+ const rank = (r) => (r.state === 'open' ? 0 : r.state === 'replied' ? 1 : 2);
5401
+ for (const d of [...items].sort((x, y) => rank(x) - rank(y) || Date.parse(x.at) - Date.parse(y.at))) {
5402
+ const where = [
5403
+ d.account ?? d.family,
5404
+ d.kind === 'question' ? 'question' : d.kind === 'permission' ? 'needed your OK' : 'left undone',
5405
+ d.waited ? `no answer for ${d.waited} min` : '',
5406
+ d.agentType ? `subagent ${d.agentType}` : '',
5407
+ d.state === 'replied' && d.repliedAt
5408
+ ? `you wrote in the session afterwards (${ago(d.repliedAt, now())})`
5409
+ : '',
5410
+ d.replyCheck === 'no-record' ? 'its session record is gone' : '',
5411
+ d.state === 'done' ? 'done' : '',
5412
+ ]
5413
+ .filter(Boolean)
5414
+ .join(' · ');
5415
+ io.out(` ${c.bold(d.id)} ${clock2(d.at, now())} ${c.dim(where)}`);
5416
+ for (const line of d.text.split('\n'))
5417
+ io.out(` ${line}`);
5418
+ if (d.sessionId)
5419
+ io.out(c.dim(` session ${d.sessionId}${d.cwd ? ` in ${tildify(d.cwd, paths.home)}` : ''}`));
5420
+ }
5190
5421
  }
5191
- io.out(c.dim('Mark one done with `sideby unattended pending done <id>`, or all with `--all`.'));
5422
+ io.out(c.dim(`${rows.some((r) => r.state === 'replied') ? '"You wrote in the session afterwards" only says you typed there later, not that it was finished. ' : ''}Mark one done once you have checked it: \`sideby unattended pending done <id>\` (several: \`--ids <a,b>\`); \`reopen <id>\` puts back one marked by mistake.`));
5192
5423
  return 0;
5193
5424
  }
5194
5425
  if (sub === 'defer') {
@@ -30,6 +30,33 @@ const PendingDecision = Type.Object({
30
30
  })),
31
31
  doneAt: Type.Optional(Type.String({ description: 'When it was marked done; ISO.' })),
32
32
  });
33
+ /** One Pending Decision as `sideby unattended pending` lists it: with its Project, state and reply (ADR-0078). */
34
+ const PendingRow = Type.Intersect([
35
+ PendingDecision,
36
+ Type.Object({
37
+ project: Type.String({
38
+ description: 'The Project: the git repository of its folder (a worktree counts as its main repository; a folder that is gone counts as the repository of the nearest folder still there), else the folder itself; "" when it has no folder.',
39
+ }),
40
+ projectName: Type.String({
41
+ description: 'The Project\'s short name, as Session History shows it; "" when it has no folder.',
42
+ }),
43
+ state: Type.Union([Type.Literal('open'), Type.Literal('replied'), Type.Literal('done')], {
44
+ description: 'done: marked done; replied: not marked, and the user typed in its session after it was kept (that does not tell whether it was finished); open: not marked, and nothing typed after it.',
45
+ }),
46
+ repliedAt: Type.Optional(Type.String({ description: 'With `replied`: when the user first typed in the session after it; ISO.' })),
47
+ replyCheck: Type.Optional(Type.Union([Type.Literal('no-record'), Type.Literal('unsupported')], {
48
+ description: 'Why sideby could not tell whether the user typed in the session afterwards: its session record is gone, or sideby reads no session records of this Family. Only on an open one with a session id.',
49
+ })),
50
+ }),
51
+ ]);
52
+ /** One Project's counts in `sideby unattended pending` (ADR-0078). */
53
+ const PendingProject = Type.Object({
54
+ project: Type.String({ description: 'The Project, as in each row; "" for those without a folder.' }),
55
+ projectName: Type.String({ description: 'Its short name; "" for those without a folder.' }),
56
+ open: Type.Integer({ description: 'Open ones nobody typed after.' }),
57
+ replied: Type.Integer({ description: 'Open ones the user typed in their session after.' }),
58
+ done: Type.Integer({ description: 'Done ones (only with --all).' }),
59
+ });
33
60
  /** The menu bar shortcut (`sideby menubar hotkey`, spec §3.31). */
34
61
  const hotkeyProps = {
35
62
  keys: Type.String({
@@ -1514,11 +1541,21 @@ export const OUTPUT_SCHEMAS = {
1514
1541
  }, { title: 'sideby unattended [on|off|schedule …|wait …] --json' }),
1515
1542
  'unattended-pending': Type.Object({
1516
1543
  schemaVersion: Version,
1517
- pending: Type.Array(PendingDecision, {
1518
- description: 'Open Pending Decisions, oldest first; with --all the done ones too.',
1544
+ pending: Type.Array(PendingRow, {
1545
+ description: "Open Pending Decisions, oldest first; with --all the done ones too; with --project only that Project's.",
1519
1546
  }),
1520
- done: Type.Optional(Type.Array(Str, { description: '`pending done`: the ids marked done.' })),
1521
- }, { title: 'sideby unattended pending [done <id>|--all] --json' }),
1547
+ projects: Type.Array(PendingProject, {
1548
+ description: 'Each Project with a listed one, as the Panel orders them: those with an open one first (the newest open one first), then the rest by their newest one, the one without a folder last.',
1549
+ }),
1550
+ done: Type.Optional(Type.Array(Str, {
1551
+ description: '`pending done`: the ids this call marked done (not ones done already).',
1552
+ })),
1553
+ reopened: Type.Optional(Type.Array(Str, {
1554
+ description: '`pending reopen`: the ids this call opened again (not ones open already).',
1555
+ })),
1556
+ }, {
1557
+ title: 'sideby unattended pending [--project <name>] [done <id>|--ids|--all|--replied] [reopen <id>|--ids] --json',
1558
+ }),
1522
1559
  'unattended-defer': Type.Object({ schemaVersion: Version, decision: PendingDecision }, { title: 'sideby unattended defer "<text>" --json' }),
1523
1560
  progress: Type.Object({
1524
1561
  schemaVersion: Version,
@@ -1607,6 +1644,50 @@ export const OUTPUT_SCHEMAS = {
1607
1644
  why: Type.Optional(Type.String()),
1608
1645
  })),
1609
1646
  }, { title: 'sideby trust undo --json' }),
1647
+ memory: Type.Object({
1648
+ schemaVersion: Version,
1649
+ action: Type.Literal('status'),
1650
+ on: Type.Boolean({
1651
+ description: "Config `claude.shareMemory` (spec §3.44): Claude sessions sideby starts in other accounts read and write the main account's memory for their project, and `sideby doctor --fix` moves memory an account wrote on its own into the main account.",
1652
+ }),
1653
+ main: Type.String({ description: "The main account's folder that holds every project's memory." }),
1654
+ folded: Type.Array(Type.Object({
1655
+ account: Type.String({ description: 'The account the memory came from.' }),
1656
+ project: Type.String({ description: 'The project folder name under projects/.' }),
1657
+ files: Type.Number({ description: 'How many files reached the main account.' }),
1658
+ at: Type.String({ description: 'When (ISO time).' }),
1659
+ }), { description: 'What `sideby doctor --fix` moved into the main account, oldest first.' }),
1660
+ dir: Type.Optional(Type.Object({
1661
+ path: Type.String({ description: 'The folder asked about (its real path).' }),
1662
+ name: Type.Optional(Type.String({ description: 'Its project folder name under projects/.' })),
1663
+ memory: Type.Optional(Type.String({ description: 'Where its memory goes for every Claude account sideby starts.' })),
1664
+ why: Type.Optional(Type.String({ description: 'Why sideby cannot tell; such a session keeps its own memory.' })),
1665
+ }, { description: 'Where the memory of the folder asked about goes; only while on.' })),
1666
+ projects: Type.Optional(Type.Array(Type.Object({
1667
+ name: Type.String({ description: 'The project folder name under projects/.' }),
1668
+ main: Type.Number({ description: "Files in the main account's memory folder for it." }),
1669
+ pending: Type.Array(Type.Object({ account: Str, files: Type.Number() }), {
1670
+ description: 'Accounts that keep memory of their own for it: what `sideby doctor --fix` would move.',
1671
+ }),
1672
+ folded: Type.Array(Type.Object({ account: Str, files: Type.Number() }), {
1673
+ description: 'Files `sideby doctor --fix` already moved in, per account.',
1674
+ }),
1675
+ }), {
1676
+ description: 'Each project with memory in the main account or in an account of its own; only while on. Nothing is read while off.',
1677
+ })),
1678
+ }, { title: 'sideby memory [--dir <path>] --json' }),
1679
+ 'memory-set': Type.Object({
1680
+ schemaVersion: Version,
1681
+ action: Type.Union([Type.Literal('on'), Type.Literal('off')]),
1682
+ on: Type.Boolean({ description: 'Whether config `claude.shareMemory` is on now.' }),
1683
+ changed: Type.Boolean(),
1684
+ applied: Type.Boolean({
1685
+ description: 'False when only the change was shown; run again with --yes (exit 10).',
1686
+ }),
1687
+ before: Type.Boolean(),
1688
+ after: Type.Boolean(),
1689
+ file: Type.String({ description: 'The config file changed.' }),
1690
+ }, { title: 'sideby memory on|off --json' }),
1610
1691
  browser: Type.Object({
1611
1692
  schemaVersion: Version,
1612
1693
  enabled: Type.Boolean({
@@ -78,7 +78,8 @@ Exit: the host's exit code.`,
78
78
  Check every account's shared items against the main account, credential file modes (600), backup leftovers,
79
79
  and whether the installed sideby skill matches this version.
80
80
 
81
- --fix repair what is safe: add missing links, refresh copies, chmod 600, sync MCP servers
81
+ --fix repair what is safe: add missing links, refresh copies, chmod 600, sync MCP servers; with shared
82
+ memory on (sideby memory), move memory an account wrote on its own into the main account
82
83
  --force with --fix, also let a synced MCP list (json-key) drop entries the account has
83
84
 
84
85
  --fix never replaces a real file with a link and never changes where an existing link points; those are
@@ -346,14 +347,16 @@ no country allowed; 2 malformed command line.`,
346
347
  sideby unattended schedule [add --days <days> --from HH:MM --to HH:MM [--name <name>] [--at <n>]] [--json]
347
348
  sideby unattended schedule remove <n> | preset weeknights [--json]
348
349
  sideby unattended wait [<minutes>|off] [--json]
349
- sideby unattended pending [--all] [--json]
350
- sideby unattended pending done <id> | --all [--json]
350
+ sideby unattended pending [--all] [--project <name>] [--json]
351
+ sideby unattended pending done <id> | --ids <a,b> | --all | --replied [--project <name>] | --project <name> [--json]
352
+ sideby unattended pending reopen <id> | --ids <a,b> [--json]
351
353
  sideby unattended defer "<text>" [--json]
352
354
 
353
355
  Unattended Mode: nobody is at the computer, so sessions sideby starts never stop to wait for a person. While it is on,
354
356
  a Claude or Codex session sideby started is not allowed to ask a question: the model takes the recommended option
355
- where it can be undone, and skips anything hard to undo (deleting, sending, publishing, deploying, paying). Each
356
- question it could not ask, and each thing it skipped (\`defer\`), is kept as a Pending Decision for when you are back.
357
+ where it can be undone, and skips anything hard to undo (deleting, sending, publishing, deploying, paying) unless
358
+ your own rules or project docs give standing permission for that kind of action. Each question it could not ask, and
359
+ each thing it skipped (\`defer\`), is kept as a Pending Decision for when you are back.
357
360
  In Claude sessions, a permission prompt Claude Code is about to show (a command it wants a person to confirm, also in
358
361
  a subagent) is answered with "no" and how to do it without one, and kept as a Pending Decision too. A Claude turn
359
362
  that failed for a passing reason (an overloaded server, a dropped connection, a rate limit that is not a used-up
@@ -376,6 +379,13 @@ written into the account folders). Codex runs the hooks once you trust both \`un
376
379
  Grok, pi, desktop apps and sessions started without sideby are not covered. Pending Decisions stay on this computer;
377
380
  \`pending done\` marks them done, and they are deleted 30 days later. \`defer\` keeps a line from inside a session ("deploy left for the user").
378
381
 
382
+ \`pending\` lists them by project (the repository of the folder the session worked in; a worktree counts as its
383
+ repository), untouched ones first. "You wrote in the session afterwards" means you typed in that session after it
384
+ was kept, read from the session's own record (Claude and Codex); it does not tell whether that finished it, so look
385
+ at each one before marking it done. \`done <id>\` or \`--ids <a,b>\` marks the ones you checked; \`--replied\` marks
386
+ every one you wrote in afterwards, \`--project <name>\` keeps to one project, and \`done --project <name>\` marks a
387
+ whole project. \`reopen\` puts back one marked done by mistake.
388
+
379
389
  --days takes mon…sun, ranges and lists: mon-fri, sat,sun, fri-mon, weekdays, daily. Each change prints its undo.
380
390
 
381
391
  Examples:
@@ -384,6 +394,8 @@ Examples:
384
394
  sideby unattended schedule add --days sat,sun --from 01:00 --to 09:00 --name "Weekend nights"
385
395
  sideby unattended wait 30
386
396
  sideby unattended pending
397
+ sideby unattended pending --project shop
398
+ sideby unattended pending reopen <id>
387
399
  sideby unattended defer "deleting the old branch is left for the user"
388
400
  Exit: 0 shown or done; 1 no such Slot or Pending Decision; 2 a time or option it does not take (the message says
389
401
  which to use).`,
@@ -433,6 +445,33 @@ Examples:
433
445
  sideby trust undo
434
446
  Exit: 0 shown or done; 10 a change was shown and waits for --yes; 1 undo left a mark it could not change (the line
435
447
  says why); 2 malformed command line.`,
448
+ memory: `sideby memory [--dir <path>] [--json]
449
+ sideby memory on|off [--yes] [--json]
450
+
451
+ Share Claude's project memory between your Claude accounts. Claude Code keeps what it learns about a project (auto
452
+ memory) per account, so a second account starts without it. With this on, every interactive Claude session sideby
453
+ starts in an account other than the main one (sideby run, short commands, pick commands, next, Auto Handoff, AI
454
+ Tasks, Unattended Mode) reads and writes the main account's memory for that project
455
+ (~/.claude/projects/<project>/memory): sideby passes that folder as autoMemoryDirectory in its own --settings file.
456
+ The project is the git repository's main checkout (a linked worktree and every subfolder share it), elsewhere the
457
+ folder itself, as Claude Code names it; sideby never runs git in the folder.
458
+
459
+ Memory an account wrote on its own (a session started with plain claude, or by an app) stays in that account until
460
+ \`sideby doctor --fix\` moves it into the main account: a project the main account lacks moves whole; a file that
461
+ differs is kept beside the main one as <name>.<account>.md; MEMORY.md gets the lines it lacks; the emptied folder goes
462
+ to the trash. A project where a session of that account is running waits until it ends.
463
+
464
+ Without a subcommand: whether it is on, what Doctor moved, and, while on, where this folder's memory goes (--dir,
465
+ default the current one) and which projects still wait to be moved; nothing of the account folders is read while it
466
+ is off. \`on\` and \`off\` change config claude.shareMemory; each shows the change first and makes it with --yes.
467
+ Turning it off stops passing the folder; the memory already in the main account stays there. A headless run (-p),
468
+ the main account itself and a session given its own --settings keep their own memory (the launch says so).
469
+
470
+ Examples:
471
+ sideby memory on --yes
472
+ sideby memory --dir ~/code/app
473
+ sideby doctor claude --fix
474
+ Exit: 0 shown or done; 10 a change was shown and waits for --yes; 2 malformed command line.`,
436
475
  browser: `sideby browser [--enable|--disable] [--yes] [--json]
437
476
  sideby browser open <account> [--profile <folder|name>] [--json]
438
477
  sideby browser set <account> <folder|name> [--json]
@@ -529,11 +568,12 @@ const COMMANDS = {
529
568
  next: { flags: ['dry-run', 'include-api', 'json', 'ignore-network', 'unattended'] },
530
569
  network: { flags: ['json', 'yes'] },
531
570
  unattended: {
532
- flags: ['json', 'all', 'slot-end'],
533
- valued: ['for', 'until', 'days', 'from', 'to', 'name', 'at'],
571
+ flags: ['json', 'all', 'slot-end', 'replied'],
572
+ valued: ['for', 'until', 'days', 'from', 'to', 'name', 'at', 'project', 'ids'],
534
573
  },
535
574
  progress: { flags: ['json'], valued: ['every'] },
536
575
  trust: { flags: ['json', 'yes'], valued: ['dir'] },
576
+ memory: { flags: ['json', 'yes'], valued: ['dir'] },
537
577
  new: { flags: ['api', 'json', 'next'], valued: ['alias', 'vendor'] },
538
578
  alias: { flags: ['json', 'yes'], valued: ['pick'] },
539
579
  doctor: { flags: ['fix', 'force', 'json'] },
@@ -871,6 +911,8 @@ async function dispatch(cmd, parsed, io, cmds) {
871
911
  return await cmds.cmdProgress(parsed, io);
872
912
  case 'trust':
873
913
  return await cmds.cmdTrust(parsed, io);
914
+ case 'memory':
915
+ return await cmds.cmdMemory(parsed, io);
874
916
  case 'shell-init':
875
917
  return await cmds.cmdShellInit(parsed, io);
876
918
  case 'plugins':