sideby 0.41.3 → 0.42.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 (36) 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 +100 -0
  4. package/dist/src/cli/json-schemas.js +56 -1
  5. package/dist/src/cli/main.js +32 -1
  6. package/dist/src/core/claude-memory.d.ts +252 -0
  7. package/dist/src/core/claude-memory.js +1015 -0
  8. package/dist/src/core/cli-commands.js +15 -2
  9. package/dist/src/core/config.d.ts +1 -0
  10. package/dist/src/core/config.js +4 -1
  11. package/dist/src/core/doctor.d.ts +2 -1
  12. package/dist/src/core/search-catalog.js +22 -0
  13. package/dist/src/core/session-hooks.d.ts +12 -2
  14. package/dist/src/core/session-hooks.js +12 -8
  15. package/dist/src/families/claude/layout.d.ts +7 -0
  16. package/dist/src/families/claude/layout.js +17 -0
  17. package/dist/src/families/claude/live-sessions.d.ts +9 -0
  18. package/dist/src/families/claude/live-sessions.js +17 -8
  19. package/dist/src/panel/handler.d.ts +11 -0
  20. package/dist/src/panel/handler.js +21 -0
  21. package/dist/src/panel/i18n.d.ts +27 -0
  22. package/dist/src/panel/i18n.js +54 -0
  23. package/dist/src/panel/page-logic.d.ts +12 -0
  24. package/dist/src/panel/page-logic.js +24 -0
  25. package/dist/src/panel/page-script.js +47 -6
  26. package/dist/src/panel/page-styles.js +1 -0
  27. package/dist/src/runtime.d.ts +30 -0
  28. package/dist/src/runtime.js +90 -1
  29. package/dist/src/types.d.ts +6 -0
  30. package/package.json +1 -1
  31. package/schemas/config.json +5 -1
  32. package/schemas/doctor.json +48 -0
  33. package/schemas/memory-set.json +117 -0
  34. package/schemas/memory.json +210 -0
  35. package/skills/sideby/SKILL.md +2 -1
  36. package/skills/sideby/references/sharing.md +23 -1
@@ -111,6 +111,18 @@ export const CLI_COMMANDS = [
111
111
  example: 'sideby trust on',
112
112
  feature: 'setting.trust',
113
113
  },
114
+ {
115
+ id: 'memory',
116
+ group: 'accounts',
117
+ usage: 'sideby memory [on|off] [--dir <path>] [--yes]',
118
+ help: "let every Claude account use the main account's memory of a project: sessions sideby starts read and write it, and doctor --fix moves memory an account wrote on its own into the main account (on|off, shows the change first)",
119
+ summary: {
120
+ en: 'Let every Claude account remember what the others learned about a project',
121
+ zh: '让每个 Claude 账号记得其他账号对项目学到的东西',
122
+ },
123
+ example: 'sideby memory on',
124
+ feature: 'setting.memory',
125
+ },
114
126
  {
115
127
  id: 'edit',
116
128
  group: 'accounts',
@@ -890,9 +902,10 @@ export function cliHelp(list = CLI_COMMANDS) {
890
902
  const HELP_TAIL = `Options:
891
903
  --json machine-readable output (list, new, next, alias, doctor, quota, tune, model, advisor, remote-control, handoff,
892
904
  families, commands, plugins, app, desktop, sessions, history, send, messages, edit, browser, update, local, ask,
893
- terminal, key, try, autostart, menubar, config, network, unattended, progress, trust)
905
+ terminal, key, try, autostart, menubar, config, network, unattended, progress, trust, memory)
894
906
  -h, --help show this help; \`sideby <command> --help\` for new, alias, login, doctor, families, commands, desktop, edit, browser,
895
- autostart, menubar, config, sessions, history, send, messages, network, unattended, progress, trust
907
+ autostart, menubar, config, sessions, history, send, messages, network, unattended, progress, trust,
908
+ memory
896
909
  -v, --version show the version
897
910
 
898
911
  An <account> is <family>:<name> (claude:work) or just <name> when it is unique.
@@ -124,6 +124,7 @@ export declare const ConfigSchema: Type.TObject<{
124
124
  claude: Type.TOptional<Type.TObject<{
125
125
  apiBetasOff: Type.TOptional<Type.TBoolean>;
126
126
  carryTrust: Type.TOptional<Type.TBoolean>;
127
+ shareMemory: Type.TOptional<Type.TBoolean>;
127
128
  }>>;
128
129
  unattended: Type.TOptional<Type.TObject<{
129
130
  schedule: Type.TOptional<Type.TArray<Type.TObject<{
@@ -253,9 +253,12 @@ export const ConfigSchema = Type.Object({
253
253
  carryTrust: Type.Optional(Type.Boolean({
254
254
  description: 'Carry folder trust between Claude accounts (spec §3.43, ADR-0078): before sideby starts an interactive Claude session in a folder this account has not trusted yet, when another Claude account of yours already trusts it (the folder, a parent folder outside any git repository, or the repository\'s main checkout), sideby copies that one trust mark (`projects["<path>"].hasTrustDialogAccepted`) into this account\'s `.claude.json`, so Claude Code does not ask again. It never adds trust no account gave. Off by default; turning it off does not remove marks already copied (`sideby trust undo` does).',
255
255
  })),
256
+ shareMemory: Type.Optional(Type.Boolean({
257
+ description: "Shared Project Memory (spec §3.44, ADR-0081): every interactive Claude session sideby starts in an account other than the main one reads and writes the main account's auto memory for its project (`~/.claude/projects/<project>/memory`, passed as `autoMemoryDirectory` through sideby's `--settings`), and `sideby doctor --fix` moves memory an account wrote on its own into the main account. Off by default; turning it off stops passing the folder and leaves the memory where it is.",
258
+ })),
256
259
  }, {
257
260
  additionalProperties: false,
258
- description: 'Claude Code launches (spec §3.41, ADR-0074; `carryTrust`: spec §3.43, ADR-0078).',
261
+ description: 'Claude Code launches (spec §3.41, ADR-0074; `carryTrust`: spec §3.43, ADR-0078; `shareMemory`: spec §3.44, ADR-0081).',
259
262
  })),
260
263
  unattended: Type.Optional(Type.Object({
261
264
  schedule: Type.Optional(Type.Array(UnattendedSlotSchema, {
@@ -1,5 +1,5 @@
1
1
  import type { HookBus } from '../plugins/bus.ts';
2
- import type { Account, CheckResult, FamilyDef, Finding, LoginProblem } from '../types.ts';
2
+ import type { Account, CheckResult, FamilyDef, Finding, FindingParams, LoginProblem } from '../types.ts';
3
3
  export interface AccountReport {
4
4
  ref: string;
5
5
  family: string;
@@ -19,6 +19,7 @@ export interface FixOutcome {
19
19
  code: string;
20
20
  ok: boolean;
21
21
  message: string;
22
+ params?: FindingParams;
22
23
  }
23
24
  export interface DoctorReport {
24
25
  status: 'ok' | 'issues';
@@ -228,6 +228,28 @@ const ENTRIES = [
228
228
  target: { settings: 'trust', find: 'trust' },
229
229
  cliCommand: 'sideby trust',
230
230
  },
231
+ {
232
+ id: 'setting.memory',
233
+ kind: 'setting',
234
+ title: { en: 'Shared memory', zh: '共享记忆' },
235
+ synonyms: [
236
+ 'memory',
237
+ 'auto memory',
238
+ 'project memory',
239
+ 'shared memory',
240
+ 'remember',
241
+ 'MEMORY.md',
242
+ 'autoMemoryDirectory',
243
+ '记忆',
244
+ '项目记忆',
245
+ '共享项目记忆',
246
+ '自动记忆',
247
+ '记不住',
248
+ ],
249
+ panel: at(SET, { en: 'Shared memory', zh: '共享记忆' }),
250
+ target: { settings: 'memory', find: 'memory' },
251
+ cliCommand: 'sideby memory',
252
+ },
231
253
  {
232
254
  id: 'setting.quota-checks',
233
255
  kind: 'setting',
@@ -7,6 +7,13 @@ export interface SessionHookPart {
7
7
  claude: ClaudeHooks;
8
8
  /** Per Codex event, the inline TOML tables of its list, such as `{matcher="…",hooks=[{type="command",command="…"}]}`. */
9
9
  codex: Record<string, string[]>;
10
+ /**
11
+ * Other top-level Claude settings it adds to the same file, such as `autoMemoryDirectory` (Shared Project Memory,
12
+ * ADR-0081). Claude only.
13
+ */
14
+ settings?: Record<string, unknown>;
15
+ /** Added to the file's name when `settings` differ per Launch, so two Launches never share one file. */
16
+ fileKey?: string;
10
17
  }
11
18
  /**
12
19
  * The command a Host runs for a hook entry: this Node and this sideby by absolute path, never `sideby` by name. A
@@ -30,7 +37,9 @@ export declare function sessionHookArgs(family: string, stateDir: string, parts:
30
37
  * Auto Handoff's Claude hook arguments with `extra` hooks added to its `--settings` file, written as `out` (Claude
31
38
  * Code takes one `--settings`). Auto Handoff's own hooks and options come first and are kept as they are.
32
39
  */
33
- export declare function withClaudeHooks(hookArgs: readonly string[], extra: ClaudeHooks, out: string): Promise<string[]>;
40
+ export declare function withClaudeHooks(hookArgs: readonly string[], extra: ClaudeHooks, out: string,
41
+ /** Other top-level settings to add, such as the session's `autoMemoryDirectory` (ADR-0081). */
42
+ more?: Record<string, unknown>): Promise<string[]>;
34
43
  /**
35
44
  * Claude `--settings` arguments with `dirs` added to the file's `permissions.additionalDirectories`, written as `out`.
36
45
  * Claude Code 2.1.326 asks the user to trust every `--add-dir` folder it has not seen before the session starts, and
@@ -40,6 +49,7 @@ export declare function withClaudeHooks(hookArgs: readonly string[], extra: Clau
40
49
  export declare function withClaudeDirs(args: readonly string[], dirs: readonly string[], out: string): Promise<string[]>;
41
50
  /**
42
51
  * Auto Handoff's Claude hook arguments with the session's own sideby hooks (`sessionArgs`, from `sessionHookArgs`)
43
- * merged into one `--settings` file, written next to the session's file with `-handoff` added to its name.
52
+ * merged into one `--settings` file, written next to the session's file with `-handoff` added to its name. The
53
+ * session file's other settings (`autoMemoryDirectory`, ADR-0081) come along.
44
54
  */
45
55
  export declare function withClaudeSessionHooks(hookArgs: readonly string[], sessionArgs: readonly string[]): Promise<string[]>;
@@ -51,11 +51,12 @@ export async function sessionHookArgs(family, stateDir, parts) {
51
51
  // A real folder of the user that nobody else can write to, so the file is never written through a link.
52
52
  const dir = (await ownedFolder(stateDir, [parts[0].id], { create: true, private: true }));
53
53
  const name = `claude-settings${parts
54
- .slice(1)
55
- .map((p) => `-${p.id}`)
54
+ .map((p, i) => `${i ? `-${p.id}` : ''}${p.fileKey ? `-${p.fileKey}` : ''}`)
56
55
  .join('')}.json`;
57
56
  const hooks = mergeClaudeHooks(...parts.map((p) => p.claude));
58
- await writeFileAtomic(join(dir, name), `${JSON.stringify({ hooks }, null, 2)}\n`, 0o600);
57
+ const settings = Object.assign({}, ...parts.map((p) => p.settings ?? {}));
58
+ const body = { ...(Object.keys(hooks).length ? { hooks } : {}), ...settings };
59
+ await writeFileAtomic(join(dir, name), `${JSON.stringify(body, null, 2)}\n`, 0o600);
59
60
  return ['--settings', join(dir, name)];
60
61
  }
61
62
  if (family === 'codex') {
@@ -84,11 +85,13 @@ async function settingsOf(args) {
84
85
  * Auto Handoff's Claude hook arguments with `extra` hooks added to its `--settings` file, written as `out` (Claude
85
86
  * Code takes one `--settings`). Auto Handoff's own hooks and options come first and are kept as they are.
86
87
  */
87
- export async function withClaudeHooks(hookArgs, extra, out) {
88
+ export async function withClaudeHooks(hookArgs, extra, out,
89
+ /** Other top-level settings to add, such as the session's `autoMemoryDirectory` (ADR-0081). */
90
+ more = {}) {
88
91
  const settings = await settingsOf(hookArgs);
89
92
  const hooks = mergeClaudeHooks(settings.hooks ?? {}, extra);
90
93
  await mkdir(dirname(out), { recursive: true, mode: 0o700 });
91
- await writeFileAtomic(out, `${JSON.stringify({ ...settings, hooks }, null, 2)}\n`, 0o600);
94
+ await writeFileAtomic(out, `${JSON.stringify({ ...settings, ...more, hooks }, null, 2)}\n`, 0o600);
92
95
  const at = hookArgs.indexOf('--settings');
93
96
  return at === -1 ? [...hookArgs, '--settings', out] : hookArgs.map((a, i) => (i === at + 1 ? out : a));
94
97
  }
@@ -121,13 +124,14 @@ export async function withClaudeDirs(args, dirs, out) {
121
124
  }
122
125
  /**
123
126
  * Auto Handoff's Claude hook arguments with the session's own sideby hooks (`sessionArgs`, from `sessionHookArgs`)
124
- * merged into one `--settings` file, written next to the session's file with `-handoff` added to its name.
127
+ * merged into one `--settings` file, written next to the session's file with `-handoff` added to its name. The
128
+ * session file's other settings (`autoMemoryDirectory`, ADR-0081) come along.
125
129
  */
126
130
  export async function withClaudeSessionHooks(hookArgs, sessionArgs) {
127
131
  const at = sessionArgs.indexOf('--settings');
128
132
  const file = at === -1 ? undefined : sessionArgs[at + 1];
129
133
  if (!file)
130
134
  return [...hookArgs];
131
- const extra = (await settingsOf(sessionArgs)).hooks ?? {};
132
- return withClaudeHooks(hookArgs, extra, join(dirname(file), `${basename(file, '.json')}-handoff.json`));
135
+ const { hooks: extra = {}, ...more } = await settingsOf(sessionArgs);
136
+ return withClaudeHooks(hookArgs, extra, join(dirname(file), `${basename(file, '.json')}-handoff.json`), more);
133
137
  }
@@ -4,3 +4,10 @@ export declare const CLAUDE_LAYOUT: {
4
4
  main: string;
5
5
  account: string;
6
6
  };
7
+ /**
8
+ * The folder Claude Code keeps a path's sessions and memory in under `projects/`: every character that is not an
9
+ * ASCII letter or digit becomes `-`; a name longer than 200 characters is cut there and gets `-` and a base-36 hash
10
+ * of the whole path (the 32-bit `(h << 5) - h + c` string hash, UTF-16 units). Read from Claude Code 2.1.328 on
11
+ * 2026-11-20 (ADR-0081).
12
+ */
13
+ export declare function claudeProjectDirName(path: string): string;
@@ -3,3 +3,20 @@
3
3
  export const CLAUDE_MAIN_DIR = '.claude';
4
4
  export const CLAUDE_ACCOUNT_PREFIX = '.claude-';
5
5
  export const CLAUDE_LAYOUT = { main: CLAUDE_MAIN_DIR, account: `${CLAUDE_ACCOUNT_PREFIX}<name>` };
6
+ /** The longest folder name Claude Code keeps under `projects/` before it shortens one and adds a hash. */
7
+ const PROJECT_NAME_MAX = 200;
8
+ /**
9
+ * The folder Claude Code keeps a path's sessions and memory in under `projects/`: every character that is not an
10
+ * ASCII letter or digit becomes `-`; a name longer than 200 characters is cut there and gets `-` and a base-36 hash
11
+ * of the whole path (the 32-bit `(h << 5) - h + c` string hash, UTF-16 units). Read from Claude Code 2.1.328 on
12
+ * 2026-11-20 (ADR-0081).
13
+ */
14
+ export function claudeProjectDirName(path) {
15
+ const name = path.replace(/[^a-zA-Z0-9]/g, '-');
16
+ if (name.length <= PROJECT_NAME_MAX)
17
+ return name;
18
+ let h = 0;
19
+ for (let i = 0; i < path.length; i++)
20
+ h = ((h << 5) - h + path.charCodeAt(i)) | 0;
21
+ return `${name.slice(0, PROJECT_NAME_MAX)}-${Math.abs(h).toString(36)}`;
22
+ }
@@ -1,5 +1,6 @@
1
1
  import type { LiveSessionStatus } from '../../core/live-sessions.ts';
2
2
  import type { LiveSessionReader } from '../live-sessions.ts';
3
+ import { type SessionRecord } from './session-files.ts';
3
4
  /** Claude Code's `status`: `busy` and `shell` run, `idle` waits for a prompt, a blocked one waits for the user. */
4
5
  export declare function claudeStatus(s: unknown): LiveSessionStatus;
5
6
  /**
@@ -17,4 +18,12 @@ export declare const claudeTranscript: (dir: string, cwd: string, id: string) =>
17
18
  * into a result. Remembered until the file changes.
18
19
  */
19
20
  export declare function claudeAiTitle(transcript: string): Promise<string | undefined>;
21
+ /**
22
+ * A running session's transcript (when it is there) and the title sideby shows for it: a name the user gave (`/rename`,
23
+ * `-n`), else Claude Code's own title, else a derived name (`<dir>-3f`), else the folder's name. Never throws.
24
+ */
25
+ export declare function claudeSessionTitle(accountDir: string, rec: SessionRecord, sessionId: string): Promise<{
26
+ title?: string;
27
+ transcript?: string;
28
+ }>;
20
29
  export declare const claudeLiveSessions: LiveSessionReader;
@@ -5,7 +5,8 @@ import { readdir } from 'node:fs/promises';
5
5
  import { basename, join } from 'node:path';
6
6
  import { statOrNull } from '../../core/fs-safe.js';
7
7
  import { isoOf } from '../../core/live-sessions-procs.js';
8
- import { readSessionRecord, recordRunsOn, recordStart, tailLinesWith } from './session-files.js';
8
+ import { claudeProjectDirName } from './layout.js';
9
+ import { readSessionRecord, recordRunsOn, recordStart, tailLinesWith, } from './session-files.js';
9
10
  const PID_FILE = /^(\d+)\.json$/;
10
11
  /** Claude Code's `status`: `busy` and `shell` run, `idle` waits for a prompt, a blocked one waits for the user. */
11
12
  export function claudeStatus(s) {
@@ -38,7 +39,7 @@ export function claudeStartedFrom(v) {
38
39
  const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
39
40
  const str = (v) => (typeof v === 'string' && v ? v : undefined);
40
41
  /** The transcript Claude Code writes for a session: `projects/<cwd with every other character as ->/<id>.jsonl`. */
41
- export const claudeTranscript = (dir, cwd, id) => join(dir, 'projects', cwd.replace(/[^a-zA-Z0-9]/g, '-'), `${id}.jsonl`);
42
+ export const claudeTranscript = (dir, cwd, id) => join(dir, 'projects', claudeProjectDirName(cwd), `${id}.jsonl`);
42
43
  const titleMemo = new Map();
43
44
  /**
44
45
  * The title Claude Code gave the session itself (the one it shows as the terminal tab title): the last `ai-title`
@@ -68,6 +69,19 @@ export async function claudeAiTitle(transcript) {
68
69
  titleMemo.set(transcript, { sig, title });
69
70
  return title;
70
71
  }
72
+ /**
73
+ * A running session's transcript (when it is there) and the title sideby shows for it: a name the user gave (`/rename`,
74
+ * `-n`), else Claude Code's own title, else a derived name (`<dir>-3f`), else the folder's name. Never throws.
75
+ */
76
+ export async function claudeSessionTitle(accountDir, rec, sessionId) {
77
+ const cwd = str(rec.cwd);
78
+ const candidate = cwd ? claudeTranscript(accountDir, cwd, sessionId) : undefined;
79
+ const transcript = candidate && (await statOrNull(candidate).catch(() => null)) ? candidate : undefined;
80
+ const named = rec.nameSource !== 'derived' ? str(rec.name) : undefined;
81
+ const aiTitle = named || !transcript ? undefined : await claudeAiTitle(transcript).catch(() => undefined);
82
+ const title = named ?? aiTitle ?? str(rec.name) ?? (cwd ? basename(cwd) : undefined);
83
+ return { ...(title ? { title } : {}), ...(transcript ? { transcript } : {}) };
84
+ }
71
85
  export const claudeLiveSessions = {
72
86
  family: 'claude',
73
87
  async read(account, procs, problems) {
@@ -108,12 +122,7 @@ export const claudeLiveSessions = {
108
122
  if (!recordRunsOn(rec, proc))
109
123
  continue;
110
124
  const cwd = str(rec.cwd);
111
- const candidate = cwd ? claudeTranscript(account.dir, cwd, sessionId) : undefined;
112
- const transcript = candidate && (await statOrNull(candidate)) ? candidate : undefined;
113
- // A name the user gave (`/rename`, `-n`) wins; a derived one (`<dir>-3f`) loses to Claude Code's own title.
114
- const named = rec.nameSource !== 'derived' ? str(rec.name) : undefined;
115
- const aiTitle = named || !transcript ? undefined : await claudeAiTitle(transcript).catch(() => undefined);
116
- const title = named ?? aiTitle ?? str(rec.name) ?? (cwd ? basename(cwd) : undefined);
125
+ const { title, transcript } = await claudeSessionTitle(account.dir, rec, sessionId);
117
126
  const startedFrom = claudeStartedFrom(rec.entrypoint);
118
127
  out.push({
119
128
  sessionId,
@@ -309,6 +309,12 @@ export interface PanelState {
309
309
  * `.claude.json` is read for it); absent with fewer than two Claude Accounts, unless it is on or has marks.
310
310
  */
311
311
  trust?: PanelTrust;
312
+ /**
313
+ * Shared Project Memory (spec §3.44): config `claude.shareMemory` and how many files Doctor moved into the Main Account,
314
+ * from the config and sideby's own records (no Account folder is read for it); absent with fewer than two Claude
315
+ * Accounts, unless it is on or Doctor moved something.
316
+ */
317
+ memory?: PanelMemory;
312
318
  }
313
319
  export interface PanelTrust {
314
320
  on: boolean;
@@ -319,6 +325,11 @@ export interface PanelTrust {
319
325
  at: string;
320
326
  }[];
321
327
  }
328
+ export interface PanelMemory {
329
+ on: boolean;
330
+ /** Files Doctor moved into the Main Account so far. */
331
+ folded: number;
332
+ }
322
333
  /**
323
334
  * One Pending Decision as the Panel's Unattended page lists it, with its Project, state and reply (ADR-0078; `project`
324
335
  * and `cwd` shortened with `~`) and the way back to its Session.
@@ -652,6 +652,7 @@ async function buildState(rt, opts) {
652
652
  const showBrowser = browser && (browser.families.matched.length || browser.families.openOnly.length);
653
653
  const progress = accounts.some((a) => PROGRESS_FAMILIES.includes(a.family)) ? rt.progressView() : undefined;
654
654
  const trust = await panelTrust(rt, accounts).catch(() => undefined);
655
+ const memory = await panelMemory(rt, accounts).catch(() => undefined);
655
656
  const permissions = aiTaskPermissions(rt.config);
656
657
  return {
657
658
  schemaVersion: 1,
@@ -701,8 +702,16 @@ async function buildState(rt, opts) {
701
702
  ...(unattended ? { unattended } : {}),
702
703
  ...(progress ? { progress } : {}),
703
704
  ...(trust ? { trust } : {}),
705
+ ...(memory ? { memory } : {}),
704
706
  };
705
707
  }
708
+ /** The Panel's view of Shared Project Memory (spec §3.44), or undefined when there is nothing to show. */
709
+ async function panelMemory(rt, accounts) {
710
+ const st = await rt.memoryOverview();
711
+ if (accounts.filter((a) => a.family === 'claude').length < 2 && !st.on && !st.folded.length)
712
+ return undefined;
713
+ return { on: st.on, folded: st.folded.reduce((n, f) => n + f.files, 0) };
714
+ }
706
715
  /** The Panel's view of carried trust (spec §3.43), or undefined when there is nothing to show. */
707
716
  async function panelTrust(rt, accounts) {
708
717
  const st = await rt.trustStatus();
@@ -1528,6 +1537,18 @@ export function createPanelHandler(opts) {
1528
1537
  return { ...r, file: tildify(r.file, rt.paths.home) };
1529
1538
  },
1530
1539
  },
1540
+ // Shared Project Memory (spec §3.44, ADR-0081): config `claude.shareMemory`, shown first like every config change;
1541
+ // the switch sends `confirm` with the words it shows beside it.
1542
+ '/api/memory/settings': {
1543
+ writes: (body) => body.confirm === true,
1544
+ async run(body) {
1545
+ if (typeof body.on !== 'boolean')
1546
+ throw new HttpError(400, '"on" must be true or false');
1547
+ const rt = await getRuntime();
1548
+ const r = await rt.memorySet(body.on, { apply: optBool(body, 'confirm') });
1549
+ return { ...r, file: tildify(r.file, rt.paths.home) };
1550
+ },
1551
+ },
1531
1552
  // Takes back the trust marks sideby copied (`sideby trust undo`): without `confirm` what it would do, with it done.
1532
1553
  '/api/trust/undo': {
1533
1554
  writes: (body) => body.confirm === true,
@@ -432,6 +432,21 @@ declare const en: {
432
432
  'finding.extra-check.error': string;
433
433
  'finding.fixHint': string;
434
434
  'finding.raw': string;
435
+ 'finding.memory.unfolded.one': string;
436
+ 'finding.memory.unfolded.other': string;
437
+ 'finding.memory.unfolded.some': string;
438
+ 'finding.memory.unfolded.waiting.one': string;
439
+ 'finding.memory.unfolded.waiting.other': string;
440
+ 'finding.memory.unfolded.unknown.one': string;
441
+ 'finding.memory.unfolded.unknown.other': string;
442
+ 'finding.memory.link': string;
443
+ 'finding.memory.index.one': string;
444
+ 'finding.memory.index.other': string;
445
+ 'finding.memory.name-mismatch': string;
446
+ 'fixres.memory.unfolded.unknown': string;
447
+ 'fixres.memory.unfolded.waiting': string;
448
+ 'fixres.memory.unfolded.some.one': string;
449
+ 'fixres.memory.unfolded.some.other': string;
435
450
  'win.5h': string;
436
451
  'win.7d': string;
437
452
  'win.5h.short': string;
@@ -1818,6 +1833,18 @@ declare const en: {
1818
1833
  'tr.onToast': string;
1819
1834
  'tr.offToast': string;
1820
1835
  'tr.failed': string;
1836
+ 'ai.ask.memory': string;
1837
+ 'mm.title': string;
1838
+ 'mm.hint': string;
1839
+ 'mm.switch': string;
1840
+ 'mm.what': string;
1841
+ 'mm.doctor': string;
1842
+ 'mm.offKeeps': string;
1843
+ 'mm.folded.one': string;
1844
+ 'mm.folded.other': string;
1845
+ 'mm.onToast': string;
1846
+ 'mm.offToast': string;
1847
+ 'mm.failed': string;
1821
1848
  };
1822
1849
  export type MessageKey = keyof typeof en;
1823
1850
  export declare const MESSAGES: Record<PanelLang, Record<string, string>>;
@@ -434,6 +434,21 @@ const en = {
434
434
  'finding.extra-check.error': 'An extra check could not finish.',
435
435
  'finding.fixHint': 'Click Fix all to fix it.',
436
436
  'finding.raw': 'Details',
437
+ 'finding.memory.unfolded.one': 'This account keeps its own memory for 1 project that your other Claude accounts do not see: {projects}.',
438
+ 'finding.memory.unfolded.other': 'This account keeps its own memory for {n} projects that your other Claude accounts do not see: {projects}.',
439
+ 'finding.memory.unfolded.some': 'This account keeps its own memory for {n} projects. Fix all moves {ready} of them into the main account now; these wait until their session ends: {waiting}.',
440
+ 'finding.memory.unfolded.waiting.one': 'This account keeps its own memory for 1 project, but a session of this account is working there. Fix it after that session ends: {waiting}.',
441
+ 'finding.memory.unfolded.waiting.other': 'This account keeps its own memory for {n} projects, but sessions of this account are working in each of them. Fix them after those sessions end: {waiting}.',
442
+ 'finding.memory.unfolded.unknown.one': 'This account keeps its own memory for 1 project ({projects}), but sideby cannot tell right now which of its sessions are running, so it does not move it yet. Run the check again in a moment.',
443
+ 'finding.memory.unfolded.unknown.other': 'This account keeps its own memory for {n} projects ({projects}), but sideby cannot tell right now which of its sessions are running, so it does not move them yet. Run the check again in a moment.',
444
+ 'finding.memory.link': '{path} is a link. Claude Code does not write memory through a link, and sideby does not follow it; replace it with a real folder.',
445
+ 'finding.memory.index.one': 'The memory index (MEMORY.md) of 1 project in the main account does not match its files: {projects}. Claude reads only what MEMORY.md lists; ask Claude in that project to tidy its memory index.',
446
+ 'finding.memory.index.other': 'The memory index (MEMORY.md) of {n} projects in the main account does not match their files: {projects}. Claude reads only what MEMORY.md lists; ask Claude in each project to tidy its memory index.',
447
+ 'finding.memory.name-mismatch': 'Claude Code named the project folder of {path} "{folder}", but sideby would name it "{derived}". Claude Code may have changed how it names project folders; turn shared memory off until you update sideby.',
448
+ 'fixres.memory.unfolded.unknown': 'sideby cannot tell which sessions of this account are running, so it moved nothing. Try again in a moment.',
449
+ 'fixres.memory.unfolded.waiting': 'Nothing moved: sessions of this account are still working in these projects. Fix them after those sessions end: {waiting}.',
450
+ 'fixres.memory.unfolded.some.one': 'The project could not be moved fully into the main account and stays in this account for now: {left}.',
451
+ 'fixres.memory.unfolded.some.other': 'Moved {moved} of {n} projects into the main account; these stay in this account for now: {left}.',
437
452
  'win.5h': '5-hour',
438
453
  'win.7d': 'Weekly',
439
454
  'win.5h.short': '5-hour',
@@ -1820,6 +1835,18 @@ const en = {
1820
1835
  'tr.onToast': 'Folder trust is reused now. Claude accounts sideby starts no longer ask where another account trusts the folder.',
1821
1836
  'tr.offToast': 'Folder trust is no longer reused. What was copied stays.',
1822
1837
  'tr.failed': 'Could not change folder trust: {msg}. Try again, or run sideby trust in a terminal.',
1838
+ 'ai.ask.memory': 'Let all my Claude accounts share what they remember about each project.',
1839
+ 'mm.title': 'Shared memory',
1840
+ 'mm.hint': 'Claude remembers what it learns about a project, but each account keeps its own memory. sideby can let all your Claude accounts share one memory per project.',
1841
+ 'mm.switch': 'Share project memory across my Claude accounts',
1842
+ 'mm.what': "Claude sessions sideby starts in your other accounts read and write the main account's memory of the project, so the next account knows what the last one learned.",
1843
+ 'mm.doctor': 'Memory an account wrote on its own (a session started without sideby) stays there until you click Fix all on the Accounts page; then it moves into the main account. A file that differs is kept beside the main one under a new name, and the emptied folder goes to the trash.',
1844
+ 'mm.offKeeps': 'Turning it off stops sharing from the next session on. Memory already moved into the main account stays there; it is not moved back to each account.',
1845
+ 'mm.folded.one': 'So far, Fix all moved 1 memory file into the main account.',
1846
+ 'mm.folded.other': 'So far, Fix all moved {n} memory files into the main account.',
1847
+ 'mm.onToast': "Shared memory is on. Claude accounts sideby starts from now on use the main account's memory; Fix all moves what they already wrote.",
1848
+ 'mm.offToast': 'Shared memory is off. Memory already in the main account stays.',
1849
+ 'mm.failed': 'Could not change shared memory: {msg}. Try again, or run sideby memory in a terminal.',
1823
1850
  };
1824
1851
  const zh = {
1825
1852
  'top.tagline': '所有 AI 编程账号,并排运行。',
@@ -2254,6 +2281,21 @@ const zh = {
2254
2281
  'finding.extra-check.error': '有一项额外检查没能完成。',
2255
2282
  'finding.fixHint': '点「全部修复」就能修好。',
2256
2283
  'finding.raw': '详情',
2284
+ 'finding.memory.unfolded.one': '这个账号有 1 个项目的记忆只存在自己这里,其他 Claude 账号看不到:{projects}。',
2285
+ 'finding.memory.unfolded.other': '这个账号有 {n} 个项目的记忆只存在自己这里,其他 Claude 账号看不到:{projects}。',
2286
+ 'finding.memory.unfolded.some': '这个账号有 {n} 个项目的记忆还没移进主账号。「全部修复」现在移 {ready} 个;这些要等会话结束后再修复:{waiting}。',
2287
+ 'finding.memory.unfolded.waiting.one': '这个账号有 1 个项目的记忆还没移进主账号,但这个账号有会话正在里面运行。等这些会话结束后再修复:{waiting}。',
2288
+ 'finding.memory.unfolded.waiting.other': '这个账号有 {n} 个项目的记忆还没移进主账号,但这个账号有会话正在这些项目里运行。等这些会话结束后再修复:{waiting}。',
2289
+ 'finding.memory.unfolded.unknown.one': '这个账号有 1 个项目的记忆还没移进主账号({projects}),但 sideby 现在看不出这个账号有哪些会话在运行,所以先不移。稍后再运行检查。',
2290
+ 'finding.memory.unfolded.unknown.other': '这个账号有 {n} 个项目的记忆还没移进主账号({projects}),但 sideby 现在看不出这个账号有哪些会话在运行,所以先不移。稍后再运行检查。',
2291
+ 'finding.memory.link': '{path} 是一个链接。Claude Code 不会通过链接写记忆,sideby 也不会跟着链接走;请把它换成真正的文件夹。',
2292
+ 'finding.memory.index.one': '主账号里 1 个项目的记忆索引(MEMORY.md)和文件对不上:{projects}。Claude 只读 MEMORY.md 里列出的记忆;可以在那个项目里让 Claude 整理记忆索引。',
2293
+ 'finding.memory.index.other': '主账号里 {n} 个项目的记忆索引(MEMORY.md)和文件对不上:{projects}。Claude 只读 MEMORY.md 里列出的记忆;可以在这些项目里让 Claude 整理记忆索引。',
2294
+ 'finding.memory.name-mismatch': 'Claude Code 给 {path} 起的项目文件夹名是「{folder}」,但 sideby 会起名为「{derived}」。Claude Code 可能改了起名方式;更新 sideby 之前先关掉共享记忆。',
2295
+ 'fixres.memory.unfolded.unknown': 'sideby 看不出这个账号有哪些会话在运行,所以什么都没移。稍后再试。',
2296
+ 'fixres.memory.unfolded.waiting': '什么都没移:这个账号还有会话在这些项目里运行。等这些会话结束后再修复:{waiting}。',
2297
+ 'fixres.memory.unfolded.some.one': '这个项目没能完整移进主账号,暂时留在这个账号:{left}。',
2298
+ 'fixres.memory.unfolded.some.other': '{n} 个项目里已有 {moved} 个移进主账号;这些暂时留在这个账号:{left}。',
2257
2299
  'win.5h': '5 小时额度',
2258
2300
  'win.7d': '每周额度',
2259
2301
  'win.5h.short': '5 小时',
@@ -3640,5 +3682,17 @@ const zh = {
3640
3682
  'tr.onToast': '已开始沿用文件夹信任。sideby 启动的 Claude 账号,在别的账号信任过的文件夹里不再询问。',
3641
3683
  'tr.offToast': '已不再沿用文件夹信任。已经复制的保留。',
3642
3684
  'tr.failed': '没能改文件夹信任:{msg}。可以再试一次,或在终端运行 sideby trust。',
3685
+ 'ai.ask.memory': '让我所有 Claude 账号共用对每个项目的记忆。',
3686
+ 'mm.title': '共享记忆',
3687
+ 'mm.hint': 'Claude 会记住它在项目里学到的东西,但每个账号各记各的。sideby 可以让你所有 Claude 账号每个项目共用一份记忆。',
3688
+ 'mm.switch': '让我的 Claude 账号共用项目记忆',
3689
+ 'mm.what': 'sideby 在其他账号里启动的 Claude 会话,读写主账号对这个项目的记忆,下一个账号就知道上一个学到了什么。',
3690
+ 'mm.doctor': '账号自己写下的记忆(不经 sideby 启动的会话)先留在那个账号里,在账号页点「全部修复」后移进主账号。同名但内容不同的文件换个名字放在主账号那份旁边,清空的文件夹移到废纸篓。',
3691
+ 'mm.offKeeps': '关掉后,从下一个会话起不再共用。已经移进主账号的记忆留在主账号,不会搬回各账号。',
3692
+ 'mm.folded.one': '「全部修复」已把 1 个记忆文件移进主账号。',
3693
+ 'mm.folded.other': '「全部修复」已把 {n} 个记忆文件移进主账号。',
3694
+ 'mm.onToast': '已打开共享记忆。之后 sideby 启动的 Claude 账号用主账号的记忆;「全部修复」会把它们已经写下的移过来。',
3695
+ 'mm.offToast': '已关闭共享记忆。已经在主账号里的记忆保留。',
3696
+ 'mm.failed': '没能改共享记忆:{msg}。可以再试一次,或在终端运行 sideby memory。',
3643
3697
  };
3644
3698
  export const MESSAGES = { en, zh };
@@ -342,6 +342,18 @@ export declare function runCodeSwap(io: {
342
342
  fail: (error: unknown) => void;
343
343
  unknown: () => void;
344
344
  }): Promise<void>;
345
+ /**
346
+ * The plain sentence the Panel shows for a Finding, or for a Fix result with `prefix` `fixres.`: the message of
347
+ * `<prefix><code>`, `.<params.form>` added when the check names a variant and `.one`/`.other` by `params.n` when the
348
+ * message has both, in `table` (the Panel's language) or else in English, with `{item}` and every param put in. Empty
349
+ * when English has no message for it, or the Finding lacks a value the message needs (one saved by an older sideby):
350
+ * the check's own text is shown then.
351
+ */
352
+ export declare function findingSentence(f: {
353
+ code: string;
354
+ item?: string;
355
+ params?: Record<string, string | number>;
356
+ }, table: Record<string, string>, en: Record<string, string>, prefix?: string): string;
345
357
  export declare function panelFixes(f: {
346
358
  code?: string;
347
359
  }, skillUpdatable: boolean): boolean;
@@ -698,6 +698,30 @@ export async function runCodeSwap(io) {
698
698
  await io.readState();
699
699
  }
700
700
  }
701
+ /**
702
+ * The plain sentence the Panel shows for a Finding, or for a Fix result with `prefix` `fixres.`: the message of
703
+ * `<prefix><code>`, `.<params.form>` added when the check names a variant and `.one`/`.other` by `params.n` when the
704
+ * message has both, in `table` (the Panel's language) or else in English, with `{item}` and every param put in. Empty
705
+ * when English has no message for it, or the Finding lacks a value the message needs (one saved by an older sideby):
706
+ * the check's own text is shown then.
707
+ */
708
+ export function findingSentence(f, table, en, prefix = 'finding.') {
709
+ const params = f.params || {};
710
+ const base = prefix + f.code + (params.form ? `.${params.form}` : '');
711
+ const key = Object.hasOwn(en, `${base}.one`) ? `${base}.${Number(params.n) === 1 ? 'one' : 'other'}` : base;
712
+ if (!Object.hasOwn(en, key))
713
+ return '';
714
+ const text = Object.hasOwn(table, key) ? table[key] : en[key];
715
+ const vars = { item: f.item ?? '', ...params };
716
+ let missing = false;
717
+ const out = text.replace(/\{(\w+)\}/g, (m, k) => {
718
+ if (Object.hasOwn(vars, k))
719
+ return String(vars[k]);
720
+ missing = true;
721
+ return m;
722
+ });
723
+ return missing ? '' : out;
724
+ }
701
725
  export function panelFixes(f, skillUpdatable) {
702
726
  return skillUpdatable && f.code === 'skill.outdated';
703
727
  }