kaizen-agent 1.85.2 → 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/rea.ts +99 -11
- package/cli/settings.ts +16 -17
- package/cli/state.ts +15 -29
- package/cli/task-service.ts +114 -34
- package/cli/tasks.ts +8 -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 +197 -61
- package/package.json +21 -4
- package/skills/kaizen/spec.md +12 -4
- package/skills/optional/disk-cleanup/SKILL.md +60 -0
- package/skills/optional/disk-cleanup/skill.json +1 -0
- package/skills/optional/disk-cleanup/tui.py +90 -0
- 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/term-paste.ts +10 -0
- package/web/{term.ts → term/term.ts} +101 -27
- 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 -86
- 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 -615
- 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 -500
- package/web/notebook.js +0 -514
- package/web/notebook.ts +0 -1254
- package/web/popup.html +0 -141
- package/web/video.js +0 -570
- /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/board/home.ts
DELETED
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
import { open } from "./panel.ts";
|
|
2
|
-
import { pick, short } from "./projects.ts";
|
|
3
|
-
import { $, html, ico, raw, vt } from "./dom.ts";
|
|
4
|
-
import { draft, DK } from "./drafts.ts";
|
|
5
|
-
import { md } from "./markdown.ts";
|
|
6
|
-
import { store } from "./store.ts";
|
|
7
|
-
import { toast } from "./toast.ts";
|
|
8
|
-
|
|
9
|
-
// ---- Home: a chat with kaizen's main agent (cli/chat.ts). Chats are not tied to the
|
|
10
|
-
// board's project: each is in a project or in none, and the agent can move it. A new chat
|
|
11
|
-
// starts in the project picked above (none in All projects); the board follows the open chat.
|
|
12
|
-
let chats = [];
|
|
13
|
-
let cur = null; // the open chat, as /chat returns it; null is a new one
|
|
14
|
-
let sending = false;
|
|
15
|
-
let remoteBusy = false;
|
|
16
|
-
let poll = null;
|
|
17
|
-
let seen = 0; // messages already on screen: only newer ones animate in
|
|
18
|
-
let shown = null; // the chat those were from
|
|
19
|
-
let following = true; // scrolling up pauses auto-follow until the reader reaches the bottom again
|
|
20
|
-
let attachments = [];
|
|
21
|
-
|
|
22
|
-
// The chat list beside the conversation: open or closed, kept per browser. A phone opens it as a drawer, closed at first.
|
|
23
|
-
const phone = () => matchMedia("(max-width:640px)").matches;
|
|
24
|
-
// Read when Home first draws, not at import: tests load this module with no window.
|
|
25
|
-
let side = null;
|
|
26
|
-
const sideAtStart = () => {
|
|
27
|
-
try {
|
|
28
|
-
return !phone() && localStorage.getItem("kz-hist") !== "0";
|
|
29
|
-
} catch (e) {
|
|
30
|
-
return !phone();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
function setSide(on) {
|
|
34
|
-
side = on;
|
|
35
|
-
$("home").classList.toggle("hopen", on);
|
|
36
|
-
for (const t of [$("htog"), $("hsidetop")]) if (t) t.setAttribute("aria-expanded", String(on)), (t.title = on ? "Hide chats" : "Show chats");
|
|
37
|
-
if (!phone())
|
|
38
|
-
try {
|
|
39
|
-
localStorage.setItem("kz-hist", on ? "1" : "0");
|
|
40
|
-
} catch (e) {}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const get = (u) => fetch(u).then((r) => r.json());
|
|
44
|
-
const post = (u, b) => fetch(u, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(b) });
|
|
45
|
-
const remember = (id) => { try { id ? sessionStorage.setItem("kz-chat", id) : sessionStorage.removeItem("kz-chat"); } catch (e) {} };
|
|
46
|
-
// The project a new chat starts in: the board's, unless it shows every project or none.
|
|
47
|
-
const here = () => (store.S.all || !store.S.dir || !(store.S.projects || []).some((p) => p.dir === store.S.dir) ? null : store.S.dir);
|
|
48
|
-
const name = (d) => short((store.S.projects || []).find((p) => p.dir === d)?.label || String(d).replace(/[\\/]\.kaizen$/, ""));
|
|
49
|
-
// The board follows the chat into its project.
|
|
50
|
-
const follow = (d) => d && d !== store.S.dir && pick(d);
|
|
51
|
-
|
|
52
|
-
const SUGGEST = ["What's waiting on me?", "Summarize what changed this week", "Plan a new feature: ", "Review my last change"];
|
|
53
|
-
// Run ids the agent named that are cards on this board: each becomes a button to its card.
|
|
54
|
-
const runsIn = (t) =>
|
|
55
|
-
[...new Set(String(t).match(/\b\d{4}-\d{2}-\d{2}-[a-z0-9-]+\b/g) || [])].filter((id) =>
|
|
56
|
-
store.S.cards.some((c) => c.kind === "run" && c.id === id),
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
function msg(m, i) {
|
|
60
|
-
const anim = i >= seen ? " in" : "";
|
|
61
|
-
if (m.role === "user") return html`<div class="hm u${anim}">${m.text ? html`<div class="hb">${m.text}</div>` : ""}${m.files?.length ? html`<div class="hfiles">${m.files.map((f) => html`<span>${ico("clip")}${f.name}</span>`)}</div>` : ""}</div>`;
|
|
62
|
-
const active = i === cur.messages.length - 1 && (sending || remoteBusy);
|
|
63
|
-
const steps = (m.steps || []).map(
|
|
64
|
-
(s) => html`<li class="${s.ok === false ? "bad" : ""}">${ico(s.kind === "edit" ? "note" : s.kind === "project" ? "board" : "term")}<code>${s.text}</code></li>`,
|
|
65
|
-
);
|
|
66
|
-
// A move is news, not a detail: shown under the reply as well as in the steps.
|
|
67
|
-
const moved = (m.steps || []).filter((s) => s.kind === "project");
|
|
68
|
-
const runs = runsIn(m.text + " " + (m.steps || []).map((s) => s.text).join(" "));
|
|
69
|
-
// Nothing yet: the typing dots stand in for the reply.
|
|
70
|
-
if (!steps.length && !m.text && !m.error && !active) return "";
|
|
71
|
-
return html`<div class="hm a${anim}">${m.text ? html`<div class="hb md">${raw(md(m.text))}</div>` : ""}${steps.length ? html`<details class="hsteps"><summary>${steps.length} step${steps.length > 1 ? "s" : ""}</summary><ul>${steps}</ul></details>` : ""}${m.error ? html`<div class="herr">${m.error}</div>` : ""}${moved.map((s) => html`<div class="hmove${s.ok === false ? " bad" : ""}">${ico("board")}${s.text}</div>`)}${runs.map((id) => html`<button class="btn ghost sm hrun" data-run="${id}">${ico("board")}Open ${id}</button>`)}${active ? html`<div class="hactivity" role="status"><span class="hmascot" aria-hidden="true"><i class="hlaptop"></i></span><span class="hactivity-copy"><span>${m.activity || "Thinking…"}</span><span class="hdots" aria-hidden="true"><i></i><i></i><i></i></span></span></div>` : ""}</div>`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function hero() {
|
|
75
|
-
const d = here();
|
|
76
|
-
return html`<div class="hhero"><h2>${d ? html`What should we do in ${name(d)}?` : "What should we work on?"}</h2><p class="hint">${d ? "Ask about this project or another one, or start a new one." : "Name a project, or describe a new one and the agent will set it up."} Bigger work becomes a kaizen run on the Board.</p></div>`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function chips() {
|
|
80
|
-
return html`<div class="hchips">${SUGGEST.map((s) => html`<button class="chip" data-s="${s}">${s}</button>`)}</div>`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function list() {
|
|
84
|
-
return html`<div class="hsin"><div class="hshd"><span>Chats</span></div><nav class="hlist" aria-label="Chats">${chats.map((c) => html`<div class="hli${cur && cur.id === c.id ? " on" : ""}"><button data-c="${c.id}" title="${c.title}">${c.busy ? html`<span class="dot"></span>` : ""}<span class="ht">${c.title}</span><span class="hp">${c.project ? name(c.project) : "No project"}</span></button><button class="ib sm" data-del="${c.id}" aria-label="Delete chat: ${c.title}" title="Delete chat">${ico("trash")}</button></div>`)}</nav></div>`;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function bindReply(root) {
|
|
88
|
-
root.querySelectorAll(".md a").forEach((a) => {
|
|
89
|
-
if (/^https?:/i.test(a.getAttribute("href") || "")) (a.target = "_blank"), (a.rel = "noopener noreferrer");
|
|
90
|
-
else a.replaceWith(Object.assign(document.createElement("span"), { textContent: a.textContent, title: a.getAttribute("href") || "" }));
|
|
91
|
-
});
|
|
92
|
-
root.querySelectorAll("[data-run]").forEach(
|
|
93
|
-
(b) =>
|
|
94
|
-
(b.onclick = () => {
|
|
95
|
-
const c = store.S.cards.find((x) => x.kind === "run" && x.id === b.dataset.run);
|
|
96
|
-
if (c) open(c);
|
|
97
|
-
}),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function updateReply(reply) {
|
|
102
|
-
const log = $("hlog");
|
|
103
|
-
const last = log?.lastElementChild;
|
|
104
|
-
if (!last?.classList.contains("hm") || !last.classList.contains("a")) return draw();
|
|
105
|
-
const top = log.scrollTop;
|
|
106
|
-
const stepsOpen = last.querySelector(".hsteps")?.open;
|
|
107
|
-
const markup = String(msg(reply, cur.messages.length - 1));
|
|
108
|
-
if (!markup) { last.remove(); log.scrollTop = following ? log.scrollHeight : top; return; }
|
|
109
|
-
const next = document.createElement("div");
|
|
110
|
-
next.innerHTML = markup;
|
|
111
|
-
last.replaceChildren(...next.firstElementChild.childNodes);
|
|
112
|
-
if (stepsOpen !== undefined && last.querySelector(".hsteps")) last.querySelector(".hsteps").open = stepsOpen;
|
|
113
|
-
bindReply(last);
|
|
114
|
-
log.scrollTop = following ? log.scrollHeight : top;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function bindChatItems(root) {
|
|
118
|
-
root.querySelectorAll("[data-c]").forEach(
|
|
119
|
-
(b) =>
|
|
120
|
-
(b.onclick = () => {
|
|
121
|
-
if (phone()) side = false;
|
|
122
|
-
show(b.dataset.c);
|
|
123
|
-
}),
|
|
124
|
-
);
|
|
125
|
-
root.querySelectorAll("[data-del]").forEach(
|
|
126
|
-
(b) =>
|
|
127
|
-
(b.onclick = async () => {
|
|
128
|
-
if (!confirm("Delete this chat?")) return;
|
|
129
|
-
const r = await post("/chat/delete", { id: b.dataset.del });
|
|
130
|
-
if (!r.ok) return toast((await r.json()).error);
|
|
131
|
-
if (cur && cur.id === b.dataset.del) { cur = null; remoteBusy = false; remember(null); }
|
|
132
|
-
refresh();
|
|
133
|
-
}),
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function drawList() {
|
|
138
|
-
const old = $("home").querySelector(".hlist");
|
|
139
|
-
if (!old) return;
|
|
140
|
-
const temp = document.createElement("div");
|
|
141
|
-
temp.innerHTML = String(list());
|
|
142
|
-
const nav = temp.querySelector(".hlist");
|
|
143
|
-
const top = old.scrollTop;
|
|
144
|
-
old.replaceWith(nav);
|
|
145
|
-
nav.scrollTop = top;
|
|
146
|
-
bindChatItems(nav);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const sendButton = () => sending || remoteBusy
|
|
150
|
-
? html`<button type="button" class="ib hgo stop" id="hstop" aria-label="Stop" title="Stop">${ico("x")}</button>`
|
|
151
|
-
: html`<button class="ib hgo" aria-label="Send" title="Send (Enter)">${ico("send")}</button>`;
|
|
152
|
-
|
|
153
|
-
function syncSendButton() {
|
|
154
|
-
const b = $("hbox")?.querySelector(".hgo");
|
|
155
|
-
if (b && b.classList.contains("stop") !== (sending || remoteBusy)) b.outerHTML = String(sendButton());
|
|
156
|
-
if ($("hstop")) $("hstop").onclick = () => post("/chat/stop", { id: cur && cur.id });
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function newChat() {
|
|
160
|
-
if (sending) return;
|
|
161
|
-
clearTimeout(poll);
|
|
162
|
-
cur = null;
|
|
163
|
-
attachments = [];
|
|
164
|
-
remoteBusy = false;
|
|
165
|
-
remember(null);
|
|
166
|
-
if (phone()) side = false;
|
|
167
|
-
vt(draw).then(() => $("hq").focus());
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function draw() {
|
|
171
|
-
const h = $("home");
|
|
172
|
-
// Full redraws keep the draft and caret; streamed replies update only the last message.
|
|
173
|
-
const typing = document.activeElement && document.activeElement.id === "hq" ? $("hq").selectionStart : -1;
|
|
174
|
-
const empty = !cur || !cur.messages.length;
|
|
175
|
-
// A redraw replaces the log: keep the reader where they were unless they were at the bottom.
|
|
176
|
-
const old = $("hlog");
|
|
177
|
-
if (shown !== (cur && cur.id)) following = true;
|
|
178
|
-
const top = old ? old.scrollTop : 0;
|
|
179
|
-
if (shown !== (cur && cur.id)) seen = 0;
|
|
180
|
-
if (side === null) side = sideAtStart();
|
|
181
|
-
h.classList.toggle("hopen", side);
|
|
182
|
-
h.innerHTML = String(html`<div class="hside">${list()}</div><div class="hscrim" id="hscrim"></div><div class="hmain${empty ? " hfresh" : ""}"><div class="htop"><button class="ib" id="htog" aria-label="Chats" aria-expanded="${String(side)}" title="${side ? "Hide chats" : "Show chats"}">${ico("side")}</button></div><div class="hlog" id="hlog" aria-live="polite">${empty ? hero() : cur.messages.map(msg)}</div><form class="hbox" id="hbox"><input id="hfile" type="file" multiple hidden><button type="button" class="ib hattach" id="hattach" aria-label="Attach files" title="Attach files">${ico("clip")}</button><div class="hinput"><div class="hatt" id="hatt"></div><textarea id="hq" rows="1" placeholder="${phone() ? "Ask or describe what to build…" : "Ask anything, or describe what to build…"}" aria-label="Message the agent"></textarea></div>${empty ? "" : html`<span class="hwhere" title="Project">${ico("board")}${cur.project ? name(cur.project) : "No project"}</span>`}${sendButton()}</form>${empty ? chips() : ""}</div>`);
|
|
183
|
-
seen = empty ? 0 : cur.messages.length;
|
|
184
|
-
shown = cur && cur.id;
|
|
185
|
-
$("htog").onclick = () => setSide(!side);
|
|
186
|
-
$("hsidetop").onclick = () => setSide(!side);
|
|
187
|
-
$("hscrim").onclick = () => setSide(false);
|
|
188
|
-
const q = $("hq");
|
|
189
|
-
renderAttachments();
|
|
190
|
-
$("hattach").disabled = sending;
|
|
191
|
-
$("hattach").onclick = () => $("hfile").click();
|
|
192
|
-
$("hfile").onchange = (e) => { addFiles([...e.target.files]); e.target.value = ""; };
|
|
193
|
-
q.onpaste = (e) => {
|
|
194
|
-
const files = [...e.clipboardData.items].filter((it) => it.kind === "file").map((it) => it.getAsFile()).filter(Boolean);
|
|
195
|
-
if (files.length) { e.preventDefault(); addFiles(files.map((f) => f.name === "image.png" ? new File([f], `paste-${Date.now()}.png`, { type: f.type }) : f)); }
|
|
196
|
-
};
|
|
197
|
-
$("hbox").ondragover = (e) => { if (Array.from(e.dataTransfer?.types || []).includes("Files")) e.preventDefault(); };
|
|
198
|
-
$("hbox").ondrop = (e) => { if (e.dataTransfer.files.length) { e.preventDefault(); addFiles([...e.dataTransfer.files]); } };
|
|
199
|
-
draft(q, "home:" + (cur ? cur.id : "new"));
|
|
200
|
-
grow(q);
|
|
201
|
-
q.oninput = () => grow(q);
|
|
202
|
-
q.onkeydown = (e) => {
|
|
203
|
-
if (e.key === "Enter" && !e.shiftKey && !e.isComposing && !phone()) { // no Shift on a phone: Enter is a new line, the Send button sends
|
|
204
|
-
e.preventDefault();
|
|
205
|
-
$("hbox").requestSubmit();
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
$("hbox").onsubmit = (e) => {
|
|
209
|
-
e.preventDefault();
|
|
210
|
-
send(q.value);
|
|
211
|
-
};
|
|
212
|
-
syncSendButton();
|
|
213
|
-
$("hnewtop").onclick = newChat;
|
|
214
|
-
// Pop out: `kaizen chat` opens the popup on this chat and hides this window.
|
|
215
|
-
$("hpop").onclick = () =>
|
|
216
|
-
fetch("/popup/open", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ id: cur?.id }) })
|
|
217
|
-
.then((r) => r.ok || toast("Could not open the popup"))
|
|
218
|
-
.catch(() => toast("Could not open the popup"));
|
|
219
|
-
$("hnewtop").disabled = sending;
|
|
220
|
-
bindChatItems(h);
|
|
221
|
-
h.querySelectorAll("[data-s]").forEach(
|
|
222
|
-
(b) =>
|
|
223
|
-
(b.onclick = () => {
|
|
224
|
-
q.value = b.dataset.s;
|
|
225
|
-
q.focus();
|
|
226
|
-
grow(q);
|
|
227
|
-
if (!b.dataset.s.endsWith(" ")) $("hbox").requestSubmit();
|
|
228
|
-
}),
|
|
229
|
-
);
|
|
230
|
-
if (typing >= 0) {
|
|
231
|
-
q.focus();
|
|
232
|
-
q.setSelectionRange(typing, typing);
|
|
233
|
-
}
|
|
234
|
-
// The agent links files by their path on disk, which the board cannot serve: the text stays, the path is its tooltip.
|
|
235
|
-
bindReply(h);
|
|
236
|
-
const log = $("hlog");
|
|
237
|
-
log.onwheel = (e) => { if (e.deltaY < 0 && log.scrollHeight > log.clientHeight) following = false; };
|
|
238
|
-
log.onscroll = () => { following = log.scrollHeight - log.scrollTop - log.clientHeight <= 0.5; };
|
|
239
|
-
if (following) log.scrollTop = log.scrollHeight;
|
|
240
|
-
else log.scrollTop = top;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function grow(t) {
|
|
244
|
-
t.style.height = "auto";
|
|
245
|
-
t.style.height = Math.min(t.scrollHeight, 220) + "px";
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function renderAttachments() {
|
|
249
|
-
const box = $("hatt");
|
|
250
|
-
if (!box) return;
|
|
251
|
-
box.innerHTML = String(html`${attachments.map((f, i) => html`<span>${ico("clip")}${f.name}<button type="button" data-file="${i}" aria-label="Remove ${f.name}">×</button></span>`)}`);
|
|
252
|
-
box.querySelectorAll("[data-file]").forEach((b) => b.onclick = () => { attachments.splice(Number(b.dataset.file), 1); renderAttachments(); });
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function addFiles(files) {
|
|
256
|
-
if (sending) { toast("Wait for the current reply"); return; }
|
|
257
|
-
for (const file of files) {
|
|
258
|
-
if (attachments.length >= 5 || file.size > 10 * 1024 * 1024 || attachments.reduce((n, f) => n + f.size, 0) + file.size > 20 * 1024 * 1024) { toast("Up to 5 files, 10 MB each and 20 MB total"); break; }
|
|
259
|
-
attachments.push(file);
|
|
260
|
-
}
|
|
261
|
-
renderAttachments();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
async function refreshChats() {
|
|
265
|
-
try {
|
|
266
|
-
chats = (await get("/chats")).chats || [];
|
|
267
|
-
} catch (e) {
|
|
268
|
-
chats = [];
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
async function refresh() {
|
|
273
|
-
await refreshChats();
|
|
274
|
-
draw();
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
async function show(id) {
|
|
278
|
-
const c = await get("/chat?id=" + encodeURIComponent(id));
|
|
279
|
-
if (c.error) return toast(c.error);
|
|
280
|
-
if (cur?.id !== c.id) attachments = [];
|
|
281
|
-
const same = cur?.id === c.id && cur.messages.length === c.messages.length && !!$("hlog");
|
|
282
|
-
// The list's busy dot is from the last /chats: a turn that ended since redraws it.
|
|
283
|
-
const listed = chats.find((x) => x.id === c.id);
|
|
284
|
-
const ended = listed && listed.busy && !c.busy;
|
|
285
|
-
if (listed) listed.busy = !!c.busy;
|
|
286
|
-
cur = c;
|
|
287
|
-
remoteBusy = !!c.busy;
|
|
288
|
-
remember(c.id);
|
|
289
|
-
if (same && !ended) { updateReply(c.messages.at(-1)); syncSendButton(); }
|
|
290
|
-
else draw();
|
|
291
|
-
follow(c.project);
|
|
292
|
-
// A turn started from another tab, or before a reload, is still running: follow it until it saves.
|
|
293
|
-
clearTimeout(poll);
|
|
294
|
-
if (c.busy && !sending) poll = setTimeout(() => cur && cur.id === id && show(id), 2000);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
async function send(text) {
|
|
298
|
-
text = text.trim();
|
|
299
|
-
if ((!text && !attachments.length) || sending || remoteBusy) return;
|
|
300
|
-
const files = attachments;
|
|
301
|
-
attachments = [];
|
|
302
|
-
clearTimeout(poll);
|
|
303
|
-
const at = new Date().toISOString();
|
|
304
|
-
const was = cur ? cur.id : "new";
|
|
305
|
-
const fresh = !cur || !cur.messages.length;
|
|
306
|
-
cur = cur || { id: null, title: text || files[0].name, project: here(), messages: [] };
|
|
307
|
-
const reply = { role: "agent", text: "", steps: [], activity: "Thinking…", at };
|
|
308
|
-
cur.messages.push({ role: "user", text, files: files.map((f) => ({ name: f.name })), at }, reply);
|
|
309
|
-
sending = true;
|
|
310
|
-
try {
|
|
311
|
-
sessionStorage.removeItem(DK + "home:" + was);
|
|
312
|
-
if (fresh) sessionStorage.setItem("kz-chat-pending", at);
|
|
313
|
-
} catch (e) {}
|
|
314
|
-
// The first message: the box glides from the middle to the bottom.
|
|
315
|
-
following = true;
|
|
316
|
-
await (fresh ? vt(draw) : (draw(), undefined));
|
|
317
|
-
$("hlog").scrollTop = $("hlog").scrollHeight;
|
|
318
|
-
let accepted = false;
|
|
319
|
-
try {
|
|
320
|
-
const form = new FormData();
|
|
321
|
-
form.set("id", cur.id || ""); form.set("text", text); form.set("project", cur.project || "");
|
|
322
|
-
files.forEach((f) => form.append("files", f));
|
|
323
|
-
const r = files.length ? await fetch("/chat", { method: "POST", body: form }) : await post("/chat", { id: cur.id, text, project: cur.project });
|
|
324
|
-
if (!r.ok) {
|
|
325
|
-
reply.error = (await r.json()).error || "Could not send";
|
|
326
|
-
attachments = [...files, ...attachments]; renderAttachments();
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
accepted = true;
|
|
330
|
-
const rd = r.body.getReader(),
|
|
331
|
-
dec = new TextDecoder();
|
|
332
|
-
let buf = "";
|
|
333
|
-
for (let x; !(x = await rd.read()).done; ) {
|
|
334
|
-
buf += dec.decode(x.value, { stream: true });
|
|
335
|
-
let i;
|
|
336
|
-
while ((i = buf.indexOf("\n")) >= 0) {
|
|
337
|
-
const line = buf.slice(0, i);
|
|
338
|
-
buf = buf.slice(i + 1);
|
|
339
|
-
let e;
|
|
340
|
-
try {
|
|
341
|
-
e = JSON.parse(line);
|
|
342
|
-
} catch (err) {
|
|
343
|
-
continue;
|
|
344
|
-
}
|
|
345
|
-
if (e.t === "chat") {
|
|
346
|
-
cur.id = shown = e.id;
|
|
347
|
-
remember(e.id);
|
|
348
|
-
try { sessionStorage.removeItem("kz-chat-pending"); } catch (err) {}
|
|
349
|
-
// In the list from its first message, marked busy, not only once the turn ends.
|
|
350
|
-
get("/chats").then((r) => {
|
|
351
|
-
chats = r.chats || chats;
|
|
352
|
-
drawList();
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
if (e.t === "text") reply.text += (reply.text ? "\n\n" : "") + e.text;
|
|
356
|
-
if (e.t === "status") reply.activity = e.text;
|
|
357
|
-
if (e.t === "step") { reply.steps.push(e.step); reply.activity = "Thinking…"; }
|
|
358
|
-
if (e.t === "error") reply.error = e.error;
|
|
359
|
-
if (e.t === "project") {
|
|
360
|
-
cur.project = e.dir;
|
|
361
|
-
follow(e.dir);
|
|
362
|
-
}
|
|
363
|
-
updateReply(reply);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
} catch (e) {
|
|
367
|
-
reply.error = "Lost the connection; the agent keeps going and the chat saves when it finishes.";
|
|
368
|
-
if (!accepted) { attachments = [...files, ...attachments]; renderAttachments(); }
|
|
369
|
-
} finally {
|
|
370
|
-
try { sessionStorage.removeItem("kz-chat-pending"); } catch (e) {}
|
|
371
|
-
sending = false;
|
|
372
|
-
delete reply.activity;
|
|
373
|
-
if (accepted && cur?.id) {
|
|
374
|
-
try { await show(cur.id); }
|
|
375
|
-
catch { remoteBusy = false; updateReply(reply); }
|
|
376
|
-
} else { remoteBusy = false; updateReply(reply); }
|
|
377
|
-
syncSendButton();
|
|
378
|
-
$("hattach").disabled = false;
|
|
379
|
-
$("hnewtop").disabled = false;
|
|
380
|
-
await refreshChats();
|
|
381
|
-
drawList();
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// The Home view opens: every chat, and the open one kept.
|
|
386
|
-
export async function openHome() {
|
|
387
|
-
await refreshChats();
|
|
388
|
-
let id;
|
|
389
|
-
try { id = sessionStorage.getItem("kz-chat"); } catch (e) {}
|
|
390
|
-
if (!id) {
|
|
391
|
-
try {
|
|
392
|
-
const pending = sessionStorage.getItem("kz-chat-pending");
|
|
393
|
-
if (pending) id = chats.find((c) => c.updated >= pending)?.id;
|
|
394
|
-
} catch (e) {}
|
|
395
|
-
}
|
|
396
|
-
// A new tab has no chat of its own yet: a chat still working is the one to follow.
|
|
397
|
-
if (!id) id = chats.find((c) => c.busy)?.id;
|
|
398
|
-
if (id && chats.some((c) => c.id === id)) await show(id);
|
|
399
|
-
else { remember(null); draw(); }
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// Back from the popup (`kaizen chat`): the server brings this window back and hands
|
|
403
|
-
// over the chat the popup was on; Home opens it. A browser window coming back from a
|
|
404
|
-
// hidden Hyprland workspace fires no focus event, so Home asks every 1.5 s.
|
|
405
|
-
async function takeHandoff() {
|
|
406
|
-
const r = await fetch("/popup/handoff").then((r) => r.json()).catch(() => null);
|
|
407
|
-
if (!r?.id) return;
|
|
408
|
-
await refreshChats();
|
|
409
|
-
if (chats.some((c) => c.id === r.id)) await show(r.id);
|
|
410
|
-
}
|
|
411
|
-
// ponytail: polling; push it through the board's state stream if this ever costs anything.
|
|
412
|
-
if (typeof document !== "undefined") setInterval(() => globalThis.document?.body?.classList.contains("homev") && takeHandoff(), 1500);
|
|
413
|
-
|
|
414
|
-
// A project picked above: a new chat's greeting names it. Only then: a redraw replays the greeting's entrance.
|
|
415
|
-
let greeted;
|
|
416
|
-
addEventListener("kz-state", () => {
|
|
417
|
-
const d = here();
|
|
418
|
-
if (d === greeted) return;
|
|
419
|
-
greeted = d;
|
|
420
|
-
if (document.body.classList.contains("homev") && !sending && (!cur || !cur.messages.length)) draw();
|
|
421
|
-
});
|