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.
- package/README.md +11 -1
- package/ai-tasks.json +90 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +9 -1
- package/dist/src/cli/commands.js +507 -26
- package/dist/src/cli/json-schemas.js +196 -19
- package/dist/src/cli/main.js +79 -13
- package/dist/src/core/after-install.d.ts +54 -0
- package/dist/src/core/after-install.js +78 -0
- package/dist/src/core/ask.d.ts +87 -1
- package/dist/src/core/ask.js +122 -7
- package/dist/src/core/autostart.d.ts +38 -8
- package/dist/src/core/autostart.js +85 -39
- package/dist/src/core/brand-mark.d.ts +49 -11
- package/dist/src/core/brand-mark.js +116 -38
- package/dist/src/core/browser-profiles.js +7 -32
- package/dist/src/core/config.d.ts +19 -0
- package/dist/src/core/config.js +75 -2
- package/dist/src/core/desktop-app.d.ts +1 -1
- package/dist/src/core/desktop-app.js +2 -2
- package/dist/src/core/edit-settings.d.ts +24 -0
- package/dist/src/core/edit-settings.js +97 -0
- package/dist/src/core/handoff-brief.d.ts +4 -2
- package/dist/src/core/handoff-brief.js +6 -1
- package/dist/src/core/handoff-chain.d.ts +24 -0
- package/dist/src/core/handoff-chain.js +2 -0
- package/dist/src/core/handoff-run.d.ts +4 -3
- package/dist/src/core/handoff-run.js +14 -9
- package/dist/src/core/launch.d.ts +2 -0
- package/dist/src/core/launch.js +14 -10
- package/dist/src/core/local-build.d.ts +12 -5
- package/dist/src/core/local-build.js +49 -31
- package/dist/src/core/lock.d.ts +30 -0
- package/dist/src/core/lock.js +143 -0
- package/dist/src/core/pick-commands.d.ts +42 -0
- package/dist/src/core/pick-commands.js +44 -0
- package/dist/src/core/quota-levels.d.ts +6 -1
- package/dist/src/core/quota-levels.js +16 -5
- package/dist/src/core/shell-init.js +3 -1
- package/dist/src/core/shell-setup.d.ts +40 -0
- package/dist/src/core/shell-setup.js +54 -0
- package/dist/src/core/skill-check.d.ts +2 -0
- package/dist/src/core/skill-check.js +2 -0
- package/dist/src/core/task-spec.d.ts +95 -0
- package/dist/src/core/task-spec.js +209 -0
- package/dist/src/core/terminal.d.ts +21 -4
- package/dist/src/core/terminal.js +155 -10
- package/dist/src/core/update.d.ts +27 -16
- package/dist/src/core/update.js +69 -95
- package/dist/src/core/windows-dirs.d.ts +19 -0
- package/dist/src/core/windows-dirs.js +39 -0
- package/dist/src/desktop/icon.js +12 -15
- package/dist/src/families/claude/ai-task.d.ts +8 -0
- package/dist/src/families/claude/ai-task.js +38 -0
- package/dist/src/families/claude/handoff-hook.js +4 -4
- package/dist/src/families/claude/index.js +3 -0
- package/dist/src/families/codex/handoff-hook.js +4 -4
- package/dist/src/families/codex/index.js +9 -0
- package/dist/src/families/grok/handoff-hook.js +4 -4
- package/dist/src/families/grok/index.js +1 -0
- package/dist/src/families/pi/index.js +1 -0
- package/dist/src/handoff/hook.js +51 -30
- package/dist/src/handoff/levels.d.ts +24 -0
- package/dist/src/handoff/levels.js +70 -0
- package/dist/src/handoff/messages.d.ts +6 -3
- package/dist/src/handoff/messages.js +20 -7
- package/dist/src/handoff/reader.d.ts +6 -3
- package/dist/src/menubar/agent.d.ts +3 -0
- package/dist/src/menubar/agent.js +21 -0
- package/dist/src/menubar/script.d.ts +8 -0
- package/dist/src/menubar/script.js +457 -0
- package/dist/src/menubar/snapshot.d.ts +115 -0
- package/dist/src/menubar/snapshot.js +255 -0
- package/dist/src/menubar/strings.d.ts +87 -0
- package/dist/src/menubar/strings.js +88 -0
- package/dist/src/panel/background.js +12 -19
- package/dist/src/panel/handler.d.ts +30 -0
- package/dist/src/panel/handler.js +148 -80
- package/dist/src/panel/i18n.d.ts +72 -0
- package/dist/src/panel/i18n.js +144 -0
- package/dist/src/panel/page-logic.d.ts +105 -0
- package/dist/src/panel/page-logic.js +170 -15
- package/dist/src/panel/page-script.js +419 -111
- package/dist/src/panel/page-styles.js +45 -13
- package/dist/src/panel/page.d.ts +7 -0
- package/dist/src/panel/page.js +11 -1
- package/dist/src/runtime.d.ts +44 -2
- package/dist/src/runtime.js +107 -6
- package/dist/src/types.d.ts +14 -0
- package/package.json +4 -3
- package/schemas/alias-list.json +119 -0
- package/schemas/alias.json +27 -1
- package/schemas/ask-choices.json +168 -0
- package/schemas/ask-print.json +87 -0
- package/schemas/config.json +28 -1
- package/schemas/edit.json +119 -0
- package/schemas/error.json +4 -0
- package/schemas/families.json +4 -0
- package/schemas/list.json +4 -0
- package/schemas/local.json +1 -1
- package/schemas/menubar-snapshot.json +646 -0
- package/schemas/menubar-start.json +112 -0
- package/schemas/menubar.json +165 -0
- package/schemas/new.json +19 -0
- package/schemas/shell-init-setup.json +124 -0
- package/skills/sideby/SKILL.md +11 -4
- package/skills/sideby/references/accounts.md +10 -0
- package/skills/sideby/references/ai-tasks.md +10 -0
- package/skills/sideby/references/handoff.md +3 -1
- package/skills/sideby/references/panel.md +6 -0
- package/skills/sideby/references/setup.md +1 -1
- 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({
|
|
@@ -567,6 +614,9 @@ export const OUTPUT_SCHEMAS = {
|
|
|
567
614
|
suggestion: Type.Optional(Type.Object({ name: Str, alias: Type.Optional(Str), aliasProblem: Type.Optional(Str) }, {
|
|
568
615
|
description: 'Only with `--next`: the picked name, the short command that follows the existing pattern, or why that short command was left out.',
|
|
569
616
|
})),
|
|
617
|
+
pickCommandOffer: Type.Optional(Type.Object({ name: Str, command: Str, shadows: Type.Optional(Str) }, {
|
|
618
|
+
description: 'Set once, when this is the Family’s second subscription account and it has no pick command: the command that adds one.',
|
|
619
|
+
})),
|
|
570
620
|
}, { title: 'sideby new --json' }),
|
|
571
621
|
alias: Type.Object({
|
|
572
622
|
schemaVersion: Version,
|
|
@@ -577,11 +627,46 @@ export const OUTPUT_SCHEMAS = {
|
|
|
577
627
|
Type.Literal('exists'),
|
|
578
628
|
Type.Literal('removed'),
|
|
579
629
|
Type.Literal('absent'),
|
|
580
|
-
|
|
630
|
+
Type.Literal('confirm'),
|
|
631
|
+
], {
|
|
632
|
+
description: '`confirm` (exit 10): the pick command would hide a command on PATH, so nothing was written; run again with `--yes`.',
|
|
633
|
+
}),
|
|
634
|
+
kind: Type.Optional(Type.Union([Type.Literal('account'), Type.Literal('pick')], {
|
|
635
|
+
description: '`pick` for a Pick Command (`--pick`), `account` for a short command of one Account.',
|
|
636
|
+
})),
|
|
581
637
|
account: Type.Optional(Str),
|
|
582
638
|
args: Type.Optional(Type.Array(Str, { description: 'Host arguments `sideby run <alias>` adds.' })),
|
|
639
|
+
family: Type.Optional(Type.String({ description: 'The Family a Pick Command picks in.' })),
|
|
640
|
+
shadows: Type.Optional(Type.String({
|
|
641
|
+
description: 'The command on PATH this Pick Command hides in the shell, such as /usr/bin/cc.',
|
|
642
|
+
})),
|
|
583
643
|
shellInitFiles: Type.Optional(ShellInitFiles),
|
|
584
644
|
}, { title: 'sideby alias add|rm --json' }),
|
|
645
|
+
'shell-init-setup': Type.Object({
|
|
646
|
+
schemaVersion: Version,
|
|
647
|
+
shell: Type.Union([Type.Literal('zsh'), Type.Literal('bash')]),
|
|
648
|
+
rc: Type.String({ description: 'The rc file, with ~ for the home folder.' }),
|
|
649
|
+
status: Type.Union([
|
|
650
|
+
Type.Literal('loaded'),
|
|
651
|
+
Type.Literal('confirm'),
|
|
652
|
+
Type.Literal('added'),
|
|
653
|
+
Type.Literal('removed'),
|
|
654
|
+
Type.Literal('not-added'),
|
|
655
|
+
], {
|
|
656
|
+
description: '`loaded`: new terminals already load the short commands. `confirm` (exit 10): nothing written; `block` is what --yes appends. `not-added`: --undo found no line sideby added.',
|
|
657
|
+
}),
|
|
658
|
+
block: Type.Optional(Type.String()),
|
|
659
|
+
}, { title: 'sideby shell-init setup --json' }),
|
|
660
|
+
'alias-list': Type.Object({
|
|
661
|
+
schemaVersion: Version,
|
|
662
|
+
shortCommands: Type.Array(Type.Object({
|
|
663
|
+
name: Str,
|
|
664
|
+
kind: Type.Union([Type.Literal('account'), Type.Literal('pick')]),
|
|
665
|
+
account: Type.Optional(Type.String({ description: 'The Account a short command of kind `account` starts.' })),
|
|
666
|
+
args: Type.Optional(Type.Array(Str)),
|
|
667
|
+
family: Type.Optional(Type.String({ description: 'The Family a Pick Command picks in.' })),
|
|
668
|
+
})),
|
|
669
|
+
}, { title: 'sideby alias list --json' }),
|
|
585
670
|
plugins: Type.Object({
|
|
586
671
|
schemaVersion: Version,
|
|
587
672
|
plugins: Type.Array(Type.Object({
|
|
@@ -632,6 +717,21 @@ export const OUTPUT_SCHEMAS = {
|
|
|
632
717
|
command: Type.Optional(Type.Array(Str, { description: 'The `open` command sideby ran.' })),
|
|
633
718
|
notices: Type.Array(Str),
|
|
634
719
|
}, { title: 'sideby desktop --json' }),
|
|
720
|
+
edit: Type.Object({
|
|
721
|
+
schemaVersion: Version,
|
|
722
|
+
ref: Str,
|
|
723
|
+
family: Str,
|
|
724
|
+
file: Type.String({
|
|
725
|
+
description: 'The settings file as the family names it, such as `settings.json`.',
|
|
726
|
+
}),
|
|
727
|
+
path: Type.String({ description: 'The file inside the account directory.' }),
|
|
728
|
+
target: Type.Optional(Type.String({ description: 'Where the file really is; only when `path` is a link.' })),
|
|
729
|
+
sharedWith: Type.Array(Str, {
|
|
730
|
+
description: 'Other accounts of the family whose settings file is this same file, so a change applies to them too.',
|
|
731
|
+
}),
|
|
732
|
+
opened: Type.Boolean({ description: 'False with --path, which only says where the file is.' }),
|
|
733
|
+
command: Type.Optional(Type.Array(Str, { description: 'The program and arguments that opened the file.' })),
|
|
734
|
+
}, { title: 'sideby edit --json' }),
|
|
635
735
|
'desktop-remove': Type.Object({
|
|
636
736
|
schemaVersion: Version,
|
|
637
737
|
ref: Str,
|
|
@@ -741,6 +841,9 @@ export const OUTPUT_SCHEMAS = {
|
|
|
741
841
|
code: Type.String({
|
|
742
842
|
description: '`usage` for a malformed command line (exit 2), a reason such as `no-quota-source` or `alias-invalid`, or `error`.',
|
|
743
843
|
}),
|
|
844
|
+
reason: Type.Optional(Type.String({
|
|
845
|
+
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).',
|
|
846
|
+
})),
|
|
744
847
|
}, { title: 'sideby error --json' }),
|
|
745
848
|
ask: Type.Object({
|
|
746
849
|
schemaVersion: Version,
|
|
@@ -772,6 +875,32 @@ export const OUTPUT_SCHEMAS = {
|
|
|
772
875
|
bytes: Type.Integer({ minimum: 0 }),
|
|
773
876
|
}), { description: 'Files given with `--attach`, in order; empty without any.' }),
|
|
774
877
|
}),
|
|
878
|
+
'ask-print': Type.Object({
|
|
879
|
+
schemaVersion: Version,
|
|
880
|
+
prompt: Type.String({
|
|
881
|
+
description: 'The Task Prompt the Host would get, attachments section included.',
|
|
882
|
+
}),
|
|
883
|
+
removedSecrets: Type.Boolean({ description: 'Whether key-shaped text was taken out of the prompt.' }),
|
|
884
|
+
}, { title: 'sideby ask --spec - --print --json' }),
|
|
885
|
+
'ask-choices': Type.Object({
|
|
886
|
+
schemaVersion: Version,
|
|
887
|
+
account: Type.Union([Str, Type.Null()], {
|
|
888
|
+
description: 'The Account an AI Task would use now; null when none can be picked (see `reason`).',
|
|
889
|
+
}),
|
|
890
|
+
accounts: Type.Array(Type.Object({
|
|
891
|
+
ref: Str,
|
|
892
|
+
label: Type.String({ description: 'What to show for it, as the Panel does.' }),
|
|
893
|
+
signedIn: Type.Boolean({ description: 'False for a Subscription Account that is signed out.' }),
|
|
894
|
+
}), {
|
|
895
|
+
description: 'Signed-in Subscription Accounts, then API Accounts, then signed-out ones; each by ref.',
|
|
896
|
+
}),
|
|
897
|
+
terminal: Type.String({ description: 'The terminal a task opens: the preferred one, else the guess.' }),
|
|
898
|
+
terminals: Type.Array(Type.Object({ id: Str, label: Str }), {
|
|
899
|
+
description: 'The supported terminals installed here.',
|
|
900
|
+
}),
|
|
901
|
+
reason: Type.Union([Type.String({ enum: ['no-accounts', 'none-signed-in', 'all-full'] }), Type.Null()]),
|
|
902
|
+
detail: Type.Union([Type.String({ description: 'What to do next, for a person.' }), Type.Null()]),
|
|
903
|
+
}, { title: 'sideby ask --choices --json' }),
|
|
775
904
|
terminal: Type.Object({
|
|
776
905
|
schemaVersion: Version,
|
|
777
906
|
preferred: Type.Union([Str, Type.Null()]),
|
|
@@ -804,26 +933,74 @@ export const OUTPUT_SCHEMAS = {
|
|
|
804
933
|
families: Type.Array(Str),
|
|
805
934
|
problems: Type.Array(Type.Object({ code: Str, message: Str, fix: Str })),
|
|
806
935
|
}),
|
|
807
|
-
autostart:
|
|
936
|
+
autostart: loginItem('The login item starts this sideby with this Node.'),
|
|
937
|
+
menubar: loginItem('The menu bar item runs this sideby with this Node.'),
|
|
938
|
+
'menubar-snapshot': Type.Object({
|
|
808
939
|
schemaVersion: Version,
|
|
809
|
-
|
|
810
|
-
description: '
|
|
940
|
+
title: Type.String({
|
|
941
|
+
description: 'The words next to the icon, such as `Codex 62%`, once the tightest tool reaches 60%; empty otherwise.',
|
|
811
942
|
}),
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
943
|
+
level: Type.Union(['ok', 'warn', 'fail', 'none'].map((k) => Type.Literal(k))),
|
|
944
|
+
tooltip: Str,
|
|
945
|
+
updatedAt: Type.String({ description: 'When this snapshot was made (ISO).' }),
|
|
946
|
+
lang: Type.Union([Type.Literal('en'), Type.Literal('zh')]),
|
|
947
|
+
card: Type.Union([
|
|
948
|
+
Type.Object({
|
|
949
|
+
status: Str,
|
|
950
|
+
detail: Str,
|
|
951
|
+
level: Type.Union(['ok', 'warn', 'fail', 'none'].map((k) => Type.Literal(k))),
|
|
952
|
+
}),
|
|
953
|
+
Type.Null(),
|
|
954
|
+
], {
|
|
955
|
+
description: 'The card at the top of the menu: a bold status and a line naming the account; null without quota data.',
|
|
815
956
|
}),
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
957
|
+
hotkey: Type.Union([Type.Object({ keyCode: Type.Number(), modifiers: Type.Number(), label: Str }), Type.Null()], {
|
|
958
|
+
description: 'The shortcut that opens the menu (config `menubar.hotkey`): a macOS key code and Carbon modifiers.',
|
|
959
|
+
}),
|
|
960
|
+
headline: Type.String({
|
|
961
|
+
description: 'The grey first line of the menu: which account the title belongs to; empty without quota data.',
|
|
962
|
+
}),
|
|
963
|
+
sections: Type.Array(Type.Object({
|
|
964
|
+
family: Str,
|
|
965
|
+
title: Str,
|
|
966
|
+
logo: Type.Union([
|
|
967
|
+
Type.Object({
|
|
968
|
+
path: Str,
|
|
969
|
+
fillRule: Type.Optional(Type.String({ enum: ['nonzero', 'evenodd'] })),
|
|
970
|
+
color: Type.Optional(Type.String({ description: 'Brand colour; without one the mark follows the text colour.' })),
|
|
971
|
+
}),
|
|
972
|
+
Type.Null(),
|
|
973
|
+
]),
|
|
974
|
+
columns: Type.Tuple([Type.Union([Str, Type.Null()]), Type.Union([Str, Type.Null()])], {
|
|
975
|
+
description: 'The window names over the two bar columns, such as `5h` and `7d`.',
|
|
976
|
+
}),
|
|
977
|
+
rows: Type.Array(MenubarRow, { description: 'The recommended account first, then Display Order.' }),
|
|
978
|
+
more: Type.Union([Type.Object({ title: Str, rows: Type.Array(MenubarRow) }), Type.Null()], {
|
|
979
|
+
description: 'API key and signed-out accounts behind one submenu; null when there are none.',
|
|
980
|
+
}),
|
|
981
|
+
}), { description: 'One per Family with accounts, in Display Order.' }),
|
|
982
|
+
labels: Type.Record(Str, Str, { description: 'Footer words; `{n}` in `updatedMinutes` is minutes.' }),
|
|
983
|
+
}),
|
|
984
|
+
'menubar-start': Type.Object({
|
|
985
|
+
schemaVersion: Version,
|
|
986
|
+
task: Str,
|
|
987
|
+
account: Str,
|
|
988
|
+
terminal: Str,
|
|
989
|
+
opened: Type.Boolean(),
|
|
990
|
+
command: Type.String({
|
|
991
|
+
description: 'The command the terminal runs; paste it into a terminal when `opened` is false.',
|
|
992
|
+
}),
|
|
993
|
+
reason: Type.Optional(Type.String({
|
|
994
|
+
enum: [
|
|
995
|
+
'not-installed',
|
|
996
|
+
'automation-denied',
|
|
997
|
+
'npx-cache',
|
|
998
|
+
'unsafe-path',
|
|
999
|
+
'failed',
|
|
1000
|
+
'unsupported-platform',
|
|
1001
|
+
],
|
|
1002
|
+
})),
|
|
1003
|
+
detail: Type.Optional(Type.String({ description: 'What to do next, for a person.' })),
|
|
827
1004
|
}),
|
|
828
1005
|
'config-get': Type.Object({
|
|
829
1006
|
schemaVersion: Version,
|
package/dist/src/cli/main.js
CHANGED
|
@@ -25,12 +25,17 @@ 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]
|
|
31
32
|
add a short command, optionally with host arguments
|
|
32
33
|
(sideby alias add pi-kimi pi:main -- --model kimi-coding/k3)
|
|
34
|
+
sideby alias add <short> --pick <family> [--yes]
|
|
35
|
+
add a pick command: each run starts the account with the
|
|
36
|
+
most quota left (sideby alias add cc --pick claude)
|
|
33
37
|
sideby alias rm <short> remove a short command
|
|
38
|
+
sideby alias list list short commands and pick commands
|
|
34
39
|
sideby login <account> sign in to an account
|
|
35
40
|
sideby resume <family> [-- args] run the host; a session resumed by id (claude --resume <id>,
|
|
36
41
|
codex resume <id>) starts in the account that holds it
|
|
@@ -65,6 +70,8 @@ Usage:
|
|
|
65
70
|
sideby desktop <account> open the desktop app (Claude Desktop, the Codex app) as this
|
|
66
71
|
account, next to the others (macOS)
|
|
67
72
|
sideby desktop grok-bot:<name> open a Grok Bot window, a new one for a new name (macOS)
|
|
73
|
+
sideby edit <account> [--path] open the account's own settings file (settings.json,
|
|
74
|
+
config.toml) in your editor
|
|
68
75
|
sideby browser [--enable [--yes]] which Chrome browser user signed in to each account's website
|
|
69
76
|
(read on this computer only; off until you enable it)
|
|
70
77
|
sideby browser open <account> [--profile <name>]
|
|
@@ -74,12 +81,16 @@ Usage:
|
|
|
74
81
|
sideby shell-init zsh|bash print shell functions, e.g. eval "$(sideby shell-init zsh)"
|
|
75
82
|
sideby shell-init [zsh|bash] --write
|
|
76
83
|
rewrite the config's shellInitFile with them
|
|
84
|
+
sideby shell-init setup [zsh|bash] [--yes|--undo]
|
|
85
|
+
make new terminals load your short commands: adds one line to
|
|
86
|
+
~/.zshrc (or ~/.bashrc), shown first; --undo takes it out
|
|
77
87
|
sideby plugins list loaded plugins and load errors
|
|
78
88
|
sideby plugins new <id> create a local Family Plugin skeleton
|
|
79
89
|
sideby plugins check <id|path> check a plugin and show fixes
|
|
80
90
|
sideby update [--yes] update sideby to the newest version (shows the command first)
|
|
81
91
|
sideby autostart [on|off] [--yes] start the panel in the background at login (macOS; shows the
|
|
82
92
|
file first)
|
|
93
|
+
sideby menubar [on|off] [--yes] show quota in the macOS menu bar; click an account to start it
|
|
83
94
|
sideby config get [<key>] every setting with its value and meaning, or one setting
|
|
84
95
|
sideby config set <key> <value> [--yes]
|
|
85
96
|
change any setting (sideby config set panel.theme dark)
|
|
@@ -89,10 +100,10 @@ Usage:
|
|
|
89
100
|
|
|
90
101
|
Options:
|
|
91
102
|
--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
|
|
103
|
+
families, plugins, app, desktop, edit, browser, update, local, ask, terminal, key, try,
|
|
104
|
+
autostart, menubar, config)
|
|
105
|
+
-h, --help show this help; \`sideby <command> --help\` for new, alias, login, doctor, families, desktop, edit, browser,
|
|
106
|
+
autostart, menubar, config
|
|
96
107
|
-v, --version show the version
|
|
97
108
|
|
|
98
109
|
An <account> is <family>:<name> (claude:work) or just <name> when it is unique.
|
|
@@ -109,7 +120,7 @@ Updates: once a day sideby asks the npm registry for its newest version and says
|
|
|
109
120
|
Turn it off with NO_UPDATE_NOTIFIER=1 or config "update": { "check": false }; "auto": true installs by itself.`;
|
|
110
121
|
/** `sideby <command> --help` for the commands agents use to set up and repair accounts (spec §3.16). */
|
|
111
122
|
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.',
|
|
123
|
+
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
124
|
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
125
|
key: 'sideby key <account> [--var <NAME>] [--json]\nEnter an API key without echo. Run in a terminal or use the Panel key box.',
|
|
115
126
|
try: 'sideby try <account> [--yes] [--json]\nSend a short request through the Host. This spends a few tokens. Exit 10 waits for --yes.',
|
|
@@ -134,20 +145,28 @@ Writes: the account directory; the config \`aliases\` and every \`shellInitFile\
|
|
|
134
145
|
Next: the user signs in with \`sideby login <account>\` (subscription) or fills in proxy.env (API).
|
|
135
146
|
Exit: 0 done; 1 invalid name or alias, directory exists, or partly failed; 2 malformed command line.`,
|
|
136
147
|
alias: `sideby alias add <short> <account> [-- host args] [--json]
|
|
148
|
+
sideby alias add <short> --pick <family> [--yes] [--json]
|
|
137
149
|
sideby alias rm <short> [--json]
|
|
150
|
+
sideby alias list [--json]
|
|
138
151
|
|
|
139
152
|
A short command starts one account: \`sideby run <short>\`, or just \`<short>\` once your shell loads
|
|
140
153
|
\`sideby shell-init\`. Host arguments after -- are added only when it starts through the short command; it is
|
|
141
154
|
the same account (same sign-in, same sessions), so do not create an account per model.
|
|
142
155
|
|
|
156
|
+
A pick command (--pick) starts, each time, the account of that family with the most quota left, the one
|
|
157
|
+
\`sideby next\` would pick; when no account has quota data yet it starts the main account. It prints which
|
|
158
|
+
account it started. A name that hides a command on PATH (cc is the C compiler on macOS) needs --yes.
|
|
159
|
+
|
|
143
160
|
Examples:
|
|
144
161
|
sideby alias add cc008 claude:008
|
|
145
162
|
sideby alias add pi-kimi pi:main -- --model kimi-coding/k3
|
|
163
|
+
sideby alias add cc --pick claude # says first if cc hides a command (exit 10)
|
|
146
164
|
sideby alias rm cc008
|
|
147
165
|
|
|
148
|
-
Writes: the config \`aliases\` and every \`shellInitFile\`. New shell functions work in a
|
|
149
|
-
eval "$(sideby shell-init zsh)" (put that line in ~/.zshrc once).
|
|
150
|
-
Exit: 0 done (also when it already exists or is absent); 1 invalid, reserved or taken; 2 malformed
|
|
166
|
+
Writes: the config \`aliases\` or \`pickCommands\` and every \`shellInitFile\`. New shell functions work in a
|
|
167
|
+
new shell, or after eval "$(sideby shell-init zsh)" (put that line in ~/.zshrc once).
|
|
168
|
+
Exit: 0 done (also when it already exists or is absent); 1 invalid, reserved or taken; 2 malformed;
|
|
169
|
+
10 a pick command would hide a command on PATH, run again with --yes.`,
|
|
151
170
|
login: `sideby login <account>
|
|
152
171
|
|
|
153
172
|
Run the host's own sign-in for one account: claude auth login, codex login, grok login. For pi it starts pi;
|
|
@@ -198,6 +217,21 @@ Examples:
|
|
|
198
217
|
sideby desktop grok-bot:002 --remove --yes
|
|
199
218
|
Exit: 0 opened, brought to the front or removed; 1 not macOS, no desktop app for that host, API account, app not
|
|
200
219
|
installed, a bad window name, or the app did not open; 10 --remove without --yes; 2 malformed command line.`,
|
|
220
|
+
edit: `sideby edit <account> [--path] [--json]
|
|
221
|
+
|
|
222
|
+
Open the account's own settings file in your editor: settings.json for claude and pi accounts, config.toml for codex
|
|
223
|
+
and grok accounts. It opens with the system's default program (the default text editor on macOS, the Windows default
|
|
224
|
+
program on WSL, xdg-open on other Linux). --path only prints where the file is.
|
|
225
|
+
|
|
226
|
+
sideby reads nothing of the file and never changes it; your editor does. When the file is a link (accounts that
|
|
227
|
+
share their settings with the main account), it says where the real file is and which accounts the change affects.
|
|
228
|
+
A missing file is not created: the message says how to get one.
|
|
229
|
+
|
|
230
|
+
Examples:
|
|
231
|
+
sideby edit claude:work
|
|
232
|
+
sideby edit cc008 --path
|
|
233
|
+
Exit: 0 opened (or printed with --path); 1 no settings file, the family names none, or it could not be opened; 2
|
|
234
|
+
malformed command line.`,
|
|
201
235
|
autostart: `sideby autostart [on|off] [--yes] [--json]
|
|
202
236
|
|
|
203
237
|
Start the panel in the background when you log in, so it already shows fresh quota when you open it. It never
|
|
@@ -214,6 +248,27 @@ Examples:
|
|
|
214
248
|
sideby autostart off --yes
|
|
215
249
|
Exit: 0 shown, done or nothing to change; 10 a change was shown and waits for --yes; 1 refused (not macOS, sideby
|
|
216
250
|
in the npx cache or a temporary folder, a file that is not sideby's) or failed; 2 malformed command line.`,
|
|
251
|
+
menubar: `sideby menubar [on|off] [--yes] [--json]
|
|
252
|
+
sideby menubar snapshot [--lang en|zh] [--json]
|
|
253
|
+
sideby menubar start <account> [--json]
|
|
254
|
+
|
|
255
|
+
Show quota in the macOS menu bar: a gauge with one percent, how much the account sideby would pick next has used
|
|
256
|
+
in your tightest tool (orange from 60%, red from 85%). Click it for every account's 5-hour and 7-day quota; click
|
|
257
|
+
an account to start it in your preferred terminal. It runs the system's osascript, starts at login and has no Dock
|
|
258
|
+
icon. macOS only for now (a LaunchAgent, ~/Library/LaunchAgents/dev.sideby.menubar.plist).
|
|
259
|
+
|
|
260
|
+
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
|
|
261
|
+
show the file first; --yes does it. snapshot prints what the menu shows (the menu bar item runs it every 2 minutes).
|
|
262
|
+
start opens an account in your preferred terminal, as clicking it does.
|
|
263
|
+
|
|
264
|
+
Examples:
|
|
265
|
+
sideby menubar on --yes
|
|
266
|
+
sideby menubar snapshot --json
|
|
267
|
+
sideby menubar start claude:work
|
|
268
|
+
sideby menubar off --yes
|
|
269
|
+
Exit: 0 shown, done or nothing to change; 10 a change was shown and waits for --yes; 1 refused (not macOS, sideby
|
|
270
|
+
in the npx cache or a temporary folder, a file that is not sideby's), failed, or the terminal did not open; 2
|
|
271
|
+
malformed command line.`,
|
|
217
272
|
config: `sideby config get [<key>] [--json]
|
|
218
273
|
sideby config set <key> <value> [--yes] [--json]
|
|
219
274
|
sideby config unset <key> [--yes] [--json]
|
|
@@ -279,11 +334,15 @@ export function nodeTooOld(version = process.versions.node) {
|
|
|
279
334
|
return maj < MIN_NODE[0] || (maj === MIN_NODE[0] && min < MIN_NODE[1]);
|
|
280
335
|
}
|
|
281
336
|
const COMMANDS = {
|
|
282
|
-
ask: {
|
|
337
|
+
ask: {
|
|
338
|
+
flags: ['json', 'print', 'choices'],
|
|
339
|
+
valued: ['task', 'account', 'terminal', 'run', 'state-dir', 'attach', 'spec'],
|
|
340
|
+
},
|
|
283
341
|
terminal: { flags: ['json', 'unset'], valued: ['set', 'custom'] },
|
|
284
342
|
key: { flags: ['json'], valued: ['var'] },
|
|
285
343
|
try: { flags: ['json', 'yes'] },
|
|
286
344
|
autostart: { flags: ['json', 'yes', 'refresh'] },
|
|
345
|
+
menubar: { flags: ['json', 'yes', 'refresh'], valued: ['lang'] },
|
|
287
346
|
config: { flags: ['json', 'yes'] },
|
|
288
347
|
list: { flags: ['json'] },
|
|
289
348
|
pin: { flags: ['json'] },
|
|
@@ -294,7 +353,7 @@ const COMMANDS = {
|
|
|
294
353
|
login: { flags: [] },
|
|
295
354
|
next: { flags: ['dry-run', 'include-api', 'json'] },
|
|
296
355
|
new: { flags: ['api', 'json', 'next'], valued: ['alias'] },
|
|
297
|
-
alias: { flags: ['json'] },
|
|
356
|
+
alias: { flags: ['json', 'yes'], valued: ['pick'] },
|
|
298
357
|
doctor: { flags: ['fix', 'force', 'json'] },
|
|
299
358
|
quota: { flags: ['json', 'yes', 'refresh'] },
|
|
300
359
|
tune: { flags: ['json', 'yes'] },
|
|
@@ -307,11 +366,12 @@ const COMMANDS = {
|
|
|
307
366
|
ui: { flags: ['no-open', 'background', 'stop', 'serve-detached'], valued: ['port'] },
|
|
308
367
|
app: { flags: ['json'], valued: ['url'] },
|
|
309
368
|
desktop: { flags: ['json', 'remove', 'yes'] },
|
|
369
|
+
edit: { flags: ['json', 'path'] },
|
|
310
370
|
browser: { flags: ['json', 'enable', 'disable', 'yes'], valued: ['profile'] },
|
|
311
|
-
'shell-init': { flags: ['write'] },
|
|
371
|
+
'shell-init': { flags: ['write', 'yes', 'undo', 'json'] },
|
|
312
372
|
plugins: { flags: ['json'] },
|
|
313
373
|
families: { flags: ['json'] },
|
|
314
|
-
update: { flags: ['json', 'yes'], valued: ['auto'] },
|
|
374
|
+
update: { flags: ['json', 'yes', 'skill'], valued: ['auto'] },
|
|
315
375
|
local: { flags: ['json', 'yes'] },
|
|
316
376
|
'update-check': { flags: [] },
|
|
317
377
|
};
|
|
@@ -329,7 +389,9 @@ function repeatedValues(args, name) {
|
|
|
329
389
|
}
|
|
330
390
|
/** Commands that never print an Update Notice: their output is read by a shell or an agent, or they are internal. */
|
|
331
391
|
function noticeAllowed(cmd, parsed) {
|
|
332
|
-
if (cmd === 'shell-init'
|
|
392
|
+
if ((cmd === 'shell-init' && parsed.positionals[0] !== 'setup') ||
|
|
393
|
+
cmd === 'update' ||
|
|
394
|
+
cmd === 'update-check')
|
|
333
395
|
return false;
|
|
334
396
|
if (cmd === 'ask' && (parsed.flags.has('print') || parsed.flags.has('run')))
|
|
335
397
|
return false;
|
|
@@ -554,6 +616,8 @@ async function dispatch(cmd, parsed, io, cmds) {
|
|
|
554
616
|
return await cmds.cmdApp(parsed, io);
|
|
555
617
|
case 'desktop':
|
|
556
618
|
return await cmds.cmdDesktop(parsed, io);
|
|
619
|
+
case 'edit':
|
|
620
|
+
return await cmds.cmdEdit(parsed, io);
|
|
557
621
|
case 'browser':
|
|
558
622
|
return await cmds.cmdBrowser(parsed, io);
|
|
559
623
|
case 'shell-init':
|
|
@@ -570,6 +634,8 @@ async function dispatch(cmd, parsed, io, cmds) {
|
|
|
570
634
|
return await cmds.cmdLocal(parsed, io);
|
|
571
635
|
case 'autostart':
|
|
572
636
|
return await cmds.cmdAutostart(parsed, io);
|
|
637
|
+
case 'menubar':
|
|
638
|
+
return await cmds.cmdMenubar(parsed, io);
|
|
573
639
|
case 'config':
|
|
574
640
|
return await cmds.cmdConfig(parsed, io);
|
|
575
641
|
}
|
|
@@ -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
|
+
}
|