@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.
Files changed (299) hide show
  1. package/README.md +1295 -0
  2. package/apps/octogent/.github/workflows/ci.yml +40 -0
  3. package/apps/octogent/.shims/claude +4 -0
  4. package/apps/octogent/AGENTS.md +71 -0
  5. package/apps/octogent/CONTRIBUTING.md +72 -0
  6. package/apps/octogent/LICENSE +21 -0
  7. package/apps/octogent/README.md +184 -0
  8. package/apps/octogent/apps/api/AGENTS.md +32 -0
  9. package/apps/octogent/apps/api/package.json +19 -0
  10. package/apps/octogent/apps/api/src/agentStateDetection.ts +181 -0
  11. package/apps/octogent/apps/api/src/claudeSessionScanner.ts +235 -0
  12. package/apps/octogent/apps/api/src/claudeSkills.ts +182 -0
  13. package/apps/octogent/apps/api/src/claudeUsage.ts +922 -0
  14. package/apps/octogent/apps/api/src/cli.ts +595 -0
  15. package/apps/octogent/apps/api/src/codeIntelStore.ts +46 -0
  16. package/apps/octogent/apps/api/src/codexUsage.ts +278 -0
  17. package/apps/octogent/apps/api/src/createApiServer/codeIntelRoutes.ts +60 -0
  18. package/apps/octogent/apps/api/src/createApiServer/conversationRoutes.ts +128 -0
  19. package/apps/octogent/apps/api/src/createApiServer/deckRoutes.ts +873 -0
  20. package/apps/octogent/apps/api/src/createApiServer/gitParsers.ts +140 -0
  21. package/apps/octogent/apps/api/src/createApiServer/gitRoutes.ts +214 -0
  22. package/apps/octogent/apps/api/src/createApiServer/miscRoutes.ts +316 -0
  23. package/apps/octogent/apps/api/src/createApiServer/monitorParsers.ts +137 -0
  24. package/apps/octogent/apps/api/src/createApiServer/monitorRoutes.ts +95 -0
  25. package/apps/octogent/apps/api/src/createApiServer/requestHandler.ts +311 -0
  26. package/apps/octogent/apps/api/src/createApiServer/requestParsers.ts +25 -0
  27. package/apps/octogent/apps/api/src/createApiServer/routeHelpers.ts +97 -0
  28. package/apps/octogent/apps/api/src/createApiServer/security.ts +70 -0
  29. package/apps/octogent/apps/api/src/createApiServer/terminalParsers.ts +167 -0
  30. package/apps/octogent/apps/api/src/createApiServer/terminalRoutes.ts +315 -0
  31. package/apps/octogent/apps/api/src/createApiServer/types.ts +24 -0
  32. package/apps/octogent/apps/api/src/createApiServer/uiStateParsers.ts +255 -0
  33. package/apps/octogent/apps/api/src/createApiServer/upgradeHandler.ts +38 -0
  34. package/apps/octogent/apps/api/src/createApiServer/usageRoutes.ts +84 -0
  35. package/apps/octogent/apps/api/src/createApiServer.ts +176 -0
  36. package/apps/octogent/apps/api/src/deck/readDeckTentacles.ts +595 -0
  37. package/apps/octogent/apps/api/src/githubRepoSummary.ts +397 -0
  38. package/apps/octogent/apps/api/src/logging.ts +9 -0
  39. package/apps/octogent/apps/api/src/monitor/defaults.ts +3 -0
  40. package/apps/octogent/apps/api/src/monitor/index.ts +8 -0
  41. package/apps/octogent/apps/api/src/monitor/repository.ts +303 -0
  42. package/apps/octogent/apps/api/src/monitor/service.ts +349 -0
  43. package/apps/octogent/apps/api/src/monitor/types.ts +120 -0
  44. package/apps/octogent/apps/api/src/monitor/xProvider.ts +587 -0
  45. package/apps/octogent/apps/api/src/projectPersistence.ts +377 -0
  46. package/apps/octogent/apps/api/src/prompts/index.ts +10 -0
  47. package/apps/octogent/apps/api/src/prompts/promptResolver.ts +145 -0
  48. package/apps/octogent/apps/api/src/runtimeMetadata.ts +69 -0
  49. package/apps/octogent/apps/api/src/server.ts +80 -0
  50. package/apps/octogent/apps/api/src/setupState.ts +80 -0
  51. package/apps/octogent/apps/api/src/setupStatus.ts +174 -0
  52. package/apps/octogent/apps/api/src/startupPrerequisites.ts +146 -0
  53. package/apps/octogent/apps/api/src/terminalRuntime/channelMessaging.ts +87 -0
  54. package/apps/octogent/apps/api/src/terminalRuntime/claudeTranscript.ts +279 -0
  55. package/apps/octogent/apps/api/src/terminalRuntime/constants.ts +15 -0
  56. package/apps/octogent/apps/api/src/terminalRuntime/conversations.ts +492 -0
  57. package/apps/octogent/apps/api/src/terminalRuntime/gitOperations.ts +341 -0
  58. package/apps/octogent/apps/api/src/terminalRuntime/hookProcessor.ts +405 -0
  59. package/apps/octogent/apps/api/src/terminalRuntime/protocol.ts +46 -0
  60. package/apps/octogent/apps/api/src/terminalRuntime/ptyEnvironment.ts +50 -0
  61. package/apps/octogent/apps/api/src/terminalRuntime/registry.ts +423 -0
  62. package/apps/octogent/apps/api/src/terminalRuntime/sessionRuntime.ts +671 -0
  63. package/apps/octogent/apps/api/src/terminalRuntime/systemClients.ts +432 -0
  64. package/apps/octogent/apps/api/src/terminalRuntime/types.ts +157 -0
  65. package/apps/octogent/apps/api/src/terminalRuntime/worktreeManager.ts +135 -0
  66. package/apps/octogent/apps/api/src/terminalRuntime.ts +567 -0
  67. package/apps/octogent/apps/api/src/usageUtils.ts +16 -0
  68. package/apps/octogent/apps/api/src/ws-shim.d.ts +28 -0
  69. package/apps/octogent/apps/api/tests/agentStateDetection.test.ts +67 -0
  70. package/apps/octogent/apps/api/tests/claudeUsage.test.ts +583 -0
  71. package/apps/octogent/apps/api/tests/codexUsage.test.ts +107 -0
  72. package/apps/octogent/apps/api/tests/createApiServer.test.ts +3207 -0
  73. package/apps/octogent/apps/api/tests/githubRepoSummary.test.ts +100 -0
  74. package/apps/octogent/apps/api/tests/logging.test.ts +33 -0
  75. package/apps/octogent/apps/api/tests/monitorApi.test.ts +467 -0
  76. package/apps/octogent/apps/api/tests/monitorCore.test.ts +104 -0
  77. package/apps/octogent/apps/api/tests/promptResolver.test.ts +109 -0
  78. package/apps/octogent/apps/api/tests/protocol.test.ts +14 -0
  79. package/apps/octogent/apps/api/tests/sessionRuntime.test.ts +608 -0
  80. package/apps/octogent/apps/api/tests/startupPrerequisites.test.ts +70 -0
  81. package/apps/octogent/apps/api/tests/upgradeHandler.test.ts +40 -0
  82. package/apps/octogent/apps/api/tests/xMonitorProvider.test.ts +109 -0
  83. package/apps/octogent/apps/api/tsconfig.json +7 -0
  84. package/apps/octogent/apps/api/vitest.config.ts +7 -0
  85. package/apps/octogent/apps/web/AGENTS.md +38 -0
  86. package/apps/octogent/apps/web/index.html +13 -0
  87. package/apps/octogent/apps/web/package.json +32 -0
  88. package/apps/octogent/apps/web/public/octopus-favicon.svg +26 -0
  89. package/apps/octogent/apps/web/src/App.tsx +646 -0
  90. package/apps/octogent/apps/web/src/app/canvas/types.ts +34 -0
  91. package/apps/octogent/apps/web/src/app/codeIntelAggregation.ts +278 -0
  92. package/apps/octogent/apps/web/src/app/constants.ts +28 -0
  93. package/apps/octogent/apps/web/src/app/conversationNormalizers.ts +135 -0
  94. package/apps/octogent/apps/web/src/app/formatTimestamp.ts +18 -0
  95. package/apps/octogent/apps/web/src/app/githubMetrics.ts +76 -0
  96. package/apps/octogent/apps/web/src/app/githubNormalizers.ts +91 -0
  97. package/apps/octogent/apps/web/src/app/hooks/useAgentRuntimeStates.ts +18 -0
  98. package/apps/octogent/apps/web/src/app/hooks/useBackendLivenessPolling.ts +53 -0
  99. package/apps/octogent/apps/web/src/app/hooks/useCanvasGraphData.ts +449 -0
  100. package/apps/octogent/apps/web/src/app/hooks/useCanvasTransform.ts +260 -0
  101. package/apps/octogent/apps/web/src/app/hooks/useClaudeUsagePolling.ts +40 -0
  102. package/apps/octogent/apps/web/src/app/hooks/useClickOutside.ts +30 -0
  103. package/apps/octogent/apps/web/src/app/hooks/useCodeIntelRuntime.ts +83 -0
  104. package/apps/octogent/apps/web/src/app/hooks/useCodexUsagePolling.ts +35 -0
  105. package/apps/octogent/apps/web/src/app/hooks/useConsoleKeyboardShortcuts.ts +31 -0
  106. package/apps/octogent/apps/web/src/app/hooks/useConversationsRuntime.ts +377 -0
  107. package/apps/octogent/apps/web/src/app/hooks/useForceSimulation.ts +319 -0
  108. package/apps/octogent/apps/web/src/app/hooks/useGitHubPrimaryViewModel.ts +143 -0
  109. package/apps/octogent/apps/web/src/app/hooks/useGithubSummaryPolling.ts +28 -0
  110. package/apps/octogent/apps/web/src/app/hooks/useInitialColumnsHydration.ts +64 -0
  111. package/apps/octogent/apps/web/src/app/hooks/useMonitorRuntime.ts +220 -0
  112. package/apps/octogent/apps/web/src/app/hooks/usePersistedUiState.ts +536 -0
  113. package/apps/octogent/apps/web/src/app/hooks/usePollingData.ts +79 -0
  114. package/apps/octogent/apps/web/src/app/hooks/usePromptLibrary.ts +185 -0
  115. package/apps/octogent/apps/web/src/app/hooks/useTentacleGitLifecycle.ts +530 -0
  116. package/apps/octogent/apps/web/src/app/hooks/useTerminalCompletionNotification.ts +94 -0
  117. package/apps/octogent/apps/web/src/app/hooks/useTerminalMutations.ts +266 -0
  118. package/apps/octogent/apps/web/src/app/hooks/useTerminalStateReconciliation.ts +23 -0
  119. package/apps/octogent/apps/web/src/app/hooks/useUsageHeatmapPolling.ts +43 -0
  120. package/apps/octogent/apps/web/src/app/hooks/useWorkspaceSetup.ts +80 -0
  121. package/apps/octogent/apps/web/src/app/hotkeys.ts +31 -0
  122. package/apps/octogent/apps/web/src/app/monitorNormalizers.ts +145 -0
  123. package/apps/octogent/apps/web/src/app/notificationSounds.ts +164 -0
  124. package/apps/octogent/apps/web/src/app/terminalRuntimeStateStore.ts +261 -0
  125. package/apps/octogent/apps/web/src/app/terminalState.ts +21 -0
  126. package/apps/octogent/apps/web/src/app/types.ts +42 -0
  127. package/apps/octogent/apps/web/src/app/uiStateNormalizers.ts +113 -0
  128. package/apps/octogent/apps/web/src/app/usageNormalizers.ts +58 -0
  129. package/apps/octogent/apps/web/src/components/ActiveAgentsSidebar.tsx +60 -0
  130. package/apps/octogent/apps/web/src/components/ActivityPrimaryView.tsx +21 -0
  131. package/apps/octogent/apps/web/src/components/AgentStateBadge.tsx +47 -0
  132. package/apps/octogent/apps/web/src/components/CanvasPrimaryView.tsx +1532 -0
  133. package/apps/octogent/apps/web/src/components/ClearAllConversationsDialog.tsx +33 -0
  134. package/apps/octogent/apps/web/src/components/CodeIntelArcDiagram.tsx +245 -0
  135. package/apps/octogent/apps/web/src/components/CodeIntelPrimaryView.tsx +104 -0
  136. package/apps/octogent/apps/web/src/components/CodeIntelTreemap.tsx +138 -0
  137. package/apps/octogent/apps/web/src/components/ConsolePrimaryNav.tsx +31 -0
  138. package/apps/octogent/apps/web/src/components/ConversationsPrimaryView.tsx +243 -0
  139. package/apps/octogent/apps/web/src/components/DeckPrimaryView.tsx +613 -0
  140. package/apps/octogent/apps/web/src/components/DeleteTentacleDialog.tsx +91 -0
  141. package/apps/octogent/apps/web/src/components/EmptyOctopus.tsx +715 -0
  142. package/apps/octogent/apps/web/src/components/GitHubPrimaryView.tsx +494 -0
  143. package/apps/octogent/apps/web/src/components/MonitorPrimaryView.tsx +475 -0
  144. package/apps/octogent/apps/web/src/components/PrimaryViewRouter.tsx +99 -0
  145. package/apps/octogent/apps/web/src/components/PromptsPrimaryView.tsx +243 -0
  146. package/apps/octogent/apps/web/src/components/RuntimeStatusStrip.tsx +273 -0
  147. package/apps/octogent/apps/web/src/components/SettingsPrimaryView.tsx +92 -0
  148. package/apps/octogent/apps/web/src/components/SidebarActionPanel.tsx +124 -0
  149. package/apps/octogent/apps/web/src/components/SidebarConversationsList.tsx +279 -0
  150. package/apps/octogent/apps/web/src/components/SidebarPromptsList.tsx +116 -0
  151. package/apps/octogent/apps/web/src/components/TelemetryTape.tsx +106 -0
  152. package/apps/octogent/apps/web/src/components/TentacleGitActionsDialog.tsx +341 -0
  153. package/apps/octogent/apps/web/src/components/Terminal.tsx +524 -0
  154. package/apps/octogent/apps/web/src/components/TerminalPromptPicker.tsx +140 -0
  155. package/apps/octogent/apps/web/src/components/UsageHeatmap.tsx +702 -0
  156. package/apps/octogent/apps/web/src/components/canvas/CanvasTentaclePanel.tsx +485 -0
  157. package/apps/octogent/apps/web/src/components/canvas/CanvasTerminalColumn.tsx +89 -0
  158. package/apps/octogent/apps/web/src/components/canvas/DeleteAllTerminalsDialog.tsx +221 -0
  159. package/apps/octogent/apps/web/src/components/canvas/OctopusNode.tsx +307 -0
  160. package/apps/octogent/apps/web/src/components/canvas/SessionNode.tsx +185 -0
  161. package/apps/octogent/apps/web/src/components/deck/ActionCards.tsx +118 -0
  162. package/apps/octogent/apps/web/src/components/deck/AddTentacleForm.tsx +269 -0
  163. package/apps/octogent/apps/web/src/components/deck/DeckBottomActions.tsx +56 -0
  164. package/apps/octogent/apps/web/src/components/deck/TentaclePod.tsx +334 -0
  165. package/apps/octogent/apps/web/src/components/deck/WorkspaceSetupCard.tsx +105 -0
  166. package/apps/octogent/apps/web/src/components/deck/octopusVisuals.ts +72 -0
  167. package/apps/octogent/apps/web/src/components/terminalReplay.ts +62 -0
  168. package/apps/octogent/apps/web/src/components/terminalWheel.ts +54 -0
  169. package/apps/octogent/apps/web/src/components/ui/ActionButton.tsx +34 -0
  170. package/apps/octogent/apps/web/src/components/ui/ConfirmationDialog.tsx +86 -0
  171. package/apps/octogent/apps/web/src/components/ui/MarkdownContent.tsx +43 -0
  172. package/apps/octogent/apps/web/src/components/ui/SettingsToggle.tsx +34 -0
  173. package/apps/octogent/apps/web/src/components/ui/StatusBadge.tsx +24 -0
  174. package/apps/octogent/apps/web/src/main.tsx +17 -0
  175. package/apps/octogent/apps/web/src/runtime/HttpTerminalSnapshotReader.ts +87 -0
  176. package/apps/octogent/apps/web/src/runtime/runtimeEndpoints.ts +412 -0
  177. package/apps/octogent/apps/web/src/styles/chrome-and-buttons.css +272 -0
  178. package/apps/octogent/apps/web/src/styles/console-canvas-activity.css +358 -0
  179. package/apps/octogent/apps/web/src/styles/console-canvas-canvas.css +1843 -0
  180. package/apps/octogent/apps/web/src/styles/console-canvas-code-intel.css +227 -0
  181. package/apps/octogent/apps/web/src/styles/console-canvas-conversations.css +705 -0
  182. package/apps/octogent/apps/web/src/styles/console-canvas-deck.css +1524 -0
  183. package/apps/octogent/apps/web/src/styles/console-canvas-github.css +541 -0
  184. package/apps/octogent/apps/web/src/styles/console-canvas-monitor.css +595 -0
  185. package/apps/octogent/apps/web/src/styles/console-canvas-pixpack.css +81 -0
  186. package/apps/octogent/apps/web/src/styles/console-canvas-prompts.css +474 -0
  187. package/apps/octogent/apps/web/src/styles/console-canvas-settings.css +207 -0
  188. package/apps/octogent/apps/web/src/styles/console-chrome-status-nav.css +441 -0
  189. package/apps/octogent/apps/web/src/styles/console-overrides-telemetry.css +320 -0
  190. package/apps/octogent/apps/web/src/styles/console-theme-tokens.css +25 -0
  191. package/apps/octogent/apps/web/src/styles/cortex-theme.css +412 -0
  192. package/apps/octogent/apps/web/src/styles/foundation.css +100 -0
  193. package/apps/octogent/apps/web/src/styles/sidebar-and-scrollbars.css +447 -0
  194. package/apps/octogent/apps/web/src/styles/terminal-and-status.css +356 -0
  195. package/apps/octogent/apps/web/src/styles.css +25 -0
  196. package/apps/octogent/apps/web/src/types/ws.d.ts +23 -0
  197. package/apps/octogent/apps/web/tests/CanvasPrimaryView.test.tsx +347 -0
  198. package/apps/octogent/apps/web/tests/HttpTerminalSnapshotReader.test.tsx +54 -0
  199. package/apps/octogent/apps/web/tests/RuntimeStatusStrip.test.tsx +70 -0
  200. package/apps/octogent/apps/web/tests/Terminal.test.tsx +87 -0
  201. package/apps/octogent/apps/web/tests/add-tentacle-form.test.tsx +48 -0
  202. package/apps/octogent/apps/web/tests/app-github-runtime.test.tsx +162 -0
  203. package/apps/octogent/apps/web/tests/app-monitor-runtime.test.tsx +657 -0
  204. package/apps/octogent/apps/web/tests/app-shell-navigation.test.tsx +109 -0
  205. package/apps/octogent/apps/web/tests/app-swarm-refresh.test.tsx +268 -0
  206. package/apps/octogent/apps/web/tests/app-ui-state-persistence.test.tsx +116 -0
  207. package/apps/octogent/apps/web/tests/app-workspace-setup.test.tsx +217 -0
  208. package/apps/octogent/apps/web/tests/canvas-tentacle-panel.test.tsx +195 -0
  209. package/apps/octogent/apps/web/tests/delete-all-terminals-dialog.test.tsx +76 -0
  210. package/apps/octogent/apps/web/tests/githubMetrics.test.tsx +52 -0
  211. package/apps/octogent/apps/web/tests/hotkeys.test.tsx +44 -0
  212. package/apps/octogent/apps/web/tests/runtimeEndpoints.test.tsx +240 -0
  213. package/apps/octogent/apps/web/tests/setup.ts +39 -0
  214. package/apps/octogent/apps/web/tests/tentacle-pod.test.tsx +62 -0
  215. package/apps/octogent/apps/web/tests/terminalReplay.test.ts +71 -0
  216. package/apps/octogent/apps/web/tests/terminalState.test.tsx +49 -0
  217. package/apps/octogent/apps/web/tests/terminalWheel.test.tsx +51 -0
  218. package/apps/octogent/apps/web/tests/test-utils/appTestHarness.ts +48 -0
  219. package/apps/octogent/apps/web/tests/uiPrimitives.test.tsx +31 -0
  220. package/apps/octogent/apps/web/tests/useAgentRuntimeStates.test.tsx +47 -0
  221. package/apps/octogent/apps/web/tsconfig.json +8 -0
  222. package/apps/octogent/apps/web/vite.api.bundle.config.mts +32 -0
  223. package/apps/octogent/apps/web/vite.config.ts +22 -0
  224. package/apps/octogent/bin/octogent +3 -0
  225. package/apps/octogent/biome.json +21 -0
  226. package/apps/octogent/docs/concepts/mental-model.md +79 -0
  227. package/apps/octogent/docs/concepts/runtime-and-api.md +60 -0
  228. package/apps/octogent/docs/concepts/tentacles.md +85 -0
  229. package/apps/octogent/docs/getting-started/installation.md +54 -0
  230. package/apps/octogent/docs/getting-started/quickstart.md +79 -0
  231. package/apps/octogent/docs/guides/inter-agent-messaging.md +43 -0
  232. package/apps/octogent/docs/guides/orchestrating-child-agents.md +49 -0
  233. package/apps/octogent/docs/guides/working-with-todos.md +56 -0
  234. package/apps/octogent/docs/index.md +40 -0
  235. package/apps/octogent/docs/reference/api.md +103 -0
  236. package/apps/octogent/docs/reference/cli.md +71 -0
  237. package/apps/octogent/docs/reference/experimental-features.md +28 -0
  238. package/apps/octogent/docs/reference/filesystem-layout.md +62 -0
  239. package/apps/octogent/docs/reference/troubleshooting.md +49 -0
  240. package/apps/octogent/package.json +35 -0
  241. package/apps/octogent/packages/core/AGENTS.md +31 -0
  242. package/apps/octogent/packages/core/package.json +12 -0
  243. package/apps/octogent/packages/core/src/adapters/InMemoryTerminalSnapshotReader.ts +10 -0
  244. package/apps/octogent/packages/core/src/application/buildTerminalList.ts +13 -0
  245. package/apps/octogent/packages/core/src/domain/agentRuntime.ts +18 -0
  246. package/apps/octogent/packages/core/src/domain/channel.ts +8 -0
  247. package/apps/octogent/packages/core/src/domain/completionSound.ts +14 -0
  248. package/apps/octogent/packages/core/src/domain/conversation.ts +48 -0
  249. package/apps/octogent/packages/core/src/domain/deck.ts +33 -0
  250. package/apps/octogent/packages/core/src/domain/git.ts +32 -0
  251. package/apps/octogent/packages/core/src/domain/monitor.ts +62 -0
  252. package/apps/octogent/packages/core/src/domain/setup.ts +27 -0
  253. package/apps/octogent/packages/core/src/domain/terminal.ts +17 -0
  254. package/apps/octogent/packages/core/src/domain/uiState.ts +22 -0
  255. package/apps/octogent/packages/core/src/domain/usage.ts +60 -0
  256. package/apps/octogent/packages/core/src/index.ts +15 -0
  257. package/apps/octogent/packages/core/src/ports/TerminalSnapshotReader.ts +5 -0
  258. package/apps/octogent/packages/core/src/util/typeCoercion.ts +20 -0
  259. package/apps/octogent/packages/core/tests/buildTerminalList.test.ts +75 -0
  260. package/apps/octogent/packages/core/tsconfig.json +7 -0
  261. package/apps/octogent/packages/core/tsconfig.tsbuildinfo +1 -0
  262. package/apps/octogent/packages/core/vitest.config.ts +7 -0
  263. package/apps/octogent/pnpm-lock.yaml +3212 -0
  264. package/apps/octogent/pnpm-workspace.yaml +3 -0
  265. package/apps/octogent/prompts/meta-prompt-generator.md +223 -0
  266. package/apps/octogent/prompts/octoboss-clean-contexts.md +30 -0
  267. package/apps/octogent/prompts/octoboss-reorganize-tentacles.md +29 -0
  268. package/apps/octogent/prompts/octoboss-reorganize-todos.md +27 -0
  269. package/apps/octogent/prompts/sandbox-init.md +3 -0
  270. package/apps/octogent/prompts/swarm-parent.md +83 -0
  271. package/apps/octogent/prompts/swarm-worker.md +50 -0
  272. package/apps/octogent/prompts/tentacle-context-init.md +1 -0
  273. package/apps/octogent/prompts/tentacle-planner.md +110 -0
  274. package/apps/octogent/prompts/tentacle-reorganize-todos.md +20 -0
  275. package/apps/octogent/prompts/tentacle-update-tentacle.md +18 -0
  276. package/apps/octogent/scripts/build-package.mjs +23 -0
  277. package/apps/octogent/scripts/dev.mjs +158 -0
  278. package/apps/octogent/scripts/smoke-public-install.mjs +271 -0
  279. package/apps/octogent/static/images/octogent-header.png +0 -0
  280. package/apps/octogent/static/images/preview_1.jpg +0 -0
  281. package/apps/octogent/static/images/preview_2.jpg +0 -0
  282. package/apps/octogent/static/images/preview_3.jpg +0 -0
  283. package/apps/octogent/static/images/preview_4.jpg +0 -0
  284. package/apps/octogent/static/images/preview_5.jpg +0 -0
  285. package/apps/octogent/static/images/preview_6.jpg +0 -0
  286. package/apps/octogent/tsconfig.base.json +16 -0
  287. package/bin/AGI +3 -0
  288. package/bin/AGI-install-app +71 -0
  289. package/bin/AGI-ui +16 -0
  290. package/bin/AGI-voice +15 -0
  291. package/bin/AGI-web +16 -0
  292. package/bin/cortex +109 -0
  293. package/bin/cortex-octogent +99 -0
  294. package/bin/import-specifier.mjs +13 -0
  295. package/bin/import-specifier.test.mjs +13 -0
  296. package/bin/octo +150 -0
  297. package/dist/cli.mjs +555650 -0
  298. package/package.json +157 -0
  299. package/scripts/setup-wizard.ts +390 -0
@@ -0,0 +1,432 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { mkdirSync } from "node:fs";
3
+ import { dirname } from "node:path";
4
+
5
+ import type { GitClient } from "./types";
6
+
7
+ export const toErrorMessage = (error: unknown) =>
8
+ error instanceof Error ? error.message : String(error);
9
+
10
+ const runGitCommand = (cwd: string, args: string[]): string =>
11
+ execFileSync("git", args, {
12
+ cwd,
13
+ encoding: "utf8",
14
+ stdio: "pipe",
15
+ }).trim();
16
+
17
+ const readOptionalGitCommand = (cwd: string, args: string[]) => {
18
+ try {
19
+ return runGitCommand(cwd, args);
20
+ } catch {
21
+ return null;
22
+ }
23
+ };
24
+
25
+ const isExitCode = (error: unknown, exitCode: number) => {
26
+ if (typeof error !== "object" || error === null) {
27
+ return false;
28
+ }
29
+ const errorWithStatus = error as { status?: unknown };
30
+ return errorWithStatus.status === exitCode;
31
+ };
32
+
33
+ const CONFLICT_MARKERS = new Set(["DD", "AU", "UD", "UA", "DU", "AA", "UU"]);
34
+
35
+ const parseChangedFile = (line: string) => {
36
+ const payload = line.slice(3).trim();
37
+ if (!payload) {
38
+ return null;
39
+ }
40
+
41
+ const renameMarker = " -> ";
42
+ const renameIndex = payload.indexOf(renameMarker);
43
+ if (renameIndex === -1) {
44
+ return payload;
45
+ }
46
+
47
+ return payload.slice(renameIndex + renameMarker.length).trim();
48
+ };
49
+
50
+ const parseDiffNumstatLineCounts = (
51
+ numstatOutput: string,
52
+ ): { insertedLineCount: number; deletedLineCount: number } =>
53
+ numstatOutput
54
+ .split("\n")
55
+ .map((line) => line.trim())
56
+ .filter((line) => line.length > 0)
57
+ .reduce(
58
+ (totals, line) => {
59
+ const [rawInserted, rawDeleted] = line.split("\t");
60
+ const parsedInserted = Number.parseInt(rawInserted ?? "0", 10);
61
+ const parsedDeleted = Number.parseInt(rawDeleted ?? "0", 10);
62
+ return {
63
+ insertedLineCount:
64
+ totals.insertedLineCount + (Number.isFinite(parsedInserted) ? parsedInserted : 0),
65
+ deletedLineCount:
66
+ totals.deletedLineCount + (Number.isFinite(parsedDeleted) ? parsedDeleted : 0),
67
+ };
68
+ },
69
+ { insertedLineCount: 0, deletedLineCount: 0 },
70
+ );
71
+
72
+ const runGhCommand = (cwd: string, args: string[]): string =>
73
+ execFileSync("gh", args, {
74
+ cwd,
75
+ encoding: "utf8",
76
+ stdio: "pipe",
77
+ }).trim();
78
+
79
+ const readErrorDetails = (error: unknown) => {
80
+ if (typeof error !== "object" || error === null) {
81
+ return "";
82
+ }
83
+
84
+ const errorWithStreams = error as { stderr?: unknown; message?: unknown };
85
+ const stderr =
86
+ typeof errorWithStreams.stderr === "string"
87
+ ? errorWithStreams.stderr
88
+ : Buffer.isBuffer(errorWithStreams.stderr)
89
+ ? errorWithStreams.stderr.toString("utf8")
90
+ : "";
91
+ if (stderr.trim().length > 0) {
92
+ return stderr.trim();
93
+ }
94
+
95
+ return typeof errorWithStreams.message === "string" ? errorWithStreams.message : "";
96
+ };
97
+
98
+ const readGhFailureMessage = (error: unknown) => {
99
+ if (typeof error === "object" && error !== null) {
100
+ const errorWithCode = error as { code?: unknown };
101
+ if (errorWithCode.code === "ENOENT") {
102
+ return "GitHub CLI not found. Install `gh` and run `gh auth login`.";
103
+ }
104
+ }
105
+
106
+ const details = readErrorDetails(error).toLowerCase();
107
+ if (details.includes("not logged in")) {
108
+ return "GitHub CLI is not authenticated. Run `gh auth login`.";
109
+ }
110
+ if (details.includes("error connecting to api.github.com")) {
111
+ return "Unable to reach api.github.com from this environment.";
112
+ }
113
+ return null;
114
+ };
115
+
116
+ const isNoPullRequestError = (error: unknown) => {
117
+ const details = readErrorDetails(error).toLowerCase();
118
+ return (
119
+ details.includes("no pull requests found") ||
120
+ details.includes("could not find any pull requests") ||
121
+ details.includes("no open pull requests")
122
+ );
123
+ };
124
+
125
+ const parsePullRequestPayload = (
126
+ payload: unknown,
127
+ ): {
128
+ number: number;
129
+ url: string;
130
+ title: string;
131
+ baseRef: string;
132
+ headRef: string;
133
+ state: "OPEN" | "MERGED" | "CLOSED";
134
+ isDraft: boolean;
135
+ mergeable: "MERGEABLE" | "CONFLICTING" | "UNKNOWN";
136
+ mergeStateStatus: string | null;
137
+ } => {
138
+ if (payload === null || payload === undefined || typeof payload !== "object") {
139
+ throw new Error("Invalid PR payload from gh.");
140
+ }
141
+
142
+ const record = payload as Record<string, unknown>;
143
+ const number = Number.parseInt(String(record.number ?? ""), 10);
144
+ const url = typeof record.url === "string" ? record.url : "";
145
+ const title = typeof record.title === "string" ? record.title : "";
146
+ const baseRef = typeof record.baseRefName === "string" ? record.baseRefName : "";
147
+ const headRef = typeof record.headRefName === "string" ? record.headRefName : "";
148
+ const stateRaw = typeof record.state === "string" ? record.state.toUpperCase() : "";
149
+ const mergeableRaw = typeof record.mergeable === "string" ? record.mergeable.toUpperCase() : "";
150
+
151
+ const state =
152
+ stateRaw === "OPEN" || stateRaw === "MERGED" || stateRaw === "CLOSED" ? stateRaw : "OPEN";
153
+ const mergeable =
154
+ mergeableRaw === "MERGEABLE" || mergeableRaw === "CONFLICTING" || mergeableRaw === "UNKNOWN"
155
+ ? mergeableRaw
156
+ : "UNKNOWN";
157
+
158
+ if (!Number.isFinite(number) || url.length === 0 || title.length === 0) {
159
+ throw new Error("Missing PR fields from gh.");
160
+ }
161
+
162
+ return {
163
+ number,
164
+ url,
165
+ title,
166
+ baseRef,
167
+ headRef,
168
+ state,
169
+ isDraft: Boolean(record.isDraft),
170
+ mergeable,
171
+ mergeStateStatus: typeof record.mergeStateStatus === "string" ? record.mergeStateStatus : null,
172
+ };
173
+ };
174
+
175
+ const readPullRequestWithGh = (cwd: string, args: string[]) => {
176
+ const output = runGhCommand(cwd, [
177
+ "pr",
178
+ "view",
179
+ ...args,
180
+ "--json",
181
+ "number,url,title,state,isDraft,baseRefName,headRefName,mergeable,mergeStateStatus",
182
+ ]);
183
+ return parsePullRequestPayload(JSON.parse(output));
184
+ };
185
+
186
+ export const createDefaultGitClient = (): GitClient => ({
187
+ assertAvailable() {
188
+ try {
189
+ execFileSync("git", ["--version"], { stdio: "ignore" });
190
+ } catch (error) {
191
+ throw new Error(`git is required for worktree tentacles: ${toErrorMessage(error)}`);
192
+ }
193
+ },
194
+
195
+ isRepository(cwd) {
196
+ try {
197
+ const output = execFileSync("git", ["rev-parse", "--is-inside-work-tree"], {
198
+ cwd,
199
+ encoding: "utf8",
200
+ stdio: "pipe",
201
+ });
202
+ return output.trim() === "true";
203
+ } catch {
204
+ return false;
205
+ }
206
+ },
207
+
208
+ addWorktree({ cwd, path, branchName, baseRef }) {
209
+ mkdirSync(dirname(path), { recursive: true });
210
+ execFileSync("git", ["worktree", "add", "-b", branchName, path, baseRef], {
211
+ cwd,
212
+ stdio: "pipe",
213
+ });
214
+ },
215
+
216
+ removeWorktree({ cwd, path }) {
217
+ execFileSync("git", ["worktree", "remove", "--force", path], {
218
+ cwd,
219
+ stdio: "pipe",
220
+ });
221
+ },
222
+
223
+ removeBranch({ cwd, branchName }) {
224
+ const output = execFileSync(
225
+ "git",
226
+ ["branch", "--list", "--format=%(refname:short)", branchName],
227
+ {
228
+ cwd,
229
+ encoding: "utf8",
230
+ stdio: "pipe",
231
+ },
232
+ );
233
+ const existingBranches = output
234
+ .split("\n")
235
+ .map((line) => line.trim())
236
+ .filter((line) => line.length > 0);
237
+ if (!existingBranches.includes(branchName)) {
238
+ return;
239
+ }
240
+
241
+ execFileSync("git", ["branch", "-D", branchName], {
242
+ cwd,
243
+ stdio: "pipe",
244
+ });
245
+ },
246
+
247
+ readWorktreeStatus({ cwd }) {
248
+ const branchName = runGitCommand(cwd, ["rev-parse", "--abbrev-ref", "HEAD"]);
249
+ const hasHeadCommit = readOptionalGitCommand(cwd, ["rev-parse", "--verify", "HEAD"]) !== null;
250
+ const upstreamBranchName = readOptionalGitCommand(cwd, [
251
+ "rev-parse",
252
+ "--abbrev-ref",
253
+ "--symbolic-full-name",
254
+ "@{upstream}",
255
+ ]);
256
+ const porcelain = readOptionalGitCommand(cwd, ["status", "--porcelain"]) ?? "";
257
+ const statusLines = porcelain
258
+ .split("\n")
259
+ .map((line) => line.trimEnd())
260
+ .filter((line) => line.length > 0);
261
+ const changedFiles = statusLines
262
+ .map((line) => parseChangedFile(line))
263
+ .filter((line): line is string => Boolean(line));
264
+ const hasConflicts = statusLines.some((line) => CONFLICT_MARKERS.has(line.slice(0, 2)));
265
+ const lineDiffNumstat = hasHeadCommit
266
+ ? (readOptionalGitCommand(cwd, ["diff", "--numstat", "HEAD", "--"]) ?? "")
267
+ : [
268
+ readOptionalGitCommand(cwd, ["diff", "--numstat", "--cached", "--"]) ?? "",
269
+ readOptionalGitCommand(cwd, ["diff", "--numstat", "--"]) ?? "",
270
+ ]
271
+ .filter((line) => line.length > 0)
272
+ .join("\n");
273
+ const { insertedLineCount, deletedLineCount } = parseDiffNumstatLineCounts(lineDiffNumstat);
274
+
275
+ let aheadCount = 0;
276
+ let behindCount = 0;
277
+ if (upstreamBranchName) {
278
+ const counts = runGitCommand(cwd, [
279
+ "rev-list",
280
+ "--left-right",
281
+ "--count",
282
+ `${upstreamBranchName}...HEAD`,
283
+ ]);
284
+ const [rawBehind, rawAhead] = counts.split(/\s+/);
285
+ const parsedBehind = Number.parseInt(rawBehind ?? "0", 10);
286
+ const parsedAhead = Number.parseInt(rawAhead ?? "0", 10);
287
+ behindCount = Number.isFinite(parsedBehind) ? parsedBehind : 0;
288
+ aheadCount = Number.isFinite(parsedAhead) ? parsedAhead : 0;
289
+ }
290
+
291
+ const remoteHead = readOptionalGitCommand(cwd, [
292
+ "symbolic-ref",
293
+ "--quiet",
294
+ "--short",
295
+ "refs/remotes/origin/HEAD",
296
+ ]);
297
+ const defaultBaseBranchName = remoteHead?.startsWith("origin/")
298
+ ? remoteHead.slice("origin/".length)
299
+ : null;
300
+
301
+ return {
302
+ branchName,
303
+ upstreamBranchName,
304
+ isDirty: statusLines.length > 0,
305
+ aheadCount,
306
+ behindCount,
307
+ insertedLineCount,
308
+ deletedLineCount,
309
+ hasConflicts,
310
+ changedFiles,
311
+ defaultBaseBranchName,
312
+ };
313
+ },
314
+
315
+ commitAll({ cwd, message }) {
316
+ execFileSync("git", ["add", "--all"], {
317
+ cwd,
318
+ stdio: "pipe",
319
+ });
320
+ try {
321
+ execFileSync("git", ["diff", "--cached", "--quiet"], {
322
+ cwd,
323
+ stdio: "pipe",
324
+ });
325
+ throw new Error("No local changes to commit.");
326
+ } catch (error) {
327
+ if (!isExitCode(error, 1)) {
328
+ if (error instanceof Error && error.message === "No local changes to commit.") {
329
+ throw error;
330
+ }
331
+ throw new Error(`Unable to prepare commit: ${toErrorMessage(error)}`);
332
+ }
333
+ }
334
+
335
+ execFileSync("git", ["commit", "-m", message], {
336
+ cwd,
337
+ stdio: "pipe",
338
+ });
339
+ },
340
+
341
+ pushCurrentBranch({ cwd }) {
342
+ const upstreamBranchName = readOptionalGitCommand(cwd, [
343
+ "rev-parse",
344
+ "--abbrev-ref",
345
+ "--symbolic-full-name",
346
+ "@{upstream}",
347
+ ]);
348
+
349
+ if (upstreamBranchName) {
350
+ execFileSync("git", ["push"], {
351
+ cwd,
352
+ stdio: "pipe",
353
+ });
354
+ return;
355
+ }
356
+
357
+ execFileSync("git", ["push", "--set-upstream", "origin", "HEAD"], {
358
+ cwd,
359
+ stdio: "pipe",
360
+ });
361
+ },
362
+
363
+ syncWithBase({ cwd, baseRef }) {
364
+ execFileSync("git", ["fetch", "origin", baseRef], {
365
+ cwd,
366
+ stdio: "pipe",
367
+ });
368
+ execFileSync("git", ["rebase", `origin/${baseRef}`], {
369
+ cwd,
370
+ stdio: "pipe",
371
+ });
372
+ },
373
+
374
+ readCurrentBranchPullRequest({ cwd }) {
375
+ try {
376
+ return readPullRequestWithGh(cwd, []);
377
+ } catch (error) {
378
+ if (isNoPullRequestError(error)) {
379
+ return null;
380
+ }
381
+
382
+ const ghFailureMessage = readGhFailureMessage(error);
383
+ if (ghFailureMessage) {
384
+ throw new Error(ghFailureMessage);
385
+ }
386
+
387
+ throw new Error(`Unable to read pull request: ${toErrorMessage(error)}`);
388
+ }
389
+ },
390
+
391
+ createPullRequest({ cwd, title, body, baseRef, headRef }) {
392
+ try {
393
+ const url = runGhCommand(cwd, [
394
+ "pr",
395
+ "create",
396
+ "--title",
397
+ title,
398
+ "--body",
399
+ body,
400
+ "--base",
401
+ baseRef,
402
+ "--head",
403
+ headRef,
404
+ ]);
405
+ if (url.length === 0) {
406
+ throw new Error("GitHub CLI did not return a pull request URL.");
407
+ }
408
+ return readPullRequestWithGh(cwd, [url]);
409
+ } catch (error) {
410
+ const ghFailureMessage = readGhFailureMessage(error);
411
+ if (ghFailureMessage) {
412
+ throw new Error(ghFailureMessage);
413
+ }
414
+
415
+ throw new Error(`Unable to create pull request: ${toErrorMessage(error)}`);
416
+ }
417
+ },
418
+
419
+ mergeCurrentBranchPullRequest({ cwd, strategy }) {
420
+ try {
421
+ const strategyArg =
422
+ strategy === "merge" ? "--merge" : strategy === "rebase" ? "--rebase" : "--squash";
423
+ runGhCommand(cwd, ["pr", "merge", strategyArg, "--delete-branch=false"]);
424
+ } catch (error) {
425
+ const ghFailureMessage = readGhFailureMessage(error);
426
+ if (ghFailureMessage) {
427
+ throw new Error(ghFailureMessage);
428
+ }
429
+ throw new Error(`Unable to merge pull request: ${toErrorMessage(error)}`);
430
+ }
431
+ },
432
+ });
@@ -0,0 +1,157 @@
1
+ import type { WriteStream } from "node:fs";
2
+
3
+ import type {
4
+ ChannelMessage,
5
+ PersistedUiState,
6
+ TentacleGitStatusSnapshot,
7
+ TentaclePullRequestSnapshot,
8
+ TentacleWorkspaceMode,
9
+ TerminalAgentProvider,
10
+ } from "@octogent/core";
11
+ import { isTerminalAgentProvider, isTerminalCompletionSoundId } from "@octogent/core";
12
+ import type { IPty } from "node-pty";
13
+ import type { WebSocket } from "ws";
14
+
15
+ import type { AgentRuntimeState, AgentStateTracker } from "../agentStateDetection";
16
+
17
+ export type TerminalStateMessage = {
18
+ type: "state";
19
+ state: AgentRuntimeState;
20
+ toolName?: string;
21
+ };
22
+
23
+ export type TerminalOutputMessage = {
24
+ type: "output";
25
+ data: string;
26
+ };
27
+
28
+ export type TerminalHistoryMessage = {
29
+ type: "history";
30
+ data: string;
31
+ };
32
+
33
+ export type TerminalRenameMessage = {
34
+ type: "rename";
35
+ tentacleName: string;
36
+ };
37
+
38
+ export type TerminalActivityMessage = {
39
+ type: "activity";
40
+ };
41
+
42
+ export type TerminalServerMessage =
43
+ | TerminalStateMessage
44
+ | TerminalOutputMessage
45
+ | TerminalHistoryMessage
46
+ | TerminalRenameMessage
47
+ | TerminalActivityMessage;
48
+
49
+ export type DirectSessionListener = (message: TerminalServerMessage) => void;
50
+
51
+ export type TerminalSession = {
52
+ terminalId: string;
53
+ tentacleId: string;
54
+ pty: IPty;
55
+ clients: Set<WebSocket>;
56
+ directListeners: Set<DirectSessionListener>;
57
+ cols: number;
58
+ rows: number;
59
+ agentState: AgentRuntimeState;
60
+ stateTracker: AgentStateTracker;
61
+ isBootstrapCommandSent: boolean;
62
+ scrollbackChunks: string[];
63
+ scrollbackBytes: number;
64
+ statePollTimer?: ReturnType<typeof setInterval>;
65
+ idleCloseTimer?: ReturnType<typeof setTimeout> | undefined;
66
+ debugLog?: WriteStream;
67
+ transcriptLog?: WriteStream | undefined;
68
+ transcriptEventCount?: number;
69
+ pendingInput?: string;
70
+ hasTranscriptEnded?: boolean;
71
+ initialPrompt?: string;
72
+ isInitialPromptSent?: boolean;
73
+ initialInputDraft?: string;
74
+ isInitialInputDraftSent?: boolean;
75
+ keepAliveWithoutClients?: boolean;
76
+ hasSeenProcessing?: boolean;
77
+ lastToolName?: string | undefined;
78
+ };
79
+
80
+ export type TerminalNameOrigin = "generated" | "user" | "prompt";
81
+
82
+ export {
83
+ type ChannelMessage,
84
+ type PersistedUiState,
85
+ type TentacleGitStatusSnapshot,
86
+ type TentaclePullRequestSnapshot,
87
+ type TentacleWorkspaceMode,
88
+ type TerminalAgentProvider,
89
+ isTerminalAgentProvider,
90
+ isTerminalCompletionSoundId,
91
+ };
92
+
93
+ export type PersistedTerminal = {
94
+ terminalId: string;
95
+ tentacleId: string;
96
+ worktreeId?: string;
97
+ tentacleName: string;
98
+ nameOrigin?: TerminalNameOrigin;
99
+ autoRenamePromptContext?: string | undefined;
100
+ createdAt: string;
101
+ workspaceMode: TentacleWorkspaceMode;
102
+ agentProvider?: TerminalAgentProvider;
103
+ initialPrompt?: string;
104
+ initialInputDraft?: string;
105
+ lastActiveAt?: string;
106
+ parentTerminalId?: string;
107
+ };
108
+
109
+ export type GitClientPullRequestSnapshot = Omit<
110
+ TentaclePullRequestSnapshot,
111
+ "tentacleId" | "workspaceMode" | "status"
112
+ > & {
113
+ state: "OPEN" | "MERGED" | "CLOSED";
114
+ };
115
+
116
+ export type TerminalRegistryDocument = {
117
+ version: 3;
118
+ terminals: PersistedTerminal[];
119
+ uiState?: PersistedUiState;
120
+ };
121
+
122
+ export type GitClient = {
123
+ assertAvailable(): void;
124
+ isRepository(cwd: string): boolean;
125
+ addWorktree(options: { cwd: string; path: string; branchName: string; baseRef: string }): void;
126
+ removeWorktree(options: { cwd: string; path: string }): void;
127
+ removeBranch(options: { cwd: string; branchName: string }): void;
128
+ readWorktreeStatus(options: {
129
+ cwd: string;
130
+ }): Omit<TentacleGitStatusSnapshot, "tentacleId" | "workspaceMode">;
131
+ commitAll(options: { cwd: string; message: string }): void;
132
+ pushCurrentBranch(options: { cwd: string }): void;
133
+ syncWithBase(options: { cwd: string; baseRef: string }): void;
134
+ readCurrentBranchPullRequest(options: {
135
+ cwd: string;
136
+ }): GitClientPullRequestSnapshot | null;
137
+ createPullRequest(options: {
138
+ cwd: string;
139
+ title: string;
140
+ body: string;
141
+ baseRef: string;
142
+ headRef: string;
143
+ }): GitClientPullRequestSnapshot | null;
144
+ mergeCurrentBranchPullRequest(options: {
145
+ cwd: string;
146
+ strategy: "squash" | "merge" | "rebase";
147
+ }): void;
148
+ };
149
+
150
+ export class RuntimeInputError extends Error {}
151
+
152
+ export type CreateTerminalRuntimeOptions = {
153
+ workspaceCwd: string;
154
+ projectStateDir?: string | undefined;
155
+ gitClient?: GitClient;
156
+ getApiBaseUrl?: () => string;
157
+ };