kaizen-agent 1.86.0 → 1.87.1
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 +1 -1
- package/cli/annotate-proxy.ts +6 -3
- package/cli/build-web.ts +46 -16
- package/cli/dev.ts +67 -0
- package/cli/docs.ts +1 -1
- package/cli/notes.ts +9 -3
- package/cli/ports.ts +121 -0
- package/cli/settings.ts +16 -17
- package/cli/state.ts +15 -29
- package/cli/task-service.ts +79 -17
- package/cli/tasks.ts +2 -2
- package/cli/term-image.ts +18 -0
- package/cli/ui-audit.allow.json +0 -1
- package/cli/ui-audit.ts +12 -12
- package/cli/web.ts +188 -58
- package/package.json +21 -4
- package/skills/kaizen/spec.md +10 -3
- package/tsconfig.json +16 -0
- package/web/README.md +105 -0
- package/web/{annotate.js → annotate/annotate.ts} +51 -50
- package/web/boot/boot.ts +7 -0
- package/web/components/annotate/annotate-bar.tsx +78 -0
- package/web/components/annotate/annotate-panel.tsx +20 -0
- package/web/components/annotate/annotate-settings.tsx +60 -0
- package/web/components/annotate/index.ts +1 -0
- package/web/components/annotate/notes-list.tsx +75 -0
- package/web/components/board/board-card.tsx +177 -0
- package/web/components/board/board-column.tsx +212 -0
- package/web/components/board/board-mode-switch.tsx +21 -0
- package/web/components/board/board-popups.tsx +45 -0
- package/web/components/board/card-footer.tsx +58 -0
- package/web/components/board/card-form.tsx +168 -0
- package/web/components/board/card-kids.tsx +53 -0
- package/web/components/board/clear-menu.tsx +36 -0
- package/web/components/board/filter-box.tsx +42 -0
- package/web/components/board/index.ts +6 -0
- package/web/components/board/run-form.tsx +129 -0
- package/web/components/board/severity-menu.tsx +44 -0
- package/web/components/board/status-strip.tsx +75 -0
- package/web/components/board/task-form.tsx +140 -0
- package/web/components/board/ws-card.tsx +38 -0
- package/web/components/context/context-panel.tsx +244 -0
- package/web/components/context/index.ts +1 -0
- package/web/components/decision/decision-bar.tsx +422 -0
- package/web/components/decision/index.ts +1 -0
- package/web/components/decision/inline-form.tsx +47 -0
- package/web/components/decision/plan-answers-form.tsx +78 -0
- package/web/components/decision/revise-form.tsx +65 -0
- package/web/components/decision/task-reply-form.tsx +48 -0
- package/web/components/footer/foot-bar.tsx +67 -0
- package/web/components/footer/index.ts +1 -0
- package/web/components/git/git-ask.tsx +88 -0
- package/web/components/git/git-commits.tsx +53 -0
- package/web/components/git/git-confirm.tsx +78 -0
- package/web/components/git/git-counts.tsx +10 -0
- package/web/components/git/git-files.tsx +113 -0
- package/web/components/git/git-head.tsx +70 -0
- package/web/components/git/git-icon.tsx +25 -0
- package/web/components/git/git-message.tsx +44 -0
- package/web/components/git/git-split.tsx +64 -0
- package/web/components/git/git-tab.tsx +55 -0
- package/web/components/git/index.ts +1 -0
- package/web/components/home/chat-list.tsx +57 -0
- package/web/components/home/home-composer.tsx +169 -0
- package/web/components/home/home-message.tsx +120 -0
- package/web/components/home/home-window.tsx +253 -0
- package/web/components/home/home-ws-add.tsx +47 -0
- package/web/components/home/index.ts +6 -0
- package/web/components/home/onboarding-dialog.tsx +371 -0
- package/web/components/icebox/board-chip.tsx +27 -0
- package/web/components/icebox/board-menu.tsx +41 -0
- package/web/components/icebox/bulk-bar.tsx +41 -0
- package/web/components/icebox/capture-box.tsx +155 -0
- package/web/components/icebox/choice-menu.tsx +39 -0
- package/web/components/icebox/collection-dialog.tsx +60 -0
- package/web/components/icebox/favicon.tsx +39 -0
- package/web/components/icebox/index.ts +10 -0
- package/web/components/icebox/kind-label.tsx +22 -0
- package/web/components/icebox/kind-menu.tsx +20 -0
- package/web/components/icebox/promote-form.tsx +93 -0
- package/web/components/icebox/reply-box.tsx +88 -0
- package/web/components/icebox/request-actions.tsx +141 -0
- package/web/components/icebox/request-badges.tsx +13 -0
- package/web/components/icebox/request-card.tsx +99 -0
- package/web/components/icebox/request-detail.tsx +43 -0
- package/web/components/icebox/request-images.tsx +33 -0
- package/web/components/icebox/request-phone-row.tsx +181 -0
- package/web/components/icebox/request-row.tsx +120 -0
- package/web/components/icebox/service-chip.tsx +58 -0
- package/web/components/icebox/snooze-menu.tsx +83 -0
- package/web/components/icebox/source-card.tsx +225 -0
- package/web/components/icebox/source-drawer.tsx +112 -0
- package/web/components/icebox/source-form.tsx +147 -0
- package/web/components/icebox/swipe-deck.tsx +242 -0
- package/web/components/layout/index.ts +1 -0
- package/web/components/layout/page-frame.tsx +44 -0
- package/web/components/markdown/index.ts +1 -0
- package/web/components/markdown/markdown.tsx +156 -0
- package/web/components/notebook/editor-pane.tsx +23 -0
- package/web/components/notebook/index.ts +5 -0
- package/web/components/notebook/note-body.tsx +172 -0
- package/web/components/notebook/note-tree.tsx +99 -0
- package/web/components/notebook/notes-head.tsx +37 -0
- package/web/components/notebook/notes-side.tsx +46 -0
- package/web/components/notes/index.ts +1 -0
- package/web/components/notes/note-composer.tsx +90 -0
- package/web/components/notes/notes-chat.tsx +58 -0
- package/web/components/panes/browser-pane.tsx +281 -0
- package/web/components/panes/index.ts +3 -0
- package/web/components/panes/preview-pane.tsx +91 -0
- package/web/components/panes/terminal-pane.tsx +52 -0
- package/web/components/phone/haptic.tsx +29 -0
- package/web/components/phone/index.ts +6 -0
- package/web/components/phone/phone-card.tsx +118 -0
- package/web/components/phone/phone-home.tsx +304 -0
- package/web/components/phone/phone-sheets.tsx +103 -0
- package/web/components/phone/qr-code.tsx +6 -0
- package/web/components/phone/usage-chips.tsx +85 -0
- package/web/components/phone/whatsapp-card.tsx +85 -0
- package/web/components/project/add-project-dialog.tsx +435 -0
- package/web/components/project/index.ts +3 -0
- package/web/components/project/project-bar.tsx +101 -0
- package/web/components/project/ws-menu.tsx +21 -0
- package/web/components/rail/agent-chips.tsx +110 -0
- package/web/components/rail/index.ts +4 -0
- package/web/components/rail/rail-filter.tsx +118 -0
- package/web/components/rail/rail-list.tsx +259 -0
- package/web/components/rail/source-marks.tsx +21 -0
- package/web/components/resources/index.ts +1 -0
- package/web/components/resources/resources-popup.tsx +490 -0
- package/web/components/run/doc-body.tsx +123 -0
- package/web/components/run/file-viewer.tsx +53 -0
- package/web/components/run/fix-form.tsx +88 -0
- package/web/components/run/index.ts +16 -0
- package/web/components/run/inline-md.tsx +30 -0
- package/web/components/run/key-hint.tsx +29 -0
- package/web/components/run/pane-gutter.tsx +52 -0
- package/web/components/run/pane-header.tsx +35 -0
- package/web/components/run/pane.tsx +140 -0
- package/web/components/run/panel-grip.tsx +49 -0
- package/web/components/run/panel-head.tsx +56 -0
- package/web/components/run/panel-tabs.tsx +35 -0
- package/web/components/run/phase-steps.tsx +37 -0
- package/web/components/run/project-notes.tsx +49 -0
- package/web/components/run/run-add-menu.tsx +80 -0
- package/web/components/run/run-bar.tsx +40 -0
- package/web/components/run/run-empty.tsx +10 -0
- package/web/components/run/run-footer.tsx +53 -0
- package/web/components/run/run-history.tsx +24 -0
- package/web/components/run/run-panes.tsx +78 -0
- package/web/components/run/run-picker.tsx +51 -0
- package/web/components/run/run-progress.tsx +30 -0
- package/web/components/run/run-tabs.tsx +147 -0
- package/web/components/run/run-wait.tsx +18 -0
- package/web/components/search/index.ts +1 -0
- package/web/components/search/search-palette.tsx +159 -0
- package/web/components/settings/account-rows.tsx +128 -0
- package/web/components/settings/agent-rows.tsx +249 -0
- package/web/components/settings/automation-rows.tsx +211 -0
- package/web/components/settings/browser-row.tsx +111 -0
- package/web/components/settings/cleanup-row.tsx +32 -0
- package/web/components/settings/commit-input.tsx +39 -0
- package/web/components/settings/index.ts +4 -0
- package/web/components/settings/integration-row.tsx +158 -0
- package/web/components/settings/mic-row.tsx +48 -0
- package/web/components/settings/orchestration-flow.tsx +87 -0
- package/web/components/settings/setting-row.tsx +131 -0
- package/web/components/settings/settings-item.tsx +78 -0
- package/web/components/settings/settings-loading.tsx +41 -0
- package/web/components/settings/settings-nav.tsx +119 -0
- package/web/components/settings/settings-scope.tsx +66 -0
- package/web/components/settings/settings-section.tsx +33 -0
- package/web/components/settings/skill-card.tsx +131 -0
- package/web/components/settings/stepper.tsx +74 -0
- package/web/components/settings/update-bar.tsx +167 -0
- package/web/components/shared/action-menu.tsx +76 -0
- package/web/components/shared/ask-host.tsx +18 -0
- package/web/components/shared/attach-button.tsx +23 -0
- package/web/components/shared/chip.tsx +19 -0
- package/web/components/shared/client-mark.tsx +15 -0
- package/web/components/shared/confirm-dialog.tsx +35 -0
- package/web/components/shared/empty-state.tsx +29 -0
- package/web/components/shared/field.tsx +77 -0
- package/web/components/shared/filter-popover.tsx +29 -0
- package/web/components/shared/form-frame.tsx +19 -0
- package/web/components/shared/icon-button.tsx +50 -0
- package/web/components/shared/index.ts +18 -0
- package/web/components/shared/mic-button.tsx +75 -0
- package/web/components/shared/pager.tsx +49 -0
- package/web/components/shared/picker.tsx +108 -0
- package/web/components/shared/project-mark.tsx +38 -0
- package/web/components/shared/segmented.tsx +43 -0
- package/web/components/shared/state-dot.tsx +4 -0
- package/web/components/shared/status-mark.tsx +26 -0
- package/web/components/shell/index.ts +3 -0
- package/web/components/shell/rail.tsx +259 -0
- package/web/components/shell/sprite.tsx +124 -0
- package/web/components/shell/wordmark.tsx +13 -0
- package/web/components/task/artifact-view.tsx +148 -0
- package/web/components/task/chat-bubble.tsx +43 -0
- package/web/components/task/filter-menu.tsx +38 -0
- package/web/components/task/index.ts +7 -0
- package/web/components/task/result-checks.tsx +34 -0
- package/web/components/task/result-view.tsx +113 -0
- package/web/components/task/status-badge.tsx +24 -0
- package/web/components/task/task-row.tsx +34 -0
- package/web/components/task/typing-dots.tsx +16 -0
- package/web/components/terminal/index.ts +3 -0
- package/web/components/terminal/terminal-bar.tsx +91 -0
- package/web/components/terminal/terminal-grid.tsx +149 -0
- package/web/components/terminal/terminal-modes.tsx +23 -0
- package/web/components/terminal/terminal-tile.tsx +139 -0
- package/web/dist/annotate.js +24 -0
- package/web/dist/board.css +718 -0
- package/web/dist/board.js +115 -0
- package/web/dist/boot.js +2 -0
- package/web/dist/notebook.css +319 -0
- package/web/dist/notebook.js +89 -0
- package/web/dist/popup.css +41 -0
- package/web/dist/popup.js +13 -0
- package/web/{term.js → dist/term.js} +48 -48
- package/web/dist/ui.css +3 -0
- package/web/dist/video.js +108 -0
- package/web/html/board.html +17 -0
- package/web/html/notes.html +14 -0
- package/web/html/popup.html +13 -0
- package/web/{video.html → html/video.html} +14 -15
- package/web/lib/annotate/index.ts +2 -0
- package/web/lib/annotate/notes.ts +105 -0
- package/web/lib/annotate/page.ts +121 -0
- package/web/lib/annotate/rules.ts +37 -0
- package/web/lib/annotate/session.ts +336 -0
- package/web/lib/board/board-actions.ts +119 -0
- package/web/lib/board/board-open.ts +12 -0
- package/web/lib/board/board-store.ts +159 -0
- package/web/lib/board/filter-box.ts +7 -0
- package/web/lib/board/index.ts +10 -0
- package/web/lib/board/nav.ts +29 -0
- package/web/lib/board/on-state.ts +90 -0
- package/web/lib/board/popups.ts +22 -0
- package/web/lib/board/snapshot.ts +105 -0
- package/web/lib/board/strip.ts +43 -0
- package/web/{board → lib/board}/ws-board.ts +1 -1
- package/web/lib/context/context-rules.ts +27 -0
- package/web/lib/context/context-store.ts +95 -0
- package/web/lib/context/feed.ts +28 -0
- package/web/lib/context/index.ts +3 -0
- package/web/lib/core/api.ts +86 -0
- package/web/lib/core/ask.ts +24 -0
- package/web/lib/core/board.ts +290 -0
- package/web/lib/core/brief.ts +31 -0
- package/web/lib/core/format.ts +8 -0
- package/web/lib/core/host.ts +107 -0
- package/web/lib/core/index.ts +16 -0
- package/web/{board → lib/core}/labels.ts +6 -5
- package/web/lib/core/layers.ts +7 -0
- package/web/lib/core/leave.ts +7 -0
- package/web/lib/core/motion.ts +10 -0
- package/web/{board/toast.ts → lib/core/notices.ts} +2 -20
- package/web/lib/core/notifier.ts +15 -0
- package/web/lib/core/store.ts +39 -0
- package/web/lib/core/term-handle.ts +8 -0
- package/web/lib/core/toast.ts +29 -0
- package/web/lib/core/utils.ts +15 -0
- package/web/lib/decision/index.ts +1 -0
- package/web/lib/decision/plan-questions.ts +39 -0
- package/web/lib/dictation/chunks.ts +93 -0
- package/web/lib/dictation/dictation-store.ts +22 -0
- package/web/lib/dictation/engine.ts +265 -0
- package/web/lib/dictation/index.ts +5 -0
- package/web/lib/dictation/mic.ts +42 -0
- package/web/lib/dictation/terminal-dictation.ts +50 -0
- package/web/lib/footer/footer-rules.ts +13 -0
- package/web/lib/footer/footer-store.ts +42 -0
- package/web/lib/footer/index.ts +2 -0
- package/web/lib/git/git-actions.ts +110 -0
- package/web/lib/git/git-panel.ts +43 -0
- package/web/lib/git/git-store.ts +47 -0
- package/web/lib/git/git.ts +170 -0
- package/web/lib/git/index.ts +4 -0
- package/web/lib/home/home-engine.ts +16 -0
- package/web/lib/home/home-events.ts +9 -0
- package/web/lib/home/home-store.ts +247 -0
- package/web/lib/home/home-window.ts +193 -0
- package/web/lib/home/home.ts +85 -0
- package/web/lib/home/index.ts +7 -0
- package/web/lib/home/onboarding.ts +199 -0
- package/web/lib/home/use-float-drag.ts +62 -0
- package/web/lib/icebox/icebox-actions.ts +518 -0
- package/web/lib/icebox/icebox-store.ts +112 -0
- package/web/lib/icebox/icebox-view.ts +48 -0
- package/web/lib/icebox/icebox.ts +273 -0
- package/web/lib/icebox/index.ts +8 -0
- package/web/lib/icebox/use-card-drag.ts +82 -0
- package/web/lib/icebox/use-ice-keys.ts +75 -0
- package/web/lib/icebox/use-icebox.ts +41 -0
- package/web/lib/icebox/use-row-swipe.ts +107 -0
- package/web/lib/markdown/index.ts +1 -0
- package/web/lib/markdown/markdown.ts +136 -0
- package/web/lib/notebook/autosave.ts +131 -0
- package/web/lib/notebook/deal.ts +58 -0
- package/web/lib/notebook/engine-complete.ts +128 -0
- package/web/lib/notebook/engine-preview.ts +287 -0
- package/web/lib/notebook/engine-types.ts +26 -0
- package/web/lib/notebook/engine-widgets.ts +218 -0
- package/web/lib/notebook/engine.ts +74 -0
- package/web/lib/notebook/index.ts +9 -0
- package/web/lib/notebook/kit-loader.ts +16 -0
- package/web/lib/notebook/kit.ts +12 -0
- package/web/{notes-lib.ts → lib/notebook/text.ts} +11 -10
- package/web/lib/notebook/vault-actions.ts +239 -0
- package/web/lib/notebook/vault-rules.ts +74 -0
- package/web/lib/notebook/vault-session.ts +73 -0
- package/web/lib/notebook/vault-store.ts +63 -0
- package/web/lib/notes/index.ts +4 -0
- package/web/lib/notes/md-html.ts +115 -0
- package/web/lib/notes/notes-actions.ts +32 -0
- package/web/lib/notes/notes-store.ts +22 -0
- package/web/lib/notes/notes.ts +58 -0
- package/web/{board → lib/notes}/rich.ts +1 -2
- package/web/lib/phone/index.ts +7 -0
- package/web/lib/phone/phone-actions.ts +77 -0
- package/web/lib/phone/phone-home.ts +102 -0
- package/web/lib/phone/phone-setup.ts +59 -0
- package/web/lib/phone/phone-sheet.ts +25 -0
- package/web/lib/phone/phone-store.ts +32 -0
- package/web/lib/phone/sheet-swipe.ts +55 -0
- package/web/lib/phone/use-phone-setup.ts +89 -0
- package/web/lib/project/add-project.ts +37 -0
- package/web/lib/project/branch.ts +14 -0
- package/web/lib/project/index.ts +5 -0
- package/web/lib/project/project-bar.ts +76 -0
- package/web/lib/project/project-pick.ts +36 -0
- package/web/lib/project/ws-menu.ts +8 -0
- package/web/lib/rail/agents.ts +63 -0
- package/web/lib/rail/card-links.ts +20 -0
- package/web/lib/rail/index.ts +7 -0
- package/web/lib/rail/rail-actions.ts +74 -0
- package/web/lib/rail/rail-boot.ts +99 -0
- package/web/lib/rail/rail-store.ts +85 -0
- package/web/lib/rail/rules.ts +241 -0
- package/web/lib/rail/source-marks.ts +17 -0
- package/web/lib/rail/use-rank-drag.ts +108 -0
- package/web/lib/resources/index.ts +3 -0
- package/web/lib/resources/resources-actions.ts +59 -0
- package/web/lib/resources/resources-store.ts +48 -0
- package/web/lib/resources/rules.ts +56 -0
- package/web/lib/router/index.ts +3 -0
- package/web/lib/router/route-rules.ts +96 -0
- package/web/lib/router/route-store.ts +115 -0
- package/web/lib/router/use-route-classes.ts +15 -0
- package/web/lib/run/browser.ts +53 -0
- package/web/lib/run/card-terminal.ts +32 -0
- package/web/lib/run/doc.ts +42 -0
- package/web/lib/run/grip.ts +8 -0
- package/web/lib/run/index.ts +19 -0
- package/web/lib/run/kept.ts +58 -0
- package/web/lib/run/layout-store.ts +156 -0
- package/web/lib/run/layout.ts +195 -0
- package/web/lib/run/panel-actions.ts +104 -0
- package/web/lib/run/panel-derive.ts +148 -0
- package/web/lib/run/panel-store.ts +125 -0
- package/web/lib/run/preview.ts +105 -0
- package/web/lib/run/run-actions.ts +118 -0
- package/web/lib/run/run-view-store.ts +134 -0
- package/web/lib/run/term-loader.ts +19 -0
- package/web/lib/run/use-panel-run.ts +125 -0
- package/web/lib/run/use-run-lifecycle.ts +70 -0
- package/web/lib/run/viewer.ts +12 -0
- package/web/lib/run/workspace.ts +281 -0
- package/web/lib/run/ws-actions.ts +293 -0
- package/web/lib/run/ws-derive.ts +50 -0
- package/web/lib/run/ws-draw.ts +102 -0
- package/web/lib/run/ws-store.ts +21 -0
- package/web/lib/run/ws-tabs.ts +125 -0
- package/web/lib/search/index.ts +3 -0
- package/web/lib/search/search-match.ts +48 -0
- package/web/lib/search/search-rows.ts +228 -0
- package/web/lib/search/search.ts +30 -0
- package/web/lib/search/use-search-rows.ts +22 -0
- package/web/lib/server/attention.ts +29 -0
- package/web/lib/server/index.ts +6 -0
- package/web/lib/server/poll-rules.ts +57 -0
- package/web/lib/server/poller.ts +210 -0
- package/web/lib/server/server-store.ts +39 -0
- package/web/lib/server/types.ts +31 -0
- package/web/lib/server/use-server.ts +19 -0
- package/web/lib/settings/agent-favicons.ts +14 -0
- package/web/lib/settings/index.ts +7 -0
- package/web/lib/settings/panel-settings.ts +29 -0
- package/web/lib/settings/settings-actions.ts +357 -0
- package/web/lib/settings/settings-store.ts +114 -0
- package/web/lib/settings/settings.ts +413 -0
- package/web/lib/settings/skill-icons.ts +24 -0
- package/web/lib/settings/update.ts +70 -0
- package/web/lib/shared/data-urls.ts +32 -0
- package/web/lib/shared/index.ts +4 -0
- package/web/lib/shared/use-draft.ts +38 -0
- package/web/lib/shared/use-narrow.ts +11 -0
- package/web/lib/shared/use-pager.ts +24 -0
- package/web/lib/shell/appearance.ts +97 -0
- package/web/lib/shell/help-store.ts +4 -0
- package/web/lib/shell/index.ts +4 -0
- package/web/lib/shell/shell-store.ts +23 -0
- package/web/lib/shell/stored-look.ts +47 -0
- package/web/lib/task/index.ts +7 -0
- package/web/lib/task/task-results.ts +92 -0
- package/web/lib/task/tasks.ts +134 -0
- package/web/lib/task/use-live-frame.ts +85 -0
- package/web/lib/task/use-saved-text.ts +25 -0
- package/web/lib/task/use-task.ts +161 -0
- package/web/lib/task/use-tasks.ts +50 -0
- package/web/{board → lib/task}/zoom.ts +25 -12
- package/web/lib/terminal/hidden-badge.ts +15 -0
- package/web/lib/terminal/index.ts +8 -0
- package/web/lib/terminal/layout.ts +138 -0
- package/web/{term-font.ts → lib/terminal/term-font.ts} +3 -2
- package/web/lib/terminal/terminal-store.ts +65 -0
- package/web/lib/terminal/terms-feed.ts +37 -0
- package/web/lib/terminal/use-arranged.ts +15 -0
- package/web/lib/terminal/use-terminal-keys.ts +37 -0
- package/web/lib/url/index.ts +1 -0
- package/web/lib/url/safe-url.ts +9 -0
- package/web/notebook/notebook.ts +27 -0
- package/web/notebook/notes-lib.ts +3 -0
- package/web/pages/board/App.tsx +76 -0
- package/web/pages/board/header.tsx +83 -0
- package/web/pages/board/help.tsx +59 -0
- package/web/pages/board/host-bridge.ts +94 -0
- package/web/pages/board/host.tsx +19 -0
- package/web/pages/board/keys.ts +112 -0
- package/web/pages/board/live.ts +39 -0
- package/web/pages/board/main.ts +32 -0
- package/web/pages/board/pages.tsx +86 -0
- package/web/pages/board/panel.tsx +157 -0
- package/web/pages/board/portal.tsx +39 -0
- package/web/pages/board/use-boot.ts +13 -0
- package/web/pages/board/views.ts +63 -0
- package/web/pages/board-page.tsx +62 -0
- package/web/pages/home-page.tsx +127 -0
- package/web/pages/icebox-page.tsx +440 -0
- package/web/pages/notebook/App.tsx +35 -0
- package/web/pages/notebook-page.tsx +50 -0
- package/web/pages/popup/App.tsx +207 -0
- package/web/pages/settings-page.tsx +111 -0
- package/web/pages/task-page.tsx +397 -0
- package/web/pages/tasks-page.tsx +151 -0
- package/web/pages/terminal-page.tsx +15 -0
- package/web/popup/popup.ts +7 -0
- package/web/{term.ts → term/term.ts} +48 -20
- package/web/ui/alert-dialog.tsx +39 -0
- package/web/ui/badge.tsx +20 -0
- package/web/ui/button.tsx +37 -0
- package/web/ui/checkbox.tsx +20 -0
- package/web/ui/command.tsx +41 -0
- package/web/ui/dialog.tsx +28 -0
- package/web/ui/dropdown-menu.tsx +54 -0
- package/web/ui/icon.tsx +17 -0
- package/web/ui/index.ts +21 -0
- package/web/ui/input.tsx +9 -0
- package/web/ui/label.tsx +7 -0
- package/web/ui/legacy/board.css +715 -0
- package/web/{notes.html → ui/legacy/notes.css} +23 -157
- package/web/ui/legacy/popup.css +40 -0
- package/web/ui/popover.tsx +28 -0
- package/web/ui/select.tsx +61 -0
- package/web/ui/sheet.tsx +43 -0
- package/web/ui/skeleton.tsx +6 -0
- package/web/ui/sonner.tsx +25 -0
- package/web/ui/spinner.tsx +12 -0
- package/web/ui/switch.tsx +18 -0
- package/web/ui/tabs.tsx +18 -0
- package/web/ui/textarea.tsx +14 -0
- package/web/ui/theme.css +125 -0
- package/web/ui/toggle.tsx +8 -0
- package/web/ui/tooltip.tsx +26 -0
- package/web/{video.ts → video/video.ts} +5 -5
- package/web/board/add-project.ts +0 -147
- package/web/board/agent-favicons.ts +0 -9
- package/web/board/agent-term.ts +0 -51
- package/web/board/annotate-lib.ts +0 -19
- package/web/board/annotate.ts +0 -221
- package/web/board/api.ts +0 -180
- package/web/board/approvals.ts +0 -109
- package/web/board/badge.ts +0 -115
- package/web/board/cards.ts +0 -1080
- package/web/board/chat.ts +0 -128
- package/web/board/context.ts +0 -248
- package/web/board/dictation.ts +0 -343
- package/web/board/dom.ts +0 -132
- package/web/board/drafts.ts +0 -21
- package/web/board/fixes.ts +0 -89
- package/web/board/git.ts +0 -416
- package/web/board/home-ws.ts +0 -266
- package/web/board/home.ts +0 -421
- package/web/board/icebox.ts +0 -1788
- package/web/board/keys.ts +0 -121
- package/web/board/live.ts +0 -87
- package/web/board/main.ts +0 -94
- package/web/board/markdown.ts +0 -210
- package/web/board/onboarding.ts +0 -227
- package/web/board/panel.ts +0 -437
- package/web/board/phone-setup.ts +0 -79
- package/web/board/phone.ts +0 -219
- package/web/board/projects.ts +0 -277
- package/web/board/resources.ts +0 -170
- package/web/board/run-pick.ts +0 -41
- package/web/board/run-view.ts +0 -1316
- package/web/board/search-match.ts +0 -20
- package/web/board/search.ts +0 -330
- package/web/board/settings-accounts.ts +0 -76
- package/web/board/settings-agents.ts +0 -102
- package/web/board/settings-automations.ts +0 -71
- package/web/board/settings-cleanup.ts +0 -42
- package/web/board/settings-orchestration.ts +0 -32
- package/web/board/settings-pages.ts +0 -62
- package/web/board/settings-skills.ts +0 -103
- package/web/board/settings-voice.ts +0 -28
- package/web/board/settings.ts +0 -490
- package/web/board/store.ts +0 -47
- package/web/board/task-page.ts +0 -628
- package/web/board/task-results.ts +0 -234
- package/web/board/tasks.ts +0 -242
- package/web/board/terms.ts +0 -390
- package/web/board/update.ts +0 -171
- package/web/board/viewer.ts +0 -47
- package/web/board/views.ts +0 -164
- package/web/board/whatsapp-setup.ts +0 -149
- package/web/board/workspace.ts +0 -650
- package/web/board/ws-board-ui.ts +0 -95
- package/web/board/ws-tabs.ts +0 -227
- package/web/board.html +0 -1563
- package/web/board.js +0 -505
- package/web/notebook.js +0 -519
- package/web/notebook.ts +0 -1254
- package/web/popup.html +0 -141
- package/web/video.js +0 -575
- /package/web/{term.css → dist/term.css} +0 -0
- /package/web/{board/term-sessions.ts → lib/terminal/sessions.ts} +0 -0
- /package/web/{board/terminal-viewport.ts → lib/terminal/viewport.ts} +0 -0
- /package/web/{term-paste.ts → term/term-paste.ts} +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// One open task: fetch and poll it, and every action the page can take. Both hold the exact request logic of
|
|
2
|
+
// the old task page (revision and operationId on every /task call, stale-answer guards, the draft's stable
|
|
3
|
+
// operation id), so another page showing the same decision calls the same code.
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { getTask, taskRequest, host, getStore, setStore } from "@lib/core";
|
|
6
|
+
import { getRoute } from "@lib/router";
|
|
7
|
+
import { getServer, onState, setTasks } from "@lib/server";
|
|
8
|
+
import { taskHref, type TaskView } from "./tasks.ts";
|
|
9
|
+
|
|
10
|
+
const operationId = () => crypto.randomUUID();
|
|
11
|
+
export const readDraft = (key: string) => {
|
|
12
|
+
try {
|
|
13
|
+
return sessionStorage.getItem("kz-task:" + key) || "";
|
|
14
|
+
} catch {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const saveDraft = (key: string, text: string) => {
|
|
19
|
+
try {
|
|
20
|
+
sessionStorage.setItem("kz-task:" + key, text);
|
|
21
|
+
} catch {}
|
|
22
|
+
};
|
|
23
|
+
export function navigateTask(t: Pick<TaskView, "id" | "dir">, replace = false) {
|
|
24
|
+
(replace ? history.replaceState : history.pushState).call(history, null, "", taskHref(t));
|
|
25
|
+
host.go("task");
|
|
26
|
+
}
|
|
27
|
+
export async function openTaskRecord(t: TaskView) {
|
|
28
|
+
if (t.legacy) {
|
|
29
|
+
const r = await taskRequest({ op: "adopt", dir: t.dir, legacy: t.legacy, operationId: operationId() });
|
|
30
|
+
if (r.ok && r.task) return navigateTask(r.task);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
navigateTask(t);
|
|
34
|
+
}
|
|
35
|
+
// The page the address names. A different task starts empty; the same one keeps what it shows while it reloads.
|
|
36
|
+
export function showTask() {
|
|
37
|
+
const p = new URLSearchParams(location.search),
|
|
38
|
+
id = p.get("task") || "",
|
|
39
|
+
dir = p.get("dir") || "";
|
|
40
|
+
const s = getStore();
|
|
41
|
+
if (id !== s.taskId || dir !== s.taskDir)
|
|
42
|
+
setStore({
|
|
43
|
+
taskId: id,
|
|
44
|
+
taskDir: dir,
|
|
45
|
+
page: null,
|
|
46
|
+
pageError: "",
|
|
47
|
+
pending: false,
|
|
48
|
+
receipt: "",
|
|
49
|
+
draft: readDraft(id),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let generation = 0;
|
|
54
|
+
export async function refreshTask() {
|
|
55
|
+
const { taskId: id, taskDir: dir } = getStore();
|
|
56
|
+
if (!id) return;
|
|
57
|
+
const gen = ++generation;
|
|
58
|
+
try {
|
|
59
|
+
const { ok, body: next } = await getTask(id, dir);
|
|
60
|
+
const now = getStore();
|
|
61
|
+
if (gen !== generation || id !== now.taskId || getRoute().page !== "task") return;
|
|
62
|
+
if (!ok || !next.task) {
|
|
63
|
+
if (!now.page) setStore({ pageError: next.why || next.error || "Refresh or return to Tasks." });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (now.page && next.task.revision < now.page.task.revision) return;
|
|
67
|
+
setStore({ page: next, pageError: "" });
|
|
68
|
+
const rest = (getServer().tasks ?? []) as TaskView[];
|
|
69
|
+
setTasks([...rest.filter((t) => t.id !== next.task.id || t.dir !== next.task.dir), next.task]);
|
|
70
|
+
} catch {
|
|
71
|
+
if (!getStore().page) setStore({ pageError: "offline" });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Mounted while the task page shows: load now, then every 4 seconds and on every board state tick.
|
|
75
|
+
export function useTask() {
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
void refreshTask();
|
|
78
|
+
let timer: ReturnType<typeof setTimeout>;
|
|
79
|
+
const poll = () => {
|
|
80
|
+
void refreshTask();
|
|
81
|
+
timer = setTimeout(poll, 4000);
|
|
82
|
+
};
|
|
83
|
+
timer = setTimeout(poll, 4000);
|
|
84
|
+
const tick = () => void refreshTask();
|
|
85
|
+
const off = onState(tick);
|
|
86
|
+
return () => {
|
|
87
|
+
generation++;
|
|
88
|
+
clearTimeout(timer);
|
|
89
|
+
off();
|
|
90
|
+
};
|
|
91
|
+
}, []);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const RECEIPTS: Record<string, string> = {
|
|
95
|
+
stop: "Cancellation requested. Waiting for confirmation; saved files are not rolled back.",
|
|
96
|
+
accept: "Result accepted. It has not been published by this action.",
|
|
97
|
+
confirm: "Plan approved.",
|
|
98
|
+
};
|
|
99
|
+
// One /task operation. Never two at once; a task that changed identity under it is followed.
|
|
100
|
+
export async function runAction(op: string, extra: Record<string, unknown> = {}) {
|
|
101
|
+
const { page, pending } = getStore();
|
|
102
|
+
if (pending || !page) return;
|
|
103
|
+
setStore({ pending: true });
|
|
104
|
+
const request = {
|
|
105
|
+
op,
|
|
106
|
+
id: page.task.id,
|
|
107
|
+
dir: page.task.dir,
|
|
108
|
+
operationId: operationId(),
|
|
109
|
+
revision: page.task.revision,
|
|
110
|
+
...extra,
|
|
111
|
+
};
|
|
112
|
+
const r = await taskRequest(request);
|
|
113
|
+
setStore({ pending: false });
|
|
114
|
+
const { taskId, taskDir, page: cur } = getStore();
|
|
115
|
+
if (r.task && r.ok) {
|
|
116
|
+
if (r.task.dir !== taskDir || r.task.id !== taskId) return navigateTask(r.task, true);
|
|
117
|
+
if (cur) setStore({ page: { ...cur, task: r.task } });
|
|
118
|
+
}
|
|
119
|
+
if (r.ok) setStore({ receipt: RECEIPTS[op] ?? "Saved." });
|
|
120
|
+
await refreshTask();
|
|
121
|
+
if (r.conflict)
|
|
122
|
+
setStore({
|
|
123
|
+
receipt:
|
|
124
|
+
"This task changed. Your message is still saved. Review the current result and send it again when ready.",
|
|
125
|
+
});
|
|
126
|
+
return r;
|
|
127
|
+
}
|
|
128
|
+
export const setDraft = (text: string) => {
|
|
129
|
+
setStore({ draft: text });
|
|
130
|
+
saveDraft(getStore().taskId, text);
|
|
131
|
+
};
|
|
132
|
+
// Send the composer's text. The same text for the same result and decision reuses one operation id, so a retry
|
|
133
|
+
// after a lost answer cannot send it twice. `selected` is the result the page shows.
|
|
134
|
+
export async function sendMessage(selected: string) {
|
|
135
|
+
const { draft, page, pending, taskId } = getStore();
|
|
136
|
+
const text = draft.trim();
|
|
137
|
+
if (!text || pending || !page) return false;
|
|
138
|
+
const baseResultId = selected || page.task.currentResultId || null;
|
|
139
|
+
const identity = JSON.stringify([text, baseResultId, page.task.decision?.id, "auto"]);
|
|
140
|
+
let saved;
|
|
141
|
+
try {
|
|
142
|
+
saved = JSON.parse(readDraft(taskId + ":operation"));
|
|
143
|
+
} catch {}
|
|
144
|
+
const messageOperation = saved?.identity === identity ? saved.id : operationId();
|
|
145
|
+
saveDraft(taskId + ":operation", JSON.stringify({ identity, id: messageOperation }));
|
|
146
|
+
const r = await runAction("message", {
|
|
147
|
+
operationId: messageOperation,
|
|
148
|
+
text,
|
|
149
|
+
intent: "auto",
|
|
150
|
+
baseResultId,
|
|
151
|
+
decisionId: page.task.decision?.id,
|
|
152
|
+
});
|
|
153
|
+
// Typing while it was sending keeps what was typed.
|
|
154
|
+
if (r?.ok && getStore().draft === draft) {
|
|
155
|
+
setDraft("");
|
|
156
|
+
saveDraft(taskId + ":operation", "");
|
|
157
|
+
setStore({ receipt: "Message received. Follow its receipt in the conversation." });
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// The Tasks list: fetch, refresh on the board's state ticks, one request at a time (a second asks for one more
|
|
2
|
+
// round, a stale answer is dropped). Every redraw is React's, so an open filter or a press in progress is never
|
|
3
|
+
// disturbed by a refresh.
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { useShallow } from "zustand/react/shallow";
|
|
6
|
+
import { getTasks, host, setStore, useStore } from "@lib/core";
|
|
7
|
+
import { getRoute } from "@lib/router";
|
|
8
|
+
import { onState, setTasks } from "@lib/server";
|
|
9
|
+
|
|
10
|
+
let sequence = 0,
|
|
11
|
+
loading = false,
|
|
12
|
+
again = false;
|
|
13
|
+
export async function refreshTasks() {
|
|
14
|
+
if (getRoute().page !== "tasks") return;
|
|
15
|
+
if (loading) {
|
|
16
|
+
again = true;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
loading = true;
|
|
20
|
+
do {
|
|
21
|
+
again = false;
|
|
22
|
+
const gen = ++sequence;
|
|
23
|
+
try {
|
|
24
|
+
const items = await getTasks();
|
|
25
|
+
if (gen !== sequence || getRoute().page !== "tasks") continue;
|
|
26
|
+
setStore({ tasks: items, tasksLoaded: true, tasksError: "" });
|
|
27
|
+
setTasks(items);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
if (getRoute().page === "tasks")
|
|
30
|
+
setStore({ tasksError: e instanceof Error ? e.message : "Tasks could not be loaded" });
|
|
31
|
+
}
|
|
32
|
+
} while (again);
|
|
33
|
+
loading = false;
|
|
34
|
+
}
|
|
35
|
+
// Mounted while the Tasks page shows.
|
|
36
|
+
export function useTasks() {
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const tick = () => {
|
|
39
|
+
setStore({ scope: host.scopeDir() });
|
|
40
|
+
void refreshTasks();
|
|
41
|
+
};
|
|
42
|
+
tick();
|
|
43
|
+
const off = onState(tick);
|
|
44
|
+
return () => {
|
|
45
|
+
off();
|
|
46
|
+
sequence++; // an answer still on its way is dropped
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
return useStore(useShallow((s) => ({ tasks: s.tasks, loaded: s.tasksLoaded, error: s.tasksError, scope: s.scope })));
|
|
50
|
+
}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
// Pinch, wheel, drag and double-click zoom for a task result image. One box, one image:
|
|
2
2
|
// the image fills the box (object-fit: contain) and a transform moves it.
|
|
3
|
-
const MIN = 1,
|
|
3
|
+
const MIN = 1,
|
|
4
|
+
MAX = 8;
|
|
4
5
|
|
|
5
6
|
export function wireZoom(root: ParentNode) {
|
|
6
7
|
root.querySelectorAll<HTMLElement>(".tp-zoom:not([data-zoom])").forEach((box) => {
|
|
7
8
|
const img = box.querySelector<HTMLElement>("img");
|
|
8
9
|
if (!img) return;
|
|
9
10
|
box.dataset.zoom = "1";
|
|
10
|
-
let s = 1,
|
|
11
|
+
let s = 1,
|
|
12
|
+
x = 0,
|
|
13
|
+
y = 0;
|
|
11
14
|
const pts = new Map<number, { x: number; y: number }>();
|
|
12
|
-
let pinch = 0,
|
|
15
|
+
let pinch = 0,
|
|
16
|
+
moved = false;
|
|
13
17
|
const label = box.querySelector<HTMLElement>("[data-zoom-reset]");
|
|
14
18
|
const apply = () => {
|
|
15
|
-
const w = box.clientWidth,
|
|
19
|
+
const w = box.clientWidth,
|
|
20
|
+
h = box.clientHeight;
|
|
16
21
|
x = Math.min(0, Math.max(w - w * s, x));
|
|
17
22
|
y = Math.min(0, Math.max(h - h * s, y));
|
|
18
23
|
img.style.transform = `translate(${x}px,${y}px) scale(${s})`;
|
|
@@ -35,12 +40,16 @@ export function wireZoom(root: ParentNode) {
|
|
|
35
40
|
const [a, b] = [...pts.values()];
|
|
36
41
|
return { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2, d: Math.hypot(a.x - b.x, a.y - b.y) };
|
|
37
42
|
};
|
|
38
|
-
box.addEventListener(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
box.addEventListener(
|
|
44
|
+
"wheel",
|
|
45
|
+
(e) => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
const p = local(e);
|
|
48
|
+
// A trackpad pinch arrives as a wheel with ctrlKey and small deltas.
|
|
49
|
+
zoomAt(p.x, p.y, s * Math.exp(-e.deltaY * (e.ctrlKey ? 0.01 : 0.0015)));
|
|
50
|
+
},
|
|
51
|
+
{ passive: false },
|
|
52
|
+
);
|
|
44
53
|
box.addEventListener("pointerdown", (e) => {
|
|
45
54
|
if ((e.target as HTMLElement).closest("button")) return;
|
|
46
55
|
box.setPointerCapture(e.pointerId);
|
|
@@ -81,8 +90,12 @@ export function wireZoom(root: ParentNode) {
|
|
|
81
90
|
if (s > 1) zoomAt(p.x, p.y, 1);
|
|
82
91
|
else zoomAt(p.x, p.y, 2.5);
|
|
83
92
|
});
|
|
84
|
-
box
|
|
85
|
-
|
|
93
|
+
box
|
|
94
|
+
.querySelector("[data-zoom-in]")
|
|
95
|
+
?.addEventListener("click", () => zoomAt(box.clientWidth / 2, box.clientHeight / 2, s * 1.5));
|
|
96
|
+
box
|
|
97
|
+
.querySelector("[data-zoom-out]")
|
|
98
|
+
?.addEventListener("click", () => zoomAt(box.clientWidth / 2, box.clientHeight / 2, s / 1.5));
|
|
86
99
|
label?.addEventListener("click", () => zoomAt(box.clientWidth / 2, box.clientHeight / 2, 1));
|
|
87
100
|
new ResizeObserver(apply).observe(box);
|
|
88
101
|
apply();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useServer } from "@lib/server";
|
|
3
|
+
import { hiddenCount } from "./layout.ts";
|
|
4
|
+
import { terminalSessions } from "./sessions.ts";
|
|
5
|
+
import { useTerminals } from "./terminal-store.ts";
|
|
6
|
+
|
|
7
|
+
// The side menu's Terminal entry counts the tiles hidden on the Terminal page, on every page: the sessions the server lists
|
|
8
|
+
// (every project's cards, else this page's) against the saved layout. The Notebook never loads a /state, so it shows none.
|
|
9
|
+
export function useHiddenTerminals() {
|
|
10
|
+
const lay = useTerminals((s) => s.lay),
|
|
11
|
+
cards = useServer((s) => s.every?.cards ?? s.state.cards),
|
|
12
|
+
shells = useServer((s) => s.shells),
|
|
13
|
+
loaded = useServer((s) => s.loaded);
|
|
14
|
+
return useMemo(() => (loaded ? hiddenCount(terminalSessions(cards, shells), lay) : 0), [loaded, cards, shells, lay]);
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./layout.ts";
|
|
2
|
+
export * from "./terminal-store.ts";
|
|
3
|
+
export * from "./use-terminal-keys.ts";
|
|
4
|
+
export * from "./use-arranged.ts";
|
|
5
|
+
export * from "./sessions.ts";
|
|
6
|
+
export * from "./hidden-badge.ts";
|
|
7
|
+
export * from "./terms-feed.ts";
|
|
8
|
+
export * from "./term-font.ts";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// The Terminal page's rules, with no DOM: every in-card agent session the board knows, tiled. Which tiles show and in
|
|
2
|
+
// what order, the grid's shape, the track sizes and where a border handle sits, and how a drag changes the sizes.
|
|
3
|
+
// ponytail: a √n grid with draggable borders, not an i3-style split tree; add one if a grid falls short.
|
|
4
|
+
|
|
5
|
+
// grid (√n), cols (side by side) or rows (stacked, so borders drag up and down).
|
|
6
|
+
export type Mode = "grid" | "cols" | "rows";
|
|
7
|
+
export const MODES: [Mode, string, string][] = [
|
|
8
|
+
["grid", "Grid", "lgrid"],
|
|
9
|
+
["cols", "Side by side", "lcols"],
|
|
10
|
+
["rows", "Stacked", "lrows"],
|
|
11
|
+
];
|
|
12
|
+
export type Sizes = { c: number[]; r: number[] };
|
|
13
|
+
// Layout is per browser (kz-terms): tile order, hidden tiles, the maximised one, and the split sizes per grid shape.
|
|
14
|
+
export type Lay = { mode: Mode; order: string[]; hidden: string[]; max: string | null; sizes: Record<string, Sizes> };
|
|
15
|
+
export const LAY_KEY = "kz-terms";
|
|
16
|
+
export const GAP = 1;
|
|
17
|
+
// One session: a card with an agent in the board (run or task) or a shell, as terminalSessions() makes it.
|
|
18
|
+
export type Session = {
|
|
19
|
+
kind: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
text?: string;
|
|
22
|
+
where?: string;
|
|
23
|
+
state?: string;
|
|
24
|
+
pty: { key: string; alive: boolean; asking: boolean };
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const EMPTY: Lay = { mode: "grid", order: [], hidden: [], max: null, sizes: {} };
|
|
28
|
+
export function readLay(raw: string | null): Lay {
|
|
29
|
+
try {
|
|
30
|
+
const l = { ...EMPTY, ...JSON.parse(raw || "{}") } as Lay;
|
|
31
|
+
return MODES.some((m) => m[0] === l.mode) ? l : { ...l, mode: "grid" };
|
|
32
|
+
} catch {
|
|
33
|
+
return EMPTY;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Only the last 100 keys are kept.
|
|
37
|
+
export const trimLay = (l: Lay): Lay => ({ ...l, order: l.order.slice(-100), hidden: l.hidden.slice(-100) });
|
|
38
|
+
|
|
39
|
+
// The header: run name - project name. A run's name is its id without the date, as card chips name runs.
|
|
40
|
+
export const nameOf = (c: Session) =>
|
|
41
|
+
c.kind === "run"
|
|
42
|
+
? String(c.id || c.text)
|
|
43
|
+
.replace(/^\d{4}-\d\d-\d\d-/, "")
|
|
44
|
+
.replace(/-/g, " ")
|
|
45
|
+
: String(c.text).split("\n")[0]!.slice(0, 80);
|
|
46
|
+
export const stateOf = (c: Session) => (!c.pty.alive ? "ended" : c.pty.asking ? "asking" : "running");
|
|
47
|
+
export const projOf = (c: Session) =>
|
|
48
|
+
String(c.where || "")
|
|
49
|
+
.split(/[\\/]/)
|
|
50
|
+
.filter(Boolean)
|
|
51
|
+
.pop() ||
|
|
52
|
+
c.where ||
|
|
53
|
+
"";
|
|
54
|
+
export const labelOf = (c: Session) => `${nameOf(c)} - ${projOf(c)}`;
|
|
55
|
+
|
|
56
|
+
export type Arranged = {
|
|
57
|
+
keys: string[]; // the tiles that show: live first, ended after, each in the saved order
|
|
58
|
+
hid: string[]; // the hidden live ones (the bar's chips); an ended one closed with × has nothing to come back to
|
|
59
|
+
order: string[]; // the saved order, with the keys not seen before at its end
|
|
60
|
+
max: string | null; // the maximised tile, if it still shows
|
|
61
|
+
one: string | null; // the one tile showing: on a phone the tab picked (the first by default), else the maximised one
|
|
62
|
+
};
|
|
63
|
+
export function arrange(all: Map<string, Session>, lay: Lay, phone: boolean, pick: string | null): Arranged {
|
|
64
|
+
const rank = (k: string) => (lay.order.includes(k) ? lay.order.indexOf(k) : 1e9);
|
|
65
|
+
const ended = (k: string) => (all.get(k)!.pty.alive ? 0 : 1);
|
|
66
|
+
const keys = [...all.keys()]
|
|
67
|
+
.filter((k) => !lay.hidden.includes(k))
|
|
68
|
+
.sort((a, b) => ended(a) - ended(b) || rank(a) - rank(b));
|
|
69
|
+
const order = [...lay.order, ...keys.filter((k) => !lay.order.includes(k))];
|
|
70
|
+
const max = lay.max && keys.includes(lay.max) ? lay.max : null;
|
|
71
|
+
return {
|
|
72
|
+
keys,
|
|
73
|
+
hid: [...all.keys()].filter((k) => lay.hidden.includes(k) && all.get(k)!.pty.alive),
|
|
74
|
+
order,
|
|
75
|
+
max,
|
|
76
|
+
one: phone ? (pick && keys.includes(pick) ? pick : (keys[0] ?? null)) : max,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// The side menu's Terminal entry counts the live tiles hidden here.
|
|
80
|
+
export const hiddenCount = (all: Map<string, Session>, lay: Lay) =>
|
|
81
|
+
lay.hidden.filter((k) => all.get(k)?.pty.alive).length;
|
|
82
|
+
// Two tiles swap places (a header dropped on another tile); null when either is not in the order.
|
|
83
|
+
export function swapOrder(order: string[], from: string, to: string): string[] | null {
|
|
84
|
+
const i = order.indexOf(from),
|
|
85
|
+
j = order.indexOf(to);
|
|
86
|
+
if (i < 0 || j < 0 || i === j) return null;
|
|
87
|
+
const out = [...order];
|
|
88
|
+
[out[i], out[j]] = [out[j]!, out[i]!];
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type Shape = { cols: number; rows: number; spanFrom: number; key: string; span: number };
|
|
93
|
+
// Grid is √n, the last tile spanning what its row leaves empty; side by side is one row, stacked one column.
|
|
94
|
+
// `span`: how many columns the last tile covers; `spanFrom`: the column where it starts, right of which the borders are
|
|
95
|
+
// not inner ones in that row.
|
|
96
|
+
export function shapeOf(n: number, mode: Mode, one: boolean): Shape {
|
|
97
|
+
const count = one ? 1 : Math.max(1, n),
|
|
98
|
+
cols = mode === "cols" ? count : mode === "rows" ? 1 : Math.ceil(Math.sqrt(count)),
|
|
99
|
+
rows = Math.ceil(count / cols);
|
|
100
|
+
const span = !one && cols * rows > count ? cols * rows - count + 1 : 1;
|
|
101
|
+
return {
|
|
102
|
+
cols,
|
|
103
|
+
rows,
|
|
104
|
+
spanFrom: span > 1 ? count - (rows - 1) * cols - 1 : cols,
|
|
105
|
+
key: `${mode}:${cols}x${rows}`,
|
|
106
|
+
span,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// Saved sizes only count when they fit the shape's track count.
|
|
110
|
+
export function sizesOf(saved: Sizes | undefined, s: Shape): Sizes {
|
|
111
|
+
return {
|
|
112
|
+
c: saved?.c?.length === s.cols ? saved.c : Array(s.cols).fill(1),
|
|
113
|
+
r: saved?.r?.length === s.rows ? saved.r : Array(s.rows).fill(1),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Track sizes are in fr, and a handle sits on each inner border: its centre is the tracks before it sharing
|
|
118
|
+
// (100% - gaps) by their fr, plus the gaps before it.
|
|
119
|
+
export const handleAt = (tr: number[], i: number) => {
|
|
120
|
+
const F = tr.reduce((a, b) => a + b, 0),
|
|
121
|
+
S = tr.slice(0, i + 1).reduce((a, b) => a + b, 0);
|
|
122
|
+
return `calc((100% - ${(tr.length - 1) * GAP}px) * ${S / F} + ${i * GAP + GAP / 2}px)`;
|
|
123
|
+
};
|
|
124
|
+
// A column handle stops above the last row where that row's spanning tile covers the border.
|
|
125
|
+
export const handleBottom = (r: number[], i: number, spanFrom: number) =>
|
|
126
|
+
i >= spanFrom ? `calc(100% - ${handleAt(r, r.length - 2)} + ${GAP / 2}px)` : "0px";
|
|
127
|
+
// The tracks after dragging the border between track i and i+1 by `delta` px over `span` px: neither gets under a tenth.
|
|
128
|
+
export function dragTracks(tr: number[], i: number, delta: number, span: number): number[] {
|
|
129
|
+
const F = tr.reduce((a, b) => a + b, 0),
|
|
130
|
+
min = F * 0.1,
|
|
131
|
+
a = tr[i]!,
|
|
132
|
+
b = tr[i + 1]!;
|
|
133
|
+
const d = Math.max(min - a, Math.min(b - min, (delta / span) * F));
|
|
134
|
+
const out = [...tr];
|
|
135
|
+
out[i] = a + d;
|
|
136
|
+
out[i + 1] = b - d;
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { KzTerm } from "@lib/core";
|
|
1
2
|
// The board terminals' font size, one per browser. Its own module so the bounds are testable
|
|
2
3
|
// without xterm and Settings can share them without loading the terminal bundle.
|
|
3
4
|
export const FONT_MIN = 8;
|
|
@@ -12,12 +13,12 @@ export function fontRead(): number {
|
|
|
12
13
|
return FONT_BASE;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
// Every mounted terminal
|
|
16
|
+
// Every mounted terminal takes the new size (term.js holds them: window.kzTerm.font), so it holds across tiles and panes.
|
|
16
17
|
export function fontSet(n: number) {
|
|
17
18
|
try {
|
|
18
19
|
localStorage.setItem("kz-term-font", String(n));
|
|
19
20
|
} catch {}
|
|
20
|
-
|
|
21
|
+
(globalThis as { kzTerm?: KzTerm }).kzTerm?.font(n);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
// The size a key leads to, or null when the key is not a font key.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// The Terminal page as state (Zustand): the sessions the board knows (pushed by board/terms.ts on every change), the saved
|
|
2
|
+
// layout (kz-terms, persisted on each change) and the page's own picks. The rules are in layout.ts.
|
|
3
|
+
import { create } from "zustand";
|
|
4
|
+
import { LAY_KEY, readLay, swapOrder, trimLay, type Lay, type Mode, type Session, type Sizes } from "./layout.ts";
|
|
5
|
+
|
|
6
|
+
export type TerminalState = {
|
|
7
|
+
showing: boolean; // the Terminal page is the view
|
|
8
|
+
seen: boolean; // it has been opened: its tiles are mounted from then on and only hidden (by CSS) on other pages
|
|
9
|
+
all: Map<string, Session>;
|
|
10
|
+
lay: Lay;
|
|
11
|
+
pick: string | null; // a phone shows one terminal at a time, picked from tabs; per visit
|
|
12
|
+
};
|
|
13
|
+
const read = () => {
|
|
14
|
+
try {
|
|
15
|
+
return readLay(localStorage.getItem(LAY_KEY));
|
|
16
|
+
} catch {
|
|
17
|
+
return readLay(null);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export const useTerminals = create<TerminalState>()(() => ({
|
|
21
|
+
showing: false,
|
|
22
|
+
seen: false,
|
|
23
|
+
all: new Map(),
|
|
24
|
+
lay: typeof localStorage === "undefined" ? readLay(null) : read(),
|
|
25
|
+
pick: null,
|
|
26
|
+
}));
|
|
27
|
+
export const setTerminals = useTerminals.setState;
|
|
28
|
+
|
|
29
|
+
// What the page asks of the old code: read the board again (a session ended), and Resume (the board opens the card on its
|
|
30
|
+
// new session; the new tile shows it).
|
|
31
|
+
export const terminalActions: { reload: () => void; resume: (c: Session) => Promise<boolean> } = {
|
|
32
|
+
reload: () => {},
|
|
33
|
+
resume: async () => false,
|
|
34
|
+
};
|
|
35
|
+
export const setTerminalActions = (a: typeof terminalActions) => Object.assign(terminalActions, a);
|
|
36
|
+
|
|
37
|
+
// Every layout change is saved at once.
|
|
38
|
+
function lay(f: (l: Lay) => Lay) {
|
|
39
|
+
const next = trimLay(f(useTerminals.getState().lay));
|
|
40
|
+
try {
|
|
41
|
+
localStorage.setItem(LAY_KEY, JSON.stringify(next));
|
|
42
|
+
} catch {}
|
|
43
|
+
useTerminals.setState({ lay: next });
|
|
44
|
+
}
|
|
45
|
+
export const terminalLayout = {
|
|
46
|
+
mode: (mode: Mode) => lay((l) => ({ ...l, mode, max: null })),
|
|
47
|
+
// The tile asked for is maximised, or restored when it already is.
|
|
48
|
+
toggleMax: (key: string) => lay((l) => ({ ...l, max: l.max === key ? null : key })),
|
|
49
|
+
// Only a tile that is not maximised or one already is a no-op (Alt+N on a maximised page switches which).
|
|
50
|
+
maxOn: (key: string) => lay((l) => (l.max && l.max !== key ? { ...l, max: key } : l)),
|
|
51
|
+
hide: (key: string) => lay((l) => ({ ...l, hidden: [...l.hidden, key], max: l.max === key ? null : l.max })),
|
|
52
|
+
show: (key: string) => lay((l) => ({ ...l, hidden: l.hidden.filter((k) => k !== key) })),
|
|
53
|
+
// `order` is the arranged order, so a tile never seen before can be swapped too.
|
|
54
|
+
swap: (order: string[], from: string, to: string) => {
|
|
55
|
+
const next = swapOrder(order, from, to);
|
|
56
|
+
if (next) lay((l) => ({ ...l, order: next }));
|
|
57
|
+
},
|
|
58
|
+
// A tile seen for the first time takes its place at the end and keeps it: a run that sorts earlier later does not move the rest.
|
|
59
|
+
see: (order: string[]) => {
|
|
60
|
+
const seen = useTerminals.getState().lay.order;
|
|
61
|
+
if (order.slice(-100).some((k) => !seen.includes(k))) lay((l) => ({ ...l, order }));
|
|
62
|
+
},
|
|
63
|
+
sizes: (shape: string, s: Sizes) => lay((l) => ({ ...l, sizes: { ...l.sizes, [shape]: s } })),
|
|
64
|
+
};
|
|
65
|
+
export const pickTerminal = (pick: string | null) => useTerminals.setState({ pick });
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { load } from "@lib/server";
|
|
2
|
+
import { resumeRun, setPanel } from "@lib/run";
|
|
3
|
+
import { getServer, onServer, refreshEvery } from "@lib/server";
|
|
4
|
+
import { setTerminalActions, setTerminals, useTerminals } from "./terminal-store.ts";
|
|
5
|
+
import { terminalSessions } from "./sessions.ts";
|
|
6
|
+
|
|
7
|
+
// ---- the Terminal page: every in-card agent session the board knows, Tasks to Done, tiled. The page is React
|
|
8
|
+
// (pages/terminal-page.tsx over components/terminal and lib/terminal); this module only feeds it the sessions (the side
|
|
9
|
+
// menu's Terminal badge reads the same store, components/shell/rail.tsx). One card per session; the newest card wins a shared key.
|
|
10
|
+
const sessions = () => terminalSessions(getServer().every?.cards ?? getServer().state.cards, getServer().shells);
|
|
11
|
+
const push = () => setTerminals({ all: sessions() });
|
|
12
|
+
|
|
13
|
+
export function termsStop() {
|
|
14
|
+
setTerminals({ showing: false });
|
|
15
|
+
}
|
|
16
|
+
export function openTerms() {
|
|
17
|
+
if (!useTerminals.getState().showing) void refreshEvery();
|
|
18
|
+
setTerminals({ showing: true, seen: true, all: sessions() });
|
|
19
|
+
}
|
|
20
|
+
// /state ticks, the footer's /shells read and the all-project snapshot each change what the page lists.
|
|
21
|
+
export const termsChanged = () => {
|
|
22
|
+
if (useTerminals.getState().seen) push();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function initTerms() {
|
|
26
|
+
onServer((s) => s.shells, termsChanged);
|
|
27
|
+
onServer((s) => s.every, termsChanged);
|
|
28
|
+
// Resume: the board opens the card on its new session; here the new tile shows it.
|
|
29
|
+
setTerminalActions({
|
|
30
|
+
reload: () => void load(true),
|
|
31
|
+
resume: async (c) => {
|
|
32
|
+
const ok = await resumeRun(c);
|
|
33
|
+
setPanel({ wantTerm: null });
|
|
34
|
+
return ok;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
|
2
|
+
import { useNarrow } from "@lib/shared";
|
|
3
|
+
import { arrange } from "./layout.ts";
|
|
4
|
+
import { terminalLayout, useTerminals } from "./terminal-store.ts";
|
|
5
|
+
|
|
6
|
+
// The tiles as the page shows them now: the sessions, the saved layout and a phone's pick, arranged.
|
|
7
|
+
export function useArranged() {
|
|
8
|
+
const all = useTerminals((s) => s.all),
|
|
9
|
+
lay = useTerminals((s) => s.lay),
|
|
10
|
+
pick = useTerminals((s) => s.pick),
|
|
11
|
+
phone = useNarrow();
|
|
12
|
+
const a = useMemo(() => arrange(all, lay, phone, pick), [all, lay, phone, pick]);
|
|
13
|
+
useEffect(() => terminalLayout.see(a.order), [a.order]);
|
|
14
|
+
return { all, lay, phone, a };
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { terminalLayout, useTerminals } from "./terminal-store.ts";
|
|
3
|
+
import { pickTerminal } from "./terminal-store.ts";
|
|
4
|
+
|
|
5
|
+
// Ctrl+Shift+M maximises or restores the tile being typed in. Alt+1…9 goes to the Nth tile; where one tile shows
|
|
6
|
+
// (maximised, or a phone's tabs) it switches which. Escape belongs to the agent, so the keys are read in capture, before
|
|
7
|
+
// xterm sends them on. Read by code, so the layout and Alt's own characters do not matter; Alt+arrows stay the shell's
|
|
8
|
+
// word jump. `focus` gives the typed-in terminal its cursor back after a header button took it.
|
|
9
|
+
export function useTerminalKeys(keys: string[], phone: boolean, focus: (key: string) => void) {
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const on = (e: KeyboardEvent) => {
|
|
12
|
+
const { lay, showing } = useTerminals.getState();
|
|
13
|
+
// The tiles stay mounted behind other pages: their keys belong to the Terminal page.
|
|
14
|
+
if (!showing) return;
|
|
15
|
+
if (e.ctrlKey && e.shiftKey && !e.altKey && !e.metaKey && e.code === "KeyM" && !phone) {
|
|
16
|
+
const k = (e.target as HTMLElement).closest?.<HTMLElement>("[data-tile]")?.dataset.tile || lay.max;
|
|
17
|
+
if (!k) return;
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
terminalLayout.toggleMax(k);
|
|
21
|
+
focus(k);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const n = /^Digit([1-9])$/.exec(e.code)?.[1];
|
|
25
|
+
if (!n || !e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) return;
|
|
26
|
+
const k = keys[+n - 1];
|
|
27
|
+
if (!k) return;
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
if (phone) pickTerminal(k);
|
|
31
|
+
else terminalLayout.maxOn(k);
|
|
32
|
+
focus(k);
|
|
33
|
+
};
|
|
34
|
+
addEventListener("keydown", on, true);
|
|
35
|
+
return () => removeEventListener("keydown", on, true);
|
|
36
|
+
}, [keys, phone, focus]);
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./safe-url.ts";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The only URLs a note may open or embed: web, mail, and relative paths. Everything
|
|
2
|
+
// else (javascript:, data:, vbscript:, file:) is null and the page leaves it as text.
|
|
3
|
+
export function safeUrl(u: string): string | null {
|
|
4
|
+
const s = u.trim();
|
|
5
|
+
if (!s || /[\x00-\x1f]/.test(s)) return null;
|
|
6
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(s);
|
|
7
|
+
if (!scheme) return s.startsWith("//") ? null : s;
|
|
8
|
+
return ["http", "https", "mailto"].includes(scheme[1]!.toLowerCase()) ? s : null;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The notebook page. Bundled into web/dist/notebook.js by `bun run build:web`; the page never sees the filesystem, only
|
|
2
|
+
// /vault. This file only starts things: the theme and menu state, the kit stores the shared code reaches through
|
|
3
|
+
// `window.kzKit`, the App (pages/notebook/App.tsx over components/notebook and lib/notebook) and the side menu's live
|
|
4
|
+
// parts. See design.md, "Notebook", for the look.
|
|
5
|
+
import { createElement } from "react";
|
|
6
|
+
import { flushSync } from "react-dom";
|
|
7
|
+
import { createRoot } from "react-dom/client";
|
|
8
|
+
import { startVault } from "@lib/notebook";
|
|
9
|
+
import { bootShell } from "@lib/shell";
|
|
10
|
+
import { refreshEvery } from "@lib/server";
|
|
11
|
+
import { initRail } from "@lib/rail/rail-boot.ts";
|
|
12
|
+
import { App } from "../pages/notebook/App.tsx";
|
|
13
|
+
import { registerKit } from "@lib/notebook/kit.ts";
|
|
14
|
+
|
|
15
|
+
// embed=1: a run workspace's note tab shows the note alone, without the side menu and header, so it starts no side menu.
|
|
16
|
+
const embed = new URLSearchParams(location.search).has("embed");
|
|
17
|
+
if (embed) document.body.classList.add("embed");
|
|
18
|
+
bootShell();
|
|
19
|
+
if (!embed) registerKit();
|
|
20
|
+
// At once: the side menu's code below finds its elements by id.
|
|
21
|
+
flushSync(() => createRoot(document.getElementById("root")!).render(createElement(App, { embed })));
|
|
22
|
+
if (!embed) {
|
|
23
|
+
initRail();
|
|
24
|
+
void refreshEvery();
|
|
25
|
+
}
|
|
26
|
+
// Every write under a state dir refreshes the page's notes, and the side menu's Board count.
|
|
27
|
+
void startVault({ onChanged: embed ? undefined : () => void refreshEvery() });
|