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/cli/web.ts
CHANGED
|
@@ -7,13 +7,13 @@ import { join, dirname, resolve, sep, basename } from "node:path";
|
|
|
7
7
|
import {
|
|
8
8
|
home, type Item, type Card, knownProjects, remember, reorderProjects, canonPath, locate, label, tilde, searchRoots, findProjects,
|
|
9
9
|
readInbox, writeInbox, replaceTask, moveTask, abandonRun, runToTask, launchRun, parseItem, agentChoices, onPath, projectOf, KNOWN_AGENTS, plainModel, short, setArchived, writeNotes,
|
|
10
|
-
appendNote, saveAttachment, pidOnPort, readText, cmdExe, sysExe, powershellExe, runGit, readCommit, commitPush, commitStaged, stageFiles, suggestMessage, notice,
|
|
10
|
+
appendNote, saveAttachment, pidOnPort, readText, cmdExe, sysExe, powershellExe, runGit, readCommit, commitPush, commitStaged, stageFiles, suggestMessage, notice, LOGO,
|
|
11
11
|
reviewFindings, pickFindings, backlogItem, startedBacklog, closeBacklog, markBacklogDone, fixPrompt, approvalPrompt, canApproveAwaiting, gateOf, recordAcceptance, healRuns, finishRun, nativePath, closeSessions, sweepSessions, issueUrl,
|
|
12
|
-
|
|
12
|
+
pruneRuns, pruneSessions, readSessions, ownerOf, runIndex, resumePrompt, runAgent, firstSession, webHosts,
|
|
13
13
|
} from "./state.ts";
|
|
14
14
|
import { ACCOUNT_EXTRA, ACCOUNT_VAR, accountDir, agyLogin, addAccount, loginStatus, readAccounts, renameAccount, removeAccount, resolveAccount, setDefaultAccount, type Login, type Tool } from "./accounts.ts";
|
|
15
15
|
import { readReport, signalOf } from "./report.ts";
|
|
16
|
-
import { MAX_IMAGE, saveImage } from "./term-image.ts";
|
|
16
|
+
import { MAX_FILE, MAX_IMAGE, saveFile, saveImage } from "./term-image.ts";
|
|
17
17
|
import { shellHistory } from "./term-history.ts";
|
|
18
18
|
import { bundledSkills, repairSkill, setSkill, skillsHeld, skillsOff, skillStatus } from "./skills.ts";
|
|
19
19
|
import * as rea from "./rea.ts";
|
|
@@ -22,6 +22,7 @@ import { agentLine, failStart, handoffModel, markRunning, readWorkers, requested
|
|
|
22
22
|
import { childDied, childQuiet, markWoken, move, requestOpen, readHandoff, refused, started, wakeAction, wakeLine, type Handoff } from "./handoff.ts";
|
|
23
23
|
import { processTable, storage, systemMemory, treeRss, type Root } from "./resources.ts";
|
|
24
24
|
import { attachPty, frames, writePty, submitPty, resizePty, exitPty, killPty, panePid, ptyState, ptyKeys, adoptLoginEnv, startPty, ptySupported, detachPty, ptyTail, ptyTmux, tmuxAlive, RESUMED } from "./pty.ts";
|
|
25
|
+
import { conflictPort, holders, inProjects, isKaizenProcess, listeners, stopPort } from "./ports.ts";
|
|
25
26
|
import { snapshot, snapWorker } from "./state-snap.ts";
|
|
26
27
|
import { claudeUsage, claudeUsageAt, codexUsage, codexUsageAt, phonePeers, type Usage } from "./usage.ts";
|
|
27
28
|
import { readSources, addSource, removeSource, moveSource, setCategory, setWriteback, setPaused, readIcebox, applySort, promote, dismiss, restore, capture, editItem, setKind, setTags, setBoard, saveBoard, removeBoard, snooze, unsnooze, readBoards, kindOf, isSnoozed, markDone, markReplied, gatherSource, freshImages, gatherAll, gatherDirs, due, socialUrl, socialOf } from "./sources.ts";
|
|
@@ -46,24 +47,31 @@ import * as taskService from "./task-service.ts";
|
|
|
46
47
|
import { artifactResponse as taskArtifactResponse } from "./task-results.ts";
|
|
47
48
|
import { gitUrl, destDir, winBad, cloneInto, branchesOf, ignoreKaizen } from "./add-project.ts";
|
|
48
49
|
|
|
49
|
-
const PAGE = join(dirname(import.meta.dir), "web", "board.html");
|
|
50
|
-
// The board's script: web/board
|
|
51
|
-
const BOARD_JS = join(dirname(import.meta.dir), "web", "board.js");
|
|
50
|
+
const PAGE = join(dirname(import.meta.dir), "web", "html", "board.html");
|
|
51
|
+
// The board's script: web/pages/board/main.ts with web/lib and web/components, bundled into one file by `bun run build:web`.
|
|
52
|
+
const BOARD_JS = join(dirname(import.meta.dir), "web", "dist", "board.js");
|
|
52
53
|
const SOUNDS_DIR = join(dirname(import.meta.dir), "web", "sounds");
|
|
53
|
-
// The notebook: its page, and the CodeMirror bundle `bun run build:web` commits
|
|
54
|
-
const NOTES_PAGE = join(dirname(import.meta.dir), "web", "notes.html");
|
|
54
|
+
// The notebook: its page, and the CodeMirror bundle `bun run build:web` commits to web/dist.
|
|
55
|
+
const NOTES_PAGE = join(dirname(import.meta.dir), "web", "html", "notes.html");
|
|
55
56
|
const ICO = join(dirname(import.meta.dir), "assets", "kaizen.ico");
|
|
56
|
-
const
|
|
57
|
+
const UI_CSS = join(dirname(import.meta.dir), "web", "dist", "ui.css");
|
|
58
|
+
const NOTES_JS = join(dirname(import.meta.dir), "web", "dist", "notebook.js");
|
|
57
59
|
// The in-card terminal (agent.launch: card): xterm.js, bundled the same way.
|
|
58
|
-
const TERM_JS = join(dirname(import.meta.dir), "web", "term.js");
|
|
59
|
-
const ANNOTATE_JS = join(dirname(import.meta.dir), "web", "annotate.js");
|
|
60
|
-
const TERM_CSS = join(dirname(import.meta.dir), "web", "term.css");
|
|
60
|
+
const TERM_JS = join(dirname(import.meta.dir), "web", "dist", "term.js");
|
|
61
|
+
const ANNOTATE_JS = join(dirname(import.meta.dir), "web", "dist", "annotate.js");
|
|
62
|
+
const TERM_CSS = join(dirname(import.meta.dir), "web", "dist", "term.css");
|
|
61
63
|
// The Video page (kaizen-video's library, editor and renders) and its bundle.
|
|
62
|
-
const VIDEO_PAGE = join(dirname(import.meta.dir), "web", "video.html");
|
|
63
|
-
const POPUP_PAGE = join(dirname(import.meta.dir), "web", "popup.html");
|
|
64
|
+
const VIDEO_PAGE = join(dirname(import.meta.dir), "web", "html", "video.html");
|
|
65
|
+
const POPUP_PAGE = join(dirname(import.meta.dir), "web", "html", "popup.html");
|
|
66
|
+
// Each page's one stylesheet (the kit's Tailwind and the page's own styles) and the chat popup's script.
|
|
67
|
+
const dist = (f: string) => join(dirname(import.meta.dir), "web", "dist", f);
|
|
68
|
+
const STYLES: Record<string, string> = { "/board.css": dist("board.css"), "/notebook.css": dist("notebook.css"), "/popup.css": dist("popup.css") };
|
|
69
|
+
const POPUP_JS = dist("popup.js");
|
|
70
|
+
// The blocking head script of the board and the Notebook: the stored theme is on <html> before the first paint.
|
|
71
|
+
const BOOT_JS = dist("boot.js");
|
|
64
72
|
// The chat the popup was on when its Back button was pressed, until Home takes it.
|
|
65
73
|
let popupChat: string | null = null;
|
|
66
|
-
const VIDEO_JS = join(dirname(import.meta.dir), "web", "video.js");
|
|
74
|
+
const VIDEO_JS = join(dirname(import.meta.dir), "web", "dist", "video.js");
|
|
67
75
|
const DEFAULT_PORT = 7420;
|
|
68
76
|
// Gathered posts a reply is going out to right now: one send per item at a time.
|
|
69
77
|
const replying = new Set<string>();
|
|
@@ -87,8 +95,15 @@ delete process.env.KAIZEN_DESKTOP_BUNDLED;
|
|
|
87
95
|
// page newer than its server sends ops the server does not know ("unknown op").
|
|
88
96
|
// So the pages are kept as they were at start, and read live (dev edits) only while
|
|
89
97
|
// the installed version is still the one this board runs.
|
|
90
|
-
const AT_START = new Map([PAGE, BOARD_JS, NOTES_PAGE, NOTES_JS, TERM_JS, TERM_CSS, VIDEO_PAGE, VIDEO_JS, ANNOTATE_JS].map((f) => [f, existsSync(f) ? readText(f) : null]));
|
|
91
|
-
|
|
98
|
+
const AT_START = new Map([PAGE, BOARD_JS, NOTES_PAGE, NOTES_JS, TERM_JS, TERM_CSS, VIDEO_PAGE, VIDEO_JS, ANNOTATE_JS, UI_CSS, POPUP_PAGE, POPUP_JS, BOOT_JS, ...Object.values(STYLES)].map((f) => [f, existsSync(f) ? readText(f) : null]));
|
|
99
|
+
// `bun run dev` (cli/dev.ts) sets KAIZEN_DEV: every page file is read from disk on each request, and pages get a small
|
|
100
|
+
// script that reloads them when the dev script has rebuilt the bundles (GET /__dev/stream, POST /__dev/reload).
|
|
101
|
+
const DEV = process.env.KAIZEN_DEV === "1";
|
|
102
|
+
const DEV_TAG = `<script>new EventSource("/__dev/stream").onmessage=(e)=>{if(e.data==="reload")location.reload()}</script>`;
|
|
103
|
+
const served = (f: string) => {
|
|
104
|
+
const body = DEV ? (existsSync(f) ? readText(f) : null) : installed() === VERSION && existsSync(f) ? readText(f) : AT_START.get(f) ?? null;
|
|
105
|
+
return DEV && body !== null && f.endsWith(".html") ? body.replace("</head>", DEV_TAG + "</head>") : body;
|
|
106
|
+
};
|
|
92
107
|
|
|
93
108
|
// A board answers at url and runs the installed version. A board from before the
|
|
94
109
|
// version header sends none, so it counts as stale too.
|
|
@@ -282,17 +297,44 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
282
297
|
: [cur]
|
|
283
298
|
).filter((d, i, arr) => arr.indexOf(d) === i && existsSync(d));
|
|
284
299
|
|
|
300
|
+
// A run's decision sent to its agent: the agent already open in this run's card takes it
|
|
301
|
+
// there, as it takes a fix: no second tab of the same conversation. With none, the run's
|
|
302
|
+
// conversation continues in one new window, and then the idle one ends. A failed launch
|
|
303
|
+
// leaves it open, since the decision went nowhere.
|
|
304
|
+
const sendDecision = (dir: string, id: string, awaiting: string, why?: string, answers?: string[]) => {
|
|
305
|
+
const text = approvalPrompt(id, awaiting, why, answers);
|
|
306
|
+
const live = liveAgent(dir, id);
|
|
307
|
+
const before = Date.now();
|
|
308
|
+
const r = live ? { ok: true as const, pty: live.key, agent: live.cmd, reused: true } : launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard);
|
|
309
|
+
if (live) submitPty(live.key, text);
|
|
310
|
+
else if (r.ok) closeSessions(dir, id, { before });
|
|
311
|
+
// The plan's approval starts the build; fixing open findings is the review stage again.
|
|
312
|
+
if (r.ok) markStage(dir, id, awaiting === "approvals.plan" ? "impl" : awaiting === "findings" ? "review" : "", r.pty);
|
|
313
|
+
// Approving the review as-is is the user's acceptance, on record before the
|
|
314
|
+
// agent marks the run done; a revise is not.
|
|
315
|
+
if (r.ok && why === undefined && (awaiting === "approvals.review" || awaiting === "findings")) recordAcceptance(dir, id, "board");
|
|
316
|
+
return { r, live };
|
|
317
|
+
};
|
|
318
|
+
// A task whose run was just approved picks the approval up as its Looks good.
|
|
319
|
+
const syncTask = (dir: string, taskId: string) => {
|
|
320
|
+
try { const found = tasks.resolveTask(dir, taskId); if (found) taskService.reconcile(found.state, found.task, taskHooks); } catch { /* the next read reconciles */ }
|
|
321
|
+
};
|
|
285
322
|
const taskHooks = {
|
|
323
|
+
approve: (dir: string, id: string, awaiting: string) => { const { r } = sendDecision(dir, id, awaiting); return r.ok ? null : (r.why || "The run's agent could not be reached"); },
|
|
286
324
|
launch: (dir: string, id: string, text: string, task: tasks.Task, pick?: any) => {
|
|
287
325
|
const live = liveAgent(dir, id);
|
|
288
326
|
if (live) { submitPty(live.key, text); return { ok: true, pty: live.key }; }
|
|
289
|
-
return launchRun({ severity: null, where: null, text, raw: text }, dir, id, { ...inCard
|
|
327
|
+
return launchRun({ severity: null, where: null, text, raw: text }, dir, id, { ...inCard, ...(pick ? { agent: KNOWN_AGENTS.some((a) => a.cmd === pick.agent) ? pick.agent : undefined, account: typeof pick.account === "string" ? pick.account : undefined, explore: typeof pick.explore === "boolean" ? pick.explore : undefined, yolo: pick.yolo === true } : {}), task: { id: task.id, requirePlanConfirmation: !task.initialConfirmed } });
|
|
290
328
|
},
|
|
291
329
|
alive: (key: string) => ptyState(key)?.alive === true,
|
|
292
330
|
stop: (key: string) => killPty(key),
|
|
331
|
+
find: (dir: string, run: string) => liveAgent(dir, run)?.key,
|
|
293
332
|
};
|
|
294
333
|
const taskPump = setInterval(() => {
|
|
295
334
|
for (const dir of states(true)) for (const task of tasks.listTasks(dir)) {
|
|
335
|
+
// A stopping task is asked to stop again until its terminal is gone, not only when someone opens it.
|
|
336
|
+
// A ready task also picks up its run's acceptance given in the agent terminal (kaizen done --user-approved).
|
|
337
|
+
if ((task.status === "stopping" || task.status === "ready") && !task.archived) { try { if (taskService.reconcile(dir, task, taskHooks).revision !== task.revision) changed(); } catch { /* next pass */ } if (task.status === "stopping") continue; }
|
|
296
338
|
if (!task.safe || task.queuePaused || task.pendingDecision || !task.inputs.some(i => i.state === "queued")) continue;
|
|
297
339
|
try { taskService.dispatchReady(dir, task.id, taskHooks); changed(); } catch { /* CAS conflict: next pass reads the new state */ }
|
|
298
340
|
}
|
|
@@ -358,6 +400,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
358
400
|
// Change notification: one SSE stream per open board, fed by fs.watch where it
|
|
359
401
|
// works and a slow poll where it does not.
|
|
360
402
|
const clients = new Set<ReadableStreamDefaultController>();
|
|
403
|
+
const devClients = new Set<ReadableStreamDefaultController>();
|
|
361
404
|
// Shells the board started (POST /shell), by /pty key; dead ones drop on the next /shells.
|
|
362
405
|
const shells = new Map<string, { key: string; dir: string; title: string; agent: string; run: string; ws?: string; pid?: number }>();
|
|
363
406
|
const SHELL_CAP = 8;
|
|
@@ -395,8 +438,8 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
395
438
|
for (const c of clients) { try { c.enqueue("data: changed\n\n"); } catch { clients.delete(c); } }
|
|
396
439
|
}, 200);
|
|
397
440
|
};
|
|
398
|
-
//
|
|
399
|
-
const inCard =
|
|
441
|
+
// What this board launches runs inside the board, shown on the card.
|
|
442
|
+
const inCard = { card: true, onChange: changed };
|
|
400
443
|
|
|
401
444
|
// The agent open in a run's card, the newest when there are several: what the user sees
|
|
402
445
|
// working. Everything sent to a run goes here before any new agent is started.
|
|
@@ -431,7 +474,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
431
474
|
const prev = readSessions(dir).filter((s) => ownerOf(dir, s, idx) === id && existsSync(tailOf(s.key))).pop();
|
|
432
475
|
let seed: string | undefined;
|
|
433
476
|
try { if (prev) seed = readText(tailOf(prev.key)) + RESUMED; } catch { /* shown without it */ }
|
|
434
|
-
const r = launchRun({ severity: null, where: null, text, raw: text }, dir, id, { ...inCard
|
|
477
|
+
const r = launchRun({ severity: null, where: null, text, raw: text }, dir, id, { ...inCard, seed });
|
|
435
478
|
if (r.ok) closeSessions(dir, id, { before });
|
|
436
479
|
if (r.ok && prev) rmSync(tailOf(prev.key), { force: true });
|
|
437
480
|
changed();
|
|
@@ -798,9 +841,8 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
798
841
|
|
|
799
842
|
if (req.method === "GET" && path === "/") {
|
|
800
843
|
const page = served(PAGE);
|
|
801
|
-
if (page === null) return new Response("web/board.html missing", { status: 500 });
|
|
802
|
-
|
|
803
|
-
return new Response(page.replace("/*notifier*/", () => notifier.toString()), {
|
|
844
|
+
if (page === null) return new Response("web/html/board.html missing", { status: 500 });
|
|
845
|
+
return new Response(page, {
|
|
804
846
|
headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store", "x-kaizen-version": VERSION },
|
|
805
847
|
});
|
|
806
848
|
}
|
|
@@ -811,6 +853,19 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
811
853
|
return new Response(body, { headers: { "content-type": "application/javascript; charset=utf-8", "cache-control": "no-store" } });
|
|
812
854
|
}
|
|
813
855
|
|
|
856
|
+
// The React pages' Tailwind (web/ui/theme.css compiled by bun run build:web).
|
|
857
|
+
if (req.method === "GET" && path === "/ui.css") {
|
|
858
|
+
const body = served(UI_CSS);
|
|
859
|
+
if (body === null) return new Response(`${path} missing; run bun run build:web`, { status: 500 });
|
|
860
|
+
return new Response(body, { headers: { "content-type": "text/css; charset=utf-8", "cache-control": "no-store" } });
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
if (req.method === "GET" && STYLES[path]) {
|
|
864
|
+
const body = served(STYLES[path]);
|
|
865
|
+
if (body === null) return new Response(`${path} missing; run bun run build:web`, { status: 500 });
|
|
866
|
+
return new Response(body, { headers: { "content-type": "text/css; charset=utf-8", "cache-control": "no-store" } });
|
|
867
|
+
}
|
|
868
|
+
|
|
814
869
|
if (req.method === "GET" && path.startsWith("/sounds/")) {
|
|
815
870
|
const name = /^\/sounds\/([A-Za-z]+)\.mp3$/.exec(path)?.[1];
|
|
816
871
|
const file = name && join(SOUNDS_DIR, `${name}.mp3`);
|
|
@@ -825,11 +880,17 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
825
880
|
return new Response(body, { headers: { "content-type": type, "cache-control": "no-store" } });
|
|
826
881
|
}
|
|
827
882
|
|
|
883
|
+
if (req.method === "GET" && path === "/boot.js") {
|
|
884
|
+
const body = served(BOOT_JS);
|
|
885
|
+
if (body === null) return new Response(`${path} missing; run bun run build:web`, { status: 500 });
|
|
886
|
+
return new Response(body, { headers: { "content-type": "application/javascript; charset=utf-8", "cache-control": "no-store" } });
|
|
887
|
+
}
|
|
888
|
+
|
|
828
889
|
// `kaizen chat`: the small chat window over the desktop.
|
|
829
|
-
if (req.method === "GET" && path === "/popup") {
|
|
830
|
-
const body = served(POPUP_PAGE);
|
|
831
|
-
if (body === null) return new Response(
|
|
832
|
-
return new Response(body, { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" } });
|
|
890
|
+
if (req.method === "GET" && (path === "/popup" || path === "/popup.js")) {
|
|
891
|
+
const body = served(path === "/popup" ? POPUP_PAGE : POPUP_JS);
|
|
892
|
+
if (body === null) return new Response(`${path} missing; run bun run build:web`, { status: 500 });
|
|
893
|
+
return new Response(body, { headers: { "content-type": path === "/popup" ? "text/html; charset=utf-8" : "application/javascript; charset=utf-8", "cache-control": "no-store" } });
|
|
833
894
|
}
|
|
834
895
|
|
|
835
896
|
// Handing the chat between Home and the popup (`kaizen chat`). /popup/open:
|
|
@@ -1009,6 +1070,16 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1009
1070
|
const saved = saveImage(bytes);
|
|
1010
1071
|
return saved ? json({ path: saved }) : bad("not an image", 415);
|
|
1011
1072
|
}
|
|
1073
|
+
// The phone's Attach key: any file, saved on this computer under its own name, and its path typed into the terminal.
|
|
1074
|
+
if (req.method === "POST" && path === "/term-file") {
|
|
1075
|
+
if (!sameOrigin(req)) return bad("cross-origin request refused", 403);
|
|
1076
|
+
if (Number(req.headers.get("content-length") ?? 0) > MAX_FILE) return bad("file too large (25 MB at most)", 413);
|
|
1077
|
+
let name = "file";
|
|
1078
|
+
try { name = decodeURIComponent(req.headers.get("x-file-name") ?? "file"); } catch {}
|
|
1079
|
+
const bytes = new Uint8Array(await req.arrayBuffer());
|
|
1080
|
+
const saved = saveFile(bytes, name);
|
|
1081
|
+
return saved ? json({ path: saved }) : bad(bytes.length ? "file too large (25 MB at most)" : "empty file", bytes.length ? 413 : 400);
|
|
1082
|
+
}
|
|
1012
1083
|
if (req.method === "POST" && path === "/shell") {
|
|
1013
1084
|
const refused = strict(req);
|
|
1014
1085
|
if (refused) return refused;
|
|
@@ -1278,6 +1349,35 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1278
1349
|
// Never the board itself: `kaizen web` started inside the workspace listens there too.
|
|
1279
1350
|
return json(devPorts(out, (pid) => { try { return readlinkSync(`/proc/${pid}/cwd`); } catch { return ""; } }, ws, [...KNOWN_AGENTS.map((a) => a.cmd), "cursor-agent"]).filter((p) => p !== port));
|
|
1280
1351
|
}
|
|
1352
|
+
// A dev server (POST /shell with dev) whose terminal says its port is taken: that port and who holds it, for the Run app
|
|
1353
|
+
// button's "Stop it and run the app" question. Read from the terminal's own output, so nothing is guessed.
|
|
1354
|
+
if (req.method === "GET" && path === "/shell/conflict") {
|
|
1355
|
+
if (!local(req)) return bad("cross-origin request refused", 403);
|
|
1356
|
+
const key = url.searchParams.get("key") ?? "";
|
|
1357
|
+
// The shell may already have left /shells (dead ones drop there); its output is kept a little longer.
|
|
1358
|
+
const p = /^sh-[\w-]+$/.test(key) ? conflictPort(ptyTail(key) ?? "") : null;
|
|
1359
|
+
return json(p ? { port: p, holders: await holders(p), board: p === port } : { port: null });
|
|
1360
|
+
}
|
|
1361
|
+
// The ports this user's processes listen on, inside the board's projects (the Resources popup's Ports). Not the board's own,
|
|
1362
|
+
// not the agents (Claude Code listens on a local port of its own). Linux only; elsewhere the list is empty.
|
|
1363
|
+
if (req.method === "GET" && path === "/ports") {
|
|
1364
|
+
if (!local(req)) return bad("cross-origin request refused", 403);
|
|
1365
|
+
const dirs = states(true).filter((d) => d !== join(home, ".kaizen")).map((d) => dirname(d));
|
|
1366
|
+
const agents = [...KNOWN_AGENTS.map((a) => a.cmd), "cursor-agent"];
|
|
1367
|
+
const list = inProjects(await listeners(), dirs).filter((l) => l.pid !== process.pid && l.port !== port && !agents.includes(l.name) && !isKaizenProcess(l.cmd));
|
|
1368
|
+
return json(list.map((l) => ({ port: l.port, pid: l.pid, name: l.name, cmd: l.cmd, cwd: l.cwd, project: label(join(l.project, ".kaizen")) })));
|
|
1369
|
+
}
|
|
1370
|
+
// Stops what listens on a port (the question above, answered yes): a process of this user, never the board itself.
|
|
1371
|
+
if (req.method === "POST" && path === "/port/stop") {
|
|
1372
|
+
const refused = strict(req);
|
|
1373
|
+
if (refused) return refused;
|
|
1374
|
+
let body: any;
|
|
1375
|
+
try { body = await req.json(); } catch { return bad("json body expected"); }
|
|
1376
|
+
const n = Number(body?.port);
|
|
1377
|
+
if (n === port) return bad("that is the board itself");
|
|
1378
|
+
const r = await stopPort(n, [process.pid]);
|
|
1379
|
+
return r.ok ? json(r) : bad(r.error ?? "could not stop it");
|
|
1380
|
+
}
|
|
1281
1381
|
// A phone on the tailnet cannot reach this computer's localhost. Serves that loopback port
|
|
1282
1382
|
// to the tailnet (`tailscale serve --https=<port>`, never funnel) and answers the address
|
|
1283
1383
|
// the phone opens instead. Loopback http only, one argv, never a shell string.
|
|
@@ -1346,7 +1446,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1346
1446
|
// Not the board itself: a proxy to it would forward /pty with an Origin rewritten to the board's own.
|
|
1347
1447
|
if (u.port === (new URL(req.url).port || "80")) return bad("that is the board's own port", 400);
|
|
1348
1448
|
try {
|
|
1349
|
-
const px = openProxy(u);
|
|
1449
|
+
const px = openProxy(u, () => served(ANNOTATE_JS));
|
|
1350
1450
|
return json({ ok: true, origin: px.origin, token: px.token, url: px.origin + u.pathname + u.search + u.hash });
|
|
1351
1451
|
} catch (e) { return bad((e as Error).message, 500); }
|
|
1352
1452
|
}
|
|
@@ -1509,7 +1609,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1509
1609
|
if (path === "/task-artifact") return taskArtifactResponse(found.state, found.task.id, url.searchParams.get("result") ?? "", url.searchParams.get("artifact") ?? "", req, url.searchParams.get("download") === "1");
|
|
1510
1610
|
let task = taskService.reconcile(found.state, found.task, taskHooks);
|
|
1511
1611
|
if (task.safe && !task.queuePaused && !task.pendingDecision && task.inputs.some(i => i.state === "queued")) task = taskService.dispatchReady(found.state, task.id, taskHooks);
|
|
1512
|
-
return json({ task: taskService.taskView(found.state, task), results: taskService.resultViews(found.state, task.id), projects: taskProjects(), defaults: taskService.taskDefaults(found.state) });
|
|
1612
|
+
return json({ task: taskService.taskView(found.state, task, taskHooks), results: taskService.resultViews(found.state, task.id), projects: taskProjects(), defaults: taskService.taskDefaults(found.state) });
|
|
1513
1613
|
} catch (e) { return bad((e as Error).message, e instanceof tasks.TaskError ? e.status : 400); }
|
|
1514
1614
|
}
|
|
1515
1615
|
|
|
@@ -1545,6 +1645,17 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1545
1645
|
// Off this thread: it also relays every terminal, and a rebuild here froze their typing.
|
|
1546
1646
|
const { cards, extra, backlog } = await buildSnap(dirs, gitGen).catch(() => snapshot(dirs, gitGen));
|
|
1547
1647
|
const pty = ptyOf(cards), beat = heartbeatMinutes();
|
|
1648
|
+
// A task's decisions shown on its run too: the open question, and Looks good when it may be given.
|
|
1649
|
+
const taskByRun = new Map<string, { id: string; dir: string; revision: number; result: string | null; question?: { id: string; text: string; options: string[] }; accept: boolean }>();
|
|
1650
|
+
for (const d of new Set(cards.filter((c) => c.kind === "run").map((c) => c.state))) {
|
|
1651
|
+
try {
|
|
1652
|
+
for (const t of tasks.listTasks(d)) {
|
|
1653
|
+
if (t.archived || !t.activeRun) continue;
|
|
1654
|
+
const q = t.pendingDecision?.kind === "question" && t.pendingDecision.run === t.activeRun ? t.pendingDecision : null;
|
|
1655
|
+
taskByRun.set(d + "\0" + t.activeRun, { id: t.id, dir: d, revision: t.revision, result: t.currentResult, ...(q ? { question: { id: q.id, text: q.text, options: q.options ?? [] } } : {}), accept: t.status !== "accepted" && taskService.allowedActions(d, t, taskHooks).accept });
|
|
1656
|
+
}
|
|
1657
|
+
} catch { /* a task file mid-write: the next refresh has it */ }
|
|
1658
|
+
}
|
|
1548
1659
|
// The agents open now, for the sidebar cards: one list per tick, from the cards' sessions and the board's agent
|
|
1549
1660
|
// shells. ws is as the card or shell has it; the page resolves it to a listed workspace. Ended agents are left out.
|
|
1550
1661
|
const agents: any[] = [], seenKey = new Set<string>(), ptys = cards.map(pty);
|
|
@@ -1569,9 +1680,12 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1569
1680
|
// Dirs with a card the picker leaves out (the global queue, a project outside the
|
|
1570
1681
|
// Projects folder): the rail still needs their workspaces so a waiting run shows.
|
|
1571
1682
|
rail: [...new Set(cards.map((c) => c.state))].filter((d) => !picker.includes(d)).map(entry),
|
|
1683
|
+
// Every known project, the Projects folder ignored: the Notes tab lists these (#86).
|
|
1684
|
+
known: states(true).map((d) => ({ dir: d, label: label(d) })),
|
|
1572
1685
|
fresh: unset.map((d) => ({ dir: join(d, ".kaizen"), label: tilde(d) })),
|
|
1573
1686
|
agents,
|
|
1574
1687
|
cards: cards.map((c, i) => {
|
|
1688
|
+
const task = c.kind === "run" && c.id ? taskByRun.get(c.state + "\0" + c.id) : undefined;
|
|
1575
1689
|
const rep = c.kind === "run" && c.id && c.status !== "done" && c.status !== "abandoned" ? readReport(c.state, c.id) : null;
|
|
1576
1690
|
const signal = signalOf(c, rep, ptys[i] as any, Date.now(), beat);
|
|
1577
1691
|
// Only a run that has workers.json carries `workers`: any other card is as it was.
|
|
@@ -1579,7 +1693,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1579
1693
|
// No terminal left to wake: the card says so, and approval works here as for any run.
|
|
1580
1694
|
const hand = c.kind === "run" && c.id ? readHandoff(c.state, c.id) : null, parentPty = hand ? ptyState(hand.parent_terminal) : null;
|
|
1581
1695
|
const unwoken = wakeAction(hand, parentPty ? { ...parentPty, typedAt: parentPty.typedAt ?? 0 } : null, Date.now()), orphan = unwoken === "gone" || unwoken === "held";
|
|
1582
|
-
return { ...c, notice: notice(orphan ? { ...c, handoff: hand!.status } : c), ...extra[i], pty: ptys[i], signal, ...(ws ? { workers: ws.workers.map((x) => ({ id: x.id, title: x.title, status: workerStale(x, x.key ? ptyState(x.key) : null, Date.now(), beat) ? "stale" : x.status, bypass: x.bypass })), ...(ws.merge && ws.merge.status !== "merged" ? { workersMerge: ws.merge.status } : {}) } : {}), ...(rep?.phase ? { phase: rep.phase } : {}), ...(signal === "blocked" ? { blocked: rep!.blocked } : {}) };
|
|
1696
|
+
return { ...c, notice: notice(orphan ? { ...c, handoff: hand!.status } : c), ...extra[i], pty: ptys[i], signal, ...(ws ? { workers: ws.workers.map((x) => ({ id: x.id, title: x.title, status: workerStale(x, x.key ? ptyState(x.key) : null, Date.now(), beat) ? "stale" : x.status, bypass: x.bypass })), ...(ws.merge && ws.merge.status !== "merged" ? { workersMerge: ws.merge.status } : {}) } : {}), ...(rep?.phase ? { phase: rep.phase } : {}), ...(signal === "blocked" ? { blocked: rep!.blocked } : {}), ...(task ? { task } : {}) };
|
|
1583
1697
|
}),
|
|
1584
1698
|
backlog: backlog.map((b) => ({ ...b, starting: backlogLaunched.has(`${b.state}\0${b.source}#${b.n}`) || undefined })),
|
|
1585
1699
|
now: Date.now(),
|
|
@@ -1830,7 +1944,16 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1830
1944
|
rea.forgetDoctor(); rea.forgetLatest();
|
|
1831
1945
|
return r.ok ? json(r) : bad(r.why);
|
|
1832
1946
|
}
|
|
1833
|
-
|
|
1947
|
+
// Node.js for REA: runs only the command nodeFix builds here, after the page's confirm
|
|
1948
|
+
// and with the one-time token the Skills page got; never a command from the request.
|
|
1949
|
+
if (body?.step === "node") {
|
|
1950
|
+
const tokenOk = !!skillToken && body?.token === skillToken;
|
|
1951
|
+
skillToken = "";
|
|
1952
|
+
if (body?.confirm !== true || !tokenOk) return bad("confirm required");
|
|
1953
|
+
const r = await rea.installNode();
|
|
1954
|
+
return r.ok ? json({ ok: true }) : bad(r.why);
|
|
1955
|
+
}
|
|
1956
|
+
return bad("step: plan, apply, off or node");
|
|
1834
1957
|
}
|
|
1835
1958
|
|
|
1836
1959
|
// Per user, so no scope. A saved environment value is never in either answer.
|
|
@@ -2073,6 +2196,16 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2073
2196
|
return new Response(null, { status: 302, headers: { location: u, "cache-control": "no-store", "referrer-policy": "no-referrer" } });
|
|
2074
2197
|
}
|
|
2075
2198
|
|
|
2199
|
+
if (DEV && path === "/__dev/stream" && req.method === "GET") {
|
|
2200
|
+
let c: ReadableStreamDefaultController;
|
|
2201
|
+
return new Response(new ReadableStream({ start(x) { c = x; devClients.add(x); x.enqueue("data: hello\n\n"); }, cancel() { devClients.delete(c); } }),
|
|
2202
|
+
{ headers: { "content-type": "text/event-stream", "cache-control": "no-store", "connection": "keep-alive" } });
|
|
2203
|
+
}
|
|
2204
|
+
if (DEV && path === "/__dev/reload" && req.method === "POST" && local(req)) {
|
|
2205
|
+
for (const c of devClients) { try { c.enqueue("data: reload\n\n"); } catch { devClients.delete(c); } }
|
|
2206
|
+
return json({ ok: true, clients: devClients.size });
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2076
2209
|
if (req.method === "GET" && path === "/events") {
|
|
2077
2210
|
let ctrl: ReadableStreamDefaultController;
|
|
2078
2211
|
const stream = new ReadableStream({
|
|
@@ -2126,7 +2259,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2126
2259
|
agents: KNOWN_AGENTS.filter((a) => agentUsable(a.cmd)).map((a) => a.cmd),
|
|
2127
2260
|
// As POST /run starts a task, without one on the inbox.
|
|
2128
2261
|
run: async (d: string, runner: "lite" | "full", agent: string, text: string) => {
|
|
2129
|
-
const r = launchRun(parseItem(`${runner} ${text}`), d, undefined, { agent, ...inCard
|
|
2262
|
+
const r = launchRun(parseItem(`${runner} ${text}`), d, undefined, { agent, ...inCard });
|
|
2130
2263
|
changed();
|
|
2131
2264
|
return r.ok ? { agent: r.agent.cmd } : { error: r.why };
|
|
2132
2265
|
},
|
|
@@ -2270,14 +2403,14 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2270
2403
|
if (!destination || !states(true).includes(destination) || destination === join(home, ".kaizen")) return bad("Choose a named project", 400);
|
|
2271
2404
|
const task = tasks.transferDraft(found.state, found.task.id, destination, dirname(destination));
|
|
2272
2405
|
const result = taskService.taskAction(destination, { op: "start", id: task.id, revision: task.revision, operationId: String(body.operationId) + ":start" }, taskHooks);
|
|
2273
|
-
changed(); return json({ ok: true, task: taskService.taskView(result.state, result.task) });
|
|
2406
|
+
changed(); return json({ ok: true, task: taskService.taskView(result.state, result.task, taskHooks) });
|
|
2274
2407
|
}
|
|
2275
2408
|
if (!["create", "adopt"].includes(body.op)) {
|
|
2276
2409
|
const found = tasks.resolveTask(dir, String(body.id ?? ""));
|
|
2277
2410
|
if (!found || !states(true).includes(found.state)) return bad("unknown task", 404);
|
|
2278
2411
|
}
|
|
2279
2412
|
const result = taskService.taskAction(dir, body, taskHooks);
|
|
2280
|
-
changed(); return json({ ok: true, task: taskService.taskView(result.state, result.task) });
|
|
2413
|
+
changed(); return json({ ok: true, task: taskService.taskView(result.state, result.task, taskHooks) });
|
|
2281
2414
|
} catch (e) { return bad((e as Error).message, e instanceof tasks.TaskError ? e.status : 400); }
|
|
2282
2415
|
}
|
|
2283
2416
|
|
|
@@ -2484,7 +2617,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2484
2617
|
const p = parseItem(line.text);
|
|
2485
2618
|
const it: Item = { ...p, text: kind ? `${kind} ${p.text}` : p.text };
|
|
2486
2619
|
it.notes = [source !== "orphan" ? `Parent: ${source}` : "", `Backlog: ${source}#${n}`, p.text !== line.text ? `Backlog item: ${line.text}` : ""].filter(Boolean).join("\n");
|
|
2487
|
-
const r = launchRun(it, dir, undefined, { agent, account: typeof body.account === "string" ? body.account : undefined, model: model || undefined, explore: typeof body.explore === "boolean" ? body.explore : undefined, yolo: body.yolo === true, ...inCard
|
|
2620
|
+
const r = launchRun(it, dir, undefined, { agent, account: typeof body.account === "string" ? body.account : undefined, model: model || undefined, explore: typeof body.explore === "boolean" ? body.explore : undefined, yolo: body.yolo === true, ...inCard });
|
|
2488
2621
|
if (r.ok) backlogLaunched.add(`${dir}\0${source}#${n}`);
|
|
2489
2622
|
changed();
|
|
2490
2623
|
return json(r.ok
|
|
@@ -2495,7 +2628,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2495
2628
|
// A `started` task may be run again: the terminal the first launch opened
|
|
2496
2629
|
// can come up empty, and nothing else tells the board a run never began.
|
|
2497
2630
|
it.notes = readInbox(dir).find((l) => (l.status === "open" || l.status === "started") && l.text === text)?.notes;
|
|
2498
|
-
const r = launchRun(it, dir, undefined, { agent, account: typeof body.account === "string" ? body.account : undefined, model: model || undefined, explore: typeof body.explore === "boolean" ? body.explore : undefined, yolo: body.yolo === true, ...inCard
|
|
2631
|
+
const r = launchRun(it, dir, undefined, { agent, account: typeof body.account === "string" ? body.account : undefined, model: model || undefined, explore: typeof body.explore === "boolean" ? body.explore : undefined, yolo: body.yolo === true, ...inCard });
|
|
2499
2632
|
if (r.ok) replaceTask(dir, text, { status: "started", text });
|
|
2500
2633
|
if (r.ok && r.pty) {
|
|
2501
2634
|
for (const [k, v] of taskPty) if (!ptyState(v)) taskPty.delete(k); // sessions already dropped
|
|
@@ -2674,7 +2807,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2674
2807
|
// The run's conversation picks the fix up, and once that window is open the
|
|
2675
2808
|
// waiting one ends. A failed launch leaves it: the decision has nowhere else.
|
|
2676
2809
|
const before = Date.now();
|
|
2677
|
-
const r = launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard
|
|
2810
|
+
const r = launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard);
|
|
2678
2811
|
if (r.ok) (closeSessions(dir, id, { before }), markStage(dir, id, "review", r.pty));
|
|
2679
2812
|
changed();
|
|
2680
2813
|
return json(r.ok
|
|
@@ -2694,7 +2827,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2694
2827
|
const text = `run ${id}: the user chose Skip Explore for this run only. Stop exploration, preserve partial findings and unanswered questions in 00-explore.md, record that the user skipped it, run kaizen report unblock --run ${id}, set explore_status=skipped stage=plan awaiting=null with kaizen state, and prepare the plan. Do not change explore.enabled or skip the plan approval.`;
|
|
2695
2828
|
const live = liveAgent(dir, id), before = Date.now();
|
|
2696
2829
|
const r = live ? { ok: true as const, agent: live.agent, pty: live.key }
|
|
2697
|
-
: launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard
|
|
2830
|
+
: launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard);
|
|
2698
2831
|
if (live) submitPty(live.key, text);
|
|
2699
2832
|
else if (r.ok) closeSessions(dir, id, { before });
|
|
2700
2833
|
changed();
|
|
@@ -2717,31 +2850,37 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2717
2850
|
const why = recordAcceptance(dir, id, "board");
|
|
2718
2851
|
if (why) return bad(why, 409);
|
|
2719
2852
|
finishRun(dir, id);
|
|
2853
|
+
if (run.task_id) syncTask(dir, String(run.task_id));
|
|
2720
2854
|
changed();
|
|
2721
2855
|
return json({ ok: true });
|
|
2722
2856
|
}
|
|
2723
|
-
|
|
2857
|
+
// A task's plan approval is the task's proposal confirmation: route it through the
|
|
2858
|
+
// task so the same version check and receipts apply. A revise is a change message.
|
|
2859
|
+
if (run.task_id && run.awaiting === "approvals.plan" && body.awaiting === "approvals.plan") {
|
|
2860
|
+
const found = tasks.resolveTask(dir, String(run.task_id));
|
|
2861
|
+
const d = found?.task.pendingDecision;
|
|
2862
|
+
if (!found || !d || d.kind !== "proposal" || d.run !== id) return bad("This task has no plan waiting. Refresh and try again.", 409);
|
|
2863
|
+
const why = body.why === undefined ? "" : String(body.why).trim();
|
|
2864
|
+
if (body.why !== undefined && !why) return bad("a revise needs a comment");
|
|
2865
|
+
const answers = Array.isArray(body.answers) ? body.answers.filter((a: unknown) => typeof a === "string" && a.trim()).slice(0, 20) : [];
|
|
2866
|
+
try {
|
|
2867
|
+
const op = why ? { op: "message", text: why } : { op: "confirm", decisionId: d.id };
|
|
2868
|
+
const done = taskService.taskAction(found.state, { ...op, id: found.task.id, revision: found.task.revision, operationId: `decide:${id}:${d.id}:${why ? "revise" : "confirm"}` }, taskHooks);
|
|
2869
|
+
// The plan's questions answered with the approval reach the agent as one message.
|
|
2870
|
+
if (!why && answers.length) taskService.taskAction(found.state, { op: "message", text: "Answers to the plan's questions:\n" + answers.join("\n"), id: found.task.id, revision: done.task.revision, operationId: `decide:${id}:${d.id}:answers` }, taskHooks);
|
|
2871
|
+
} catch (e) { return bad((e as Error).message, e instanceof tasks.TaskError ? e.status : 400); }
|
|
2872
|
+
changed();
|
|
2873
|
+
return json({ ok: true, task: true });
|
|
2874
|
+
}
|
|
2724
2875
|
if (!canApproveAwaiting(run.awaiting) || run.awaiting !== body.awaiting) return bad("this run is not waiting on that approval", 409);
|
|
2725
2876
|
if (run.awaiting === "findings" && body.why !== undefined) return bad("open findings can only be approved as-is or fixed individually", 409);
|
|
2726
2877
|
if (body.why !== undefined && !String(body.why).trim()) return bad("a revise needs a comment");
|
|
2727
2878
|
const answers = body.answers;
|
|
2728
2879
|
if (answers !== undefined && (run.awaiting !== "approvals.plan" || body.why !== undefined || !Array.isArray(answers)
|
|
2729
2880
|
|| !answers.length || answers.length > 20 || answers.some((a: unknown) => typeof a !== "string" || !a.trim()))) return bad("bad answers");
|
|
2730
|
-
const
|
|
2731
|
-
//
|
|
2732
|
-
|
|
2733
|
-
// continues in one new window, and then the idle one ends. A failed launch leaves
|
|
2734
|
-
// it open, since the decision went nowhere.
|
|
2735
|
-
const live = liveAgent(dir, id);
|
|
2736
|
-
const before = Date.now();
|
|
2737
|
-
const r = live ? { ok: true as const, pty: live.key, agent: live.cmd, reused: true } : launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard(dir));
|
|
2738
|
-
if (live) submitPty(live.key, text);
|
|
2739
|
-
else if (r.ok) closeSessions(dir, id, { before });
|
|
2740
|
-
// The plan's approval starts the build; fixing open findings is the review stage again.
|
|
2741
|
-
if (r.ok) markStage(dir, id, run.awaiting === "approvals.plan" ? "impl" : run.awaiting === "findings" ? "review" : "", r.pty);
|
|
2742
|
-
// Approving the review as-is is the user's acceptance, on record before the
|
|
2743
|
-
// agent marks the run done; a revise is not.
|
|
2744
|
-
if (r.ok && body.why === undefined && (run.awaiting === "approvals.review" || run.awaiting === "findings")) recordAcceptance(dir, id, "board");
|
|
2881
|
+
const { r, live } = sendDecision(dir, id, run.awaiting, body.why === undefined ? undefined : String(body.why), answers);
|
|
2882
|
+
// A task's run approved here is the task's Looks good too.
|
|
2883
|
+
if (r.ok && run.task_id) syncTask(dir, String(run.task_id));
|
|
2745
2884
|
changed();
|
|
2746
2885
|
return json(r.ok
|
|
2747
2886
|
? { ok: true, agent: r.agent, pty: r.pty, ...(live ? { reused: true } : {}) }
|
|
@@ -2761,6 +2900,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2761
2900
|
const why = recordAcceptance(dir, id, "board");
|
|
2762
2901
|
if (why) return bad(why, 409);
|
|
2763
2902
|
finishRun(dir, id);
|
|
2903
|
+
if (st.task_id) syncTask(dir, String(st.task_id));
|
|
2764
2904
|
changed();
|
|
2765
2905
|
return json({ ok: true });
|
|
2766
2906
|
}
|
|
@@ -2826,7 +2966,6 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2826
2966
|
done.add(`${dir}\0${id}`);
|
|
2827
2967
|
viaRun.add(key);
|
|
2828
2968
|
if (saved.crash && resumed && Date.now() - resumed < CRASH_AGAIN_MS) { console.log(` not resuming ${id}: the board died again right after resuming it`); continue; }
|
|
2829
|
-
if (launchMode(projectOf(dir)) !== "card") continue;
|
|
2830
2969
|
const r = resumeRun(dir, id);
|
|
2831
2970
|
if (saved.crash && "pty" in r && r.pty) autoResumed.set(r.pty, Date.now());
|
|
2832
2971
|
console.log(` ${"error" in r || !r.ok ? "could not resume" : "resumed"} ${id}${"error" in r ? ` (${r.error})` : !r.ok ? ` (${r.why})` : ""}`);
|
|
@@ -2983,11 +3122,8 @@ export function shellHosts(root: number, id: string): boolean {
|
|
|
2983
3122
|
}
|
|
2984
3123
|
|
|
2985
3124
|
export async function openApp(url: string, profile?: string) {
|
|
2986
|
-
// Kaizen Bot's window (a profile) is
|
|
2987
|
-
if (!profile)
|
|
2988
|
-
const { listSettings } = await import("./settings.ts");
|
|
2989
|
-
if (listSettings(join(import.meta.dir, "..")).rows.find((r) => r.key === "board.open")?.value !== "app") return openDefault(url);
|
|
2990
|
-
}
|
|
3125
|
+
// Kaizen Bot's window (a profile) is an app window; the board opens in a browser tab.
|
|
3126
|
+
if (!profile) return openDefault(url);
|
|
2991
3127
|
const args = [`--app=${url}`, ...(profile ? [`--user-data-dir=${profile}`] : [])];
|
|
2992
3128
|
const chromes = process.platform === "darwin"
|
|
2993
3129
|
? ["Google Chrome", "Chromium", "Microsoft Edge", "Brave Browser"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kaizen-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.87.0",
|
|
4
4
|
"description": "Staged workflow for AI agents — code, writing, research, operations: plan, human approval, build, independent review, bounded fix loop.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"agents",
|
|
14
14
|
"commands",
|
|
15
15
|
"web",
|
|
16
|
+
"tsconfig.json",
|
|
16
17
|
"assets/kaizen-logo.png",
|
|
17
18
|
"assets/kaizen.ico",
|
|
18
19
|
"README.md",
|
|
@@ -24,9 +25,10 @@
|
|
|
24
25
|
"install-links": "bun run cli/install.ts",
|
|
25
26
|
"check": "bun run cli/install.ts --check",
|
|
26
27
|
"build:web": "bun run cli/build-web.ts",
|
|
28
|
+
"dev": "bun cli/dev.ts",
|
|
27
29
|
"audit:ui": "bun run cli/ui-audit.ts",
|
|
28
|
-
"format": "prettier --write web
|
|
29
|
-
"format:check": "prettier --check web
|
|
30
|
+
"format": "prettier --write web/notebook web/term web/video web/ui web/components web/pages web/lib bot/web/app",
|
|
31
|
+
"format:check": "prettier --check web/notebook web/term web/video web/ui web/components web/pages web/lib bot/web/app",
|
|
30
32
|
"test": "bun test",
|
|
31
33
|
"prepublishOnly": "bun test",
|
|
32
34
|
"postpublish": "sh cli/release.sh",
|
|
@@ -57,12 +59,27 @@
|
|
|
57
59
|
"@codemirror/state": "6.7.6",
|
|
58
60
|
"@codemirror/view": "6.43.13",
|
|
59
61
|
"@lezer/highlight": "1.2.5",
|
|
62
|
+
"@tailwindcss/cli": "4.3.5",
|
|
63
|
+
"@types/bun": "1.4.4",
|
|
64
|
+
"@types/react": "19.3.0",
|
|
65
|
+
"@types/react-dom": "19.3.0",
|
|
60
66
|
"@xterm/addon-fit": "0.11.0",
|
|
61
67
|
"@xterm/addon-search": "0.16.0",
|
|
62
68
|
"@xterm/addon-unicode11": "0.9.0",
|
|
63
69
|
"@xterm/addon-web-links": "0.12.0",
|
|
64
70
|
"@xterm/addon-webgl": "0.19.0",
|
|
65
71
|
"@xterm/xterm": "6.0.0",
|
|
66
|
-
"
|
|
72
|
+
"class-variance-authority": "0.7.1",
|
|
73
|
+
"clsx": "2.1.1",
|
|
74
|
+
"cmdk": "1.1.1",
|
|
75
|
+
"prettier": "3.9.10",
|
|
76
|
+
"radix-ui": "1.8.1",
|
|
77
|
+
"react": "19.3.1",
|
|
78
|
+
"react-dom": "19.3.1",
|
|
79
|
+
"sonner": "2.0.8",
|
|
80
|
+
"tailwind-merge": "3.7.0",
|
|
81
|
+
"tailwindcss": "4.3.5",
|
|
82
|
+
"tw-animate-css": "1.4.0",
|
|
83
|
+
"zustand": "5.1.0"
|
|
67
84
|
}
|
|
68
85
|
}
|
package/skills/kaizen/spec.md
CHANGED
|
@@ -213,9 +213,12 @@ switch agents. Both full and lite runners honor the persisted task policy before
|
|
|
213
213
|
reading global auto/approval defaults.
|
|
214
214
|
|
|
215
215
|
Task intake/planning may ask questions and propose an outcome, but must not produce
|
|
216
|
-
until the current
|
|
217
|
-
it rejects build/review/done before that
|
|
218
|
-
task_id or task_confirmed by hand. The
|
|
216
|
+
until the current plan is explicitly approved. Use the sanctioned state command;
|
|
217
|
+
it rejects build/review/done before that approval. Do not overwrite task_policy,
|
|
218
|
+
task_id or task_confirmed by hand. The user may decide in any of three places: the task
|
|
219
|
+
page, the run panel, or by typing to you. The board records the first two; record a
|
|
220
|
+
decision typed to you with the `approved` or `answered` event below. The final yes on
|
|
221
|
+
the result is `kaizen done <run> --user-approved`; it also accepts the task.
|
|
219
222
|
|
|
220
223
|
Read context with `kaizen task show --task <uuid>`. Publish structured events with
|
|
221
224
|
`kaizen task event --task <uuid> --run <run-id> --operation <stable-event-id> --json '<event>'`.
|
|
@@ -227,6 +230,10 @@ input ids; acknowledge the launch before doing anything else:
|
|
|
227
230
|
- `{"type":"question","text":"...","options":["..."]}` requests material input.
|
|
228
231
|
- `{"type":"proposal","text":"outcome, constraints and checks","details":"full plan"}`
|
|
229
232
|
requests explicit confirmation of this run/iteration/result. Stop production here.
|
|
233
|
+
- `{"type":"approved"}` records that the user approved the current plan by typing to
|
|
234
|
+
you in the agent terminal. Send it only on a clear yes, then continue the build.
|
|
235
|
+
- `{"type":"answered","text":"..."}` records the user's answer to your open question (or
|
|
236
|
+
their plan changes) given in the agent terminal, so the task and run pages stop asking.
|
|
230
237
|
- `{"type":"work","text":"..."}` reports genuine production after confirmation.
|
|
231
238
|
- `{"type":"receipt","inputIds":["..."],"outcome":"applied"}` acknowledges only
|
|
232
239
|
dispatched input ids. Use `failed` and `error` for requests not applied.
|
|
@@ -239,7 +246,8 @@ input ids; acknowledge the launch before doing anything else:
|
|
|
239
246
|
publishes a typed version. Paths must be regular files inside the project/worktree.
|
|
240
247
|
Do not snapshot source trees or databases. HTML/SVG files download only. Include
|
|
241
248
|
specialized Video identity as `video:{name,letter,revision}` when relevant, without
|
|
242
|
-
changing its recipes. A
|
|
249
|
+
changing its recipes. A refused result does not pause the task; fix the cause and publish again.
|
|
250
|
+
Only a failed copy to disk pauses it, retains earlier versions and needs recovery.
|
|
243
251
|
|
|
244
252
|
A question/status reply never authorizes production. Queued change requests are not
|
|
245
253
|
already applied: keep their ids and report receipts. Stop requests cancellation and
|