sideby 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +11 -1
  2. package/ai-tasks.json +90 -0
  3. package/dist/build.json +1 -1
  4. package/dist/src/cli/commands.d.ts +9 -1
  5. package/dist/src/cli/commands.js +507 -26
  6. package/dist/src/cli/json-schemas.js +196 -19
  7. package/dist/src/cli/main.js +79 -13
  8. package/dist/src/core/after-install.d.ts +54 -0
  9. package/dist/src/core/after-install.js +78 -0
  10. package/dist/src/core/ask.d.ts +87 -1
  11. package/dist/src/core/ask.js +122 -7
  12. package/dist/src/core/autostart.d.ts +38 -8
  13. package/dist/src/core/autostart.js +85 -39
  14. package/dist/src/core/brand-mark.d.ts +49 -11
  15. package/dist/src/core/brand-mark.js +116 -38
  16. package/dist/src/core/browser-profiles.js +7 -32
  17. package/dist/src/core/config.d.ts +19 -0
  18. package/dist/src/core/config.js +75 -2
  19. package/dist/src/core/desktop-app.d.ts +1 -1
  20. package/dist/src/core/desktop-app.js +2 -2
  21. package/dist/src/core/edit-settings.d.ts +24 -0
  22. package/dist/src/core/edit-settings.js +97 -0
  23. package/dist/src/core/handoff-brief.d.ts +4 -2
  24. package/dist/src/core/handoff-brief.js +6 -1
  25. package/dist/src/core/handoff-chain.d.ts +24 -0
  26. package/dist/src/core/handoff-chain.js +2 -0
  27. package/dist/src/core/handoff-run.d.ts +4 -3
  28. package/dist/src/core/handoff-run.js +14 -9
  29. package/dist/src/core/launch.d.ts +2 -0
  30. package/dist/src/core/launch.js +14 -10
  31. package/dist/src/core/local-build.d.ts +12 -5
  32. package/dist/src/core/local-build.js +49 -31
  33. package/dist/src/core/lock.d.ts +30 -0
  34. package/dist/src/core/lock.js +143 -0
  35. package/dist/src/core/pick-commands.d.ts +42 -0
  36. package/dist/src/core/pick-commands.js +44 -0
  37. package/dist/src/core/quota-levels.d.ts +6 -1
  38. package/dist/src/core/quota-levels.js +16 -5
  39. package/dist/src/core/shell-init.js +3 -1
  40. package/dist/src/core/shell-setup.d.ts +40 -0
  41. package/dist/src/core/shell-setup.js +54 -0
  42. package/dist/src/core/skill-check.d.ts +2 -0
  43. package/dist/src/core/skill-check.js +2 -0
  44. package/dist/src/core/task-spec.d.ts +95 -0
  45. package/dist/src/core/task-spec.js +209 -0
  46. package/dist/src/core/terminal.d.ts +21 -4
  47. package/dist/src/core/terminal.js +155 -10
  48. package/dist/src/core/update.d.ts +27 -16
  49. package/dist/src/core/update.js +69 -95
  50. package/dist/src/core/windows-dirs.d.ts +19 -0
  51. package/dist/src/core/windows-dirs.js +39 -0
  52. package/dist/src/desktop/icon.js +12 -15
  53. package/dist/src/families/claude/ai-task.d.ts +8 -0
  54. package/dist/src/families/claude/ai-task.js +38 -0
  55. package/dist/src/families/claude/handoff-hook.js +4 -4
  56. package/dist/src/families/claude/index.js +3 -0
  57. package/dist/src/families/codex/handoff-hook.js +4 -4
  58. package/dist/src/families/codex/index.js +9 -0
  59. package/dist/src/families/grok/handoff-hook.js +4 -4
  60. package/dist/src/families/grok/index.js +1 -0
  61. package/dist/src/families/pi/index.js +1 -0
  62. package/dist/src/handoff/hook.js +51 -30
  63. package/dist/src/handoff/levels.d.ts +24 -0
  64. package/dist/src/handoff/levels.js +70 -0
  65. package/dist/src/handoff/messages.d.ts +6 -3
  66. package/dist/src/handoff/messages.js +20 -7
  67. package/dist/src/handoff/reader.d.ts +6 -3
  68. package/dist/src/menubar/agent.d.ts +3 -0
  69. package/dist/src/menubar/agent.js +21 -0
  70. package/dist/src/menubar/script.d.ts +8 -0
  71. package/dist/src/menubar/script.js +457 -0
  72. package/dist/src/menubar/snapshot.d.ts +115 -0
  73. package/dist/src/menubar/snapshot.js +255 -0
  74. package/dist/src/menubar/strings.d.ts +87 -0
  75. package/dist/src/menubar/strings.js +88 -0
  76. package/dist/src/panel/background.js +12 -19
  77. package/dist/src/panel/handler.d.ts +30 -0
  78. package/dist/src/panel/handler.js +148 -80
  79. package/dist/src/panel/i18n.d.ts +72 -0
  80. package/dist/src/panel/i18n.js +144 -0
  81. package/dist/src/panel/page-logic.d.ts +105 -0
  82. package/dist/src/panel/page-logic.js +170 -15
  83. package/dist/src/panel/page-script.js +419 -111
  84. package/dist/src/panel/page-styles.js +45 -13
  85. package/dist/src/panel/page.d.ts +7 -0
  86. package/dist/src/panel/page.js +11 -1
  87. package/dist/src/runtime.d.ts +44 -2
  88. package/dist/src/runtime.js +107 -6
  89. package/dist/src/types.d.ts +14 -0
  90. package/package.json +4 -3
  91. package/schemas/alias-list.json +119 -0
  92. package/schemas/alias.json +27 -1
  93. package/schemas/ask-choices.json +168 -0
  94. package/schemas/ask-print.json +87 -0
  95. package/schemas/config.json +28 -1
  96. package/schemas/edit.json +119 -0
  97. package/schemas/error.json +4 -0
  98. package/schemas/families.json +4 -0
  99. package/schemas/list.json +4 -0
  100. package/schemas/local.json +1 -1
  101. package/schemas/menubar-snapshot.json +646 -0
  102. package/schemas/menubar-start.json +112 -0
  103. package/schemas/menubar.json +165 -0
  104. package/schemas/new.json +19 -0
  105. package/schemas/shell-init-setup.json +124 -0
  106. package/skills/sideby/SKILL.md +11 -4
  107. package/skills/sideby/references/accounts.md +10 -0
  108. package/skills/sideby/references/ai-tasks.md +10 -0
  109. package/skills/sideby/references/handoff.md +3 -1
  110. package/skills/sideby/references/panel.md +6 -0
  111. package/skills/sideby/references/setup.md +1 -1
  112. package/skills/sideby/references/update.md +1 -1
@@ -18,29 +18,56 @@ const defaultExec = (file, args) => new Promise((resolve) => {
18
18
  resolve({ code, output: `${stdout}${stderr}` });
19
19
  });
20
20
  });
21
- export const autostartPath = (home) => join(home, 'Library', 'LaunchAgents', `${AUTOSTART_LABEL}.plist`);
21
+ export const PANEL_AGENT = {
22
+ label: AUTOSTART_LABEL,
23
+ marker: AUTOSTART_MARKER,
24
+ command: 'autostart',
25
+ comment: 'starts the sideby panel in the background at login',
26
+ programArguments: (l) => programArgumentsFor(l),
27
+ launcherPaths: (args) => args.slice(0, 2),
28
+ later: 'the panel starts at your next login, or now with `sideby ui --background`',
29
+ };
30
+ export const agentPath = (home, agent) => join(home, 'Library', 'LaunchAgents', `${agent.label}.plist`);
31
+ export const autostartPath = (home) => agentPath(home, PANEL_AGENT);
22
32
  const xml = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
23
33
  const unxml = (s) => s.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&');
24
34
  export const programArgumentsFor = (l) => [l.node, l.entry, 'ui', '--background', '--no-open'];
25
- /** The agent's file: starts the Panel once at login, never again by itself, and lets it outlive the job. */
26
- export function plistContent(args) {
35
+ /**
36
+ * The agent's file. The Panel's starts once at login, never again by itself, and outlives the job; an agent with
37
+ * `restartOnCrash` is the long-running process itself, which launchd starts again only after a failed exit.
38
+ */
39
+ export function plistContent(args, agent = PANEL_AGENT, environment = {}) {
40
+ const vars = Object.entries(environment);
27
41
  return `<?xml version="1.0" encoding="UTF-8"?>
28
42
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
29
- <!-- ${AUTOSTART_MARKER}: starts the sideby panel in the background at login. Turn it off with \`sideby autostart off\`. -->
43
+ <!-- ${agent.marker}: ${agent.comment}. Turn it off with \`sideby ${agent.command} off\`. -->
30
44
  <plist version="1.0">
31
45
  <dict>
32
46
  <key>Label</key>
33
- <string>${AUTOSTART_LABEL}</string>
47
+ <string>${agent.label}</string>
34
48
  <key>ProgramArguments</key>
35
49
  <array>
36
50
  ${args.map((a) => ` <string>${xml(a)}</string>`).join('\n')}
37
51
  </array>
38
- <key>RunAtLoad</key>
52
+ ${vars.length
53
+ ? ` <key>EnvironmentVariables</key>
54
+ <dict>
55
+ ${vars.map(([k, v]) => ` <key>${xml(k)}</key>\n <string>${xml(v)}</string>`).join('\n')}
56
+ </dict>
57
+ `
58
+ : ''} <key>RunAtLoad</key>
39
59
  <true/>
40
60
  <key>KeepAlive</key>
41
- <false/>
61
+ ${agent.restartOnCrash
62
+ ? ` <dict>
63
+ <key>SuccessfulExit</key>
64
+ <false/>
65
+ </dict>
66
+ <key>ThrottleInterval</key>
67
+ <integer>30</integer>`
68
+ : ` <false/>
42
69
  <key>AbandonProcessGroup</key>
43
- <true/>
70
+ <true/>`}
44
71
  </dict>
45
72
  </plist>
46
73
  `;
@@ -65,12 +92,12 @@ async function readAgent(path) {
65
92
  }
66
93
  }
67
94
  /** Whether a sideby agent (with the marker) is installed; reads only that one file. */
68
- export async function autostartInstalled(home) {
69
- const content = await readAgent(autostartPath(home)).catch(() => null);
70
- return content?.includes(AUTOSTART_MARKER) ?? false;
95
+ export async function autostartInstalled(home, agent = PANEL_AGENT) {
96
+ const content = await readAgent(agentPath(home, agent)).catch(() => null);
97
+ return content?.includes(agent.marker) ?? false;
71
98
  }
72
- export async function autostartStatus(ctx) {
73
- const path = autostartPath(ctx.home);
99
+ export async function autostartStatus(ctx, agent = PANEL_AGENT) {
100
+ const path = agentPath(ctx.home, agent);
74
101
  const supported = platformOf(ctx) === 'darwin';
75
102
  const base = { supported, ...(supported ? {} : { reason: UNSUPPORTED }), path, current: false };
76
103
  if (!supported)
@@ -78,15 +105,15 @@ export async function autostartStatus(ctx) {
78
105
  const content = await readAgent(path);
79
106
  if (content === null)
80
107
  return { ...base, state: 'off' };
81
- const args = content.includes(AUTOSTART_MARKER) ? parseProgramArguments(content) : null;
108
+ const args = content.includes(agent.marker) ? parseProgramArguments(content) : null;
82
109
  if (!args)
83
110
  return { ...base, state: 'foreign' };
84
111
  const missing = [];
85
- for (const p of args.slice(0, 2))
112
+ for (const p of agent.launcherPaths(args))
86
113
  if (!(await statOrNull(p)))
87
114
  missing.push(p);
88
115
  const launcher = ctx.launcher ?? askLauncher();
89
- const want = programArgumentsFor(launcher);
116
+ const want = agent.programArguments(launcher);
90
117
  const current = args.length === want.length && args.every((a, i) => a === want[i]);
91
118
  return {
92
119
  ...base,
@@ -105,22 +132,22 @@ async function inTempDir(path) {
105
132
  return roots.some((r) => path.startsWith(r));
106
133
  }
107
134
  /** Why the agent cannot start this launcher, with what to do instead; null when it can. */
108
- export async function autostartLauncherProblem(l) {
135
+ export async function autostartLauncherProblem(l, command = 'autostart') {
109
136
  const p = launcherProblem(l);
110
137
  if (p?.reason === 'npx-cache')
111
138
  return {
112
139
  code: 'npx-cache',
113
- message: 'sideby runs from the npx cache, which npm may clear, so it cannot start at login from there; install it with `npm i -g sideby`, then run `sideby autostart on` again',
140
+ message: `sideby runs from the npx cache, which npm may clear, so it cannot start at login from there; install it with \`npm i -g sideby\`, then run \`sideby ${command} on\` again`,
114
141
  };
115
142
  if (p)
116
143
  return {
117
144
  code: 'unsafe-path',
118
- message: 'the path of sideby or Node has characters a login item cannot run safely; install sideby with `npm i -g sideby` in an ordinary folder, then run `sideby autostart on` again',
145
+ message: `the path of sideby or Node has characters a login item cannot run safely; install sideby with \`npm i -g sideby\` in an ordinary folder, then run \`sideby ${command} on\` again`,
119
146
  };
120
147
  if ((await inTempDir(l.entry)) || (await inTempDir(l.node)))
121
148
  return {
122
149
  code: 'temp-dir',
123
- message: 'sideby or Node runs from a temporary folder that the system empties, so it cannot start at login from there; install it with `npm i -g sideby`, then run `sideby autostart on` again',
150
+ message: `sideby or Node runs from a temporary folder that the system empties, so it cannot start at login from there; install it with \`npm i -g sideby\`, then run \`sideby ${command} on\` again`,
124
151
  };
125
152
  return null;
126
153
  }
@@ -131,10 +158,14 @@ const bootstrap = (ctx, path) => [
131
158
  `gui/${uidOf(ctx)}`,
132
159
  path,
133
160
  ];
134
- const bootout = (ctx) => ['launchctl', 'bootout', `gui/${uidOf(ctx)}/${AUTOSTART_LABEL}`];
161
+ const bootout = (ctx, agent) => [
162
+ 'launchctl',
163
+ 'bootout',
164
+ `gui/${uidOf(ctx)}/${agent.label}`,
165
+ ];
135
166
  /** What `on` or `off` would change; writes nothing. */
136
- export async function planAutostart(ctx, action) {
137
- const status = await autostartStatus(ctx);
167
+ export async function planAutostart(ctx, action, agent = PANEL_AGENT) {
168
+ const status = await autostartStatus(ctx, agent);
138
169
  const path = status.path;
139
170
  const hash = status.supported ? await fileHash(path) : null;
140
171
  const plan = (extra) => ({
@@ -152,25 +183,39 @@ export async function planAutostart(ctx, action) {
152
183
  return plan({
153
184
  blocked: {
154
185
  code: 'foreign',
155
- message: `${path} was not written by sideby, so sideby leaves it alone; look at it, and remove or rename it yourself before \`sideby autostart ${action}\` if it is not needed`,
186
+ message: `${path} was not written by sideby, so sideby leaves it alone; look at it, and remove or rename it yourself before \`sideby ${agent.command} ${action}\` if it is not needed`,
156
187
  },
157
188
  });
158
189
  if (action === 'off')
159
- return status.state === 'off' ? plan({}) : plan({ changed: true, commands: [bootout(ctx)] });
190
+ return status.state === 'off' ? plan({}) : plan({ changed: true, commands: [bootout(ctx, agent)] });
160
191
  const launcher = ctx.launcher ?? askLauncher();
161
- const blocked = await autostartLauncherProblem(launcher);
192
+ const blocked = await autostartLauncherProblem(launcher, agent.command);
162
193
  if (blocked)
163
194
  return plan({ blocked });
164
- const programArguments = programArgumentsFor(launcher);
165
- const content = plistContent(programArguments);
195
+ const programArguments = agent.programArguments(launcher);
196
+ const content = plistContent(programArguments, agent, agent.environment?.(ctx.env ?? process.env));
166
197
  const same = hash !== null && hash === sha256(content);
198
+ // The file alone does not start it: launchd may have let it go (a `launchctl bootout`, a failed start), and then
199
+ // only loading it again brings it back.
200
+ const loaded = !same || (await agentLoaded(ctx, agent));
167
201
  return plan({
168
- changed: !same,
202
+ changed: !same || !loaded,
169
203
  content,
170
204
  programArguments,
171
- commands: same ? [] : [...(status.state === 'off' ? [] : [bootout(ctx)]), bootstrap(ctx, path)],
205
+ commands: same
206
+ ? loaded
207
+ ? []
208
+ : [bootstrap(ctx, path)]
209
+ : [...(status.state === 'off' ? [] : [bootout(ctx, agent)]), bootstrap(ctx, path)],
172
210
  });
173
211
  }
212
+ /** Whether launchd holds the agent now; asks only for the login home, and counts any other HOME as loaded. */
213
+ async function agentLoaded(ctx, agent) {
214
+ if (launchctlNote(ctx))
215
+ return true;
216
+ const r = await (ctx.exec ?? defaultExec)('launchctl', ['print', `gui/${uidOf(ctx)}/${agent.label}`]).catch(() => null);
217
+ return r === null || r.code === 0;
218
+ }
174
219
  /** Whether launchctl may run: only for the login user's own LaunchAgents, never for a demo or test HOME. */
175
220
  function launchctlNote(ctx) {
176
221
  let login = ctx.loginHome;
@@ -186,7 +231,7 @@ function launchctlNote(ctx) {
186
231
  : `HOME (${ctx.home}) is not your login home, so launchd was not told; it reads this file only from your login home`;
187
232
  }
188
233
  /** Carries out a plan the user confirmed. Refuses, changing nothing, when the file changed since it was planned. */
189
- export async function applyAutostart(ctx, plan) {
234
+ export async function applyAutostart(ctx, plan, agent = PANEL_AGENT) {
190
235
  if (plan.blocked)
191
236
  throw new UserError(plan.blocked.message, { code: plan.blocked.code });
192
237
  const path = plan.path;
@@ -206,13 +251,14 @@ export async function applyAutostart(ctx, plan) {
206
251
  const note = launchctlNote(ctx);
207
252
  const run = async (cmd) => (note ? null : exec(cmd[0], cmd.slice(1)));
208
253
  if (plan.action === 'off') {
209
- // Not loaded (already out, or never in) is fine: the file is what starts it at the next login.
210
- await run(bootout(ctx));
254
+ // The file goes first: bootout ends the job's whole process group, which holds this process when the menu bar
255
+ // item's own "Hide" runs it. Not loaded (already out, or never in) is fine: the file starts it at the next login.
211
256
  await rm(path, { force: true });
257
+ await run(bootout(ctx, agent));
212
258
  return { changed: true, state: 'off', path, loaded: note === null, ...(note ? { note } : {}) };
213
259
  }
214
260
  if (plan.status.state !== 'off')
215
- await run(bootout(ctx));
261
+ await run(bootout(ctx, agent));
216
262
  await mkdir(dirname(path), { recursive: true, mode: 0o755 });
217
263
  // launchd skips an agent that others can write; 644 is what it expects.
218
264
  if (!(await writeIfUnchanged(path, plan.hash, plan.content, 0o644)))
@@ -230,24 +276,24 @@ export async function applyAutostart(ctx, plan) {
230
276
  if (note)
231
277
  result.note = note;
232
278
  else if (r && r.code !== 0)
233
- result.note = `launchctl bootstrap failed (exit ${r.code}); the panel starts at your next login, or now with \`sideby ui --background\``;
279
+ result.note = `launchctl bootstrap failed (exit ${r.code}); ${agent.later}`;
234
280
  return result;
235
281
  }
236
282
  /**
237
283
  * After `sideby update` or `pnpm local`: rewrites an existing sideby agent so it starts `launcher`. Never creates one,
238
284
  * never touches a foreign file, and never throws; `rewritten` says whether the file changed.
239
285
  */
240
- export async function refreshAutostart(ctx) {
286
+ export async function refreshAutostart(ctx, agent = PANEL_AGENT) {
241
287
  let state = 'off';
242
288
  try {
243
- const status = await autostartStatus(ctx);
289
+ const status = await autostartStatus(ctx, agent);
244
290
  state = status.state;
245
291
  if (status.state !== 'on' && status.state !== 'stale')
246
292
  return { rewritten: false, state: status.state };
247
- const plan = await planAutostart(ctx, 'on');
293
+ const plan = await planAutostart(ctx, 'on', agent);
248
294
  if (plan.blocked)
249
295
  return { rewritten: false, state: status.state, note: plan.blocked.message };
250
- const r = await applyAutostart(ctx, plan);
296
+ const r = await applyAutostart(ctx, plan, agent);
251
297
  return { rewritten: r.changed, state: r.state, ...(r.note ? { note: r.note } : {}) };
252
298
  }
253
299
  catch (err) {
@@ -1,10 +1,12 @@
1
- /** An outlined shape of one buddy, as SVG path data on its 64-unit grid. */
1
+ /** A colour by name, or a fixed hex colour for a prop. */
2
+ export type Paint = 'ink' | 'light' | `#${string}`;
3
+ /** An outlined shape of one buddy, as SVG path data (absolute M, L, H, Q, C, Z) on its 64-unit grid. */
2
4
  export interface BuddyPath {
3
5
  d: string;
4
6
  /** `body`, `shade`: the buddy's own colours; `none`: an open line. */
5
- fill: 'body' | 'shade' | 'none';
6
- /** Line colour; `chevron` is the buddy's accent colour. Default ink. */
7
- stroke?: 'ink' | 'chevron';
7
+ fill: 'body' | 'shade' | 'none' | Paint;
8
+ /** Line colour; `none` draws no line. Default ink. */
9
+ stroke?: Paint | 'none';
8
10
  /** Line width on the 64-unit grid, before the buddy's scale. Default: the outline width. */
9
11
  width?: number;
10
12
  }
@@ -16,36 +18,46 @@ export interface BuddyDot {
16
18
  ry: number;
17
19
  fill: 'ink' | 'light';
18
20
  }
19
- /** Back to front: feet, arms, body, then the face. */
21
+ /** The body both buddies share, back to front: feet, arms, body; then the eyes. No forehead `>`: that belongs to Nika. */
20
22
  export declare const BUDDY: {
21
23
  paths: readonly BuddyPath[];
22
24
  eyes: readonly BuddyDot[];
23
25
  };
26
+ /** What one buddy wears and how it smiles: `behind` the body, its `mouth`, and `above` the face. */
27
+ export interface BuddyProps {
28
+ behind: readonly BuddyPath[];
29
+ mouth: BuddyPath;
30
+ above: readonly BuddyPath[];
31
+ }
32
+ /** Sai (blue): a red cape behind the shoulders, a gold crown with a red jewel, a small smile. */
33
+ export declare const SAI: BuddyProps;
34
+ /** Bai (amber): a green spare battery on its back, a bent antenna with a ball, an open laugh. */
35
+ export declare const BAI: BuddyProps;
24
36
  /** The eye highlights sit towards where the buddy looks: `1` right, `-1` left. */
25
37
  export declare function highlights(look: 1 | -1): BuddyDot[];
26
38
  export interface BuddyColors {
27
39
  body: string;
28
40
  shade: string;
29
- chevron: string;
30
41
  }
31
42
  export declare const MARK_COLORS: {
32
43
  readonly blue: {
33
44
  readonly body: '#3f8fc4';
34
45
  readonly shade: '#29658e';
35
- readonly chevron: '#f2b35e';
36
46
  };
37
47
  readonly amber: {
38
48
  readonly body: '#f2b35e';
39
49
  readonly shade: '#c98a35';
40
- readonly chevron: '#3f8fc4';
41
50
  };
42
51
  readonly ink: '#1e2a44';
43
52
  readonly light: '#f6f0e5';
44
53
  };
45
54
  export interface PlacedBuddy {
46
55
  colors: BuddyColors;
56
+ props: BuddyProps;
47
57
  /** Where the buddy looks (and which way its eye highlights sit). */
48
58
  look: 1 | -1;
59
+ /** Mirror the props left to right, so what is worn on the back stays behind a buddy that turns the other way. */
60
+ mirror?: boolean;
49
61
  /** 64-unit grid → mark units: translate by (x, y), then scale. */
50
62
  x: number;
51
63
  y: number;
@@ -64,6 +76,27 @@ export declare const MARK_VIEWBOX: {
64
76
  readonly y: 3;
65
77
  readonly size: 69;
66
78
  };
79
+ /** Path data mirrored on the 64-unit grid (x → 64 − x); absolute M, L, H, Q, C, Z only. */
80
+ export declare function mirrorPath(d: string): string;
81
+ /** One shape of a placed buddy with its colours resolved; `fill` undefined inherits the surrounding fill. */
82
+ export interface BuddyShape {
83
+ d: string;
84
+ fill: string | undefined;
85
+ stroke: string;
86
+ width?: number;
87
+ }
88
+ /**
89
+ * One buddy's shapes, back to front: the props behind, the body, the mouth, the eyes, the props above.
90
+ * `bodyFill`: `undefined` keeps the buddy's body colour, `null` leaves the body unfilled so it inherits.
91
+ */
92
+ export declare function buddyShapes(b: PlacedBuddy, bodyFill?: string | null): {
93
+ paths: BuddyShape[];
94
+ above: BuddyShape[];
95
+ dots: BuddyDot[];
96
+ };
97
+ /** One placed buddy as SVG, drawn inside a group that sets the ink outline (`MARK_OUTLINE`). */
98
+ export declare function buddySvg(b: PlacedBuddy, line: number, bodyFill?: string | null): string;
99
+ export declare const MARK_OUTLINE: string;
67
100
  /**
68
101
  * The mark as SVG children (no outer <svg>). With `front` omitted the blue buddy's body has no fill of its own, so it
69
102
  * takes the surrounding `fill` (the Panel's `--logo-fg`, which Portals set with `logoColor`); everything else is fixed.
@@ -74,8 +107,13 @@ export declare const MARK_SVG: string;
74
107
  /** `<basePath>/icon.svg`: the whole mark on a transparent square, for a Portal's tab or menu (ADR-0006 amendment). */
75
108
  export declare const ICON_SVG: string;
76
109
  /**
77
- * `<basePath>/favicon.svg`: the small cut for sizes below about 24 px, redrawn for a 16 pt browser tab (ADR-0022):
78
- * the blue buddy alone on a 32 grid, its body filling the width, short feet and no arms, `>` or mouth, bigger eyes,
79
- * and a 2-unit outline (about 6% of the canvas). The same rules as the Local tools Portal's tab icons.
110
+ * `<basePath>/favicon.svg`: the small cut for sizes below about 24 px, for a 16 pt browser tab (ADR-0022): Sai alone
111
+ * on a 32 grid at half scale, his body, eyes, cape and crown; no feet, arms or mouth. The same cut as the tab icons
112
+ * of the brand design sheet.
80
113
  */
81
114
  export declare const FAVICON_SVG: string;
115
+ /**
116
+ * The Menu Bar Item's icon (spec §3.31): the favicon's small cut of Sai in colour, 18 pt square. It keeps its colours
117
+ * in light and dark mode, as the brand's tab icons do; the body's dark outline keeps it visible on both.
118
+ */
119
+ export declare const MENUBAR_ICON_SVG: string;
@@ -1,8 +1,10 @@
1
1
  // The sideby mark: two buddies side by side, the amber one behind on the left and the blue one in front on the right,
2
2
  // looking at each other (ADR-0022, the characters of the intro film). One source for the Panel header, the empty
3
3
  // state, the Portal icon, the favicon and the app icon.
4
- // One buddy is drawn on a 64-unit grid; the mark places two of them with a translate and a scale.
5
- /** Back to front: feet, arms, body, then the face. */
4
+ // One buddy is drawn on a 64-unit grid; the mark places two of them with a translate and a scale. Both share one
5
+ // gumdrop body; what tells them apart is a pair of props each, from the brand design sheet (ADR-0022 amendment):
6
+ // Sai, the blue one, wears a gold crown and a red cape; Bai, the amber one, a bent antenna and a spare battery.
7
+ /** The body both buddies share, back to front: feet, arms, body; then the eyes. No forehead `>`: that belongs to Nika. */
6
8
  export const BUDDY = {
7
9
  paths: [
8
10
  { d: 'M17 48 Q15 58 22 57 Q27 57 27 50 M37 50 Q37 57 42 57 Q49 58 47 48', fill: 'shade' },
@@ -11,14 +13,49 @@ export const BUDDY = {
11
13
  d: 'M12 37 C12 27 17 23 25 23 H39 C47 23 52 27 52 37 C52 48 45 53 32 53 C19 53 12 48 12 37 Z',
12
14
  fill: 'body',
13
15
  },
14
- { d: 'M30 27 L34 29.31 L30 31.62', fill: 'none', stroke: 'chevron', width: 2.5 },
15
- { d: 'M29 46 Q32 49 35 46', fill: 'none', width: 2.5 },
16
16
  ],
17
17
  eyes: [
18
18
  { cx: 22, cy: 38.5, rx: 4.5, ry: 6, fill: 'ink' },
19
19
  { cx: 42, cy: 38.5, rx: 4.5, ry: 6, fill: 'ink' },
20
20
  ],
21
21
  };
22
+ const RED = '#e0685a';
23
+ const GOLD = '#ffd977';
24
+ const GREEN = '#5bb06a';
25
+ /** Sai (blue): a red cape behind the shoulders, a gold crown with a red jewel, a small smile. */
26
+ export const SAI = {
27
+ behind: [
28
+ { d: 'M19 29 Q10 27 9 34 L4 53 Q13 57 22 50 L42 50 Q51 57 60 53 L55 34 Q54 27 45 29 Z', fill: RED },
29
+ ],
30
+ mouth: { d: 'M29 46 Q32 49 35 46', fill: 'none', width: 2.5 },
31
+ above: [
32
+ { d: 'M20 23 L17 10 L27 15 L32 6 L37 15 L47 10 L44 23 Z', fill: GOLD },
33
+ {
34
+ d: 'M35 19 C35 20.66 33.66 22 32 22 C30.34 22 29 20.66 29 19 C29 17.34 30.34 16 32 16 C33.66 16 35 17.34 35 19 Z',
35
+ fill: RED,
36
+ stroke: 'none',
37
+ },
38
+ ],
39
+ };
40
+ /** Bai (amber): a green spare battery on its back, a bent antenna with a ball, an open laugh. */
41
+ export const BAI = {
42
+ behind: [
43
+ {
44
+ d: 'M52 23 H56 C58.21 23 60 24.79 60 27 L60 48 C60 50.21 58.21 52 56 52 H52 C49.79 52 48 50.21 48 48 L48 27 C48 24.79 49.79 23 52 23 Z',
45
+ fill: GREEN,
46
+ },
47
+ { d: 'M52 23 L52 19 H57 L57 23', fill: GREEN },
48
+ { d: 'M51 32 H57 M54 29 L54 35', fill: 'none', stroke: 'light', width: 2 },
49
+ ],
50
+ mouth: { d: 'M29 46 Q32 52 35 46 Z', fill: 'ink', width: 2.5 },
51
+ above: [
52
+ { d: 'M31 24 C24 17 26 9 36 10', fill: 'none', stroke: GREEN, width: 4 },
53
+ {
54
+ d: 'M44 10 C44 12.76 41.76 15 39 15 C36.24 15 34 12.76 34 10 C34 7.24 36.24 5 39 5 C41.76 5 44 7.24 44 10 Z',
55
+ fill: GREEN,
56
+ },
57
+ ],
58
+ };
22
59
  /** The eye highlights sit towards where the buddy looks: `1` right, `-1` left. */
23
60
  export function highlights(look) {
24
61
  return BUDDY.eyes.map((e) => ({
@@ -30,8 +67,8 @@ export function highlights(look) {
30
67
  }));
31
68
  }
32
69
  export const MARK_COLORS = {
33
- blue: { body: '#3f8fc4', shade: '#29658e', chevron: '#f2b35e' },
34
- amber: { body: '#f2b35e', shade: '#c98a35', chevron: '#3f8fc4' },
70
+ blue: { body: '#3f8fc4', shade: '#29658e' },
71
+ amber: { body: '#f2b35e', shade: '#c98a35' },
35
72
  ink: '#1e2a44',
36
73
  light: '#f6f0e5',
37
74
  };
@@ -41,39 +78,76 @@ export const MARK = {
41
78
  line: 2.75,
42
79
  /** Outline width of a placed buddy before its scale, so the outline stays about 2.5 mark units. */
43
80
  placedLine: 3.6,
44
- back: { colors: MARK_COLORS.amber, look: 1, x: -2, y: 2, scale: 0.7 },
45
- front: { colors: MARK_COLORS.blue, look: -1, x: 22, y: 16, scale: 0.7 },
81
+ back: { colors: MARK_COLORS.amber, props: BAI, look: 1, mirror: true, x: -2, y: 2, scale: 0.7 },
82
+ front: { colors: MARK_COLORS.blue, props: SAI, look: -1, x: 22, y: 16, scale: 0.7 },
46
83
  };
47
84
  /** The square the pair is drawn in, in mark units (the Panel's 40 px tile and the app icon tile). */
48
85
  export const MARK_VIEWBOX = { x: -2.5, y: 3, size: 69 };
49
- function buddySvg(b, line, bodyFill) {
50
- const color = (fill) => {
51
- if (fill === 'none')
52
- return ' fill="none"';
53
- if (fill === 'shade')
54
- return ` fill="${b.colors.shade}"`;
55
- return bodyFill === null ? '' : ` fill="${bodyFill ?? b.colors.body}"`;
86
+ /** Path data mirrored on the 64-unit grid (x → 64 − x); absolute M, L, H, Q, C, Z only. */
87
+ export function mirrorPath(d) {
88
+ let cmd = '';
89
+ let n = 0;
90
+ return d.replace(/[MLHQCZ]|-?\d*\.?\d+/g, (t) => {
91
+ if (/[A-Z]/.test(t)) {
92
+ cmd = t;
93
+ n = 0;
94
+ return t;
95
+ }
96
+ const isX = cmd === 'H' || n++ % 2 === 0;
97
+ return isX ? String(Math.round((64 - Number(t)) * 1000) / 1000) : t;
98
+ });
99
+ }
100
+ const paint = (p) => (p === 'ink' ? MARK_COLORS.ink : p === 'light' ? MARK_COLORS.light : p);
101
+ /**
102
+ * One buddy's shapes, back to front: the props behind, the body, the mouth, the eyes, the props above.
103
+ * `bodyFill`: `undefined` keeps the buddy's body colour, `null` leaves the body unfilled so it inherits.
104
+ */
105
+ export function buddyShapes(b, bodyFill) {
106
+ const resolve = (p) => {
107
+ const fill = p.fill === 'none'
108
+ ? 'none'
109
+ : p.fill === 'shade'
110
+ ? b.colors.shade
111
+ : p.fill === 'body'
112
+ ? bodyFill === null
113
+ ? undefined
114
+ : (bodyFill ?? b.colors.body)
115
+ : paint(p.fill);
116
+ const stroke = p.stroke === undefined ? MARK_COLORS.ink : p.stroke === 'none' ? 'none' : paint(p.stroke);
117
+ return { d: p.d, fill, stroke, ...(p.width ? { width: p.width } : {}) };
56
118
  };
57
- const paths = BUDDY.paths
58
- .map((p) => {
59
- const stroke = p.stroke === 'chevron' ? ` stroke="${b.colors.chevron}"` : '';
60
- const width = p.width ? ` stroke-width="${p.width}"` : '';
61
- return `<path d="${p.d}"${color(p.fill)}${stroke}${width}/>`;
62
- })
63
- .join('');
64
- const dots = [...BUDDY.eyes, ...highlights(b.look)]
119
+ const prop = (p) => {
120
+ const s = resolve(p);
121
+ return b.mirror ? { ...s, d: mirrorPath(s.d) } : s;
122
+ };
123
+ return {
124
+ paths: [...b.props.behind.map(prop), ...BUDDY.paths.map(resolve), resolve(b.props.mouth)],
125
+ dots: [...BUDDY.eyes, ...highlights(b.look)],
126
+ above: b.props.above.map(prop),
127
+ };
128
+ }
129
+ function shapeSvg(s) {
130
+ const fill = s.fill === undefined ? '' : ` fill="${s.fill}"`;
131
+ const stroke = s.stroke === MARK_COLORS.ink ? '' : ` stroke="${s.stroke}"`;
132
+ const width = s.width ? ` stroke-width="${s.width}"` : '';
133
+ return `<path d="${s.d}"${fill}${stroke}${width}/>`;
134
+ }
135
+ /** One placed buddy as SVG, drawn inside a group that sets the ink outline (`MARK_OUTLINE`). */
136
+ export function buddySvg(b, line, bodyFill) {
137
+ const { paths, dots, above } = buddyShapes(b, bodyFill);
138
+ const eyes = dots
65
139
  .map((e) => `<ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" fill="${e.fill === 'ink' ? MARK_COLORS.ink : MARK_COLORS.light}"/>`)
66
140
  .join('');
67
141
  const transform = b.scale === 1 && b.x === 0 && b.y === 0 ? '' : ` transform="translate(${b.x} ${b.y}) scale(${b.scale})"`;
68
- return `<g${transform} stroke-width="${line}">${paths}<g stroke="none">${dots}</g></g>`;
142
+ return `<g${transform} stroke-width="${line}">${paths.map(shapeSvg).join('')}<g stroke="none">${eyes}</g>${above.map(shapeSvg).join('')}</g>`;
69
143
  }
70
- const OUTLINE = `stroke="${MARK_COLORS.ink}" stroke-linecap="round" stroke-linejoin="round"`;
144
+ export const MARK_OUTLINE = `stroke="${MARK_COLORS.ink}" stroke-linecap="round" stroke-linejoin="round"`;
71
145
  /**
72
146
  * The mark as SVG children (no outer <svg>). With `front` omitted the blue buddy's body has no fill of its own, so it
73
147
  * takes the surrounding `fill` (the Panel's `--logo-fg`, which Portals set with `logoColor`); everything else is fixed.
74
148
  */
75
149
  export function markSvgBody(front) {
76
- return `<g ${OUTLINE}>${buddySvg(MARK.back, MARK.placedLine)}${buddySvg(MARK.front, MARK.placedLine, front ?? null)}</g>`;
150
+ return `<g ${MARK_OUTLINE}>${buddySvg(MARK.back, MARK.placedLine)}${buddySvg(MARK.front, MARK.placedLine, front ?? null)}</g>`;
77
151
  }
78
152
  const viewBox = (v) => `${v.x} ${v.y} ${v.size} ${v.size}`;
79
153
  /** The Panel's header logo: the mark sized for its 40 px tile. */
@@ -82,20 +156,24 @@ export const MARK_SVG = `<svg viewBox="${viewBox(MARK_VIEWBOX)}">${markSvgBody()
82
156
  export const ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox(MARK_VIEWBOX)}" role="img" aria-label="sideby">` +
83
157
  `${markSvgBody(MARK_COLORS.blue.body)}</svg>`;
84
158
  /**
85
- * `<basePath>/favicon.svg`: the small cut for sizes below about 24 px, redrawn for a 16 pt browser tab (ADR-0022):
86
- * the blue buddy alone on a 32 grid, its body filling the width, short feet and no arms, `>` or mouth, bigger eyes,
87
- * and a 2-unit outline (about 6% of the canvas). The same rules as the Local tools Portal's tab icons.
159
+ * `<basePath>/favicon.svg`: the small cut for sizes below about 24 px, for a 16 pt browser tab (ADR-0022): Sai alone
160
+ * on a 32 grid at half scale, his body, eyes, cape and crown; no feet, arms or mouth. The same cut as the tab icons
161
+ * of the brand design sheet.
88
162
  */
89
163
  export const FAVICON_SVG = (() => {
90
- const blue = MARK_COLORS.blue;
91
- const ink = MARK_COLORS.ink;
92
- const light = MARK_COLORS.light;
164
+ const sai = { ...MARK.front, x: 0, y: 0, scale: 1 };
165
+ const { paths, dots, above } = buddyShapes(sai);
93
166
  const body = BUDDY.paths[2].d;
167
+ const keep = paths.filter((p) => p.d === body || SAI.behind.some((q) => q.d === p.d));
168
+ const eyes = dots
169
+ .map((e) => `<ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" fill="${e.fill === 'ink' ? MARK_COLORS.ink : MARK_COLORS.light}"/>`)
170
+ .join('');
94
171
  return (`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" role="img" aria-label="sideby">` +
95
- `<g stroke-linecap="round" stroke-linejoin="round" transform="translate(0 -1.3)">` +
96
- `<path d="M8.5 25 Q7.6 31 11.5 30.6 Q14 30.4 14 26.6 M18 26.6 Q18 30.4 20.5 30.6 Q24.4 31 23.5 25" fill="${blue.shade}" stroke="${ink}" stroke-width="2"/>` +
97
- `<g transform="translate(-7.2 -12.675) scale(0.725)"><path d="${body}" fill="${blue.body}" stroke="${ink}" stroke-width="2.759"/>` +
98
- `<ellipse cx="22.5" cy="38" rx="5.5" ry="7" fill="${ink}"/><ellipse cx="41.5" cy="38" rx="5.5" ry="7" fill="${ink}"/>` +
99
- `<ellipse cx="20.6" cy="35.4" rx="2.1" ry="2.6" fill="${light}"/><ellipse cx="39.6" cy="35.4" rx="2.1" ry="2.6" fill="${light}"/>` +
100
- `</g></g></svg>`);
172
+ `<g transform="translate(0 -1) scale(.5)"><g ${MARK_OUTLINE} stroke-width="${MARK.line}">` +
173
+ `${keep.map(shapeSvg).join('')}<g stroke="none">${eyes}</g>${above.map(shapeSvg).join('')}</g></g></svg>`);
101
174
  })();
175
+ /**
176
+ * The Menu Bar Item's icon (spec §3.31): the favicon's small cut of Sai in colour, 18 pt square. It keeps its colours
177
+ * in light and dark mode, as the brand's tab icons do; the body's dark outline keeps it visible on both.
178
+ */
179
+ export const MENUBAR_ICON_SVG = FAVICON_SVG.replace('<svg ', '<svg width="18" height="18" ');
@@ -13,6 +13,7 @@ import { editConfigBrowser } from './config.js';
13
13
  import { depsFor, findApp } from './desktop-app.js';
14
14
  import { UserError } from './errors.js';
15
15
  import { localStorageKeys } from './leveldb-keys.js';
16
+ import { askWindowsDirs } from './windows-dirs.js';
16
17
  const OPEN = '/usr/bin/open';
17
18
  export const CHROME = {
18
19
  title: 'Google Chrome',
@@ -25,41 +26,15 @@ const MAX_LOCAL_STATE = 16 * 1024 * 1024;
25
26
  export function chromeUserData(home) {
26
27
  return join(home, 'Library', 'Application Support', 'Google', 'Chrome');
27
28
  }
28
- /** A Windows drive path (`C:\Windows`) as WSL mounts it (`/mnt/c/Windows`); undefined for anything else. */
29
- function toUnix(win, mount) {
30
- const m = /^([A-Za-z]):\\(.*)$/.exec(win.trim());
31
- if (!m)
32
- return undefined;
33
- return join(mount, m[1].toLowerCase(), ...m[2].split('\\').filter(Boolean));
34
- }
35
- const windowsMemo = new Map();
29
+ /** Windows folders sideby needs on WSL, each as a Windows path and as the WSL path it is mounted at. */
36
30
  /**
37
- * `%LOCALAPPDATA%` and the Program Files folders, from one `cmd.exe` call, remembered for the process. When cmd.exe
38
- * fails, the only Windows user with Chrome data under `<mount>/c/Users`; several are not guessed between.
31
+ * `%LOCALAPPDATA%` and the Program Files folders (core/windows-dirs.ts). When cmd.exe fails, the only Windows user
32
+ * with Chrome data under `<mount>/c/Users`; several are not guessed between.
39
33
  */
40
34
  async function windowsDirs(deps, mount, problems) {
41
- const hit = windowsMemo.get(mount);
42
- if (hit)
43
- return hit;
44
- const r = await deps.exec(join(mount, 'c', 'Windows', 'System32', 'cmd.exe'), [
45
- '/d',
46
- '/c',
47
- 'echo %LOCALAPPDATA%^|%ProgramFiles%^|%ProgramFiles(x86)%',
48
- ]);
49
- const parts = r.code === 0 ? r.stdout.trim().split('|') : [];
50
- const dir = (win) => {
51
- const unix = win ? toUnix(win, mount) : undefined;
52
- return win && unix ? { win: win.trim(), unix } : undefined;
53
- };
54
- const local = dir(parts[0]);
55
- if (local) {
56
- const found = {
57
- localAppData: local,
58
- programs: [dir(parts[1]), dir(parts[2])].filter((d) => d !== undefined),
59
- };
60
- windowsMemo.set(mount, found);
61
- return found;
62
- }
35
+ const asked = await askWindowsDirs((file, args) => deps.exec(file, args), mount);
36
+ if (asked)
37
+ return asked;
63
38
  // cmd.exe did not answer (interop off, or no C: drive): look for the one Windows user that has Chrome.
64
39
  const users = join(mount, 'c', 'Users');
65
40
  const withChrome = [];