@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,334 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import type { DeckAvailableSkill, DeckTentacleSummary } from "@octogent/core";
|
|
4
|
+
import { OctopusGlyph } from "../EmptyOctopus";
|
|
5
|
+
import type { OctopusVisuals } from "./octopusVisuals";
|
|
6
|
+
|
|
7
|
+
// ─── Status styling ──────────────────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
export const STATUS_LABELS: Record<DeckTentacleSummary["status"], string> = {
|
|
10
|
+
idle: "idle",
|
|
11
|
+
active: "active",
|
|
12
|
+
blocked: "blocked",
|
|
13
|
+
"needs-review": "review",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// ─── TodoList ────────────────────────────────────────────────────────────────
|
|
17
|
+
|
|
18
|
+
export const TodoList = ({
|
|
19
|
+
items,
|
|
20
|
+
tentacleId,
|
|
21
|
+
onToggle,
|
|
22
|
+
}: {
|
|
23
|
+
items: { text: string; done: boolean }[];
|
|
24
|
+
tentacleId: string;
|
|
25
|
+
onToggle?: ((tentacleId: string, itemIndex: number, done: boolean) => void) | undefined;
|
|
26
|
+
}) => {
|
|
27
|
+
let lastDoneIndex = -1;
|
|
28
|
+
for (let idx = items.length - 1; idx >= 0; idx--) {
|
|
29
|
+
if (items[idx]?.done) {
|
|
30
|
+
lastDoneIndex = idx;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const scrollRef = useRef<HTMLLIElement | null>(null);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
scrollRef.current?.scrollIntoView({ block: "start" });
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<ul className="deck-pod-todos">
|
|
42
|
+
{items.map((item, i) => (
|
|
43
|
+
<li
|
|
44
|
+
key={item.text}
|
|
45
|
+
ref={i === lastDoneIndex ? scrollRef : undefined}
|
|
46
|
+
className={`deck-pod-todo-item${item.done ? " deck-pod-todo-item--done" : ""}`}
|
|
47
|
+
>
|
|
48
|
+
<input
|
|
49
|
+
type="checkbox"
|
|
50
|
+
checked={item.done}
|
|
51
|
+
className="deck-pod-todo-checkbox"
|
|
52
|
+
onChange={() => onToggle?.(tentacleId, i, !item.done)}
|
|
53
|
+
/>
|
|
54
|
+
<span className="deck-pod-todo-text">{item.text}</span>
|
|
55
|
+
</li>
|
|
56
|
+
))}
|
|
57
|
+
</ul>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// ─── TentaclePod ─────────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
export type TentaclePodProps = {
|
|
64
|
+
tentacle: DeckTentacleSummary;
|
|
65
|
+
visuals: OctopusVisuals;
|
|
66
|
+
isFocused: boolean;
|
|
67
|
+
activeFileName?: string | undefined;
|
|
68
|
+
onVaultFileClick?: (fileName: string) => void;
|
|
69
|
+
onVaultBrowse?: () => void;
|
|
70
|
+
onClose?: () => void;
|
|
71
|
+
onDelete?: () => void;
|
|
72
|
+
isDeleting?: boolean | undefined;
|
|
73
|
+
onTodoToggle?: (tentacleId: string, itemIndex: number, done: boolean) => void;
|
|
74
|
+
availableSkills: DeckAvailableSkill[];
|
|
75
|
+
isSavingSkills?: boolean | undefined;
|
|
76
|
+
onSaveSuggestedSkills?:
|
|
77
|
+
| ((tentacleId: string, suggestedSkills: string[]) => Promise<boolean>)
|
|
78
|
+
| undefined;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const TentaclePod = ({
|
|
82
|
+
tentacle,
|
|
83
|
+
visuals,
|
|
84
|
+
isFocused,
|
|
85
|
+
activeFileName,
|
|
86
|
+
onVaultFileClick,
|
|
87
|
+
onVaultBrowse,
|
|
88
|
+
onClose,
|
|
89
|
+
onDelete,
|
|
90
|
+
isDeleting,
|
|
91
|
+
onTodoToggle,
|
|
92
|
+
availableSkills,
|
|
93
|
+
isSavingSkills,
|
|
94
|
+
onSaveSuggestedSkills,
|
|
95
|
+
}: TentaclePodProps) => {
|
|
96
|
+
const progressPct =
|
|
97
|
+
tentacle.todoTotal > 0 ? Math.round((tentacle.todoDone / tentacle.todoTotal) * 100) : 0;
|
|
98
|
+
const [confirmingDelete, setConfirmingDelete] = useState(false);
|
|
99
|
+
const [isEditingSkills, setIsEditingSkills] = useState(false);
|
|
100
|
+
const [draftSkills, setDraftSkills] = useState<string[]>(tentacle.suggestedSkills);
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
setDraftSkills(tentacle.suggestedSkills);
|
|
104
|
+
}, [tentacle.suggestedSkills]);
|
|
105
|
+
|
|
106
|
+
const availableSkillNames = availableSkills.map((skill) => skill.name);
|
|
107
|
+
const skillNames = [...new Set([...availableSkillNames, ...draftSkills])].sort((a, b) =>
|
|
108
|
+
a.localeCompare(b),
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const toggleSkill = (skillName: string) => {
|
|
112
|
+
setDraftSkills((current) =>
|
|
113
|
+
current.includes(skillName)
|
|
114
|
+
? current.filter((skill) => skill !== skillName)
|
|
115
|
+
: [...current, skillName].sort((a, b) => a.localeCompare(b)),
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const handleSaveSkills = async () => {
|
|
120
|
+
const saved = await onSaveSuggestedSkills?.(tentacle.tentacleId, draftSkills);
|
|
121
|
+
if (saved) {
|
|
122
|
+
setIsEditingSkills(false);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<article
|
|
128
|
+
className={`deck-pod${isFocused ? " deck-pod--focused" : ""}`}
|
|
129
|
+
data-status={tentacle.status}
|
|
130
|
+
style={{ borderColor: "var(--accent-primary)" }}
|
|
131
|
+
>
|
|
132
|
+
<header className="deck-pod-header">
|
|
133
|
+
{isFocused && (
|
|
134
|
+
<button type="button" className="deck-pod-btn deck-pod-btn--secondary" onClick={onClose}>
|
|
135
|
+
← Back
|
|
136
|
+
</button>
|
|
137
|
+
)}
|
|
138
|
+
<button type="button" className="deck-pod-btn">
|
|
139
|
+
Spawn
|
|
140
|
+
</button>
|
|
141
|
+
<button
|
|
142
|
+
type="button"
|
|
143
|
+
className="deck-pod-btn"
|
|
144
|
+
onClick={() => {
|
|
145
|
+
setDraftSkills(tentacle.suggestedSkills);
|
|
146
|
+
setIsEditingSkills((current) => !current);
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
Skills
|
|
150
|
+
</button>
|
|
151
|
+
<button type="button" className="deck-pod-btn" onClick={() => onVaultBrowse?.()}>
|
|
152
|
+
Vault
|
|
153
|
+
</button>
|
|
154
|
+
{confirmingDelete ? (
|
|
155
|
+
<>
|
|
156
|
+
<button
|
|
157
|
+
type="button"
|
|
158
|
+
className="deck-pod-btn deck-pod-btn--danger"
|
|
159
|
+
disabled={isDeleting}
|
|
160
|
+
onClick={() => onDelete?.()}
|
|
161
|
+
>
|
|
162
|
+
{isDeleting ? "..." : "Confirm Delete"}
|
|
163
|
+
</button>
|
|
164
|
+
<button
|
|
165
|
+
type="button"
|
|
166
|
+
className="deck-pod-btn deck-pod-btn--secondary"
|
|
167
|
+
onClick={() => setConfirmingDelete(false)}
|
|
168
|
+
>
|
|
169
|
+
Cancel
|
|
170
|
+
</button>
|
|
171
|
+
</>
|
|
172
|
+
) : (
|
|
173
|
+
<button
|
|
174
|
+
type="button"
|
|
175
|
+
className="deck-pod-btn deck-pod-btn--delete"
|
|
176
|
+
onClick={() => setConfirmingDelete(true)}
|
|
177
|
+
aria-label="Delete tentacle"
|
|
178
|
+
>
|
|
179
|
+
<svg className="deck-pod-btn-icon" viewBox="0 0 16 16" aria-hidden="true">
|
|
180
|
+
<path
|
|
181
|
+
d="M5.5 1.5h5M2 4h12M6 7v5M10 7v5M3.5 4l.75 9.5a1 1 0 001 .9h5.5a1 1 0 001-.9L12.5 4"
|
|
182
|
+
fill="none"
|
|
183
|
+
stroke="currentColor"
|
|
184
|
+
strokeWidth="1.3"
|
|
185
|
+
strokeLinecap="round"
|
|
186
|
+
strokeLinejoin="round"
|
|
187
|
+
/>
|
|
188
|
+
</svg>
|
|
189
|
+
</button>
|
|
190
|
+
)}
|
|
191
|
+
</header>
|
|
192
|
+
|
|
193
|
+
<div className="deck-pod-body">
|
|
194
|
+
<span className={`deck-pod-status deck-pod-status--${tentacle.status}`}>
|
|
195
|
+
{STATUS_LABELS[tentacle.status]}
|
|
196
|
+
</span>
|
|
197
|
+
<div className="deck-pod-identity">
|
|
198
|
+
<div className="deck-pod-octopus-col">
|
|
199
|
+
<div className="deck-pod-octopus">
|
|
200
|
+
<OctopusGlyph
|
|
201
|
+
color={visuals.color}
|
|
202
|
+
animation={visuals.animation}
|
|
203
|
+
expression={visuals.expression}
|
|
204
|
+
accessory={visuals.accessory}
|
|
205
|
+
{...(visuals.hairColor ? { hairColor: visuals.hairColor } : {})}
|
|
206
|
+
scale={5}
|
|
207
|
+
/>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
<div className="deck-pod-identity-text">
|
|
211
|
+
<span className="deck-pod-name">{tentacle.displayName}</span>
|
|
212
|
+
<span className="deck-pod-description">{tentacle.description}</span>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
<div className="deck-pod-details">
|
|
217
|
+
{isEditingSkills && (
|
|
218
|
+
<div className="deck-pod-skills-editor">
|
|
219
|
+
{skillNames.length === 0 ? (
|
|
220
|
+
<span className="deck-pod-skills-empty">No Cortex skills found.</span>
|
|
221
|
+
) : (
|
|
222
|
+
<div className="deck-pod-skills-options">
|
|
223
|
+
{skillNames.map((skillName) => {
|
|
224
|
+
const skill = availableSkills.find((entry) => entry.name === skillName);
|
|
225
|
+
return (
|
|
226
|
+
<label key={skillName} className="deck-pod-skill-option">
|
|
227
|
+
<input
|
|
228
|
+
type="checkbox"
|
|
229
|
+
checked={draftSkills.includes(skillName)}
|
|
230
|
+
onChange={() => toggleSkill(skillName)}
|
|
231
|
+
/>
|
|
232
|
+
<span className="deck-pod-skill-copy">
|
|
233
|
+
<span className="deck-pod-skill-name">{skillName}</span>
|
|
234
|
+
{skill?.description && (
|
|
235
|
+
<span className="deck-pod-skill-desc">{skill.description}</span>
|
|
236
|
+
)}
|
|
237
|
+
{!skill && (
|
|
238
|
+
<span className="deck-pod-skill-desc">
|
|
239
|
+
Stored on this tentacle, but not available right now.
|
|
240
|
+
</span>
|
|
241
|
+
)}
|
|
242
|
+
</span>
|
|
243
|
+
</label>
|
|
244
|
+
);
|
|
245
|
+
})}
|
|
246
|
+
</div>
|
|
247
|
+
)}
|
|
248
|
+
<div className="deck-pod-skills-actions">
|
|
249
|
+
<button
|
|
250
|
+
type="button"
|
|
251
|
+
className="deck-pod-btn deck-pod-btn--secondary"
|
|
252
|
+
onClick={() => {
|
|
253
|
+
setDraftSkills(tentacle.suggestedSkills);
|
|
254
|
+
setIsEditingSkills(false);
|
|
255
|
+
}}
|
|
256
|
+
>
|
|
257
|
+
Cancel
|
|
258
|
+
</button>
|
|
259
|
+
<button
|
|
260
|
+
type="button"
|
|
261
|
+
className="deck-pod-btn"
|
|
262
|
+
disabled={Boolean(isSavingSkills)}
|
|
263
|
+
onClick={() => void handleSaveSkills()}
|
|
264
|
+
>
|
|
265
|
+
{isSavingSkills ? "Saving..." : "Save Skills"}
|
|
266
|
+
</button>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
)}
|
|
270
|
+
|
|
271
|
+
{tentacle.todoTotal > 0 && (
|
|
272
|
+
<div className="deck-pod-progress">
|
|
273
|
+
<div className="deck-pod-progress-bar">
|
|
274
|
+
<div
|
|
275
|
+
className="deck-pod-progress-fill"
|
|
276
|
+
style={{ width: `${progressPct}%`, backgroundColor: visuals.color }}
|
|
277
|
+
/>
|
|
278
|
+
</div>
|
|
279
|
+
<span
|
|
280
|
+
className="deck-pod-progress-label"
|
|
281
|
+
style={{ backgroundColor: `${visuals.color}22`, color: visuals.color }}
|
|
282
|
+
>
|
|
283
|
+
{tentacle.todoDone}/{tentacle.todoTotal} done
|
|
284
|
+
</span>
|
|
285
|
+
</div>
|
|
286
|
+
)}
|
|
287
|
+
|
|
288
|
+
{tentacle.todoItems.length > 0 && (
|
|
289
|
+
<TodoList
|
|
290
|
+
items={tentacle.todoItems}
|
|
291
|
+
tentacleId={tentacle.tentacleId}
|
|
292
|
+
onToggle={onTodoToggle}
|
|
293
|
+
/>
|
|
294
|
+
)}
|
|
295
|
+
|
|
296
|
+
{tentacle.suggestedSkills.length > 0 && (
|
|
297
|
+
<div className="deck-pod-vault">
|
|
298
|
+
<span className="deck-pod-vault-label">skills</span>
|
|
299
|
+
<div className="deck-pod-vault-files">
|
|
300
|
+
{tentacle.suggestedSkills.map((skill) => (
|
|
301
|
+
<span key={skill} className="deck-pod-vault-file">
|
|
302
|
+
{skill}
|
|
303
|
+
</span>
|
|
304
|
+
))}
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
)}
|
|
308
|
+
|
|
309
|
+
{tentacle.vaultFiles.length > 0 && (
|
|
310
|
+
<div className="deck-pod-vault">
|
|
311
|
+
<span className="deck-pod-vault-label">vault</span>
|
|
312
|
+
<div className="deck-pod-vault-files">
|
|
313
|
+
{tentacle.vaultFiles.map((file) => (
|
|
314
|
+
<button
|
|
315
|
+
key={file}
|
|
316
|
+
type="button"
|
|
317
|
+
className="deck-pod-vault-file"
|
|
318
|
+
aria-current={activeFileName === file ? "true" : undefined}
|
|
319
|
+
onClick={(e) => {
|
|
320
|
+
e.stopPropagation();
|
|
321
|
+
onVaultFileClick?.(file);
|
|
322
|
+
}}
|
|
323
|
+
>
|
|
324
|
+
{file}
|
|
325
|
+
</button>
|
|
326
|
+
))}
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
)}
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
</article>
|
|
333
|
+
);
|
|
334
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { WorkspaceSetupSnapshot, WorkspaceSetupStepId } from "@octogent/core";
|
|
2
|
+
import { OctopusGlyph } from "../EmptyOctopus";
|
|
3
|
+
|
|
4
|
+
type WorkspaceSetupCardProps = {
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
workspaceSetup: WorkspaceSetupSnapshot | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
error: string | null;
|
|
9
|
+
onRunStep: (stepId: WorkspaceSetupStepId) => void;
|
|
10
|
+
onLaunchClaudeCode: () => void;
|
|
11
|
+
isLaunchingAgent?: boolean;
|
|
12
|
+
isRunningStepId?: WorkspaceSetupStepId | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const buildStepSummary = (stepId: WorkspaceSetupStepId, description: string) => {
|
|
16
|
+
if (stepId === "create-tentacles") {
|
|
17
|
+
return "Launch Cortex so it can plan and create the first tentacles.";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return description;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const WorkspaceSetupCard = ({
|
|
24
|
+
compact,
|
|
25
|
+
workspaceSetup,
|
|
26
|
+
isLoading,
|
|
27
|
+
error,
|
|
28
|
+
onRunStep,
|
|
29
|
+
onLaunchClaudeCode,
|
|
30
|
+
isLaunchingAgent,
|
|
31
|
+
isRunningStepId,
|
|
32
|
+
}: WorkspaceSetupCardProps) => (
|
|
33
|
+
<section
|
|
34
|
+
className={`workspace-setup-card${compact ? " workspace-setup-card--compact" : ""}`}
|
|
35
|
+
aria-label="Workspace setup"
|
|
36
|
+
>
|
|
37
|
+
<header className="workspace-setup-card-header">
|
|
38
|
+
<div className="workspace-setup-card-glyph">
|
|
39
|
+
<OctopusGlyph
|
|
40
|
+
color="#d4a017"
|
|
41
|
+
animation={compact ? "idle" : "walk"}
|
|
42
|
+
expression="happy"
|
|
43
|
+
accessory="none"
|
|
44
|
+
scale={compact ? 4 : 7}
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
<div className="workspace-setup-card-copy">
|
|
48
|
+
<h2 className="workspace-setup-card-title">Workspace Setup</h2>
|
|
49
|
+
<p className="workspace-setup-card-desc">
|
|
50
|
+
Run each step explicitly. Cortex only marks it done after the workspace is checked
|
|
51
|
+
again.
|
|
52
|
+
</p>
|
|
53
|
+
</div>
|
|
54
|
+
</header>
|
|
55
|
+
|
|
56
|
+
{error ? <p className="workspace-setup-card-error">{error}</p> : null}
|
|
57
|
+
|
|
58
|
+
<div className="workspace-setup-step-list">
|
|
59
|
+
{(workspaceSetup?.steps ?? []).map((step) => {
|
|
60
|
+
const isCreateTentaclesStep = step.id === "create-tentacles";
|
|
61
|
+
const buttonLabel = isCreateTentaclesStep ? "Launch Cortex" : step.actionLabel;
|
|
62
|
+
const isButtonDisabled = isCreateTentaclesStep ? isLaunchingAgent : isLoading;
|
|
63
|
+
const isButtonRunning = isCreateTentaclesStep
|
|
64
|
+
? isLaunchingAgent
|
|
65
|
+
: isRunningStepId === step.id;
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<article key={step.id} className="workspace-setup-step" data-complete={step.complete}>
|
|
69
|
+
<div className="workspace-setup-step-main">
|
|
70
|
+
<div className="workspace-setup-step-title-row">
|
|
71
|
+
<span className="workspace-setup-step-title">{step.title}</span>
|
|
72
|
+
<span className="workspace-setup-step-state">
|
|
73
|
+
{step.complete ? "Done" : step.required ? "Required" : "Optional"}
|
|
74
|
+
</span>
|
|
75
|
+
</div>
|
|
76
|
+
<p className="workspace-setup-step-desc">
|
|
77
|
+
{buildStepSummary(step.id, step.description)}
|
|
78
|
+
</p>
|
|
79
|
+
</div>
|
|
80
|
+
{buttonLabel ? (
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
className="workspace-setup-step-action"
|
|
84
|
+
disabled={Boolean(isButtonDisabled)}
|
|
85
|
+
onClick={() => {
|
|
86
|
+
if (isCreateTentaclesStep) {
|
|
87
|
+
onLaunchClaudeCode();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
onRunStep(step.id);
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
{isButtonRunning ? "..." : buttonLabel}
|
|
95
|
+
</button>
|
|
96
|
+
) : null}
|
|
97
|
+
</article>
|
|
98
|
+
);
|
|
99
|
+
})}
|
|
100
|
+
{isLoading && workspaceSetup === null ? (
|
|
101
|
+
<p className="workspace-setup-card-loading">Loading workspace setup…</p>
|
|
102
|
+
) : null}
|
|
103
|
+
</div>
|
|
104
|
+
</section>
|
|
105
|
+
);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { DeckTentacleSummary } from "@octogent/core";
|
|
2
|
+
import type { OctopusAccessory, OctopusAnimation, OctopusExpression } from "../EmptyOctopus";
|
|
3
|
+
|
|
4
|
+
// ─── Octopus visual derivation (seeded from tentacle id) ────────────────────
|
|
5
|
+
|
|
6
|
+
export const OCTOPUS_COLORS = [
|
|
7
|
+
"#ff6b2b",
|
|
8
|
+
"#ff2d6b",
|
|
9
|
+
"#00ffaa",
|
|
10
|
+
"#bf5fff",
|
|
11
|
+
"#00c8ff",
|
|
12
|
+
"#ffee00",
|
|
13
|
+
"#39ff14",
|
|
14
|
+
"#ff4df0",
|
|
15
|
+
"#00fff7",
|
|
16
|
+
"#ff9500",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export const ANIMATIONS: OctopusAnimation[] = ["sway", "walk", "jog", "bounce", "float", "swim-up"];
|
|
20
|
+
export const EXPRESSIONS: OctopusExpression[] = ["normal", "happy", "angry", "surprised"];
|
|
21
|
+
export const ACCESSORIES: OctopusAccessory[] = [
|
|
22
|
+
"none",
|
|
23
|
+
"none",
|
|
24
|
+
"long",
|
|
25
|
+
"mohawk",
|
|
26
|
+
"side-sweep",
|
|
27
|
+
"curly",
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export function hashString(str: string): number {
|
|
31
|
+
let h = 0;
|
|
32
|
+
for (let i = 0; i < str.length; i++) {
|
|
33
|
+
h = ((h << 5) - h + str.charCodeAt(i)) | 0;
|
|
34
|
+
}
|
|
35
|
+
return Math.abs(h);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function seededRandom(seed: number): () => number {
|
|
39
|
+
let s = seed;
|
|
40
|
+
return () => {
|
|
41
|
+
s = (s * 16807 + 0) % 2147483647;
|
|
42
|
+
return (s - 1) / 2147483646;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type OctopusVisuals = {
|
|
47
|
+
color: string;
|
|
48
|
+
animation: OctopusAnimation;
|
|
49
|
+
expression: OctopusExpression;
|
|
50
|
+
accessory: OctopusAccessory;
|
|
51
|
+
hairColor?: string | undefined;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export function deriveOctopusVisuals(tentacle: DeckTentacleSummary): OctopusVisuals {
|
|
55
|
+
const rng = seededRandom(hashString(tentacle.tentacleId));
|
|
56
|
+
const stored = tentacle.octopus;
|
|
57
|
+
return {
|
|
58
|
+
color:
|
|
59
|
+
tentacle.color ??
|
|
60
|
+
(OCTOPUS_COLORS[hashString(tentacle.tentacleId) % OCTOPUS_COLORS.length] as string),
|
|
61
|
+
animation:
|
|
62
|
+
(stored?.animation as OctopusAnimation | null) ??
|
|
63
|
+
(ANIMATIONS[Math.floor(rng() * ANIMATIONS.length)] as OctopusAnimation),
|
|
64
|
+
expression:
|
|
65
|
+
(stored?.expression as OctopusExpression | null) ??
|
|
66
|
+
(EXPRESSIONS[Math.floor(rng() * EXPRESSIONS.length)] as OctopusExpression),
|
|
67
|
+
accessory:
|
|
68
|
+
(stored?.accessory as OctopusAccessory | null) ??
|
|
69
|
+
(ACCESSORIES[Math.floor(rng() * ACCESSORIES.length)] as OctopusAccessory),
|
|
70
|
+
hairColor: stored?.hairColor ?? undefined,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
type ReplayViewport = Pick<HTMLElement, "clientHeight" | "scrollHeight" | "scrollTop">;
|
|
2
|
+
|
|
3
|
+
type ReplayTerminal = {
|
|
4
|
+
reset: () => void;
|
|
5
|
+
write: (value: string, callback?: () => void) => void;
|
|
6
|
+
clearSelection?: () => void;
|
|
7
|
+
refresh?: (start: number, end: number) => void;
|
|
8
|
+
rows?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const NEAR_BOTTOM_THRESHOLD_PX = 8;
|
|
12
|
+
|
|
13
|
+
const restoreViewportScroll = (
|
|
14
|
+
viewport: ReplayViewport,
|
|
15
|
+
previousScrollTop: number,
|
|
16
|
+
wasNearBottom: boolean,
|
|
17
|
+
) => {
|
|
18
|
+
if (wasNearBottom) {
|
|
19
|
+
viewport.scrollTop = viewport.scrollHeight;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
viewport.scrollTop = Math.max(
|
|
24
|
+
0,
|
|
25
|
+
Math.min(previousScrollTop, viewport.scrollHeight - viewport.clientHeight),
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const replayTerminalHistory = (
|
|
30
|
+
terminal: ReplayTerminal,
|
|
31
|
+
history: string,
|
|
32
|
+
viewport: ReplayViewport | null,
|
|
33
|
+
) => {
|
|
34
|
+
const previousScrollTop = viewport?.scrollTop ?? 0;
|
|
35
|
+
const wasNearBottom =
|
|
36
|
+
viewport !== null
|
|
37
|
+
? viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop <=
|
|
38
|
+
NEAR_BOTTOM_THRESHOLD_PX
|
|
39
|
+
: false;
|
|
40
|
+
|
|
41
|
+
terminal.clearSelection?.();
|
|
42
|
+
terminal.reset();
|
|
43
|
+
terminal.write(history, () => {
|
|
44
|
+
terminal.clearSelection?.();
|
|
45
|
+
|
|
46
|
+
if (
|
|
47
|
+
typeof terminal.refresh === "function" &&
|
|
48
|
+
typeof terminal.rows === "number" &&
|
|
49
|
+
terminal.rows > 0
|
|
50
|
+
) {
|
|
51
|
+
terminal.refresh(0, terminal.rows - 1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!viewport) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
window.requestAnimationFrame(() => {
|
|
59
|
+
restoreViewportScroll(viewport, previousScrollTop, wasNearBottom);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const PIXELS_PER_LINE = 36;
|
|
2
|
+
const PIXELS_PER_DOM_LINE = 16;
|
|
3
|
+
const PIXELS_PER_DOM_PAGE = 160;
|
|
4
|
+
|
|
5
|
+
type TerminalActiveBufferLike = {
|
|
6
|
+
baseY?: number;
|
|
7
|
+
type?: string;
|
|
8
|
+
viewportY?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const wheelDeltaToScrollLines = (deltaY: number, deltaMode: number): number => {
|
|
12
|
+
if (!Number.isFinite(deltaY) || deltaY === 0) {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const absoluteDelta = Math.abs(deltaY);
|
|
17
|
+
let pixelDelta = absoluteDelta;
|
|
18
|
+
if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
|
19
|
+
pixelDelta = absoluteDelta * PIXELS_PER_DOM_LINE;
|
|
20
|
+
} else if (deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
|
21
|
+
pixelDelta = absoluteDelta * PIXELS_PER_DOM_PAGE;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const lines = Math.max(1, Math.round(pixelDelta / PIXELS_PER_LINE));
|
|
25
|
+
return deltaY > 0 ? lines : -lines;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const shouldUseManualWheelScroll = (
|
|
29
|
+
activeBuffer: TerminalActiveBufferLike | null | undefined,
|
|
30
|
+
): boolean => {
|
|
31
|
+
if (!activeBuffer) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (activeBuffer.type === "alternate") {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (activeBuffer.baseY ?? 0) > 0;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const readViewportY = (
|
|
43
|
+
activeBuffer: TerminalActiveBufferLike | null | undefined,
|
|
44
|
+
): number | null => {
|
|
45
|
+
if (
|
|
46
|
+
!activeBuffer ||
|
|
47
|
+
typeof activeBuffer.viewportY !== "number" ||
|
|
48
|
+
!Number.isFinite(activeBuffer.viewportY)
|
|
49
|
+
) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return activeBuffer.viewportY;
|
|
54
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
type ActionButtonVariant = "primary" | "accent" | "info" | "danger";
|
|
4
|
+
type ActionButtonSize = "compact" | "dense";
|
|
5
|
+
|
|
6
|
+
type ActionButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> & {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
variant?: ActionButtonVariant;
|
|
9
|
+
size?: ActionButtonSize;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const ActionButton = ({
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
variant = "accent",
|
|
16
|
+
size = "dense",
|
|
17
|
+
type = "button",
|
|
18
|
+
...buttonProps
|
|
19
|
+
}: ActionButtonProps) => {
|
|
20
|
+
const classes = [
|
|
21
|
+
"action-button",
|
|
22
|
+
`action-button--${variant}`,
|
|
23
|
+
`action-button--${size}`,
|
|
24
|
+
className,
|
|
25
|
+
]
|
|
26
|
+
.filter((value) => Boolean(value))
|
|
27
|
+
.join(" ");
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<button className={classes} type={type} {...buttonProps}>
|
|
31
|
+
{children}
|
|
32
|
+
</button>
|
|
33
|
+
);
|
|
34
|
+
};
|