kaizen-agent 1.86.0 → 1.87.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 +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 +44 -14
- package/cli/tasks.ts +1 -1
- 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 +182 -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 +103 -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 +132 -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 +383 -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,228 @@
|
|
|
1
|
+
// Global search: the "Search" entry on top of the side menu, and Ctrl/Cmd+K anywhere, open one palette over
|
|
2
|
+
// workspaces, runs and tasks, chats, agent terminals, projects, pages and actions (modelled on Orca's "Jump to..."
|
|
3
|
+
// palette). This file builds the rows from the side menu's data and says what each does; `useSearchRows` (use-search-rows.ts)
|
|
4
|
+
// reads that data and the chats while the palette is open.
|
|
5
|
+
// The palette itself is React (components/search/search-palette.tsx). The board mounts it; the Notebook page loads it on
|
|
6
|
+
// its own (notebook/kit.ts) and opens it in place; Video, which carries no React, sends the person to the board with the
|
|
7
|
+
// palette open (?search=1).
|
|
8
|
+
import { age, host, leave } from "@lib/core";
|
|
9
|
+
import type { RailData } from "@lib/server";
|
|
10
|
+
import { openAdd } from "@lib/project/add-project.ts";
|
|
11
|
+
import { cardHref, cardState as stateOf, projName, titleOf, wsHref, wsLabel, wsOfCardNow as wsOfCard } from "@lib/rail";
|
|
12
|
+
import { railActions } from "@lib/rail/rail-actions.ts";
|
|
13
|
+
import { kitFor } from "@lib/rail/rail-boot.ts";
|
|
14
|
+
import { menuGo } from "@lib/router";
|
|
15
|
+
import { toggleRail, toggleTheme, setHelp } from "@lib/shell";
|
|
16
|
+
import { newTask } from "@lib/board";
|
|
17
|
+
import { leaves, wsKey } from "@lib/run/ws-tabs.ts";
|
|
18
|
+
import { useSearch } from "./search.ts";
|
|
19
|
+
import type { Item } from "./search-match.ts";
|
|
20
|
+
|
|
21
|
+
// Set when the board starts (initSearch): the Notebook and Video are not the board.
|
|
22
|
+
let onBoard = () => false;
|
|
23
|
+
// A page load: the Notebook writes the note it has open first (leave), the board has nothing to write.
|
|
24
|
+
const go = (href: string) => (onBoard() ? void (location.href = href) : leave(href));
|
|
25
|
+
// A menu entry's own click: in place on the board, a page load elsewhere.
|
|
26
|
+
const page = (v: string, href: string) => () => (onBoard() ? menuGo(v) : go(href));
|
|
27
|
+
const openWs = (dir: string, ws: string) => {
|
|
28
|
+
if (!host.open.ws({ dir, ws })) go(wsHref(dir, ws));
|
|
29
|
+
};
|
|
30
|
+
// The run view's saved layouts (run-view.ts keeps them here per workspace).
|
|
31
|
+
const layouts = (): Record<string, any> => {
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(localStorage.getItem("kz-runtabs") || "{}");
|
|
34
|
+
} catch {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// A tab: the board opens it in place; elsewhere its screen is chosen in storage, then the workspace loads.
|
|
39
|
+
const openTab = (dir: string, ws: string, id: string) => {
|
|
40
|
+
if (host.open.tab({ dir, ws, id })) return;
|
|
41
|
+
const all = layouts(),
|
|
42
|
+
s = all[wsKey(dir, ws)],
|
|
43
|
+
sc = s?.screens?.find((x) => leaves(x.tree).includes(id));
|
|
44
|
+
if (sc)
|
|
45
|
+
try {
|
|
46
|
+
s.on = sc.id;
|
|
47
|
+
localStorage.setItem("kz-runtabs", JSON.stringify(all));
|
|
48
|
+
} catch {}
|
|
49
|
+
go(wsHref(dir, ws));
|
|
50
|
+
};
|
|
51
|
+
// The run view's own tabs worth jumping to; agent tabs are listed with the terminals.
|
|
52
|
+
const TAB_KINDS = ["local", "preview", "note", "history", "shell"];
|
|
53
|
+
const browsed = (k: string) => {
|
|
54
|
+
try {
|
|
55
|
+
return localStorage.getItem("kz-browse:" + k)?.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
56
|
+
} catch {}
|
|
57
|
+
};
|
|
58
|
+
// The palette's rows for the side menu's data and the chats read so far.
|
|
59
|
+
// What a run or task is doing, in words beside its project (the dot alone has to be decoded).
|
|
60
|
+
const STATUS: Record<string, string> = { wait: "needs you", plan: "planning", build: "building", review: "in review", stalled: "stalled", done: "done", aband: "abandoned" };
|
|
61
|
+
export function buildRows({ cards, projects = [], agents = [] }: RailData, chats: any[]): Item[] {
|
|
62
|
+
const now = Date.now();
|
|
63
|
+
const cur = new URLSearchParams(location.search);
|
|
64
|
+
// The workspace open now: named by the address, or the one holding the run it names.
|
|
65
|
+
const curRun = cur.get("id") && cards.find((c) => c.kind === "run" && c.state === cur.get("dir") && c.id === cur.get("id"));
|
|
66
|
+
const curWs = cur.get("ws") ?? (curRun ? wsOfCard(curRun, projects) : null);
|
|
67
|
+
const out: Item[] = [];
|
|
68
|
+
const saved = layouts();
|
|
69
|
+
// Workspaces, the one open now first; then by their latest run.
|
|
70
|
+
const latest = new Map<string, number>();
|
|
71
|
+
for (const c of cards) {
|
|
72
|
+
const k = c.state + "\0" + wsOfCard(c, projects);
|
|
73
|
+
latest.set(k, Math.max(latest.get(k) ?? 0, c.moved ?? 0));
|
|
74
|
+
}
|
|
75
|
+
for (const p of projects) {
|
|
76
|
+
const name = projName(p.dir, projects);
|
|
77
|
+
for (const w of p.workspaces ?? []) {
|
|
78
|
+
const here = cur.get("dir") === p.dir && curWs === w.path;
|
|
79
|
+
const at = latest.get(p.dir + "\0" + w.path);
|
|
80
|
+
out.push({
|
|
81
|
+
group: here ? "Current" : "Workspaces",
|
|
82
|
+
title: wsLabel(w),
|
|
83
|
+
sub: name,
|
|
84
|
+
when: at ? age(at, now) : undefined,
|
|
85
|
+
hay: `${wsLabel(w)} ${name} ${w.path} workspace`,
|
|
86
|
+
at: here ? Infinity : at ?? 0,
|
|
87
|
+
ico: "ws",
|
|
88
|
+
act: () => openWs(p.dir, w.path),
|
|
89
|
+
});
|
|
90
|
+
const k = wsKey(p.dir, w.path),
|
|
91
|
+
lay = saved[k];
|
|
92
|
+
for (const t of lay?.tabs ?? []) {
|
|
93
|
+
if (!TAB_KINDS.includes(t.kind) || lay.hidden?.includes(t.id)) continue;
|
|
94
|
+
const title = (t.kind === "local" && browsed(k)) || t.title;
|
|
95
|
+
out.push({ group: "Tabs", title, sub: `${wsLabel(w)} · ${name}`, hay: `${title} ${t.title} ${t.kind} ${t.note ?? ""} ${wsLabel(w)} ${name} tab`, ico: "tab", act: () => openTab(p.dir, w.path, t.id) });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
out.push({ group: "Projects", title: name, hay: `${name} ${p.dir} project`, ico: "proj", act: () => {
|
|
99
|
+
const main = p.workspaces?.find((w) => w.main) ?? p.workspaces?.[0];
|
|
100
|
+
main ? openWs(p.dir, main.path) : page("board", "/?view=board")();
|
|
101
|
+
} });
|
|
102
|
+
}
|
|
103
|
+
// Runs and tasks, not archived.
|
|
104
|
+
for (const c of cards.filter((c) => !c.archived)) {
|
|
105
|
+
const st = stateOf(c);
|
|
106
|
+
out.push({
|
|
107
|
+
group: c.kind === "run" ? "Runs" : "Tasks",
|
|
108
|
+
title: titleOf(c) || c.id,
|
|
109
|
+
sub: [projName(c.state, projects), STATUS[st]].filter(Boolean).join(" · "),
|
|
110
|
+
when: c.moved ? age(c.moved, now) : undefined,
|
|
111
|
+
hay: `${titleOf(c)} ${c.id ?? ""} ${c.text ?? ""} ${projName(c.state, projects)} ${st}`,
|
|
112
|
+
at: c.moved ?? 0,
|
|
113
|
+
dot: st,
|
|
114
|
+
ico: c.kind === "run" ? "run" : "idea",
|
|
115
|
+
act: () => {
|
|
116
|
+
if (!host.open.card({ dir: c.state, id: c.kind === "run" ? c.id : undefined, text: c.text })) go(cardHref(c));
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
for (const c of chats) {
|
|
121
|
+
// updated is an ISO date string.
|
|
122
|
+
const at = Date.parse(c.updated) || 0;
|
|
123
|
+
out.push({
|
|
124
|
+
group: "Chats & terminals",
|
|
125
|
+
title: c.title || "Chat",
|
|
126
|
+
sub: c.project ? projName(c.project, projects) : undefined,
|
|
127
|
+
when: at ? age(at, now) : undefined,
|
|
128
|
+
hay: `${c.title} chat ${c.project ?? ""}`,
|
|
129
|
+
at,
|
|
130
|
+
dot: c.busy ? "build" : undefined,
|
|
131
|
+
ico: "chat",
|
|
132
|
+
act: () => {
|
|
133
|
+
try {
|
|
134
|
+
sessionStorage.setItem("kz-chat", c.id);
|
|
135
|
+
} catch {}
|
|
136
|
+
page("home", "/")();
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
for (const a of agents)
|
|
141
|
+
out.push({
|
|
142
|
+
group: "Chats & terminals",
|
|
143
|
+
title: a.name || a.agent || "Terminal",
|
|
144
|
+
sub: projName(a.dir, projects),
|
|
145
|
+
hay: `${a.name} ${a.agent ?? ""} ${a.run ?? ""} ${a.last ?? ""} ${projName(a.dir, projects)} terminal agent`,
|
|
146
|
+
at: a.at ?? a.born ?? 0,
|
|
147
|
+
dot: a.asking ? "wait" : a.busy ? "build" : "done",
|
|
148
|
+
ico: "term",
|
|
149
|
+
act: () => {
|
|
150
|
+
if (!host.open.term({ dir: a.dir, ws: a.ws, key: a.key })) go(wsHref(a.dir, a.ws ?? ""));
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
// Pages and actions. Each clicks the side menu's own control, so it behaves the same.
|
|
154
|
+
// [title, icon, what it does, keywords, a page]: each has its own icon (the sprite's name, or one the palette draws).
|
|
155
|
+
const acts: [string, string, () => void, string?, true?][] = [
|
|
156
|
+
["Chat", "chat", page("home", "/"), "home", true],
|
|
157
|
+
["Icebox", "inbox", page("sources", "/?view=icebox"), "requests sources gathered capture inbox later add note", true],
|
|
158
|
+
["Tasks", "idea", page("tasks", "/?view=tasks"), "backlog", true],
|
|
159
|
+
["Board", "board", page("board", "/?view=board"), "kanban runs", true],
|
|
160
|
+
["Notes", "doc", () => go("/notebook"), "notebook docs", true],
|
|
161
|
+
["Settings", "gear", page("settings", "/?view=settings"), "preferences config", true],
|
|
162
|
+
["New task", "plus", () => (onBoard() ? newTask() : go("/?view=board")), "create add run"],
|
|
163
|
+
["Add a project", "proj", () => openAdd({ dir: null }), "clone folder create workspace"],
|
|
164
|
+
["Toggle theme", "moon", toggleTheme, "dark light"],
|
|
165
|
+
["Collapse or expand menu", "side", toggleRail, "sidebar rail"],
|
|
166
|
+
["Keyboard shortcuts", "kbd", () => setHelp(true), "keys help"],
|
|
167
|
+
["Report an issue", "bug", () => open("/issue", "_blank", "noopener"), "bug feedback"],
|
|
168
|
+
];
|
|
169
|
+
for (const [title, ico, act, kw, pg] of acts) out.push({ group: "Actions", title, hay: `${title} ${kw ?? ""}`, ico, act, page: pg });
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function newTaskWith(text: string) {
|
|
174
|
+
if (!onBoard()) return void go("/?view=board");
|
|
175
|
+
newTask(undefined, text);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// The rows are the palette's own (useSearchRows); this opens it.
|
|
179
|
+
// The palette's store: this bundle's own on the board; on the Notebook page the loaded kit's, which the mounted palette reads.
|
|
180
|
+
let S = useSearch;
|
|
181
|
+
export function openSearch() {
|
|
182
|
+
if (onBoard()) return show();
|
|
183
|
+
kitFor().then(
|
|
184
|
+
(k) => {
|
|
185
|
+
S = k.useSearch;
|
|
186
|
+
show();
|
|
187
|
+
},
|
|
188
|
+
() => leave("/?view=board&search=1"),
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
function show() {
|
|
192
|
+
S.setState({ open: true, newTask: newTaskWith });
|
|
193
|
+
}
|
|
194
|
+
const toggle = () => (S.getState().open ? S.setState({ open: false }) : openSearch());
|
|
195
|
+
|
|
196
|
+
export function initSearch(board: boolean) {
|
|
197
|
+
onBoard = () => board;
|
|
198
|
+
railActions.search = openSearch;
|
|
199
|
+
const mac = /Mac|iP(hone|ad)/.test(navigator.platform);
|
|
200
|
+
let asked: ReturnType<typeof setTimeout> | undefined;
|
|
201
|
+
// Arriving from the notebook or Video with the palette asked for.
|
|
202
|
+
if (onBoard() && new URLSearchParams(location.search).get("search") === "1") {
|
|
203
|
+
const q = new URLSearchParams(location.search);
|
|
204
|
+
q.delete("search");
|
|
205
|
+
history.replaceState(null, "", location.pathname + (q.toString() ? "?" + q : "") + location.hash);
|
|
206
|
+
asked = setTimeout(openSearch, 400);
|
|
207
|
+
}
|
|
208
|
+
// Ctrl/Cmd+K anywhere, and Orca's own Cmd+J (Ctrl+Shift+J is the browser's console).
|
|
209
|
+
const onKey = (e: KeyboardEvent) => {
|
|
210
|
+
// Ctrl+Shift+Space works in a terminal too: no shell or agent needs it.
|
|
211
|
+
if (e.ctrlKey && e.shiftKey && e.code === "Space") {
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
e.stopPropagation();
|
|
214
|
+
return void toggle();
|
|
215
|
+
}
|
|
216
|
+
// A terminal keeps its keys: Ctrl+K there is the shell's kill-line.
|
|
217
|
+
if ((e.target as Element)?.closest?.(".xterm")) return;
|
|
218
|
+
const mod = mac ? e.metaKey : e.ctrlKey;
|
|
219
|
+
const k = e.key.toLowerCase();
|
|
220
|
+
if (mod && !e.altKey && ((k === "k" && !e.shiftKey) || (mac && k === "j" && !e.shiftKey))) {
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
e.stopPropagation();
|
|
223
|
+
toggle();
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
addEventListener("keydown", onKey, true);
|
|
227
|
+
return () => (clearTimeout(asked), removeEventListener("keydown", onKey, true));
|
|
228
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The Search palette (Ctrl/Cmd+K and the side menu's Search): whether it is open and what its New task row does; the rows are
|
|
2
|
+
// built by use-search-rows.ts from the side menu's data (search-rows.ts), the typing and choosing are the palette's own.
|
|
3
|
+
import { create } from "zustand";
|
|
4
|
+
import { match, type Item } from "./search-match.ts";
|
|
5
|
+
|
|
6
|
+
// newTask: what the New task row does with the typed text (the board knows how to open its form).
|
|
7
|
+
export const useSearch = create<{ open: boolean; newTask: (text: string) => void }>()(() => ({
|
|
8
|
+
open: false,
|
|
9
|
+
newTask: () => {},
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
// What shows for `q`: typed, the group holding the best match comes first (so Enter takes it) with up to 8 rows each, then an
|
|
13
|
+
// offer to make a task of what was typed. Empty: what waits on you, then what you touched last; a board with little in it
|
|
14
|
+
// also lists the pages, so the palette is never bare.
|
|
15
|
+
const WORK = ["Current", "Workspaces", "Runs", "Tasks", "Chats & terminals"];
|
|
16
|
+
export function shownRows(all: Item[], q: string, newTask: (text: string) => void): Item[] {
|
|
17
|
+
const t = q.trim();
|
|
18
|
+
if (!t) {
|
|
19
|
+
const recent = (a: Item, b: Item) => (b.at ?? 0) - (a.at ?? 0);
|
|
20
|
+
const need = all.filter((i) => i.dot === "wait" && (i.group === "Runs" || i.group === "Tasks")).sort(recent).slice(0, 3);
|
|
21
|
+
const last = all.filter((i) => WORK.includes(i.group) && !need.includes(i)).sort(recent).slice(0, 5);
|
|
22
|
+
const rows = [...need.map((i) => ({ ...i, group: "Needs you" })), ...last.map((i) => ({ ...i, group: i.group === "Current" ? "Current" : "Recent" }))];
|
|
23
|
+
if (rows.length < 4) rows.push(...all.filter((i) => i.group === "Actions" && i.page).map((i) => ({ ...i, group: "Go to" })));
|
|
24
|
+
return rows;
|
|
25
|
+
}
|
|
26
|
+
const hit = match(all, q);
|
|
27
|
+
const rows = [...new Set(hit.map((i) => i.group))].flatMap((g) => hit.filter((i) => i.group === g).slice(0, 8));
|
|
28
|
+
rows.push({ group: "Create", title: `New task "${t}"`, hay: "", ico: "plus", act: () => newTask(t) });
|
|
29
|
+
return rows;
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The palette's rows as a hook: the side menu's data (the server store) and the chats, read when the palette opens. Nothing
|
|
2
|
+
// refills a store by hand: a change of the data is a new render, and closing the palette aborts a read in flight.
|
|
3
|
+
import { useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { useRailData } from "@lib/server";
|
|
5
|
+
import { buildRows } from "./search-rows.ts";
|
|
6
|
+
import type { Item } from "./search-match.ts";
|
|
7
|
+
|
|
8
|
+
export function useSearchRows(open: boolean): Item[] {
|
|
9
|
+
const data = useRailData(),
|
|
10
|
+
[chats, setChats] = useState<any[]>([]);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
// Closed: forget them, so the next open never shows a chat deleted since.
|
|
13
|
+
if (!open) return setChats([]);
|
|
14
|
+
const ac = new AbortController();
|
|
15
|
+
fetch("/chats", { signal: ac.signal })
|
|
16
|
+
.then((r) => r.json())
|
|
17
|
+
.then((d) => setChats(d.chats ?? []))
|
|
18
|
+
.catch(() => {});
|
|
19
|
+
return () => ac.abort();
|
|
20
|
+
}, [open]);
|
|
21
|
+
return useMemo(() => (open ? buildRows(data, chats) : []), [open, data, chats]);
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getServer } from "./server-store.ts";
|
|
2
|
+
import type { RailTask } from "./types.ts";
|
|
3
|
+
|
|
4
|
+
export type AttentionTask = RailTask;
|
|
5
|
+
type BadgeCard = {
|
|
6
|
+
state?: string;
|
|
7
|
+
archived?: boolean;
|
|
8
|
+
kind: string;
|
|
9
|
+
status: string;
|
|
10
|
+
pty?: { alive: boolean; asking: boolean };
|
|
11
|
+
};
|
|
12
|
+
// How many runs wait on you (the tab title and the Board's badge): the tasks' own count where it is known, else the cards'.
|
|
13
|
+
export function waitingCount(cards: BadgeCard[], tasks: RailTask[] | null = getServer().tasks) {
|
|
14
|
+
if (tasks) {
|
|
15
|
+
const dirs = new Set(cards.map((c) => c.state).filter(Boolean));
|
|
16
|
+
return tasks.filter((t) => (!dirs.size || dirs.has(t.dir)) && t.attention.category === "needs-you").length;
|
|
17
|
+
}
|
|
18
|
+
return cards.filter(
|
|
19
|
+
(c) => !c.archived && ((c.kind === "run" && c.status === "waiting") || (c.pty?.alive && c.pty.asking)),
|
|
20
|
+
).length;
|
|
21
|
+
}
|
|
22
|
+
// The side menu's counts: tasks that need you, and new Icebox requests that are awake.
|
|
23
|
+
export const needYouCount = (tasks: RailTask[] | null) =>
|
|
24
|
+
tasks?.filter((t) => t.attention.category === "needs-you").length ?? 0;
|
|
25
|
+
export const iceNewCount = (sources: any) =>
|
|
26
|
+
(sources?.icebox ?? []).filter((s: any) => s.status === "new" && !s.asleep).length;
|
|
27
|
+
// Live terminals: the board's agent sessions plus the shells /shell started.
|
|
28
|
+
export const liveTerminals = (cards: any[], shells: unknown[]) =>
|
|
29
|
+
cards.filter((c) => c.pty?.alive).length + shells.length;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// The poller's decisions without the network (tested in server.test.ts): when a /state read is worth drawing, how repeated
|
|
2
|
+
// cards get distinct keys, which cards moved column or started needing you, and which agents just started asking.
|
|
3
|
+
export const QUIET_GAP = 500; // a change event can come several times a second while agents work
|
|
4
|
+
export const HIDDEN_GAP = 5000; // a hidden tab only watches for agents asking
|
|
5
|
+
export const REDRAW_MS = 30_000; // an identical reply still redraws now and then, for ages and repeat notices
|
|
6
|
+
export const BADGE_GAP = 2000; // the all-projects read is hundreds of KB: at most one per gap
|
|
7
|
+
export const TASKS_GAP = 2000;
|
|
8
|
+
export const SOURCES_GAP = 30_000;
|
|
9
|
+
|
|
10
|
+
// The reply without its clock: two replies that differ only in `now` are the same.
|
|
11
|
+
export const withoutClock = (text: string) => text.replace(/"now":\d+\}$/, "");
|
|
12
|
+
// How long a quiet read waits so one runs per gap and the last change is always covered.
|
|
13
|
+
export const quietDelay = (now: number, lastQuiet: number, hidden: boolean) =>
|
|
14
|
+
Math.max(0, lastQuiet + (hidden ? HIDDEN_GAP : QUIET_GAP) - now);
|
|
15
|
+
// A quiet read of the same reply, drawn recently, skips the redraw.
|
|
16
|
+
export const skipRedraw = (quiet: boolean, body: string, last: string, now: number, drawnAt: number) =>
|
|
17
|
+
quiet && body === last && now - drawnAt < REDRAW_MS;
|
|
18
|
+
|
|
19
|
+
// A card's key: one name per task or run. Two tasks may carry the same text; numberKeys makes the repeats distinct.
|
|
20
|
+
export const baseKey = (c: any) =>
|
|
21
|
+
c.kind === "idea" ? "idea:" + c.state + ":" + c.text : "run:" + c.state + ":" + c.id;
|
|
22
|
+
export const cardKey = (c: any) => c._k || baseKey(c);
|
|
23
|
+
export function numberKeys(cards: any[]) {
|
|
24
|
+
const seen = new Map<string, number>();
|
|
25
|
+
for (const c of cards) {
|
|
26
|
+
const b = baseKey(c),
|
|
27
|
+
n = seen.get(b) || 0;
|
|
28
|
+
seen.set(b, n + 1);
|
|
29
|
+
c._k = n ? b + "#" + n : b;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// A run waiting on you, or an agent waiting on input.
|
|
34
|
+
export const needsYou = (c: any) => c.status === "waiting" || !!(c.pty?.alive && c.pty.asking);
|
|
35
|
+
export type Seen = Map<string, [number, boolean]>;
|
|
36
|
+
// Against the last read: the cards that changed column (they slide), the ones that started needing you (they flash), and
|
|
37
|
+
// what to compare the next read to. `before` null is the first read, which is not news.
|
|
38
|
+
export function changes(before: Seen | null, cards: any[]) {
|
|
39
|
+
const moved: string[] = [],
|
|
40
|
+
flash: string[] = [];
|
|
41
|
+
for (const c of before ? cards : []) {
|
|
42
|
+
const b = before!.get(cardKey(c));
|
|
43
|
+
if (b && b[0] !== c.column) moved.push(cardKey(c));
|
|
44
|
+
if (b && !b[1] && needsYou(c)) flash.push(cardKey(c));
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
moved,
|
|
48
|
+
flash,
|
|
49
|
+
next: new Map(cards.map((c) => [cardKey(c), [c.column, needsYou(c)] as [number, boolean]])) as Seen,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// In-card agents waiting on input, by session key.
|
|
53
|
+
export const askingNow = (cards: any[]) =>
|
|
54
|
+
new Map(cards.filter((c) => !c.archived && c.pty?.alive && c.pty.asking).map((c) => [c.pty.key as string, c]));
|
|
55
|
+
// The ones that started asking since `asked` (null: the first read, what already asks is not news).
|
|
56
|
+
export const newlyAsking = (asked: Set<string> | null, now: Map<string, any>) =>
|
|
57
|
+
asked ? [...now].filter(([k]) => !asked.has(k)).map(([, c]) => c) : [];
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// The one poller: reads /state (and the reads that hang off it) and writes the server store. The board's engines hear of a
|
|
2
|
+
// new /state through `setEngine` (the cards' redraw, notifications, the open panel); nothing else reads the server to share it.
|
|
3
|
+
import { toast } from "@lib/core";
|
|
4
|
+
import { homeShows, useRoute } from "@lib/router";
|
|
5
|
+
import { BADGE_GAP, quietDelay, skipRedraw, SOURCES_GAP, TASKS_GAP, numberKeys, withoutClock } from "./poll-rules.ts";
|
|
6
|
+
import { getServer, onServer, setServer, type Every } from "./server-store.ts";
|
|
7
|
+
|
|
8
|
+
// This page's project, sent with each request: the server keeps none, so another tab or a phone picking a project never
|
|
9
|
+
// moves this one.
|
|
10
|
+
export const dirHeader = () => {
|
|
11
|
+
const { dir } = getServer();
|
|
12
|
+
return dir ? { "x-kz-dir": dir } : {};
|
|
13
|
+
};
|
|
14
|
+
// A tab outliving its server would otherwise swallow every click: say so.
|
|
15
|
+
const GONE = "The kaizen server is not running — start it with kaizen web (or the shortcut), then reload.";
|
|
16
|
+
|
|
17
|
+
// What the board does with a new /state besides storing it (the cards' redraw, notifications, the open panel).
|
|
18
|
+
type Engine = (next: any, prev: any, quiet: boolean) => Promise<void> | void;
|
|
19
|
+
let engine: Engine = () => {};
|
|
20
|
+
export const setEngine = (f: Engine) => (engine = f);
|
|
21
|
+
|
|
22
|
+
const everyOf = (s: any): Every => ({
|
|
23
|
+
cards: s.cards,
|
|
24
|
+
projects: [...s.projects, ...(s.rail ?? [])],
|
|
25
|
+
agents: s.agents ?? [],
|
|
26
|
+
});
|
|
27
|
+
let generation = 0; // a newer all-projects snapshot makes a read still in flight stale
|
|
28
|
+
function publish(every: Every, rest: object = {}) {
|
|
29
|
+
generation++;
|
|
30
|
+
setServer({ every, ...rest });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ---- /state
|
|
34
|
+
let latest = 0,
|
|
35
|
+
lastBody = "",
|
|
36
|
+
drawnAt = 0,
|
|
37
|
+
lastQuiet = 0,
|
|
38
|
+
quietTimer: ReturnType<typeof setTimeout> | 0 = 0;
|
|
39
|
+
const runQuiet = () => {
|
|
40
|
+
quietTimer = 0;
|
|
41
|
+
lastQuiet = Date.now();
|
|
42
|
+
return read(true);
|
|
43
|
+
};
|
|
44
|
+
// quiet: the server said something changed, nobody asked for a redraw. A change event can come several times a second while
|
|
45
|
+
// agents work and a full read and redraw blocks this thread (and any terminal in it): one quiet load per gap, the last change
|
|
46
|
+
// always covered, a hidden tab only watching for agents asking.
|
|
47
|
+
export function load(quiet?: boolean) {
|
|
48
|
+
if (!quiet) return read(false);
|
|
49
|
+
if (!quietTimer) quietTimer = setTimeout(runQuiet, quietDelay(Date.now(), lastQuiet, document.hidden));
|
|
50
|
+
}
|
|
51
|
+
// Back on a hidden tab: what it put off is shown now.
|
|
52
|
+
export function flushLoad() {
|
|
53
|
+
if (!document.hidden && quietTimer) {
|
|
54
|
+
clearTimeout(quietTimer);
|
|
55
|
+
void runQuiet();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function read(quiet: boolean) {
|
|
59
|
+
const current = ++latest,
|
|
60
|
+
all = getServer().all;
|
|
61
|
+
let r: Response;
|
|
62
|
+
try {
|
|
63
|
+
r = await fetch("/state" + (all ? "?all=1" : ""), { headers: dirHeader() });
|
|
64
|
+
} catch {
|
|
65
|
+
toast(GONE);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const text = await r.text();
|
|
69
|
+
if (current !== latest) return;
|
|
70
|
+
const body = withoutClock(text);
|
|
71
|
+
const same = skipRedraw(quiet, body, lastBody, Date.now(), drawnAt);
|
|
72
|
+
lastBody = body;
|
|
73
|
+
if (same) {
|
|
74
|
+
if (!all) void refreshEvery();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
drawnAt = Date.now();
|
|
78
|
+
const next = JSON.parse(text),
|
|
79
|
+
prev = getServer().state;
|
|
80
|
+
numberKeys(next.cards);
|
|
81
|
+
if (all) publish(everyOf(next), { state: next, loaded: true });
|
|
82
|
+
else {
|
|
83
|
+
setServer({ state: next, loaded: true });
|
|
84
|
+
void refreshEvery();
|
|
85
|
+
}
|
|
86
|
+
await engine(next, prev, quiet);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ---- every project's cards (the side menu, the Terminal page, the tab title): the state itself when the page shows all
|
|
90
|
+
// projects, else one more read, at most one per BADGE_GAP, the last request still served when the gap ends.
|
|
91
|
+
let lastAll = "",
|
|
92
|
+
loading = false,
|
|
93
|
+
again = false,
|
|
94
|
+
lastRun = 0,
|
|
95
|
+
waiting: ReturnType<typeof setTimeout> | undefined;
|
|
96
|
+
export async function refreshEvery() {
|
|
97
|
+
if (loading) {
|
|
98
|
+
again = true;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const gap = lastRun + BADGE_GAP - Date.now();
|
|
102
|
+
if (gap > 0) {
|
|
103
|
+
waiting ??= setTimeout(() => {
|
|
104
|
+
waiting = undefined;
|
|
105
|
+
void refreshEvery();
|
|
106
|
+
}, gap);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
lastRun = Date.now();
|
|
110
|
+
loading = true;
|
|
111
|
+
do {
|
|
112
|
+
again = false;
|
|
113
|
+
const current = generation;
|
|
114
|
+
try {
|
|
115
|
+
const r = await fetch("/state?all=1");
|
|
116
|
+
if (!r.ok) continue;
|
|
117
|
+
const text = await r.text();
|
|
118
|
+
const body = withoutClock(text);
|
|
119
|
+
if (body === lastAll) continue;
|
|
120
|
+
if (!again && current === generation) {
|
|
121
|
+
lastAll = body;
|
|
122
|
+
const s = JSON.parse(text);
|
|
123
|
+
publish(everyOf(s));
|
|
124
|
+
}
|
|
125
|
+
} catch {
|
|
126
|
+
/* keep the last count while the board is offline */
|
|
127
|
+
}
|
|
128
|
+
} while (again);
|
|
129
|
+
loading = false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ---- the reads that follow a new all-projects snapshot
|
|
133
|
+
let tasksAt = 0,
|
|
134
|
+
tasksReading = false;
|
|
135
|
+
export async function readTasks() {
|
|
136
|
+
if (tasksReading || Date.now() - tasksAt < TASKS_GAP) return;
|
|
137
|
+
tasksReading = true;
|
|
138
|
+
tasksAt = Date.now();
|
|
139
|
+
try {
|
|
140
|
+
const r = await fetch("/tasks?all=1");
|
|
141
|
+
if (r.ok) setServer({ tasks: (await r.json()).tasks ?? [] });
|
|
142
|
+
} catch {
|
|
143
|
+
/* retain the latest persisted projection */
|
|
144
|
+
} finally {
|
|
145
|
+
tasksReading = false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
let sourcesAt = 0;
|
|
149
|
+
export async function readSources(force = false) {
|
|
150
|
+
if (!force && Date.now() - sourcesAt < SOURCES_GAP) return;
|
|
151
|
+
sourcesAt = Date.now();
|
|
152
|
+
try {
|
|
153
|
+
const r = await fetch("/sources");
|
|
154
|
+
if (r.ok) setServer({ sources: await r.json() });
|
|
155
|
+
} catch {
|
|
156
|
+
/* offline: keep what shows */
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Whether the list was read (false: offline, what shows is kept, and a caller judging by it should not).
|
|
160
|
+
export async function readShells(): Promise<boolean> {
|
|
161
|
+
try {
|
|
162
|
+
setServer({ shells: await (await fetch("/shells")).json() });
|
|
163
|
+
return true;
|
|
164
|
+
} catch {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// The side menu's live parts (task and Icebox counts, source marks) and, on the board, the footer's terminal count follow
|
|
169
|
+
// each all-projects snapshot. The Notebook starts this too; Video lists no projects. Returns the function that stops it.
|
|
170
|
+
export function startRailFeed(withShells = false) {
|
|
171
|
+
void readTasks();
|
|
172
|
+
return onServer(
|
|
173
|
+
(s) => s.every,
|
|
174
|
+
() => {
|
|
175
|
+
void readSources();
|
|
176
|
+
void readTasks();
|
|
177
|
+
if (withShells) void readShells();
|
|
178
|
+
},
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// ---- the event stream: a change reloads the board quietly; a new server start reloads the page
|
|
183
|
+
let boot: string | null = null,
|
|
184
|
+
pendingReload = false;
|
|
185
|
+
// Home's chat holds a stream the person is reading: a reload waits until they leave it.
|
|
186
|
+
const reloadWhenAway = () => (homeShows() ? (pendingReload = true) : location.reload());
|
|
187
|
+
function listen() {
|
|
188
|
+
const es = new EventSource("/events");
|
|
189
|
+
es.onmessage = (ev) => {
|
|
190
|
+
if (ev.data === "changed") {
|
|
191
|
+
load(true);
|
|
192
|
+
setServer((s) => ({ changed: s.changed + 1 }));
|
|
193
|
+
} else if (ev.data.startsWith("hello ")) {
|
|
194
|
+
const b = ev.data.slice(6);
|
|
195
|
+
if (boot && b !== boot) reloadWhenAway();
|
|
196
|
+
boot = b;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
es.onerror = () => {
|
|
200
|
+
es.close();
|
|
201
|
+
setTimeout(listen, 3000);
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
export function startEvents() {
|
|
205
|
+
useRoute.subscribe((r, p) => r.view !== p.view && pendingReload && !homeShows() && location.reload());
|
|
206
|
+
// Back from a terminal: what was committed or pushed there touched nothing the server watches.
|
|
207
|
+
addEventListener("focus", () => load(true));
|
|
208
|
+
addEventListener("visibilitychange", flushLoad);
|
|
209
|
+
listen();
|
|
210
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// What the server says, as slices of one Zustand store: this page's /state (cards, projects, the picked project), the
|
|
2
|
+
// all-projects cards and agents the side menu and the Terminal page list, the tasks' attention, the Icebox's /sources and
|
|
3
|
+
// the live shells. One poller (poller.ts) is the only writer; components read the slice they draw.
|
|
4
|
+
import { create } from "zustand";
|
|
5
|
+
import type { Agent, RailTask } from "./types.ts";
|
|
6
|
+
|
|
7
|
+
export type Shell = { key: string; dir: string; title: string; agent: string; run?: string };
|
|
8
|
+
export type Every = { cards: any[]; projects: any[]; agents: Agent[] };
|
|
9
|
+
export type Server = {
|
|
10
|
+
state: any; // GET /state for the project this page is on (or all of them)
|
|
11
|
+
loaded: boolean; // the first /state has come
|
|
12
|
+
all: boolean; // the page shows every project
|
|
13
|
+
dir: string | null; // the project this page picked; null is wherever the board started
|
|
14
|
+
every: Every | null; // GET /state?all=1: every project's cards and agents (null until read)
|
|
15
|
+
tasks: RailTask[] | null; // GET /tasks?all=1: what needs you
|
|
16
|
+
sources: any | null; // GET /sources: request sources and every Icebox signal
|
|
17
|
+
shells: Shell[]; // GET /shells
|
|
18
|
+
changed: number; // counts the server's "changed" events, for pages that refetch their own data
|
|
19
|
+
};
|
|
20
|
+
export const useServer = create<Server>()(() => ({
|
|
21
|
+
state: { project: null, projects: [], cards: [], now: Date.now(), all: false, dir: null },
|
|
22
|
+
loaded: false,
|
|
23
|
+
all: typeof location === "undefined" ? true : new URLSearchParams(location.search).get("all") !== "0",
|
|
24
|
+
dir: null,
|
|
25
|
+
every: null,
|
|
26
|
+
tasks: null,
|
|
27
|
+
sources: null,
|
|
28
|
+
shells: [],
|
|
29
|
+
changed: 0,
|
|
30
|
+
}));
|
|
31
|
+
export const getServer = useServer.getState;
|
|
32
|
+
export const setServer = useServer.setState;
|
|
33
|
+
// Runs `fn` when one slice changes (the engines that react to a read: a changed /state, new shells).
|
|
34
|
+
export const onServer = <T>(pick: (s: Server) => T, fn: (next: T, prev: T) => void) =>
|
|
35
|
+
useServer.subscribe((s, p) => (pick(s) !== pick(p) ? fn(pick(s), pick(p)) : undefined));
|
|
36
|
+
export const onState = (fn: (next: any, prev: any) => void) => onServer((s) => s.state, fn);
|
|
37
|
+
|
|
38
|
+
export const setTasks = (tasks: RailTask[]) => setServer({ tasks });
|
|
39
|
+
export const setShells = (shells: Shell[]) => setServer({ shells });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// The shapes the server's reads carry and the side menu lists (the cards' own shape stays loose, as /state sends it).
|
|
2
|
+
// /state `agents`: one entry per open agent terminal.
|
|
3
|
+
export type Agent = {
|
|
4
|
+
key: string;
|
|
5
|
+
dir: string;
|
|
6
|
+
ws?: string;
|
|
7
|
+
agent?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
run?: string;
|
|
10
|
+
asking: boolean;
|
|
11
|
+
busy: boolean;
|
|
12
|
+
last?: string;
|
|
13
|
+
at?: number;
|
|
14
|
+
born?: number;
|
|
15
|
+
land?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type RailTask = {
|
|
19
|
+
id: string;
|
|
20
|
+
dir: string;
|
|
21
|
+
title: string;
|
|
22
|
+
status?: string;
|
|
23
|
+
created?: number;
|
|
24
|
+
activeRun?: string | null;
|
|
25
|
+
runs?: (string | { id: string })[];
|
|
26
|
+
runIds?: string[];
|
|
27
|
+
legacy?: { kind: string; id?: string; index?: number };
|
|
28
|
+
attention: { category: string; reason: string; action: string };
|
|
29
|
+
};
|
|
30
|
+
// What the side menu and the phone's pages draw (/state?all=1 and /tasks?all=1).
|
|
31
|
+
export type RailData = { cards: any[]; projects: any[]; agents: Agent[]; tasks: RailTask[] | null };
|