@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,235 @@
|
|
|
1
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const CLAUDE_PROJECTS_DIR = join(homedir(), ".claude", "projects");
|
|
6
|
+
|
|
7
|
+
export type UsageSlice = {
|
|
8
|
+
key: string;
|
|
9
|
+
tokens: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type UsageDayEntry = {
|
|
13
|
+
date: string;
|
|
14
|
+
totalTokens: number;
|
|
15
|
+
projects: UsageSlice[];
|
|
16
|
+
models: UsageSlice[];
|
|
17
|
+
sessions: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type UsageChartResponse = {
|
|
21
|
+
days: UsageDayEntry[];
|
|
22
|
+
projects: string[];
|
|
23
|
+
models: string[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type AssistantEvent = {
|
|
27
|
+
type: string;
|
|
28
|
+
timestamp: string;
|
|
29
|
+
sessionId: string;
|
|
30
|
+
message?: {
|
|
31
|
+
model?: string;
|
|
32
|
+
usage?: {
|
|
33
|
+
input_tokens?: number;
|
|
34
|
+
output_tokens?: number;
|
|
35
|
+
cache_creation_input_tokens?: number;
|
|
36
|
+
cache_read_input_tokens?: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const isAssistantEvent = (value: unknown): value is AssistantEvent => {
|
|
42
|
+
if (typeof value !== "object" || value === null) return false;
|
|
43
|
+
const record = value as Record<string, unknown>;
|
|
44
|
+
return record.type === "assistant" && typeof record.timestamp === "string";
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const toDateKey = (timestamp: string): string | null => {
|
|
48
|
+
const parsed = Date.parse(timestamp);
|
|
49
|
+
if (!Number.isFinite(parsed)) return null;
|
|
50
|
+
return new Date(parsed).toISOString().slice(0, 10);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type DayBucket = {
|
|
54
|
+
totalTokens: number;
|
|
55
|
+
projectTokens: Map<string, number>;
|
|
56
|
+
modelTokens: Map<string, number>;
|
|
57
|
+
sessions: Set<string>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const scanJsonlFile = async (
|
|
61
|
+
filePath: string,
|
|
62
|
+
projectLabel: string,
|
|
63
|
+
buckets: Map<string, DayBucket>,
|
|
64
|
+
): Promise<void> => {
|
|
65
|
+
let content: string;
|
|
66
|
+
try {
|
|
67
|
+
content = await readFile(filePath, "utf8");
|
|
68
|
+
} catch {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const line of content.split("\n")) {
|
|
73
|
+
const trimmed = line.trim();
|
|
74
|
+
if (trimmed.length === 0) continue;
|
|
75
|
+
|
|
76
|
+
let parsed: unknown;
|
|
77
|
+
try {
|
|
78
|
+
parsed = JSON.parse(trimmed);
|
|
79
|
+
} catch {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!isAssistantEvent(parsed)) continue;
|
|
84
|
+
|
|
85
|
+
const dateKey = toDateKey(parsed.timestamp);
|
|
86
|
+
if (!dateKey) continue;
|
|
87
|
+
|
|
88
|
+
const usage = parsed.message?.usage;
|
|
89
|
+
if (!usage) continue;
|
|
90
|
+
|
|
91
|
+
const totalTokens =
|
|
92
|
+
(usage.input_tokens ?? 0) +
|
|
93
|
+
(usage.output_tokens ?? 0) +
|
|
94
|
+
(usage.cache_creation_input_tokens ?? 0) +
|
|
95
|
+
(usage.cache_read_input_tokens ?? 0);
|
|
96
|
+
|
|
97
|
+
if (totalTokens === 0) continue;
|
|
98
|
+
|
|
99
|
+
let bucket = buckets.get(dateKey);
|
|
100
|
+
if (!bucket) {
|
|
101
|
+
bucket = {
|
|
102
|
+
totalTokens: 0,
|
|
103
|
+
projectTokens: new Map(),
|
|
104
|
+
modelTokens: new Map(),
|
|
105
|
+
sessions: new Set(),
|
|
106
|
+
};
|
|
107
|
+
buckets.set(dateKey, bucket);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
bucket.totalTokens += totalTokens;
|
|
111
|
+
bucket.projectTokens.set(
|
|
112
|
+
projectLabel,
|
|
113
|
+
(bucket.projectTokens.get(projectLabel) ?? 0) + totalTokens,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const modelKey = parsed.message?.model ?? "unknown";
|
|
117
|
+
bucket.modelTokens.set(modelKey, (bucket.modelTokens.get(modelKey) ?? 0) + totalTokens);
|
|
118
|
+
|
|
119
|
+
if (parsed.sessionId) {
|
|
120
|
+
bucket.sessions.add(parsed.sessionId);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const scanProjectDirectory = async (
|
|
126
|
+
projectDir: string,
|
|
127
|
+
projectLabel: string,
|
|
128
|
+
buckets: Map<string, DayBucket>,
|
|
129
|
+
): Promise<void> => {
|
|
130
|
+
let entries: string[];
|
|
131
|
+
try {
|
|
132
|
+
entries = await readdir(projectDir);
|
|
133
|
+
} catch {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const jsonlFiles = entries.filter((entry) => entry.endsWith(".jsonl"));
|
|
138
|
+
await Promise.all(
|
|
139
|
+
jsonlFiles.map((file) => scanJsonlFile(join(projectDir, file), projectLabel, buckets)),
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const slugToLabel = (slug: string): string => {
|
|
144
|
+
const parts = slug.replace(/^-/, "").split("-");
|
|
145
|
+
const codebaseIndex = parts.findIndex((p) => p.toLowerCase() === "codebase");
|
|
146
|
+
const relevant = codebaseIndex >= 0 ? parts.slice(codebaseIndex + 1) : parts.slice(-1);
|
|
147
|
+
if (relevant.length === 0) return slug;
|
|
148
|
+
|
|
149
|
+
const joined = relevant.join("-");
|
|
150
|
+
const worktreeMatch = joined.match(/^(.+?)--.*?-worktrees-(.+)$/);
|
|
151
|
+
if (worktreeMatch) {
|
|
152
|
+
return `${worktreeMatch[1]}/${worktreeMatch[2]}`;
|
|
153
|
+
}
|
|
154
|
+
return joined;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const sortedKeys = (totals: Map<string, number>): string[] =>
|
|
158
|
+
Array.from(totals.entries())
|
|
159
|
+
.sort((a, b) => b[1] - a[1])
|
|
160
|
+
.map(([name]) => name);
|
|
161
|
+
|
|
162
|
+
const mapToSlices = (map: Map<string, number>): UsageSlice[] =>
|
|
163
|
+
Array.from(map.entries())
|
|
164
|
+
.map(([key, tokens]) => ({ key, tokens }))
|
|
165
|
+
.sort((a, b) => b.tokens - a.tokens);
|
|
166
|
+
|
|
167
|
+
const projectSlugFromCwd = (cwd: string): string => cwd.replace(/\//g, "-");
|
|
168
|
+
|
|
169
|
+
let cachedResult: { response: UsageChartResponse; fetchedAt: number; cacheKey: string } | null =
|
|
170
|
+
null;
|
|
171
|
+
const CACHE_TTL_MS = 120_000;
|
|
172
|
+
|
|
173
|
+
export const scanClaudeUsageChart = async (
|
|
174
|
+
scope: "all" | "project",
|
|
175
|
+
workspaceCwd: string,
|
|
176
|
+
): Promise<UsageChartResponse> => {
|
|
177
|
+
const projectSlug = scope === "project" ? projectSlugFromCwd(workspaceCwd) : null;
|
|
178
|
+
const cacheKey = `${scope}:${projectSlug ?? "all"}`;
|
|
179
|
+
|
|
180
|
+
if (
|
|
181
|
+
cachedResult &&
|
|
182
|
+
Date.now() - cachedResult.fetchedAt < CACHE_TTL_MS &&
|
|
183
|
+
cachedResult.cacheKey === cacheKey
|
|
184
|
+
) {
|
|
185
|
+
return cachedResult.response;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const buckets = new Map<string, DayBucket>();
|
|
189
|
+
|
|
190
|
+
if (scope === "project" && projectSlug) {
|
|
191
|
+
const label = slugToLabel(projectSlug);
|
|
192
|
+
await scanProjectDirectory(join(CLAUDE_PROJECTS_DIR, projectSlug), label, buckets);
|
|
193
|
+
} else {
|
|
194
|
+
let projectDirs: string[];
|
|
195
|
+
try {
|
|
196
|
+
projectDirs = await readdir(CLAUDE_PROJECTS_DIR);
|
|
197
|
+
} catch {
|
|
198
|
+
projectDirs = [];
|
|
199
|
+
}
|
|
200
|
+
await Promise.all(
|
|
201
|
+
projectDirs.map((dir) =>
|
|
202
|
+
scanProjectDirectory(join(CLAUDE_PROJECTS_DIR, dir), slugToLabel(dir), buckets),
|
|
203
|
+
),
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const projectTotals = new Map<string, number>();
|
|
208
|
+
const modelTotals = new Map<string, number>();
|
|
209
|
+
|
|
210
|
+
const days: UsageDayEntry[] = Array.from(buckets.entries())
|
|
211
|
+
.map(([date, bucket]) => {
|
|
212
|
+
for (const [p, t] of bucket.projectTokens) {
|
|
213
|
+
projectTotals.set(p, (projectTotals.get(p) ?? 0) + t);
|
|
214
|
+
}
|
|
215
|
+
for (const [m, t] of bucket.modelTokens) {
|
|
216
|
+
modelTotals.set(m, (modelTotals.get(m) ?? 0) + t);
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
date,
|
|
220
|
+
totalTokens: bucket.totalTokens,
|
|
221
|
+
projects: mapToSlices(bucket.projectTokens),
|
|
222
|
+
models: mapToSlices(bucket.modelTokens),
|
|
223
|
+
sessions: bucket.sessions.size,
|
|
224
|
+
};
|
|
225
|
+
})
|
|
226
|
+
.sort((a, b) => a.date.localeCompare(b.date));
|
|
227
|
+
|
|
228
|
+
const response: UsageChartResponse = {
|
|
229
|
+
days,
|
|
230
|
+
projects: sortedKeys(projectTotals),
|
|
231
|
+
models: sortedKeys(modelTotals),
|
|
232
|
+
};
|
|
233
|
+
cachedResult = { response, fetchedAt: Date.now(), cacheKey };
|
|
234
|
+
return response;
|
|
235
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import type { DeckAvailableSkill } from "@octogent/core";
|
|
5
|
+
|
|
6
|
+
const SKILL_MARKER_START = "<!-- octogent:suggested-skills:start -->";
|
|
7
|
+
const SKILL_MARKER_END = "<!-- octogent:suggested-skills:end -->";
|
|
8
|
+
const FRONT_MATTER_PATTERN = /^---\n([\s\S]*?)\n---\n?/;
|
|
9
|
+
const H1_PATTERN = /^#\s+(.+)$/m;
|
|
10
|
+
|
|
11
|
+
const normalizeSkillNames = (skills: readonly string[]): string[] => {
|
|
12
|
+
const seen = new Set<string>();
|
|
13
|
+
const normalized: string[] = [];
|
|
14
|
+
|
|
15
|
+
for (const skill of skills) {
|
|
16
|
+
const trimmed = skill.trim();
|
|
17
|
+
if (trimmed.length === 0 || seen.has(trimmed)) continue;
|
|
18
|
+
seen.add(trimmed);
|
|
19
|
+
normalized.push(trimmed);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return normalized.sort((a, b) => a.localeCompare(b));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const readSkillMetadata = (
|
|
26
|
+
skillFilePath: string,
|
|
27
|
+
): { name: string; description: string; title: string | null } => {
|
|
28
|
+
const fallbackName =
|
|
29
|
+
basename(skillFilePath, ".md") === "SKILL"
|
|
30
|
+
? basename(dirname(skillFilePath))
|
|
31
|
+
: basename(skillFilePath, ".md");
|
|
32
|
+
try {
|
|
33
|
+
const content = readFileSync(skillFilePath, "utf8");
|
|
34
|
+
const frontMatterMatch = content.match(FRONT_MATTER_PATTERN);
|
|
35
|
+
let name: string | null = null;
|
|
36
|
+
let description = "";
|
|
37
|
+
|
|
38
|
+
if (frontMatterMatch) {
|
|
39
|
+
for (const line of (frontMatterMatch[1] ?? "").split("\n")) {
|
|
40
|
+
const separatorIndex = line.indexOf(":");
|
|
41
|
+
if (separatorIndex <= 0) continue;
|
|
42
|
+
|
|
43
|
+
const key = line.slice(0, separatorIndex).trim();
|
|
44
|
+
const rawValue = line.slice(separatorIndex + 1).trim();
|
|
45
|
+
const value = rawValue.replace(/^['"]|['"]$/g, "");
|
|
46
|
+
if (key === "name" && value.length > 0) {
|
|
47
|
+
name = value;
|
|
48
|
+
} else if (key === "description" && value.length > 0) {
|
|
49
|
+
description = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const title = content.match(H1_PATTERN)?.[1]?.trim() ?? null;
|
|
55
|
+
return {
|
|
56
|
+
name: name ?? title ?? fallbackName,
|
|
57
|
+
description,
|
|
58
|
+
title,
|
|
59
|
+
};
|
|
60
|
+
} catch {
|
|
61
|
+
return {
|
|
62
|
+
name: fallbackName,
|
|
63
|
+
description: "",
|
|
64
|
+
title: null,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const listSkillDefinitionFiles = (skillsRoot: string): string[] => {
|
|
70
|
+
if (!existsSync(skillsRoot)) return [];
|
|
71
|
+
|
|
72
|
+
const definitions: string[] = [];
|
|
73
|
+
|
|
74
|
+
let entries: string[] = [];
|
|
75
|
+
try {
|
|
76
|
+
entries = readdirSync(skillsRoot);
|
|
77
|
+
} catch {
|
|
78
|
+
return definitions;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const entry of entries) {
|
|
82
|
+
const entryPath = join(skillsRoot, entry);
|
|
83
|
+
try {
|
|
84
|
+
if (!statSync(entryPath).isDirectory()) continue;
|
|
85
|
+
} catch {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const skillFile = join(entryPath, "SKILL.md");
|
|
90
|
+
if (existsSync(skillFile)) {
|
|
91
|
+
definitions.push(skillFile);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return definitions;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const readAvailableClaudeSkills = (workspaceCwd: string): DeckAvailableSkill[] => {
|
|
99
|
+
const roots: Array<{ path: string; source: DeckAvailableSkill["source"] }> = [
|
|
100
|
+
{ path: join(workspaceCwd, ".claude", "skills"), source: "project" },
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
const seen = new Map<string, DeckAvailableSkill>();
|
|
104
|
+
|
|
105
|
+
for (const root of roots) {
|
|
106
|
+
const definitions = listSkillDefinitionFiles(root.path);
|
|
107
|
+
for (const definition of definitions) {
|
|
108
|
+
const metadata = readSkillMetadata(definition);
|
|
109
|
+
const name = metadata.name.trim();
|
|
110
|
+
if (name.length === 0 || seen.has(name)) continue;
|
|
111
|
+
seen.set(name, {
|
|
112
|
+
name,
|
|
113
|
+
description: metadata.description,
|
|
114
|
+
source: root.source,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return [...seen.values()].sort((a, b) => {
|
|
120
|
+
if (a.source !== b.source) {
|
|
121
|
+
return a.source === "project" ? -1 : 1;
|
|
122
|
+
}
|
|
123
|
+
return a.name.localeCompare(b.name);
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const parseSuggestedSkillsFromContext = (content: string): string[] => {
|
|
128
|
+
const start = content.indexOf(SKILL_MARKER_START);
|
|
129
|
+
const end = content.indexOf(SKILL_MARKER_END);
|
|
130
|
+
if (start < 0 || end < 0 || end <= start) return [];
|
|
131
|
+
|
|
132
|
+
const block = content.slice(start, end);
|
|
133
|
+
const skills = block
|
|
134
|
+
.split("\n")
|
|
135
|
+
.map((line) => {
|
|
136
|
+
const match = line.trim().match(/^- `(.+)`$/);
|
|
137
|
+
return match?.[1]?.trim() ?? null;
|
|
138
|
+
})
|
|
139
|
+
.filter((skill): skill is string => skill !== null);
|
|
140
|
+
|
|
141
|
+
return normalizeSkillNames(skills);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const renderSuggestedSkillsBlock = (skills: readonly string[]): string => {
|
|
145
|
+
const normalized = normalizeSkillNames(skills);
|
|
146
|
+
if (normalized.length === 0) return "";
|
|
147
|
+
|
|
148
|
+
const items = normalized.map((skill) => `- \`${skill}\``).join("\n");
|
|
149
|
+
return [
|
|
150
|
+
SKILL_MARKER_START,
|
|
151
|
+
"## Suggested Skills",
|
|
152
|
+
"",
|
|
153
|
+
"You can use these skills if you need to.",
|
|
154
|
+
"",
|
|
155
|
+
items,
|
|
156
|
+
SKILL_MARKER_END,
|
|
157
|
+
].join("\n");
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export const applySuggestedSkillsToContext = (
|
|
161
|
+
content: string,
|
|
162
|
+
skills: readonly string[],
|
|
163
|
+
): string => {
|
|
164
|
+
const trimmedContent = content.trimEnd();
|
|
165
|
+
const start = trimmedContent.indexOf(SKILL_MARKER_START);
|
|
166
|
+
const end = trimmedContent.indexOf(SKILL_MARKER_END);
|
|
167
|
+
const block = renderSuggestedSkillsBlock(skills);
|
|
168
|
+
|
|
169
|
+
let withoutExistingBlock = trimmedContent;
|
|
170
|
+
if (start >= 0 && end > start) {
|
|
171
|
+
withoutExistingBlock = `${trimmedContent.slice(0, start).trimEnd()}\n${trimmedContent
|
|
172
|
+
.slice(end + SKILL_MARKER_END.length)
|
|
173
|
+
.trimStart()}`.trimEnd();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (block.length === 0) {
|
|
177
|
+
return `${withoutExistingBlock}\n`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const base = withoutExistingBlock.length > 0 ? `${withoutExistingBlock}\n\n` : "";
|
|
181
|
+
return `${base}${block}\n`;
|
|
182
|
+
};
|