sideby 0.41.3 → 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.
package/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"id":"20261120T032753-91cea3"}
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;
@@ -4992,6 +4992,106 @@ export async function cmdTrust(a, io) {
4992
4992
  io.out(c.dim('Turning it off keeps what was copied; `sideby trust undo` takes it back.'));
4993
4993
  return 0;
4994
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
+ }
4995
5095
  /** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
4996
5096
  export async function cmdUnattended(a, io) {
4997
5097
  const [sub, ...rest] = a.positionals;
@@ -1644,6 +1644,50 @@ export const OUTPUT_SCHEMAS = {
1644
1644
  why: Type.Optional(Type.String()),
1645
1645
  })),
1646
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' }),
1647
1691
  browser: Type.Object({
1648
1692
  schemaVersion: Version,
1649
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
@@ -444,6 +445,33 @@ Examples:
444
445
  sideby trust undo
445
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
446
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.`,
447
475
  browser: `sideby browser [--enable|--disable] [--yes] [--json]
448
476
  sideby browser open <account> [--profile <folder|name>] [--json]
449
477
  sideby browser set <account> <folder|name> [--json]
@@ -545,6 +573,7 @@ const COMMANDS = {
545
573
  },
546
574
  progress: { flags: ['json'], valued: ['every'] },
547
575
  trust: { flags: ['json', 'yes'], valued: ['dir'] },
576
+ memory: { flags: ['json', 'yes'], valued: ['dir'] },
548
577
  new: { flags: ['api', 'json', 'next'], valued: ['alias', 'vendor'] },
549
578
  alias: { flags: ['json', 'yes'], valued: ['pick'] },
550
579
  doctor: { flags: ['fix', 'force', 'json'] },
@@ -882,6 +911,8 @@ async function dispatch(cmd, parsed, io, cmds) {
882
911
  return await cmds.cmdProgress(parsed, io);
883
912
  case 'trust':
884
913
  return await cmds.cmdTrust(parsed, io);
914
+ case 'memory':
915
+ return await cmds.cmdMemory(parsed, io);
885
916
  case 'shell-init':
886
917
  return await cmds.cmdShellInit(parsed, io);
887
918
  case 'plugins':
@@ -0,0 +1,236 @@
1
+ import { type FileHandle } from 'node:fs/promises';
2
+ import type { Account, CheckResult, Env, Finding, FixResult } from '../types.ts';
3
+ import type { ProcessView } from './live-sessions-procs.ts';
4
+ import type { SessionHookPart } from './session-hooks.ts';
5
+ /** The index Claude Code keeps in each memory folder. */
6
+ export declare const MEMORY_INDEX = "MEMORY.md";
7
+ export type MemoryTarget =
8
+ /** `root` is the Project's key, `name` its folder under `projects/`, `dir` the Main Account's memory folder. */
9
+ {
10
+ status: 'ok';
11
+ root: string;
12
+ name: string;
13
+ dir: string;
14
+ } | {
15
+ status: 'skip';
16
+ why: string;
17
+ };
18
+ /**
19
+ * Where Claude Code keeps auto memory for `cwd`, by its own rule (ADR-0081): the git repository's main checkout root
20
+ * (a linked worktree and every subfolder use it), elsewhere the folder itself; real paths; named with
21
+ * `claudeProjectDirName`. Read from files only, never by running `git` (`trustRoot`). `skip` when sideby cannot tell
22
+ * (a submodule, a separate git folder), when the Main Account has no folder yet, or when a folder on the way under
23
+ * the Main Account is a link (Claude Code refuses memory writes through one, anthropics/claude-code#108770).
24
+ */
25
+ export declare function memoryTarget(mainDir: string, cwd: string): Promise<MemoryTarget>;
26
+ /** The session settings part that sends a Claude session's auto memory to `dir` (one file per folder, ADR-0081). */
27
+ export declare function memoryHookPart(dir: string): SessionHookPart;
28
+ /** The line a Claude Launch prints when the user's own `--settings` leaves no room for the memory folder. */
29
+ export declare function memorySettingsLine(env: Env): string;
30
+ /** The line a Claude Launch prints when sideby cannot tell where the Project's memory belongs. */
31
+ export declare function memorySkipLine(env: Env, why: string): string;
32
+ /** One Project folder of an Account that holds memory files. */
33
+ export interface AccountMemory {
34
+ /** The folder name under `projects/`. */
35
+ project: string;
36
+ dir: string;
37
+ files: number;
38
+ }
39
+ /**
40
+ * An Account's own memory: every `projects/<project>/memory` folder with at least one entry. A link anywhere on the
41
+ * way (`projects`, the Project folder, `memory`) is not followed: it is named in `links`.
42
+ */
43
+ export declare function accountMemories(accountDir: string): Promise<{
44
+ list: AccountMemory[];
45
+ links: string[];
46
+ }>;
47
+ /** Where a folder sideby emptied went: the system trash, or sideby's own folder (named). */
48
+ export type TrashResult = {
49
+ ok: true;
50
+ to: string;
51
+ } | {
52
+ ok: false;
53
+ why: string;
54
+ };
55
+ export type Trash = (path: string) => Promise<TrashResult>;
56
+ /**
57
+ * Moves `path` to the system trash with the `trash` command on PATH (macOS 14 and later ship `/usr/bin/trash`; Linux
58
+ * has `trash-cli`), only when HOME is the user's own home (a demo or test HOME never reaches the real trash). Without
59
+ * one, it moves the folder into `<state>/memory/trash/` and names it there. Never deletes anything.
60
+ */
61
+ export declare function systemTrash(env: Env, stateDir: string, now: () => Date): Trash;
62
+ /** Moves `path` into `<state>/memory/trash/<time>-<name>`; the folder is the user's own (700). */
63
+ export declare function keepInState(path: string, stateDir: string, at: Date): Promise<TrashResult>;
64
+ /** The working folders of an Account's Live Sessions, or why sideby cannot tell which run. */
65
+ export type LiveCwds = {
66
+ cwds: string[];
67
+ } | {
68
+ unknown: string;
69
+ };
70
+ /**
71
+ * The working folders of a Claude Account's Live Sessions, from Claude Code's `sessions/<pid>.json` files and the
72
+ * process list. It fails closed: a record of a running process that cannot be read (one Claude Code is rewriting),
73
+ * lacks its session id, working folder or start time, or a process list that cannot be read, means sideby cannot
74
+ * tell which Projects are in use, so the Fix moves nothing of that Account. Only a record whose process is gone, or
75
+ * whose pid now belongs to another process (its start time differs), counts as ended.
76
+ */
77
+ export declare function claudeLiveCwds(account: Account, procs: ProcessView): Promise<LiveCwds>;
78
+ /** The names of the session folders a Live Session in each of `cwds` uses for memory (its Project, and itself). */
79
+ export declare function liveProjects(cwds: readonly string[]): Promise<Set<string>>;
80
+ /** What folding one Project did. */
81
+ export interface FoldOutcome {
82
+ project: string;
83
+ /** `partial`: what was read is in the Main Account, but something written meanwhile stays in the Account. */
84
+ status: 'moved' | 'merged' | 'partial' | 'skipped' | 'failed';
85
+ /** Files that reached the Main Account under their own name. */
86
+ moved: string[];
87
+ /** Files kept beside a different file of the same name in the Main Account. */
88
+ renamed: {
89
+ from: string;
90
+ to: string;
91
+ }[];
92
+ /** Files the Main Account already held with the same content. */
93
+ same: string[];
94
+ /** Lines added to the Main Account's `MEMORY.md`. */
95
+ indexLines: number;
96
+ /** Where the emptied Account folder went. */
97
+ trashed?: string;
98
+ why?: string;
99
+ }
100
+ /**
101
+ * The memory file a link in `MEMORY.md` points at, with its `#fragment`: the target resolved against the memory
102
+ * folder (`a.md`, `./a.md`, `../memory/a.md` and `a.md#section` all name `a.md`). Null for a link with a scheme, an
103
+ * absolute path, or a file outside the memory folder.
104
+ */
105
+ export declare function memoryLink(target: string): {
106
+ file: string;
107
+ fragment: string;
108
+ } | null;
109
+ /**
110
+ * An index with every link to a renamed file pointing at its new name (its `#fragment` kept), in one pass over the
111
+ * links, each resolved against the memory folder, so one rename never feeds another.
112
+ */
113
+ export declare function rewriteLinks(text: string, renamed: ReadonlyMap<string, string>): string;
114
+ /** `into` with every line of `from` it does not hold yet (trailing spaces ignored), in order; and how many. */
115
+ export declare function mergeIndex(into: string, from: string): {
116
+ text: string;
117
+ added: number;
118
+ };
119
+ export interface FoldInput {
120
+ /** The Main Account's folder (`~/.claude`). */
121
+ mainDir: string;
122
+ account: Account;
123
+ project: string;
124
+ trash: Trash;
125
+ /** Internal, for tests: runs after every copy is checked and before the Account's files are taken out. */
126
+ afterCopy?: () => Promise<void>;
127
+ /** Internal, for tests: writes a copy's bytes into its temp file (default: all of them). */
128
+ write?: (fh: FileHandle, data: Buffer) => Promise<void>;
129
+ /** Internal, for tests: runs after a file is renamed into the stage and before it is hashed there. */
130
+ staged?: (name: string) => Promise<void>;
131
+ }
132
+ /** The folder beside an Account's `memory` that holds the files being taken out, until they go to the trash. */
133
+ export declare const FOLD_STAGE = "memory-folded-by-sideby";
134
+ /**
135
+ * Folds one Project's memory of `account` into the Main Account (ADR-0081). When the Main Account has no memory for
136
+ * it, the folder moves whole. Otherwise every file is read once, and copied in from that read (temp file, fsync, then
137
+ * a hard link to its name, so never over another file and never half-written; times kept): a file the Main Account
138
+ * holds with the same content counts as there, one with other content is kept as `<name>.<account>.md` (a name
139
+ * neither folder uses), and `MEMORY.md` gets the Account's lines it lacks, with links to renamed files rewritten in
140
+ * one pass. Then each file read is taken out on its own: renamed into a stage beside the memory folder, hashed there,
141
+ * and kept out only when it still holds what was copied (else renamed back). The stage goes to the trash, and the
142
+ * memory folder is removed only when empty, so a file written meanwhile is never trashed: it stays for the next fold.
143
+ */
144
+ export declare function foldProject(input: FoldInput): Promise<FoldOutcome>;
145
+ /** One fold sideby recorded (its state folder; names and counts only, never a file's text). */
146
+ export interface FoldRecord {
147
+ account: string;
148
+ project: string;
149
+ /** Memory files that reached the Main Account, `MEMORY.md` not counted. */
150
+ files: number;
151
+ at: string;
152
+ }
153
+ /** Every fold sideby recorded, oldest first; a file that cannot be read gives none. */
154
+ export declare function readFolds(stateDir: string): Promise<FoldRecord[]>;
155
+ export interface MemoryDoctorContext {
156
+ mainDir: string;
157
+ stateDir: string;
158
+ /** The working folders of the Account's Live Sessions, or why sideby cannot tell (`claudeLiveCwds`). */
159
+ liveCwds: (account: Account) => Promise<LiveCwds>;
160
+ trash: Trash;
161
+ now: () => Date;
162
+ /** Shortens a path for a message (`~/…`). */
163
+ show: (p: string) => string;
164
+ }
165
+ /** Every Project of `account` with memory of its own, folded unless a Live Session of the Account works in it. */
166
+ export declare function foldAccount(ctx: MemoryDoctorContext, account: Account): Promise<FixResult>;
167
+ /** Doctor's check of one Claude Account that is not the Main Account (only while config `claude.shareMemory` is on). */
168
+ export declare function memoryFindings(ctx: MemoryDoctorContext, account: Account): Promise<CheckResult[]>;
169
+ /** The memory files an index links to (`memoryLink`); links to anything else are left out. */
170
+ export declare function indexTargets(text: string): string[];
171
+ /** One memory folder whose index does not match its files. */
172
+ export interface IndexProblem {
173
+ project: string;
174
+ /** Files the index links to that are not there. */
175
+ missing: string[];
176
+ /** Memory files the index does not list. */
177
+ unlisted: string[];
178
+ }
179
+ /** Every memory folder of the Main Account whose `MEMORY.md` lists a missing file or misses a file that is there. */
180
+ export declare function indexProblems(mainDir: string): Promise<IndexProblem[]>;
181
+ /** A Project folder Claude Code named differently from the name sideby gives the same path. */
182
+ export interface NameMismatch {
183
+ account: string;
184
+ folder: string;
185
+ cwd: string;
186
+ derived: string;
187
+ }
188
+ /**
189
+ * Whether Claude Code still names Project folders the way sideby does (ADR-0081). Claude Code names a session's
190
+ * folder after the session's working folder, by the same rule as its memory folder; a folder that holds memory and
191
+ * session files none of whose `cwd`s (first and last records, folders that still exist) names it means the rule
192
+ * changed. The three newest session files of up to 40 folders are looked at, and a folder counts only when none of
193
+ * them agrees.
194
+ */
195
+ export declare function nameMismatches(accounts: readonly Account[]): Promise<NameMismatch[]>;
196
+ /** Doctor's warnings about the Main Account's memory (only while config `claude.shareMemory` is on); never `fail`. */
197
+ export declare function mainMemoryFindings(ctx: Pick<MemoryDoctorContext, 'mainDir' | 'show'>, accounts: readonly Account[]): Promise<Finding[]>;
198
+ /** What `sideby memory` and the Panel show (spec §3.44). */
199
+ export interface MemoryStatus {
200
+ /** Config `claude.shareMemory`. */
201
+ on: boolean;
202
+ /** The Main Account's folder that holds every Project's memory (`~/.claude/projects`). */
203
+ main: string;
204
+ /** Folds Doctor recorded, newest last. */
205
+ folded: FoldRecord[];
206
+ /** The folder asked about and where its memory goes; only while on. */
207
+ dir?: {
208
+ path: string;
209
+ name?: string;
210
+ memory?: string;
211
+ why?: string;
212
+ };
213
+ /** Each Project with memory in the Main Account or of an Account's own; only while on. */
214
+ projects?: {
215
+ name: string;
216
+ /** Files in the Main Account's memory folder. */
217
+ main: number;
218
+ /** Accounts that keep memory of their own for it: files Doctor would fold. */
219
+ pending: {
220
+ account: string;
221
+ files: number;
222
+ }[];
223
+ /** Files Doctor folded into the Main Account, per Account. */
224
+ folded: {
225
+ account: string;
226
+ files: number;
227
+ }[];
228
+ }[];
229
+ }
230
+ /** `sideby memory` (spec §3.44): reads no Account folder while the setting is off. */
231
+ export declare function memoryStatus(opts: {
232
+ mainDir: string;
233
+ stateDir: string;
234
+ /** Asked only while on: finding the Accounts reads the Host folders. */
235
+ accounts: () => Promise<readonly Account[]>;
236
+ }, on: boolean, cwd?: string): Promise<MemoryStatus>;