@gokulvenkatareddy/cortex 0.1.7
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 +1295 -0
- package/apps/octogent/.github/workflows/ci.yml +40 -0
- package/apps/octogent/.shims/claude +4 -0
- package/apps/octogent/AGENTS.md +71 -0
- package/apps/octogent/CONTRIBUTING.md +72 -0
- package/apps/octogent/LICENSE +21 -0
- package/apps/octogent/README.md +184 -0
- package/apps/octogent/apps/api/AGENTS.md +32 -0
- package/apps/octogent/apps/api/package.json +19 -0
- package/apps/octogent/apps/api/src/agentStateDetection.ts +181 -0
- package/apps/octogent/apps/api/src/claudeSessionScanner.ts +235 -0
- package/apps/octogent/apps/api/src/claudeSkills.ts +182 -0
- package/apps/octogent/apps/api/src/claudeUsage.ts +922 -0
- package/apps/octogent/apps/api/src/cli.ts +595 -0
- package/apps/octogent/apps/api/src/codeIntelStore.ts +46 -0
- package/apps/octogent/apps/api/src/codexUsage.ts +278 -0
- package/apps/octogent/apps/api/src/createApiServer/codeIntelRoutes.ts +60 -0
- package/apps/octogent/apps/api/src/createApiServer/conversationRoutes.ts +128 -0
- package/apps/octogent/apps/api/src/createApiServer/deckRoutes.ts +873 -0
- package/apps/octogent/apps/api/src/createApiServer/gitParsers.ts +140 -0
- package/apps/octogent/apps/api/src/createApiServer/gitRoutes.ts +214 -0
- package/apps/octogent/apps/api/src/createApiServer/miscRoutes.ts +316 -0
- package/apps/octogent/apps/api/src/createApiServer/monitorParsers.ts +137 -0
- package/apps/octogent/apps/api/src/createApiServer/monitorRoutes.ts +95 -0
- package/apps/octogent/apps/api/src/createApiServer/requestHandler.ts +311 -0
- package/apps/octogent/apps/api/src/createApiServer/requestParsers.ts +25 -0
- package/apps/octogent/apps/api/src/createApiServer/routeHelpers.ts +97 -0
- package/apps/octogent/apps/api/src/createApiServer/security.ts +70 -0
- package/apps/octogent/apps/api/src/createApiServer/terminalParsers.ts +167 -0
- package/apps/octogent/apps/api/src/createApiServer/terminalRoutes.ts +315 -0
- package/apps/octogent/apps/api/src/createApiServer/types.ts +24 -0
- package/apps/octogent/apps/api/src/createApiServer/uiStateParsers.ts +255 -0
- package/apps/octogent/apps/api/src/createApiServer/upgradeHandler.ts +38 -0
- package/apps/octogent/apps/api/src/createApiServer/usageRoutes.ts +84 -0
- package/apps/octogent/apps/api/src/createApiServer.ts +176 -0
- package/apps/octogent/apps/api/src/deck/readDeckTentacles.ts +595 -0
- package/apps/octogent/apps/api/src/githubRepoSummary.ts +397 -0
- package/apps/octogent/apps/api/src/logging.ts +9 -0
- package/apps/octogent/apps/api/src/monitor/defaults.ts +3 -0
- package/apps/octogent/apps/api/src/monitor/index.ts +8 -0
- package/apps/octogent/apps/api/src/monitor/repository.ts +303 -0
- package/apps/octogent/apps/api/src/monitor/service.ts +349 -0
- package/apps/octogent/apps/api/src/monitor/types.ts +120 -0
- package/apps/octogent/apps/api/src/monitor/xProvider.ts +587 -0
- package/apps/octogent/apps/api/src/projectPersistence.ts +377 -0
- package/apps/octogent/apps/api/src/prompts/index.ts +10 -0
- package/apps/octogent/apps/api/src/prompts/promptResolver.ts +145 -0
- package/apps/octogent/apps/api/src/runtimeMetadata.ts +69 -0
- package/apps/octogent/apps/api/src/server.ts +80 -0
- package/apps/octogent/apps/api/src/setupState.ts +80 -0
- package/apps/octogent/apps/api/src/setupStatus.ts +174 -0
- package/apps/octogent/apps/api/src/startupPrerequisites.ts +146 -0
- package/apps/octogent/apps/api/src/terminalRuntime/channelMessaging.ts +87 -0
- package/apps/octogent/apps/api/src/terminalRuntime/claudeTranscript.ts +279 -0
- package/apps/octogent/apps/api/src/terminalRuntime/constants.ts +15 -0
- package/apps/octogent/apps/api/src/terminalRuntime/conversations.ts +492 -0
- package/apps/octogent/apps/api/src/terminalRuntime/gitOperations.ts +341 -0
- package/apps/octogent/apps/api/src/terminalRuntime/hookProcessor.ts +405 -0
- package/apps/octogent/apps/api/src/terminalRuntime/protocol.ts +46 -0
- package/apps/octogent/apps/api/src/terminalRuntime/ptyEnvironment.ts +50 -0
- package/apps/octogent/apps/api/src/terminalRuntime/registry.ts +423 -0
- package/apps/octogent/apps/api/src/terminalRuntime/sessionRuntime.ts +671 -0
- package/apps/octogent/apps/api/src/terminalRuntime/systemClients.ts +432 -0
- package/apps/octogent/apps/api/src/terminalRuntime/types.ts +157 -0
- package/apps/octogent/apps/api/src/terminalRuntime/worktreeManager.ts +135 -0
- package/apps/octogent/apps/api/src/terminalRuntime.ts +567 -0
- package/apps/octogent/apps/api/src/usageUtils.ts +16 -0
- package/apps/octogent/apps/api/src/ws-shim.d.ts +28 -0
- package/apps/octogent/apps/api/tests/agentStateDetection.test.ts +67 -0
- package/apps/octogent/apps/api/tests/claudeUsage.test.ts +583 -0
- package/apps/octogent/apps/api/tests/codexUsage.test.ts +107 -0
- package/apps/octogent/apps/api/tests/createApiServer.test.ts +3207 -0
- package/apps/octogent/apps/api/tests/githubRepoSummary.test.ts +100 -0
- package/apps/octogent/apps/api/tests/logging.test.ts +33 -0
- package/apps/octogent/apps/api/tests/monitorApi.test.ts +467 -0
- package/apps/octogent/apps/api/tests/monitorCore.test.ts +104 -0
- package/apps/octogent/apps/api/tests/promptResolver.test.ts +109 -0
- package/apps/octogent/apps/api/tests/protocol.test.ts +14 -0
- package/apps/octogent/apps/api/tests/sessionRuntime.test.ts +608 -0
- package/apps/octogent/apps/api/tests/startupPrerequisites.test.ts +70 -0
- package/apps/octogent/apps/api/tests/upgradeHandler.test.ts +40 -0
- package/apps/octogent/apps/api/tests/xMonitorProvider.test.ts +109 -0
- package/apps/octogent/apps/api/tsconfig.json +7 -0
- package/apps/octogent/apps/api/vitest.config.ts +7 -0
- package/apps/octogent/apps/web/AGENTS.md +38 -0
- package/apps/octogent/apps/web/index.html +13 -0
- package/apps/octogent/apps/web/package.json +32 -0
- package/apps/octogent/apps/web/public/octopus-favicon.svg +26 -0
- package/apps/octogent/apps/web/src/App.tsx +646 -0
- package/apps/octogent/apps/web/src/app/canvas/types.ts +34 -0
- package/apps/octogent/apps/web/src/app/codeIntelAggregation.ts +278 -0
- package/apps/octogent/apps/web/src/app/constants.ts +28 -0
- package/apps/octogent/apps/web/src/app/conversationNormalizers.ts +135 -0
- package/apps/octogent/apps/web/src/app/formatTimestamp.ts +18 -0
- package/apps/octogent/apps/web/src/app/githubMetrics.ts +76 -0
- package/apps/octogent/apps/web/src/app/githubNormalizers.ts +91 -0
- package/apps/octogent/apps/web/src/app/hooks/useAgentRuntimeStates.ts +18 -0
- package/apps/octogent/apps/web/src/app/hooks/useBackendLivenessPolling.ts +53 -0
- package/apps/octogent/apps/web/src/app/hooks/useCanvasGraphData.ts +449 -0
- package/apps/octogent/apps/web/src/app/hooks/useCanvasTransform.ts +260 -0
- package/apps/octogent/apps/web/src/app/hooks/useClaudeUsagePolling.ts +40 -0
- package/apps/octogent/apps/web/src/app/hooks/useClickOutside.ts +30 -0
- package/apps/octogent/apps/web/src/app/hooks/useCodeIntelRuntime.ts +83 -0
- package/apps/octogent/apps/web/src/app/hooks/useCodexUsagePolling.ts +35 -0
- package/apps/octogent/apps/web/src/app/hooks/useConsoleKeyboardShortcuts.ts +31 -0
- package/apps/octogent/apps/web/src/app/hooks/useConversationsRuntime.ts +377 -0
- package/apps/octogent/apps/web/src/app/hooks/useForceSimulation.ts +319 -0
- package/apps/octogent/apps/web/src/app/hooks/useGitHubPrimaryViewModel.ts +143 -0
- package/apps/octogent/apps/web/src/app/hooks/useGithubSummaryPolling.ts +28 -0
- package/apps/octogent/apps/web/src/app/hooks/useInitialColumnsHydration.ts +64 -0
- package/apps/octogent/apps/web/src/app/hooks/useMonitorRuntime.ts +220 -0
- package/apps/octogent/apps/web/src/app/hooks/usePersistedUiState.ts +536 -0
- package/apps/octogent/apps/web/src/app/hooks/usePollingData.ts +79 -0
- package/apps/octogent/apps/web/src/app/hooks/usePromptLibrary.ts +185 -0
- package/apps/octogent/apps/web/src/app/hooks/useTentacleGitLifecycle.ts +530 -0
- package/apps/octogent/apps/web/src/app/hooks/useTerminalCompletionNotification.ts +94 -0
- package/apps/octogent/apps/web/src/app/hooks/useTerminalMutations.ts +266 -0
- package/apps/octogent/apps/web/src/app/hooks/useTerminalStateReconciliation.ts +23 -0
- package/apps/octogent/apps/web/src/app/hooks/useUsageHeatmapPolling.ts +43 -0
- package/apps/octogent/apps/web/src/app/hooks/useWorkspaceSetup.ts +80 -0
- package/apps/octogent/apps/web/src/app/hotkeys.ts +31 -0
- package/apps/octogent/apps/web/src/app/monitorNormalizers.ts +145 -0
- package/apps/octogent/apps/web/src/app/notificationSounds.ts +164 -0
- package/apps/octogent/apps/web/src/app/terminalRuntimeStateStore.ts +261 -0
- package/apps/octogent/apps/web/src/app/terminalState.ts +21 -0
- package/apps/octogent/apps/web/src/app/types.ts +42 -0
- package/apps/octogent/apps/web/src/app/uiStateNormalizers.ts +113 -0
- package/apps/octogent/apps/web/src/app/usageNormalizers.ts +58 -0
- package/apps/octogent/apps/web/src/components/ActiveAgentsSidebar.tsx +60 -0
- package/apps/octogent/apps/web/src/components/ActivityPrimaryView.tsx +21 -0
- package/apps/octogent/apps/web/src/components/AgentStateBadge.tsx +47 -0
- package/apps/octogent/apps/web/src/components/CanvasPrimaryView.tsx +1532 -0
- package/apps/octogent/apps/web/src/components/ClearAllConversationsDialog.tsx +33 -0
- package/apps/octogent/apps/web/src/components/CodeIntelArcDiagram.tsx +245 -0
- package/apps/octogent/apps/web/src/components/CodeIntelPrimaryView.tsx +104 -0
- package/apps/octogent/apps/web/src/components/CodeIntelTreemap.tsx +138 -0
- package/apps/octogent/apps/web/src/components/ConsolePrimaryNav.tsx +31 -0
- package/apps/octogent/apps/web/src/components/ConversationsPrimaryView.tsx +243 -0
- package/apps/octogent/apps/web/src/components/DeckPrimaryView.tsx +613 -0
- package/apps/octogent/apps/web/src/components/DeleteTentacleDialog.tsx +91 -0
- package/apps/octogent/apps/web/src/components/EmptyOctopus.tsx +715 -0
- package/apps/octogent/apps/web/src/components/GitHubPrimaryView.tsx +494 -0
- package/apps/octogent/apps/web/src/components/MonitorPrimaryView.tsx +475 -0
- package/apps/octogent/apps/web/src/components/PrimaryViewRouter.tsx +99 -0
- package/apps/octogent/apps/web/src/components/PromptsPrimaryView.tsx +243 -0
- package/apps/octogent/apps/web/src/components/RuntimeStatusStrip.tsx +273 -0
- package/apps/octogent/apps/web/src/components/SettingsPrimaryView.tsx +92 -0
- package/apps/octogent/apps/web/src/components/SidebarActionPanel.tsx +124 -0
- package/apps/octogent/apps/web/src/components/SidebarConversationsList.tsx +279 -0
- package/apps/octogent/apps/web/src/components/SidebarPromptsList.tsx +116 -0
- package/apps/octogent/apps/web/src/components/TelemetryTape.tsx +106 -0
- package/apps/octogent/apps/web/src/components/TentacleGitActionsDialog.tsx +341 -0
- package/apps/octogent/apps/web/src/components/Terminal.tsx +524 -0
- package/apps/octogent/apps/web/src/components/TerminalPromptPicker.tsx +140 -0
- package/apps/octogent/apps/web/src/components/UsageHeatmap.tsx +702 -0
- package/apps/octogent/apps/web/src/components/canvas/CanvasTentaclePanel.tsx +485 -0
- package/apps/octogent/apps/web/src/components/canvas/CanvasTerminalColumn.tsx +89 -0
- package/apps/octogent/apps/web/src/components/canvas/DeleteAllTerminalsDialog.tsx +221 -0
- package/apps/octogent/apps/web/src/components/canvas/OctopusNode.tsx +307 -0
- package/apps/octogent/apps/web/src/components/canvas/SessionNode.tsx +185 -0
- package/apps/octogent/apps/web/src/components/deck/ActionCards.tsx +118 -0
- package/apps/octogent/apps/web/src/components/deck/AddTentacleForm.tsx +269 -0
- package/apps/octogent/apps/web/src/components/deck/DeckBottomActions.tsx +56 -0
- package/apps/octogent/apps/web/src/components/deck/TentaclePod.tsx +334 -0
- package/apps/octogent/apps/web/src/components/deck/WorkspaceSetupCard.tsx +105 -0
- package/apps/octogent/apps/web/src/components/deck/octopusVisuals.ts +72 -0
- package/apps/octogent/apps/web/src/components/terminalReplay.ts +62 -0
- package/apps/octogent/apps/web/src/components/terminalWheel.ts +54 -0
- package/apps/octogent/apps/web/src/components/ui/ActionButton.tsx +34 -0
- package/apps/octogent/apps/web/src/components/ui/ConfirmationDialog.tsx +86 -0
- package/apps/octogent/apps/web/src/components/ui/MarkdownContent.tsx +43 -0
- package/apps/octogent/apps/web/src/components/ui/SettingsToggle.tsx +34 -0
- package/apps/octogent/apps/web/src/components/ui/StatusBadge.tsx +24 -0
- package/apps/octogent/apps/web/src/main.tsx +17 -0
- package/apps/octogent/apps/web/src/runtime/HttpTerminalSnapshotReader.ts +87 -0
- package/apps/octogent/apps/web/src/runtime/runtimeEndpoints.ts +412 -0
- package/apps/octogent/apps/web/src/styles/chrome-and-buttons.css +272 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-activity.css +358 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-canvas.css +1843 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-code-intel.css +227 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-conversations.css +705 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-deck.css +1524 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-github.css +541 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-monitor.css +595 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-pixpack.css +81 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-prompts.css +474 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-settings.css +207 -0
- package/apps/octogent/apps/web/src/styles/console-chrome-status-nav.css +441 -0
- package/apps/octogent/apps/web/src/styles/console-overrides-telemetry.css +320 -0
- package/apps/octogent/apps/web/src/styles/console-theme-tokens.css +25 -0
- package/apps/octogent/apps/web/src/styles/cortex-theme.css +412 -0
- package/apps/octogent/apps/web/src/styles/foundation.css +100 -0
- package/apps/octogent/apps/web/src/styles/sidebar-and-scrollbars.css +447 -0
- package/apps/octogent/apps/web/src/styles/terminal-and-status.css +356 -0
- package/apps/octogent/apps/web/src/styles.css +25 -0
- package/apps/octogent/apps/web/src/types/ws.d.ts +23 -0
- package/apps/octogent/apps/web/tests/CanvasPrimaryView.test.tsx +347 -0
- package/apps/octogent/apps/web/tests/HttpTerminalSnapshotReader.test.tsx +54 -0
- package/apps/octogent/apps/web/tests/RuntimeStatusStrip.test.tsx +70 -0
- package/apps/octogent/apps/web/tests/Terminal.test.tsx +87 -0
- package/apps/octogent/apps/web/tests/add-tentacle-form.test.tsx +48 -0
- package/apps/octogent/apps/web/tests/app-github-runtime.test.tsx +162 -0
- package/apps/octogent/apps/web/tests/app-monitor-runtime.test.tsx +657 -0
- package/apps/octogent/apps/web/tests/app-shell-navigation.test.tsx +109 -0
- package/apps/octogent/apps/web/tests/app-swarm-refresh.test.tsx +268 -0
- package/apps/octogent/apps/web/tests/app-ui-state-persistence.test.tsx +116 -0
- package/apps/octogent/apps/web/tests/app-workspace-setup.test.tsx +217 -0
- package/apps/octogent/apps/web/tests/canvas-tentacle-panel.test.tsx +195 -0
- package/apps/octogent/apps/web/tests/delete-all-terminals-dialog.test.tsx +76 -0
- package/apps/octogent/apps/web/tests/githubMetrics.test.tsx +52 -0
- package/apps/octogent/apps/web/tests/hotkeys.test.tsx +44 -0
- package/apps/octogent/apps/web/tests/runtimeEndpoints.test.tsx +240 -0
- package/apps/octogent/apps/web/tests/setup.ts +39 -0
- package/apps/octogent/apps/web/tests/tentacle-pod.test.tsx +62 -0
- package/apps/octogent/apps/web/tests/terminalReplay.test.ts +71 -0
- package/apps/octogent/apps/web/tests/terminalState.test.tsx +49 -0
- package/apps/octogent/apps/web/tests/terminalWheel.test.tsx +51 -0
- package/apps/octogent/apps/web/tests/test-utils/appTestHarness.ts +48 -0
- package/apps/octogent/apps/web/tests/uiPrimitives.test.tsx +31 -0
- package/apps/octogent/apps/web/tests/useAgentRuntimeStates.test.tsx +47 -0
- package/apps/octogent/apps/web/tsconfig.json +8 -0
- package/apps/octogent/apps/web/vite.api.bundle.config.mts +32 -0
- package/apps/octogent/apps/web/vite.config.ts +22 -0
- package/apps/octogent/bin/octogent +3 -0
- package/apps/octogent/biome.json +21 -0
- package/apps/octogent/docs/concepts/mental-model.md +79 -0
- package/apps/octogent/docs/concepts/runtime-and-api.md +60 -0
- package/apps/octogent/docs/concepts/tentacles.md +85 -0
- package/apps/octogent/docs/getting-started/installation.md +54 -0
- package/apps/octogent/docs/getting-started/quickstart.md +79 -0
- package/apps/octogent/docs/guides/inter-agent-messaging.md +43 -0
- package/apps/octogent/docs/guides/orchestrating-child-agents.md +49 -0
- package/apps/octogent/docs/guides/working-with-todos.md +56 -0
- package/apps/octogent/docs/index.md +40 -0
- package/apps/octogent/docs/reference/api.md +103 -0
- package/apps/octogent/docs/reference/cli.md +71 -0
- package/apps/octogent/docs/reference/experimental-features.md +28 -0
- package/apps/octogent/docs/reference/filesystem-layout.md +62 -0
- package/apps/octogent/docs/reference/troubleshooting.md +49 -0
- package/apps/octogent/package.json +35 -0
- package/apps/octogent/packages/core/AGENTS.md +31 -0
- package/apps/octogent/packages/core/package.json +12 -0
- package/apps/octogent/packages/core/src/adapters/InMemoryTerminalSnapshotReader.ts +10 -0
- package/apps/octogent/packages/core/src/application/buildTerminalList.ts +13 -0
- package/apps/octogent/packages/core/src/domain/agentRuntime.ts +18 -0
- package/apps/octogent/packages/core/src/domain/channel.ts +8 -0
- package/apps/octogent/packages/core/src/domain/completionSound.ts +14 -0
- package/apps/octogent/packages/core/src/domain/conversation.ts +48 -0
- package/apps/octogent/packages/core/src/domain/deck.ts +33 -0
- package/apps/octogent/packages/core/src/domain/git.ts +32 -0
- package/apps/octogent/packages/core/src/domain/monitor.ts +62 -0
- package/apps/octogent/packages/core/src/domain/setup.ts +27 -0
- package/apps/octogent/packages/core/src/domain/terminal.ts +17 -0
- package/apps/octogent/packages/core/src/domain/uiState.ts +22 -0
- package/apps/octogent/packages/core/src/domain/usage.ts +60 -0
- package/apps/octogent/packages/core/src/index.ts +15 -0
- package/apps/octogent/packages/core/src/ports/TerminalSnapshotReader.ts +5 -0
- package/apps/octogent/packages/core/src/util/typeCoercion.ts +20 -0
- package/apps/octogent/packages/core/tests/buildTerminalList.test.ts +75 -0
- package/apps/octogent/packages/core/tsconfig.json +7 -0
- package/apps/octogent/packages/core/tsconfig.tsbuildinfo +1 -0
- package/apps/octogent/packages/core/vitest.config.ts +7 -0
- package/apps/octogent/pnpm-lock.yaml +3212 -0
- package/apps/octogent/pnpm-workspace.yaml +3 -0
- package/apps/octogent/prompts/meta-prompt-generator.md +223 -0
- package/apps/octogent/prompts/octoboss-clean-contexts.md +30 -0
- package/apps/octogent/prompts/octoboss-reorganize-tentacles.md +29 -0
- package/apps/octogent/prompts/octoboss-reorganize-todos.md +27 -0
- package/apps/octogent/prompts/sandbox-init.md +3 -0
- package/apps/octogent/prompts/swarm-parent.md +83 -0
- package/apps/octogent/prompts/swarm-worker.md +50 -0
- package/apps/octogent/prompts/tentacle-context-init.md +1 -0
- package/apps/octogent/prompts/tentacle-planner.md +110 -0
- package/apps/octogent/prompts/tentacle-reorganize-todos.md +20 -0
- package/apps/octogent/prompts/tentacle-update-tentacle.md +18 -0
- package/apps/octogent/scripts/build-package.mjs +23 -0
- package/apps/octogent/scripts/dev.mjs +158 -0
- package/apps/octogent/scripts/smoke-public-install.mjs +271 -0
- package/apps/octogent/static/images/octogent-header.png +0 -0
- package/apps/octogent/static/images/preview_1.jpg +0 -0
- package/apps/octogent/static/images/preview_2.jpg +0 -0
- package/apps/octogent/static/images/preview_3.jpg +0 -0
- package/apps/octogent/static/images/preview_4.jpg +0 -0
- package/apps/octogent/static/images/preview_5.jpg +0 -0
- package/apps/octogent/static/images/preview_6.jpg +0 -0
- package/apps/octogent/tsconfig.base.json +16 -0
- package/bin/AGI +3 -0
- package/bin/AGI-install-app +71 -0
- package/bin/AGI-ui +16 -0
- package/bin/AGI-voice +15 -0
- package/bin/AGI-web +16 -0
- package/bin/cortex +109 -0
- package/bin/cortex-octogent +99 -0
- package/bin/import-specifier.mjs +13 -0
- package/bin/import-specifier.test.mjs +13 -0
- package/bin/octo +150 -0
- package/dist/cli.mjs +555650 -0
- package/package.json +157 -0
- package/scripts/setup-wizard.ts +390 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { CanvasPrimaryView } from "../src/components/CanvasPrimaryView";
|
|
5
|
+
|
|
6
|
+
type MockCanvasNode = {
|
|
7
|
+
id: string;
|
|
8
|
+
type: "tentacle" | "active-session";
|
|
9
|
+
tentacleId: string;
|
|
10
|
+
label: string;
|
|
11
|
+
color: string;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
radius: number;
|
|
15
|
+
sessionId?: string;
|
|
16
|
+
agentState?: "live";
|
|
17
|
+
agentRuntimeState?: "idle";
|
|
18
|
+
hasUserPrompt?: boolean;
|
|
19
|
+
workspaceMode?: "shared";
|
|
20
|
+
parentTerminalId?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const nodes: MockCanvasNode[] = [
|
|
24
|
+
{
|
|
25
|
+
id: "t:tentacle-a",
|
|
26
|
+
type: "tentacle" as const,
|
|
27
|
+
tentacleId: "tentacle-a",
|
|
28
|
+
label: "tentacle-a",
|
|
29
|
+
color: "#ff6b2b",
|
|
30
|
+
x: 80,
|
|
31
|
+
y: 80,
|
|
32
|
+
radius: 28,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "a:terminal-1",
|
|
36
|
+
type: "active-session" as const,
|
|
37
|
+
sessionId: "terminal-1",
|
|
38
|
+
tentacleId: "tentacle-a",
|
|
39
|
+
label: "terminal-1",
|
|
40
|
+
color: "#ff6b2b",
|
|
41
|
+
x: 120,
|
|
42
|
+
y: 120,
|
|
43
|
+
radius: 20,
|
|
44
|
+
agentState: "live" as const,
|
|
45
|
+
agentRuntimeState: "idle" as const,
|
|
46
|
+
hasUserPrompt: true,
|
|
47
|
+
workspaceMode: "shared" as const,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
vi.mock("../src/app/hooks/useAgentRuntimeStates", () => ({
|
|
52
|
+
useAgentRuntimeStates: () => new Map(),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
vi.mock("../src/app/hooks/useCanvasGraphData", () => ({
|
|
56
|
+
useCanvasGraphData: () => ({
|
|
57
|
+
nodes,
|
|
58
|
+
edges: [],
|
|
59
|
+
tentacleById: new Map(),
|
|
60
|
+
sessionsByTentacleId: new Map(),
|
|
61
|
+
refresh: vi.fn(),
|
|
62
|
+
refreshDeckTentacles: vi.fn(),
|
|
63
|
+
}),
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
vi.mock("../src/app/hooks/useCanvasTransform", () => ({
|
|
67
|
+
useCanvasTransform: () => ({
|
|
68
|
+
transform: { translateX: 0, translateY: 0, scale: 1 },
|
|
69
|
+
isPanning: false,
|
|
70
|
+
svgRef: { current: null },
|
|
71
|
+
handleWheel: vi.fn(),
|
|
72
|
+
handlePointerDown: vi.fn(),
|
|
73
|
+
handlePointerMove: vi.fn(),
|
|
74
|
+
handlePointerUp: vi.fn(),
|
|
75
|
+
screenToGraph: () => ({ x: 0, y: 0 }),
|
|
76
|
+
fitAll: vi.fn(),
|
|
77
|
+
}),
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
vi.mock("../src/app/hooks/useForceSimulation", () => ({
|
|
81
|
+
DEFAULT_FORCE_PARAMS: {},
|
|
82
|
+
useForceSimulation: ({ nodes: nextNodes }: { nodes: typeof nodes }) => ({
|
|
83
|
+
simulatedNodes: nextNodes,
|
|
84
|
+
pinNode: vi.fn(),
|
|
85
|
+
unpinNode: vi.fn(),
|
|
86
|
+
moveNode: vi.fn(),
|
|
87
|
+
reheat: vi.fn(),
|
|
88
|
+
}),
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
vi.mock("../src/components/canvas/SessionNode", () => ({
|
|
92
|
+
SessionNode: ({
|
|
93
|
+
node,
|
|
94
|
+
onClick,
|
|
95
|
+
}: {
|
|
96
|
+
node: (typeof nodes)[number];
|
|
97
|
+
onClick: (nodeId: string) => void;
|
|
98
|
+
}) => (
|
|
99
|
+
<button type="button" data-node-id={node.id} onClick={() => onClick(node.id)}>
|
|
100
|
+
{node.label}
|
|
101
|
+
</button>
|
|
102
|
+
),
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
vi.mock("../src/components/canvas/OctopusNode", () => ({
|
|
106
|
+
OctopusNode: ({
|
|
107
|
+
node,
|
|
108
|
+
onClick,
|
|
109
|
+
}: {
|
|
110
|
+
node: (typeof nodes)[number];
|
|
111
|
+
onClick: (nodeId: string) => void;
|
|
112
|
+
}) => (
|
|
113
|
+
<g
|
|
114
|
+
data-node-id={node.id}
|
|
115
|
+
onClick={() => onClick(node.id)}
|
|
116
|
+
onKeyDown={(event) => {
|
|
117
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
118
|
+
onClick(node.id);
|
|
119
|
+
}
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<circle cx={node.x} cy={node.y} r={node.radius} />
|
|
123
|
+
<title>{node.label}</title>
|
|
124
|
+
</g>
|
|
125
|
+
),
|
|
126
|
+
}));
|
|
127
|
+
|
|
128
|
+
vi.mock("../src/components/canvas/CanvasTerminalColumn", () => ({
|
|
129
|
+
CanvasTerminalColumn: ({
|
|
130
|
+
node,
|
|
131
|
+
panelRef,
|
|
132
|
+
}: {
|
|
133
|
+
node: (typeof nodes)[number];
|
|
134
|
+
panelRef?: ((element: HTMLElement | null) => void) | undefined;
|
|
135
|
+
}) => (
|
|
136
|
+
<section ref={panelRef} data-testid={`panel-${node.id}`} tabIndex={-1}>
|
|
137
|
+
panel {node.id} label {node.label}
|
|
138
|
+
</section>
|
|
139
|
+
),
|
|
140
|
+
}));
|
|
141
|
+
|
|
142
|
+
vi.mock("../src/components/canvas/CanvasTentaclePanel", () => ({
|
|
143
|
+
CanvasTentaclePanel: () => null,
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
describe("CanvasPrimaryView", () => {
|
|
147
|
+
beforeEach(() => {
|
|
148
|
+
vi.spyOn(window, "requestAnimationFrame").mockImplementation(
|
|
149
|
+
(callback: FrameRequestCallback) => {
|
|
150
|
+
callback(0);
|
|
151
|
+
return 1;
|
|
152
|
+
},
|
|
153
|
+
);
|
|
154
|
+
vi.spyOn(window, "cancelAnimationFrame").mockImplementation(() => {});
|
|
155
|
+
Object.defineProperty(HTMLElement.prototype, "scrollIntoView", {
|
|
156
|
+
configurable: true,
|
|
157
|
+
value: vi.fn(),
|
|
158
|
+
writable: true,
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(HTMLElement.prototype, "focus", {
|
|
161
|
+
configurable: true,
|
|
162
|
+
value: vi.fn(),
|
|
163
|
+
writable: true,
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
afterEach(() => {
|
|
168
|
+
cleanup();
|
|
169
|
+
nodes.splice(2);
|
|
170
|
+
vi.restoreAllMocks();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("reveals and focuses a newly opened terminal panel when a session node is clicked", async () => {
|
|
174
|
+
render(<CanvasPrimaryView columns={[]} isUiStateHydrated />);
|
|
175
|
+
|
|
176
|
+
const [terminalButton] = screen.getAllByRole("button", { name: "terminal-1" });
|
|
177
|
+
expect(terminalButton).toBeDefined();
|
|
178
|
+
if (!terminalButton) throw new Error("Missing terminal button");
|
|
179
|
+
|
|
180
|
+
fireEvent.click(terminalButton);
|
|
181
|
+
|
|
182
|
+
await waitFor(() => {
|
|
183
|
+
expect(screen.getByTestId("panel-a:terminal-1")).toBeInTheDocument();
|
|
184
|
+
expect(HTMLElement.prototype.scrollIntoView).toHaveBeenCalledTimes(1);
|
|
185
|
+
expect(HTMLElement.prototype.focus).toHaveBeenCalledTimes(1);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("auto-opens a newly created child terminal when its parent panel is already open", async () => {
|
|
190
|
+
const { rerender } = render(
|
|
191
|
+
<CanvasPrimaryView
|
|
192
|
+
columns={[
|
|
193
|
+
{
|
|
194
|
+
terminalId: "terminal-1",
|
|
195
|
+
label: "terminal-1",
|
|
196
|
+
state: "live",
|
|
197
|
+
tentacleId: "tentacle-a",
|
|
198
|
+
createdAt: "2026-02-24T10:00:00.000Z",
|
|
199
|
+
},
|
|
200
|
+
]}
|
|
201
|
+
isUiStateHydrated
|
|
202
|
+
/>,
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const [terminalButton] = screen.getAllByRole("button", { name: "terminal-1" });
|
|
206
|
+
expect(terminalButton).toBeDefined();
|
|
207
|
+
if (!terminalButton) throw new Error("Missing terminal button");
|
|
208
|
+
|
|
209
|
+
fireEvent.click(terminalButton);
|
|
210
|
+
|
|
211
|
+
await waitFor(() => {
|
|
212
|
+
expect(screen.getByTestId("panel-a:terminal-1")).toBeInTheDocument();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
nodes.push({
|
|
216
|
+
id: "a:terminal-2",
|
|
217
|
+
type: "active-session" as const,
|
|
218
|
+
sessionId: "terminal-2",
|
|
219
|
+
tentacleId: "tentacle-a",
|
|
220
|
+
label: "terminal-2",
|
|
221
|
+
color: "#ff6b2b",
|
|
222
|
+
x: 160,
|
|
223
|
+
y: 160,
|
|
224
|
+
radius: 20,
|
|
225
|
+
agentState: "live" as const,
|
|
226
|
+
agentRuntimeState: "idle" as const,
|
|
227
|
+
hasUserPrompt: true,
|
|
228
|
+
workspaceMode: "shared" as const,
|
|
229
|
+
parentTerminalId: "terminal-1",
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
rerender(
|
|
233
|
+
<CanvasPrimaryView
|
|
234
|
+
columns={[
|
|
235
|
+
{
|
|
236
|
+
terminalId: "terminal-1",
|
|
237
|
+
label: "terminal-1",
|
|
238
|
+
state: "live",
|
|
239
|
+
tentacleId: "tentacle-a",
|
|
240
|
+
createdAt: "2026-02-24T10:00:00.000Z",
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
terminalId: "terminal-2",
|
|
244
|
+
label: "terminal-2",
|
|
245
|
+
state: "live",
|
|
246
|
+
tentacleId: "tentacle-a",
|
|
247
|
+
tentacleName: "tentacle-a",
|
|
248
|
+
parentTerminalId: "terminal-1",
|
|
249
|
+
workspaceMode: "shared",
|
|
250
|
+
createdAt: "2026-02-24T10:05:00.000Z",
|
|
251
|
+
hasUserPrompt: true,
|
|
252
|
+
},
|
|
253
|
+
]}
|
|
254
|
+
isUiStateHydrated
|
|
255
|
+
recentlyCreatedTerminal={{
|
|
256
|
+
terminalId: "terminal-2",
|
|
257
|
+
label: "terminal-2",
|
|
258
|
+
state: "live",
|
|
259
|
+
tentacleId: "tentacle-a",
|
|
260
|
+
tentacleName: "tentacle-a",
|
|
261
|
+
parentTerminalId: "terminal-1",
|
|
262
|
+
workspaceMode: "shared",
|
|
263
|
+
createdAt: "2026-02-24T10:05:00.000Z",
|
|
264
|
+
hasUserPrompt: true,
|
|
265
|
+
}}
|
|
266
|
+
/>,
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
await waitFor(() => {
|
|
270
|
+
expect(screen.getByTestId("panel-a:terminal-2")).toBeInTheDocument();
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it("updates an open terminal panel label when the terminal is renamed", async () => {
|
|
275
|
+
const { rerender } = render(
|
|
276
|
+
<CanvasPrimaryView
|
|
277
|
+
columns={[
|
|
278
|
+
{
|
|
279
|
+
terminalId: "terminal-1",
|
|
280
|
+
label: "terminal-1",
|
|
281
|
+
state: "live",
|
|
282
|
+
tentacleId: "tentacle-a",
|
|
283
|
+
tentacleName: "tentacle-a",
|
|
284
|
+
createdAt: "2026-02-24T10:00:00.000Z",
|
|
285
|
+
},
|
|
286
|
+
]}
|
|
287
|
+
isUiStateHydrated
|
|
288
|
+
/>,
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
const [terminalButton] = screen.getAllByRole("button", { name: "terminal-1" });
|
|
292
|
+
expect(terminalButton).toBeDefined();
|
|
293
|
+
if (!terminalButton) throw new Error("Missing terminal button");
|
|
294
|
+
|
|
295
|
+
fireEvent.click(terminalButton);
|
|
296
|
+
|
|
297
|
+
await waitFor(() => {
|
|
298
|
+
expect(screen.getByTestId("panel-a:terminal-1")).toHaveTextContent(
|
|
299
|
+
"panel a:terminal-1 label tentacle-a",
|
|
300
|
+
);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
rerender(
|
|
304
|
+
<CanvasPrimaryView
|
|
305
|
+
columns={[
|
|
306
|
+
{
|
|
307
|
+
terminalId: "terminal-1",
|
|
308
|
+
label: "terminal-1",
|
|
309
|
+
state: "live",
|
|
310
|
+
tentacleId: "tentacle-a",
|
|
311
|
+
tentacleName: "renamed-tentacle",
|
|
312
|
+
createdAt: "2026-02-24T10:00:00.000Z",
|
|
313
|
+
},
|
|
314
|
+
]}
|
|
315
|
+
isUiStateHydrated
|
|
316
|
+
/>,
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
await waitFor(() => {
|
|
320
|
+
expect(screen.getByTestId("panel-a:terminal-1")).toHaveTextContent(
|
|
321
|
+
"panel a:terminal-1 label renamed-tentacle",
|
|
322
|
+
);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it("shows tentacle maintenance actions in the context menu and passes the tentacle ID", async () => {
|
|
327
|
+
const onTentacleAction = vi.fn().mockResolvedValue(undefined);
|
|
328
|
+
|
|
329
|
+
const { container } = render(
|
|
330
|
+
<CanvasPrimaryView columns={[]} isUiStateHydrated onTentacleAction={onTentacleAction} />,
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
const tentacleNode = container.querySelector('[data-node-id="t:tentacle-a"]');
|
|
334
|
+
expect(tentacleNode).not.toBeNull();
|
|
335
|
+
|
|
336
|
+
fireEvent.contextMenu(tentacleNode as Element, { clientX: 160, clientY: 120 });
|
|
337
|
+
|
|
338
|
+
expect(await screen.findByRole("button", { name: "Update To-Do List" })).toBeInTheDocument();
|
|
339
|
+
expect(screen.getByRole("button", { name: "Update Tentacle" })).toBeInTheDocument();
|
|
340
|
+
|
|
341
|
+
fireEvent.click(screen.getByRole("button", { name: "Update To-Do List" }));
|
|
342
|
+
|
|
343
|
+
await waitFor(() => {
|
|
344
|
+
expect(onTentacleAction).toHaveBeenCalledWith("tentacle-a", "tentacle-reorganize-todos");
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { HttpTerminalSnapshotReader } from "../src/runtime/HttpTerminalSnapshotReader";
|
|
4
|
+
|
|
5
|
+
describe("HttpTerminalSnapshotReader", () => {
|
|
6
|
+
it("loads snapshots and filters out malformed payload entries", async () => {
|
|
7
|
+
const reader = new HttpTerminalSnapshotReader({
|
|
8
|
+
endpoint: "https://runtime.example.com/api/terminal-snapshots",
|
|
9
|
+
fetcher: async () => ({
|
|
10
|
+
ok: true,
|
|
11
|
+
status: 200,
|
|
12
|
+
json: async () => [
|
|
13
|
+
{
|
|
14
|
+
terminalId: "agent-1",
|
|
15
|
+
label: "root-a",
|
|
16
|
+
state: "live",
|
|
17
|
+
tentacleId: "tentacle-a",
|
|
18
|
+
tentacleName: "planner",
|
|
19
|
+
createdAt: "2026-02-24T10:00:00.000Z",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "invalid-entry",
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await expect(reader.listTerminalSnapshots()).resolves.toEqual([
|
|
29
|
+
{
|
|
30
|
+
terminalId: "agent-1",
|
|
31
|
+
label: "root-a",
|
|
32
|
+
state: "live",
|
|
33
|
+
tentacleId: "tentacle-a",
|
|
34
|
+
tentacleName: "planner",
|
|
35
|
+
createdAt: "2026-02-24T10:00:00.000Z",
|
|
36
|
+
},
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("throws when API response is not ok", async () => {
|
|
41
|
+
const reader = new HttpTerminalSnapshotReader({
|
|
42
|
+
endpoint: "https://runtime.example.com/api/terminal-snapshots",
|
|
43
|
+
fetcher: async () => ({
|
|
44
|
+
ok: false,
|
|
45
|
+
status: 503,
|
|
46
|
+
json: async () => [],
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await expect(reader.listTerminalSnapshots()).rejects.toThrow(
|
|
51
|
+
"Unable to load terminal snapshots (503)",
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { render, screen, within } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { RuntimeStatusStrip } from "../src/components/RuntimeStatusStrip";
|
|
5
|
+
|
|
6
|
+
describe("RuntimeStatusStrip", () => {
|
|
7
|
+
it("shows loading placeholders before claude usage loads", () => {
|
|
8
|
+
render(<RuntimeStatusStrip sparklinePoints="" usageData={null} claudeUsage={null} />);
|
|
9
|
+
|
|
10
|
+
const usage = screen.getByLabelText("Claude usage limits");
|
|
11
|
+
expect(within(usage).getAllByText("···")).toHaveLength(2);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("uses a 5h label for oauth-backed usage", () => {
|
|
15
|
+
render(
|
|
16
|
+
<RuntimeStatusStrip
|
|
17
|
+
sparklinePoints=""
|
|
18
|
+
usageData={null}
|
|
19
|
+
claudeUsage={{
|
|
20
|
+
status: "ok",
|
|
21
|
+
source: "oauth-api",
|
|
22
|
+
fetchedAt: "2026-04-09T10:00:00.000Z",
|
|
23
|
+
primaryUsedPercent: 14,
|
|
24
|
+
secondaryUsedPercent: 52,
|
|
25
|
+
}}
|
|
26
|
+
/>,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const usage = screen.getByLabelText("Claude usage limits");
|
|
30
|
+
expect(within(usage).getByText("5h")).toBeInTheDocument();
|
|
31
|
+
expect(within(usage).getByText("14%")).toBeInTheDocument();
|
|
32
|
+
expect(within(usage).getByText("52%")).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("shows unavailable values instead of a permanent loading state", () => {
|
|
36
|
+
render(
|
|
37
|
+
<RuntimeStatusStrip
|
|
38
|
+
sparklinePoints=""
|
|
39
|
+
usageData={null}
|
|
40
|
+
claudeUsage={{
|
|
41
|
+
status: "unavailable",
|
|
42
|
+
source: "none",
|
|
43
|
+
fetchedAt: "2026-04-09T10:00:00.000Z",
|
|
44
|
+
message: "Claude credentials not found. Run `claude login`.",
|
|
45
|
+
}}
|
|
46
|
+
/>,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const usage = screen.getByLabelText("Claude usage limits");
|
|
50
|
+
expect(within(usage).getAllByText("NA")).toHaveLength(2);
|
|
51
|
+
expect(within(usage).queryByText("···")).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("marks the refresh button as rotating while Claude usage is refreshing", () => {
|
|
55
|
+
render(
|
|
56
|
+
<RuntimeStatusStrip
|
|
57
|
+
sparklinePoints=""
|
|
58
|
+
usageData={null}
|
|
59
|
+
claudeUsage={null}
|
|
60
|
+
isRefreshingClaudeUsage
|
|
61
|
+
onRefreshClaudeUsage={() => {}}
|
|
62
|
+
/>,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(screen.getByRole("button", { name: "Refresh Claude usage" })).toHaveAttribute(
|
|
66
|
+
"data-refreshing",
|
|
67
|
+
"true",
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { cleanup, render, screen, waitFor } from "@testing-library/react";
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { Terminal } from "../src/components/Terminal";
|
|
5
|
+
|
|
6
|
+
type Listener = (event: { data: unknown }) => void;
|
|
7
|
+
|
|
8
|
+
class MockWebSocket {
|
|
9
|
+
static instances: MockWebSocket[] = [];
|
|
10
|
+
|
|
11
|
+
readonly url: string;
|
|
12
|
+
private listeners = new Map<string, Set<Listener>>();
|
|
13
|
+
|
|
14
|
+
close = vi.fn();
|
|
15
|
+
send = vi.fn();
|
|
16
|
+
|
|
17
|
+
constructor(url: string) {
|
|
18
|
+
this.url = url;
|
|
19
|
+
MockWebSocket.instances.push(this);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
addEventListener(type: string, listener: Listener) {
|
|
23
|
+
const bucket = this.listeners.get(type) ?? new Set<Listener>();
|
|
24
|
+
bucket.add(listener);
|
|
25
|
+
this.listeners.set(type, bucket);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
removeEventListener(type: string, listener: Listener) {
|
|
29
|
+
this.listeners.get(type)?.delete(listener);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
emit(type: string, data?: unknown) {
|
|
33
|
+
const event = { data };
|
|
34
|
+
for (const listener of this.listeners.get(type) ?? []) {
|
|
35
|
+
listener(event);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe("Terminal", () => {
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
cleanup();
|
|
43
|
+
vi.restoreAllMocks();
|
|
44
|
+
vi.unstubAllGlobals();
|
|
45
|
+
MockWebSocket.instances = [];
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("renders idle badge and updates it from websocket state events", async () => {
|
|
49
|
+
vi.stubGlobal("WebSocket", MockWebSocket as unknown as typeof WebSocket);
|
|
50
|
+
|
|
51
|
+
render(<Terminal terminalId="tentacle-a" />);
|
|
52
|
+
|
|
53
|
+
expect(screen.getByText("IDLE")).toBeInTheDocument();
|
|
54
|
+
|
|
55
|
+
await waitFor(() => {
|
|
56
|
+
expect(MockWebSocket.instances.length).toBe(1);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const socket = MockWebSocket.instances[0];
|
|
60
|
+
if (!socket) {
|
|
61
|
+
throw new Error("Expected websocket instance");
|
|
62
|
+
}
|
|
63
|
+
socket.emit("message", JSON.stringify({ type: "state", state: "processing" }));
|
|
64
|
+
|
|
65
|
+
await waitFor(() => {
|
|
66
|
+
const badge = screen.getByText("PROCESSING").closest(".status-badge");
|
|
67
|
+
expect(badge).not.toBeNull();
|
|
68
|
+
expect(badge).toHaveClass("pill", "processing");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
socket.emit("message", JSON.stringify({ type: "state", state: "idle" }));
|
|
72
|
+
|
|
73
|
+
await waitFor(() => {
|
|
74
|
+
const badge = screen.getByText("IDLE").closest(".status-badge");
|
|
75
|
+
expect(badge).not.toBeNull();
|
|
76
|
+
expect(badge).toHaveClass("pill", "idle");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("renders terminal with the provided terminal label", async () => {
|
|
81
|
+
vi.stubGlobal("WebSocket", MockWebSocket as unknown as typeof WebSocket);
|
|
82
|
+
|
|
83
|
+
render(<Terminal terminalId="tentacle-a-agent-1" terminalLabel="tentacle-a-agent-1" />);
|
|
84
|
+
|
|
85
|
+
expect(screen.getByText("tentacle-a-agent-1")).toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { AddTentacleForm } from "../src/components/deck/AddTentacleForm";
|
|
5
|
+
|
|
6
|
+
describe("AddTentacleForm", () => {
|
|
7
|
+
it("submits selected suggested skills", () => {
|
|
8
|
+
const onSubmit = vi.fn();
|
|
9
|
+
|
|
10
|
+
render(
|
|
11
|
+
<AddTentacleForm
|
|
12
|
+
onSubmit={onSubmit}
|
|
13
|
+
onCancel={() => {}}
|
|
14
|
+
isSubmitting={false}
|
|
15
|
+
error={null}
|
|
16
|
+
availableSkills={[
|
|
17
|
+
{
|
|
18
|
+
name: "docs-writer",
|
|
19
|
+
description: "Keeps docs aligned with the product.",
|
|
20
|
+
source: "project",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "release-helper",
|
|
24
|
+
description: "Helps with release coordination.",
|
|
25
|
+
source: "user",
|
|
26
|
+
},
|
|
27
|
+
]}
|
|
28
|
+
/>,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
fireEvent.change(screen.getByLabelText("Name"), { target: { value: "docs" } });
|
|
32
|
+
fireEvent.click(screen.getByLabelText(/docs-writer/i));
|
|
33
|
+
fireEvent.click(screen.getByRole("button", { name: /create tentacle/i }));
|
|
34
|
+
|
|
35
|
+
expect(onSubmit).toHaveBeenCalledWith(
|
|
36
|
+
"docs",
|
|
37
|
+
"",
|
|
38
|
+
expect.any(String),
|
|
39
|
+
expect.objectContaining({
|
|
40
|
+
animation: expect.any(String),
|
|
41
|
+
expression: expect.any(String),
|
|
42
|
+
accessory: expect.any(String),
|
|
43
|
+
hairColor: expect.any(String),
|
|
44
|
+
}),
|
|
45
|
+
["docs-writer"],
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
});
|