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.
- package/README.md +3 -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 +349 -14
- package/dist/src/cli/json-schemas.js +157 -18
- package/dist/src/cli/main.js +56 -7
- 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 +73 -1
- package/dist/src/core/ask.js +106 -6
- 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/config.d.ts +5 -0
- package/dist/src/core/config.js +11 -1
- 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/quota-levels.d.ts +6 -1
- package/dist/src/core/quota-levels.js +16 -5
- package/dist/src/core/task-spec.d.ts +95 -0
- package/dist/src/core/task-spec.js +209 -0
- package/dist/src/core/terminal.js +6 -1
- package/dist/src/core/update.d.ts +27 -16
- package/dist/src/core/update.js +67 -93
- 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 +12 -0
- package/dist/src/panel/handler.js +80 -80
- package/dist/src/panel/i18n.d.ts +33 -0
- package/dist/src/panel/i18n.js +66 -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 +238 -109
- package/dist/src/panel/page-styles.js +42 -13
- package/dist/src/panel/page.d.ts +7 -0
- package/dist/src/panel/page.js +5 -0
- package/dist/src/runtime.d.ts +9 -1
- package/dist/src/runtime.js +11 -3
- package/dist/src/types.d.ts +14 -0
- package/package.json +4 -3
- package/schemas/ask-choices.json +168 -0
- package/schemas/ask-print.json +87 -0
- package/schemas/config.json +17 -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/skills/sideby/SKILL.md +6 -2
- 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/update.md +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ The agent checks Node and your Host CLIs, installs sideby and the skill, creates
|
|
|
46
46
|
|
|
47
47
|
The 25-second story: one account buried in tasks, then accounts side by side sharing one setup, and a task moving on when one runs out.
|
|
48
48
|
|
|
49
|
-
https://github.com/user-attachments/assets/
|
|
49
|
+
https://github.com/user-attachments/assets/d1d7e8dd-1df1-4881-ac88-e468c2dd4a1d
|
|
50
50
|
|
|
51
51
|
<img alt="Two terminals: the personal account and the work account running at the same time, both linked to the main account's skills and settings, then the local quota panel, and at 95% Auto Handoff moving work's session to the next account" src="https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/demo.gif" width="1280">
|
|
52
52
|
|
|
@@ -73,6 +73,7 @@ cc-switch's docs describe that switch: it writes the live settings file ([README
|
|
|
73
73
|
| You want to | Run | Guide |
|
|
74
74
|
|---|---|---|
|
|
75
75
|
| Hand a task to your own AI from the panel: set up an account, fix a problem, support a new tool | **Let AI do it** in the panel, or `sideby ask` | [Let AI do it](docs/guide/panel.md#let-ai-do-it) |
|
|
76
|
+
| See quota at a glance in the macOS menu bar | **Settings › Startup** in the panel, or `sideby menubar on` | [Quota in the menu bar](docs/guide/usage.md#quota-in-the-menu-bar) |
|
|
76
77
|
| Have the panel ready in the background whenever you log in | **Settings › Startup** in the panel, or `sideby autostart on` | [Start at login](docs/guide/usage.md#start-at-login) |
|
|
77
78
|
| Add an API key account (DeepSeek, a gateway, …) | `sideby new claude deepseek --api` | [API accounts](docs/guide/usage.md#api-accounts) |
|
|
78
79
|
| Find and fix config drift between accounts | `sideby doctor --fix` | [Doctor](docs/guide/usage.md#doctor) |
|
|
@@ -115,6 +116,7 @@ macOS and Linux. CI runs the suite on `ubuntu-latest` and `macos-latest`, Node 2
|
|
|
115
116
|
- It never edits a Host's global config to switch accounts. It moves a task to another account only when you turn on Auto Handoff, and never proxies requests or pools logins.
|
|
116
117
|
- It never reads, prints or sends a credential value. Nothing about your accounts leaves your machine: the only request sideby makes on its own is a daily check of the npm registry for its newest version (off with `NO_UPDATE_NOTIFIER=1`; see [Updates](docs/guide/configuration.md#updates)).
|
|
117
118
|
- `doctor --fix` never replaces a real file and never changes where a link points.
|
|
119
|
+
- The panel answers only on `127.0.0.1` and refuses web pages from other sites, but it trusts every user of this computer. On a shared Mac, do not leave it running in the background ([details](docs/guide/panel.md#who-can-reach-the-panel)).
|
|
118
120
|
|
|
119
121
|
Details and the terms-of-service question are in the [FAQ](docs/guide/faq.md).
|
|
120
122
|
|
package/ai-tasks.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"tools": {
|
|
4
|
+
"accounts": {
|
|
5
|
+
"skill": "sideby",
|
|
6
|
+
"skillInstall": "npx skills add Adonis0123/sideby -g",
|
|
7
|
+
"cwd": "engine",
|
|
8
|
+
"contribute": { "repo": "https://github.com/Adonis0123/sideby", "guide": "CONTRIBUTING.md" },
|
|
9
|
+
"presets": [
|
|
10
|
+
{
|
|
11
|
+
"id": "fix",
|
|
12
|
+
"native": true,
|
|
13
|
+
"title": { "en": "Let AI fix it", "zh": "让 AI 修复" },
|
|
14
|
+
"placeholder": { "en": "Anything to add? You can leave this empty", "zh": "想补充什么?可以不填" },
|
|
15
|
+
"examples": [
|
|
16
|
+
{ "en": "Fix these problems for me", "zh": "帮我修好这些问题" },
|
|
17
|
+
{ "en": "Explain them first, then fix them", "zh": "先解释一下再修" }
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"id": "quota",
|
|
22
|
+
"native": true,
|
|
23
|
+
"title": { "en": "Ask AI why", "zh": "问 AI 为什么" },
|
|
24
|
+
"placeholder": { "en": "Anything to add? You can leave this empty", "zh": "想补充什么?可以不填" },
|
|
25
|
+
"examples": [
|
|
26
|
+
{ "en": "Why can't I see my quota?", "zh": "为什么看不到额度" },
|
|
27
|
+
{ "en": "Turn on the quota display for me", "zh": "帮我开启额度显示" }
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "account",
|
|
32
|
+
"native": true,
|
|
33
|
+
"title": { "en": "Let AI set up an account", "zh": "让 AI 帮我配账号" },
|
|
34
|
+
"placeholder": {
|
|
35
|
+
"en": "For example: I have a DeepSeek API key",
|
|
36
|
+
"zh": "比如:我有一个 DeepSeek 的 API key"
|
|
37
|
+
},
|
|
38
|
+
"examples": [
|
|
39
|
+
{ "en": "Add a Claude subscription account", "zh": "加一个 Claude 订阅账号" },
|
|
40
|
+
{ "en": "I have an API address or a docs link", "zh": "我有一个 API 地址或文档链接" }
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "host",
|
|
45
|
+
"native": true,
|
|
46
|
+
"title": { "en": "Let AI support a new tool", "zh": "让 AI 支持一个新工具" },
|
|
47
|
+
"placeholder": { "en": "Which tool do you want to use?", "zh": "你想用哪个工具?" },
|
|
48
|
+
"examples": [
|
|
49
|
+
{ "en": "I want to use Gemini CLI", "zh": "我想用 Gemini CLI" },
|
|
50
|
+
{ "en": "I want to use OpenCode", "zh": "我想用 OpenCode" }
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "plugin",
|
|
55
|
+
"native": true,
|
|
56
|
+
"title": { "en": "Let AI write a plugin", "zh": "让 AI 写插件" },
|
|
57
|
+
"placeholder": { "en": "What should the plugin do?", "zh": "你想让插件做什么?" },
|
|
58
|
+
"examples": [
|
|
59
|
+
{ "en": "Switch my proxy before each launch", "zh": "启动前自动切换代理" },
|
|
60
|
+
{ "en": "Copy my settings into each new account", "zh": "新建账号时复制我的配置" }
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"id": "terminal",
|
|
65
|
+
"native": true,
|
|
66
|
+
"title": { "en": "Let AI set up your terminal", "zh": "让 AI 帮我配终端" },
|
|
67
|
+
"placeholder": { "en": "Which terminal do you use?", "zh": "你用的是什么终端?" },
|
|
68
|
+
"examples": [
|
|
69
|
+
{ "en": "I use Warp", "zh": "我用 Warp" },
|
|
70
|
+
{ "en": "sideby doesn't recognize my terminal", "zh": "我用的终端没被认出来" }
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": "handoff",
|
|
75
|
+
"native": true,
|
|
76
|
+
"title": { "en": "Let AI tune it", "zh": "让 AI 帮我调" },
|
|
77
|
+
"placeholder": {
|
|
78
|
+
"en": "Anything to add? For example: use work first",
|
|
79
|
+
"zh": "想补充什么?比如:先用 work"
|
|
80
|
+
},
|
|
81
|
+
"examples": [
|
|
82
|
+
{ "en": "Recommend a threshold for my accounts", "zh": "按我的账号推荐阈值" },
|
|
83
|
+
{ "en": "Use my team account last", "zh": "团队账号放到最后" },
|
|
84
|
+
{ "en": "Explain how a handoff works first", "zh": "先讲讲接力是怎么工作的" }
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"20261019T082103-0c6910"}
|
|
@@ -67,7 +67,8 @@ export declare function cmdShellInit(a: ParsedArgs, io: Io): Promise<number>;
|
|
|
67
67
|
export declare function cmdUi(a: ParsedArgs, io: Io): Promise<number>;
|
|
68
68
|
/**
|
|
69
69
|
* `sideby update [--yes] [--json]` (spec §3.23): asks the registry now, shows what an Update runs, and runs it with
|
|
70
|
-
* `--yes` (exit 10 before). An install sideby cannot update gets the command to run and exit 1.
|
|
70
|
+
* `--yes` (exit 10 before). An install sideby cannot update gets the command to run and exit 1. `--skill` updates the
|
|
71
|
+
* skill alone (cmdUpdateSkill).
|
|
71
72
|
*/
|
|
72
73
|
export declare function cmdUpdate(a: ParsedArgs, io: Io): Promise<number>;
|
|
73
74
|
/** The internal `sideby update-check` the CLI starts detached: one Update Check, then Auto Update if it is on. */
|
|
@@ -83,6 +84,8 @@ export declare function cmdApp(a: ParsedArgs, io: Io): Promise<number>;
|
|
|
83
84
|
* a Grok Bot window, new or open, and with `--remove` its removal (ADR-0019).
|
|
84
85
|
*/
|
|
85
86
|
export declare function cmdDesktop(a: ParsedArgs, io: Io): Promise<number>;
|
|
87
|
+
/** `sideby edit <account> [--path]`: the Account's Host settings file in the user's editor (spec §3.30, ADR-0033). */
|
|
88
|
+
export declare function cmdEdit(a: ParsedArgs, io: Io): Promise<number>;
|
|
86
89
|
/** `sideby browser [--enable|--disable] [--yes]` and `sideby browser open <account> [--profile <p>]` (spec §3.24). */
|
|
87
90
|
export declare function cmdBrowser(a: ParsedArgs, io: Io): Promise<number>;
|
|
88
91
|
export declare function cmdAlias(a: ParsedArgs, io: Io): Promise<number>;
|
|
@@ -101,5 +104,10 @@ export declare function cmdKey(a: ParsedArgs, io: Io, runtime?: Runtime): Promis
|
|
|
101
104
|
export declare function cmdTry(a: ParsedArgs, io: Io): Promise<number>;
|
|
102
105
|
/** `sideby autostart [on|off] [--yes]` (spec §3.29, ADR-0029): start the Panel in the background at login. */
|
|
103
106
|
export declare function cmdAutostart(a: ParsedArgs, io: Io): Promise<number>;
|
|
107
|
+
/**
|
|
108
|
+
* `sideby menubar [on|off] [--yes]`, `menubar snapshot` and `menubar start <account>` (spec §3.31, ADR-0034): quota in
|
|
109
|
+
* the macOS menu bar.
|
|
110
|
+
*/
|
|
111
|
+
export declare function cmdMenubar(a: ParsedArgs, io: Io): Promise<number>;
|
|
104
112
|
/** `sideby config get|set|unset` (spec §3.29): every setting has a command. */
|
|
105
113
|
export declare function cmdConfig(a: ParsedArgs, io: Io): Promise<number>;
|
package/dist/src/cli/commands.js
CHANGED
|
@@ -5,6 +5,7 @@ import { listAppProfiles, openAppProfile, parseProfileRef, removeAppProfile } fr
|
|
|
5
5
|
import { browserReport, openInBrowser, setBrowserSignIns } from '../core/browser-profiles.js';
|
|
6
6
|
import { aliasRefs, editConfigUpdate } from '../core/config.js';
|
|
7
7
|
import { openDesktopApp, withDesktopApps } from '../core/desktop-app.js';
|
|
8
|
+
import { editSettings } from '../core/edit-settings.js';
|
|
8
9
|
import { UserError } from '../core/errors.js';
|
|
9
10
|
import { requestHandoff } from '../core/handoff-chain.js';
|
|
10
11
|
import { handoffOverview } from '../core/handoff-overview.js';
|
|
@@ -33,17 +34,15 @@ async function whileRunning(rt, fn) {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
/** Runs the Account with Auto Handoff when it applies (spec §3.17), else the Host as usual. */
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
/** `opts.aiTask`: an AI Task's Host, started without permission bypasses (ADR-0031); `sideby run` leaves it out. */
|
|
38
|
+
async function runAccount(rt, ref, args, io, opts = {}) {
|
|
39
|
+
return whileRunning(rt, () => runAccountNow(rt, ref, args, io, opts));
|
|
38
40
|
}
|
|
39
|
-
async function runAccountNow(rt, ref, args, io) {
|
|
40
|
-
const handed = await runWithHandoff(rt, ref, args, {
|
|
41
|
-
err: (l) => io.err(c.dim(l)),
|
|
42
|
-
stdin: io.stdin ?? process.stdin,
|
|
43
|
-
});
|
|
41
|
+
async function runAccountNow(rt, ref, args, io, opts) {
|
|
42
|
+
const handed = await runWithHandoff(rt, ref, args, { err: (l) => io.err(c.dim(l)), stdin: io.stdin ?? process.stdin }, opts);
|
|
44
43
|
if (handed !== null)
|
|
45
44
|
return handed;
|
|
46
|
-
const prepared = await rt.prepareLaunch(ref, args, 'run');
|
|
45
|
+
const prepared = await rt.prepareLaunch(ref, args, 'run', opts);
|
|
47
46
|
if (prepared.notice)
|
|
48
47
|
io.err(c.cyan(prepared.notice));
|
|
49
48
|
const code = await runHost(prepared);
|
|
@@ -1257,13 +1256,73 @@ export async function cmdUi(a, io) {
|
|
|
1257
1256
|
});
|
|
1258
1257
|
return 0;
|
|
1259
1258
|
}
|
|
1259
|
+
/**
|
|
1260
|
+
* `sideby update --skill [--yes] [--json]` (spec §3.23): only the installed sideby skill, toward this version. It
|
|
1261
|
+
* never installs the CLI, also when a newer one exists (it says that update is separate), and asks no registry. The
|
|
1262
|
+
* new code runs it after an install, so a registry that moved meanwhile never installs a version nobody confirmed.
|
|
1263
|
+
*/
|
|
1264
|
+
async function cmdUpdateSkill(a, io) {
|
|
1265
|
+
if (a.positionals.length || a.rest.length)
|
|
1266
|
+
throw new UsageError('usage: sideby update --skill [--yes] [--json]');
|
|
1267
|
+
const u = await import('../core/update.js');
|
|
1268
|
+
const { SKILL_INSTALL } = await import('../core/skill-check.js');
|
|
1269
|
+
const paths = resolvePaths(process.env);
|
|
1270
|
+
const asJson = a.flags.has('json');
|
|
1271
|
+
const plan = await u.planSkillUpdate(paths, process.env);
|
|
1272
|
+
const shown = u.shownPlan(plan);
|
|
1273
|
+
const sk = plan.skill;
|
|
1274
|
+
// The skills tool fetches the newest skill, so a newer CLI should follow; that stays the user's own step.
|
|
1275
|
+
const cliLine = () => {
|
|
1276
|
+
if (plan.available)
|
|
1277
|
+
io.out(c.cyan(`sideby ${plan.latest} is available; updating sideby itself is separate: \`sideby update\`.`));
|
|
1278
|
+
};
|
|
1279
|
+
if (!sk?.outdated || !sk.canRun) {
|
|
1280
|
+
if (asJson)
|
|
1281
|
+
json(io, { ...shown, updated: false });
|
|
1282
|
+
else {
|
|
1283
|
+
if (!sk)
|
|
1284
|
+
io.out(`No sideby skill is installed. To install it: ${SKILL_INSTALL}`);
|
|
1285
|
+
else if (!sk.outdated)
|
|
1286
|
+
io.out(`${c.green('✓')} The sideby skill is already for sideby ${plan.current}.`);
|
|
1287
|
+
else
|
|
1288
|
+
io.out(c.yellow(`The sideby skill is not updated by sideby: ${sk.reason}.\n ${sk.command}`));
|
|
1289
|
+
cliLine();
|
|
1290
|
+
}
|
|
1291
|
+
return 0;
|
|
1292
|
+
}
|
|
1293
|
+
if (!a.flags.has('yes')) {
|
|
1294
|
+
if (asJson)
|
|
1295
|
+
json(io, { ...shown, updated: false });
|
|
1296
|
+
else {
|
|
1297
|
+
const from = sk.installed.map((v) => v ?? 'no version').join(', ');
|
|
1298
|
+
io.out(`Updating the sideby skill (for ${from}) to sideby ${plan.current} runs:\n ${sk.command}`);
|
|
1299
|
+
cliLine();
|
|
1300
|
+
io.out(c.cyan('\nRun it with `sideby update --skill --yes`.'));
|
|
1301
|
+
}
|
|
1302
|
+
return 10;
|
|
1303
|
+
}
|
|
1304
|
+
if (!asJson)
|
|
1305
|
+
io.out(c.dim(`$ ${sk.command}`));
|
|
1306
|
+
const r = await u.applySkillOnly(paths, sk, process.env, asJson ? undefined : (t) => process.stderr.write(t));
|
|
1307
|
+
if (asJson)
|
|
1308
|
+
json(io, { ...shown, updated: false, skillUpdated: r?.ok ?? false, message: r?.message ?? '' });
|
|
1309
|
+
else {
|
|
1310
|
+
if (r?.ok)
|
|
1311
|
+
io.out(`${c.green('✓')} ${r.message}; agents load it in their next session.`);
|
|
1312
|
+
else
|
|
1313
|
+
io.err(c.red(`✗ ${r?.message}`));
|
|
1314
|
+
cliLine();
|
|
1315
|
+
}
|
|
1316
|
+
return r?.ok ? 0 : 1;
|
|
1317
|
+
}
|
|
1260
1318
|
/**
|
|
1261
1319
|
* `sideby update [--yes] [--json]` (spec §3.23): asks the registry now, shows what an Update runs, and runs it with
|
|
1262
|
-
* `--yes` (exit 10 before). An install sideby cannot update gets the command to run and exit 1.
|
|
1320
|
+
* `--yes` (exit 10 before). An install sideby cannot update gets the command to run and exit 1. `--skill` updates the
|
|
1321
|
+
* skill alone (cmdUpdateSkill).
|
|
1263
1322
|
*/
|
|
1264
1323
|
export async function cmdUpdate(a, io) {
|
|
1265
1324
|
if (a.positionals.length)
|
|
1266
|
-
throw new UsageError('usage: sideby update [--yes] [--json]');
|
|
1325
|
+
throw new UsageError('usage: sideby update [--skill] [--yes] [--json]');
|
|
1267
1326
|
if (a.flags.has('auto')) {
|
|
1268
1327
|
if (a.rest.length)
|
|
1269
1328
|
throw new UsageError('usage: sideby update --auto on|off [--json]');
|
|
@@ -1276,6 +1335,8 @@ export async function cmdUpdate(a, io) {
|
|
|
1276
1335
|
io.out(`Auto Update ${auto ? 'on' : 'off'}${r.changed ? '.' : ' (unchanged).'}`);
|
|
1277
1336
|
return 0;
|
|
1278
1337
|
}
|
|
1338
|
+
if (a.flags.has('skill'))
|
|
1339
|
+
return cmdUpdateSkill(a, io);
|
|
1279
1340
|
const u = await import('../core/update.js');
|
|
1280
1341
|
const { SKILL_INSTALL } = await import('../core/skill-check.js');
|
|
1281
1342
|
const { backgroundPanelPort } = await import('../panel/background.js');
|
|
@@ -1566,6 +1627,28 @@ export async function cmdDesktop(a, io) {
|
|
|
1566
1627
|
io.err(c.cyan(n));
|
|
1567
1628
|
return 0;
|
|
1568
1629
|
}
|
|
1630
|
+
/** `sideby edit <account> [--path]`: the Account's Host settings file in the user's editor (spec §3.30, ADR-0033). */
|
|
1631
|
+
export async function cmdEdit(a, io) {
|
|
1632
|
+
const [ref, ...extra] = a.positionals;
|
|
1633
|
+
if (!ref || extra.length || a.rest.length)
|
|
1634
|
+
throw new UsageError('usage: sideby edit <account> [--path]');
|
|
1635
|
+
const rt = await createRuntime();
|
|
1636
|
+
const r = await editSettings(rt, ref, { open: !a.flags.has('path') });
|
|
1637
|
+
if (a.flags.has('json')) {
|
|
1638
|
+
json(io, r);
|
|
1639
|
+
return 0;
|
|
1640
|
+
}
|
|
1641
|
+
const home = rt.paths.home;
|
|
1642
|
+
if (!r.opened)
|
|
1643
|
+
io.out(r.target ?? r.path);
|
|
1644
|
+
else
|
|
1645
|
+
io.out(`${c.green('✓')} opened ${c.bold(r.ref)}'s ${r.file} with your default program`);
|
|
1646
|
+
if (r.opened || r.target)
|
|
1647
|
+
io.out(c.dim(` ${tildify(r.target ?? r.path, home)}${r.target ? ` (linked from ${tildify(r.path, home)})` : ''}`));
|
|
1648
|
+
if (r.sharedWith.length)
|
|
1649
|
+
io.out(c.dim(` shared: a change also applies to ${r.sharedWith.join(', ')}`));
|
|
1650
|
+
return 0;
|
|
1651
|
+
}
|
|
1569
1652
|
/** `sideby browser [--enable|--disable] [--yes]` and `sideby browser open <account> [--profile <p>]` (spec §3.24). */
|
|
1570
1653
|
export async function cmdBrowser(a, io) {
|
|
1571
1654
|
const [sub, ref, ...extra] = a.positionals;
|
|
@@ -1702,7 +1785,7 @@ export async function cmdFamilies(a, io) {
|
|
|
1702
1785
|
}
|
|
1703
1786
|
/** AI Task CLI; the terminal receives only an opaque task id. */
|
|
1704
1787
|
export async function cmdAsk(a, io, runtime) {
|
|
1705
|
-
const { previewAttachments, promptForTask, readTask, startAiTask, taskEnv, taskHostArgs, taskStateDir } = await import('../core/ask.js');
|
|
1788
|
+
const { movedCwdError, previewAttachments, promptForTask, readTask, realCwdInHome, startAiTask, taskEnv, taskHostArgs, taskStateDir, } = await import('../core/ask.js');
|
|
1706
1789
|
const run = a.flags.get('run');
|
|
1707
1790
|
if (typeof run === 'string') {
|
|
1708
1791
|
const stateDir = a.flags.get('state-dir');
|
|
@@ -1722,9 +1805,27 @@ export async function cmdAsk(a, io, runtime) {
|
|
|
1722
1805
|
: (runtime ?? (await createRuntime()));
|
|
1723
1806
|
const cwd = process.cwd();
|
|
1724
1807
|
try {
|
|
1725
|
-
|
|
1808
|
+
try {
|
|
1809
|
+
process.chdir(task.cwd);
|
|
1810
|
+
}
|
|
1811
|
+
catch (err) {
|
|
1812
|
+
if (task.cwdInHome)
|
|
1813
|
+
throw movedCwdError('does not exist');
|
|
1814
|
+
throw err;
|
|
1815
|
+
}
|
|
1816
|
+
// A Portal's folder is checked where the process now is, so a link swapped in after the task was written is
|
|
1817
|
+
// caught, and the folder cannot change between the check and the Host start.
|
|
1818
|
+
if (task.cwdInHome) {
|
|
1819
|
+
const now = await realCwdInHome(process.cwd(), task.home ?? rt.paths.home);
|
|
1820
|
+
if ('why' in now)
|
|
1821
|
+
throw movedCwdError(now.why);
|
|
1822
|
+
if (now.real !== task.cwd)
|
|
1823
|
+
throw movedCwdError('points somewhere else');
|
|
1824
|
+
}
|
|
1726
1825
|
if (task.kind === 'prompt')
|
|
1727
|
-
return await runAccount(rt, task.account, await taskHostArgs(rt, task), io);
|
|
1826
|
+
return await runAccount(rt, task.account, await taskHostArgs(rt, task), io, { aiTask: true });
|
|
1827
|
+
if (task.kind === 'run')
|
|
1828
|
+
return await runAccount(rt, task.account, [], io);
|
|
1728
1829
|
const prepared = await rt.prepareLaunch(task.account, [], 'login');
|
|
1729
1830
|
if (prepared.notice)
|
|
1730
1831
|
io.err(prepared.notice);
|
|
@@ -1734,6 +1835,8 @@ export async function cmdAsk(a, io, runtime) {
|
|
|
1734
1835
|
process.chdir(cwd);
|
|
1735
1836
|
}
|
|
1736
1837
|
}
|
|
1838
|
+
if (a.flags.has('spec') || a.flags.has('choices'))
|
|
1839
|
+
return cmdAskSpec(a, io, runtime);
|
|
1737
1840
|
const rt = runtime ?? (await createRuntime());
|
|
1738
1841
|
const task = String(a.flags.get('task') ?? 'free');
|
|
1739
1842
|
if (!AI_TASK_KINDS.includes(task))
|
|
@@ -1760,13 +1863,85 @@ export async function cmdAsk(a, io, runtime) {
|
|
|
1760
1863
|
if (a.flags.has('json'))
|
|
1761
1864
|
json(io, result);
|
|
1762
1865
|
else if (result.command)
|
|
1763
|
-
io.out(result.opened ?
|
|
1866
|
+
io.out(result.opened ? await openedLine(rt, result) : result.command);
|
|
1764
1867
|
else
|
|
1765
1868
|
io.out(result.prompt ?? preview.prompt);
|
|
1766
1869
|
if (!result.opened)
|
|
1767
1870
|
io.err(result.detail);
|
|
1768
1871
|
return result.opened ? 0 : 1;
|
|
1769
1872
|
}
|
|
1873
|
+
/** What `sideby ask` prints once the terminal opened; a Family with `aiTaskArgs` adds that its checks stay on. */
|
|
1874
|
+
async function openedLine(rt, result) {
|
|
1875
|
+
const line = `Opened ${result.terminal} for ${result.account}.`;
|
|
1876
|
+
const family = result.account
|
|
1877
|
+
? await rt.resolve(result.account).then((a) => rt.families.get(a.family), () => undefined)
|
|
1878
|
+
: undefined;
|
|
1879
|
+
return family?.aiTaskArgs
|
|
1880
|
+
? `${line} Its permission checks stay on, so risky actions are checked first.`
|
|
1881
|
+
: line;
|
|
1882
|
+
}
|
|
1883
|
+
/**
|
|
1884
|
+
* `sideby ask --spec - [--print]` and `sideby ask --choices` (ADR-0030): the AI Tasks a Portal starts. The Task Spec
|
|
1885
|
+
* comes on stdin, never through a shell. A refused spec exits 1 with its `code` (and `reason`, as the Portal reads
|
|
1886
|
+
* it), or 2 for a spec version this sideby does not know.
|
|
1887
|
+
*/
|
|
1888
|
+
async function cmdAskSpec(a, io, runtime) {
|
|
1889
|
+
const { previewTaskSpec, parseTaskSpec, readSpecText, SpecError, startTaskSpec, taskChoices } = await import('../core/task-spec.js');
|
|
1890
|
+
const choices = a.flags.has('choices');
|
|
1891
|
+
const allowed = choices ? ['choices', 'json'] : ['spec', 'print', 'json'];
|
|
1892
|
+
if (a.positionals.length ||
|
|
1893
|
+
a.rest.length ||
|
|
1894
|
+
a.attach?.length ||
|
|
1895
|
+
[...a.flags.keys()].some((f) => !allowed.includes(f)))
|
|
1896
|
+
throw new UsageError('Use `sideby ask --spec - [--print] --json` or `sideby ask --choices --json` on their own.');
|
|
1897
|
+
const rt = runtime ?? (await createRuntime());
|
|
1898
|
+
if (choices) {
|
|
1899
|
+
const result = await taskChoices(rt);
|
|
1900
|
+
if (a.flags.has('json'))
|
|
1901
|
+
json(io, result);
|
|
1902
|
+
else {
|
|
1903
|
+
io.out(result.account ? `Account: ${result.account}` : `No account: ${result.detail}`);
|
|
1904
|
+
io.out(`Terminal: ${result.terminal}`);
|
|
1905
|
+
}
|
|
1906
|
+
return 0;
|
|
1907
|
+
}
|
|
1908
|
+
if (a.flags.get('spec') !== '-')
|
|
1909
|
+
throw new UsageError('Pass the Task Spec on stdin: sideby ask --spec - --json');
|
|
1910
|
+
const stdin = io.stdin ?? process.stdin;
|
|
1911
|
+
if (stdin.isTTY)
|
|
1912
|
+
throw new UsageError('Pipe the Task Spec into stdin: sideby ask --spec - --json < spec.json');
|
|
1913
|
+
try {
|
|
1914
|
+
const spec = parseTaskSpec(await readSpecText(stdin));
|
|
1915
|
+
if (a.flags.has('print')) {
|
|
1916
|
+
const preview = await previewTaskSpec(rt, spec);
|
|
1917
|
+
if (a.flags.has('json'))
|
|
1918
|
+
json(io, preview);
|
|
1919
|
+
else
|
|
1920
|
+
io.out(preview.prompt);
|
|
1921
|
+
return 0;
|
|
1922
|
+
}
|
|
1923
|
+
const result = await startTaskSpec(rt, spec);
|
|
1924
|
+
if (a.flags.has('json'))
|
|
1925
|
+
json(io, result);
|
|
1926
|
+
else if (result.command)
|
|
1927
|
+
io.out(result.opened ? await openedLine(rt, result) : result.command);
|
|
1928
|
+
else
|
|
1929
|
+
io.out(result.prompt ?? '');
|
|
1930
|
+
if (!result.opened)
|
|
1931
|
+
io.err(result.detail);
|
|
1932
|
+
return result.opened ? 0 : 1;
|
|
1933
|
+
}
|
|
1934
|
+
catch (err) {
|
|
1935
|
+
// A folder that changed between the check and the task file is refused like a bad one.
|
|
1936
|
+
if (!(err instanceof SpecError) && !(err instanceof UserError && err.code === 'bad-cwd'))
|
|
1937
|
+
throw err;
|
|
1938
|
+
if (a.flags.has('json'))
|
|
1939
|
+
json(io, { schemaVersion: 1, error: err.message, code: err.code, reason: err.code });
|
|
1940
|
+
else
|
|
1941
|
+
io.err(`sideby: ${err.message}`);
|
|
1942
|
+
return err.code === 'spec-version' ? 2 : 1;
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1770
1945
|
export async function cmdTerminal(a, io) {
|
|
1771
1946
|
const { terminals, setCustomTerminal, setPreferredTerminal } = await import('../core/ask.js');
|
|
1772
1947
|
const rt = await createRuntime();
|
|
@@ -2004,6 +2179,166 @@ export async function cmdAutostart(a, io) {
|
|
|
2004
2179
|
}
|
|
2005
2180
|
return 0;
|
|
2006
2181
|
}
|
|
2182
|
+
/** What the Menu Bar Item lists (spec §3.31): each Family's accounts in Display Order, with its Handoff ranking. */
|
|
2183
|
+
async function menubarFamilies(rt) {
|
|
2184
|
+
const accounts = displayOrdered(await rt.accounts(), rt);
|
|
2185
|
+
const ids = [...new Set(accounts.map((x) => x.family))];
|
|
2186
|
+
return Promise.all(ids.map(async (id) => {
|
|
2187
|
+
const f = rt.families.get(id);
|
|
2188
|
+
const plan = f.readQuota || f.fetchQuota ? await rt.handoff(id).catch(() => null) : null;
|
|
2189
|
+
const list = await Promise.all(accounts
|
|
2190
|
+
.filter((x) => x.family === id)
|
|
2191
|
+
.map(async (x) => ({
|
|
2192
|
+
ref: x.ref,
|
|
2193
|
+
name: x.name,
|
|
2194
|
+
kind: x.kind,
|
|
2195
|
+
login: x.kind === 'api' ? 'not-needed' : (await rt.status(x)).login,
|
|
2196
|
+
quota: await rt.quota(x),
|
|
2197
|
+
sameLogin: await rt.sameLogin(x),
|
|
2198
|
+
})));
|
|
2199
|
+
return { id, title: f.title, logo: f.logo ?? null, plan, accounts: list };
|
|
2200
|
+
}));
|
|
2201
|
+
}
|
|
2202
|
+
/**
|
|
2203
|
+
* `sideby menubar [on|off] [--yes]`, `menubar snapshot` and `menubar start <account>` (spec §3.31, ADR-0034): quota in
|
|
2204
|
+
* the macOS menu bar.
|
|
2205
|
+
*/
|
|
2206
|
+
export async function cmdMenubar(a, io) {
|
|
2207
|
+
const [action, extra] = a.positionals;
|
|
2208
|
+
const wantJson = a.flags.has('json');
|
|
2209
|
+
if (action === 'snapshot') {
|
|
2210
|
+
if (extra !== undefined)
|
|
2211
|
+
throw new UsageError('usage: sideby menubar snapshot [--lang en|zh] [--json]');
|
|
2212
|
+
const { menubarHotkey, menubarLang, menubarSnapshot } = await import('../menubar/snapshot.js');
|
|
2213
|
+
const rt = await createRuntime();
|
|
2214
|
+
const lang = menubarLang(rt.config.panel?.language, a.flags.get('lang') ?? rt.env.LANG);
|
|
2215
|
+
const snap = menubarSnapshot(await menubarFamilies(rt), rt.readContext().now, lang, menubarHotkey(rt.config.menubar?.hotkey));
|
|
2216
|
+
if (wantJson)
|
|
2217
|
+
json(io, snap);
|
|
2218
|
+
else {
|
|
2219
|
+
io.out(snap.title ? `${snap.title} ${c.dim(snap.tooltip)}` : snap.tooltip);
|
|
2220
|
+
const line = (r, indent) => io.out(`${indent}${r.label}${r.recommended ? ` (${snap.labels.recommended})` : ''} ${c.dim(r.detail)}`);
|
|
2221
|
+
for (const s of snap.sections) {
|
|
2222
|
+
io.out(c.bold(s.title));
|
|
2223
|
+
for (const r of s.rows)
|
|
2224
|
+
line(r, ' ');
|
|
2225
|
+
if (s.more) {
|
|
2226
|
+
io.out(` ${s.more.title}`);
|
|
2227
|
+
for (const r of s.more.rows)
|
|
2228
|
+
line(r, ' ');
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
return 0;
|
|
2233
|
+
}
|
|
2234
|
+
if (action === 'start') {
|
|
2235
|
+
if (!extra || a.positionals.length > 2)
|
|
2236
|
+
throw new UsageError('usage: sideby menubar start <account> [--json]');
|
|
2237
|
+
const { openRunInTerminal } = await import('../core/ask.js');
|
|
2238
|
+
const rt = await createRuntime();
|
|
2239
|
+
const r = await openRunInTerminal(rt, extra);
|
|
2240
|
+
if (wantJson)
|
|
2241
|
+
json(io, r);
|
|
2242
|
+
else
|
|
2243
|
+
io.out(r.opened ? `Opened ${r.terminal} for ${r.account}.` : r.command);
|
|
2244
|
+
if (!r.opened)
|
|
2245
|
+
io.err(r.detail);
|
|
2246
|
+
return r.opened ? 0 : 1;
|
|
2247
|
+
}
|
|
2248
|
+
const { applyAutostart, autostartStatus, planAutostart, refreshAutostart } = await import('../core/autostart.js');
|
|
2249
|
+
const { MENUBAR_AGENT } = await import('../menubar/agent.js');
|
|
2250
|
+
if (extra !== undefined || (action !== undefined && action !== 'on' && action !== 'off'))
|
|
2251
|
+
throw new UsageError('usage: sideby menubar [on|off] [--yes] [--json]');
|
|
2252
|
+
if (a.flags.has('yes') && !action)
|
|
2253
|
+
throw new UsageError('--yes needs a change: sideby menubar on|off --yes');
|
|
2254
|
+
const home = resolvePaths().home;
|
|
2255
|
+
const ctx = { home };
|
|
2256
|
+
if (a.flags.has('refresh')) {
|
|
2257
|
+
// After an update or a local build switch: point an existing agent at this sideby; never create one.
|
|
2258
|
+
const r = await refreshAutostart(ctx, MENUBAR_AGENT);
|
|
2259
|
+
const status = await autostartStatus(ctx, MENUBAR_AGENT);
|
|
2260
|
+
if (wantJson)
|
|
2261
|
+
json(io, {
|
|
2262
|
+
...status,
|
|
2263
|
+
path: tilde(status.path, home),
|
|
2264
|
+
changed: r.rewritten,
|
|
2265
|
+
...(r.note ? { note: r.note } : {}),
|
|
2266
|
+
});
|
|
2267
|
+
else
|
|
2268
|
+
io.out(r.rewritten ? 'The menu bar item now runs this sideby.' : (r.note ?? 'Nothing to change.'));
|
|
2269
|
+
return 0;
|
|
2270
|
+
}
|
|
2271
|
+
if (!action) {
|
|
2272
|
+
const s = await autostartStatus(ctx, MENUBAR_AGENT);
|
|
2273
|
+
if (wantJson)
|
|
2274
|
+
json(io, { ...s, path: tilde(s.path, home) });
|
|
2275
|
+
else if (!s.supported)
|
|
2276
|
+
io.out('The menu bar item is only available on macOS for now.');
|
|
2277
|
+
else if (s.state === 'off')
|
|
2278
|
+
io.out('Menu bar item: off. Run `sideby menubar on` to show quota in the menu bar.');
|
|
2279
|
+
else if (s.state === 'foreign')
|
|
2280
|
+
io.out(`${tilde(s.path, home)} is not sideby's, so sideby leaves it alone; remove or rename it yourself if it is not needed.`);
|
|
2281
|
+
else if (s.state === 'stale')
|
|
2282
|
+
io.out('Menu bar item: points to a sideby or Node that is no longer there. Run `sideby menubar on` to fix it.');
|
|
2283
|
+
else {
|
|
2284
|
+
io.out('Menu bar item: on.');
|
|
2285
|
+
if (!s.current)
|
|
2286
|
+
io.out(c.dim('It runs another sideby than this one; `sideby menubar on` points it here.'));
|
|
2287
|
+
io.out(c.dim('Turn it off: sideby menubar off'));
|
|
2288
|
+
}
|
|
2289
|
+
return 0;
|
|
2290
|
+
}
|
|
2291
|
+
const plan = await planAutostart(ctx, action, MENUBAR_AGENT);
|
|
2292
|
+
if (plan.blocked)
|
|
2293
|
+
throw new UserError(plan.blocked.code === 'unsupported'
|
|
2294
|
+
? 'The menu bar item is only available on macOS for now.'
|
|
2295
|
+
: plan.blocked.message, { code: plan.blocked.code });
|
|
2296
|
+
const shown = {
|
|
2297
|
+
...plan.status,
|
|
2298
|
+
path: tilde(plan.path, home),
|
|
2299
|
+
action,
|
|
2300
|
+
changed: plan.changed,
|
|
2301
|
+
applied: false,
|
|
2302
|
+
...(plan.content ? { content: plan.content } : {}),
|
|
2303
|
+
...(plan.programArguments ? { programArguments: plan.programArguments } : {}),
|
|
2304
|
+
commands: plan.commands,
|
|
2305
|
+
};
|
|
2306
|
+
if (!plan.changed) {
|
|
2307
|
+
if (wantJson)
|
|
2308
|
+
json(io, shown);
|
|
2309
|
+
else
|
|
2310
|
+
io.out(action === 'on' ? 'Already on.' : 'Already off.');
|
|
2311
|
+
return 0;
|
|
2312
|
+
}
|
|
2313
|
+
const path = tilde(plan.path, home);
|
|
2314
|
+
if (!a.flags.has('yes')) {
|
|
2315
|
+
// The file holds the whole menu bar script, so only its path is printed; `--json` carries the content.
|
|
2316
|
+
if (wantJson)
|
|
2317
|
+
json(io, shown);
|
|
2318
|
+
else
|
|
2319
|
+
io.out(action === 'on'
|
|
2320
|
+
? `This adds a login item at ${path} that shows your quota in the menu bar and starts at login. Run \`sideby menubar on --yes\` to turn it on.`
|
|
2321
|
+
: `This removes ${path} and hides the menu bar item. Run \`sideby menubar off --yes\` to turn it off.`);
|
|
2322
|
+
return 10;
|
|
2323
|
+
}
|
|
2324
|
+
const r = await applyAutostart(ctx, plan, MENUBAR_AGENT);
|
|
2325
|
+
if (wantJson)
|
|
2326
|
+
json(io, {
|
|
2327
|
+
...shown,
|
|
2328
|
+
state: r.state,
|
|
2329
|
+
applied: true,
|
|
2330
|
+
loaded: r.loaded,
|
|
2331
|
+
...(r.note ? { note: r.note } : {}),
|
|
2332
|
+
});
|
|
2333
|
+
else {
|
|
2334
|
+
io.out(action === 'on'
|
|
2335
|
+
? 'The menu bar item is on and in your menu bar now. To turn it off later, run `sideby menubar off`.'
|
|
2336
|
+
: 'The menu bar item is off. Run `sideby menubar on` to turn it on again.');
|
|
2337
|
+
if (r.note)
|
|
2338
|
+
io.out(c.dim(r.note));
|
|
2339
|
+
}
|
|
2340
|
+
return 0;
|
|
2341
|
+
}
|
|
2007
2342
|
/** The `accounts.<ref>.args` check of `sideby config set`: only the model and effort arguments, as `sideby model`. */
|
|
2008
2343
|
function modelArgsProblem(rt) {
|
|
2009
2344
|
return (ref, args) => {
|