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
@@ -6,7 +6,7 @@ import { groupsToAccept } from '../core/inbound.js';
6
6
  import { limitResetOffer, quotaAge, quotaIsStale, windowAge } from '../core/quota-levels.js';
7
7
  import { remoteControlTodo } from '../core/remote-control.js';
8
8
  import { catalogMatchLevel, catalogNorm, searchCatalog } from '../core/search-catalog.js';
9
- import { accountTitle, advisorPick, advisorSummary, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dateFormatter, dotsKeepKeyboard, enableOutcome, expiredLogins, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyRowSig, historyWhen, historyWhenNext, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, openBridge, openBridged, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, portalRefresh, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, startedFromView, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, toastMerge, uaDayRuns, uaGroupByProject, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
9
+ import { accountTitle, advisorPick, advisorSummary, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dateFormatter, dotsKeepKeyboard, enableOutcome, expiredLogins, fileSize, findingSentence, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyRowSig, historyWhen, historyWhenNext, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, openBridge, openBridged, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, portalRefresh, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, startedFromView, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, toastMerge, uaDayRuns, uaGroupByProject, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
10
10
  // The component library's dropdown menu, copied by the brand repo's add script (--html into ui/); do not edit it.
11
11
  import { CHECK, menuItem, menuScript } from './ui/dropdown-menu/dropdown-menu.html.js';
12
12
  import { cn, esc } from './ui/lib/cn.js';
@@ -82,6 +82,7 @@ const LOGIC = [
82
82
  dateFormatter,
83
83
  runCodeSwap,
84
84
  switchFailure,
85
+ findingSentence,
85
86
  panelFixes,
86
87
  panelHint,
87
88
  panelLang,
@@ -3286,9 +3287,9 @@ const MAIN = String.raw `
3286
3287
  // A Finding in plain words (its code's sentence); the check's own text goes under "Details".
3287
3288
  function findingRow(f) {
3288
3289
  const own = panelFixes(f, skillFixable())
3289
- const key = 'finding.' + f.code
3290
- const plain = Object.hasOwn(MESSAGES.en, key) ? t(key, { item: f.item }) : ''
3291
- const fixHere = plain && f.fixable && !BOOT.readOnly && !own
3290
+ const plain = findingSentence(f, MESSAGES[lang] || {}, MESSAGES.en)
3291
+ // A finding whose sentence says some of it waits (Shared Project Memory) already says what Fix all does now.
3292
+ const fixHere = plain && f.fixable && !BOOT.readOnly && !own && !(f.params && f.params.waiting)
3292
3293
  return h('li', { class: 'finding lvl-' + f.level },
3293
3294
  h('span', { class: 'dot', title: f.level }),
3294
3295
  h('div', { class: 'finding-body' },
@@ -3305,6 +3306,12 @@ const MAIN = String.raw `
3305
3306
  // The check's own words (and any command to run) stay one click away.
3306
3307
  plain ? h('details', { class: 'finding-raw' }, h('summary', null, t('finding.raw')), h('p', { class: 'mono small' }, f.message), f.hint ? h('p', { class: 'mono small' }, f.hint) : null) : null))
3307
3308
  }
3309
+ // A Fix that did not fix: its plain sentence when the check gave one, the check's own words one click away.
3310
+ function fixLine(f) {
3311
+ const plain = findingSentence(f, MESSAGES[lang] || {}, MESSAGES.en, 'fixres.')
3312
+ return h('li', null, h('b', null, f.account + ' · ' + f.item + colon()), plain || f.message,
3313
+ plain ? h('details', { class: 'finding-raw' }, h('summary', null, t('finding.raw')), h('p', { class: 'mono small' }, f.message)) : null)
3314
+ }
3308
3315
  function renderCheckup() {
3309
3316
  const box = $('checkup')
3310
3317
  // With no account there is nothing to check: the empty state is the only thing to do.
@@ -3347,7 +3354,7 @@ const MAIN = String.raw `
3347
3354
  const failed = S.fixes.filter((f) => !f.ok)
3348
3355
  out.push(h('div', { class: 'fix-result ' + (failed.length ? 'is-warn' : 'is-ok'), role: 'status' },
3349
3356
  S.fixes.length ? t('fix.result', { ok: S.fixes.length - failed.length, n: S.fixes.length }) : t('fix.nothing'),
3350
- failed.length ? h('ul', null, failed.map((f) => h('li', null, h('b', null, f.account + ' · ' + f.item + colon()), f.message))) : null))
3357
+ failed.length ? h('ul', null, failed.map(fixLine)) : null))
3351
3358
  }
3352
3359
  if (!findings) {
3353
3360
  if (busy || !S.state) out.push(h('span', { class: 'sk sk-line w70' }), h('span', { class: 'sk sk-line w50' }))
@@ -7237,6 +7244,38 @@ const MAIN = String.raw `
7237
7244
  out.push(h('p', { class: 'small' }, h('button', { class: 'link-btn small', type: 'button', 'data-key': 'tr-ask', onclick: () => openAsk({ text: t('ai.ask.trust') }) }, t('adv.ask'))))
7238
7245
  return out
7239
7246
  }
7247
+ // Shared Project Memory (spec §3.44, ADR-0081): the switch writes config claude.shareMemory at once (the words beside
7248
+ // it say what it does and what Fix all moves) and the toast offers the way back. Its state reads no account folder.
7249
+ async function setMemory(on) {
7250
+ const mm = S.state && S.state.memory
7251
+ if (!mm) return
7252
+ const was = mm.on
7253
+ S.state.memory = Object.assign({}, mm, { on })
7254
+ refreshSettings()
7255
+ try {
7256
+ await api('/api/memory/settings', { on, confirm: true })
7257
+ toast(t(on ? 'mm.onToast' : 'mm.offToast'), { kind: 'ok', action: { label: t('toast.undo'), run: () => setMemory(was) }, duration: 8000 })
7258
+ } catch (e) {
7259
+ S.state.memory = Object.assign({}, S.state.memory, { on: was })
7260
+ refreshSettings()
7261
+ toast(t('mm.failed', { msg: e.message }), { kind: 'fail' })
7262
+ }
7263
+ load({ silent: true })
7264
+ }
7265
+ function memoryItems() {
7266
+ const mm = S.state.memory
7267
+ const label = t('mm.switch')
7268
+ const out = [fm('memory', h('div', { class: 'set-row', 'data-patch': '' },
7269
+ h('span', { class: 'set-label' }, label),
7270
+ BOOT.readOnly ? h('span', { class: 'chip chip-sm' + (mm.on ? ' chip-ok' : '') }, mm.on ? t('ah.on') : t('ah.off'))
7271
+ : h('div', { class: 'seg', role: 'group', 'aria-label': label, 'data-patch': '' }, [[true, t('ah.on')], [false, t('ah.off')]].map(([v, text]) =>
7272
+ h('button', { class: 'seg-btn', type: 'button', 'aria-pressed': String(v === mm.on), onclick: () => { if (v !== mm.on) setMemory(v) } }, text)))))]
7273
+ out.push(h('ul', { class: 'pr-notes' }, h('li', null, t('mm.what')), h('li', null, t('mm.doctor')), h('li', null, t('mm.offKeeps'))))
7274
+ if (mm.folded) out.push(h('p', { class: 'small muted mm-folded' }, tn('mm.folded', mm.folded)))
7275
+ if (!BOOT.readOnly && !askBridged(BOOT, window))
7276
+ out.push(h('p', { class: 'small' }, h('button', { class: 'link-btn small', type: 'button', 'data-key': 'mm-ask', onclick: () => openAsk({ text: t('ai.ask.memory') }) }, t('adv.ask'))))
7277
+ return out
7278
+ }
7240
7279
  function famTitleOf(fam) { const f = S.state && S.state.families.find((x) => x.id === fam); return f ? f.title : fam }
7241
7280
  // ---------- settings ----------
7242
7281
  // One header button holds what is set once and rarely changed: language, theme, Remote Control and Auto Handoff.
@@ -7255,6 +7294,7 @@ const MAIN = String.raw `
7255
7294
  if (S.state && S.state.network) out.push('net')
7256
7295
  if (S.state && S.state.progress) out.push('progress')
7257
7296
  if (S.state && S.state.trust) out.push('trust')
7297
+ if (S.state && S.state.memory) out.push('memory')
7258
7298
  return out
7259
7299
  }
7260
7300
  function renderSettingsButton() {
@@ -7370,6 +7410,7 @@ const MAIN = String.raw `
7370
7410
  { id: 'handoff', title: t('ah.button'), items: [ahLink(leave)].filter(Boolean), foot: t('set.ahHint') },
7371
7411
  { id: 'progress', title: t('pr.title'), items: secs.includes('progress') ? progressItems() : [], foot: t('pr.hint') },
7372
7412
  { id: 'trust', title: t('tr.title'), items: secs.includes('trust') ? trustItems() : [], foot: t('tr.hint') },
7413
+ { id: 'memory', title: t('mm.title'), items: secs.includes('memory') ? memoryItems() : [], foot: t('mm.hint') },
7373
7414
  { id: 'network', title: t('net.title'), items: netItems, foot: t('net.hint') },
7374
7415
  { id: 'ai', title: t('set.g.ai'), items: ai, foot: t('set.aiHint') },
7375
7416
  ].filter((g) => g.items.length)
@@ -8073,7 +8114,7 @@ const MAIN = String.raw `
8073
8114
  return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
8074
8115
  }
8075
8116
  // Example phrases: a click puts one in the Let AI do it box (spec §3.28).
8076
- const AI_ASKS = ['ai.ask.quota', 'ai.ask.reset', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.hide', 'ai.ask.relogin', 'ai.ask.expired', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.handoffRules', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.advisor', 'ai.ask.trust', 'ai.ask.network', 'ai.ask.unattended', 'ai.ask.pending', 'ai.ask.progress', 'ai.ask.theme', 'ai.ask.find', 'ai.ask.commands', 'ai.ask.tool']
8117
+ const AI_ASKS = ['ai.ask.quota', 'ai.ask.reset', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.hide', 'ai.ask.relogin', 'ai.ask.expired', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.handoffRules', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.advisor', 'ai.ask.trust', 'ai.ask.memory', 'ai.ask.network', 'ai.ask.unattended', 'ai.ask.pending', 'ai.ask.progress', 'ai.ask.theme', 'ai.ask.find', 'ai.ask.commands', 'ai.ask.tool']
8077
8118
  // Network Guard (spec §3.35): one dialog with the switch, the allowed countries and the newest result per address.
8078
8119
  // Countries are never ticked for the user, the current one included: a wrong network would allow itself.
8079
8120
  const NET_COMMON = ['US', 'JP', 'SG', 'GB', 'DE', 'FR', 'NL', 'CA', 'AU', 'KR', 'TW', 'HK']
@@ -982,6 +982,7 @@ ${UI_CSS}
982
982
  .set-group > .reveal[data-key=pr-every] { margin-top: -8px; }
983
983
  .reveal[data-key=pr-every] > .reveal-in > .pr-every { padding-top: 8px; }
984
984
  .pr-notes { margin: 4px 0 0; padding-left: 16px; display: grid; gap: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }
985
+ .mm-folded { margin: 12px 0 0; }
985
986
  .pr-every .seg-btn { white-space: nowrap; }
986
987
  :where(:root[data-width=phone]) .pr-every { flex-direction: column; align-items: flex-start; gap: 8px; }
987
988
  :where(:root[data-width=phone]) .pr-every .seg { max-width: 100%; }
@@ -1,5 +1,6 @@
1
1
  import { type AccountRefError } from './core/accounts.ts';
2
2
  import { type AdvisorChange, type AdvisorChoice, type AdvisorSeen, type AdvisorStatus } from './core/advisor.ts';
3
+ import { type FoldRecord, type LiveRuns, type MemoryStatus, type Trash } from './core/claude-memory.ts';
3
4
  import { type TrustStatus, type UndoItem } from './core/claude-trust.ts';
4
5
  import { type Config, type DisplayConfig, type HandoffSettings } from './core/config.ts';
5
6
  import { type CreateResult } from './core/create.ts';
@@ -474,6 +475,27 @@ export interface Runtime {
474
475
  at: string;
475
476
  }[];
476
477
  }): Promise<UndoItem[]>;
478
+ /**
479
+ * Shared Project Memory (spec §3.44, ADR-0081): config `claude.shareMemory`, the folds Doctor recorded and, only while
480
+ * on, each Project's memory in the Main Account and in each Account, and where `dir`'s memory goes. While off no
481
+ * Account folder is read.
482
+ */
483
+ memoryStatus(dir?: string): Promise<MemoryStatus>;
484
+ /** Turns config `claude.shareMemory` on or off; without `apply`, only says what would change. */
485
+ memorySet(on: boolean, opts: {
486
+ apply: boolean;
487
+ }): Promise<{
488
+ changed: boolean;
489
+ applied: boolean;
490
+ before: boolean;
491
+ after: boolean;
492
+ file: string;
493
+ }>;
494
+ /** The setting and the folds Doctor recorded, from the config and sideby's own records only (no Account folder). */
495
+ memoryOverview(): Promise<{
496
+ on: boolean;
497
+ folded: FoldRecord[];
498
+ }>;
477
499
  /**
478
500
  * Which Account of a Family to move on to (spec §3.13), for a start the user asks for: past the Takeover Limit it
479
501
  * falls back to the least used Account under 100% (`tight`). Throws a UserError with code `no-quota-source`
@@ -545,4 +567,12 @@ export declare function createRuntime(opts?: {
545
567
  cwd?: () => string;
546
568
  print?: (line: string) => void;
547
569
  };
570
+ /**
571
+ * Internal, for tests: the working folders of an Account's Live Sessions (null: cannot tell) and where Doctor puts a
572
+ * memory folder it emptied (spec §3.44). Omitted, the Claude session files with `ps`, and the system trash.
573
+ */
574
+ memory?: {
575
+ liveRuns?: (account: Account) => Promise<LiveRuns>;
576
+ trash?: Trash;
577
+ };
548
578
  }): Promise<Runtime>;
@@ -1,6 +1,7 @@
1
1
  // The one service layer the CLI and the Panel share. Frozen contract for v0.1 (plan: 审核修订).
2
- import { aliasesByAccount, discoverAccounts, resolveRef, startArgsOf, } from './core/accounts.js';
2
+ import { aliasesByAccount, discoverAccounts, mainDirOf, resolveRef, startArgsOf, } from './core/accounts.js';
3
3
  import { advisorStatus, checkAdvisorAccount, setAdvisor, setAdvisorUnlock, undoAdvisor, } from './core/advisor.js';
4
+ import { claudeLiveRuns, mainMemoryFindings, memoryFindings, memoryHookPart, memorySettingsLine, memorySkipLine, memoryStatus, memoryTarget, readFolds, systemTrash, } from './core/claude-memory.js';
4
5
  import { carryLine, carryTrust, trustStatus, undoCarries, } from './core/claude-trust.js';
5
6
  import { addConfigAlias, addConfigPickCommand, aiTaskPermissions, aliasAccount, aliasArgs, aliasProblem, aliasRefs, editConfigClaude, editConfigDisplay, editConfigQuotaCheck, handoffSettings, loadConfig, removeConfigAlias, removeConfigPickCommand, } from './core/config.js';
6
7
  import { createAccount } from './core/create.js';
@@ -202,6 +203,50 @@ export async function createRuntime(opts = {}) {
202
203
  p.env[PROGRESS_ENV] = String(every);
203
204
  return progressHookPart();
204
205
  };
206
+ /** The Main Claude Account's folder (`~/.claude`), where Shared Project Memory lives. */
207
+ const claudeMainDir = () => {
208
+ const f = families.get('claude');
209
+ return f ? mainDirOf(f, paths.home) : `${paths.home}/.claude`;
210
+ };
211
+ /**
212
+ * Shared Project Memory on a Claude session sideby starts (spec §3.44, ADR-0081): the Main Account's memory folder of
213
+ * the Project, as `autoMemoryDirectory` in sideby's own `--settings` file. Not for the Main Account (that folder is
214
+ * already its own), a headless run, or a session given its own `--settings` (the notice says so).
215
+ */
216
+ const memoryPrepared = async (p) => {
217
+ if (p.family.id !== 'claude' || config.claude?.shareMemory !== true || p.account.isMain)
218
+ return null;
219
+ if (claudeHeadless(p.args))
220
+ return null;
221
+ if (hasOption(p.args, ['--settings'])) {
222
+ addNotice(p, [memorySettingsLine(p.env)]);
223
+ return null;
224
+ }
225
+ const t = await memoryTarget(claudeMainDir(), opts.trust?.cwd?.() ?? process.cwd());
226
+ if (t.status === 'skip') {
227
+ addNotice(p, [memorySkipLine(p.env, t.why.split(`${paths.home}/`).join('~/'))]);
228
+ return null;
229
+ }
230
+ return memoryHookPart(t.dir);
231
+ };
232
+ /** What Doctor's Shared Project Memory check and Fix use (spec §3.44, ADR-0081). */
233
+ const memoryCtx = async () => {
234
+ const { accountLabels, sessionLabel } = await import('./core/live-sessions.js');
235
+ const labels = accountLabels(rt, await accounts());
236
+ return {
237
+ mainDir: claudeMainDir(),
238
+ stateDir: paths.stateDir,
239
+ liveRuns: opts.memory?.liveRuns ??
240
+ (async (a) => {
241
+ const { processView, systemDeps } = await import('./core/live-sessions-procs.js');
242
+ return claudeLiveRuns(a, processView(systemDeps(env)));
243
+ }),
244
+ label: (a, run) => sessionLabel(labels.get(a.ref) ?? a.ref, run.title ?? '', run.sessionId),
245
+ trash: opts.memory?.trash ?? systemTrash(env, paths.stateDir, now),
246
+ now,
247
+ show: (p) => p.split(`${paths.home}/`).join('~/'),
248
+ };
249
+ };
205
250
  /** Puts every session hook into the Launch's arguments: one `--settings` for Claude, `-c hooks.*` for Codex. */
206
251
  const addSessionHooks = async (p, list) => {
207
252
  const parts = list.filter((x) => x !== null);
@@ -225,6 +270,9 @@ export async function createRuntime(opts = {}) {
225
270
  parts.push(await unattendedPrepared(p, Boolean(o.unattended)));
226
271
  if (session)
227
272
  parts.push(progressPrepared(p));
273
+ // Last: its file name says which Project's folder it holds.
274
+ if (session)
275
+ parts.push(await memoryPrepared(p));
228
276
  await addSessionHooks(p, parts);
229
277
  };
230
278
  const familyOf = (id) => {
@@ -788,6 +836,12 @@ export async function createRuntime(opts = {}) {
788
836
  scope = { kind: 'account', ref: one.ref };
789
837
  }
790
838
  }
839
+ // Shared Project Memory (spec §3.44): checked only while on, and only when the run includes Claude.
840
+ const freshMemory = await loadConfig(paths.configFile).catch(() => null);
841
+ if (freshMemory)
842
+ config.claude = freshMemory.claude;
843
+ const memoryOn = config.claude?.shareMemory === true && fams.has('claude');
844
+ const mctx = memoryOn ? await memoryCtx() : null;
791
845
  const input = {
792
846
  home: paths.home,
793
847
  families: fams,
@@ -802,6 +856,8 @@ export async function createRuntime(opts = {}) {
802
856
  ...(await checkAppData(loaded.plugins, paths.home, a, Boolean(o.force))),
803
857
  // Messages held in bypass permission mode (spec §3.32 step 2): the arguments the Account starts with.
804
858
  ...(await inboundFindings(a, startArgs(a))),
859
+ // Memory an Account wrote on its own, folded into the Main Account by the Fix (spec §3.44).
860
+ ...(mctx ? await memoryFindings(mctx, a) : []),
805
861
  ],
806
862
  loginProblem: (a) => loginProblemFor(a),
807
863
  };
@@ -819,6 +875,9 @@ export async function createRuntime(opts = {}) {
819
875
  : {}),
820
876
  home: paths.home,
821
877
  });
878
+ // The Main Account's memory index and folder names (spec §3.44); warnings only.
879
+ if (mctx)
880
+ extra.push(...(await mainMemoryFindings(mctx, all.filter((a) => a.family === 'claude')).catch(() => [])));
822
881
  return extra.length ? { ...r, general: [...r.general, ...extra] } : r;
823
882
  };
824
883
  let report = await withHandoff(await runDoctor(input));
@@ -1619,6 +1678,36 @@ export async function createRuntime(opts = {}) {
1619
1678
  };
1620
1679
  },
1621
1680
  trustUndo: (o) => undoCarries(paths.stateDir, { apply: o.apply, ...(o.only ? { only: o.only } : {}) }),
1681
+ async memoryStatus(dir) {
1682
+ const fresh = await loadConfig(paths.configFile).catch(() => null);
1683
+ if (fresh)
1684
+ config.claude = fresh.claude;
1685
+ // `accounts` walks the Host folders: asked only while the setting is on.
1686
+ return memoryStatus({ mainDir: claudeMainDir(), stateDir: paths.stateDir, accounts }, config.claude?.shareMemory === true, dir);
1687
+ },
1688
+ async memorySet(on, o) {
1689
+ const r = await editConfigClaude(paths.configFile, (c) => {
1690
+ if (on)
1691
+ return { ...c, shareMemory: true };
1692
+ const { shareMemory: _drop, ...rest } = c;
1693
+ return Object.keys(rest).length ? rest : undefined;
1694
+ }, { dryRun: !o.apply });
1695
+ if (o.apply && r.changed)
1696
+ config.claude = r.after;
1697
+ return {
1698
+ changed: r.changed,
1699
+ applied: o.apply && r.changed,
1700
+ before: r.before?.shareMemory === true,
1701
+ after: r.after?.shareMemory === true,
1702
+ file: paths.configFile,
1703
+ };
1704
+ },
1705
+ async memoryOverview() {
1706
+ const fresh = await loadConfig(paths.configFile).catch(() => null);
1707
+ if (fresh)
1708
+ config.claude = fresh.claude;
1709
+ return { on: config.claude?.shareMemory === true, folded: await readFolds(paths.stateDir) };
1710
+ },
1622
1711
  async advisorUnlock(on) {
1623
1712
  const r = await setAdvisorUnlock(paths.configFile, on);
1624
1713
  await reloadAdvisorConfig();
@@ -660,7 +660,11 @@ export type FindingLevel = 'ok' | 'warn' | 'fail';
660
660
  export interface FixResult {
661
661
  ok: boolean;
662
662
  message: string;
663
+ /** Values for the Panel's own sentence for this Fix's Finding code (`params.form` picks a variant); never a secret. */
664
+ params?: FindingParams;
663
665
  }
666
+ /** Values a Finding or a Fix gives the Panel to put into its translated sentence: names and counts only. */
667
+ export type FindingParams = Record<string, string | number>;
664
668
  export interface Finding {
665
669
  level: FindingLevel;
666
670
  /** Account ref the Finding is about. */
@@ -672,6 +676,8 @@ export interface Finding {
672
676
  message: string;
673
677
  /** What the user should do; never contains credential values. */
674
678
  hint?: string;
679
+ /** Values for the Panel's translated sentence of `code` (`params.form` picks a variant); never a secret. */
680
+ params?: FindingParams;
675
681
  /** `core` or the Plugin name. */
676
682
  source: string;
677
683
  fixable: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.41.3",
3
+ "version": "0.42.1",
4
4
  "description": "Run work, personal and API-key accounts at the same time, without their configs drifting apart.",
5
5
  "license": "MIT",
6
6
  "author": "Adonis0123 (https://github.com/Adonis0123)",
@@ -428,10 +428,14 @@
428
428
  "carryTrust": {
429
429
  "type": "boolean",
430
430
  "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)."
431
+ },
432
+ "shareMemory": {
433
+ "type": "boolean",
434
+ "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."
431
435
  }
432
436
  },
433
437
  "additionalProperties": false,
434
- "description": "Claude Code launches (spec §3.41, ADR-0074; `carryTrust`: spec §3.43, ADR-0078)."
438
+ "description": "Claude Code launches (spec §3.41, ADR-0074; `carryTrust`: spec §3.43, ADR-0078; `shareMemory`: spec §3.44, ADR-0081)."
435
439
  },
436
440
  "unattended": {
437
441
  "type": "object",
@@ -128,6 +128,22 @@
128
128
  "hint": {
129
129
  "type": "string"
130
130
  },
131
+ "params": {
132
+ "type": "object",
133
+ "patternProperties": {
134
+ "^.*$": {
135
+ "anyOf": [
136
+ {
137
+ "type": "string"
138
+ },
139
+ {
140
+ "type": "number"
141
+ }
142
+ ]
143
+ }
144
+ },
145
+ "description": "Names and counts the Panel puts into its own translated sentence for `code`; `form` picks a variant of it. The `message` says the same in English."
146
+ },
131
147
  "source": {
132
148
  "type": "string"
133
149
  },
@@ -185,6 +201,22 @@
185
201
  "hint": {
186
202
  "type": "string"
187
203
  },
204
+ "params": {
205
+ "type": "object",
206
+ "patternProperties": {
207
+ "^.*$": {
208
+ "anyOf": [
209
+ {
210
+ "type": "string"
211
+ },
212
+ {
213
+ "type": "number"
214
+ }
215
+ ]
216
+ }
217
+ },
218
+ "description": "Names and counts the Panel puts into its own translated sentence for `code`; `form` picks a variant of it. The `message` says the same in English."
219
+ },
188
220
  "source": {
189
221
  "type": "string"
190
222
  },
@@ -220,6 +252,22 @@
220
252
  },
221
253
  "message": {
222
254
  "type": "string"
255
+ },
256
+ "params": {
257
+ "type": "object",
258
+ "patternProperties": {
259
+ "^.*$": {
260
+ "anyOf": [
261
+ {
262
+ "type": "string"
263
+ },
264
+ {
265
+ "type": "number"
266
+ }
267
+ ]
268
+ }
269
+ },
270
+ "description": "Names and counts the Panel puts into its own translated sentence for `code`; `form` picks a variant of it. The `message` says the same in English."
223
271
  }
224
272
  }
225
273
  }
@@ -0,0 +1,117 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "sideby/memory-set.json",
4
+ "type": "object",
5
+ "required": [
6
+ "schemaVersion",
7
+ "action",
8
+ "on",
9
+ "changed",
10
+ "applied",
11
+ "before",
12
+ "after",
13
+ "file"
14
+ ],
15
+ "properties": {
16
+ "schemaVersion": {
17
+ "type": "number",
18
+ "const": 1
19
+ },
20
+ "action": {
21
+ "anyOf": [
22
+ {
23
+ "type": "string",
24
+ "const": "on"
25
+ },
26
+ {
27
+ "type": "string",
28
+ "const": "off"
29
+ }
30
+ ]
31
+ },
32
+ "on": {
33
+ "type": "boolean",
34
+ "description": "Whether config `claude.shareMemory` is on now."
35
+ },
36
+ "changed": {
37
+ "type": "boolean"
38
+ },
39
+ "applied": {
40
+ "type": "boolean",
41
+ "description": "False when only the change was shown; run again with --yes (exit 10)."
42
+ },
43
+ "before": {
44
+ "type": "boolean"
45
+ },
46
+ "after": {
47
+ "type": "boolean"
48
+ },
49
+ "file": {
50
+ "type": "string",
51
+ "description": "The config file changed."
52
+ },
53
+ "_notice": {
54
+ "type": "object",
55
+ "properties": {
56
+ "update": {
57
+ "type": "object",
58
+ "required": [
59
+ "current",
60
+ "latest",
61
+ "command",
62
+ "message"
63
+ ],
64
+ "properties": {
65
+ "current": {
66
+ "type": "string"
67
+ },
68
+ "latest": {
69
+ "type": "string"
70
+ },
71
+ "command": {
72
+ "type": "string",
73
+ "description": "Run it after the user agrees: it shows the plan and exits 10; then --yes."
74
+ },
75
+ "message": {
76
+ "type": "string"
77
+ }
78
+ }
79
+ },
80
+ "skill": {
81
+ "type": "object",
82
+ "required": [
83
+ "installed",
84
+ "current",
85
+ "command",
86
+ "message"
87
+ ],
88
+ "properties": {
89
+ "installed": {
90
+ "anyOf": [
91
+ {
92
+ "type": "string"
93
+ },
94
+ {
95
+ "type": "null"
96
+ }
97
+ ],
98
+ "description": "The skill's version; null when it has none."
99
+ },
100
+ "current": {
101
+ "type": "string"
102
+ },
103
+ "command": {
104
+ "type": "string",
105
+ "description": "`sideby update`, which updates the skill with sideby: run it after the user agrees; it shows the plan and exits 10, then --yes."
106
+ },
107
+ "message": {
108
+ "type": "string"
109
+ }
110
+ }
111
+ }
112
+ },
113
+ "description": "Not the answer to the task: mention it briefly afterwards and offer to update."
114
+ }
115
+ },
116
+ "title": "sideby memory on|off --json"
117
+ }