sideby 0.35.5 → 0.35.7
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/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +9 -1
- package/dist/src/cli/commands.js +59 -16
- package/dist/src/cli/json-schemas.js +20 -0
- package/dist/src/cli/main.js +11 -5
- package/dist/src/core/cli-commands.js +1 -1
- package/dist/src/core/config.d.ts +7 -0
- package/dist/src/core/config.js +9 -0
- package/dist/src/core/doctor.d.ts +5 -1
- package/dist/src/core/doctor.js +16 -0
- package/dist/src/core/edit-settings.d.ts +27 -1
- package/dist/src/core/edit-settings.js +78 -4
- package/dist/src/core/handoff-select.d.ts +3 -1
- package/dist/src/core/handoff-select.js +11 -1
- package/dist/src/core/handoff.d.ts +13 -1
- package/dist/src/core/handoff.js +16 -5
- package/dist/src/core/login-mark.d.ts +3 -0
- package/dist/src/core/login-mark.js +22 -0
- package/dist/src/core/pick-commands.d.ts +4 -2
- package/dist/src/core/pick-commands.js +7 -2
- package/dist/src/core/quota-fetch.d.ts +7 -1
- package/dist/src/core/quota-fetch.js +38 -1
- package/dist/src/core/quota-store.d.ts +5 -0
- package/dist/src/core/quota-store.js +3 -0
- package/dist/src/core/search-catalog.js +9 -0
- package/dist/src/core/session-hooks.d.ts +6 -1
- package/dist/src/core/session-hooks.js +16 -2
- package/dist/src/families/claude/index.js +3 -0
- package/dist/src/families/claude/login-events.d.ts +24 -0
- package/dist/src/families/claude/login-events.js +163 -0
- package/dist/src/families/claude/quota-fetch.js +14 -0
- package/dist/src/menubar/snapshot.d.ts +2 -0
- package/dist/src/menubar/snapshot.js +6 -2
- package/dist/src/menubar/strings.d.ts +4 -0
- package/dist/src/menubar/strings.js +4 -0
- package/dist/src/panel/handler.d.ts +14 -1
- package/dist/src/panel/handler.js +48 -14
- package/dist/src/panel/i18n.d.ts +23 -0
- package/dist/src/panel/i18n.js +46 -0
- package/dist/src/panel/page-logic.d.ts +44 -2
- package/dist/src/panel/page-logic.js +43 -3
- package/dist/src/panel/page-script.js +124 -7
- package/dist/src/panel/page-styles.js +8 -0
- package/dist/src/panel/page.d.ts +7 -0
- package/dist/src/panel/page.js +1 -0
- package/dist/src/runtime.d.ts +16 -1
- package/dist/src/runtime.js +51 -2
- package/dist/src/types.d.ts +37 -0
- package/package.json +3 -3
- package/schemas/config.json +11 -0
- package/schemas/edit.json +4 -0
- package/schemas/list.json +24 -0
- package/schemas/next.json +18 -0
- package/skills/sideby/SKILL.md +4 -2
- package/skills/sideby/references/accounts.md +9 -0
- package/skills/sideby/references/diagnose.md +6 -1
- package/skills/sideby/references/panel.md +1 -1
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"20261109T030142-15900e"}
|
|
@@ -62,6 +62,11 @@ export interface NewSuggestion {
|
|
|
62
62
|
}
|
|
63
63
|
export declare function cmdNew(a: ParsedArgs, io: Io): Promise<number>;
|
|
64
64
|
export declare function cmdRun(a: ParsedArgs, io: Io, command: 'run' | 'login'): Promise<number>;
|
|
65
|
+
/**
|
|
66
|
+
* After a sign-in that ended with exit 0 for an Account with an Expired Login (ADR-0071 Q9): ask its Quota once, so a
|
|
67
|
+
* good answer clears the state; say whether it did, or that sideby waits for the next session or Quota answer.
|
|
68
|
+
*/
|
|
69
|
+
export declare function confirmLogin(rt: Runtime, account: Account, io: Io): Promise<void>;
|
|
65
70
|
/**
|
|
66
71
|
* `sideby resume <family>`: what the Host-named shell function calls (spec §3.15). Starts the Account that holds the
|
|
67
72
|
* session the arguments resume by id, a new session where a never-saved one started (ADR-0009), or the Host unchanged.
|
|
@@ -107,7 +112,10 @@ export declare function cmdApp(a: ParsedArgs, io: Io): Promise<number>;
|
|
|
107
112
|
* a Grok Bot window, new or open, and with `--remove` its removal (ADR-0019).
|
|
108
113
|
*/
|
|
109
114
|
export declare function cmdDesktop(a: ParsedArgs, io: Io): Promise<number>;
|
|
110
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* `sideby edit <account> [--path] [--with <editor>]`: the Account's Host settings file in the user's editor (spec §3.30,
|
|
117
|
+
* ADR-0033).
|
|
118
|
+
*/
|
|
111
119
|
export declare function cmdEdit(a: ParsedArgs, io: Io): Promise<number>;
|
|
112
120
|
/** `sideby browser [--enable|--disable] [--yes]` and `sideby browser open <account> [--profile <p>]` (spec §3.24). */
|
|
113
121
|
export declare function cmdBrowser(a: ParsedArgs, io: Io): Promise<number>;
|
package/dist/src/cli/commands.js
CHANGED
|
@@ -6,9 +6,9 @@ import { aliasesByAccount } from '../core/accounts.js';
|
|
|
6
6
|
import { listAppProfiles, openAppProfile, parseProfileRef, removeAppProfile } from '../core/app-profiles.js';
|
|
7
7
|
import { browserReport, openInBrowser, setBrowserChoice, setBrowserSignIns, } from '../core/browser-profiles.js';
|
|
8
8
|
import { CLI_COMMANDS, COMMAND_GROUPS, commonCommands } from '../core/cli-commands.js';
|
|
9
|
-
import { aiTaskPermissions, aliasAccount, aliasArgs, aliasRefs, editConfigAskPermissions, editConfigUpdate, loadConfig, } from '../core/config.js';
|
|
9
|
+
import { aiTaskPermissions, aliasAccount, aliasArgs, aliasRefs, EDITORS, editConfigAskPermissions, editConfigUpdate, loadConfig, } from '../core/config.js';
|
|
10
10
|
import { openDesktopApp, withDesktopApps } from '../core/desktop-app.js';
|
|
11
|
-
import { editSettings } from '../core/edit-settings.js';
|
|
11
|
+
import { EDITOR_APPS, editSettings, isEditor } from '../core/edit-settings.js';
|
|
12
12
|
import { UserError } from '../core/errors.js';
|
|
13
13
|
import { requestHandoff } from '../core/handoff-chain.js';
|
|
14
14
|
import { handoffOverview } from '../core/handoff-overview.js';
|
|
@@ -368,13 +368,15 @@ export async function cmdList(a, io) {
|
|
|
368
368
|
const rows = shown.map((s) => [
|
|
369
369
|
`${c.bold(s.ref)}${sameMark(s.sameLogin)}${s.hidden ? ` ${c.dim('(hidden)')}` : ''}`,
|
|
370
370
|
s.isMain ? 'main' : s.kind === 'api' ? c.cyan('api') : 'sub',
|
|
371
|
-
s.
|
|
372
|
-
? c.
|
|
373
|
-
: s.login === '
|
|
374
|
-
? c.
|
|
375
|
-
: s.login === '
|
|
376
|
-
? c.
|
|
377
|
-
:
|
|
371
|
+
s.loginProblem?.kind === 'expired'
|
|
372
|
+
? c.yellow('expired')
|
|
373
|
+
: s.login === 'logged-in'
|
|
374
|
+
? c.green('✓')
|
|
375
|
+
: s.login === 'not-needed'
|
|
376
|
+
? c.dim('key')
|
|
377
|
+
: s.login === 'logged-out'
|
|
378
|
+
? c.yellow('login needed')
|
|
379
|
+
: c.dim('?'),
|
|
378
380
|
s.identity?.email ?? c.dim('—'),
|
|
379
381
|
s.model ?? c.dim('—'),
|
|
380
382
|
s.hostInstalled
|
|
@@ -390,6 +392,9 @@ export async function cmdList(a, io) {
|
|
|
390
392
|
: `\n${f.title} is not installed; install it: ${installHint(f)}`));
|
|
391
393
|
if (shown.some((s) => s.sameLogin?.length))
|
|
392
394
|
io.out(c.dim('\n= <account>: signed in as the same login as that account, so they share one quota.'));
|
|
395
|
+
// An Expired Login (ADR-0071): the login file is there, but the Host said it no longer works.
|
|
396
|
+
for (const s of shown.filter((x) => x.loginProblem?.kind === 'expired'))
|
|
397
|
+
io.out(c.yellow(`\n${s.ref}: sign-in expired; sign in again with \`sideby login ${s.ref}\``));
|
|
393
398
|
if (hiddenCount)
|
|
394
399
|
io.out(hiddenLine);
|
|
395
400
|
io.out(c.dim('\nsideby run <account> · sideby new <family> <name> · sideby quota · sideby ui'));
|
|
@@ -598,7 +603,10 @@ async function runLogin(rt, ref, io) {
|
|
|
598
603
|
const hint = before && loginBeforeLine(account.ref, before);
|
|
599
604
|
if (hint)
|
|
600
605
|
io.err(c.dim(`sideby: ${hint}`));
|
|
606
|
+
const expired = await rt.loginProblem(account).catch(() => undefined);
|
|
601
607
|
const code = await whileRunning(rt, () => runHost(prepared));
|
|
608
|
+
if (code === 0 && expired)
|
|
609
|
+
await confirmLogin(rt, account, io);
|
|
602
610
|
if (!before)
|
|
603
611
|
return code;
|
|
604
612
|
const after = await loginSnapshot(rt, account).catch(() => undefined);
|
|
@@ -607,6 +615,24 @@ async function runLogin(rt, ref, io) {
|
|
|
607
615
|
io.err((result.ok ? c.green : c.yellow)(`sideby: ${result.line}`));
|
|
608
616
|
return code;
|
|
609
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* After a sign-in that ended with exit 0 for an Account with an Expired Login (ADR-0071 Q9): ask its Quota once, so a
|
|
620
|
+
* good answer clears the state; say whether it did, or that sideby waits for the next session or Quota answer.
|
|
621
|
+
*/
|
|
622
|
+
export async function confirmLogin(rt, account, io) {
|
|
623
|
+
let r;
|
|
624
|
+
try {
|
|
625
|
+
r = await rt.afterLogin(account);
|
|
626
|
+
}
|
|
627
|
+
catch (err) {
|
|
628
|
+
io.err(c.yellow(`sideby: sign-in finished, but sideby could not confirm it (${err?.message ?? String(err)}); ${account.ref} shows as expired until its next session or quota check confirms it`));
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
if (!r.loginProblem)
|
|
632
|
+
io.err(c.green(`sideby: ${account.ref} is signed in again`));
|
|
633
|
+
else
|
|
634
|
+
io.err(c.dim(`sideby: sign-in finished; ${account.ref} shows as expired until its next session or quota check confirms it${r.checked ? '' : ' (quota checks are off)'}`));
|
|
635
|
+
}
|
|
610
636
|
/** A Pick Command (spec §3.13, ADR-0035): start the Account with the most room, else the Main Account, and say which. */
|
|
611
637
|
async function runPick(rt, name, args, io, opts = {}) {
|
|
612
638
|
const { choice, family } = await rt.pickChoice(name);
|
|
@@ -679,6 +705,8 @@ export async function cmdNext(a, io) {
|
|
|
679
705
|
const note = (e) => {
|
|
680
706
|
if (e.sameLoginAs)
|
|
681
707
|
return `same login as ${e.sameLoginAs}, which shares its quota; skipped`;
|
|
708
|
+
if (e.skip?.reason === 'login-expired')
|
|
709
|
+
return `sign-in expired; skipped, sign in with \`${e.skip.command}\``;
|
|
682
710
|
if (e.state === 'ready')
|
|
683
711
|
return `closest to its limit: ${closest(e)}`;
|
|
684
712
|
if (e.state === 'unknown')
|
|
@@ -695,7 +723,11 @@ export async function cmdNext(a, io) {
|
|
|
695
723
|
};
|
|
696
724
|
const mark = { ready: c.green, unknown: c.yellow, api: c.cyan, full: c.red, 'logged-out': c.dim };
|
|
697
725
|
// A full Account with no window used up still has some quota: `low` in the table, and a Last Resort can start it.
|
|
698
|
-
const stateText = (e) =>
|
|
726
|
+
const stateText = (e) => e.skip?.reason === 'login-expired'
|
|
727
|
+
? c.yellow('expired')
|
|
728
|
+
: low(e)
|
|
729
|
+
? c.yellow('low')
|
|
730
|
+
: mark[e.state](e.state === 'logged-out' ? 'signed out' : e.state);
|
|
699
731
|
io.out(table(plan.accounts.map((e) => [
|
|
700
732
|
e.ref === plan.pick ? c.green('→') : ' ',
|
|
701
733
|
c.bold(e.ref),
|
|
@@ -703,7 +735,9 @@ export async function cmdNext(a, io) {
|
|
|
703
735
|
c.dim(note(e)),
|
|
704
736
|
]), ['', 'ACCOUNT', 'STATE', 'NOTE']));
|
|
705
737
|
if (!plan.pick) {
|
|
706
|
-
const out = plan.accounts
|
|
738
|
+
const out = plan.accounts
|
|
739
|
+
.filter((e) => e.state === 'logged-out' || e.skip?.reason === 'login-expired')
|
|
740
|
+
.map((e) => `sideby login ${e.ref}`);
|
|
707
741
|
const apiLeft = !includeApi && plan.accounts.some((e) => e.state === 'api');
|
|
708
742
|
const why = plan.earliestReset
|
|
709
743
|
? `every signed-in ${family} account has used up its quota; ${plan.earliestReset.ref} is back ${resetWhen(plan.earliestReset.at, now.getTime(), 'en')}`
|
|
@@ -2048,13 +2082,20 @@ export async function cmdDesktop(a, io) {
|
|
|
2048
2082
|
io.err(c.cyan(n));
|
|
2049
2083
|
return 0;
|
|
2050
2084
|
}
|
|
2051
|
-
/**
|
|
2085
|
+
/**
|
|
2086
|
+
* `sideby edit <account> [--path] [--with <editor>]`: the Account's Host settings file in the user's editor (spec §3.30,
|
|
2087
|
+
* ADR-0033).
|
|
2088
|
+
*/
|
|
2052
2089
|
export async function cmdEdit(a, io) {
|
|
2053
2090
|
const [ref, ...extra] = a.positionals;
|
|
2091
|
+
const usage = 'usage: sideby edit <account> [--path] [--with <editor>]';
|
|
2054
2092
|
if (!ref || extra.length || a.rest.length)
|
|
2055
|
-
throw new UsageError(
|
|
2093
|
+
throw new UsageError(usage);
|
|
2094
|
+
const editor = a.flags.get('with');
|
|
2095
|
+
if (editor !== undefined && !isEditor(editor))
|
|
2096
|
+
throw new UsageError(`--with takes one of ${EDITORS.join(', ')}; ${usage}`);
|
|
2056
2097
|
const rt = await createRuntime();
|
|
2057
|
-
const r = await editSettings(rt, ref, { open: !a.flags.has('path') });
|
|
2098
|
+
const r = await editSettings(rt, ref, { open: !a.flags.has('path'), ...(editor ? { editor } : {}) });
|
|
2058
2099
|
if (a.flags.has('json')) {
|
|
2059
2100
|
json(io, r);
|
|
2060
2101
|
return 0;
|
|
@@ -2063,7 +2104,7 @@ export async function cmdEdit(a, io) {
|
|
|
2063
2104
|
if (!r.opened)
|
|
2064
2105
|
io.out(r.target ?? r.path);
|
|
2065
2106
|
else
|
|
2066
|
-
io.out(`${c.green('✓')} opened ${c.bold(r.ref)}'s ${r.file} with your default program`);
|
|
2107
|
+
io.out(`${c.green('✓')} opened ${c.bold(r.ref)}'s ${r.file} with ${r.editor && r.editor !== 'system' ? EDITOR_APPS[r.editor].title : 'your default program'}`);
|
|
2067
2108
|
if (r.opened || r.target)
|
|
2068
2109
|
io.out(c.dim(` ${tildify(r.target ?? r.path, home)}${r.target ? ` (linked from ${tildify(r.path, home)})` : ''}`));
|
|
2069
2110
|
if (r.sharedWith.length)
|
|
@@ -2782,7 +2823,8 @@ async function menubarFamilies(rt, o = {}) {
|
|
|
2782
2823
|
.map(async (x) => {
|
|
2783
2824
|
const quota = await rt.quota(x, { fetch: o.fetch });
|
|
2784
2825
|
const sameLogin = await rt.sameLogin(x);
|
|
2785
|
-
const
|
|
2826
|
+
const st = x.kind === 'api' ? null : await rt.status(x);
|
|
2827
|
+
const login = st ? st.login : 'not-needed';
|
|
2786
2828
|
let refresh;
|
|
2787
2829
|
if (asks && x.kind === 'subscription' && login !== 'logged-out') {
|
|
2788
2830
|
const kept = await readQuotaStore(quotaStoreFile(rt.paths.stateDir, x.family, x.name));
|
|
@@ -2803,6 +2845,7 @@ async function menubarFamilies(rt, o = {}) {
|
|
|
2803
2845
|
name: x.name,
|
|
2804
2846
|
kind: x.kind,
|
|
2805
2847
|
login,
|
|
2848
|
+
...(st?.loginProblem?.kind === 'expired' ? { loginExpired: true } : {}),
|
|
2806
2849
|
quota,
|
|
2807
2850
|
sameLogin,
|
|
2808
2851
|
...(refresh ? { refresh } : {}),
|
|
@@ -88,6 +88,16 @@ const Account = Type.Object({
|
|
|
88
88
|
kind: Kind,
|
|
89
89
|
secretFile: Type.Optional(Str),
|
|
90
90
|
});
|
|
91
|
+
const LoginProblemSchema = Type.Object({
|
|
92
|
+
kind: Type.Literal('expired'),
|
|
93
|
+
since: Type.Optional(Str),
|
|
94
|
+
message: Str,
|
|
95
|
+
signedInAt: Type.Optional(Type.String({
|
|
96
|
+
description: 'When a sign-in sideby started finished after `since`, with nothing confirming it yet: the Panel says the sign-in finished and waits for confirmation.',
|
|
97
|
+
})),
|
|
98
|
+
}, {
|
|
99
|
+
description: "An Expired Login (ADR-0071): the account is signed in (`login` stays `logged-in`) but its host has reported that the login expired, with no later successful turn or quota answer. `since` is when the host reported it, `message` is sideby's own sentence. Absent when the login is not known to be expired; only Claude Code accounts are checked for now.",
|
|
100
|
+
});
|
|
91
101
|
const AccountStatus = Type.Intersect([
|
|
92
102
|
Account,
|
|
93
103
|
Type.Object({
|
|
@@ -99,6 +109,7 @@ const AccountStatus = Type.Intersect([
|
|
|
99
109
|
Type.Literal('unknown'),
|
|
100
110
|
Type.Literal('not-needed'),
|
|
101
111
|
]),
|
|
112
|
+
loginProblem: Type.Optional(LoginProblemSchema),
|
|
102
113
|
model: Type.Optional(Str),
|
|
103
114
|
identity: Type.Optional(Type.Object({ email: Type.Optional(Str), org: Type.Optional(Str) }, {
|
|
104
115
|
description: "Who the account is signed in as, from the host's login file: identity fields only, never a token (ADR-0003).",
|
|
@@ -739,6 +750,12 @@ export const OUTPUT_SCHEMAS = {
|
|
|
739
750
|
sameLoginAs: Type.Optional(Type.String({
|
|
740
751
|
description: 'The current account (`from`), when this one is signed in as the same login: it shares that quota and is never picked.',
|
|
741
752
|
})),
|
|
753
|
+
skip: Type.Optional(Type.Object({
|
|
754
|
+
reason: Type.Literal('login-expired'),
|
|
755
|
+
command: Type.String({ description: 'The command that fixes it: `sideby login <account>`.' }),
|
|
756
|
+
}, {
|
|
757
|
+
description: 'Set when the account is never picked for a reason its state does not show: `login-expired`, its sign-in expired (ADR-0071).',
|
|
758
|
+
})),
|
|
742
759
|
}), { description: 'Every account of the family, best first.' }),
|
|
743
760
|
hasQuota: Type.Boolean({
|
|
744
761
|
description: 'False when no account has quota data: the pick is then a guess, and `sideby next` does not start it (exit 1).',
|
|
@@ -1207,6 +1224,9 @@ export const OUTPUT_SCHEMAS = {
|
|
|
1207
1224
|
}),
|
|
1208
1225
|
opened: Type.Boolean({ description: 'False with --path, which only says where the file is.' }),
|
|
1209
1226
|
command: Type.Optional(Type.Array(Str, { description: 'The program and arguments that opened the file.' })),
|
|
1227
|
+
editor: Type.Optional(Type.String({
|
|
1228
|
+
description: 'What opened it: `system` (the default program) or the editor from config `editor` or `--with`.',
|
|
1229
|
+
})),
|
|
1210
1230
|
}, { title: 'sideby edit --json' }),
|
|
1211
1231
|
'desktop-remove': Type.Object({
|
|
1212
1232
|
schemaVersion: Version,
|
package/dist/src/cli/main.js
CHANGED
|
@@ -213,11 +213,16 @@ Examples:
|
|
|
213
213
|
sideby messages inbound accept --yes
|
|
214
214
|
Exit: 0 listed or changed; 1 a file could not be changed or nothing was changed; 10 a change was shown and waits for --yes; 2 malformed
|
|
215
215
|
command line.`,
|
|
216
|
-
edit: `sideby edit <account> [--path] [--json]
|
|
216
|
+
edit: `sideby edit <account> [--path] [--with <editor>] [--json]
|
|
217
217
|
|
|
218
218
|
Open the account's own settings file in your editor: settings.json for claude and pi accounts, config.toml for codex
|
|
219
|
-
and grok accounts.
|
|
220
|
-
program on WSL, xdg-open on other Linux).
|
|
219
|
+
and grok accounts. By default it opens with the system's default program (the default text editor on macOS, the
|
|
220
|
+
Windows default program on WSL, xdg-open on other Linux). Config editor (cursor, vscode, windsurf or zed; system is
|
|
221
|
+
the default) opens it in that editor instead, through the editor's own command line; --with <editor> does so once.
|
|
222
|
+
--path only prints where the file is.
|
|
223
|
+
|
|
224
|
+
If your default text editor shows a window of its own but not the file (current Cursor shows its Agents window),
|
|
225
|
+
choose the editor: sideby config set editor cursor.
|
|
221
226
|
|
|
222
227
|
sideby reads nothing of the file and never changes it; your editor does. When the file is a link (accounts that
|
|
223
228
|
share their settings with the main account), it says where the real file is and which accounts the change affects.
|
|
@@ -225,9 +230,10 @@ A missing file is not created: the message says how to get one.
|
|
|
225
230
|
|
|
226
231
|
Examples:
|
|
227
232
|
sideby edit claude:work
|
|
233
|
+
sideby edit claude:work --with vscode
|
|
228
234
|
sideby edit cc008 --path
|
|
229
235
|
Exit: 0 opened (or printed with --path); 1 no settings file, the family names none, or it could not be opened; 2
|
|
230
|
-
malformed command line.`,
|
|
236
|
+
malformed command line or an unknown editor.`,
|
|
231
237
|
autostart: `sideby autostart [on|off] [--yes] [--json]
|
|
232
238
|
|
|
233
239
|
Start the panel in the background when you log in, so it already shows fresh quota when you open it. It never
|
|
@@ -490,7 +496,7 @@ const COMMANDS = {
|
|
|
490
496
|
},
|
|
491
497
|
send: { flags: ['json'], valued: ['image', 'lang'] },
|
|
492
498
|
messages: { flags: ['json', 'yes'], valued: ['to', 'limit'] },
|
|
493
|
-
edit: { flags: ['json', 'path'] },
|
|
499
|
+
edit: { flags: ['json', 'path'], valued: ['with'] },
|
|
494
500
|
browser: { flags: ['json', 'enable', 'disable', 'yes', 'auto'], valued: ['profile'] },
|
|
495
501
|
'shell-init': { flags: ['write', 'yes', 'undo', 'json'] },
|
|
496
502
|
plugins: { flags: ['json'] },
|
|
@@ -90,7 +90,7 @@ export const CLI_COMMANDS = [
|
|
|
90
90
|
{
|
|
91
91
|
id: 'edit',
|
|
92
92
|
group: 'accounts',
|
|
93
|
-
usage: 'sideby edit <account> [--path]',
|
|
93
|
+
usage: 'sideby edit <account> [--path] [--with <editor>]',
|
|
94
94
|
help: "open the account's own settings file (settings.json, config.toml) in your editor",
|
|
95
95
|
summary: {
|
|
96
96
|
en: "Open an account's own settings file in your editor",
|
|
@@ -45,6 +45,12 @@ export declare const UnattendedSlotSchema: Type.TObject<{
|
|
|
45
45
|
start: Type.TString;
|
|
46
46
|
end: Type.TString;
|
|
47
47
|
}>;
|
|
48
|
+
/**
|
|
49
|
+
* What `sideby edit` and the Panel's "Open settings.json" open the file with (spec §3.30, ADR-0033): `system` is the
|
|
50
|
+
* system's default program; the others are editors sideby starts through their own command line.
|
|
51
|
+
*/
|
|
52
|
+
export declare const EDITORS: readonly ['system', 'cursor', 'vscode', 'windsurf', 'zed'];
|
|
53
|
+
export type EditorChoice = (typeof EDITORS)[number];
|
|
48
54
|
export declare const ConfigSchema: Type.TObject<{
|
|
49
55
|
$schema: Type.TOptional<Type.TString>;
|
|
50
56
|
panel: Type.TOptional<Type.TObject<{
|
|
@@ -59,6 +65,7 @@ export declare const ConfigSchema: Type.TObject<{
|
|
|
59
65
|
preferred: Type.TOptional<Type.TString>;
|
|
60
66
|
custom: Type.TOptional<Type.TString>;
|
|
61
67
|
}>>;
|
|
68
|
+
editor: Type.TOptional<Type.TString>;
|
|
62
69
|
ask: Type.TOptional<Type.TObject<{
|
|
63
70
|
account: Type.TOptional<Type.TString>;
|
|
64
71
|
permissions: Type.TOptional<Type.TString>;
|
package/dist/src/core/config.js
CHANGED
|
@@ -131,6 +131,11 @@ export const UnattendedSlotSchema = Type.Object({
|
|
|
131
131
|
description: 'When it ends, `HH:MM`. An end before the start is the next day; an end equal to the start lasts the whole day.',
|
|
132
132
|
}),
|
|
133
133
|
}, { additionalProperties: false });
|
|
134
|
+
/**
|
|
135
|
+
* What `sideby edit` and the Panel's "Open settings.json" open the file with (spec §3.30, ADR-0033): `system` is the
|
|
136
|
+
* system's default program; the others are editors sideby starts through their own command line.
|
|
137
|
+
*/
|
|
138
|
+
export const EDITORS = ['system', 'cursor', 'vscode', 'windsurf', 'zed'];
|
|
134
139
|
export const ConfigSchema = Type.Object({
|
|
135
140
|
$schema: Type.Optional(Type.String()),
|
|
136
141
|
panel: Type.Optional(Type.Object({
|
|
@@ -172,6 +177,10 @@ export const ConfigSchema = Type.Object({
|
|
|
172
177
|
description: 'Your own launch command for `preferred: custom`, with `{cwd}` and `{cmd}` placeholders.',
|
|
173
178
|
})),
|
|
174
179
|
}, { additionalProperties: false, description: 'The terminal AI Tasks open in (spec §3.28).' })),
|
|
180
|
+
editor: Type.Optional(Type.String({
|
|
181
|
+
enum: [...EDITORS],
|
|
182
|
+
description: 'The editor `sideby edit` and the Panel open an account’s settings file with: `system` (the default) uses the system’s default program; `cursor`, `vscode`, `windsurf` and `zed` start that editor.',
|
|
183
|
+
})),
|
|
175
184
|
ask: Type.Optional(Type.Object({
|
|
176
185
|
account: Type.Optional(Type.String({
|
|
177
186
|
description: 'The account AI Tasks start (`<family>:<name>` or a short command); sideby picks one without it.',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HookBus } from '../plugins/bus.ts';
|
|
2
|
-
import type { Account, CheckResult, FamilyDef, Finding } from '../types.ts';
|
|
2
|
+
import type { Account, CheckResult, FamilyDef, Finding, LoginProblem } from '../types.ts';
|
|
3
3
|
export interface AccountReport {
|
|
4
4
|
ref: string;
|
|
5
5
|
family: string;
|
|
@@ -40,7 +40,11 @@ export interface DoctorInput {
|
|
|
40
40
|
* counted in `shared`; a result's `fix` runs with the others under `--fix` and must stay within what it checked.
|
|
41
41
|
*/
|
|
42
42
|
extraChecks?: (account: Account) => Promise<CheckResult[]>;
|
|
43
|
+
/** An Account's Expired Login (ADR-0071), for every Account, the Main Account too; a throw counts as none. */
|
|
44
|
+
loginProblem?: (account: Account) => Promise<LoginProblem | undefined>;
|
|
43
45
|
}
|
|
46
|
+
/** The warning for an Expired Login (ADR-0071): only a new sign-in fixes it, so `--fix` never touches it. */
|
|
47
|
+
export declare function loginExpiredFinding(account: Account, problem: LoginProblem): Finding;
|
|
44
48
|
export declare function runDoctor(input: DoctorInput): Promise<DoctorReport>;
|
|
45
49
|
/** Applies every fixable Finding once, in order; one failing fix never stops the others. */
|
|
46
50
|
export declare function applyFixes(report: DoctorReport): Promise<FixOutcome[]>;
|
package/dist/src/core/doctor.js
CHANGED
|
@@ -4,6 +4,19 @@ import { lstatOrNull, permBits, statOrNull } from './fs-safe.js';
|
|
|
4
4
|
import { inspectSecretFile } from './secret-file.js';
|
|
5
5
|
import { checkItem, credentialModeFinding, itemPaths } from './share-modes.js';
|
|
6
6
|
import { checkInstalledSkills } from './skill-check.js';
|
|
7
|
+
/** The warning for an Expired Login (ADR-0071): only a new sign-in fixes it, so `--fix` never touches it. */
|
|
8
|
+
export function loginExpiredFinding(account, problem) {
|
|
9
|
+
return {
|
|
10
|
+
level: 'warn',
|
|
11
|
+
account: account.ref,
|
|
12
|
+
item: 'login',
|
|
13
|
+
code: 'login.expired',
|
|
14
|
+
message: `${account.ref}: its sign-in has expired${problem.since ? ` (reported ${problem.since})` : ''}`,
|
|
15
|
+
hint: `sign in again with \`sideby login ${account.ref}\``,
|
|
16
|
+
source: 'core',
|
|
17
|
+
fixable: false,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
7
20
|
const BACKUP_ENTRY = /(\.bak|backup|\.tmp)/i;
|
|
8
21
|
const BACKUP_DIRS = new Set(['backups', 'tmp', '.tmp']);
|
|
9
22
|
async function countBackups(dir) {
|
|
@@ -83,6 +96,9 @@ async function checkAccount(input, family, account) {
|
|
|
83
96
|
findings.push(toFinding(credentialModeFinding(item.mainPath ?? item.path, mainPath, permBits(st)), account.ref, 'core'));
|
|
84
97
|
}
|
|
85
98
|
}
|
|
99
|
+
const expired = await input.loginProblem?.(account).catch(() => undefined);
|
|
100
|
+
if (expired?.kind === 'expired')
|
|
101
|
+
findings.push(loginExpiredFinding(account, expired));
|
|
86
102
|
if (account.secretFile) {
|
|
87
103
|
const state = await inspectSecretFile(account.secretFile);
|
|
88
104
|
if (state.kind === 'not-file')
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Runtime } from '../runtime.ts';
|
|
2
2
|
import type { FamilyDef } from '../types.ts';
|
|
3
|
+
import { type EditorChoice } from './config.ts';
|
|
3
4
|
export interface EditSettingsResult {
|
|
4
5
|
schemaVersion: 1;
|
|
5
6
|
ref: string;
|
|
@@ -16,12 +17,37 @@ export interface EditSettingsResult {
|
|
|
16
17
|
opened: boolean;
|
|
17
18
|
/** The program and arguments that opened it. */
|
|
18
19
|
command?: string[];
|
|
20
|
+
/** What opened it: `system` (the default program) or the editor from config `editor` or `--with`. */
|
|
21
|
+
editor?: EditorChoice;
|
|
19
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* How sideby starts each editor (ADR-0033 amendment): on macOS the command line inside its app bundle, then the
|
|
25
|
+
* command on PATH, then `open -a <app>`; elsewhere the command on PATH, then the system's default program.
|
|
26
|
+
*/
|
|
27
|
+
export declare const EDITOR_APPS: Record<Exclude<EditorChoice, 'system'>, {
|
|
28
|
+
title: string;
|
|
29
|
+
app: string;
|
|
30
|
+
command: string;
|
|
31
|
+
bundled: string;
|
|
32
|
+
/** The command line's arguments; without it just the file. */
|
|
33
|
+
args?: (file: string) => string[];
|
|
34
|
+
}>;
|
|
35
|
+
export declare const isEditor: (v: unknown) => v is EditorChoice;
|
|
20
36
|
/** The Family's settings file when it names a relative path that stays inside the account directory. */
|
|
21
37
|
export declare function hostSettingsFile(def: Pick<FamilyDef, 'settingsFile'> | undefined): string | undefined;
|
|
22
|
-
export declare function editSettings(rt: Runtime, ref: string,
|
|
38
|
+
export declare function editSettings(rt: Runtime, ref: string,
|
|
39
|
+
/** `editor` is a one-off choice (`--with`); without it config `editor`, else `system`. */
|
|
40
|
+
opts?: {
|
|
23
41
|
open?: boolean;
|
|
42
|
+
editor?: EditorChoice;
|
|
24
43
|
}): Promise<EditSettingsResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Opens `file` with `editor` (ADR-0033 amendment); `system` is `openWithDefault`. Each way is tried in turn until one
|
|
46
|
+
* exits 0: on macOS the editor's own command line in its app bundle (in `DesktopDeps.appDirs`), then the command on
|
|
47
|
+
* PATH, then `open -a <app> <file>`; elsewhere the command on PATH, then the system's default program. Returns the
|
|
48
|
+
* command that opened it, or throws what to do instead.
|
|
49
|
+
*/
|
|
50
|
+
export declare function openWithEditor(rt: Runtime, file: string, editor: EditorChoice): Promise<string[]>;
|
|
25
51
|
/**
|
|
26
52
|
* Opens `file` with the system's default program (on macOS its default text editor, unless `text` is false);
|
|
27
53
|
* returns the command, or throws what to do instead.
|
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
// Opens an Account's Host settings file in the user's editor (spec §3.30, ADR-0033). sideby reads none of the file:
|
|
2
2
|
// it checks that the file is there and, for a link, where it really is and which Accounts share it. Every program
|
|
3
3
|
// it runs goes through `DesktopDeps.exec`, so tests start nothing.
|
|
4
|
-
import { realpath } from 'node:fs/promises';
|
|
5
|
-
import { isAbsolute, join } from 'node:path';
|
|
4
|
+
import { access, constants, realpath } from 'node:fs/promises';
|
|
5
|
+
import { dirname, isAbsolute, join } from 'node:path';
|
|
6
|
+
import { EDITORS } from './config.js';
|
|
6
7
|
import { depsFor } from './desktop-app.js';
|
|
7
8
|
import { UserError } from './errors.js';
|
|
8
9
|
import { lstatOrNull } from './fs-safe.js';
|
|
10
|
+
import { which } from './launch.js';
|
|
11
|
+
/**
|
|
12
|
+
* How sideby starts each editor (ADR-0033 amendment): on macOS the command line inside its app bundle, then the
|
|
13
|
+
* command on PATH, then `open -a <app>`; elsewhere the command on PATH, then the system's default program.
|
|
14
|
+
*/
|
|
15
|
+
export const EDITOR_APPS = {
|
|
16
|
+
// Cursor 3.x opens a lone file in its Agent Window and shows nothing of it; `--classic` with the file's folder
|
|
17
|
+
// opens a classic editor window on that file.
|
|
18
|
+
cursor: {
|
|
19
|
+
title: 'Cursor',
|
|
20
|
+
app: 'Cursor',
|
|
21
|
+
command: 'cursor',
|
|
22
|
+
bundled: 'Contents/Resources/app/bin/cursor',
|
|
23
|
+
args: (file) => ['--classic', dirname(file), file],
|
|
24
|
+
},
|
|
25
|
+
vscode: {
|
|
26
|
+
title: 'VS Code',
|
|
27
|
+
app: 'Visual Studio Code',
|
|
28
|
+
command: 'code',
|
|
29
|
+
bundled: 'Contents/Resources/app/bin/code',
|
|
30
|
+
},
|
|
31
|
+
windsurf: {
|
|
32
|
+
title: 'Windsurf',
|
|
33
|
+
app: 'Windsurf',
|
|
34
|
+
command: 'windsurf',
|
|
35
|
+
bundled: 'Contents/Resources/app/bin/windsurf',
|
|
36
|
+
},
|
|
37
|
+
zed: { title: 'Zed', app: 'Zed', command: 'zed', bundled: 'Contents/MacOS/cli' },
|
|
38
|
+
};
|
|
39
|
+
export const isEditor = (v) => typeof v === 'string' && EDITORS.includes(v);
|
|
9
40
|
/** The Family's settings file when it names a relative path that stays inside the account directory. */
|
|
10
41
|
export function hostSettingsFile(def) {
|
|
11
42
|
const f = def?.settingsFile;
|
|
@@ -21,7 +52,11 @@ async function realOrNull(path) {
|
|
|
21
52
|
return null;
|
|
22
53
|
}
|
|
23
54
|
}
|
|
24
|
-
export async function editSettings(rt, ref,
|
|
55
|
+
export async function editSettings(rt, ref,
|
|
56
|
+
/** `editor` is a one-off choice (`--with`); without it config `editor`, else `system`. */
|
|
57
|
+
opts = {}) {
|
|
58
|
+
if (opts.editor !== undefined && !isEditor(opts.editor))
|
|
59
|
+
throw new UserError(`the editor must be one of ${EDITORS.join(', ')}`, { code: 'bad-editor' });
|
|
25
60
|
const account = await rt.resolve(ref);
|
|
26
61
|
const def = rt.families.get(account.family);
|
|
27
62
|
const file = hostSettingsFile(def);
|
|
@@ -53,7 +88,46 @@ export async function editSettings(rt, ref, opts = {}) {
|
|
|
53
88
|
};
|
|
54
89
|
if (opts.open === false)
|
|
55
90
|
return { ...base, opened: false };
|
|
56
|
-
|
|
91
|
+
const configured = rt.config.editor;
|
|
92
|
+
const editor = opts.editor ?? (isEditor(configured) ? configured : 'system');
|
|
93
|
+
const command = await openWithEditor(rt, real, editor);
|
|
94
|
+
// On Linux and WSL an editor that is not on PATH falls back to the default program: say so.
|
|
95
|
+
const fellBack = command[0] === 'xdg-open' || command[0]?.endsWith('/cmd.exe');
|
|
96
|
+
return { ...base, opened: true, command, editor: fellBack ? 'system' : editor };
|
|
97
|
+
}
|
|
98
|
+
const executable = (path) => access(path, constants.X_OK).then(() => true, () => false);
|
|
99
|
+
/**
|
|
100
|
+
* Opens `file` with `editor` (ADR-0033 amendment); `system` is `openWithDefault`. Each way is tried in turn until one
|
|
101
|
+
* exits 0: on macOS the editor's own command line in its app bundle (in `DesktopDeps.appDirs`), then the command on
|
|
102
|
+
* PATH, then `open -a <app> <file>`; elsewhere the command on PATH, then the system's default program. Returns the
|
|
103
|
+
* command that opened it, or throws what to do instead.
|
|
104
|
+
*/
|
|
105
|
+
export async function openWithEditor(rt, file, editor) {
|
|
106
|
+
if (editor === 'system')
|
|
107
|
+
return openWithDefault(rt, file);
|
|
108
|
+
const e = EDITOR_APPS[editor];
|
|
109
|
+
const deps = depsFor(rt);
|
|
110
|
+
const tries = [];
|
|
111
|
+
if (deps.platform === 'darwin')
|
|
112
|
+
for (const dir of deps.appDirs) {
|
|
113
|
+
const cli = join(dir, `${e.app}.app`, e.bundled);
|
|
114
|
+
if (await executable(cli))
|
|
115
|
+
tries.push(cli);
|
|
116
|
+
}
|
|
117
|
+
const onPath = await which(e.command, rt.env);
|
|
118
|
+
if (onPath && !tries.includes(onPath))
|
|
119
|
+
tries.push(onPath);
|
|
120
|
+
const cliArgs = e.args ? e.args(file) : [file];
|
|
121
|
+
for (const cmd of tries)
|
|
122
|
+
if ((await deps.exec(cmd, cliArgs)).code === 0)
|
|
123
|
+
return [cmd, ...cliArgs];
|
|
124
|
+
if (deps.platform === 'darwin') {
|
|
125
|
+
const args = ['-a', e.app, file];
|
|
126
|
+
if ((await deps.exec('/usr/bin/open', args)).code === 0)
|
|
127
|
+
return ['/usr/bin/open', ...args];
|
|
128
|
+
throw new UserError(`${e.title} could not open the file; install ${e.title}, choose another editor (\`sideby config set editor system\`), or open ${file} yourself`, { code: 'open-failed' });
|
|
129
|
+
}
|
|
130
|
+
return openWithDefault(rt, file);
|
|
57
131
|
}
|
|
58
132
|
/**
|
|
59
133
|
* Opens `file` with the system's default program (on macOS its default text editor, unless `text` is false);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Account, AccountIdentity, LoginState, QuotaResult } from '../types.ts';
|
|
1
|
+
import type { Account, AccountIdentity, LoginProblem, LoginState, QuotaResult } from '../types.ts';
|
|
2
2
|
import type { HandoffSettings } from './config.ts';
|
|
3
3
|
export interface SelectCandidate {
|
|
4
4
|
ref: string;
|
|
@@ -7,6 +7,8 @@ export interface SelectCandidate {
|
|
|
7
7
|
isMain: boolean;
|
|
8
8
|
kind: Account['kind'];
|
|
9
9
|
login: LoginState | 'not-needed';
|
|
10
|
+
/** Its Expired Login (ADR-0071): such an Account never takes over. */
|
|
11
|
+
loginProblem?: LoginProblem;
|
|
10
12
|
quota: QuotaResult;
|
|
11
13
|
identity?: AccountIdentity;
|
|
12
14
|
/** The other Accounts of its Same Login (spec §3.21); they share its Quota. */
|
|
@@ -103,11 +103,19 @@ export function selectNext(input) {
|
|
|
103
103
|
const skipped = list
|
|
104
104
|
.filter((c) => sameLogin.has(c.ref))
|
|
105
105
|
.map((c) => ({ ref: c.ref, reason: `same login as ${origin.ref}, so it shares the same quota` }));
|
|
106
|
+
// An Expired Login cannot start a session, so it never takes over (ADR-0071).
|
|
107
|
+
const expired = (c) => c.loginProblem?.kind === 'expired';
|
|
108
|
+
for (const c of list)
|
|
109
|
+
if (expired(c) && !sameLogin.has(c.ref) && c.ref !== origin.ref)
|
|
110
|
+
skipped.push({
|
|
111
|
+
ref: c.ref,
|
|
112
|
+
reason: `its sign-in has expired; run \`sideby login ${c.ref}\` to use it again`,
|
|
113
|
+
});
|
|
106
114
|
// A used Account with no recorded window comes back only on Quota data that shows it ready: not on a guess
|
|
107
115
|
// (`unknown`, an API account). It is still counted while full, so its reset can be named.
|
|
108
116
|
const unsure = (c) => used.ifReady.has(c.ref) && !['ready', 'full', 'logged-out'].includes(stateOf(c, s, now).state);
|
|
109
117
|
// Could take over if the settings allowed it: another login, its Host installed and able to receive.
|
|
110
|
-
const couldTake = (c) => !sameLogin.has(c.ref) && !used.out.has(c.ref) && !unsure(c) && c.installed && c.receive;
|
|
118
|
+
const couldTake = (c) => !sameLogin.has(c.ref) && !expired(c) && !used.out.has(c.ref) && !unsure(c) && c.installed && c.receive;
|
|
111
119
|
const allows = (c) =>
|
|
112
120
|
// An API account pays per request, so it gets past no vendor's limit: sameFamily does not apply to it, but it
|
|
113
121
|
// takes over only when the user allowed paying for it (`api`, ADR-0046).
|
|
@@ -159,6 +167,8 @@ function refusal(origin, target, s, allowed) {
|
|
|
159
167
|
return 'it is the account this session runs in';
|
|
160
168
|
if (origin.sameLogin?.includes(target.ref))
|
|
161
169
|
return `it is the same login as ${origin.ref}, so it shares the same quota`;
|
|
170
|
+
if (target.loginProblem?.kind === 'expired')
|
|
171
|
+
return `its sign-in has expired; run \`sideby login ${target.ref}\` first`;
|
|
162
172
|
if (!target.installed)
|
|
163
173
|
return 'its host is not installed';
|
|
164
174
|
if (!target.receive)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Account, LoginState, QuotaResult } from '../types.ts';
|
|
1
|
+
import type { Account, LoginProblem, LoginState, QuotaResult } from '../types.ts';
|
|
2
2
|
import { type TakeoverLimits } from './quota-levels.ts';
|
|
3
3
|
export type HandoffState = 'ready' | 'unknown' | 'api' | 'full' | 'logged-out';
|
|
4
4
|
export interface HandoffCandidate {
|
|
@@ -7,10 +7,18 @@ export interface HandoffCandidate {
|
|
|
7
7
|
isMain: boolean;
|
|
8
8
|
kind: Account['kind'];
|
|
9
9
|
login: LoginState | 'not-needed';
|
|
10
|
+
/** Its Expired Login (ADR-0071): such an Account is never picked. */
|
|
11
|
+
loginProblem?: LoginProblem;
|
|
10
12
|
quota: QuotaResult;
|
|
11
13
|
/** The other Accounts of its Same Login (spec §3.21). */
|
|
12
14
|
sameLogin?: readonly string[];
|
|
13
15
|
}
|
|
16
|
+
/** Why an Account that could otherwise be picked is left out, and the command that fixes it (ADR-0071). */
|
|
17
|
+
export interface HandoffSkip {
|
|
18
|
+
reason: 'login-expired';
|
|
19
|
+
/** The command that signs it in again: `sideby login <ref>`. */
|
|
20
|
+
command: string;
|
|
21
|
+
}
|
|
14
22
|
export interface HandoffEntry {
|
|
15
23
|
ref: string;
|
|
16
24
|
kind: Account['kind'];
|
|
@@ -43,6 +51,8 @@ export interface HandoffEntry {
|
|
|
43
51
|
* never picked.
|
|
44
52
|
*/
|
|
45
53
|
sameLoginAs?: string;
|
|
54
|
+
/** Set when the Account is never picked for a reason its state does not show: its login expired (ADR-0071). */
|
|
55
|
+
skip?: HandoffSkip;
|
|
46
56
|
}
|
|
47
57
|
export interface HandoffPlan {
|
|
48
58
|
family: string;
|
|
@@ -73,6 +83,8 @@ export interface HandoffPlan {
|
|
|
73
83
|
at: string;
|
|
74
84
|
};
|
|
75
85
|
}
|
|
86
|
+
/** An entry that can never be picked whatever its state: the current Account's Same Login, or an Expired Login. */
|
|
87
|
+
export declare const blocked: (e: HandoffEntry) => boolean;
|
|
76
88
|
export declare function planHandoff(family: string, candidates: readonly HandoffCandidate[], now: Date,
|
|
77
89
|
/**
|
|
78
90
|
* `limits`: the Takeover Limits, at or above which a window makes an Account full (default 85 for Short Windows and
|