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.
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +2 -0
- package/dist/src/cli/commands.js +263 -32
- package/dist/src/cli/json-schemas.js +85 -4
- package/dist/src/cli/main.js +49 -7
- package/dist/src/core/claude-memory.d.ts +236 -0
- package/dist/src/core/claude-memory.js +937 -0
- package/dist/src/core/cli-commands.js +16 -3
- package/dist/src/core/config.d.ts +17 -0
- package/dist/src/core/config.js +266 -43
- package/dist/src/core/history-project.d.ts +14 -0
- package/dist/src/core/history-project.js +42 -12
- package/dist/src/core/history.d.ts +4 -6
- package/dist/src/core/history.js +5 -15
- package/dist/src/core/local-build.d.ts +12 -0
- package/dist/src/core/local-build.js +32 -0
- package/dist/src/core/search-catalog.js +49 -0
- package/dist/src/core/session-hooks.d.ts +12 -2
- package/dist/src/core/session-hooks.js +12 -8
- package/dist/src/core/unattended-followup.d.ts +62 -0
- package/dist/src/core/unattended-followup.js +205 -0
- package/dist/src/core/unattended-pending.d.ts +11 -3
- package/dist/src/core/unattended-pending.js +34 -8
- package/dist/src/families/claude/history.js +9 -1
- package/dist/src/families/claude/layout.d.ts +7 -0
- package/dist/src/families/claude/layout.js +17 -0
- package/dist/src/families/claude/live-sessions.js +2 -1
- package/dist/src/families/history.d.ts +22 -2
- package/dist/src/families/history.js +55 -0
- package/dist/src/handoff/messages.js +1 -1
- package/dist/src/panel/handler.d.ts +22 -4
- package/dist/src/panel/handler.js +71 -25
- package/dist/src/panel/i18n.d.ts +35 -1
- package/dist/src/panel/i18n.js +72 -4
- package/dist/src/panel/page-logic.d.ts +53 -0
- package/dist/src/panel/page-logic.js +96 -0
- package/dist/src/panel/page-script.js +174 -36
- package/dist/src/panel/page-styles.js +18 -0
- package/dist/src/runtime.d.ts +30 -0
- package/dist/src/runtime.js +85 -1
- package/dist/src/unattended/hook.d.ts +10 -5
- package/dist/src/unattended/hook.js +17 -12
- package/package.json +1 -1
- package/schemas/config.json +5 -1
- package/schemas/memory-set.json +117 -0
- package/schemas/memory.json +210 -0
- package/schemas/unattended-pending.json +156 -56
- package/skills/sideby/SKILL.md +3 -1
- package/skills/sideby/references/diagnose.md +1 -0
- package/skills/sideby/references/handoff.md +1 -1
- package/skills/sideby/references/panel.md +1 -1
- package/skills/sideby/references/sharing.md +23 -1
- package/skills/sideby/references/unattended.md +16 -5
|
@@ -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>;
|