@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,319 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Simulation,
|
|
3
|
+
type SimulationLinkDatum,
|
|
4
|
+
type SimulationNodeDatum,
|
|
5
|
+
forceCollide,
|
|
6
|
+
forceLink,
|
|
7
|
+
forceManyBody,
|
|
8
|
+
forceSimulation,
|
|
9
|
+
forceX,
|
|
10
|
+
forceY,
|
|
11
|
+
} from "d3-force";
|
|
12
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
13
|
+
|
|
14
|
+
import type { GraphEdge, GraphNode } from "../canvas/types";
|
|
15
|
+
|
|
16
|
+
type ForceParams = {
|
|
17
|
+
repelStrength: number;
|
|
18
|
+
repelDistanceMax: number;
|
|
19
|
+
linkDistance: number;
|
|
20
|
+
linkStrength: number;
|
|
21
|
+
positionStrength: number;
|
|
22
|
+
collisionPadding: number;
|
|
23
|
+
velocityDecay: number;
|
|
24
|
+
alphaDecay: number;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const DEFAULT_FORCE_PARAMS: ForceParams = {
|
|
28
|
+
repelStrength: -400,
|
|
29
|
+
repelDistanceMax: 600,
|
|
30
|
+
linkDistance: 100,
|
|
31
|
+
linkStrength: 0.25,
|
|
32
|
+
positionStrength: 0.04,
|
|
33
|
+
collisionPadding: 50,
|
|
34
|
+
velocityDecay: 0.4,
|
|
35
|
+
alphaDecay: 0.0228,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const ALPHA_MIN = 0.001;
|
|
39
|
+
const ALPHA_TARGET = 0;
|
|
40
|
+
const REHEAT_ALPHA = 0.8;
|
|
41
|
+
|
|
42
|
+
// Reference dimensions for initial viewport fit (no longer used for clamping)
|
|
43
|
+
export const WORLD_W = 1400;
|
|
44
|
+
export const WORLD_H = 800;
|
|
45
|
+
|
|
46
|
+
type SimNode = SimulationNodeDatum & { _gn: GraphNode };
|
|
47
|
+
type SimLink = SimulationLinkDatum<SimNode>;
|
|
48
|
+
|
|
49
|
+
type UseForceSimulationOptions = {
|
|
50
|
+
nodes: GraphNode[];
|
|
51
|
+
edges: GraphEdge[];
|
|
52
|
+
centerX: number;
|
|
53
|
+
centerY: number;
|
|
54
|
+
params?: ForceParams;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type UseForceSimulationResult = {
|
|
58
|
+
simulatedNodes: GraphNode[];
|
|
59
|
+
pinNode: (id: string) => void;
|
|
60
|
+
unpinNode: (id: string) => void;
|
|
61
|
+
moveNode: (id: string, x: number, y: number) => void;
|
|
62
|
+
reheat: () => void;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const useForceSimulation = ({
|
|
66
|
+
nodes,
|
|
67
|
+
edges,
|
|
68
|
+
centerX,
|
|
69
|
+
centerY,
|
|
70
|
+
params = DEFAULT_FORCE_PARAMS,
|
|
71
|
+
}: UseForceSimulationOptions): UseForceSimulationResult => {
|
|
72
|
+
const simRef = useRef<Simulation<SimNode, SimLink> | null>(null);
|
|
73
|
+
const simNodeMapRef = useRef<Map<string, SimNode>>(new Map());
|
|
74
|
+
const [snapshot, setSnapshot] = useState<GraphNode[]>(nodes);
|
|
75
|
+
|
|
76
|
+
// Keep latest inputs in refs so the effect can read them without depending on them
|
|
77
|
+
const nodesRef = useRef(nodes);
|
|
78
|
+
const edgesRef = useRef(edges);
|
|
79
|
+
const paramsRef = useRef(params);
|
|
80
|
+
nodesRef.current = nodes;
|
|
81
|
+
edgesRef.current = edges;
|
|
82
|
+
paramsRef.current = params;
|
|
83
|
+
|
|
84
|
+
// Stable topology keys — effect only fires when graph structure actually changes
|
|
85
|
+
const nodeIdKey = useMemo(() => nodes.map((n) => n.id).join("\0"), [nodes]);
|
|
86
|
+
const edgeKey = useMemo(() => edges.map((e) => `${e.source}\0${e.target}`).join("\0"), [edges]);
|
|
87
|
+
|
|
88
|
+
// Content key — captures mutable node properties that should update the snapshot
|
|
89
|
+
// even when topology (nodeIdKey/edgeKey) hasn't changed.
|
|
90
|
+
const contentKey = useMemo(
|
|
91
|
+
() =>
|
|
92
|
+
nodes
|
|
93
|
+
.map(
|
|
94
|
+
(n) =>
|
|
95
|
+
`${n.id}\t${n.hasUserPrompt ?? ""}\t${n.agentState ?? ""}\t${n.agentRuntimeState ?? ""}\t${n.waitingToolName ?? ""}\t${n.color}\t${n.label}`,
|
|
96
|
+
)
|
|
97
|
+
.join("\0"),
|
|
98
|
+
[nodes],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
void nodeIdKey;
|
|
103
|
+
void edgeKey;
|
|
104
|
+
|
|
105
|
+
const currentNodes = nodesRef.current;
|
|
106
|
+
const currentEdges = edgesRef.current;
|
|
107
|
+
const p = paramsRef.current;
|
|
108
|
+
|
|
109
|
+
if (currentNodes.length === 0) {
|
|
110
|
+
simRef.current?.stop();
|
|
111
|
+
simRef.current = null;
|
|
112
|
+
simNodeMapRef.current.clear();
|
|
113
|
+
setSnapshot([]);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const prevMap = simNodeMapRef.current;
|
|
118
|
+
|
|
119
|
+
const simNodes: SimNode[] = currentNodes.map((gn) => {
|
|
120
|
+
const prev = prevMap.get(gn.id);
|
|
121
|
+
if (prev) {
|
|
122
|
+
prev._gn = gn;
|
|
123
|
+
return prev;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
_gn: gn,
|
|
127
|
+
x: gn.x,
|
|
128
|
+
y: gn.y,
|
|
129
|
+
vx: gn.vx,
|
|
130
|
+
vy: gn.vy,
|
|
131
|
+
fx: gn.pinned ? gn.x : undefined,
|
|
132
|
+
fy: gn.pinned ? gn.y : undefined,
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const nextMap = new Map<string, SimNode>();
|
|
137
|
+
for (const sn of simNodes) {
|
|
138
|
+
nextMap.set(sn._gn.id, sn);
|
|
139
|
+
}
|
|
140
|
+
simNodeMapRef.current = nextMap;
|
|
141
|
+
|
|
142
|
+
const simLinks: SimLink[] = currentEdges
|
|
143
|
+
.map((e) => {
|
|
144
|
+
const source = nextMap.get(e.source);
|
|
145
|
+
const target = nextMap.get(e.target);
|
|
146
|
+
if (!source || !target) return null;
|
|
147
|
+
return { source, target } as SimLink;
|
|
148
|
+
})
|
|
149
|
+
.filter((l): l is SimLink => l !== null);
|
|
150
|
+
|
|
151
|
+
const applyForces = (sim: Simulation<SimNode, SimLink>) => {
|
|
152
|
+
sim
|
|
153
|
+
.force(
|
|
154
|
+
"link",
|
|
155
|
+
forceLink<SimNode, SimLink>(simLinks)
|
|
156
|
+
.distance((link: SimLink) => {
|
|
157
|
+
const target = link.target as SimNode;
|
|
158
|
+
return target._gn.type === "inactive-session"
|
|
159
|
+
? p.linkDistance * 0.35
|
|
160
|
+
: p.linkDistance;
|
|
161
|
+
})
|
|
162
|
+
.strength((link: SimLink) => {
|
|
163
|
+
const target = link.target as SimNode;
|
|
164
|
+
return target._gn.type === "inactive-session" ? p.linkStrength * 1.5 : p.linkStrength;
|
|
165
|
+
}),
|
|
166
|
+
)
|
|
167
|
+
.force(
|
|
168
|
+
"charge",
|
|
169
|
+
forceManyBody<SimNode>().strength(p.repelStrength).distanceMax(p.repelDistanceMax),
|
|
170
|
+
)
|
|
171
|
+
.force("x", forceX<SimNode>(centerX).strength(p.positionStrength))
|
|
172
|
+
.force("y", forceY<SimNode>(centerY).strength(p.positionStrength))
|
|
173
|
+
.force("collide", forceCollide<SimNode>(p.collisionPadding));
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
if (simRef.current) {
|
|
177
|
+
simRef.current.nodes(simNodes);
|
|
178
|
+
applyForces(simRef.current);
|
|
179
|
+
simRef.current.alpha(REHEAT_ALPHA).restart();
|
|
180
|
+
} else {
|
|
181
|
+
const sim = forceSimulation<SimNode>(simNodes)
|
|
182
|
+
.velocityDecay(p.velocityDecay)
|
|
183
|
+
.alphaDecay(p.alphaDecay)
|
|
184
|
+
.alphaMin(ALPHA_MIN)
|
|
185
|
+
.alphaTarget(ALPHA_TARGET);
|
|
186
|
+
|
|
187
|
+
applyForces(sim);
|
|
188
|
+
|
|
189
|
+
sim.on("tick", () => {
|
|
190
|
+
const updated: GraphNode[] = sim.nodes().map((sn) => ({
|
|
191
|
+
...sn._gn,
|
|
192
|
+
x: sn.x ?? sn._gn.x,
|
|
193
|
+
y: sn.y ?? sn._gn.y,
|
|
194
|
+
vx: sn.vx ?? 0,
|
|
195
|
+
vy: sn.vy ?? 0,
|
|
196
|
+
}));
|
|
197
|
+
setSnapshot(updated);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
simRef.current = sim;
|
|
201
|
+
}
|
|
202
|
+
}, [nodeIdKey, edgeKey, centerX, centerY]);
|
|
203
|
+
|
|
204
|
+
// Sync non-topology node property changes (e.g., hasUserPrompt, agentState,
|
|
205
|
+
// color, label) into the simulation's internal nodes and produce a fresh
|
|
206
|
+
// snapshot without reheating the simulation.
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
void contentKey;
|
|
209
|
+
|
|
210
|
+
const map = simNodeMapRef.current;
|
|
211
|
+
const currentNodes = nodesRef.current;
|
|
212
|
+
let changed = false;
|
|
213
|
+
|
|
214
|
+
for (const gn of currentNodes) {
|
|
215
|
+
const sn = map.get(gn.id);
|
|
216
|
+
if (sn && sn._gn !== gn) {
|
|
217
|
+
sn._gn = gn;
|
|
218
|
+
changed = true;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (changed && simRef.current) {
|
|
223
|
+
const updated: GraphNode[] = simRef.current.nodes().map((sn) => ({
|
|
224
|
+
...sn._gn,
|
|
225
|
+
x: sn.x ?? sn._gn.x,
|
|
226
|
+
y: sn.y ?? sn._gn.y,
|
|
227
|
+
vx: sn.vx ?? 0,
|
|
228
|
+
vy: sn.vy ?? 0,
|
|
229
|
+
}));
|
|
230
|
+
setSnapshot(updated);
|
|
231
|
+
}
|
|
232
|
+
}, [contentKey]);
|
|
233
|
+
|
|
234
|
+
// Apply param changes without rebuilding the simulation
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
const sim = simRef.current;
|
|
237
|
+
if (!sim) return;
|
|
238
|
+
|
|
239
|
+
sim.velocityDecay(params.velocityDecay).alphaDecay(params.alphaDecay);
|
|
240
|
+
|
|
241
|
+
const linkForce = sim.force("link") as ReturnType<typeof forceLink<SimNode, SimLink>> | null;
|
|
242
|
+
if (linkForce) {
|
|
243
|
+
linkForce
|
|
244
|
+
.distance((link: SimLink) => {
|
|
245
|
+
const target = link.target as SimNode;
|
|
246
|
+
return target._gn.type === "inactive-session"
|
|
247
|
+
? params.linkDistance * 0.35
|
|
248
|
+
: params.linkDistance;
|
|
249
|
+
})
|
|
250
|
+
.strength((link: SimLink) => {
|
|
251
|
+
const target = link.target as SimNode;
|
|
252
|
+
return target._gn.type === "inactive-session"
|
|
253
|
+
? params.linkStrength * 1.5
|
|
254
|
+
: params.linkStrength;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const chargeForce = sim.force("charge") as ReturnType<typeof forceManyBody<SimNode>> | null;
|
|
259
|
+
if (chargeForce) {
|
|
260
|
+
chargeForce.strength(params.repelStrength).distanceMax(params.repelDistanceMax);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const xForce = sim.force("x") as ReturnType<typeof forceX<SimNode>> | null;
|
|
264
|
+
if (xForce) xForce.strength(params.positionStrength);
|
|
265
|
+
|
|
266
|
+
const yForce = sim.force("y") as ReturnType<typeof forceY<SimNode>> | null;
|
|
267
|
+
if (yForce) yForce.strength(params.positionStrength);
|
|
268
|
+
|
|
269
|
+
const collideForce = sim.force("collide") as ReturnType<typeof forceCollide<SimNode>> | null;
|
|
270
|
+
if (collideForce) {
|
|
271
|
+
collideForce.radius(params.collisionPadding);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
sim.alpha(REHEAT_ALPHA).restart();
|
|
275
|
+
}, [params]);
|
|
276
|
+
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
return () => {
|
|
279
|
+
simRef.current?.stop();
|
|
280
|
+
simRef.current = null;
|
|
281
|
+
};
|
|
282
|
+
}, []);
|
|
283
|
+
|
|
284
|
+
const pinNode = useCallback((id: string) => {
|
|
285
|
+
const sn = simNodeMapRef.current.get(id);
|
|
286
|
+
if (sn) {
|
|
287
|
+
sn.fx = sn.x;
|
|
288
|
+
sn.fy = sn.y;
|
|
289
|
+
sn._gn = { ...sn._gn, pinned: true };
|
|
290
|
+
}
|
|
291
|
+
}, []);
|
|
292
|
+
|
|
293
|
+
const unpinNode = useCallback((id: string) => {
|
|
294
|
+
const sn = simNodeMapRef.current.get(id);
|
|
295
|
+
if (sn) {
|
|
296
|
+
sn.fx = undefined;
|
|
297
|
+
sn.fy = undefined;
|
|
298
|
+
sn._gn = { ...sn._gn, pinned: false };
|
|
299
|
+
}
|
|
300
|
+
}, []);
|
|
301
|
+
|
|
302
|
+
const moveNode = useCallback((id: string, x: number, y: number) => {
|
|
303
|
+
const sn = simNodeMapRef.current.get(id);
|
|
304
|
+
if (sn) {
|
|
305
|
+
sn.fx = x;
|
|
306
|
+
sn.fy = y;
|
|
307
|
+
sn.x = x;
|
|
308
|
+
sn.y = y;
|
|
309
|
+
sn.vx = 0;
|
|
310
|
+
sn.vy = 0;
|
|
311
|
+
}
|
|
312
|
+
}, []);
|
|
313
|
+
|
|
314
|
+
const reheat = useCallback(() => {
|
|
315
|
+
simRef.current?.alpha(REHEAT_ALPHA).restart();
|
|
316
|
+
}, []);
|
|
317
|
+
|
|
318
|
+
return { simulatedNodes: snapshot, pinNode, unpinNode, moveNode, reheat };
|
|
319
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
|
2
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GITHUB_OVERVIEW_GRAPH_HEIGHT,
|
|
6
|
+
GITHUB_OVERVIEW_GRAPH_WIDTH,
|
|
7
|
+
GITHUB_SPARKLINE_HEIGHT,
|
|
8
|
+
GITHUB_SPARKLINE_WIDTH,
|
|
9
|
+
} from "../constants";
|
|
10
|
+
import {
|
|
11
|
+
buildGitHubCommitCount,
|
|
12
|
+
buildGitHubCommitSeries,
|
|
13
|
+
buildGitHubCommitSparkPoints,
|
|
14
|
+
buildGitHubSparkPolylinePoints,
|
|
15
|
+
buildGitHubStatusPill,
|
|
16
|
+
formatGitHubCommitHoverLabel,
|
|
17
|
+
} from "../githubMetrics";
|
|
18
|
+
import type {
|
|
19
|
+
GitHubCommitSparkPoint,
|
|
20
|
+
GitHubRecentCommit,
|
|
21
|
+
GitHubRepoSummarySnapshot,
|
|
22
|
+
} from "../types";
|
|
23
|
+
|
|
24
|
+
type UseGitHubPrimaryViewModelOptions = {
|
|
25
|
+
githubRepoSummary: GitHubRepoSummarySnapshot | null;
|
|
26
|
+
hoveredGitHubOverviewPointIndex: number | null;
|
|
27
|
+
setHoveredGitHubOverviewPointIndex: Dispatch<SetStateAction<number | null>>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type GitHubPrimaryViewModel = {
|
|
31
|
+
githubCommitCount30d: number;
|
|
32
|
+
sparklinePoints: string;
|
|
33
|
+
githubOverviewGraphSeries: GitHubCommitSparkPoint[];
|
|
34
|
+
githubOverviewGraphPolylinePoints: string;
|
|
35
|
+
githubOverviewHoverLabel: string;
|
|
36
|
+
githubStatusPill: string;
|
|
37
|
+
githubRepoLabel: string;
|
|
38
|
+
githubStarCountLabel: string;
|
|
39
|
+
githubOpenIssuesLabel: string;
|
|
40
|
+
githubOpenPrsLabel: string;
|
|
41
|
+
githubRecentCommits: GitHubRecentCommit[];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const useGitHubPrimaryViewModel = ({
|
|
45
|
+
githubRepoSummary,
|
|
46
|
+
hoveredGitHubOverviewPointIndex,
|
|
47
|
+
setHoveredGitHubOverviewPointIndex,
|
|
48
|
+
}: UseGitHubPrimaryViewModelOptions): GitHubPrimaryViewModel => {
|
|
49
|
+
const githubCommitSeries = useMemo(
|
|
50
|
+
() => buildGitHubCommitSeries(githubRepoSummary),
|
|
51
|
+
[githubRepoSummary],
|
|
52
|
+
);
|
|
53
|
+
const githubCommitCount30d = useMemo(
|
|
54
|
+
() => buildGitHubCommitCount(githubCommitSeries),
|
|
55
|
+
[githubCommitSeries],
|
|
56
|
+
);
|
|
57
|
+
const sparklineSeries = useMemo<GitHubCommitSparkPoint[]>(
|
|
58
|
+
() =>
|
|
59
|
+
buildGitHubCommitSparkPoints(
|
|
60
|
+
githubCommitSeries,
|
|
61
|
+
GITHUB_SPARKLINE_WIDTH,
|
|
62
|
+
GITHUB_SPARKLINE_HEIGHT,
|
|
63
|
+
),
|
|
64
|
+
[githubCommitSeries],
|
|
65
|
+
);
|
|
66
|
+
const sparklinePoints = useMemo(
|
|
67
|
+
() => buildGitHubSparkPolylinePoints(sparklineSeries),
|
|
68
|
+
[sparklineSeries],
|
|
69
|
+
);
|
|
70
|
+
const githubOverviewGraphSeries = useMemo<GitHubCommitSparkPoint[]>(
|
|
71
|
+
() =>
|
|
72
|
+
buildGitHubCommitSparkPoints(
|
|
73
|
+
githubCommitSeries,
|
|
74
|
+
GITHUB_OVERVIEW_GRAPH_WIDTH,
|
|
75
|
+
GITHUB_OVERVIEW_GRAPH_HEIGHT,
|
|
76
|
+
),
|
|
77
|
+
[githubCommitSeries],
|
|
78
|
+
);
|
|
79
|
+
const githubOverviewGraphPolylinePoints = useMemo(
|
|
80
|
+
() => buildGitHubSparkPolylinePoints(githubOverviewGraphSeries),
|
|
81
|
+
[githubOverviewGraphSeries],
|
|
82
|
+
);
|
|
83
|
+
const hoveredGitHubOverviewPoint = useMemo(() => {
|
|
84
|
+
if (hoveredGitHubOverviewPointIndex === null) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return githubOverviewGraphSeries[hoveredGitHubOverviewPointIndex] ?? null;
|
|
88
|
+
}, [githubOverviewGraphSeries, hoveredGitHubOverviewPointIndex]);
|
|
89
|
+
const githubOverviewHoverLabel = useMemo(() => {
|
|
90
|
+
if (hoveredGitHubOverviewPoint) {
|
|
91
|
+
return formatGitHubCommitHoverLabel(hoveredGitHubOverviewPoint);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return "Hover points for date and commit count";
|
|
95
|
+
}, [hoveredGitHubOverviewPoint]);
|
|
96
|
+
const githubStatusPill = useMemo(
|
|
97
|
+
() => buildGitHubStatusPill(githubRepoSummary),
|
|
98
|
+
[githubRepoSummary],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (hoveredGitHubOverviewPointIndex === null) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (hoveredGitHubOverviewPointIndex >= githubOverviewGraphSeries.length) {
|
|
106
|
+
setHoveredGitHubOverviewPointIndex(null);
|
|
107
|
+
}
|
|
108
|
+
}, [
|
|
109
|
+
githubOverviewGraphSeries.length,
|
|
110
|
+
hoveredGitHubOverviewPointIndex,
|
|
111
|
+
setHoveredGitHubOverviewPointIndex,
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
const githubRepoLabel = githubRepoSummary?.repo ?? "GitHub repository";
|
|
115
|
+
const githubStarCountLabel =
|
|
116
|
+
githubRepoSummary?.stargazerCount !== null && githubRepoSummary?.stargazerCount !== undefined
|
|
117
|
+
? Math.round(githubRepoSummary.stargazerCount).toLocaleString("en-US")
|
|
118
|
+
: "--";
|
|
119
|
+
const githubOpenIssuesLabel =
|
|
120
|
+
githubRepoSummary?.openIssueCount !== null && githubRepoSummary?.openIssueCount !== undefined
|
|
121
|
+
? Math.round(githubRepoSummary.openIssueCount).toString()
|
|
122
|
+
: "--";
|
|
123
|
+
const githubOpenPrsLabel =
|
|
124
|
+
githubRepoSummary?.openPullRequestCount !== null &&
|
|
125
|
+
githubRepoSummary?.openPullRequestCount !== undefined
|
|
126
|
+
? Math.round(githubRepoSummary.openPullRequestCount).toString()
|
|
127
|
+
: "--";
|
|
128
|
+
const githubRecentCommits = (githubRepoSummary?.recentCommits ?? []).slice(0, 50);
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
githubCommitCount30d,
|
|
132
|
+
sparklinePoints,
|
|
133
|
+
githubOverviewGraphSeries,
|
|
134
|
+
githubOverviewGraphPolylinePoints,
|
|
135
|
+
githubOverviewHoverLabel,
|
|
136
|
+
githubStatusPill,
|
|
137
|
+
githubRepoLabel,
|
|
138
|
+
githubStarCountLabel,
|
|
139
|
+
githubOpenIssuesLabel,
|
|
140
|
+
githubOpenPrsLabel,
|
|
141
|
+
githubRecentCommits,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { buildGithubSummaryUrl } from "../../runtime/runtimeEndpoints";
|
|
2
|
+
import { GITHUB_SUMMARY_SCAN_INTERVAL_MS } from "../constants";
|
|
3
|
+
import { normalizeGitHubRepoSummarySnapshot } from "../githubNormalizers";
|
|
4
|
+
import type { GitHubRepoSummarySnapshot } from "../types";
|
|
5
|
+
import { usePollingData } from "./usePollingData";
|
|
6
|
+
|
|
7
|
+
const fallback = (): GitHubRepoSummarySnapshot => ({
|
|
8
|
+
status: "error",
|
|
9
|
+
source: "none",
|
|
10
|
+
fetchedAt: new Date().toISOString(),
|
|
11
|
+
message: "Unable to read GitHub summary.",
|
|
12
|
+
commitsPerDay: [],
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const useGithubSummaryPolling = () => {
|
|
16
|
+
const { data, isLoading, refresh } = usePollingData<GitHubRepoSummarySnapshot>({
|
|
17
|
+
fetchUrl: buildGithubSummaryUrl(),
|
|
18
|
+
intervalMs: GITHUB_SUMMARY_SCAN_INTERVAL_MS,
|
|
19
|
+
normalize: normalizeGitHubRepoSummarySnapshot,
|
|
20
|
+
fallback,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
githubRepoSummary: data,
|
|
25
|
+
isRefreshingGitHubSummary: isLoading,
|
|
26
|
+
refreshGitHubRepoSummary: refresh,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
3
|
+
|
|
4
|
+
import type { FrontendUiStateSnapshot, TerminalView } from "../types";
|
|
5
|
+
|
|
6
|
+
type UseInitialColumnsHydrationOptions = {
|
|
7
|
+
readColumns: (signal?: AbortSignal) => Promise<TerminalView>;
|
|
8
|
+
readUiState: (signal?: AbortSignal) => Promise<FrontendUiStateSnapshot | null>;
|
|
9
|
+
applyHydratedUiState: (
|
|
10
|
+
snapshot: FrontendUiStateSnapshot | null,
|
|
11
|
+
nextColumns: TerminalView,
|
|
12
|
+
) => void;
|
|
13
|
+
setColumns: Dispatch<SetStateAction<TerminalView>>;
|
|
14
|
+
setLoadError: Dispatch<SetStateAction<string | null>>;
|
|
15
|
+
setIsLoading: Dispatch<SetStateAction<boolean>>;
|
|
16
|
+
setIsUiStateHydrated: Dispatch<SetStateAction<boolean>>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const useInitialColumnsHydration = ({
|
|
20
|
+
readColumns,
|
|
21
|
+
readUiState,
|
|
22
|
+
applyHydratedUiState,
|
|
23
|
+
setColumns,
|
|
24
|
+
setLoadError,
|
|
25
|
+
setIsLoading,
|
|
26
|
+
setIsUiStateHydrated,
|
|
27
|
+
}: UseInitialColumnsHydrationOptions) => {
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const controller = new AbortController();
|
|
30
|
+
|
|
31
|
+
const syncColumns = async () => {
|
|
32
|
+
try {
|
|
33
|
+
setLoadError(null);
|
|
34
|
+
const [nextColumns, nextUiState] = await Promise.all([
|
|
35
|
+
readColumns(controller.signal),
|
|
36
|
+
readUiState(controller.signal),
|
|
37
|
+
]);
|
|
38
|
+
setColumns(nextColumns);
|
|
39
|
+
applyHydratedUiState(nextUiState, nextColumns);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if ((error as Error).name !== "AbortError") {
|
|
42
|
+
setColumns([]);
|
|
43
|
+
setLoadError("Agent data is currently unavailable.");
|
|
44
|
+
}
|
|
45
|
+
} finally {
|
|
46
|
+
setIsLoading(false);
|
|
47
|
+
setIsUiStateHydrated(true);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
void syncColumns();
|
|
52
|
+
return () => {
|
|
53
|
+
controller.abort();
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
applyHydratedUiState,
|
|
57
|
+
readColumns,
|
|
58
|
+
readUiState,
|
|
59
|
+
setColumns,
|
|
60
|
+
setIsLoading,
|
|
61
|
+
setIsUiStateHydrated,
|
|
62
|
+
setLoadError,
|
|
63
|
+
]);
|
|
64
|
+
};
|