@polderlabs/bizar 3.23.0 → 4.0.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 +72 -2
- package/bizar-dash/.bizar/activity.log +3 -0
- package/bizar-dash/.bizar/graph/.graphify_analysis.json +1540 -0
- package/bizar-dash/.bizar/graph/.graphify_labels.json +1 -0
- package/bizar-dash/.bizar/graph/GRAPH_REPORT.md +404 -0
- package/bizar-dash/.bizar/graph/cache/ast/v0.8.46/0661b816358db84dfdb7f10443db8a61152fd20b3fee950caf8fbf32920a1790.json +1 -0
- package/bizar-dash/.bizar/graph/cache/ast/v0.8.46/16da06d774142a6e5d74829ad982531286a6193ef798de8f593db029e123ec32.json +1 -0
- package/bizar-dash/.bizar/graph/cache/ast/v0.8.46/27e5697c01254c69c64c5a33896669073b40afb5ba88375102ae77fa5404136d.json +1 -0
- package/bizar-dash/.bizar/graph/cache/ast/v0.8.46/532997898027254aa4c0932243dc71d2f55888181232b65974961934997dc85b.json +1 -0
- package/bizar-dash/.bizar/graph/cache/ast/v0.8.46/84e3451a64c7f99f0cd6a88b0748d7426780486f53ab4935b7476b28c08f8293.json +1 -0
- package/bizar-dash/.bizar/graph/cache/ast/v0.8.46/88e5ea5f3e78fa69353fe9e6a8d1a05391d54605e25600cb125531eb5a6432ff.json +1 -0
- package/bizar-dash/.bizar/graph/cache/stat-index.json +1 -0
- package/bizar-dash/.bizar/graph/graph.html +307 -0
- package/bizar-dash/.bizar/graph/graph.json +40267 -0
- package/bizar-dash/.bizar/graph/manifest.json +762 -0
- package/bizar-dash/.graphifyignore +40 -0
- package/bizar-dash/.obsidian/README.md +14 -0
- package/bizar-dash/.obsidian/daily/2026-06-25.md +9 -0
- package/bizar-dash/.obsidian/vault.json +7 -0
- package/bizar-dash/.od-skills/web-prototype-e1429c1737/SKILL.md +103 -0
- package/bizar-dash/.od-skills/web-prototype-e1429c1737/assets/template.html +338 -0
- package/bizar-dash/.od-skills/web-prototype-e1429c1737/example.html +81 -0
- package/bizar-dash/.od-skills/web-prototype-e1429c1737/open-design.json +172 -0
- package/bizar-dash/.od-skills/web-prototype-e1429c1737/references/checklist.md +44 -0
- package/bizar-dash/.od-skills/web-prototype-e1429c1737/references/layouts.md +247 -0
- package/bizar-dash/CHANGELOG.md +474 -0
- package/bizar-dash/DESIGN.md +136 -0
- package/bizar-dash/dist/assets/main-B3RgW6FS.js +331 -0
- package/bizar-dash/dist/assets/main-B3RgW6FS.js.map +1 -0
- package/bizar-dash/dist/assets/main-DlJ8wgLR.css +1 -0
- package/bizar-dash/dist/assets/mobile-CsZQAswA.css +1 -0
- package/bizar-dash/dist/assets/mobile-DbxIw8BG.js +2 -0
- package/bizar-dash/dist/assets/mobile-DbxIw8BG.js.map +1 -0
- package/bizar-dash/dist/assets/mobile-Dvq2d53Y.js +354 -0
- package/bizar-dash/dist/assets/mobile-Dvq2d53Y.js.map +1 -0
- package/bizar-dash/dist/index.html +40 -0
- package/bizar-dash/dist/mobile.html +22 -0
- package/bizar-dash/plans/debug-plan/comments.json +1 -0
- package/bizar-dash/plans/debug-plan/meta.json +10 -0
- package/bizar-dash/plans/debug-plan/plan.json +174 -0
- package/bizar-dash/scripts/smoke-bg-retry.mjs +246 -0
- package/bizar-dash/src/cli/dashboard-ports.mjs +488 -0
- package/bizar-dash/src/cli.mjs +522 -0
- package/bizar-dash/src/server/activity-log.mjs +174 -0
- package/bizar-dash/src/server/agents-store.mjs +465 -0
- package/bizar-dash/src/server/api.mjs +138 -0
- package/bizar-dash/src/server/artifact-template.html +810 -0
- package/bizar-dash/src/server/artifacts-store.mjs +733 -0
- package/bizar-dash/src/server/auth.mjs +381 -0
- package/bizar-dash/src/server/background-store.mjs +447 -0
- package/bizar-dash/src/server/bg-poller.mjs +305 -0
- package/bizar-dash/src/server/bg-retry.mjs +574 -0
- package/bizar-dash/src/server/browser.mjs +40 -0
- package/bizar-dash/src/server/diagnostics-store.mjs +148 -0
- package/bizar-dash/src/server/dialog-poller.mjs +105 -0
- package/bizar-dash/src/server/dialog-store.mjs +177 -0
- package/bizar-dash/src/server/glyphs/mdx-compiler.mjs +583 -0
- package/bizar-dash/src/server/lib/path-safe.mjs +283 -0
- package/bizar-dash/src/server/memory-git.mjs +249 -0
- package/bizar-dash/src/server/memory-schema.mjs +145 -0
- package/bizar-dash/src/server/memory-secrets.mjs +84 -0
- package/bizar-dash/src/server/memory-store.mjs +424 -0
- package/bizar-dash/src/server/mod-security.mjs +398 -0
- package/bizar-dash/src/server/mods-loader.mjs +1067 -0
- package/bizar-dash/src/server/notifications-store.mjs +243 -0
- package/bizar-dash/src/server/obsidian-store.mjs +318 -0
- package/bizar-dash/src/server/opencode-runner.mjs +279 -0
- package/bizar-dash/src/server/pair-store.mjs +138 -0
- package/bizar-dash/src/server/projects-store.mjs +364 -0
- package/bizar-dash/src/server/providers-store.mjs +789 -0
- package/bizar-dash/src/server/routes/_shared.mjs +415 -0
- package/bizar-dash/src/server/routes/activity.mjs +110 -0
- package/bizar-dash/src/server/routes/agents.mjs +134 -0
- package/bizar-dash/src/server/routes/artifacts.mjs +279 -0
- package/bizar-dash/src/server/routes/auth.mjs +69 -0
- package/bizar-dash/src/server/routes/background.mjs +165 -0
- package/bizar-dash/src/server/routes/chat.mjs +485 -0
- package/bizar-dash/src/server/routes/config.mjs +129 -0
- package/bizar-dash/src/server/routes/diagnostics.mjs +50 -0
- package/bizar-dash/src/server/routes/dialogs.mjs +86 -0
- package/bizar-dash/src/server/routes/fs.mjs +429 -0
- package/bizar-dash/src/server/routes/history.mjs +78 -0
- package/bizar-dash/src/server/routes/memory.mjs +499 -0
- package/bizar-dash/src/server/routes/misc.mjs +89 -0
- package/bizar-dash/src/server/routes/mods.mjs +359 -0
- package/bizar-dash/src/server/routes/notifications.mjs +54 -0
- package/bizar-dash/src/server/routes/obsidian.mjs +239 -0
- package/bizar-dash/src/server/routes/opencode-sessions.mjs +55 -0
- package/bizar-dash/src/server/routes/overview.mjs +91 -0
- package/bizar-dash/src/server/routes/pair.mjs +67 -0
- package/bizar-dash/src/server/routes/projects.mjs +175 -0
- package/bizar-dash/src/server/routes/providers.mjs +47 -0
- package/bizar-dash/src/server/routes/schedules.mjs +104 -0
- package/bizar-dash/src/server/routes/settings.mjs +51 -0
- package/bizar-dash/src/server/routes/skills.mjs +76 -0
- package/bizar-dash/src/server/routes/tasks.mjs +468 -0
- package/bizar-dash/src/server/routes/themes.mjs +51 -0
- package/bizar-dash/src/server/routes-v2/auth.mjs +59 -0
- package/bizar-dash/src/server/routes-v2/events.mjs +107 -0
- package/bizar-dash/src/server/routes-v2/health.mjs +21 -0
- package/bizar-dash/src/server/routes-v2/index.mjs +90 -0
- package/bizar-dash/src/server/routes-v2/sessions.mjs +111 -0
- package/bizar-dash/src/server/schedules-runner.mjs +369 -0
- package/bizar-dash/src/server/schedules-store.mjs +268 -0
- package/bizar-dash/src/server/search-store.mjs +220 -0
- package/bizar-dash/src/server/serve-info.mjs +684 -0
- package/bizar-dash/src/server/server.mjs +796 -0
- package/bizar-dash/src/server/settings-store.mjs +45 -0
- package/bizar-dash/src/server/skills-store.mjs +300 -0
- package/bizar-dash/src/server/state.mjs +437 -0
- package/bizar-dash/src/server/tailscale-store.mjs +113 -0
- package/bizar-dash/src/server/task-delegator.mjs +824 -0
- package/bizar-dash/src/server/tasks-store.mjs +508 -0
- package/bizar-dash/src/server/tui.mjs +923 -0
- package/bizar-dash/src/server/update-store.mjs +168 -0
- package/bizar-dash/src/server/v2-auth-file.mjs +99 -0
- package/bizar-dash/src/server/v2-event-bus.mjs +128 -0
- package/bizar-dash/src/server/watcher.mjs +81 -0
- package/bizar-dash/src/server/yaml.mjs +238 -0
- package/bizar-dash/src/web/App.tsx +718 -0
- package/bizar-dash/src/web/MobileApp.tsx +408 -0
- package/bizar-dash/src/web/components/ArtifactCreateDialog.tsx +95 -0
- package/bizar-dash/src/web/components/ArtifactListDialog.tsx +55 -0
- package/bizar-dash/src/web/components/ArtifactViewer.tsx +143 -0
- package/bizar-dash/src/web/components/AuditDialog.tsx +79 -0
- package/bizar-dash/src/web/components/BgStatusBadge.tsx +32 -0
- package/bizar-dash/src/web/components/Button.tsx +56 -0
- package/bizar-dash/src/web/components/CanvasContextMenu.tsx +68 -0
- package/bizar-dash/src/web/components/Card.tsx +40 -0
- package/bizar-dash/src/web/components/CollapsibleSection.tsx +72 -0
- package/bizar-dash/src/web/components/CommandDialog.tsx +66 -0
- package/bizar-dash/src/web/components/EmptyState.tsx +30 -0
- package/bizar-dash/src/web/components/FileBrowser.tsx +633 -0
- package/bizar-dash/src/web/components/HelpDialog.tsx +55 -0
- package/bizar-dash/src/web/components/KillConfirmDialog.tsx +88 -0
- package/bizar-dash/src/web/components/Modal.tsx +215 -0
- package/bizar-dash/src/web/components/Notifications.tsx +241 -0
- package/bizar-dash/src/web/components/SearchModal.tsx +224 -0
- package/bizar-dash/src/web/components/Sidebar.tsx +66 -0
- package/bizar-dash/src/web/components/Spinner.tsx +19 -0
- package/bizar-dash/src/web/components/StatusBadge.tsx +25 -0
- package/bizar-dash/src/web/components/Tag.tsx +28 -0
- package/bizar-dash/src/web/components/Toast.tsx +150 -0
- package/bizar-dash/src/web/components/Topbar.tsx +368 -0
- package/bizar-dash/src/web/components/VisualPlanDialog.tsx +58 -0
- package/bizar-dash/src/web/components/chat/AgentChip.tsx +68 -0
- package/bizar-dash/src/web/components/chat/ChatBubble.tsx +60 -0
- package/bizar-dash/src/web/components/chat/ChatThread.tsx +88 -0
- package/bizar-dash/src/web/components/chat/ChatTopBar.tsx +50 -0
- package/bizar-dash/src/web/components/chat/Composer.tsx +164 -0
- package/bizar-dash/src/web/components/chat/ConfirmModal.tsx +54 -0
- package/bizar-dash/src/web/components/chat/EmptyState.tsx +21 -0
- package/bizar-dash/src/web/components/chat/FirstRunGreeting.tsx +18 -0
- package/bizar-dash/src/web/components/chat/FloatingComposer.tsx +32 -0
- package/bizar-dash/src/web/components/chat/InfoPanel.tsx +119 -0
- package/bizar-dash/src/web/components/chat/LoadingSkeleton.tsx +19 -0
- package/bizar-dash/src/web/components/chat/MessageBubble.tsx +60 -0
- package/bizar-dash/src/web/components/chat/SessionList.tsx +153 -0
- package/bizar-dash/src/web/components/chat/StreamingIndicator.tsx +9 -0
- package/bizar-dash/src/web/components/chat/SuggestionCards.tsx +55 -0
- package/bizar-dash/src/web/components/chat/WelcomeScreen.tsx +36 -0
- package/bizar-dash/src/web/components/chat/index.ts +20 -0
- package/bizar-dash/src/web/components/chat/useAutoGrowTextarea.ts +18 -0
- package/bizar-dash/src/web/components/chat/useChat.ts +219 -0
- package/bizar-dash/src/web/components/chat/useSlashCommands.ts +47 -0
- package/bizar-dash/src/web/index.html +37 -0
- package/bizar-dash/src/web/lib/api.ts +193 -0
- package/bizar-dash/src/web/lib/markdown.tsx +59 -0
- package/bizar-dash/src/web/lib/types.ts +668 -0
- package/bizar-dash/src/web/lib/utils.ts +114 -0
- package/bizar-dash/src/web/lib/ws.ts +176 -0
- package/bizar-dash/src/web/main.tsx +34 -0
- package/bizar-dash/src/web/mobile/MobileApp.tsx +278 -0
- package/bizar-dash/src/web/mobile/MobileBottomNav.tsx +38 -0
- package/bizar-dash/src/web/mobile/MobileTopbar.tsx +115 -0
- package/bizar-dash/src/web/mobile/components/MobileBottomSheet.tsx +182 -0
- package/bizar-dash/src/web/mobile/components/MobileListItem.tsx +64 -0
- package/bizar-dash/src/web/mobile/components/MobileModal.tsx +123 -0
- package/bizar-dash/src/web/mobile/views/MobileActivity.tsx +273 -0
- package/bizar-dash/src/web/mobile/views/MobileAgents.tsx +374 -0
- package/bizar-dash/src/web/mobile/views/MobileArtifactCanvas.tsx +439 -0
- package/bizar-dash/src/web/mobile/views/MobileArtifacts.tsx +143 -0
- package/bizar-dash/src/web/mobile/views/MobileChat.tsx +180 -0
- package/bizar-dash/src/web/mobile/views/MobileConfig.tsx +175 -0
- package/bizar-dash/src/web/mobile/views/MobileHistory.tsx +191 -0
- package/bizar-dash/src/web/mobile/views/MobileMods.tsx +149 -0
- package/bizar-dash/src/web/mobile/views/MobileMore.tsx +121 -0
- package/bizar-dash/src/web/mobile/views/MobileNotifications.tsx +137 -0
- package/bizar-dash/src/web/mobile/views/MobilePlans.tsx +26 -0
- package/bizar-dash/src/web/mobile/views/MobileSchedules.tsx +685 -0
- package/bizar-dash/src/web/mobile/views/MobileSearchModal.tsx +172 -0
- package/bizar-dash/src/web/mobile/views/MobileSettings.tsx +388 -0
- package/bizar-dash/src/web/mobile/views/MobileSkills.tsx +153 -0
- package/bizar-dash/src/web/mobile/views/MobileTasks.tsx +564 -0
- package/bizar-dash/src/web/mobile.html +20 -0
- package/bizar-dash/src/web/mobile.tsx +13 -0
- package/bizar-dash/src/web/styles/chat.css +198 -0
- package/bizar-dash/src/web/styles/glyphs.css +960 -0
- package/bizar-dash/src/web/styles/main.css +8855 -0
- package/bizar-dash/src/web/styles/mobile-chat.css +5 -0
- package/bizar-dash/src/web/styles/mobile.css +1960 -0
- package/bizar-dash/src/web/views/Activity.tsx +1203 -0
- package/bizar-dash/src/web/views/Agents.tsx +701 -0
- package/bizar-dash/src/web/views/Artifacts.tsx +1480 -0
- package/bizar-dash/src/web/views/BackgroundAgents.tsx +450 -0
- package/bizar-dash/src/web/views/Chat.tsx +190 -0
- package/bizar-dash/src/web/views/Config.tsx +1603 -0
- package/bizar-dash/src/web/views/History.tsx +335 -0
- package/bizar-dash/src/web/views/ModView.tsx +207 -0
- package/bizar-dash/src/web/views/Mods.tsx +693 -0
- package/bizar-dash/src/web/views/Overview.tsx +812 -0
- package/bizar-dash/src/web/views/Providers.tsx +302 -0
- package/bizar-dash/src/web/views/Schedules.tsx +802 -0
- package/bizar-dash/src/web/views/Settings.tsx +1787 -0
- package/bizar-dash/src/web/views/Skills.tsx +431 -0
- package/bizar-dash/src/web/views/Tasks.tsx +1523 -0
- package/bizar-dash/src/web/views/glyphs/GlyphRenderer.tsx +613 -0
- package/bizar-dash/src/web/views/glyphs/components.tsx +1098 -0
- package/bizar-dash/templates/mod/FORMAT.md +76 -0
- package/bizar-dash/templates/mod/hello-mod/README.md +19 -0
- package/bizar-dash/templates/mod/hello-mod/agents/greeter.md +8 -0
- package/bizar-dash/templates/mod/hello-mod/commands/hello.md +6 -0
- package/bizar-dash/templates/mod/hello-mod/mod.json +20 -0
- package/bizar-dash/templates/mod/hello-mod/routes/ping.mjs +9 -0
- package/bizar-dash/templates/mod/hello-mod/views/HelloView.tsx +10 -0
- package/bizar-dash/tests/dashboard-ports.test.mjs +138 -0
- package/bizar-dash/tests/graphify-mod-spawn.node.test.mjs +90 -0
- package/bizar-dash/tests/memory-git.test.mjs +138 -0
- package/bizar-dash/tests/memory-schema.test.mjs +198 -0
- package/bizar-dash/tests/memory-secrets.test.mjs +121 -0
- package/bizar-dash/tests/memory-store.test.mjs +390 -0
- package/bizar-dash/tests/memory-sync.test.mjs +141 -0
- package/bizar-dash/tests/mod-instructions.node.test.mjs +188 -0
- package/bizar-dash/tests/mod-security.test.mjs +273 -0
- package/bizar-dash/tests/mod-upgrade.node.test.mjs +357 -0
- package/bizar-dash/tests/no-agent-browser.node.test.mjs +98 -0
- package/bizar-dash/tests/obsidian-back-compat.test.mjs +199 -0
- package/bizar-dash/tests/opencode-runner.test.mjs +172 -0
- package/bizar-dash/tests/path-safe.test.mjs +108 -0
- package/bizar-dash/tests/providers-store-backup-keys.node.test.mjs +333 -0
- package/bizar-dash/tests/smoke-v2.mjs +212 -0
- package/bizar-dash/tests/strip-thinking.test.mjs +175 -0
- package/bizar-dash/tests/submit-feedback.test.mjs +353 -0
- package/bizar-dash/tests/tmux-wrap.test.mjs +145 -0
- package/bizar-dash/tests/yaml.test.mjs +128 -0
- package/bizar-dash/tsconfig.json +23 -0
- package/bizar-dash/vite.config.ts +27 -0
- package/cli/atomic.mjs +73 -0
- package/cli/bin.mjs +43 -46
- package/cli/copy.mjs +3 -0
- package/cli/dev-link.mjs +17 -1
- package/cli/init.mjs +135 -1
- package/cli/install.mjs +10 -23
- package/cli/memory-constants.mjs +59 -0
- package/cli/memory.mjs +757 -0
- package/cli/service.mjs +5 -6
- package/config/skills/obsidian/SKILL.md +213 -65
- package/install.sh +48 -18
- package/package.json +49 -14
- package/packages/sdk/LICENSE +21 -0
- package/packages/sdk/README.md +80 -0
- package/packages/sdk/src/client.ts +183 -0
- package/packages/sdk/src/errors.ts +120 -0
- package/packages/sdk/src/events.ts +153 -0
- package/packages/sdk/src/index.ts +63 -0
- package/packages/sdk/src/types.ts +176 -0
- package/packages/sdk/src/version.ts +4 -0
- package/packages/sdk/tests/client.test.ts +217 -0
- package/packages/sdk/tests/errors.test.ts +108 -0
- package/packages/sdk/tests/events.test.ts +139 -0
- package/packages/sdk/tests/fixtures/fetch-mock.ts +152 -0
- package/packages/sdk/tests/fixtures/sse-mock.ts +30 -0
- package/packages/sdk/tsconfig.json +25 -0
- package/packages/sdk/vitest.config.ts +9 -0
- package/plugins/bizar/LICENSE +21 -0
- package/plugins/bizar/README.md +448 -0
- package/plugins/bizar/dist/index.js +29901 -0
- package/plugins/bizar/index.ts +1484 -0
- package/plugins/bizar/scripts/check-forbidden-imports.sh +33 -0
- package/plugins/bizar/src/background-state.ts +551 -0
- package/plugins/bizar/src/background.ts +1250 -0
- package/plugins/bizar/src/commands-impl.ts +464 -0
- package/plugins/bizar/src/commands.ts +1127 -0
- package/plugins/bizar/src/dashboard-client.ts +233 -0
- package/plugins/bizar/src/event-stream.ts +606 -0
- package/plugins/bizar/src/fingerprint.ts +120 -0
- package/plugins/bizar/src/handoff.ts +79 -0
- package/plugins/bizar/src/http-client.ts +467 -0
- package/plugins/bizar/src/key-rotation.ts +218 -0
- package/plugins/bizar/src/logger.ts +144 -0
- package/plugins/bizar/src/loop.ts +176 -0
- package/plugins/bizar/src/opencode-runner.ts +390 -0
- package/plugins/bizar/src/options.ts +421 -0
- package/plugins/bizar/src/plan-fs.ts +323 -0
- package/plugins/bizar/src/reasoning-clean.ts +454 -0
- package/plugins/bizar/src/report.ts +178 -0
- package/plugins/bizar/src/research-prompt.ts +35 -0
- package/plugins/bizar/src/serve-info.ts +228 -0
- package/plugins/bizar/src/serve.ts +496 -0
- package/plugins/bizar/src/settings.ts +349 -0
- package/plugins/bizar/src/state.ts +298 -0
- package/plugins/bizar/src/tools/bg-collect.ts +104 -0
- package/plugins/bizar/src/tools/bg-get-comments.ts +239 -0
- package/plugins/bizar/src/tools/bg-kill.ts +87 -0
- package/plugins/bizar/src/tools/bg-spawn.ts +401 -0
- package/plugins/bizar/src/tools/bg-status.ts +99 -0
- package/plugins/bizar/src/tools/plan-action.ts +767 -0
- package/plugins/bizar/src/tools/read-glyph-feedback.ts +170 -0
- package/plugins/bizar/src/tools/wait-for-feedback.ts +402 -0
- package/plugins/bizar/tests/attach-handler-bug.test.ts +169 -0
- package/plugins/bizar/tests/background-state.test.ts +277 -0
- package/plugins/bizar/tests/background.test.ts +402 -0
- package/plugins/bizar/tests/block.test.ts +195 -0
- package/plugins/bizar/tests/canonical-key-order.test.ts +75 -0
- package/plugins/bizar/tests/commands-impl.test.ts +442 -0
- package/plugins/bizar/tests/commands.test.ts +548 -0
- package/plugins/bizar/tests/config.test.ts +122 -0
- package/plugins/bizar/tests/dashboard-client.test.ts +159 -0
- package/plugins/bizar/tests/dispose.test.ts +336 -0
- package/plugins/bizar/tests/event-stream.test.ts +409 -0
- package/plugins/bizar/tests/event.test.ts +262 -0
- package/plugins/bizar/tests/fingerprint.test.ts +162 -0
- package/plugins/bizar/tests/http-client.test.ts +404 -0
- package/plugins/bizar/tests/init-helpers.test.ts +203 -0
- package/plugins/bizar/tests/integration/slash-command.test.ts +348 -0
- package/plugins/bizar/tests/integration/tool-routing.test.ts +314 -0
- package/plugins/bizar/tests/key-rotation.test.ts +396 -0
- package/plugins/bizar/tests/loop.test.ts +397 -0
- package/plugins/bizar/tests/options.test.ts +276 -0
- package/plugins/bizar/tests/reasoning-clean.test.ts +422 -0
- package/plugins/bizar/tests/serve.test.ts +339 -0
- package/plugins/bizar/tests/settings.test.ts +351 -0
- package/plugins/bizar/tests/stall-think.test.ts +750 -0
- package/plugins/bizar/tests/state.test.ts +276 -0
- package/plugins/bizar/tests/tools/bg-collect.test.ts +337 -0
- package/plugins/bizar/tests/tools/bg-get-comments.test.ts +485 -0
- package/plugins/bizar/tests/tools/bg-kill.test.ts +235 -0
- package/plugins/bizar/tests/tools/bg-spawn-delegation.test.ts +147 -0
- package/plugins/bizar/tests/tools/bg-spawn.test.ts +311 -0
- package/plugins/bizar/tests/tools/bg-status.test.ts +217 -0
- package/plugins/bizar/tests/tools/opencode-runner.test.ts +115 -0
- package/plugins/bizar/tests/tools/plan-action.test.ts +599 -0
- package/plugins/bizar/tests/tools/read-glyph-feedback.test.ts +253 -0
- package/plugins/bizar/tests/tools/wait-for-feedback.test.ts +390 -0
- package/plugins/bizar/tests/update-deadlock.test.ts +145 -0
- package/plugins/bizar/tsconfig.json +29 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* read-glyph-feedback.test.ts
|
|
3
|
+
*
|
|
4
|
+
* Tests for `readGlyphFeedback` — the pure read function extracted
|
|
5
|
+
* from `read-glyph-feedback.ts`. Mirrors the style of
|
|
6
|
+
* `bg-get-comments.test.ts` so future readers can compare them
|
|
7
|
+
* side-by-side.
|
|
8
|
+
*
|
|
9
|
+
* Groups (8 tests):
|
|
10
|
+
* 1. invalid slug — returns ok:false
|
|
11
|
+
* 2. missing feedback.md — returns ok:true, found:false
|
|
12
|
+
* 3. valid feedback file — parses frontmatter + body
|
|
13
|
+
* 4. commentCount / questionCount parsed as integers
|
|
14
|
+
* 5. malformed frontmatter — falls back to raw body
|
|
15
|
+
* 6. multi-line body preserved verbatim
|
|
16
|
+
* 7. empty file — found:false-equivalent? Actually returns ok:true, found:true, empty meta
|
|
17
|
+
* 8. feedback file with comments + Q&A sections round-trips correctly
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { describe, it, expect, beforeAll, afterAll } from "bun:test";
|
|
21
|
+
import { mkdtempSync, writeFileSync, mkdirSync, rmSync } from "node:fs";
|
|
22
|
+
import { join } from "node:path";
|
|
23
|
+
import { tmpdir } from "node:os";
|
|
24
|
+
|
|
25
|
+
import { readGlyphFeedback } from "../../src/tools/read-glyph-feedback.js";
|
|
26
|
+
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Fixtures / helpers
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
let worktree: string;
|
|
32
|
+
|
|
33
|
+
beforeAll(() => {
|
|
34
|
+
worktree = mkdtempSync(join(tmpdir(), "bizar-feedback-test-"));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterAll(() => {
|
|
38
|
+
if (worktree) {
|
|
39
|
+
rmSync(worktree, { recursive: true, force: true });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
function writeFeedback(slug: string, body: string): void {
|
|
44
|
+
const dir = join(worktree, "artifacts", slug);
|
|
45
|
+
mkdirSync(dir, { recursive: true });
|
|
46
|
+
writeFileSync(join(dir, "feedback.md"), body, "utf-8");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const SAMPLE_FEEDBACK = `---
|
|
50
|
+
glyph: sample-plan
|
|
51
|
+
submittedAt: 2026-06-26T18:00:00.000Z
|
|
52
|
+
submittedBy: drb0rk
|
|
53
|
+
commentCount: 2
|
|
54
|
+
questionCount: 1
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
# Feedback for Sample Plan
|
|
58
|
+
|
|
59
|
+
## Free-placed comments
|
|
60
|
+
- (240, 120) — drb0rk: Make this button say Send link instead of Continue
|
|
61
|
+
- (165, 2121) — drb0rk: test
|
|
62
|
+
|
|
63
|
+
## Open-question answers
|
|
64
|
+
### Q: Rate-limit per IP or per email?
|
|
65
|
+
A: Per email
|
|
66
|
+
|
|
67
|
+
(kind: choice)
|
|
68
|
+
|
|
69
|
+
## Full MDX source
|
|
70
|
+
\`\`\`mdx
|
|
71
|
+
---
|
|
72
|
+
title: "Sample Plan"
|
|
73
|
+
status: review
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
# Hello
|
|
77
|
+
\`\`\`
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Group 1 — invalid slug
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
describe("readGlyphFeedback — invalid slug", () => {
|
|
85
|
+
it("rejects uppercase slugs", () => {
|
|
86
|
+
const result = readGlyphFeedback(worktree, "INVALID");
|
|
87
|
+
expect(result.ok).toBe(false);
|
|
88
|
+
if (!result.ok) {
|
|
89
|
+
expect(result.error).toContain("Invalid slug");
|
|
90
|
+
expect(result.slug).toBe("INVALID");
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("rejects path-traversal slugs", () => {
|
|
95
|
+
const result = readGlyphFeedback(worktree, "../etc");
|
|
96
|
+
expect(result.ok).toBe(false);
|
|
97
|
+
if (!result.ok) {
|
|
98
|
+
expect(result.error).toContain("Invalid slug");
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("rejects empty slugs", () => {
|
|
103
|
+
const result = readGlyphFeedback(worktree, "");
|
|
104
|
+
expect(result.ok).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
// Group 2 — missing feedback.md
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
describe("readGlyphFeedback — missing feedback.md", () => {
|
|
113
|
+
it("returns ok:true, found:false when the file does not exist", () => {
|
|
114
|
+
const result = readGlyphFeedback(worktree, "no-feedback-yet");
|
|
115
|
+
expect(result.ok).toBe(true);
|
|
116
|
+
if (result.ok && !result.found) {
|
|
117
|
+
expect(result.found).toBe(false);
|
|
118
|
+
expect(result.slug).toBe("no-feedback-yet");
|
|
119
|
+
expect(result.message).toContain("No feedback.md");
|
|
120
|
+
} else {
|
|
121
|
+
throw new Error("expected found:false");
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// Group 3 — valid feedback file
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
|
|
130
|
+
describe("readGlyphFeedback — valid feedback file", () => {
|
|
131
|
+
it("parses frontmatter and body", () => {
|
|
132
|
+
const slug = "valid-feedback";
|
|
133
|
+
writeFeedback(slug, SAMPLE_FEEDBACK);
|
|
134
|
+
const result = readGlyphFeedback(worktree, slug);
|
|
135
|
+
expect(result.ok).toBe(true);
|
|
136
|
+
if (result.ok && result.found) {
|
|
137
|
+
expect(result.meta.glyph).toBe("sample-plan");
|
|
138
|
+
expect(result.meta.submittedBy).toBe("drb0rk");
|
|
139
|
+
expect(result.body).toContain("# Feedback for Sample Plan");
|
|
140
|
+
expect(result.body).toContain("(240, 120)");
|
|
141
|
+
expect(result.body).toContain("A: Per email");
|
|
142
|
+
} else {
|
|
143
|
+
throw new Error("expected found:true");
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
// Group 4 — counts parsed
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
describe("readGlyphFeedback — counts parsed as integers", () => {
|
|
153
|
+
it("returns commentCount and questionCount as numbers", () => {
|
|
154
|
+
const slug = "counts-feedback";
|
|
155
|
+
writeFeedback(slug, SAMPLE_FEEDBACK);
|
|
156
|
+
const result = readGlyphFeedback(worktree, slug);
|
|
157
|
+
expect(result.ok).toBe(true);
|
|
158
|
+
if (result.ok && result.found) {
|
|
159
|
+
expect(result.commentCount).toBe(2);
|
|
160
|
+
expect(result.questionCount).toBe(1);
|
|
161
|
+
expect(typeof result.commentCount).toBe("number");
|
|
162
|
+
expect(typeof result.questionCount).toBe("number");
|
|
163
|
+
} else {
|
|
164
|
+
throw new Error("expected found:true");
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("treats missing counts as 0", () => {
|
|
169
|
+
const slug = "no-counts-feedback";
|
|
170
|
+
writeFeedback(slug, "---\nglyph: x\n---\n\nbody\n");
|
|
171
|
+
const result = readGlyphFeedback(worktree, slug);
|
|
172
|
+
expect(result.ok).toBe(true);
|
|
173
|
+
if (result.ok && result.found) {
|
|
174
|
+
expect(result.commentCount).toBe(0);
|
|
175
|
+
expect(result.questionCount).toBe(0);
|
|
176
|
+
} else {
|
|
177
|
+
throw new Error("expected found:true");
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
// Group 5 — malformed frontmatter
|
|
184
|
+
// ---------------------------------------------------------------------------
|
|
185
|
+
|
|
186
|
+
describe("readGlyphFeedback — malformed frontmatter", () => {
|
|
187
|
+
it("returns the raw text as body when frontmatter delimiters are missing", () => {
|
|
188
|
+
const slug = "no-frontmatter";
|
|
189
|
+
writeFeedback(slug, "Just a plain markdown body\nwith two lines\n");
|
|
190
|
+
const result = readGlyphFeedback(worktree, slug);
|
|
191
|
+
expect(result.ok).toBe(true);
|
|
192
|
+
if (result.ok && result.found) {
|
|
193
|
+
expect(result.meta).toEqual({});
|
|
194
|
+
expect(result.body).toContain("Just a plain markdown body");
|
|
195
|
+
expect(result.commentCount).toBe(0);
|
|
196
|
+
expect(result.questionCount).toBe(0);
|
|
197
|
+
} else {
|
|
198
|
+
throw new Error("expected found:true");
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
// Group 6 — body preserved verbatim
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
describe("readGlyphFeedback — body preserved verbatim", () => {
|
|
208
|
+
it("preserves multi-line bodies including fenced code blocks", () => {
|
|
209
|
+
const slug = "verbatim-feedback";
|
|
210
|
+
const longBody = "Line 1\nLine 2\n```ts\nconst x = 1;\n```\nLine 4\n";
|
|
211
|
+
writeFeedback(slug, `---\nglyph: x\ncommentCount: 0\nquestionCount: 0\n---\n\n${longBody}`);
|
|
212
|
+
const result = readGlyphFeedback(worktree, slug);
|
|
213
|
+
expect(result.ok).toBe(true);
|
|
214
|
+
if (result.ok && result.found) {
|
|
215
|
+
expect(result.body).toContain("const x = 1;");
|
|
216
|
+
expect(result.body).toContain("Line 4");
|
|
217
|
+
} else {
|
|
218
|
+
throw new Error("expected found:true");
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// ---------------------------------------------------------------------------
|
|
224
|
+
// Group 7 — round-trip
|
|
225
|
+
// ---------------------------------------------------------------------------
|
|
226
|
+
|
|
227
|
+
describe("readGlyphFeedback — round-trip", () => {
|
|
228
|
+
it("a feedback.md containing comments + Q&A + MDX source round-trips", () => {
|
|
229
|
+
const slug = "roundtrip";
|
|
230
|
+
writeFeedback(slug, SAMPLE_FEEDBACK);
|
|
231
|
+
const result = readGlyphFeedback(worktree, slug);
|
|
232
|
+
expect(result.ok).toBe(true);
|
|
233
|
+
if (result.ok && result.found) {
|
|
234
|
+
// Free-placed comments section
|
|
235
|
+
expect(result.body).toMatch(/## Free-placed comments/);
|
|
236
|
+
expect(result.body).toContain("(240, 120)");
|
|
237
|
+
expect(result.body).toContain("Send link");
|
|
238
|
+
// Open-question answers section
|
|
239
|
+
expect(result.body).toMatch(/## Open-question answers/);
|
|
240
|
+
expect(result.body).toContain("A: Per email");
|
|
241
|
+
// Full MDX source section
|
|
242
|
+
expect(result.body).toMatch(/## Full MDX source/);
|
|
243
|
+
expect(result.body).toContain("```mdx");
|
|
244
|
+
// Counts
|
|
245
|
+
expect(result.commentCount).toBe(2);
|
|
246
|
+
expect(result.questionCount).toBe(1);
|
|
247
|
+
// feedbackFile path is the worktree path
|
|
248
|
+
expect(result.feedbackFile).toBe(join(worktree, "artifacts", slug, "feedback.md"));
|
|
249
|
+
} else {
|
|
250
|
+
throw new Error("expected found:true");
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
});
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wait-for-feedback.test.ts
|
|
3
|
+
*
|
|
4
|
+
* Tests for `waitForFeedback` in src/tools/wait-for-feedback.ts.
|
|
5
|
+
*
|
|
6
|
+
* We test the core function (extracted from the tool factory) directly
|
|
7
|
+
* with an injectable `sleep` and `now` so tests run instantly. The
|
|
8
|
+
* tool factory's wrapper is thin and adds no behavior.
|
|
9
|
+
*
|
|
10
|
+
* Groups:
|
|
11
|
+
* 1. timeout (no feedback → status: "timed_out")
|
|
12
|
+
* 2. immediate feedback (comments already present)
|
|
13
|
+
* 3. delayed feedback (comments added while polling)
|
|
14
|
+
* 4. approved status (meta.json)
|
|
15
|
+
* 5. rejected status (meta.json)
|
|
16
|
+
* 6. sinceTimestamp filter (only newer comments count)
|
|
17
|
+
* 7. invalid slug → error
|
|
18
|
+
* 8. missing plan → error
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { describe, test, expect, beforeAll, afterAll } from "bun:test";
|
|
22
|
+
import {
|
|
23
|
+
mkdtempSync,
|
|
24
|
+
rmSync,
|
|
25
|
+
mkdirSync,
|
|
26
|
+
writeFileSync,
|
|
27
|
+
} from "node:fs";
|
|
28
|
+
import { join } from "node:path";
|
|
29
|
+
import { tmpdir } from "node:os";
|
|
30
|
+
|
|
31
|
+
import { waitForFeedback } from "../../src/tools/wait-for-feedback.js";
|
|
32
|
+
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Fixtures
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
class MockLogger {
|
|
38
|
+
messages: Array<{ level: string; message: string }> = [];
|
|
39
|
+
log(opts: { level: string; message: string }) { this.messages.push(opts); }
|
|
40
|
+
debug(m: string) { this.messages.push({ level: "debug", message: m }); }
|
|
41
|
+
info(m: string) { this.messages.push({ level: "info", message: m }); }
|
|
42
|
+
warn(m: string) { this.messages.push({ level: "warn", message: m }); }
|
|
43
|
+
error(m: string) { this.messages.push({ level: "error", message: m }); }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let worktree: string;
|
|
47
|
+
|
|
48
|
+
beforeAll(() => {
|
|
49
|
+
worktree = mkdtempSync(join(tmpdir(), "bizar-wait-feedback-test-"));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
afterAll(() => {
|
|
53
|
+
if (worktree) rmSync(worktree, { recursive: true, force: true });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
function planDir(slug: string) {
|
|
57
|
+
return join(worktree, "plans", slug);
|
|
58
|
+
}
|
|
59
|
+
function planJsonPath(slug: string) {
|
|
60
|
+
return join(planDir(slug), "plan.json");
|
|
61
|
+
}
|
|
62
|
+
function metaJsonPath(slug: string) {
|
|
63
|
+
return join(planDir(slug), "meta.json");
|
|
64
|
+
}
|
|
65
|
+
function seedCanvas(slug: string, canvas: unknown) {
|
|
66
|
+
mkdirSync(planDir(slug), { recursive: true });
|
|
67
|
+
writeFileSync(planJsonPath(slug), JSON.stringify(canvas), "utf-8");
|
|
68
|
+
}
|
|
69
|
+
function seedMeta(slug: string, meta: unknown) {
|
|
70
|
+
mkdirSync(planDir(slug), { recursive: true });
|
|
71
|
+
writeFileSync(metaJsonPath(slug), JSON.stringify(meta), "utf-8");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Make a sleep function that just bumps a fake clock by `ms` instead of
|
|
75
|
+
* actually waiting. Tests stay fast even with big timeout values. */
|
|
76
|
+
function fakeSleep(now: { t: number }) {
|
|
77
|
+
return (ms: number) => {
|
|
78
|
+
now.t += ms;
|
|
79
|
+
return Promise.resolve();
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ===========================================================================
|
|
84
|
+
// Group 1 — timeout
|
|
85
|
+
// ===========================================================================
|
|
86
|
+
|
|
87
|
+
describe("waitForFeedback — timeout", () => {
|
|
88
|
+
test("returns timed_out when no feedback arrives", async () => {
|
|
89
|
+
const slug = "timeout-no-feedback";
|
|
90
|
+
seedCanvas(slug, { schemaVersion: 2, comments: [] });
|
|
91
|
+
const now = { t: 1000 };
|
|
92
|
+
const r = await waitForFeedback(
|
|
93
|
+
{
|
|
94
|
+
worktree,
|
|
95
|
+
logger: new MockLogger(),
|
|
96
|
+
pollIntervalMs: 5,
|
|
97
|
+
sleep: fakeSleep(now),
|
|
98
|
+
now: () => now.t,
|
|
99
|
+
},
|
|
100
|
+
{ planSlug: slug, timeoutMs: 50 },
|
|
101
|
+
);
|
|
102
|
+
expect(r.ok).toBe(true);
|
|
103
|
+
if (r.ok) {
|
|
104
|
+
expect(r.status).toBe("timed_out");
|
|
105
|
+
expect(r.newComments).toEqual([]);
|
|
106
|
+
expect(r.planStatus).toBe("draft");
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("clamps timeout to minimum 5000ms", async () => {
|
|
111
|
+
const slug = "timeout-clamp";
|
|
112
|
+
seedCanvas(slug, { schemaVersion: 2, comments: [] });
|
|
113
|
+
const now = { t: 0 };
|
|
114
|
+
const r = await waitForFeedback(
|
|
115
|
+
{
|
|
116
|
+
worktree,
|
|
117
|
+
logger: new MockLogger(),
|
|
118
|
+
pollIntervalMs: 5,
|
|
119
|
+
sleep: fakeSleep(now),
|
|
120
|
+
now: () => now.t,
|
|
121
|
+
},
|
|
122
|
+
{ planSlug: slug, timeoutMs: 100 }, // way below min
|
|
123
|
+
);
|
|
124
|
+
expect(r.ok).toBe(true);
|
|
125
|
+
if (r.ok) {
|
|
126
|
+
// Waited exactly the clamped minimum (5000ms), no feedback → timed out
|
|
127
|
+
expect(r.status).toBe("timed_out");
|
|
128
|
+
expect(r.waitedMs).toBeGreaterThanOrEqual(5000);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// ===========================================================================
|
|
134
|
+
// Group 2 — immediate feedback (comments already present)
|
|
135
|
+
// ===========================================================================
|
|
136
|
+
|
|
137
|
+
describe("waitForFeedback — immediate feedback", () => {
|
|
138
|
+
test("returns feedback_received on first tick when comments exist", async () => {
|
|
139
|
+
const slug = "immediate-comments";
|
|
140
|
+
seedCanvas(slug, {
|
|
141
|
+
schemaVersion: 2,
|
|
142
|
+
comments: [
|
|
143
|
+
{ id: "c_1", text: "Hello", created: "2026-06-18T10:00:00Z", author: "DrB0rk" },
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
const now = { t: 0 };
|
|
147
|
+
const r = await waitForFeedback(
|
|
148
|
+
{
|
|
149
|
+
worktree,
|
|
150
|
+
logger: new MockLogger(),
|
|
151
|
+
pollIntervalMs: 5,
|
|
152
|
+
sleep: fakeSleep(now),
|
|
153
|
+
now: () => now.t,
|
|
154
|
+
},
|
|
155
|
+
{ planSlug: slug, timeoutMs: 60_000 },
|
|
156
|
+
);
|
|
157
|
+
expect(r.ok).toBe(true);
|
|
158
|
+
if (r.ok) {
|
|
159
|
+
expect(r.status).toBe("feedback_received");
|
|
160
|
+
expect(r.newComments).toHaveLength(1);
|
|
161
|
+
expect(r.newComments[0]!.id).toBe("c_1");
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// ===========================================================================
|
|
167
|
+
// Group 3 — delayed feedback (comments added while polling)
|
|
168
|
+
// ===========================================================================
|
|
169
|
+
|
|
170
|
+
describe("waitForFeedback — delayed feedback", () => {
|
|
171
|
+
test("returns feedback_received when comments appear during polling", async () => {
|
|
172
|
+
const slug = "delayed-comments";
|
|
173
|
+
seedCanvas(slug, { schemaVersion: 2, comments: [] });
|
|
174
|
+
const now = { t: 0 };
|
|
175
|
+
|
|
176
|
+
// Sleep that injects a comment after 2 ticks
|
|
177
|
+
let sleepCount = 0;
|
|
178
|
+
const sleep = (ms: number) => {
|
|
179
|
+
sleepCount++;
|
|
180
|
+
now.t += ms;
|
|
181
|
+
// After 2 sleeps (i.e. during the 3rd tick), add a comment.
|
|
182
|
+
if (sleepCount === 2) {
|
|
183
|
+
const canvas = {
|
|
184
|
+
schemaVersion: 2,
|
|
185
|
+
comments: [
|
|
186
|
+
{ id: "c_late", text: "Late", created: "2026-06-18T12:00:00Z" },
|
|
187
|
+
],
|
|
188
|
+
};
|
|
189
|
+
writeFileSync(planJsonPath(slug), JSON.stringify(canvas), "utf-8");
|
|
190
|
+
}
|
|
191
|
+
return Promise.resolve();
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const r = await waitForFeedback(
|
|
195
|
+
{
|
|
196
|
+
worktree,
|
|
197
|
+
logger: new MockLogger(),
|
|
198
|
+
pollIntervalMs: 5,
|
|
199
|
+
sleep,
|
|
200
|
+
now: () => now.t,
|
|
201
|
+
},
|
|
202
|
+
{ planSlug: slug, timeoutMs: 60_000 },
|
|
203
|
+
);
|
|
204
|
+
expect(r.ok).toBe(true);
|
|
205
|
+
if (r.ok) {
|
|
206
|
+
expect(r.status).toBe("feedback_received");
|
|
207
|
+
expect(r.newComments).toHaveLength(1);
|
|
208
|
+
expect(r.newComments[0]!.id).toBe("c_late");
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// ===========================================================================
|
|
214
|
+
// Group 4 — approved status
|
|
215
|
+
// ===========================================================================
|
|
216
|
+
|
|
217
|
+
describe("waitForFeedback — approved", () => {
|
|
218
|
+
test("returns approved when meta.json status is approved (on first tick)", async () => {
|
|
219
|
+
const slug = "approved-first-tick";
|
|
220
|
+
seedCanvas(slug, { schemaVersion: 2, comments: [] });
|
|
221
|
+
seedMeta(slug, { status: "approved" });
|
|
222
|
+
const now = { t: 0 };
|
|
223
|
+
const r = await waitForFeedback(
|
|
224
|
+
{
|
|
225
|
+
worktree,
|
|
226
|
+
logger: new MockLogger(),
|
|
227
|
+
pollIntervalMs: 5,
|
|
228
|
+
sleep: fakeSleep(now),
|
|
229
|
+
now: () => now.t,
|
|
230
|
+
},
|
|
231
|
+
{ planSlug: slug, timeoutMs: 60_000 },
|
|
232
|
+
);
|
|
233
|
+
expect(r.ok).toBe(true);
|
|
234
|
+
if (r.ok) {
|
|
235
|
+
expect(r.status).toBe("approved");
|
|
236
|
+
expect(r.planStatus).toBe("approved");
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test("returns approved when meta.json becomes approved during polling", async () => {
|
|
241
|
+
const slug = "approved-during";
|
|
242
|
+
seedCanvas(slug, { schemaVersion: 2, comments: [] });
|
|
243
|
+
const now = { t: 0 };
|
|
244
|
+
let sleepCount = 0;
|
|
245
|
+
const sleep = (ms: number) => {
|
|
246
|
+
sleepCount++;
|
|
247
|
+
now.t += ms;
|
|
248
|
+
if (sleepCount === 2) {
|
|
249
|
+
writeFileSync(metaJsonPath(slug), JSON.stringify({ status: "approved" }));
|
|
250
|
+
}
|
|
251
|
+
return Promise.resolve();
|
|
252
|
+
};
|
|
253
|
+
const r = await waitForFeedback(
|
|
254
|
+
{ worktree, logger: new MockLogger(), pollIntervalMs: 5, sleep, now: () => now.t },
|
|
255
|
+
{ planSlug: slug, timeoutMs: 60_000 },
|
|
256
|
+
);
|
|
257
|
+
expect(r.ok).toBe(true);
|
|
258
|
+
if (r.ok) expect(r.status).toBe("approved");
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// ===========================================================================
|
|
263
|
+
// Group 5 — rejected status
|
|
264
|
+
// ===========================================================================
|
|
265
|
+
|
|
266
|
+
describe("waitForFeedback — rejected", () => {
|
|
267
|
+
test("returns rejected when meta.json status is rejected", async () => {
|
|
268
|
+
const slug = "rejected-ok";
|
|
269
|
+
seedCanvas(slug, { schemaVersion: 2, comments: [] });
|
|
270
|
+
seedMeta(slug, { status: "rejected" });
|
|
271
|
+
const now = { t: 0 };
|
|
272
|
+
const r = await waitForFeedback(
|
|
273
|
+
{
|
|
274
|
+
worktree,
|
|
275
|
+
logger: new MockLogger(),
|
|
276
|
+
pollIntervalMs: 5,
|
|
277
|
+
sleep: fakeSleep(now),
|
|
278
|
+
now: () => now.t,
|
|
279
|
+
},
|
|
280
|
+
{ planSlug: slug, timeoutMs: 60_000 },
|
|
281
|
+
);
|
|
282
|
+
expect(r.ok).toBe(true);
|
|
283
|
+
if (r.ok) {
|
|
284
|
+
expect(r.status).toBe("rejected");
|
|
285
|
+
expect(r.planStatus).toBe("rejected");
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// ===========================================================================
|
|
291
|
+
// Group 6 — sinceTimestamp filter
|
|
292
|
+
// ===========================================================================
|
|
293
|
+
|
|
294
|
+
describe("waitForFeedback — sinceTimestamp filter", () => {
|
|
295
|
+
test("only counts comments strictly after sinceTimestamp", async () => {
|
|
296
|
+
const slug = "since-ts";
|
|
297
|
+
seedCanvas(slug, {
|
|
298
|
+
schemaVersion: 2,
|
|
299
|
+
comments: [
|
|
300
|
+
{ id: "c_old", text: "Old", created: "2026-06-18T09:00:00Z" },
|
|
301
|
+
{ id: "c_new", text: "New", created: "2026-06-18T11:00:00Z" },
|
|
302
|
+
],
|
|
303
|
+
});
|
|
304
|
+
const now = { t: 0 };
|
|
305
|
+
const r = await waitForFeedback(
|
|
306
|
+
{
|
|
307
|
+
worktree,
|
|
308
|
+
logger: new MockLogger(),
|
|
309
|
+
pollIntervalMs: 5,
|
|
310
|
+
sleep: fakeSleep(now),
|
|
311
|
+
now: () => now.t,
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
planSlug: slug,
|
|
315
|
+
timeoutMs: 60_000,
|
|
316
|
+
sinceTimestamp: "2026-06-18T10:00:00Z",
|
|
317
|
+
},
|
|
318
|
+
);
|
|
319
|
+
expect(r.ok).toBe(true);
|
|
320
|
+
if (r.ok) {
|
|
321
|
+
expect(r.status).toBe("feedback_received");
|
|
322
|
+
expect(r.newComments).toHaveLength(1);
|
|
323
|
+
expect(r.newComments[0]!.id).toBe("c_new");
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test("returns timed_out when all comments are older than sinceTimestamp", async () => {
|
|
328
|
+
const slug = "since-ts-no-new";
|
|
329
|
+
seedCanvas(slug, {
|
|
330
|
+
schemaVersion: 2,
|
|
331
|
+
comments: [
|
|
332
|
+
{ id: "c_old", text: "Old", created: "2026-06-18T09:00:00Z" },
|
|
333
|
+
],
|
|
334
|
+
});
|
|
335
|
+
const now = { t: 0 };
|
|
336
|
+
const r = await waitForFeedback(
|
|
337
|
+
{
|
|
338
|
+
worktree,
|
|
339
|
+
logger: new MockLogger(),
|
|
340
|
+
pollIntervalMs: 5,
|
|
341
|
+
sleep: fakeSleep(now),
|
|
342
|
+
now: () => now.t,
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
planSlug: slug,
|
|
346
|
+
timeoutMs: 60_000,
|
|
347
|
+
sinceTimestamp: "2026-06-18T12:00:00Z",
|
|
348
|
+
},
|
|
349
|
+
);
|
|
350
|
+
expect(r.ok).toBe(true);
|
|
351
|
+
if (r.ok) {
|
|
352
|
+
expect(r.status).toBe("timed_out");
|
|
353
|
+
expect(r.newComments).toEqual([]);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// ===========================================================================
|
|
359
|
+
// Group 7 — invalid slug
|
|
360
|
+
// ===========================================================================
|
|
361
|
+
|
|
362
|
+
describe("waitForFeedback — invalid slug", () => {
|
|
363
|
+
test("returns error result for invalid slug", async () => {
|
|
364
|
+
const r = await waitForFeedback(
|
|
365
|
+
{ worktree, logger: new MockLogger(), pollIntervalMs: 5, sleep: fakeSleep({ t: 0 }), now: () => 0 },
|
|
366
|
+
{ planSlug: "UPPERCASE", timeoutMs: 60_000 },
|
|
367
|
+
);
|
|
368
|
+
expect(r.ok).toBe(false);
|
|
369
|
+
if (!r.ok) {
|
|
370
|
+
expect(r.error).toMatch(/Invalid planSlug/);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// ===========================================================================
|
|
376
|
+
// Group 8 — missing plan
|
|
377
|
+
// ===========================================================================
|
|
378
|
+
|
|
379
|
+
describe("waitForFeedback — missing plan", () => {
|
|
380
|
+
test("returns error result when plan directory does not exist", async () => {
|
|
381
|
+
const r = await waitForFeedback(
|
|
382
|
+
{ worktree, logger: new MockLogger(), pollIntervalMs: 5, sleep: fakeSleep({ t: 0 }), now: () => 0 },
|
|
383
|
+
{ planSlug: "does-not-exist", timeoutMs: 60_000 },
|
|
384
|
+
);
|
|
385
|
+
expect(r.ok).toBe(false);
|
|
386
|
+
if (!r.ok) {
|
|
387
|
+
expect(r.error).toMatch(/Plan not found/);
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
});
|