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
|
@@ -393,6 +393,73 @@ export function switchFailure(e) {
|
|
|
393
393
|
return 'wait';
|
|
394
394
|
return (e.status ?? 0) >= 500 ? 'check' : 'fail';
|
|
395
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* What a request that may swap the server's code (an Update, a Local Build switch; spec §3.23) has done. `failure` is
|
|
398
|
+
* how the request failed (`switchFailure`), null for an answer. `landed` is what a fresh read of the state says
|
|
399
|
+
* (the version runs, the switch is in place), null while the state cannot be read. `waitedOut`: the wait for the new
|
|
400
|
+
* code is over. Without an answer only the state can confirm success; until the wait is over the page keeps reading.
|
|
401
|
+
*/
|
|
402
|
+
export function codeSwapOutcome(s) {
|
|
403
|
+
if (s.failure === null)
|
|
404
|
+
return 'done';
|
|
405
|
+
if (s.failure === 'fail')
|
|
406
|
+
return 'failed';
|
|
407
|
+
if (s.landed === true)
|
|
408
|
+
return 'done';
|
|
409
|
+
if (!s.waitedOut)
|
|
410
|
+
return 'waiting';
|
|
411
|
+
return s.landed === false ? 'failed' : 'unknown';
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Runs a request that may swap the server's code (an Update, a Local Build switch; spec §3.23). A background Panel
|
|
415
|
+
* restarting from the new code drops the answer, and a Portal moving to it may answer 5xx: without an answer only a
|
|
416
|
+
* fresh read of the state that shows the change counts as success (`codeSwapOutcome`). Each wait starts when the
|
|
417
|
+
* previous step ended, never before the request (an install can take longer than a wait): `windowMs` to confirm the
|
|
418
|
+
* change, reading every `pollMs` and once more at the end, then `windowMs` for the new build, which `reload`s the
|
|
419
|
+
* page. `done(answer)` returns false to stop after it; `stuck` when no new build came, `fail(error)` when the change
|
|
420
|
+
* did not happen, `unknown` when the state never answered.
|
|
421
|
+
*/
|
|
422
|
+
export async function runCodeSwap(io) {
|
|
423
|
+
let answer = null;
|
|
424
|
+
let error = null;
|
|
425
|
+
let failure = null;
|
|
426
|
+
try {
|
|
427
|
+
answer = await io.send();
|
|
428
|
+
}
|
|
429
|
+
catch (e) {
|
|
430
|
+
error = e;
|
|
431
|
+
failure = switchFailure((e ?? {}));
|
|
432
|
+
}
|
|
433
|
+
const cut = failure === 'wait' || failure === 'check';
|
|
434
|
+
if (cut)
|
|
435
|
+
io.confirming();
|
|
436
|
+
let until = io.now() + io.windowMs;
|
|
437
|
+
for (;;) {
|
|
438
|
+
const landed = cut ? ((await io.readState()) ? io.landed() : null) : null;
|
|
439
|
+
// The server runs another build: the change is in place, and this page reloads into it.
|
|
440
|
+
if (io.newBuild())
|
|
441
|
+
return io.reload();
|
|
442
|
+
const out = codeSwapOutcome({ failure, landed, waitedOut: io.now() > until });
|
|
443
|
+
if (out === 'failed')
|
|
444
|
+
return io.fail(error);
|
|
445
|
+
if (out === 'unknown')
|
|
446
|
+
return io.unknown();
|
|
447
|
+
if (out === 'done')
|
|
448
|
+
break;
|
|
449
|
+
await io.pause(io.pollMs);
|
|
450
|
+
}
|
|
451
|
+
if (!io.done(answer))
|
|
452
|
+
return;
|
|
453
|
+
until = io.now() + io.windowMs;
|
|
454
|
+
for (;;) {
|
|
455
|
+
if (io.newBuild())
|
|
456
|
+
return io.reload();
|
|
457
|
+
if (io.now() > until)
|
|
458
|
+
return io.stuck();
|
|
459
|
+
await io.pause(io.pollMs);
|
|
460
|
+
await io.readState();
|
|
461
|
+
}
|
|
462
|
+
}
|
|
396
463
|
export function panelFixes(f, skillUpdatable) {
|
|
397
464
|
return skillUpdatable && f.code === 'skill.outdated';
|
|
398
465
|
}
|
|
@@ -637,6 +704,62 @@ export function askCopy(task, has, freeChips) {
|
|
|
637
704
|
const chips = own ? [1, 2, 3].map((n) => 'ask.ex.' + task + '.' + n).filter(has) : [];
|
|
638
705
|
return { title, placeholder, chips: chips.length ? chips : freeChips.slice() };
|
|
639
706
|
}
|
|
707
|
+
/**
|
|
708
|
+
* Whether the Panel hands its AI Tasks to the Portal around it (ADR-0030): createPanelHandler was given
|
|
709
|
+
* `ask: { bridge: 'postMessage' }` and the page sits in a frame. A Panel opened on its own is its own parent; it keeps
|
|
710
|
+
* its header "Let AI do it" button and its own dialog. The page decides this when it loads.
|
|
711
|
+
*/
|
|
712
|
+
export function askBridged(boot, win) {
|
|
713
|
+
return boot.ask?.bridge === 'postMessage' && Boolean(win.parent) && win.parent !== win;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Hands an AI Task to the Portal around the Panel (ADR-0030) when `askBridged` says so: posts
|
|
717
|
+
* `{ type: 'local-tools:ask', version: 1, preset, native: { task, text, context }, text }` to the parent with the
|
|
718
|
+
* Panel's own origin as the target, and says it did, so the Panel opens no dialog of its own. Otherwise posts nothing
|
|
719
|
+
* and returns false.
|
|
720
|
+
*/
|
|
721
|
+
export function askBridge(boot, opts, win) {
|
|
722
|
+
if (!askBridged(boot, win) || !win.parent)
|
|
723
|
+
return false;
|
|
724
|
+
const o = opts || {};
|
|
725
|
+
const task = o.task || 'free';
|
|
726
|
+
const text = o.text || '';
|
|
727
|
+
win.parent.postMessage({
|
|
728
|
+
type: 'local-tools:ask',
|
|
729
|
+
version: 1,
|
|
730
|
+
preset: task,
|
|
731
|
+
native: { task, text, context: o.context || {} },
|
|
732
|
+
text,
|
|
733
|
+
}, win.location.origin);
|
|
734
|
+
return true;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* The "Attached files" section of a Task Prompt (spec §3.28 "附件"), in `lang` (`zh`, otherwise English): one line
|
|
738
|
+
* per file with its absolute path and kind, plus how to look at a video. Empty without files. `heading` goes before
|
|
739
|
+
* the section title, so a prompt with Markdown headings (`## `, a Task Spec from a Portal) gets one of its level.
|
|
740
|
+
* sideby's own Task Prompts and the ones a Portal hands over (ADR-0030) share it, word for word.
|
|
741
|
+
*/
|
|
742
|
+
export function attachedSection(files, lang, heading = '') {
|
|
743
|
+
if (!files.length)
|
|
744
|
+
return '';
|
|
745
|
+
const L = lang === 'zh'
|
|
746
|
+
? {
|
|
747
|
+
attached: '附件',
|
|
748
|
+
image: '图片',
|
|
749
|
+
video: '视频',
|
|
750
|
+
videoHint: '需要看视频内容时,用 ffmpeg 抽几帧再看,例如 `ffmpeg -i <视频> -vf fps=1 -frames:v 5 frame-%d.png`。',
|
|
751
|
+
}
|
|
752
|
+
: {
|
|
753
|
+
attached: 'Attached files',
|
|
754
|
+
image: 'image',
|
|
755
|
+
video: 'video',
|
|
756
|
+
videoHint: 'To see what a video shows, extract a few frames with ffmpeg first, for example `ffmpeg -i <video> -vf fps=1 -frames:v 5 frame-%d.png`.',
|
|
757
|
+
};
|
|
758
|
+
const lines = files.map((f) => '- ' + f.path + ' (' + (f.kind === 'video' ? L.video : L.image) + ')');
|
|
759
|
+
if (files.some((f) => f.kind === 'video'))
|
|
760
|
+
lines.push(L.videoHint);
|
|
761
|
+
return heading + L.attached + '\n' + lines.join('\n');
|
|
762
|
+
}
|
|
640
763
|
/**
|
|
641
764
|
* The Task Prompt of an AI Task (spec §3.28), in `lang` (`zh`, otherwise English): what to do, the context given,
|
|
642
765
|
* the fixed rules, pointers for the task and the invitation to contribute. For `free` the user's `text` is what to
|
|
@@ -688,10 +811,6 @@ export function taskPrompt(input, strip) {
|
|
|
688
811
|
pHost: '用 `sideby plugins new <id>` 生成插件骨架;收集事实时写明宿主的版本和日期;用 `sideby plugins check <id>` 检查,并在演示 HOME 里试一遍。',
|
|
689
812
|
pPlugin: '照 sideby 仓库的插件指南 docs/guide/plugins.zh-CN.md 写;写完用 `sideby plugins check <id>` 检查。',
|
|
690
813
|
pTerminal: "先问我用的是什么终端。只看这个终端的官方文档和它的 `--help`,找出「在指定目录新开一个窗口运行一条命令」的写法,写明你看的版本。写成一个模板:`{cmd}` 是要运行的命令,`{cwd}` 是文件夹,sideby 按参数填入,不经过 shell。保存要用 `sideby terminal --custom '<模板>'`,它会改 sideby 的设置,先问我。保存后让我在面板上点一次「让 AI 帮我」试一下,打不开就一起看错误再改。",
|
|
691
|
-
attached: '附件',
|
|
692
|
-
image: '图片',
|
|
693
|
-
video: '视频',
|
|
694
|
-
videoHint: '需要看视频内容时,用 ffmpeg 抽几帧再看,例如 `ffmpeg -i <视频> -vf fps=1 -frames:v 5 frame-%d.png`。',
|
|
695
814
|
share: '做好之后,问我愿不愿意把这次的改进分享给 sideby。我同意后,按 sideby 仓库的 CONTRIBUTING.md 提一个 pull request,提交前去掉我自己的账号名、路径和邮箱。',
|
|
696
815
|
shareTerminal: '跑通之后,问我愿不愿意把这个终端做成 sideby 的内置终端。我同意后,在 sideby 仓库 src/core/terminal.ts 的终端表里加一行并补上测试,按 CONTRIBUTING.md 提一个 pull request,提交前去掉我自己的账号名、路径和邮箱。',
|
|
697
816
|
}
|
|
@@ -731,10 +850,6 @@ export function taskPrompt(input, strip) {
|
|
|
731
850
|
pHost: 'Start with `sideby plugins new <id>`; note the Host version and the date with every fact you gather; check it with `sideby plugins check <id>` and try it in a demo HOME.',
|
|
732
851
|
pPlugin: 'Follow the plugins guide in the sideby repository (docs/guide/plugins.md); check it with `sideby plugins check <id>`.',
|
|
733
852
|
pTerminal: "Ask me which terminal I use first. Read only that terminal's official docs and its `--help` to find how it opens a new window that runs one command in a given folder, and note the version you read. Write it as a template: `{cmd}` is the command and `{cwd}` the folder; sideby fills them in as separate arguments, no shell runs it. Save it with `sideby terminal --custom '<template>'`, which changes sideby's settings, so ask me first. Then have me click Let AI do it in the Panel once to try it; if it does not open, look at the error with me and fix the template.",
|
|
734
|
-
attached: 'Attached files',
|
|
735
|
-
image: 'image',
|
|
736
|
-
video: 'video',
|
|
737
|
-
videoHint: 'To see what a video shows, extract a few frames with ffmpeg first, for example `ffmpeg -i <video> -vf fps=1 -frames:v 5 frame-%d.png`.',
|
|
738
853
|
share: 'When it works, ask me whether to share the improvement with sideby. Only with my yes, follow the CONTRIBUTING.md of the sideby repository to open a pull request, and first remove my own account names, paths and emails.',
|
|
739
854
|
shareTerminal: 'When it works, ask me whether to make this terminal built into sideby. Only with my yes, add a row to the terminal table in src/core/terminal.ts of the sideby repository with tests, follow its CONTRIBUTING.md to open a pull request, and first remove my own account names, paths and emails.',
|
|
740
855
|
};
|
|
@@ -784,13 +899,9 @@ export function taskPrompt(input, strip) {
|
|
|
784
899
|
facts.push('- ' + L.cLang);
|
|
785
900
|
const pointer = L['p' + task.charAt(0).toUpperCase() + task.slice(1)];
|
|
786
901
|
const parts = [L.task + '\n' + what, L.context + '\n' + facts.join('\n')];
|
|
787
|
-
const
|
|
788
|
-
if (
|
|
789
|
-
|
|
790
|
-
if (files.some((f) => f.kind === 'video'))
|
|
791
|
-
lines.push(L.videoHint);
|
|
792
|
-
parts.push(L.attached + '\n' + lines.join('\n'));
|
|
793
|
-
}
|
|
902
|
+
const attached = attachedSection(input.attachments || [], input.lang);
|
|
903
|
+
if (attached)
|
|
904
|
+
parts.push(attached);
|
|
794
905
|
parts.push(L.rules + '\n- ' + L.r1 + '\n- ' + L.r2 + '\n- ' + L.r3);
|
|
795
906
|
if (pointer)
|
|
796
907
|
parts.push(L.pointers + '\n' + pointer);
|
|
@@ -923,3 +1034,47 @@ export function handoffTaskFacts(settings, starters, accounts, now, status) {
|
|
|
923
1034
|
out.push('next steps: ' + status.nextSteps.join('; '));
|
|
924
1035
|
return out;
|
|
925
1036
|
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Whether a click on `target` inside a foldable row leaves the row as it is: a control, a tooltip, or anything in
|
|
1039
|
+
* the open details, whose lines (a Same Login row's directories among them) are there to use, not to close the row.
|
|
1040
|
+
*/
|
|
1041
|
+
export function foldSkips(target) {
|
|
1042
|
+
return Boolean(target.closest('button, a, input, select, textarea, .tip, .row-detail'));
|
|
1043
|
+
}
|
|
1044
|
+
/** The layout band for a viewport `width` in CSS pixels: up to 560 phone, up to 760 narrow, up to 1100 medium. */
|
|
1045
|
+
export function widthTier(width) {
|
|
1046
|
+
return width <= 560 ? 'phone' : width <= 760 ? 'narrow' : width <= 1100 ? 'medium' : 'wide';
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Follows a viewport width that changes frame by frame (a window being dragged, a Portal's sidebar sliding open
|
|
1050
|
+
* around the Panel's frame) and calls `apply` with the new band as soon as the width crosses into one, so the layout
|
|
1051
|
+
* moves together with the sliding edge instead of after it. For `settleMs` after that (restarted while the width keeps
|
|
1052
|
+
* moving) it only notes further crossings, then applies the band the width came to rest in if that differs, so one
|
|
1053
|
+
* gesture changes the layout at most twice and never flickers on every frame. Returns the function to call with each
|
|
1054
|
+
* new width.
|
|
1055
|
+
*/
|
|
1056
|
+
export function widthFollower(shown, tierOf, apply, settleMs, timers) {
|
|
1057
|
+
let current = shown;
|
|
1058
|
+
let latest = shown;
|
|
1059
|
+
let timer = null;
|
|
1060
|
+
const settle = () => {
|
|
1061
|
+
timer = null;
|
|
1062
|
+
if (latest === current)
|
|
1063
|
+
return;
|
|
1064
|
+
current = latest;
|
|
1065
|
+
apply(latest);
|
|
1066
|
+
};
|
|
1067
|
+
return (width) => {
|
|
1068
|
+
latest = tierOf(width);
|
|
1069
|
+
if (timer !== null) {
|
|
1070
|
+
timers.clear(timer);
|
|
1071
|
+
timer = timers.set(settle, settleMs);
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
if (latest === current)
|
|
1075
|
+
return;
|
|
1076
|
+
current = latest;
|
|
1077
|
+
apply(latest);
|
|
1078
|
+
timer = timers.set(settle, settleMs);
|
|
1079
|
+
};
|
|
1080
|
+
}
|