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
|
@@ -21,6 +21,7 @@ export interface HandoffSettings {
|
|
|
21
21
|
sameFamily: boolean;
|
|
22
22
|
prepareAt: number;
|
|
23
23
|
threshold: number;
|
|
24
|
+
adaptive: boolean;
|
|
24
25
|
waitIfResetWithinMinutes: number;
|
|
25
26
|
countdownSeconds: number;
|
|
26
27
|
crossOrganization: string[];
|
|
@@ -35,6 +36,9 @@ export declare const ConfigSchema: Type.TObject<{
|
|
|
35
36
|
theme: Type.TOptional<Type.TString>;
|
|
36
37
|
language: Type.TOptional<Type.TString>;
|
|
37
38
|
}>>;
|
|
39
|
+
menubar: Type.TOptional<Type.TObject<{
|
|
40
|
+
hotkey: Type.TOptional<Type.TString>;
|
|
41
|
+
}>>;
|
|
38
42
|
terminal: Type.TOptional<Type.TObject<{
|
|
39
43
|
preferred: Type.TOptional<Type.TString>;
|
|
40
44
|
custom: Type.TOptional<Type.TString>;
|
|
@@ -49,6 +53,7 @@ export declare const ConfigSchema: Type.TObject<{
|
|
|
49
53
|
account: Type.TString;
|
|
50
54
|
args: Type.TOptional<Type.TArray<Type.TString>>;
|
|
51
55
|
}>]>>>;
|
|
56
|
+
pickCommands: Type.TOptional<Type.TRecord<"^.*$", Type.TString>>;
|
|
52
57
|
ignore: Type.TOptional<Type.TArray<Type.TString>>;
|
|
53
58
|
pluginDirs: Type.TOptional<Type.TArray<Type.TString>>;
|
|
54
59
|
plugins: Type.TOptional<Type.TRecord<"^.*$", Type.TRecord<"^.*$", Type.TUnknown>>>;
|
|
@@ -65,6 +70,7 @@ export declare const ConfigSchema: Type.TObject<{
|
|
|
65
70
|
sameFamily: Type.TOptional<Type.TBoolean>;
|
|
66
71
|
prepareAt: Type.TOptional<Type.TInteger>;
|
|
67
72
|
threshold: Type.TOptional<Type.TInteger>;
|
|
73
|
+
adaptive: Type.TOptional<Type.TBoolean>;
|
|
68
74
|
waitIfResetWithinMinutes: Type.TOptional<Type.TInteger>;
|
|
69
75
|
countdownSeconds: Type.TOptional<Type.TInteger>;
|
|
70
76
|
crossOrganization: Type.TOptional<Type.TArray<Type.TString>>;
|
|
@@ -183,6 +189,19 @@ export declare function removeConfigAlias(file: string, alias: string): Promise<
|
|
|
183
189
|
status: 'removed' | 'absent';
|
|
184
190
|
aliases: Record<string, AliasValue>;
|
|
185
191
|
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Adds `name → family` to the config file's `pickCommands` (see `editConfigKey` for how the file is written). Refuses
|
|
194
|
+
* an invalid name, one that is an Alias, or one that already picks in another Family.
|
|
195
|
+
*/
|
|
196
|
+
export declare function addConfigPickCommand(file: string, name: string, family: string): Promise<{
|
|
197
|
+
status: 'added' | 'exists';
|
|
198
|
+
pickCommands: Record<string, string>;
|
|
199
|
+
}>;
|
|
200
|
+
/** Removes `name` from `pickCommands`; `absent` when it was not there. An emptied key goes away with it. */
|
|
201
|
+
export declare function removeConfigPickCommand(file: string, name: string): Promise<{
|
|
202
|
+
status: 'removed' | 'absent';
|
|
203
|
+
pickCommands: Record<string, string>;
|
|
204
|
+
}>;
|
|
186
205
|
export declare function editConfigTerminal(file: string, patch: {
|
|
187
206
|
preferred?: string;
|
|
188
207
|
custom?: string;
|
package/dist/src/core/config.js
CHANGED
|
@@ -55,7 +55,10 @@ const HandoffSchema = Type.Object({
|
|
|
55
55
|
description: 'Also hand off to an account of the same family (cc001 → cc002). The kind vendors are most likely to act on. Off by default.',
|
|
56
56
|
})),
|
|
57
57
|
prepareAt: Percent('Quota Pressure at which the session starts keeping a Handoff Brief (default 80).'),
|
|
58
|
-
threshold: Percent('Quota Pressure at which the Handoff begins (default 95).'),
|
|
58
|
+
threshold: Percent('Quota Pressure at which the Handoff begins (default 95). With `adaptive`, a window uses it until the run has measured a turn of it.'),
|
|
59
|
+
adaptive: Type.Optional(Type.Boolean({
|
|
60
|
+
description: 'Hand over by each window’s own pace: when it has less room left than 1.5 times its largest recent turn, between `prepareAt` and 99 (default true; ADR-0032). False uses `threshold` for every window.',
|
|
61
|
+
})),
|
|
59
62
|
waitIfResetWithinMinutes: Type.Optional(Type.Integer({
|
|
60
63
|
minimum: 0,
|
|
61
64
|
description: 'Stay and wait when the full window resets within this many minutes (default 30; 0 never waits).',
|
|
@@ -88,9 +91,25 @@ export const ConfigSchema = Type.Object({
|
|
|
88
91
|
description: "Panel language: the browser's (default), English, or Chinese.",
|
|
89
92
|
})),
|
|
90
93
|
}, { additionalProperties: false, description: 'How the Panel looks (spec §3.29).' })),
|
|
94
|
+
menubar: Type.Optional(Type.Object({
|
|
95
|
+
hotkey: Type.Optional(Type.String({
|
|
96
|
+
pattern: '^(off|((ctrl|opt|cmd|shift)\\+)+[a-z0-9])$',
|
|
97
|
+
description: 'The shortcut that opens the menu bar item from anywhere, such as `opt+cmd+s` (default), or `off`.',
|
|
98
|
+
})),
|
|
99
|
+
}, { additionalProperties: false, description: 'The Menu Bar Item on macOS (spec §3.31).' })),
|
|
91
100
|
terminal: Type.Optional(Type.Object({
|
|
92
101
|
preferred: Type.Optional(Type.String({
|
|
93
|
-
enum: [
|
|
102
|
+
enum: [
|
|
103
|
+
'terminal',
|
|
104
|
+
'iterm2',
|
|
105
|
+
'ghostty',
|
|
106
|
+
'orca',
|
|
107
|
+
'wezterm',
|
|
108
|
+
'kitty',
|
|
109
|
+
'alacritty',
|
|
110
|
+
'windows-terminal',
|
|
111
|
+
'custom',
|
|
112
|
+
],
|
|
94
113
|
description: 'The terminal sideby opens for AI Tasks; without it sideby picks the one you use.',
|
|
95
114
|
})),
|
|
96
115
|
custom: Type.Optional(Type.String({
|
|
@@ -110,6 +129,9 @@ export const ConfigSchema = Type.Object({
|
|
|
110
129
|
aliases: Type.Optional(Type.Record(Type.String({ pattern: '^[A-Za-z_][A-Za-z0-9_-]*$' }), AliasSchema, {
|
|
111
130
|
description: 'Short shell function names created by `sideby shell-init`, mapped to an Account ref or to `{ account, args }`.',
|
|
112
131
|
})),
|
|
132
|
+
pickCommands: Type.Optional(Type.Record(Type.String({ pattern: '^[A-Za-z_][A-Za-z0-9_-]*$' }), Type.String({ minLength: 1 }), {
|
|
133
|
+
description: 'Pick Commands: short shell function names created by `sideby shell-init`, mapped to a Family. Each run starts the Account of that Family with the most Quota left, or the Main Account when none has Quota data (ADR-0035). They share one namespace with `aliases`.',
|
|
134
|
+
})),
|
|
113
135
|
ignore: Type.Optional(Type.Array(Type.String(), { description: 'Account refs that are not Accounts.' })),
|
|
114
136
|
pluginDirs: Type.Optional(Type.Array(Type.String(), { description: 'Absolute or `~/` paths of Plugin directories.' })),
|
|
115
137
|
plugins: Type.Optional(Type.Record(Type.String(), Type.Record(Type.String(), Type.Unknown()), {
|
|
@@ -174,6 +196,7 @@ export function handoffSettings(config) {
|
|
|
174
196
|
sameFamily: h.sameFamily ?? false,
|
|
175
197
|
prepareAt: h.prepareAt ?? 80,
|
|
176
198
|
threshold: h.threshold ?? 95,
|
|
199
|
+
adaptive: h.adaptive ?? true,
|
|
177
200
|
waitIfResetWithinMinutes: h.waitIfResetWithinMinutes ?? 30,
|
|
178
201
|
countdownSeconds: h.countdownSeconds ?? 10,
|
|
179
202
|
crossOrganization: [...(h.crossOrganization ?? [])],
|
|
@@ -216,8 +239,22 @@ export async function loadConfig(file) {
|
|
|
216
239
|
if (problem)
|
|
217
240
|
throw new ConfigError(`${file}: alias "${alias}" ${problem} (it becomes a shell function name)`);
|
|
218
241
|
}
|
|
242
|
+
const shortProblem = shortCommandProblem(data);
|
|
243
|
+
if (shortProblem)
|
|
244
|
+
throw new ConfigError(`${file}: ${shortProblem}`);
|
|
219
245
|
return data;
|
|
220
246
|
}
|
|
247
|
+
/** A Pick Command whose name is unsafe in a shell or also an Alias (they share one namespace), or null. */
|
|
248
|
+
function shortCommandProblem(data) {
|
|
249
|
+
for (const name of Object.keys(data.pickCommands ?? {})) {
|
|
250
|
+
const problem = aliasProblem(name);
|
|
251
|
+
if (problem)
|
|
252
|
+
return `pick command "${name}" ${problem} (it becomes a shell function name); pick another name`;
|
|
253
|
+
if (data.aliases && Object.hasOwn(data.aliases, name))
|
|
254
|
+
return `"${name}" is both an alias and a pick command; remove one with \`sideby alias rm ${name}\` and add it again`;
|
|
255
|
+
}
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
221
258
|
/** Where the config file is read and written: the target of a link (a dotfiles manager may link it). */
|
|
222
259
|
async function configTarget(file) {
|
|
223
260
|
return (await lstatOrNull(file))?.isSymbolicLink() ? ((await realpathOrNull(file)) ?? file) : file;
|
|
@@ -277,6 +314,9 @@ async function editConfigKey(file, key, retry, edit, opts = {}) {
|
|
|
277
314
|
code: 'bad-value',
|
|
278
315
|
});
|
|
279
316
|
}
|
|
317
|
+
const shortProblem = shortCommandProblem(next);
|
|
318
|
+
if (shortProblem)
|
|
319
|
+
throw new ConfigError(shortProblem, { code: 'bad-value' });
|
|
280
320
|
const h = handoffSettings(next);
|
|
281
321
|
if (h.prepareAt >= h.threshold)
|
|
282
322
|
throw new ConfigError(`handoff.prepareAt must be lower than handoff.threshold; fix them in ${file} and ${retry} again`);
|
|
@@ -388,6 +428,38 @@ export async function removeConfigAlias(file, alias) {
|
|
|
388
428
|
});
|
|
389
429
|
return { status, aliases };
|
|
390
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Adds `name → family` to the config file's `pickCommands` (see `editConfigKey` for how the file is written). Refuses
|
|
433
|
+
* an invalid name, one that is an Alias, or one that already picks in another Family.
|
|
434
|
+
*/
|
|
435
|
+
export async function addConfigPickCommand(file, name, family) {
|
|
436
|
+
const problem = aliasProblem(name);
|
|
437
|
+
if (problem)
|
|
438
|
+
throw new ConfigError(`pick command "${name}" ${problem} (it becomes a shell function name)`);
|
|
439
|
+
let status = 'added';
|
|
440
|
+
const r = await editConfigKey(file, 'pickCommands', 'add the pick command', (current) => {
|
|
441
|
+
const now = current ?? {};
|
|
442
|
+
if (!Object.hasOwn(now, name))
|
|
443
|
+
return { ...now, [name]: family };
|
|
444
|
+
if (now[name] !== family)
|
|
445
|
+
throw new ConfigError(`"${name}" already starts the ${now[name]} account with the most room; pick another name, or remove it first with \`sideby alias rm ${name}\``);
|
|
446
|
+
status = 'exists';
|
|
447
|
+
return null;
|
|
448
|
+
});
|
|
449
|
+
return { status, pickCommands: r.after ?? {} };
|
|
450
|
+
}
|
|
451
|
+
/** Removes `name` from `pickCommands`; `absent` when it was not there. An emptied key goes away with it. */
|
|
452
|
+
export async function removeConfigPickCommand(file, name) {
|
|
453
|
+
let status = 'absent';
|
|
454
|
+
const r = await editConfigKey(file, 'pickCommands', 'remove the pick command', (current) => {
|
|
455
|
+
if (!current || !Object.hasOwn(current, name))
|
|
456
|
+
return null;
|
|
457
|
+
status = 'removed';
|
|
458
|
+
const { [name]: _gone, ...rest } = current;
|
|
459
|
+
return Object.keys(rest).length ? rest : undefined;
|
|
460
|
+
});
|
|
461
|
+
return { status, pickCommands: r.after ?? {} };
|
|
462
|
+
}
|
|
391
463
|
export function editConfigTerminal(file, patch) {
|
|
392
464
|
return editConfigKey(file, 'terminal', 'run `sideby terminal`', (current) => {
|
|
393
465
|
const next = { ...current, ...patch };
|
|
@@ -419,6 +491,7 @@ export function editConfigPanel(file, patch, opts = {}) {
|
|
|
419
491
|
const PLACEHOLDERS = {
|
|
420
492
|
accounts: '<family>:<name>',
|
|
421
493
|
aliases: '<short>',
|
|
494
|
+
pickCommands: '<short>',
|
|
422
495
|
plugins: '<plugin>',
|
|
423
496
|
extraSharedItems: '<family>',
|
|
424
497
|
'handoff.families': '<family>',
|
|
@@ -112,4 +112,4 @@ export declare function withDesktopApps<T extends {
|
|
|
112
112
|
* Account. Results are named `app-data/<path>` and are not counted in `shared`. The App Data is the repair boundary:
|
|
113
113
|
* a fix may only add a missing link inside it or sync a file's `key` there, never replace a real file.
|
|
114
114
|
*/
|
|
115
|
-
export declare function checkAppData(plugins: readonly LoadedPlugin[], home: string, account: Account): Promise<CheckResult[]>;
|
|
115
|
+
export declare function checkAppData(plugins: readonly LoadedPlugin[], home: string, account: Account, force?: boolean): Promise<CheckResult[]>;
|
|
@@ -369,7 +369,7 @@ export async function withDesktopApps(rt, accounts, statuses) {
|
|
|
369
369
|
* Account. Results are named `app-data/<path>` and are not counted in `shared`. The App Data is the repair boundary:
|
|
370
370
|
* a fix may only add a missing link inside it or sync a file's `key` there, never replace a real file.
|
|
371
371
|
*/
|
|
372
|
-
export async function checkAppData(plugins, home, account) {
|
|
372
|
+
export async function checkAppData(plugins, home, account, force = false) {
|
|
373
373
|
if (account.isMain || account.kind === 'api')
|
|
374
374
|
return [];
|
|
375
375
|
const def = desktopAppOf(plugins, account.family);
|
|
@@ -383,7 +383,7 @@ export async function checkAppData(plugins, home, account) {
|
|
|
383
383
|
const item = { path: f.path, mode: 'link' };
|
|
384
384
|
const mainPath = join(home, f.mainPath);
|
|
385
385
|
const p = join(dir, item.path);
|
|
386
|
-
const ctx = { account, item, mainPath, accountPath: p, accountDir: dir, force
|
|
386
|
+
const ctx = { account, item, mainPath, accountPath: p, accountDir: dir, force };
|
|
387
387
|
let res = await checkItem(ctx);
|
|
388
388
|
// The Desktop App writes its own file when the Main Account had none at first open, and replaces the link when
|
|
389
389
|
// it saves its preferences: not the user's doing, and a new link would be replaced again. With a `key`, only
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Runtime } from '../runtime.ts';
|
|
2
|
+
import type { FamilyDef } from '../types.ts';
|
|
3
|
+
export interface EditSettingsResult {
|
|
4
|
+
schemaVersion: 1;
|
|
5
|
+
ref: string;
|
|
6
|
+
family: string;
|
|
7
|
+
/** The file as the Family names it, such as `settings.json`. */
|
|
8
|
+
file: string;
|
|
9
|
+
/** The file inside the account directory. */
|
|
10
|
+
path: string;
|
|
11
|
+
/** Where the file really is, only when `path` is a link. */
|
|
12
|
+
target?: string;
|
|
13
|
+
/** Other Accounts of the Family whose settings file is this same file. */
|
|
14
|
+
sharedWith: string[];
|
|
15
|
+
/** False with `--path`, which only says where the file is. */
|
|
16
|
+
opened: boolean;
|
|
17
|
+
/** The program and arguments that opened it. */
|
|
18
|
+
command?: string[];
|
|
19
|
+
}
|
|
20
|
+
/** The Family's settings file when it names a relative path that stays inside the account directory. */
|
|
21
|
+
export declare function hostSettingsFile(def: Pick<FamilyDef, 'settingsFile'> | undefined): string | undefined;
|
|
22
|
+
export declare function editSettings(rt: Runtime, ref: string, opts?: {
|
|
23
|
+
open?: boolean;
|
|
24
|
+
}): Promise<EditSettingsResult>;
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
// it checks that the file is there and, for a link, where it really is and which Accounts share it. Every program
|
|
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';
|
|
6
|
+
import { depsFor } from './desktop-app.js';
|
|
7
|
+
import { UserError } from './errors.js';
|
|
8
|
+
import { lstatOrNull } from './fs-safe.js';
|
|
9
|
+
/** The Family's settings file when it names a relative path that stays inside the account directory. */
|
|
10
|
+
export function hostSettingsFile(def) {
|
|
11
|
+
const f = def?.settingsFile;
|
|
12
|
+
if (typeof f !== 'string' || !f || isAbsolute(f) || f.split(/[\\/]/).includes('..'))
|
|
13
|
+
return undefined;
|
|
14
|
+
return f;
|
|
15
|
+
}
|
|
16
|
+
async function realOrNull(path) {
|
|
17
|
+
try {
|
|
18
|
+
return await realpath(path);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export async function editSettings(rt, ref, opts = {}) {
|
|
25
|
+
const account = await rt.resolve(ref);
|
|
26
|
+
const def = rt.families.get(account.family);
|
|
27
|
+
const file = hostSettingsFile(def);
|
|
28
|
+
if (!file)
|
|
29
|
+
throw new UserError(`${account.ref}: ${def?.title ?? account.family} names no settings file; its folder is ${account.dir}`, { code: 'no-settings-file' });
|
|
30
|
+
const path = join(account.dir, file);
|
|
31
|
+
const real = await realOrNull(path);
|
|
32
|
+
if (!real) {
|
|
33
|
+
const link = await lstatOrNull(path);
|
|
34
|
+
throw new UserError(link?.isSymbolicLink()
|
|
35
|
+
? `${path} links to a file that is not there; run \`sideby doctor ${account.ref}\` to see what it should point to`
|
|
36
|
+
: `${account.ref} has no ${file} yet (${path}); \`sideby doctor ${account.ref} --fix\` links the main account's when they share it, or create the file in your editor`, { code: 'settings-missing' });
|
|
37
|
+
}
|
|
38
|
+
const sharedWith = [];
|
|
39
|
+
for (const other of await rt.accounts()) {
|
|
40
|
+
if (other.family !== account.family || other.ref === account.ref)
|
|
41
|
+
continue;
|
|
42
|
+
if ((await realOrNull(join(other.dir, file))) === real)
|
|
43
|
+
sharedWith.push(other.ref);
|
|
44
|
+
}
|
|
45
|
+
const base = {
|
|
46
|
+
schemaVersion: 1,
|
|
47
|
+
ref: account.ref,
|
|
48
|
+
family: account.family,
|
|
49
|
+
file,
|
|
50
|
+
path,
|
|
51
|
+
...(real !== path && (await lstatOrNull(path))?.isSymbolicLink() ? { target: real } : {}),
|
|
52
|
+
sharedWith,
|
|
53
|
+
};
|
|
54
|
+
if (opts.open === false)
|
|
55
|
+
return { ...base, opened: false };
|
|
56
|
+
return { ...base, opened: true, command: await openWithDefault(rt, real) };
|
|
57
|
+
}
|
|
58
|
+
/** Opens `file` with the system's default program; returns the command, or throws what to do instead. */
|
|
59
|
+
async function openWithDefault(rt, file) {
|
|
60
|
+
const deps = depsFor(rt);
|
|
61
|
+
const yourself = `open ${file} in your editor yourself`;
|
|
62
|
+
if (deps.platform === 'darwin') {
|
|
63
|
+
const r = await deps.exec('/usr/bin/open', ['-t', file]);
|
|
64
|
+
if (r.code !== 0)
|
|
65
|
+
throw new UserError(`macOS could not open the file; ${yourself}`, { code: 'open-failed' });
|
|
66
|
+
return ['/usr/bin/open', '-t', file];
|
|
67
|
+
}
|
|
68
|
+
if (deps.platform === 'linux' && deps.wslMount) {
|
|
69
|
+
const w = await deps.exec('wslpath', ['-w', file]);
|
|
70
|
+
const win = w.stdout.trim();
|
|
71
|
+
if (w.code !== 0 || !win)
|
|
72
|
+
throw new UserError(`wslpath could not name the file for Windows; ${yourself}`, { code: 'open-failed' });
|
|
73
|
+
// `start` hands the file to its Windows default program; explorer.exe opens one only now and then. cmd reads
|
|
74
|
+
// these characters itself, so a path with one is left to the user.
|
|
75
|
+
if (/[&|<>^%"]/.test(win))
|
|
76
|
+
throw new UserError(`the path has a character cmd.exe reads itself; ${yourself}`, {
|
|
77
|
+
code: 'open-failed',
|
|
78
|
+
});
|
|
79
|
+
const cmd = `${deps.wslMount}/c/Windows/System32/cmd.exe`;
|
|
80
|
+
const args = ['/c', 'start', '', win];
|
|
81
|
+
const r = await deps.exec(cmd, args);
|
|
82
|
+
if (r.code !== 0)
|
|
83
|
+
throw new UserError(`Windows could not open the file; ${yourself}`, { code: 'open-failed' });
|
|
84
|
+
return [cmd, ...args];
|
|
85
|
+
}
|
|
86
|
+
if (deps.platform === 'linux') {
|
|
87
|
+
const r = await deps.exec('xdg-open', [file]);
|
|
88
|
+
if (r.code !== 0)
|
|
89
|
+
throw new UserError(`xdg-open could not open the file; install xdg-utils, or ${yourself}`, {
|
|
90
|
+
code: 'open-failed',
|
|
91
|
+
});
|
|
92
|
+
return ['xdg-open', file];
|
|
93
|
+
}
|
|
94
|
+
throw new UserError(`sideby cannot open files on ${deps.platform} yet; ${yourself}`, {
|
|
95
|
+
code: 'open-failed',
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReadyFile } from './handoff-chain.ts';
|
|
2
2
|
/** Branch, uncommitted files and `git diff --stat`, as Markdown; '' outside a git work tree. Never commits or stashes. */
|
|
3
3
|
export declare function gitSection(cwd: string): Promise<string>;
|
|
4
4
|
export declare const ASSEMBLED_NOTE = "> Put together by sideby from the previous session\u2019s records, without a model; it may be incomplete. Check the repository before continuing.";
|
|
5
|
+
export declare const UNFINISHED_NOTE = "> The previous session did not finish the brief above. sideby added what it found in the session\u2019s records below.";
|
|
5
6
|
/**
|
|
6
7
|
* Writes the final Brief to `target` (mode 600) and says where it came from: the user's or the session's Brief
|
|
7
|
-
* named in `ready`, the session's Brief already at `target`, else `assembled`, plus the repository state.
|
|
8
|
+
* named in `ready`, the session's Brief already at `target`, else `assembled`, plus the repository state. A session's
|
|
9
|
+
* Brief without `BRIEF_DONE` is kept, with `assembled` added under it (ADR-0032).
|
|
8
10
|
*/
|
|
9
11
|
export declare function finishBrief(opts: {
|
|
10
12
|
target: string;
|
|
@@ -4,6 +4,7 @@ import { execFile } from 'node:child_process';
|
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
import { promisify } from 'node:util';
|
|
6
6
|
import { writeFileAtomic } from './fs-safe.js';
|
|
7
|
+
import { BRIEF_DONE } from './handoff-chain.js';
|
|
7
8
|
const run = promisify(execFile);
|
|
8
9
|
const GIT_TIMEOUT_MS = 3000;
|
|
9
10
|
const MAX_STATUS_LINES = 50;
|
|
@@ -54,9 +55,11 @@ async function nonEmpty(path) {
|
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
export const ASSEMBLED_NOTE = '> Put together by sideby from the previous session’s records, without a model; it may be incomplete. Check the repository before continuing.';
|
|
58
|
+
export const UNFINISHED_NOTE = '> The previous session did not finish the brief above. sideby added what it found in the session’s records below.';
|
|
57
59
|
/**
|
|
58
60
|
* Writes the final Brief to `target` (mode 600) and says where it came from: the user's or the session's Brief
|
|
59
|
-
* named in `ready`, the session's Brief already at `target`, else `assembled`, plus the repository state.
|
|
61
|
+
* named in `ready`, the session's Brief already at `target`, else `assembled`, plus the repository state. A session's
|
|
62
|
+
* Brief without `BRIEF_DONE` is kept, with `assembled` added under it (ADR-0032).
|
|
60
63
|
*/
|
|
61
64
|
export async function finishBrief(opts) {
|
|
62
65
|
let body = await nonEmpty(opts.ready.brief);
|
|
@@ -69,6 +72,8 @@ export async function finishBrief(opts) {
|
|
|
69
72
|
source = 'sideby';
|
|
70
73
|
body = `${ASSEMBLED_NOTE}\n\n${opts.assembled ?? 'sideby could not read the previous session’s records.\n'}`;
|
|
71
74
|
}
|
|
75
|
+
else if (source === 'agent' && !body.includes(BRIEF_DONE) && opts.assembled)
|
|
76
|
+
body = `${body.trimEnd()}\n\n${UNFINISHED_NOTE}\n\n${opts.assembled}`;
|
|
72
77
|
const repo = await gitSection(opts.cwd);
|
|
73
78
|
await writeFileAtomic(opts.target, `${body.trimEnd()}\n${repo ? `\n${repo}` : ''}`, 0o600);
|
|
74
79
|
return { path: opts.target, source };
|
|
@@ -5,6 +5,15 @@ export declare const HANDOFF_ENV: {
|
|
|
5
5
|
readonly dir: 'SIDEBY_HANDOFF_DIR';
|
|
6
6
|
};
|
|
7
7
|
export type HandoffTrigger = 'threshold' | 'limit' | 'manual';
|
|
8
|
+
/** The last line of a Brief the session finished (ADR-0032); a Brief without it is treated as unfinished. */
|
|
9
|
+
export declare const BRIEF_DONE = "<!-- handoff brief complete -->";
|
|
10
|
+
/** One Quota window as the hook read it: which window, how full, when it resets. */
|
|
11
|
+
export interface WindowReading {
|
|
12
|
+
/** `5h`, `7d` or `<n>m`, as `QuotaWindow.label`. */
|
|
13
|
+
label: string;
|
|
14
|
+
usedPercent: number;
|
|
15
|
+
resetsAt: string;
|
|
16
|
+
}
|
|
8
17
|
/** What the parent decided the next Handoff would do, refreshed while the Host runs. */
|
|
9
18
|
export interface PlanFile {
|
|
10
19
|
/** The run this plan is for; a plan left by an earlier hop of the chain is ignored. */
|
|
@@ -18,6 +27,8 @@ export interface PlanFile {
|
|
|
18
27
|
until?: string;
|
|
19
28
|
prepareAt: number;
|
|
20
29
|
threshold: number;
|
|
30
|
+
/** Each window hands over at its own pace (ADR-0032); missing (an older parent) means every window uses `threshold`. */
|
|
31
|
+
adaptive?: boolean;
|
|
21
32
|
/** False when the session cannot write its Brief: no preparing step, and the threshold only ends the turn. */
|
|
22
33
|
agentBrief?: boolean;
|
|
23
34
|
/** The parent reads `to` from a manual request; a parent from before 0.9.3 does not write it and ignores `to`. */
|
|
@@ -30,6 +41,15 @@ export interface RunState {
|
|
|
30
41
|
stopBlocked?: boolean;
|
|
31
42
|
/** The user was told this run waits for a reset instead of moving on (ADR-0018). */
|
|
32
43
|
waitNoticeSentAt?: string;
|
|
44
|
+
/** The window that reached its Hand-over Level, when the threshold message went out. */
|
|
45
|
+
thresholdWindow?: WindowReading;
|
|
46
|
+
/** Each window at the last `Stop`, by label: where the next turn's growth is measured from (ADR-0032). */
|
|
47
|
+
turnMark?: Record<string, {
|
|
48
|
+
usedPercent: number;
|
|
49
|
+
resetsAt: string;
|
|
50
|
+
}>;
|
|
51
|
+
/** Each window's growth in the run's last finished turns, newest last, by label. */
|
|
52
|
+
turnUse?: Record<string, number[]>;
|
|
33
53
|
sessionId?: string;
|
|
34
54
|
transcriptPath?: string;
|
|
35
55
|
}
|
|
@@ -41,6 +61,8 @@ export interface ReadyFile {
|
|
|
41
61
|
/** The Brief file, when the session or the user wrote one. */
|
|
42
62
|
brief?: string;
|
|
43
63
|
briefSource?: 'agent' | 'user';
|
|
64
|
+
/** The window that started a `threshold` or `limit` Handoff. */
|
|
65
|
+
window?: WindowReading;
|
|
44
66
|
/** `sideby handoff ready --to`: the Account ref to hand over to. */
|
|
45
67
|
to?: string;
|
|
46
68
|
sessionId?: string;
|
|
@@ -59,6 +81,8 @@ export interface ChainHop {
|
|
|
59
81
|
trigger?: HandoffTrigger;
|
|
60
82
|
briefSource?: 'agent' | 'sideby' | 'user';
|
|
61
83
|
brief?: string;
|
|
84
|
+
/** The window that started the Handoff, when the Quota did. */
|
|
85
|
+
window?: WindowReading;
|
|
62
86
|
}
|
|
63
87
|
export interface ChainFile {
|
|
64
88
|
hops: ChainHop[];
|
|
@@ -13,6 +13,8 @@ export const HANDOFF_ENV = {
|
|
|
13
13
|
family: 'SIDEBY_HANDOFF_FAMILY',
|
|
14
14
|
dir: 'SIDEBY_HANDOFF_DIR',
|
|
15
15
|
};
|
|
16
|
+
/** The last line of a Brief the session finished (ADR-0032); a Brief without it is treated as unfinished. */
|
|
17
|
+
export const BRIEF_DONE = '<!-- handoff brief complete -->';
|
|
16
18
|
export const FILES = {
|
|
17
19
|
plan: 'plan.json',
|
|
18
20
|
ready: 'ready.json',
|
|
@@ -21,10 +21,11 @@ export declare function hookEntryWorks(env: Env): Promise<boolean>;
|
|
|
21
21
|
* Runs `ref` with Auto Handoff when the config, the Family, the run and the terminal allow it, and returns the exit
|
|
22
22
|
* code of the last Host; null when Auto Handoff does not apply and the caller should run the Host as usual.
|
|
23
23
|
*/
|
|
24
|
-
export declare function runWithHandoff(rt: Runtime, ref: string, userArgs: readonly string[], io: HandoffIo,
|
|
25
|
-
/** For tests: how long the Host gets to exit after SIGTERM. */
|
|
26
|
-
opts?: {
|
|
24
|
+
export declare function runWithHandoff(rt: Runtime, ref: string, userArgs: readonly string[], io: HandoffIo, opts?: {
|
|
25
|
+
/** For tests: how long the Host gets to exit after SIGTERM. */
|
|
27
26
|
exitGraceMs?: number;
|
|
27
|
+
/** An AI Task (ADR-0031): every Account it hands over to starts without permission bypasses too. */
|
|
28
|
+
aiTask?: boolean;
|
|
28
29
|
}): Promise<number | null>;
|
|
29
30
|
/**
|
|
30
31
|
* For `sideby handoff ready`: where a Handoff from the session running under `env` would go now, using the chain's
|
|
@@ -6,7 +6,7 @@ import { watch } from 'node:fs';
|
|
|
6
6
|
import { rm } from 'node:fs/promises';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
8
|
import { HOOK_FAMILIES } from '../handoff/hook.js';
|
|
9
|
-
import { firstPrompt } from '../handoff/messages.js';
|
|
9
|
+
import { firstPrompt, windowText } from '../handoff/messages.js';
|
|
10
10
|
import { aliasArgs } from './config.js';
|
|
11
11
|
import { UserError } from './errors.js';
|
|
12
12
|
import { finishBrief } from './handoff-brief.js';
|
|
@@ -147,14 +147,13 @@ async function decide(rt, account, used, to, manual = false) {
|
|
|
147
147
|
* Runs `ref` with Auto Handoff when the config, the Family, the run and the terminal allow it, and returns the exit
|
|
148
148
|
* code of the last Host; null when Auto Handoff does not apply and the caller should run the Host as usual.
|
|
149
149
|
*/
|
|
150
|
-
export async function runWithHandoff(rt, ref, userArgs, io,
|
|
151
|
-
/** For tests: how long the Host gets to exit after SIGTERM. */
|
|
152
|
-
opts = {}) {
|
|
150
|
+
export async function runWithHandoff(rt, ref, userArgs, io, opts = {}) {
|
|
153
151
|
const grace = opts.exitGraceMs ?? EXIT_GRACE_MS;
|
|
154
152
|
const settings = rt.handoffSettings();
|
|
155
153
|
if (!settings.auto || !io.stdin.isTTY)
|
|
156
154
|
return null;
|
|
157
|
-
const
|
|
155
|
+
const launchOpts = opts.aiTask ? { aiTask: true } : {};
|
|
156
|
+
const firstLaunch = await rt.prepareLaunch(ref, userArgs, 'run', launchOpts);
|
|
158
157
|
const firstHandoff = firstLaunch.family.handoff;
|
|
159
158
|
// Only built-in Families have a hook reader (spec §3.17); a Plugin Family can only take over.
|
|
160
159
|
if (!firstHandoff?.starts.length || !HOOK_FAMILIES.includes(firstLaunch.family.id))
|
|
@@ -183,7 +182,7 @@ opts = {}) {
|
|
|
183
182
|
let hop = { ref, args: [...aliasArgs(own), ...userArgs] };
|
|
184
183
|
let n = 1;
|
|
185
184
|
for (;;) {
|
|
186
|
-
const launch = n === 1 ? firstLaunch : await rt.prepareLaunch(hop.ref, hop.args, 'run');
|
|
185
|
+
const launch = n === 1 ? firstLaunch : await rt.prepareLaunch(hop.ref, hop.args, 'run', launchOpts);
|
|
187
186
|
const account = launch.account;
|
|
188
187
|
const h = launch.family.handoff;
|
|
189
188
|
if (!h)
|
|
@@ -236,6 +235,7 @@ opts = {}) {
|
|
|
236
235
|
...(d.kind === 'wait' ? { until: d.until } : {}),
|
|
237
236
|
prepareAt: settings.prepareAt,
|
|
238
237
|
threshold: settings.threshold,
|
|
238
|
+
adaptive: settings.adaptive,
|
|
239
239
|
...(elig.agentBrief === false ? { agentBrief: false } : {}),
|
|
240
240
|
acceptsTo: true,
|
|
241
241
|
};
|
|
@@ -316,11 +316,16 @@ opts = {}) {
|
|
|
316
316
|
cwd: process.cwd(),
|
|
317
317
|
});
|
|
318
318
|
const last = hops.hops[hops.hops.length - 1];
|
|
319
|
-
Object.assign(last, {
|
|
319
|
+
Object.assign(last, {
|
|
320
|
+
trigger: ready.trigger,
|
|
321
|
+
briefSource: done.source,
|
|
322
|
+
brief: done.path,
|
|
323
|
+
...(ready.window ? { window: ready.window } : {}),
|
|
324
|
+
});
|
|
320
325
|
await writeJsonFile(join(dir, FILES.chain), hops);
|
|
321
326
|
await rm(join(dir, FILES.ready), { force: true });
|
|
322
327
|
await rm(join(dir, FILES.request), { force: true });
|
|
323
|
-
io.err(`sideby: ${account.ref} saved its session and is handing over because ${WHY[ready.trigger]}; next is ${decision.ref}${skippedText(decision)}. Brief: ${done.path}`);
|
|
328
|
+
io.err(`sideby: ${account.ref} saved its session and is handing over because ${WHY[ready.trigger]}${ready.window ? ` (${windowText(ready.window)})` : ''}; next is ${decision.ref}${skippedText(decision)}. Brief: ${done.path}`);
|
|
324
329
|
if (settings.countdownSeconds > 0 &&
|
|
325
330
|
(await countdown(io, settings.countdownSeconds, decision.ref, account.ref))) {
|
|
326
331
|
io.err(`sideby: staying in ${account.ref}`);
|
|
@@ -329,7 +334,7 @@ opts = {}) {
|
|
|
329
334
|
return ended.code;
|
|
330
335
|
}
|
|
331
336
|
const backArgs = [...h.continueArgs(hop.args), ...h.resumeArgs(ready.sessionId)];
|
|
332
|
-
const back = await rt.prepareLaunch(account.ref, backArgs, 'run');
|
|
337
|
+
const back = await rt.prepareLaunch(account.ref, backArgs, 'run', launchOpts);
|
|
333
338
|
// The same per-Account arguments as before (Grok's leader socket), without sideby's hooks.
|
|
334
339
|
const backElig = await h.eligibility(back.args, account, back.env);
|
|
335
340
|
return runHost({ ...back, args: beforeDashes(back.args, backElig.args ?? []) });
|
|
@@ -45,6 +45,8 @@ export interface LaunchCommandOptions {
|
|
|
45
45
|
accountArgs: readonly string[];
|
|
46
46
|
userArgs: readonly string[];
|
|
47
47
|
command: 'run' | 'login';
|
|
48
|
+
/** An AI Task (spec §3.28): the Family's `aiTaskArgs` removes every permission bypass (ADR-0031). */
|
|
49
|
+
aiTask?: boolean;
|
|
48
50
|
/** Config `accountTitle`: set the terminal title to `[<label>]` and keep the Host from replacing it. */
|
|
49
51
|
title?: boolean;
|
|
50
52
|
}
|
package/dist/src/core/launch.js
CHANGED
|
@@ -88,15 +88,17 @@ export function launchCommand(opts) {
|
|
|
88
88
|
const keep = opts.title && family.keepTitle && !opts.userArgs.some((a) => a.includes(family.keepTitle.key))
|
|
89
89
|
? family.keepTitle.args
|
|
90
90
|
: [];
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
const args = [
|
|
92
|
+
...(family.defaultArgs?.(account, opts.userArgs) ?? []),
|
|
93
|
+
...keep,
|
|
94
|
+
...opts.accountArgs,
|
|
95
|
+
...opts.userArgs,
|
|
96
|
+
];
|
|
97
|
+
return { bin: family.bin, args: opts.aiTask ? aiTaskArgs(family, args) : args };
|
|
98
|
+
}
|
|
99
|
+
/** The arguments of an AI Task's Launch, without the Family's permission bypasses (ADR-0031). */
|
|
100
|
+
function aiTaskArgs(family, args) {
|
|
101
|
+
return family.aiTaskArgs ? family.aiTaskArgs(args) : args;
|
|
100
102
|
}
|
|
101
103
|
export async function prepareLaunch(opts) {
|
|
102
104
|
const { account, family } = opts;
|
|
@@ -119,6 +121,8 @@ export async function prepareLaunch(opts) {
|
|
|
119
121
|
config: {},
|
|
120
122
|
command: opts.command,
|
|
121
123
|
});
|
|
124
|
+
// A `launch.before` hook cannot add a bypass back into an AI Task either.
|
|
125
|
+
const finalArgs = opts.aiTask && opts.command === 'run' ? aiTaskArgs(family, args) : args;
|
|
122
126
|
// Control characters would end the escape sequence early; labels are shell-safe names, so this is a guard only.
|
|
123
127
|
const title = opts.title
|
|
124
128
|
? [...`[${env.SIDEBY_LABEL ?? account.ref}]`].filter((ch) => ch >= ' ' && ch !== '\x7f').join('')
|
|
@@ -127,7 +131,7 @@ export async function prepareLaunch(opts) {
|
|
|
127
131
|
account,
|
|
128
132
|
family,
|
|
129
133
|
bin: family.bin,
|
|
130
|
-
args,
|
|
134
|
+
args: finalArgs,
|
|
131
135
|
env,
|
|
132
136
|
...(notice ? { notice } : {}),
|
|
133
137
|
...(title ? { title } : {}),
|
|
@@ -11,6 +11,12 @@ export interface LocalDirs {
|
|
|
11
11
|
export declare const pkgDir: (d: LocalDirs) => string;
|
|
12
12
|
export declare const globalPkg: (d: LocalDirs) => string;
|
|
13
13
|
export declare const devDir: (env: Env) => string;
|
|
14
|
+
/**
|
|
15
|
+
* The environment to ask npm for its global prefix in. A pnpm script gets pnpm's own `--dir` (`pnpm -C <dir> …`) as
|
|
16
|
+
* `npm_config_dir` and `npm_config_prefix`, and npm would answer with that directory; npm reads the user's real
|
|
17
|
+
* setting from its config files and from `NPM_CONFIG_PREFIX` without them.
|
|
18
|
+
*/
|
|
19
|
+
export declare function npmEnv(env: Env): Env;
|
|
14
20
|
/** Where the switch works, with npm's global prefix from `npm prefix -g`; null when npm cannot be asked. */
|
|
15
21
|
export declare function localDirs(env: Env): Promise<LocalDirs | null>;
|
|
16
22
|
export declare function kind(p: string): Promise<'link' | 'dir' | 'file' | null>;
|
|
@@ -51,11 +57,11 @@ export interface SwitchResult {
|
|
|
51
57
|
unchanged?: boolean;
|
|
52
58
|
restartedPanel: boolean;
|
|
53
59
|
/**
|
|
54
|
-
* Back on npm, `sideby update --yes` of the npm code brought the skill agents read to its version (true), or
|
|
55
|
-
* failed (false); absent for a switch to the Local Build, which has no skill of its own to bring.
|
|
60
|
+
* Back on npm, `sideby update --skill --yes` of the npm code brought the skill agents read to its version (true), or
|
|
61
|
+
* that failed (false); absent for a switch to the Local Build, which has no skill of its own to bring.
|
|
56
62
|
*/
|
|
57
63
|
skillSynced?: boolean;
|
|
58
|
-
/** With `skillSync: 'background'`: that `sideby update --yes` started on its own and is not waited for. */
|
|
64
|
+
/** With `skillSync: 'background'`: that `sideby update --skill --yes` started on its own and is not waited for. */
|
|
59
65
|
skillSyncStarted?: boolean;
|
|
60
66
|
/** Another install held the lock; nothing ran. */
|
|
61
67
|
busy?: boolean;
|
|
@@ -64,8 +70,9 @@ export interface SwitchResult {
|
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
72
|
* Puts `to` behind the global `sideby`. `local` links the newest Local Build; `npm` restores the kept package or
|
|
67
|
-
* installs `latest` (a failed install links the Local Build back, so `sideby` never goes missing). Afterwards
|
|
68
|
-
*
|
|
73
|
+
* installs `latest` (a failed install links the Local Build back, so `sideby` never goes missing). Afterwards
|
|
74
|
+
* (after-install.ts) an existing login item follows, back on npm the skill does, and a background Panel on `panelPort`
|
|
75
|
+
* starts again from the new code, last. One install at a time (the Update lock).
|
|
69
76
|
*/
|
|
70
77
|
export declare function switchLocal(paths: Paths, d: LocalDirs, to: LocalTarget, env: Env, opts?: {
|
|
71
78
|
panelPort?: () => Promise<number | null>;
|