sideby 0.17.0 → 0.18.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 (95) hide show
  1. package/README.md +3 -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 +349 -14
  6. package/dist/src/cli/json-schemas.js +157 -18
  7. package/dist/src/cli/main.js +56 -7
  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 +73 -1
  11. package/dist/src/core/ask.js +106 -6
  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/config.d.ts +5 -0
  17. package/dist/src/core/config.js +11 -1
  18. package/dist/src/core/desktop-app.d.ts +1 -1
  19. package/dist/src/core/desktop-app.js +2 -2
  20. package/dist/src/core/edit-settings.d.ts +24 -0
  21. package/dist/src/core/edit-settings.js +97 -0
  22. package/dist/src/core/handoff-brief.d.ts +4 -2
  23. package/dist/src/core/handoff-brief.js +6 -1
  24. package/dist/src/core/handoff-chain.d.ts +24 -0
  25. package/dist/src/core/handoff-chain.js +2 -0
  26. package/dist/src/core/handoff-run.d.ts +4 -3
  27. package/dist/src/core/handoff-run.js +14 -9
  28. package/dist/src/core/launch.d.ts +2 -0
  29. package/dist/src/core/launch.js +14 -10
  30. package/dist/src/core/local-build.d.ts +12 -5
  31. package/dist/src/core/local-build.js +49 -31
  32. package/dist/src/core/lock.d.ts +30 -0
  33. package/dist/src/core/lock.js +143 -0
  34. package/dist/src/core/quota-levels.d.ts +6 -1
  35. package/dist/src/core/quota-levels.js +16 -5
  36. package/dist/src/core/task-spec.d.ts +95 -0
  37. package/dist/src/core/task-spec.js +209 -0
  38. package/dist/src/core/terminal.js +6 -1
  39. package/dist/src/core/update.d.ts +27 -16
  40. package/dist/src/core/update.js +67 -93
  41. package/dist/src/desktop/icon.js +12 -15
  42. package/dist/src/families/claude/ai-task.d.ts +8 -0
  43. package/dist/src/families/claude/ai-task.js +38 -0
  44. package/dist/src/families/claude/handoff-hook.js +4 -4
  45. package/dist/src/families/claude/index.js +3 -0
  46. package/dist/src/families/codex/handoff-hook.js +4 -4
  47. package/dist/src/families/codex/index.js +9 -0
  48. package/dist/src/families/grok/handoff-hook.js +4 -4
  49. package/dist/src/families/grok/index.js +1 -0
  50. package/dist/src/families/pi/index.js +1 -0
  51. package/dist/src/handoff/hook.js +51 -30
  52. package/dist/src/handoff/levels.d.ts +24 -0
  53. package/dist/src/handoff/levels.js +70 -0
  54. package/dist/src/handoff/messages.d.ts +6 -3
  55. package/dist/src/handoff/messages.js +20 -7
  56. package/dist/src/handoff/reader.d.ts +6 -3
  57. package/dist/src/menubar/agent.d.ts +3 -0
  58. package/dist/src/menubar/agent.js +21 -0
  59. package/dist/src/menubar/script.d.ts +8 -0
  60. package/dist/src/menubar/script.js +457 -0
  61. package/dist/src/menubar/snapshot.d.ts +115 -0
  62. package/dist/src/menubar/snapshot.js +255 -0
  63. package/dist/src/menubar/strings.d.ts +87 -0
  64. package/dist/src/menubar/strings.js +88 -0
  65. package/dist/src/panel/background.js +12 -19
  66. package/dist/src/panel/handler.d.ts +12 -0
  67. package/dist/src/panel/handler.js +80 -80
  68. package/dist/src/panel/i18n.d.ts +33 -0
  69. package/dist/src/panel/i18n.js +66 -0
  70. package/dist/src/panel/page-logic.d.ts +105 -0
  71. package/dist/src/panel/page-logic.js +170 -15
  72. package/dist/src/panel/page-script.js +238 -109
  73. package/dist/src/panel/page-styles.js +42 -13
  74. package/dist/src/panel/page.d.ts +7 -0
  75. package/dist/src/panel/page.js +5 -0
  76. package/dist/src/runtime.d.ts +9 -1
  77. package/dist/src/runtime.js +11 -3
  78. package/dist/src/types.d.ts +14 -0
  79. package/package.json +4 -3
  80. package/schemas/ask-choices.json +168 -0
  81. package/schemas/ask-print.json +87 -0
  82. package/schemas/config.json +17 -1
  83. package/schemas/edit.json +119 -0
  84. package/schemas/error.json +4 -0
  85. package/schemas/families.json +4 -0
  86. package/schemas/list.json +4 -0
  87. package/schemas/local.json +1 -1
  88. package/schemas/menubar-snapshot.json +646 -0
  89. package/schemas/menubar-start.json +112 -0
  90. package/schemas/menubar.json +165 -0
  91. package/skills/sideby/SKILL.md +6 -2
  92. package/skills/sideby/references/ai-tasks.md +10 -0
  93. package/skills/sideby/references/handoff.md +3 -1
  94. package/skills/sideby/references/panel.md +6 -0
  95. package/skills/sideby/references/update.md +1 -1
@@ -8,6 +8,28 @@ const ReasonCode = Type.Union(['local-build', 'npx', 'volta', 'not-writable', 'p
8
8
  const Level = Type.Union([Type.Literal('ok'), Type.Literal('warn'), Type.Literal('fail')]);
9
9
  const Kind = Type.Union([Type.Literal('subscription'), Type.Literal('api')]);
10
10
  const Version = Type.Literal(1);
11
+ /** `sideby autostart` and `sideby menubar` (ADR-0029, ADR-0034): a LaunchAgent sideby writes. */
12
+ const loginItem = (current) => Type.Object({
13
+ schemaVersion: Version,
14
+ supported: Type.Boolean({
15
+ description: 'False on a system sideby cannot start at login yet; `reason` says so.',
16
+ }),
17
+ reason: Type.Optional(Str),
18
+ state: Type.Union(['off', 'on', 'stale', 'foreign'].map((k) => Type.Literal(k)), {
19
+ description: '`stale`: the Node or sideby it starts no longer exists; `foreign`: a file at that path that sideby did not write.',
20
+ }),
21
+ path: Str,
22
+ programArguments: Type.Optional(Type.Array(Str)),
23
+ current: Type.Boolean({ description: current }),
24
+ missing: Type.Optional(Type.Array(Str)),
25
+ action: Type.Optional(Type.Union([Type.Literal('on'), Type.Literal('off')])),
26
+ changed: Type.Optional(Type.Boolean()),
27
+ applied: Type.Optional(Type.Boolean()),
28
+ content: Type.Optional(Type.String({ description: 'The file `on` writes.' })),
29
+ commands: Type.Optional(Type.Array(Type.Array(Str))),
30
+ loaded: Type.Optional(Type.Boolean({ description: 'launchd took the change now.' })),
31
+ note: Type.Optional(Str),
32
+ });
11
33
  const Choice = Type.Object({ model: Type.Optional(Str), effort: Type.Optional(Str) });
12
34
  const Shown = Type.Object({
13
35
  value: Str,
@@ -60,6 +82,9 @@ const FamilyInfo = Type.Object({
60
82
  brokenBin: Type.Optional(Str),
61
83
  plugin: Str,
62
84
  tuning: Type.Boolean(),
85
+ settingsFile: Type.Optional(Type.String({
86
+ description: "The Host's settings file `sideby edit` opens, relative to the account directory.",
87
+ })),
63
88
  });
64
89
  const ShareModeSchema = Type.Union(['link', 'copy', 'link-or-copy', 'link-or-local', 'local', 'local-if-api', 'info', 'json-key'].map((m) => Type.Literal(m)));
65
90
  const FamilyDetail = Type.Intersect([
@@ -315,6 +340,28 @@ const Overview = Type.Object({
315
340
  ]),
316
341
  })),
317
342
  });
343
+ const MenubarLevel = Type.Union(['ok', 'warn', 'fail', 'none'].map((k) => Type.Literal(k)));
344
+ const MenubarBar = Type.Union([
345
+ Type.Object({ label: Str, percent: Type.Number(), level: MenubarLevel }),
346
+ Type.Null(),
347
+ ]);
348
+ const MenubarRow = Type.Object({
349
+ ref: Str,
350
+ label: Str,
351
+ detail: Type.String({ description: 'The whole row as one line of text.' }),
352
+ level: MenubarLevel,
353
+ recommended: Type.Boolean({ description: 'The account `sideby next` would pick in this Family.' }),
354
+ tip: Type.String({ description: 'Hover text: when each window resets, and what a click does.' }),
355
+ bars: Type.Union([Type.Tuple([MenubarBar, MenubarBar]), Type.Null()], {
356
+ description: 'The shorter window, then the longer one; a single window fills the second. Null without quota.',
357
+ }),
358
+ reset: Type.String({
359
+ description: 'Until the fullest window resets, such as `4d 17h`; empty when nothing is used.',
360
+ }),
361
+ note: Type.String({
362
+ description: 'Text drawn instead of bars, such as `API key`; empty when bars are drawn.',
363
+ }),
364
+ });
318
365
  export const OUTPUT_SCHEMAS = {
319
366
  pin: PinResult,
320
367
  unpin: PinResult,
@@ -352,7 +399,7 @@ export const OUTPUT_SCHEMAS = {
352
399
  message: Type.Optional(Str),
353
400
  restartedPanel: Type.Optional(Type.Boolean()),
354
401
  skillSynced: Type.Optional(Type.Boolean({
355
- description: 'Back on npm, `sideby update --yes` brought the sideby skill to that version (true) or failed (false).',
402
+ description: 'Back on npm, `sideby update --skill --yes` brought the sideby skill to that version (true) or failed (false).',
356
403
  })),
357
404
  }, { title: 'sideby local --json' }),
358
405
  list: Type.Object({
@@ -632,6 +679,21 @@ export const OUTPUT_SCHEMAS = {
632
679
  command: Type.Optional(Type.Array(Str, { description: 'The `open` command sideby ran.' })),
633
680
  notices: Type.Array(Str),
634
681
  }, { title: 'sideby desktop --json' }),
682
+ edit: Type.Object({
683
+ schemaVersion: Version,
684
+ ref: Str,
685
+ family: Str,
686
+ file: Type.String({
687
+ description: 'The settings file as the family names it, such as `settings.json`.',
688
+ }),
689
+ path: Type.String({ description: 'The file inside the account directory.' }),
690
+ target: Type.Optional(Type.String({ description: 'Where the file really is; only when `path` is a link.' })),
691
+ sharedWith: Type.Array(Str, {
692
+ description: 'Other accounts of the family whose settings file is this same file, so a change applies to them too.',
693
+ }),
694
+ opened: Type.Boolean({ description: 'False with --path, which only says where the file is.' }),
695
+ command: Type.Optional(Type.Array(Str, { description: 'The program and arguments that opened the file.' })),
696
+ }, { title: 'sideby edit --json' }),
635
697
  'desktop-remove': Type.Object({
636
698
  schemaVersion: Version,
637
699
  ref: Str,
@@ -741,6 +803,9 @@ export const OUTPUT_SCHEMAS = {
741
803
  code: Type.String({
742
804
  description: '`usage` for a malformed command line (exit 2), a reason such as `no-quota-source` or `alias-invalid`, or `error`.',
743
805
  }),
806
+ reason: Type.Optional(Type.String({
807
+ description: 'Same as `code`, for a refused Task Spec (`sideby ask --spec -`): `spec-invalid`, `spec-too-large`, `bad-cwd`, or `spec-version` (exit 2: update sideby).',
808
+ })),
744
809
  }, { title: 'sideby error --json' }),
745
810
  ask: Type.Object({
746
811
  schemaVersion: Version,
@@ -772,6 +837,32 @@ export const OUTPUT_SCHEMAS = {
772
837
  bytes: Type.Integer({ minimum: 0 }),
773
838
  }), { description: 'Files given with `--attach`, in order; empty without any.' }),
774
839
  }),
840
+ 'ask-print': Type.Object({
841
+ schemaVersion: Version,
842
+ prompt: Type.String({
843
+ description: 'The Task Prompt the Host would get, attachments section included.',
844
+ }),
845
+ removedSecrets: Type.Boolean({ description: 'Whether key-shaped text was taken out of the prompt.' }),
846
+ }, { title: 'sideby ask --spec - --print --json' }),
847
+ 'ask-choices': Type.Object({
848
+ schemaVersion: Version,
849
+ account: Type.Union([Str, Type.Null()], {
850
+ description: 'The Account an AI Task would use now; null when none can be picked (see `reason`).',
851
+ }),
852
+ accounts: Type.Array(Type.Object({
853
+ ref: Str,
854
+ label: Type.String({ description: 'What to show for it, as the Panel does.' }),
855
+ signedIn: Type.Boolean({ description: 'False for a Subscription Account that is signed out.' }),
856
+ }), {
857
+ description: 'Signed-in Subscription Accounts, then API Accounts, then signed-out ones; each by ref.',
858
+ }),
859
+ terminal: Type.String({ description: 'The terminal a task opens: the preferred one, else the guess.' }),
860
+ terminals: Type.Array(Type.Object({ id: Str, label: Str }), {
861
+ description: 'The supported terminals installed here.',
862
+ }),
863
+ reason: Type.Union([Type.String({ enum: ['no-accounts', 'none-signed-in', 'all-full'] }), Type.Null()]),
864
+ detail: Type.Union([Type.String({ description: 'What to do next, for a person.' }), Type.Null()]),
865
+ }, { title: 'sideby ask --choices --json' }),
775
866
  terminal: Type.Object({
776
867
  schemaVersion: Version,
777
868
  preferred: Type.Union([Str, Type.Null()]),
@@ -804,26 +895,74 @@ export const OUTPUT_SCHEMAS = {
804
895
  families: Type.Array(Str),
805
896
  problems: Type.Array(Type.Object({ code: Str, message: Str, fix: Str })),
806
897
  }),
807
- autostart: Type.Object({
898
+ autostart: loginItem('The login item starts this sideby with this Node.'),
899
+ menubar: loginItem('The menu bar item runs this sideby with this Node.'),
900
+ 'menubar-snapshot': Type.Object({
808
901
  schemaVersion: Version,
809
- supported: Type.Boolean({
810
- description: 'False on a system sideby cannot start at login yet; `reason` says so.',
902
+ title: Type.String({
903
+ description: 'The words next to the icon, such as `Codex 62%`, once the tightest tool reaches 60%; empty otherwise.',
811
904
  }),
812
- reason: Type.Optional(Str),
813
- state: Type.Union(['off', 'on', 'stale', 'foreign'].map((k) => Type.Literal(k)), {
814
- description: '`stale`: the Node or sideby it starts no longer exists; `foreign`: a file at that path that sideby did not write.',
905
+ level: Type.Union(['ok', 'warn', 'fail', 'none'].map((k) => Type.Literal(k))),
906
+ tooltip: Str,
907
+ updatedAt: Type.String({ description: 'When this snapshot was made (ISO).' }),
908
+ lang: Type.Union([Type.Literal('en'), Type.Literal('zh')]),
909
+ card: Type.Union([
910
+ Type.Object({
911
+ status: Str,
912
+ detail: Str,
913
+ level: Type.Union(['ok', 'warn', 'fail', 'none'].map((k) => Type.Literal(k))),
914
+ }),
915
+ Type.Null(),
916
+ ], {
917
+ description: 'The card at the top of the menu: a bold status and a line naming the account; null without quota data.',
815
918
  }),
816
- path: Str,
817
- programArguments: Type.Optional(Type.Array(Str)),
818
- current: Type.Boolean({ description: 'The login item starts this sideby with this Node.' }),
819
- missing: Type.Optional(Type.Array(Str)),
820
- action: Type.Optional(Type.Union([Type.Literal('on'), Type.Literal('off')])),
821
- changed: Type.Optional(Type.Boolean()),
822
- applied: Type.Optional(Type.Boolean()),
823
- content: Type.Optional(Type.String({ description: 'The file `on` writes.' })),
824
- commands: Type.Optional(Type.Array(Type.Array(Str))),
825
- loaded: Type.Optional(Type.Boolean({ description: 'launchd took the change now.' })),
826
- note: Type.Optional(Str),
919
+ hotkey: Type.Union([Type.Object({ keyCode: Type.Number(), modifiers: Type.Number(), label: Str }), Type.Null()], {
920
+ description: 'The shortcut that opens the menu (config `menubar.hotkey`): a macOS key code and Carbon modifiers.',
921
+ }),
922
+ headline: Type.String({
923
+ description: 'The grey first line of the menu: which account the title belongs to; empty without quota data.',
924
+ }),
925
+ sections: Type.Array(Type.Object({
926
+ family: Str,
927
+ title: Str,
928
+ logo: Type.Union([
929
+ Type.Object({
930
+ path: Str,
931
+ fillRule: Type.Optional(Type.String({ enum: ['nonzero', 'evenodd'] })),
932
+ color: Type.Optional(Type.String({ description: 'Brand colour; without one the mark follows the text colour.' })),
933
+ }),
934
+ Type.Null(),
935
+ ]),
936
+ columns: Type.Tuple([Type.Union([Str, Type.Null()]), Type.Union([Str, Type.Null()])], {
937
+ description: 'The window names over the two bar columns, such as `5h` and `7d`.',
938
+ }),
939
+ rows: Type.Array(MenubarRow, { description: 'The recommended account first, then Display Order.' }),
940
+ more: Type.Union([Type.Object({ title: Str, rows: Type.Array(MenubarRow) }), Type.Null()], {
941
+ description: 'API key and signed-out accounts behind one submenu; null when there are none.',
942
+ }),
943
+ }), { description: 'One per Family with accounts, in Display Order.' }),
944
+ labels: Type.Record(Str, Str, { description: 'Footer words; `{n}` in `updatedMinutes` is minutes.' }),
945
+ }),
946
+ 'menubar-start': Type.Object({
947
+ schemaVersion: Version,
948
+ task: Str,
949
+ account: Str,
950
+ terminal: Str,
951
+ opened: Type.Boolean(),
952
+ command: Type.String({
953
+ description: 'The command the terminal runs; paste it into a terminal when `opened` is false.',
954
+ }),
955
+ reason: Type.Optional(Type.String({
956
+ enum: [
957
+ 'not-installed',
958
+ 'automation-denied',
959
+ 'npx-cache',
960
+ 'unsafe-path',
961
+ 'failed',
962
+ 'unsupported-platform',
963
+ ],
964
+ })),
965
+ detail: Type.Optional(Type.String({ description: 'What to do next, for a person.' })),
827
966
  }),
828
967
  'config-get': Type.Object({
829
968
  schemaVersion: Version,
@@ -25,6 +25,7 @@ Usage:
25
25
  sideby order --reset restore default order, keeping pins
26
26
  sideby quota check <family> on|off turn quota fetching on or off
27
27
  sideby update --auto on|off set Auto Update without running an update
28
+ sideby update --skill [--yes] update only the installed sideby skill to this version
28
29
  sideby families [family] what each host's accounts share with the main account,
29
30
  where they live and how they sign in
30
31
  sideby alias add <short> <account> [-- args]
@@ -65,6 +66,8 @@ Usage:
65
66
  sideby desktop <account> open the desktop app (Claude Desktop, the Codex app) as this
66
67
  account, next to the others (macOS)
67
68
  sideby desktop grok-bot:<name> open a Grok Bot window, a new one for a new name (macOS)
69
+ sideby edit <account> [--path] open the account's own settings file (settings.json,
70
+ config.toml) in your editor
68
71
  sideby browser [--enable [--yes]] which Chrome browser user signed in to each account's website
69
72
  (read on this computer only; off until you enable it)
70
73
  sideby browser open <account> [--profile <name>]
@@ -80,6 +83,7 @@ Usage:
80
83
  sideby update [--yes] update sideby to the newest version (shows the command first)
81
84
  sideby autostart [on|off] [--yes] start the panel in the background at login (macOS; shows the
82
85
  file first)
86
+ sideby menubar [on|off] [--yes] show quota in the macOS menu bar; click an account to start it
83
87
  sideby config get [<key>] every setting with its value and meaning, or one setting
84
88
  sideby config set <key> <value> [--yes]
85
89
  change any setting (sideby config set panel.theme dark)
@@ -89,10 +93,10 @@ Usage:
89
93
 
90
94
  Options:
91
95
  --json machine-readable output (list, new, next, alias, doctor, quota, tune, model, remote-control, handoff,
92
- families, plugins, app, desktop, browser, update, local, ask, terminal, key, try,
93
- autostart, config)
94
- -h, --help show this help; \`sideby <command> --help\` for new, alias, login, doctor, families, desktop, browser,
95
- autostart, config
96
+ families, plugins, app, desktop, edit, browser, update, local, ask, terminal, key, try,
97
+ autostart, menubar, config)
98
+ -h, --help show this help; \`sideby <command> --help\` for new, alias, login, doctor, families, desktop, edit, browser,
99
+ autostart, menubar, config
96
100
  -v, --version show the version
97
101
 
98
102
  An <account> is <family>:<name> (claude:work) or just <name> when it is unique.
@@ -109,7 +113,7 @@ Updates: once a day sideby asks the npm registry for its newest version and says
109
113
  Turn it off with NO_UPDATE_NOTIFIER=1 or config "update": { "check": false }; "auto": true installs by itself.`;
110
114
  /** `sideby <command> --help` for the commands agents use to set up and repair accounts (spec §3.16). */
111
115
  const COMMAND_HELP = {
112
- ask: 'sideby ask [<text>] [--task free|fix|quota|account|host|plugin|terminal|handoff] [--account <ref>] [--terminal <id>] [--attach <file>]... [--print] [--json]\nsideby ask --run <id> [--state-dir <dir>]\nOpen a task in your terminal. --attach adds an image (PNG, JPEG, GIF, WebP; up to 20 MB) or a video (MP4, MOV, WebM; up to 200 MB), at most 5. --print prints only the prompt. If opening fails, paste the command into a terminal.',
116
+ ask: 'sideby ask [<text>] [--task free|fix|quota|account|host|plugin|terminal|handoff] [--account <ref>] [--terminal <id>] [--attach <file>]... [--print] [--json]\nsideby ask --run <id> [--state-dir <dir>]\nsideby ask --spec - [--print] --json\nsideby ask --choices --json\nOpen a task in your terminal. --spec reads a Task Spec (one JSON object, at most 1 MB) from stdin, as a Portal sends it; --choices lists the accounts and terminals a task can use. --attach adds an image (PNG, JPEG, GIF, WebP; up to 20 MB) or a video (MP4, MOV, WebM; up to 200 MB), at most 5. --print prints only the prompt. If opening fails, paste the command into a terminal.',
113
117
  terminal: "sideby terminal [--set <id>|--custom '<program> … {cwd} … {cmd}'|--unset] [--json]\nList terminals or save your preference; --custom saves and selects your own launch command.",
114
118
  key: 'sideby key <account> [--var <NAME>] [--json]\nEnter an API key without echo. Run in a terminal or use the Panel key box.',
115
119
  try: 'sideby try <account> [--yes] [--json]\nSend a short request through the Host. This spends a few tokens. Exit 10 waits for --yes.',
@@ -198,6 +202,21 @@ Examples:
198
202
  sideby desktop grok-bot:002 --remove --yes
199
203
  Exit: 0 opened, brought to the front or removed; 1 not macOS, no desktop app for that host, API account, app not
200
204
  installed, a bad window name, or the app did not open; 10 --remove without --yes; 2 malformed command line.`,
205
+ edit: `sideby edit <account> [--path] [--json]
206
+
207
+ Open the account's own settings file in your editor: settings.json for claude and pi accounts, config.toml for codex
208
+ and grok accounts. It opens with the system's default program (the default text editor on macOS, the Windows default
209
+ program on WSL, xdg-open on other Linux). --path only prints where the file is.
210
+
211
+ sideby reads nothing of the file and never changes it; your editor does. When the file is a link (accounts that
212
+ share their settings with the main account), it says where the real file is and which accounts the change affects.
213
+ A missing file is not created: the message says how to get one.
214
+
215
+ Examples:
216
+ sideby edit claude:work
217
+ sideby edit cc008 --path
218
+ Exit: 0 opened (or printed with --path); 1 no settings file, the family names none, or it could not be opened; 2
219
+ malformed command line.`,
201
220
  autostart: `sideby autostart [on|off] [--yes] [--json]
202
221
 
203
222
  Start the panel in the background when you log in, so it already shows fresh quota when you open it. It never
@@ -214,6 +233,27 @@ Examples:
214
233
  sideby autostart off --yes
215
234
  Exit: 0 shown, done or nothing to change; 10 a change was shown and waits for --yes; 1 refused (not macOS, sideby
216
235
  in the npx cache or a temporary folder, a file that is not sideby's) or failed; 2 malformed command line.`,
236
+ menubar: `sideby menubar [on|off] [--yes] [--json]
237
+ sideby menubar snapshot [--lang en|zh] [--json]
238
+ sideby menubar start <account> [--json]
239
+
240
+ Show quota in the macOS menu bar: a gauge with one percent, how much the account sideby would pick next has used
241
+ in your tightest tool (orange from 60%, red from 85%). Click it for every account's 5-hour and 7-day quota; click
242
+ an account to start it in your preferred terminal. It runs the system's osascript, starts at login and has no Dock
243
+ icon. macOS only for now (a LaunchAgent, ~/Library/LaunchAgents/dev.sideby.menubar.plist).
244
+
245
+ Without on or off it says whether it is on, off, out of date or blocked by a file that is not sideby's. on and off
246
+ show the file first; --yes does it. snapshot prints what the menu shows (the menu bar item runs it every 2 minutes).
247
+ start opens an account in your preferred terminal, as clicking it does.
248
+
249
+ Examples:
250
+ sideby menubar on --yes
251
+ sideby menubar snapshot --json
252
+ sideby menubar start claude:work
253
+ sideby menubar off --yes
254
+ Exit: 0 shown, done or nothing to change; 10 a change was shown and waits for --yes; 1 refused (not macOS, sideby
255
+ in the npx cache or a temporary folder, a file that is not sideby's), failed, or the terminal did not open; 2
256
+ malformed command line.`,
217
257
  config: `sideby config get [<key>] [--json]
218
258
  sideby config set <key> <value> [--yes] [--json]
219
259
  sideby config unset <key> [--yes] [--json]
@@ -279,11 +319,15 @@ export function nodeTooOld(version = process.versions.node) {
279
319
  return maj < MIN_NODE[0] || (maj === MIN_NODE[0] && min < MIN_NODE[1]);
280
320
  }
281
321
  const COMMANDS = {
282
- ask: { flags: ['json', 'print'], valued: ['task', 'account', 'terminal', 'run', 'state-dir', 'attach'] },
322
+ ask: {
323
+ flags: ['json', 'print', 'choices'],
324
+ valued: ['task', 'account', 'terminal', 'run', 'state-dir', 'attach', 'spec'],
325
+ },
283
326
  terminal: { flags: ['json', 'unset'], valued: ['set', 'custom'] },
284
327
  key: { flags: ['json'], valued: ['var'] },
285
328
  try: { flags: ['json', 'yes'] },
286
329
  autostart: { flags: ['json', 'yes', 'refresh'] },
330
+ menubar: { flags: ['json', 'yes', 'refresh'], valued: ['lang'] },
287
331
  config: { flags: ['json', 'yes'] },
288
332
  list: { flags: ['json'] },
289
333
  pin: { flags: ['json'] },
@@ -307,11 +351,12 @@ const COMMANDS = {
307
351
  ui: { flags: ['no-open', 'background', 'stop', 'serve-detached'], valued: ['port'] },
308
352
  app: { flags: ['json'], valued: ['url'] },
309
353
  desktop: { flags: ['json', 'remove', 'yes'] },
354
+ edit: { flags: ['json', 'path'] },
310
355
  browser: { flags: ['json', 'enable', 'disable', 'yes'], valued: ['profile'] },
311
356
  'shell-init': { flags: ['write'] },
312
357
  plugins: { flags: ['json'] },
313
358
  families: { flags: ['json'] },
314
- update: { flags: ['json', 'yes'], valued: ['auto'] },
359
+ update: { flags: ['json', 'yes', 'skill'], valued: ['auto'] },
315
360
  local: { flags: ['json', 'yes'] },
316
361
  'update-check': { flags: [] },
317
362
  };
@@ -554,6 +599,8 @@ async function dispatch(cmd, parsed, io, cmds) {
554
599
  return await cmds.cmdApp(parsed, io);
555
600
  case 'desktop':
556
601
  return await cmds.cmdDesktop(parsed, io);
602
+ case 'edit':
603
+ return await cmds.cmdEdit(parsed, io);
557
604
  case 'browser':
558
605
  return await cmds.cmdBrowser(parsed, io);
559
606
  case 'shell-init':
@@ -570,6 +617,8 @@ async function dispatch(cmd, parsed, io, cmds) {
570
617
  return await cmds.cmdLocal(parsed, io);
571
618
  case 'autostart':
572
619
  return await cmds.cmdAutostart(parsed, io);
620
+ case 'menubar':
621
+ return await cmds.cmdMenubar(parsed, io);
573
622
  case 'config':
574
623
  return await cmds.cmdConfig(parsed, io);
575
624
  }
@@ -0,0 +1,54 @@
1
+ import type { Env } from '../types.ts';
2
+ import type { SkillUpdatePlan, UpdateDeps } from './update.ts';
3
+ /**
4
+ * The skill step the new code runs by name. `--skill` updates only the installed skill: it never installs the CLI,
5
+ * even when the registry has moved on since the user confirmed.
6
+ */
7
+ export declare const SKILL_SYNC: readonly ['sideby', 'update', '--skill', '--yes'];
8
+ /** Runs the skills tool when the plan says the skill is outdated and sideby may; null when it did nothing. */
9
+ export declare function runSkillUpdate(m: UpdateDeps, plan: SkillUpdatePlan | undefined, env: Env, onOutput?: (text: string) => void): Promise<{
10
+ ok: boolean;
11
+ message: string;
12
+ } | null>;
13
+ export interface AfterInstallOptions {
14
+ home: string;
15
+ /** Frees the install lock. Called once, before anything starts that takes the lock itself. */
16
+ release: () => Promise<void>;
17
+ /** Write an installed desktop app again from the new code (an Update). */
18
+ app?: boolean;
19
+ /**
20
+ * Points an existing login item at the new code; undefined when there is none. Without it, `sideby autostart
21
+ * --refresh` of the new code does that where a login item is installed.
22
+ */
23
+ autostart?: () => Promise<boolean | undefined>;
24
+ /**
25
+ * The installed sideby skill: `plan` when the caller has looked at it (an Update), `by-name` when only the new code
26
+ * can tell (a switch back to npm). Absent: nothing to bring along.
27
+ */
28
+ skill?: {
29
+ plan: SkillUpdatePlan | undefined;
30
+ } | 'by-name';
31
+ /**
32
+ * `background` (the Panel): the new code updates the skill on its own after the answer. Its fetch can take minutes,
33
+ * and a Portal that moves to the new code, or the Panel restarting from it, ends the request it runs in.
34
+ */
35
+ skillSync?: 'wait' | 'background';
36
+ /** The port of the background Panel to start again, or null when none runs. */
37
+ panelPort?: () => Promise<number | null>;
38
+ onOutput?: (text: string) => void;
39
+ }
40
+ export interface AfterInstallResult {
41
+ restartedPanel: boolean;
42
+ refreshedApp: boolean;
43
+ /** Absent when there is no login item. */
44
+ refreshedAutostart?: boolean;
45
+ /** `plan`, waited for: the skill was updated (true) or that failed (false); absent when it was not tried. */
46
+ skillUpdated?: boolean;
47
+ skillMessage?: string;
48
+ /** `by-name`, waited for: `sideby update --skill --yes` of the new code succeeded. */
49
+ skillSynced?: boolean;
50
+ /** `background`: `sideby update --skill --yes` of the new code started on its own. */
51
+ skillSyncStarted?: boolean;
52
+ }
53
+ /** Runs the steps above in their order. Never throws, and a failed step never fails the install before it. */
54
+ export declare function afterInstall(m: UpdateDeps, env: Env, o: AfterInstallOptions): Promise<AfterInstallResult>;
@@ -0,0 +1,78 @@
1
+ import { SKILL_UPDATE } from './skill-check.js';
2
+ /**
3
+ * The skill step the new code runs by name. `--skill` updates only the installed skill: it never installs the CLI,
4
+ * even when the registry has moved on since the user confirmed.
5
+ */
6
+ export const SKILL_SYNC = ['sideby', 'update', '--skill', '--yes'];
7
+ /** Runs the skills tool when the plan says the skill is outdated and sideby may; null when it did nothing. */
8
+ export async function runSkillUpdate(m, plan, env, onOutput) {
9
+ if (!plan?.outdated || !plan.canRun)
10
+ return null;
11
+ const [file, ...args] = SKILL_UPDATE;
12
+ const r = await m
13
+ .exec(file, args, { env, ...(onOutput ? { onOutput } : {}) })
14
+ .catch((e) => ({ code: 1, output: e instanceof Error ? e.message : String(e) }));
15
+ return r.code === 0
16
+ ? { ok: true, message: 'updated the sideby skill' }
17
+ : { ok: false, message: `\`${plan.command}\` failed (exit ${r.code}); run it yourself to see why` };
18
+ }
19
+ async function autostartByName(m, home, env) {
20
+ // Never created here: only a login item `sideby autostart on` wrote is refreshed (ADR-0029).
21
+ const panel = (await m.autostartInstalled(home).catch(() => false))
22
+ ? await m.refreshAutostart(env).catch(() => false)
23
+ : undefined;
24
+ // The menu bar item's login item records the same Node and entry (ADR-0034); not reported, and never created here.
25
+ if (await m.autostartInstalled(home, 'menubar').catch(() => false))
26
+ await m.refreshAutostart(env, 'menubar').catch(() => false);
27
+ return panel;
28
+ }
29
+ /** Runs the steps above in their order. Never throws, and a failed step never fails the install before it. */
30
+ export async function afterInstall(m, env, o) {
31
+ let freed = false;
32
+ const release = async () => {
33
+ if (freed)
34
+ return;
35
+ freed = true;
36
+ await o.release().catch(() => { });
37
+ };
38
+ try {
39
+ // By name, from the new code: the app records its own Node and entry and carries the icon of the version that
40
+ // wrote it. Only where one is installed.
41
+ const refreshedApp = !!o.app &&
42
+ (await m.appInstalled(o.home, env).catch(() => false)) &&
43
+ (await m.refreshApp(env).catch(() => false));
44
+ const refreshedAutostart = await (o.autostart ?? (() => autostartByName(m, o.home, env)))().catch(() => false);
45
+ const background = o.skillSync === 'background';
46
+ const plan = o.skill && o.skill !== 'by-name' ? o.skill.plan : undefined;
47
+ const due = o.skill === 'by-name' || (!!plan?.outdated && plan.canRun);
48
+ let skill = {};
49
+ // In place, under the lock, so a skill update never runs beside another install.
50
+ if (due && !background && plan) {
51
+ const r = await runSkillUpdate(m, plan, env, o.onOutput);
52
+ if (r)
53
+ skill = { skillUpdated: r.ok, skillMessage: r.message };
54
+ }
55
+ await release();
56
+ if (due && background)
57
+ skill = {
58
+ skillSyncStarted: await m.startDetached(SKILL_SYNC[0], SKILL_SYNC.slice(1), env).catch(() => false),
59
+ };
60
+ else if (due && !plan) {
61
+ const u = await m
62
+ .exec(SKILL_SYNC[0], SKILL_SYNC.slice(1), { env, ...(o.onOutput ? { onOutput: o.onOutput } : {}) })
63
+ .catch(() => ({ code: 1, output: '' }));
64
+ skill = { skillSynced: u.code === 0 };
65
+ }
66
+ const port = o.panelPort ? await o.panelPort().catch(() => null) : null;
67
+ const restartedPanel = port !== null && (await m.restartPanel(env, port).catch(() => false));
68
+ return {
69
+ restartedPanel,
70
+ refreshedApp,
71
+ ...(refreshedAutostart === undefined ? {} : { refreshedAutostart }),
72
+ ...skill,
73
+ };
74
+ }
75
+ finally {
76
+ await release();
77
+ }
78
+ }
@@ -2,6 +2,7 @@ import { taskPrompt } from '../panel/page-logic.ts';
2
2
  import type { Runtime } from '../runtime.ts';
3
3
  import type { Account, Env } from '../types.ts';
4
4
  import { type Attachment } from './attachments.ts';
5
+ import { UserError } from './errors.ts';
5
6
  import { type Paths } from './paths.ts';
6
7
  import { type ProbeDeps } from './probe.ts';
7
8
  import { type TerminalId } from './terminal.ts';
@@ -14,7 +15,8 @@ export declare function pickTaskAccount(rt: Runtime, opts?: {
14
15
  reason: 'no-accounts' | 'none-signed-in' | 'all-full';
15
16
  }>;
16
17
  export interface TaskFile {
17
- kind: 'prompt' | 'login';
18
+ /** `run` starts the Host as `sideby run` does, from the Menu Bar Item (spec §3.31). */
19
+ kind: 'prompt' | 'login' | 'run';
18
20
  account: string;
19
21
  prompt?: string;
20
22
  cwd: string;
@@ -27,7 +29,23 @@ export interface TaskFile {
27
29
  path: string;
28
30
  kind: 'image' | 'video';
29
31
  }[];
32
+ /**
33
+ * The folder came from a Task Spec (ADR-0030): `cwd` is its real path, which must still be an existing folder inside
34
+ * `home` when the task is written and again when `ask --run` has changed into it.
35
+ */
36
+ cwdInHome?: true;
30
37
  }
38
+ /**
39
+ * Why `cwd` cannot be the folder of a Portal's task (ADR-0030), or its real path: it must be an absolute path whose
40
+ * real path is an existing directory inside the real `home`. A link, or a link in an ancestor, counts where it points.
41
+ */
42
+ export declare function realCwdInHome(cwd: string, home: string): Promise<{
43
+ real: string;
44
+ } | {
45
+ why: string;
46
+ }>;
47
+ /** A Portal's task folder that stopped being a folder inside the HOME after it was checked. */
48
+ export declare function movedCwdError(why: string): UserError;
31
49
  export declare function taskWorkDir(paths?: Paths): Promise<string>;
32
50
  export declare const newTaskId: () => string;
33
51
  export declare function writeTask(task: TaskFile, paths?: Paths, id?: string): Promise<string>;
@@ -82,14 +100,22 @@ export interface AiTaskInput {
82
100
  /** The user's own files to attach (`sideby ask --attach`). */
83
101
  files?: string[];
84
102
  }
103
+ /**
104
+ * The `context` of an AI Task as a page or a Task Spec sends it (spec §3.28): only the strings and findings a Task
105
+ * Prompt shows; anything else is refused through `fail`, which makes the caller's error (a 400, a Task Spec error).
106
+ */
107
+ export declare function taskContext(c: unknown, fail: (message: string) => Error): AiTaskInput['context'];
85
108
  /** The attachments a prompt shown before the task exists lists: uploads still staged, the user's files in place. */
86
109
  export declare function previewAttachments(rt: Runtime, input: AiTaskInput): Promise<Attachment[]>;
110
+ /** The language of a Task Prompt: the one asked for, else Chinese under a `zh` locale, else English. */
111
+ export declare function taskLang(rt: Runtime, lang?: string): string;
87
112
  export declare function promptForTask(rt: Runtime, input: AiTaskInput, attachments?: readonly Attachment[]): {
88
113
  prompt: string;
89
114
  removedSecrets: boolean;
90
115
  };
91
116
  /** Machine-readable reasons an AI Task did not open; `detail` says what to do. */
92
117
  export type AiTaskReason = 'no-accounts' | 'none-signed-in' | 'all-full' | 'not-installed' | 'automation-denied' | 'npx-cache' | 'unsafe-path' | 'failed' | 'unsupported-platform';
118
+ export declare const PICK_DETAIL: Record<'no-accounts' | 'none-signed-in' | 'all-full', string>;
93
119
  export declare function startAiTask(rt: Runtime, input: AiTaskInput): Promise<{
94
120
  schemaVersion: 1;
95
121
  task: null;
@@ -115,6 +141,41 @@ export declare function startAiTask(rt: Runtime, input: AiTaskInput): Promise<{
115
141
  removedSecrets: boolean;
116
142
  attachments: Attachment[];
117
143
  }>;
144
+ /**
145
+ * Picks the Account and opens the Preferred Terminal for a written Task Prompt, as every AI Task does (spec §3.28):
146
+ * sideby's own, and one a Portal hands over in a Task Spec (ADR-0030), which names its own `cwd`.
147
+ */
148
+ export declare function openPromptTask(rt: Runtime, input: Pick<AiTaskInput, 'account' | 'family' | 'terminal' | 'remember'>, written: {
149
+ taskId: string;
150
+ prompt: string;
151
+ removedSecrets: boolean;
152
+ attachments: Attachment[];
153
+ cwd?: string;
154
+ }): Promise<{
155
+ schemaVersion: 1;
156
+ task: null;
157
+ account: null;
158
+ terminal: null;
159
+ opened: boolean;
160
+ command: null;
161
+ prompt: string;
162
+ reason: AiTaskReason;
163
+ detail: string;
164
+ removedSecrets: boolean;
165
+ attachments: Attachment[];
166
+ } | {
167
+ schemaVersion: 1;
168
+ task: string;
169
+ account: string;
170
+ terminal: string;
171
+ opened: boolean;
172
+ command: string;
173
+ reason?: AiTaskReason | undefined;
174
+ detail?: string | undefined;
175
+ prompt?: undefined;
176
+ removedSecrets: boolean;
177
+ attachments: Attachment[];
178
+ }>;
118
179
  export declare function openLoginInTerminal(rt: Runtime, ref: string): Promise<{
119
180
  schemaVersion: 1;
120
181
  task: string;
@@ -125,6 +186,17 @@ export declare function openLoginInTerminal(rt: Runtime, ref: string): Promise<{
125
186
  reason?: AiTaskReason | undefined;
126
187
  detail?: string | undefined;
127
188
  }>;
189
+ /** Starts an Account in the Preferred Terminal as `sideby run` would, in the HOME folder (spec §3.31). */
190
+ export declare function openRunInTerminal(rt: Runtime, ref: string): Promise<{
191
+ schemaVersion: 1;
192
+ task: string;
193
+ account: string;
194
+ terminal: string;
195
+ opened: boolean;
196
+ command: string;
197
+ reason?: AiTaskReason | undefined;
198
+ detail?: string | undefined;
199
+ }>;
128
200
  /**
129
201
  * What `try` will run for an Account, computed as `sideby run` would (Family defaults, config arguments) but without
130
202
  * reading its Secret File or running `launch.before` hooks: nothing runs before the user agrees.