@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,595 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
mkdirSync,
|
|
4
|
+
readFileSync,
|
|
5
|
+
readdirSync,
|
|
6
|
+
rmSync,
|
|
7
|
+
statSync,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
} from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
DeckAvailableSkill,
|
|
14
|
+
DeckOctopusAppearance,
|
|
15
|
+
DeckTentacleStatus,
|
|
16
|
+
DeckTentacleSummary,
|
|
17
|
+
} from "@octogent/core";
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
applySuggestedSkillsToContext,
|
|
21
|
+
parseSuggestedSkillsFromContext,
|
|
22
|
+
readAvailableClaudeSkills,
|
|
23
|
+
} from "../claudeSkills";
|
|
24
|
+
import { markTentaclesInitialized } from "../setupState";
|
|
25
|
+
|
|
26
|
+
const TENTACLES_DIR = ".octogent/tentacles";
|
|
27
|
+
const DECK_STATE_PATH = ".octogent/state/deck.json";
|
|
28
|
+
|
|
29
|
+
const VALID_STATUSES: ReadonlySet<string> = new Set(["idle", "active", "blocked", "needs-review"]);
|
|
30
|
+
|
|
31
|
+
// ─── Deck state (app metadata, separate from agent-facing files) ────────────
|
|
32
|
+
|
|
33
|
+
type DeckTentacleState = {
|
|
34
|
+
color: string | null;
|
|
35
|
+
status: DeckTentacleStatus;
|
|
36
|
+
octopus: DeckOctopusAppearance;
|
|
37
|
+
scope: { paths: string[]; tags: string[] };
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type DeckStateDocument = {
|
|
41
|
+
tentacles: Record<string, DeckTentacleState>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const readDeckState = (projectStateDir: string): DeckStateDocument => {
|
|
45
|
+
const filePath = join(projectStateDir, "state", "deck.json");
|
|
46
|
+
try {
|
|
47
|
+
const raw = JSON.parse(readFileSync(filePath, "utf-8"));
|
|
48
|
+
if (
|
|
49
|
+
raw &&
|
|
50
|
+
typeof raw === "object" &&
|
|
51
|
+
typeof raw.tentacles === "object" &&
|
|
52
|
+
raw.tentacles !== null
|
|
53
|
+
) {
|
|
54
|
+
return raw as DeckStateDocument;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
// missing or corrupt — return empty
|
|
58
|
+
}
|
|
59
|
+
return { tentacles: {} };
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const writeDeckState = (projectStateDir: string, state: DeckStateDocument): void => {
|
|
63
|
+
const filePath = join(projectStateDir, "state", "deck.json");
|
|
64
|
+
const dir = join(projectStateDir, "state");
|
|
65
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
66
|
+
writeFileSync(filePath, `${JSON.stringify(state, null, 2)}\n`);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const parseTentacleState = (raw: unknown): DeckTentacleState => {
|
|
70
|
+
const defaults: DeckTentacleState = {
|
|
71
|
+
color: null,
|
|
72
|
+
status: "idle",
|
|
73
|
+
octopus: { animation: null, expression: null, accessory: null, hairColor: null },
|
|
74
|
+
scope: { paths: [], tags: [] },
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
if (raw === null || typeof raw !== "object") return defaults;
|
|
78
|
+
const rec = raw as Record<string, unknown>;
|
|
79
|
+
|
|
80
|
+
const color =
|
|
81
|
+
typeof rec.color === "string" && rec.color.trim().length > 0 ? rec.color.trim() : null;
|
|
82
|
+
const status =
|
|
83
|
+
typeof rec.status === "string" && VALID_STATUSES.has(rec.status)
|
|
84
|
+
? (rec.status as DeckTentacleStatus)
|
|
85
|
+
: "idle";
|
|
86
|
+
|
|
87
|
+
const octopus: DeckOctopusAppearance = {
|
|
88
|
+
animation: null,
|
|
89
|
+
expression: null,
|
|
90
|
+
accessory: null,
|
|
91
|
+
hairColor: null,
|
|
92
|
+
};
|
|
93
|
+
if (rec.octopus !== null && typeof rec.octopus === "object") {
|
|
94
|
+
const o = rec.octopus as Record<string, unknown>;
|
|
95
|
+
if (typeof o.animation === "string") octopus.animation = o.animation;
|
|
96
|
+
if (typeof o.expression === "string") octopus.expression = o.expression;
|
|
97
|
+
if (typeof o.accessory === "string") octopus.accessory = o.accessory;
|
|
98
|
+
if (typeof o.hairColor === "string") octopus.hairColor = o.hairColor;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const scope = { paths: [] as string[], tags: [] as string[] };
|
|
102
|
+
if (rec.scope !== null && typeof rec.scope === "object") {
|
|
103
|
+
const s = rec.scope as Record<string, unknown>;
|
|
104
|
+
if (Array.isArray(s.paths)) {
|
|
105
|
+
scope.paths = s.paths.filter((p): p is string => typeof p === "string");
|
|
106
|
+
}
|
|
107
|
+
if (Array.isArray(s.tags)) {
|
|
108
|
+
scope.tags = s.tags.filter((t): t is string => typeof t === "string");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return { color, status, octopus, scope };
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// ─── Parse CONTEXT.md for title and description ───────────────────────────────
|
|
116
|
+
|
|
117
|
+
const parseContextMd = (
|
|
118
|
+
content: string,
|
|
119
|
+
): { displayName: string; description: string; suggestedSkills: string[] } | null => {
|
|
120
|
+
const lines = content.split("\n");
|
|
121
|
+
let displayName: string | null = null;
|
|
122
|
+
let description = "";
|
|
123
|
+
|
|
124
|
+
for (const line of lines) {
|
|
125
|
+
const trimmed = line.trim();
|
|
126
|
+
if (!displayName) {
|
|
127
|
+
const h1Match = trimmed.match(/^#\s+(.+)/);
|
|
128
|
+
if (h1Match) {
|
|
129
|
+
displayName = (h1Match[1] as string).trim();
|
|
130
|
+
}
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
// First non-empty line after the H1 is the description
|
|
134
|
+
if (trimmed.length > 0) {
|
|
135
|
+
description = trimmed;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!displayName) return null;
|
|
141
|
+
return { displayName, description, suggestedSkills: parseSuggestedSkillsFromContext(content) };
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// ─── Todo parsing ───────────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
export const parseTodoProgress = (
|
|
147
|
+
content: string,
|
|
148
|
+
): { total: number; done: number; items: { text: string; done: boolean }[] } => {
|
|
149
|
+
const lines = content.split("\n");
|
|
150
|
+
let total = 0;
|
|
151
|
+
let done = 0;
|
|
152
|
+
const items: { text: string; done: boolean }[] = [];
|
|
153
|
+
|
|
154
|
+
for (const line of lines) {
|
|
155
|
+
const trimmed = line.trim();
|
|
156
|
+
const checkedMatch = trimmed.match(/^- \[x\]\s+(.+)/i);
|
|
157
|
+
const uncheckedMatch = trimmed.match(/^- \[ \]\s+(.+)/);
|
|
158
|
+
|
|
159
|
+
if (checkedMatch) {
|
|
160
|
+
total++;
|
|
161
|
+
done++;
|
|
162
|
+
items.push({ text: checkedMatch[1] as string, done: true });
|
|
163
|
+
} else if (uncheckedMatch) {
|
|
164
|
+
total++;
|
|
165
|
+
items.push({ text: uncheckedMatch[1] as string, done: false });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return { total, done, items };
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// ─── Read all tentacles ─────────────────────────────────────────────────────
|
|
173
|
+
|
|
174
|
+
export const readDeckTentacles = (
|
|
175
|
+
workspaceCwd: string,
|
|
176
|
+
projectStateDir?: string,
|
|
177
|
+
): DeckTentacleSummary[] => {
|
|
178
|
+
const tentaclesRoot = join(workspaceCwd, TENTACLES_DIR);
|
|
179
|
+
if (!existsSync(tentaclesRoot)) return [];
|
|
180
|
+
|
|
181
|
+
let entries: string[];
|
|
182
|
+
try {
|
|
183
|
+
entries = readdirSync(tentaclesRoot);
|
|
184
|
+
} catch {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const deckState = readDeckState(projectStateDir ?? join(workspaceCwd, ".octogent"));
|
|
189
|
+
const results: DeckTentacleSummary[] = [];
|
|
190
|
+
|
|
191
|
+
for (const entry of entries) {
|
|
192
|
+
const entryPath = join(tentaclesRoot, entry);
|
|
193
|
+
if (!statSync(entryPath).isDirectory()) continue;
|
|
194
|
+
|
|
195
|
+
// A tentacle folder must have CONTEXT.md
|
|
196
|
+
const contextMdPath = join(entryPath, "CONTEXT.md");
|
|
197
|
+
if (!existsSync(contextMdPath)) continue;
|
|
198
|
+
|
|
199
|
+
let agentInfo: { displayName: string; description: string };
|
|
200
|
+
try {
|
|
201
|
+
const content = readFileSync(contextMdPath, "utf-8");
|
|
202
|
+
const parsed = parseContextMd(content);
|
|
203
|
+
if (!parsed) continue;
|
|
204
|
+
agentInfo = parsed;
|
|
205
|
+
} catch {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// App metadata from deck state
|
|
210
|
+
const state = parseTentacleState(deckState.tentacles[entry]);
|
|
211
|
+
|
|
212
|
+
// List markdown files in the tentacle folder (excluding CONTEXT.md itself)
|
|
213
|
+
let vaultFiles: string[] = [];
|
|
214
|
+
try {
|
|
215
|
+
vaultFiles = readdirSync(entryPath)
|
|
216
|
+
.filter((f) => f.endsWith(".md") && f !== "CONTEXT.md")
|
|
217
|
+
.sort((a, b) => {
|
|
218
|
+
if (a === "todo.md") return -1;
|
|
219
|
+
if (b === "todo.md") return 1;
|
|
220
|
+
return a.localeCompare(b);
|
|
221
|
+
});
|
|
222
|
+
} catch {
|
|
223
|
+
// skip unreadable dirs
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Parse todo.md for progress
|
|
227
|
+
let todoTotal = 0;
|
|
228
|
+
let todoDone = 0;
|
|
229
|
+
let todoItems: { text: string; done: boolean }[] = [];
|
|
230
|
+
const todoPath = join(entryPath, "todo.md");
|
|
231
|
+
if (existsSync(todoPath)) {
|
|
232
|
+
try {
|
|
233
|
+
const todoContent = readFileSync(todoPath, "utf-8");
|
|
234
|
+
const progress = parseTodoProgress(todoContent);
|
|
235
|
+
todoTotal = progress.total;
|
|
236
|
+
todoDone = progress.done;
|
|
237
|
+
todoItems = progress.items;
|
|
238
|
+
} catch {
|
|
239
|
+
// skip unreadable todo
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
results.push({
|
|
244
|
+
tentacleId: entry,
|
|
245
|
+
displayName: agentInfo.displayName,
|
|
246
|
+
description: agentInfo.description,
|
|
247
|
+
status: state.status,
|
|
248
|
+
color: state.color,
|
|
249
|
+
octopus: state.octopus,
|
|
250
|
+
scope: state.scope,
|
|
251
|
+
vaultFiles,
|
|
252
|
+
todoTotal,
|
|
253
|
+
todoDone,
|
|
254
|
+
todoItems,
|
|
255
|
+
suggestedSkills: agentInfo.suggestedSkills,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return results;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// ─── Read a vault file from a tentacle ──────────────────────────────────────
|
|
263
|
+
|
|
264
|
+
export const readDeckVaultFile = (
|
|
265
|
+
workspaceCwd: string,
|
|
266
|
+
tentacleId: string,
|
|
267
|
+
fileName: string,
|
|
268
|
+
): string | null => {
|
|
269
|
+
// Prevent path traversal
|
|
270
|
+
if (tentacleId.includes("..") || tentacleId.includes("/")) return null;
|
|
271
|
+
if (fileName.includes("..") || fileName.includes("/")) return null;
|
|
272
|
+
|
|
273
|
+
const filePath = join(workspaceCwd, TENTACLES_DIR, tentacleId, fileName);
|
|
274
|
+
|
|
275
|
+
if (!existsSync(filePath)) return null;
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
return readFileSync(filePath, "utf-8");
|
|
279
|
+
} catch {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Toggle a todo checkbox in a tentacle's todo.md by item index.
|
|
286
|
+
*/
|
|
287
|
+
export const toggleTodoItem = (
|
|
288
|
+
workspaceCwd: string,
|
|
289
|
+
tentacleId: string,
|
|
290
|
+
itemIndex: number,
|
|
291
|
+
done: boolean,
|
|
292
|
+
): { total: number; done: number; items: { text: string; done: boolean }[] } | null => {
|
|
293
|
+
if (tentacleId.includes("..") || tentacleId.includes("/")) return null;
|
|
294
|
+
|
|
295
|
+
const filePath = join(workspaceCwd, TENTACLES_DIR, tentacleId, "todo.md");
|
|
296
|
+
if (!existsSync(filePath)) return null;
|
|
297
|
+
|
|
298
|
+
let content: string;
|
|
299
|
+
try {
|
|
300
|
+
content = readFileSync(filePath, "utf-8");
|
|
301
|
+
} catch {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const lines = content.split("\n");
|
|
306
|
+
let todoIndex = 0;
|
|
307
|
+
let toggled = false;
|
|
308
|
+
|
|
309
|
+
for (let i = 0; i < lines.length; i++) {
|
|
310
|
+
const trimmed = (lines[i] as string).trim();
|
|
311
|
+
if (/^- \[[ xX]\]\s+/.test(trimmed)) {
|
|
312
|
+
if (todoIndex === itemIndex) {
|
|
313
|
+
lines[i] = done
|
|
314
|
+
? (lines[i] as string).replace(/- \[ \]/, "- [x]")
|
|
315
|
+
: (lines[i] as string).replace(/- \[[xX]\]/, "- [ ]");
|
|
316
|
+
toggled = true;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
todoIndex++;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (!toggled) return null;
|
|
324
|
+
|
|
325
|
+
const updated = lines.join("\n");
|
|
326
|
+
try {
|
|
327
|
+
writeFileSync(filePath, updated, "utf-8");
|
|
328
|
+
} catch {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return parseTodoProgress(updated);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Edit the text of a todo item in a tentacle's todo.md by item index.
|
|
337
|
+
*/
|
|
338
|
+
export const editTodoItem = (
|
|
339
|
+
workspaceCwd: string,
|
|
340
|
+
tentacleId: string,
|
|
341
|
+
itemIndex: number,
|
|
342
|
+
text: string,
|
|
343
|
+
): { total: number; done: number; items: { text: string; done: boolean }[] } | null => {
|
|
344
|
+
if (tentacleId.includes("..") || tentacleId.includes("/")) return null;
|
|
345
|
+
|
|
346
|
+
const filePath = join(workspaceCwd, TENTACLES_DIR, tentacleId, "todo.md");
|
|
347
|
+
if (!existsSync(filePath)) return null;
|
|
348
|
+
|
|
349
|
+
let content: string;
|
|
350
|
+
try {
|
|
351
|
+
content = readFileSync(filePath, "utf-8");
|
|
352
|
+
} catch {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const lines = content.split("\n");
|
|
357
|
+
let todoIndex = 0;
|
|
358
|
+
let edited = false;
|
|
359
|
+
|
|
360
|
+
for (let i = 0; i < lines.length; i++) {
|
|
361
|
+
const trimmed = (lines[i] as string).trim();
|
|
362
|
+
const match = trimmed.match(/^(- \[[ xX]\])\s+(.+)/);
|
|
363
|
+
if (match) {
|
|
364
|
+
if (todoIndex === itemIndex) {
|
|
365
|
+
const indent = (lines[i] as string).match(/^(\s*)/)?.[1] ?? "";
|
|
366
|
+
lines[i] = `${indent}${match[1]} ${text}`;
|
|
367
|
+
edited = true;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
todoIndex++;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (!edited) return null;
|
|
375
|
+
|
|
376
|
+
const updated = lines.join("\n");
|
|
377
|
+
try {
|
|
378
|
+
writeFileSync(filePath, updated, "utf-8");
|
|
379
|
+
} catch {
|
|
380
|
+
return null;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return parseTodoProgress(updated);
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Add a new todo item to a tentacle's todo.md.
|
|
388
|
+
*/
|
|
389
|
+
export const addTodoItem = (
|
|
390
|
+
workspaceCwd: string,
|
|
391
|
+
tentacleId: string,
|
|
392
|
+
text: string,
|
|
393
|
+
): { total: number; done: number; items: { text: string; done: boolean }[] } | null => {
|
|
394
|
+
if (tentacleId.includes("..") || tentacleId.includes("/")) return null;
|
|
395
|
+
|
|
396
|
+
const filePath = join(workspaceCwd, TENTACLES_DIR, tentacleId, "todo.md");
|
|
397
|
+
if (!existsSync(filePath)) return null;
|
|
398
|
+
|
|
399
|
+
let content: string;
|
|
400
|
+
try {
|
|
401
|
+
content = readFileSync(filePath, "utf-8");
|
|
402
|
+
} catch {
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const trimmed = content.endsWith("\n") ? content : `${content}\n`;
|
|
407
|
+
const updated = `${trimmed}- [ ] ${text}\n`;
|
|
408
|
+
|
|
409
|
+
try {
|
|
410
|
+
writeFileSync(filePath, updated, "utf-8");
|
|
411
|
+
} catch {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return parseTodoProgress(updated);
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Delete a todo item from a tentacle's todo.md by item index.
|
|
420
|
+
*/
|
|
421
|
+
export const deleteTodoItem = (
|
|
422
|
+
workspaceCwd: string,
|
|
423
|
+
tentacleId: string,
|
|
424
|
+
itemIndex: number,
|
|
425
|
+
): { total: number; done: number; items: { text: string; done: boolean }[] } | null => {
|
|
426
|
+
if (tentacleId.includes("..") || tentacleId.includes("/")) return null;
|
|
427
|
+
|
|
428
|
+
const filePath = join(workspaceCwd, TENTACLES_DIR, tentacleId, "todo.md");
|
|
429
|
+
if (!existsSync(filePath)) return null;
|
|
430
|
+
|
|
431
|
+
let content: string;
|
|
432
|
+
try {
|
|
433
|
+
content = readFileSync(filePath, "utf-8");
|
|
434
|
+
} catch {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const lines = content.split("\n");
|
|
439
|
+
let todoIndex = 0;
|
|
440
|
+
let deleted = false;
|
|
441
|
+
|
|
442
|
+
for (let i = 0; i < lines.length; i++) {
|
|
443
|
+
const trimmed = (lines[i] as string).trim();
|
|
444
|
+
if (/^- \[[ xX]\]\s+/.test(trimmed)) {
|
|
445
|
+
if (todoIndex === itemIndex) {
|
|
446
|
+
lines.splice(i, 1);
|
|
447
|
+
deleted = true;
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
todoIndex++;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (!deleted) return null;
|
|
455
|
+
|
|
456
|
+
const updated = lines.join("\n");
|
|
457
|
+
try {
|
|
458
|
+
writeFileSync(filePath, updated, "utf-8");
|
|
459
|
+
} catch {
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return parseTodoProgress(updated);
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
// ─── Create a new tentacle ──────────────────────────────────────────────────
|
|
467
|
+
|
|
468
|
+
type CreateDeckTentacleInput = {
|
|
469
|
+
name: string;
|
|
470
|
+
description: string;
|
|
471
|
+
color: string;
|
|
472
|
+
octopus: DeckOctopusAppearance;
|
|
473
|
+
suggestedSkills?: string[];
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
type CreateDeckTentacleResult =
|
|
477
|
+
| { ok: true; tentacle: DeckTentacleSummary }
|
|
478
|
+
| { ok: false; error: string };
|
|
479
|
+
|
|
480
|
+
export const createDeckTentacle = (
|
|
481
|
+
workspaceCwd: string,
|
|
482
|
+
input: CreateDeckTentacleInput,
|
|
483
|
+
projectStateDir?: string,
|
|
484
|
+
): CreateDeckTentacleResult => {
|
|
485
|
+
const stateDir = projectStateDir ?? join(workspaceCwd, ".octogent");
|
|
486
|
+
const name = input.name.trim();
|
|
487
|
+
if (name.length === 0) {
|
|
488
|
+
return { ok: false, error: "Name is required" };
|
|
489
|
+
}
|
|
490
|
+
if (name.includes("..") || name.includes("/")) {
|
|
491
|
+
return { ok: false, error: "Name contains invalid characters" };
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const tentacleDir = join(workspaceCwd, TENTACLES_DIR, name);
|
|
495
|
+
if (existsSync(tentacleDir)) {
|
|
496
|
+
return { ok: false, error: "A tentacle with this name already exists" };
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Create the tentacle folder with agent-facing files
|
|
500
|
+
mkdirSync(tentacleDir, { recursive: true });
|
|
501
|
+
|
|
502
|
+
const description = input.description.trim();
|
|
503
|
+
const baseContextMd = description.length > 0 ? `# ${name}\n\n${description}\n` : `# ${name}\n`;
|
|
504
|
+
const suggestedSkills = [...new Set((input.suggestedSkills ?? []).map((skill) => skill.trim()))]
|
|
505
|
+
.filter((skill) => skill.length > 0)
|
|
506
|
+
.sort((a, b) => a.localeCompare(b));
|
|
507
|
+
const contextMd = applySuggestedSkillsToContext(baseContextMd, suggestedSkills);
|
|
508
|
+
writeFileSync(join(tentacleDir, "CONTEXT.md"), contextMd);
|
|
509
|
+
writeFileSync(join(tentacleDir, "todo.md"), "# Todo\n");
|
|
510
|
+
|
|
511
|
+
// Persist app metadata in deck state
|
|
512
|
+
const deckState = readDeckState(stateDir);
|
|
513
|
+
deckState.tentacles[name] = {
|
|
514
|
+
color: input.color,
|
|
515
|
+
status: "idle",
|
|
516
|
+
octopus: input.octopus,
|
|
517
|
+
scope: { paths: [], tags: [] },
|
|
518
|
+
};
|
|
519
|
+
writeDeckState(stateDir, deckState);
|
|
520
|
+
markTentaclesInitialized(stateDir);
|
|
521
|
+
|
|
522
|
+
return {
|
|
523
|
+
ok: true,
|
|
524
|
+
tentacle: {
|
|
525
|
+
tentacleId: name,
|
|
526
|
+
displayName: name,
|
|
527
|
+
description,
|
|
528
|
+
status: "idle",
|
|
529
|
+
color: input.color,
|
|
530
|
+
octopus: input.octopus,
|
|
531
|
+
scope: { paths: [], tags: [] },
|
|
532
|
+
vaultFiles: [],
|
|
533
|
+
todoTotal: 0,
|
|
534
|
+
todoDone: 0,
|
|
535
|
+
todoItems: [],
|
|
536
|
+
suggestedSkills,
|
|
537
|
+
},
|
|
538
|
+
};
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
export const listDeckAvailableSkills = (workspaceCwd: string): DeckAvailableSkill[] =>
|
|
542
|
+
readAvailableClaudeSkills(workspaceCwd);
|
|
543
|
+
|
|
544
|
+
export const updateDeckTentacleSuggestedSkills = (
|
|
545
|
+
workspaceCwd: string,
|
|
546
|
+
tentacleId: string,
|
|
547
|
+
suggestedSkills: string[],
|
|
548
|
+
projectStateDir?: string,
|
|
549
|
+
): DeckTentacleSummary | null => {
|
|
550
|
+
if (tentacleId.includes("..") || tentacleId.includes("/")) return null;
|
|
551
|
+
|
|
552
|
+
const contextPath = join(workspaceCwd, TENTACLES_DIR, tentacleId, "CONTEXT.md");
|
|
553
|
+
if (!existsSync(contextPath)) return null;
|
|
554
|
+
|
|
555
|
+
try {
|
|
556
|
+
const existing = readFileSync(contextPath, "utf8");
|
|
557
|
+
const updated = applySuggestedSkillsToContext(existing, suggestedSkills);
|
|
558
|
+
writeFileSync(contextPath, updated, "utf8");
|
|
559
|
+
} catch {
|
|
560
|
+
return null;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return (
|
|
564
|
+
readDeckTentacles(workspaceCwd, projectStateDir).find(
|
|
565
|
+
(tentacle) => tentacle.tentacleId === tentacleId,
|
|
566
|
+
) ?? null
|
|
567
|
+
);
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
// ─── Delete a tentacle ──────────────────────────────────────────────────────
|
|
571
|
+
|
|
572
|
+
export const deleteDeckTentacle = (
|
|
573
|
+
workspaceCwd: string,
|
|
574
|
+
tentacleId: string,
|
|
575
|
+
projectStateDir?: string,
|
|
576
|
+
): { ok: true } | { ok: false; error: string } => {
|
|
577
|
+
const stateDir = projectStateDir ?? join(workspaceCwd, ".octogent");
|
|
578
|
+
if (tentacleId.includes("..") || tentacleId.includes("/")) {
|
|
579
|
+
return { ok: false, error: "Invalid tentacle ID" };
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const tentacleDir = join(workspaceCwd, TENTACLES_DIR, tentacleId);
|
|
583
|
+
if (!existsSync(tentacleDir)) {
|
|
584
|
+
return { ok: false, error: "Tentacle not found" };
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
rmSync(tentacleDir, { recursive: true, force: true });
|
|
588
|
+
|
|
589
|
+
// Remove from deck state
|
|
590
|
+
const deckState = readDeckState(stateDir);
|
|
591
|
+
delete deckState.tentacles[tentacleId];
|
|
592
|
+
writeDeckState(stateDir, deckState);
|
|
593
|
+
|
|
594
|
+
return { ok: true };
|
|
595
|
+
};
|