@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
package/README.md ADDED
@@ -0,0 +1,1295 @@
1
+ ```
2
+ ██████╗ ██████╗ ██████╗ ████████╗ ███████╗ ██╗ ██╗
3
+ ██╔════╝ ██╔═══██╗ ██╔══██╗ ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝
4
+ ██║ ██║ ██║ ██████╔╝ ██║ █████╗ ╚███╔╝
5
+ ██║ ██║ ██║ ██╔══██╗ ██║ ██╔══╝ ██╔██╗
6
+ ╚██████╗ ╚██████╔╝ ██║ ██║ ██║ ███████╗ ██╔╝ ██╗
7
+ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝
8
+
9
+ C O D E O R C H E S T R A T I O N +
10
+ R E A S O N I N G T E R M I N A L E N G I N E
11
+ ```
12
+
13
+ <p align="center">
14
+ <strong>An open-source, agentic AI coding assistant for your terminal, desktop, and editor.</strong><br/>
15
+ Runs entirely on free HuggingFace models. No Anthropic / OpenAI subscription required.
16
+ </p>
17
+
18
+ <p align="center">
19
+ <a href="#-quick-start"><img src="https://img.shields.io/badge/Quick%20Start-5%20min-brightgreen" /></a>
20
+ <a href="#-architecture"><img src="https://img.shields.io/badge/Architecture-Full%20Diagram-blue" /></a>
21
+ <a href="#-command-reference-50-total"><img src="https://img.shields.io/badge/Commands-50+-purple" /></a>
22
+ <a href="#-153-specialist-agents"><img src="https://img.shields.io/badge/Agents-153-orange" /></a>
23
+ <a href="#-mcp-servers-38-registered"><img src="https://img.shields.io/badge/MCP%20Servers-38-cyan" /></a>
24
+ <a href="#-quick-start"><img src="https://img.shields.io/badge/Install-1%20command-green" /></a>
25
+ <a href="#-docker"><img src="https://img.shields.io/badge/Docker-ready-2496ED?logo=docker&logoColor=white" /></a>
26
+ <a href="https://www.npmjs.com/package/@gitlawb/cortex"><img src="https://img.shields.io/badge/npm-%40gitlawb%2Fcortex-red?logo=npm" /></a>
27
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow" /></a>
28
+ </p>
29
+
30
+ ---
31
+
32
+ ## 📑 Table of Contents
33
+
34
+ - [Why CORTEX](#-why-cortex)
35
+ - [Feature Matrix](#-feature-matrix)
36
+ - [Architecture](#-architecture)
37
+ - [Data Flow](#-data-flow)
38
+ - [Quick Start](#-quick-start)
39
+ - [Five Ways to Run It](#-five-ways-to-run-it)
40
+ - [Zero-Command UX](#-zero-command-ux)
41
+ - [Command Reference (50+ total)](#-command-reference-50-total)
42
+ - [153 Specialist Agents](#-153-specialist-agents)
43
+ - [MCP Servers (38 registered)](#-mcp-servers-38-registered)
44
+ - [Model Fallback + Offline Mode](#-model-fallback--offline-mode)
45
+ - [Floating Desktop UI (Tier A)](#-tier-a--floating-desktop-ui-with-screen-watcher)
46
+ - [Web Dashboard](#-tier-a--web-dashboard)
47
+ - [VS Code Extension](#-tier-a--vs-code--cursor-extension)
48
+ - [Media & Diagrams](#-tier-a--media--diagrams)
49
+ - [Project Structure](#-project-structure)
50
+ - [Tech Stack](#-tech-stack)
51
+ - [Development](#-development)
52
+ - [Privacy & Security](#-privacy--security)
53
+ - [Benchmarks](#-benchmarks)
54
+ - [Roadmap](#-roadmap)
55
+ - [Contributing](#-contributing)
56
+ - [License](#-license)
57
+
58
+ ---
59
+
60
+ ## 🎯 Why CORTEX
61
+
62
+ A fully-agentic AI coding assistant with **everything built-in** — 50+ slash commands, 153 specialist agents, 38 MCP servers, browser automation, voice I/O, screen vision, local LLM fallback, and a floating desktop UI. Zero vendor lock-in. One HuggingFace token is the only requirement.
63
+
64
+ | Problem | CORTEX's Solution |
65
+ |---|---|
66
+ | Claude Code / Cursor subscriptions are expensive | **Free** via HuggingFace GLM-5 |
67
+ | Every AI tool does one thing | **50+ slash commands** across 9 tiers |
68
+ | No personas / no specialists | **153 auto-loaded expert agents** |
69
+ | No ecosystem hooks | **38 MCP servers** (GitHub, Slack, Linear, Context7, Serena, Playwright, Git, ...) |
70
+ | Terminal-only or web-only | **CLI + Electron + Web + VS Code** — all four |
71
+ | No offline mode | **Ollama fallback** wired in |
72
+ | Can't see what you're doing | **Screen-watcher** with vision model |
73
+ | Telemetry concerns | **Zero telemetry** — 21 modules stubbed at build time |
74
+ | One model, one provider | **Auto-failover** between providers (`:together` → `:novita`) |
75
+
76
+ ---
77
+
78
+ ## ✨ Feature Matrix
79
+
80
+ | | Feature | Detail |
81
+ |---|---|---|
82
+ | 🧠 | **AI brain** | HuggingFace Router → GLM-5 (default) · swap any HF-hosted model |
83
+ | 🔄 | **Auto-failover** | Primary `zai-org/GLM-5:together` → fallback `:novita` on 5xx errors |
84
+ | 🦙 | **Offline mode** | Ollama detected automatically at `localhost:11434` — zero config |
85
+ | ⚡ | **50+ slash commands** | Smart commits, PR reviews, RAG, agents, voice, media, diagrams |
86
+ | 👥 | **153 specialist agents** | Engineering · Marketing · Security · Design · Testing · Compliance · XR |
87
+ | 🔌 | **38 MCP servers** | GitHub, Slack, Linear, Context7, Serena, Playwright, Jupyter, Git, Exa, Tavily, DuckDuckGo, Time, Everything, Postgres, SQLite, Puppeteer, Fetch, Memory, Filesystem, Seq-Thinking, Docker, Kubernetes, Chroma, Excel, Pandoc, PDF-Reader, Wikipedia, ArXiv, HackerNews, Reddit, YouTube-Transcript, RepoMix, OSM, AppleScript, Apple-Shortcuts, Automation-Mac, Calculator |
88
+ | 🎤 | **Voice I/O** | Whisper (STT) + Bark (TTS) + Web Speech API |
89
+ | 👁 | **Screen vision** | Electron `desktopCapturer` → vision LLM every 10s |
90
+ | 🖼 | **Media generation** | Images (FLUX.1), video (HunyuanVideo), diagrams (Mermaid/Excalidraw/Draw.io) |
91
+ | 📚 | **RAG** | pgvector + HuggingFace embeddings over your codebase |
92
+ | 🤖 | **Autonomous daemon** | Background agent scans repo, writes daily briefs, drafts PRs |
93
+ | 🧪 | **Test generation** | Auto-generate tests for any file/function |
94
+ | 🛡 | **Security scan** | Deep audit for secrets, vulnerabilities, unsafe patterns |
95
+ | 🌐 | **Browser automation** | Lightpanda + Scrapling + Puppeteer |
96
+ | 🎨 | **4 user interfaces** | CLI · Electron floating UI · Web dashboard · VS Code extension |
97
+ | 🔐 | **Privacy-friendly** | No telemetry · gitignored secrets · local-first where possible |
98
+ | 🐙 | **Octogent integration** | Bundled multi-agent orchestrator (MIT, vendored at `apps/octogent/`) — tentacles, scoped context folders, todo.md, inter-agent messaging, parent/child Claude-style agents. **Auto-launches** when running `./cortex.mjs` or `AGI`. UI auto-opens in browser at `http://127.0.0.1:8787`. Rebranded to Cortex with glassmorphism + 3D animations. Built automatically with pnpm. |
99
+ | 🚀 | **Mac `.app` bundle** | Installable via Spotlight — no terminal needed |
100
+
101
+ ---
102
+
103
+ ## 🏗 Architecture
104
+
105
+ Full system diagram — every component, every connection:
106
+
107
+ ```mermaid
108
+ graph TB
109
+ subgraph USER["👤 USER INTERFACES"]
110
+ direction LR
111
+ CLI["🖥 CLI<br/>./cortex.mjs"]
112
+ ELECTRON["🪟 Electron App<br/>./bin/AGI-ui<br/><i>Floating · Always-on-top</i>"]
113
+ WEB["🌐 Web Dashboard<br/>localhost:3737"]
114
+ VSCODE["💻 VS Code Extension<br/>Right-click menu"]
115
+ OCTOGENT["🐙 Octogent<br/>./bin/cortex-octogent<br/><i>Multi-agent orchestrator</i>"]
116
+ end
117
+
118
+ subgraph CORE["⚙️ CORTEX CORE (TypeScript + Bun)"]
119
+ direction TB
120
+ ROUTER["📋 CORTEX.md Router<br/><i>Zero-command UX · routes plain English → capability</i>"]
121
+ REPL["🔁 REPL / Orchestrator<br/><i>src/entrypoints/cli.tsx</i>"]
122
+
123
+ subgraph COMMANDS["50+ Slash Commands (9 Tiers + /octo UI launcher)"]
124
+ T1["Tier 1 · Core (7)"]
125
+ T2["Tier 2 · Productivity (8)"]
126
+ T3["Tier 3 · Code Intelligence (7)"]
127
+ T4["Tier 4 · Git (6)"]
128
+ T5["Tier 5 · Automation (6)"]
129
+ T6["Tier 6 · RAG (5)"]
130
+ T7["Tier 7 · Multi-Model (4)"]
131
+ T8["Tier 8 · Observability (4)"]
132
+ T9["Tier 9 · Next-Gen (3+)"]
133
+ end
134
+
135
+ subgraph AGENTS["👥 153 Specialist Agents"]
136
+ A1["Engineering (26)"]
137
+ A2["Marketing (29)"]
138
+ A3["Design (8)"]
139
+ A4["Testing (8)"]
140
+ A5["Security / Compliance"]
141
+ A6["60+ Niche"]
142
+ end
143
+
144
+ TOOLS["🔧 Built-in Tools<br/>Read · Write · Edit · Bash<br/>WebFetch · Glob · Grep · Notebook"]
145
+ end
146
+
147
+ subgraph AI["🧠 AI / MODEL LAYER"]
148
+ direction TB
149
+ SMART_ROUTER["🔀 Smart Router<br/>python/smart_router.py<br/><i>Latency + cost + health scoring</i>"]
150
+
151
+ subgraph PROVIDERS["LLM Providers"]
152
+ HF_TOGETHER["HF Router · GLM-5 (Together)<br/><i>PRIMARY</i>"]
153
+ HF_NOVITA["HF Router · GLM-5 (Novita)<br/><i>FALLBACK on 5xx</i>"]
154
+ OLLAMA["Ollama (local)<br/><i>OFFLINE fallback · llama3.2/moondream</i>"]
155
+ HF_OTHER["Other HF Models<br/><i>Llama · DeepSeek · Qwen</i>"]
156
+ end
157
+
158
+ VISION["👁 Vision Model<br/>Screen → description<br/><i>Moondream / LLaVA via Ollama</i>"]
159
+ VOICE["🎤 Voice Stack<br/>Whisper (STT) + Bark (TTS)"]
160
+ EMBEDDINGS["📚 Embeddings<br/>HF sentence-transformers"]
161
+ end
162
+
163
+ subgraph MCP["🔌 MCP SERVERS (38)"]
164
+ direction LR
165
+ MCP_GH["GitHub"]
166
+ MCP_SLACK["Slack"]
167
+ MCP_LINEAR["Linear"]
168
+ MCP_PG["Postgres"]
169
+ MCP_SQL["SQLite"]
170
+ MCP_PUP["Puppeteer"]
171
+ MCP_FETCH["Fetch"]
172
+ MCP_MEM["Memory"]
173
+ MCP_FS["Filesystem"]
174
+ MCP_SEQ["Seq-Thinking"]
175
+ MCP_CTX7["Context7"]
176
+ MCP_SERENA["Serena"]
177
+ MCP_PLAY["Playwright"]
178
+ MCP_JUPY["Jupyter"]
179
+ MCP_AUTOMAC["Automation-Mac"]
180
+ MCP_GIT["Git"]
181
+ MCP_DESK["Desktop-Commander"]
182
+ MCP_EXA["Exa"]
183
+ MCP_TAVILY["Tavily"]
184
+ MCP_DUCK["DuckDuckGo"]
185
+ MCP_TIME["Time"]
186
+ end
187
+
188
+ subgraph DATA["💾 DATA / STATE"]
189
+ direction LR
190
+ PGVECTOR["pgvector<br/><i>RAG index</i>"]
191
+ SQLITE["data/cortex.db<br/><i>History · memory</i>"]
192
+ DIAGRAMS["data/diagrams/<br/><i>Mermaid · Excalidraw · Draw.io</i>"]
193
+ LOGS["logs/<br/><i>Structured JSON</i>"]
194
+ ENV[".env<br/><i>Secrets (gitignored)</i>"]
195
+ end
196
+
197
+ subgraph AUTOMATION["🤖 AUTOMATION"]
198
+ DAEMON["Autonomous Daemon<br/><i>/autonomous start</i>"]
199
+ SCHEDULER["Scheduler<br/><i>Cron-like AI tasks</i>"]
200
+ WATCHER["File Watcher<br/><i>/watch</i>"]
201
+ end
202
+
203
+ subgraph BROWSER["🌐 BROWSER AUTOMATION"]
204
+ LIGHT["Lightpanda"]
205
+ SCRAPE["Scrapling"]
206
+ PUPP["Puppeteer"]
207
+ end
208
+
209
+ USER --> CORE
210
+ OCTOGENT --> CORE
211
+ ROUTER --> COMMANDS
212
+ ROUTER --> AGENTS
213
+ REPL --> ROUTER
214
+ COMMANDS --> TOOLS
215
+ AGENTS --> TOOLS
216
+ TOOLS --> MCP
217
+ TOOLS --> BROWSER
218
+
219
+ CORE --> AI
220
+ SMART_ROUTER --> PROVIDERS
221
+ ELECTRON --> VISION
222
+ ELECTRON --> VOICE
223
+ T6 --> EMBEDDINGS
224
+ EMBEDDINGS --> PGVECTOR
225
+
226
+ TOOLS --> DATA
227
+ DAEMON --> CORE
228
+ SCHEDULER --> CORE
229
+ WATCHER --> CORE
230
+
231
+ style USER fill:#1e3a5f,stroke:#4aa3df,color:#fff
232
+ style CORE fill:#2d1b4e,stroke:#8b5cf6,color:#fff
233
+ style AI fill:#1f3a2e,stroke:#10b981,color:#fff
234
+ style MCP fill:#4e2d1b,stroke:#f59e0b,color:#fff
235
+ style DATA fill:#3a1f2e,stroke:#ec4899,color:#fff
236
+ style AUTOMATION fill:#1b3a4e,stroke:#06b6d4,color:#fff
237
+ style BROWSER fill:#3a3a1b,stroke:#eab308,color:#fff
238
+ ```
239
+
240
+ ### Component Responsibilities
241
+
242
+ | Layer | Component | Responsibility |
243
+ |---|---|---|
244
+ | **UI** | CLI / Electron / Web / VS Code | User input surfaces (terminal, desktop, browser, IDE) |
245
+ | **Core** | CORTEX.md Router | Parses plain-English → slash command / agent / tool |
246
+ | **Core** | REPL | Orchestrates the agentic loop (observe → think → act) |
247
+ | **Core** | Slash Commands | 50+ opinionated workflows across 9 tiers |
248
+ | **Core** | Agents | 153 specialist personas with tailored system prompts |
249
+ | **Core** | Tools | Read/Write/Edit/Bash + MCP tool proxies |
250
+ | **AI** | Smart Router | Provider selection by latency/cost/health |
251
+ | **AI** | Vision / Voice / Embeddings | Multimodal + semantic-search pipelines |
252
+ | **MCP** | 38 Servers | GitHub · Slack · Linear · Context7 · Serena · Playwright · Jupyter · Git · Exa · Tavily · DuckDuckGo · Time · Everything · Postgres · SQLite · Puppeteer · Fetch · Memory · FS · Seq-Thinking + 18 open-source (Docker, K8s, Chroma, Excel, Pandoc, Wikipedia, ArXiv, ...) |
253
+ | **Data** | pgvector · SQLite · Filesystem | RAG index, history, generated artefacts |
254
+ | **Automation** | Daemon · Scheduler · Watcher | Background agentic loops |
255
+ | **Browser** | Lightpanda · Scrapling · Puppeteer | Web scraping + automation |
256
+
257
+ ---
258
+
259
+ ## 🔄 Data Flow
260
+
261
+ How a single user prompt traverses the system:
262
+
263
+ ```mermaid
264
+ sequenceDiagram
265
+ autonumber
266
+ participant U as 👤 User
267
+ participant UI as 🖥 UI (CLI/Electron/Web/VSCode)
268
+ participant ROUTER as 📋 CORTEX.md Router
269
+ participant REPL as 🔁 Agentic REPL
270
+ participant TOOLS as 🔧 Tools
271
+ participant MCP as 🔌 MCP Servers
272
+ participant LLM as 🧠 HF Router (GLM-5)
273
+ participant FALLBACK as 🔀 Fallback (novita / Ollama)
274
+ participant FS as 💾 Filesystem / DB
275
+
276
+ U->>UI: "create portfolio site at ~/Desktop/..."
277
+ UI->>ROUTER: raw prompt
278
+ ROUTER->>ROUTER: classify → match playbook from CORTEX.md
279
+ ROUTER->>REPL: enriched prompt + system context
280
+
281
+ loop Agentic Loop (observe → think → act)
282
+ REPL->>LLM: POST /v1/chat/completions
283
+ alt Primary OK
284
+ LLM-->>REPL: tool_calls + reasoning
285
+ else 5xx / empty
286
+ LLM->>FALLBACK: retry with :novita
287
+ FALLBACK-->>REPL: tool_calls + reasoning
288
+ end
289
+
290
+ alt Tool: Read/Write/Edit/Bash
291
+ REPL->>TOOLS: invoke
292
+ TOOLS->>FS: fs.readFile / writeFile / exec
293
+ FS-->>TOOLS: result
294
+ TOOLS-->>REPL: observation
295
+ else Tool: MCP
296
+ REPL->>MCP: jsonrpc tool call
297
+ MCP-->>REPL: result
298
+ else Done
299
+ REPL->>UI: final answer / file paths
300
+ end
301
+ end
302
+
303
+ UI->>U: streamed response + artefacts
304
+ ```
305
+
306
+ ### Fast-mode bypass (Electron ⚡ Fast)
307
+
308
+ ```
309
+ User → Electron → direct HF POST → stream text → DOM
310
+ (no REPL, no tools, <2s)
311
+ ```
312
+
313
+ ### Offline mode
314
+
315
+ ```
316
+ User → Electron / CLI → HF fails (no internet)
317
+ → auto-fallback → Ollama (localhost:11434)
318
+ → local model response
319
+ ```
320
+
321
+ ---
322
+
323
+ ## 🚀 Quick Start
324
+
325
+ ### 🏎 Fastest: One-command install (recommended)
326
+
327
+ ```bash
328
+ git clone https://github.com/gokul77898/Cortex.git
329
+ cd Cortex
330
+ ./install.sh # creates .venv, installs Python + Node deps, builds CLI
331
+ cp .env.example .env # add your HF_TOKEN
332
+ ./cortex.mjs "hello"
333
+ ```
334
+
335
+ ### 🐳 Docker (zero local deps)
336
+
337
+ ```bash
338
+ git clone https://github.com/gokul77898/Cortex.git
339
+ cd Cortex
340
+ cp .env.example .env # add your HF_TOKEN
341
+ docker build -t cortex .
342
+ docker run -it --rm --env-file .env -v "$(pwd)/workspace:/workspace" cortex "hello"
343
+ ```
344
+
345
+ Or with docker-compose:
346
+ ```bash
347
+ docker-compose up -d
348
+ docker-compose run cortex "hello"
349
+ ```
350
+
351
+ ### 📦 npm (global install)
352
+
353
+ ```bash
354
+ npm install -g @gitlawb/cortex
355
+ cortex "hello"
356
+ ```
357
+
358
+ ### 🔧 Makefile shortcuts
359
+
360
+ ```bash
361
+ make install # one-command setup
362
+ make run ARGS="hello"
363
+ make docker-build
364
+ make test
365
+ ```
366
+
367
+ ### Prerequisites (for manual install only)
368
+
369
+ - **Node.js** ≥ 20 & **Bun** ≥ 1.1 — `brew install bun`
370
+ - **Python** ≥ 3.9 (for RAG, voice, media helpers)
371
+ - **HuggingFace token** → [hf.co/settings/tokens](https://huggingface.co/settings/tokens) (free)
372
+ - **Optional:** Ollama for offline mode → `brew install ollama`
373
+
374
+ ### Manual install (if you skip `install.sh`)
375
+
376
+ ```bash
377
+ git clone https://github.com/gokul77898/Cortex.git
378
+ cd Cortex
379
+ python3 -m venv .venv && source .venv/bin/activate
380
+ pip install -r python/requirements.txt uv
381
+ bun install
382
+ bun run build
383
+ ```
384
+
385
+ ### Configure
386
+
387
+ Copy `.env.example` → `.env`. **One key is required**; the rest are optional:
388
+
389
+ ```bash
390
+ # REQUIRED — the AI brain (free @ huggingface.co/settings/tokens)
391
+ HF_TOKEN=hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
392
+ HF_MODEL_ID=zai-org/GLM-5:together # primary
393
+ HF_MODEL_FALLBACK=zai-org/GLM-5:novita # auto-used on 5xx
394
+ HF_BASE_URL=https://router.huggingface.co/v1
395
+
396
+ # OPTIONAL — each unlocks one MCP
397
+ GITHUB_TOKEN=ghp_xxxxx
398
+ SLACK_BOT_TOKEN=xoxb-xxxxx
399
+ SLACK_TEAM_ID=Txxxxxxxx
400
+ LINEAR_API_KEY=lin_api_xxxxx
401
+ POSTGRES_CONNECTION_STRING=postgresql://user@localhost:5432/dbname
402
+
403
+ # OPTIONAL — offline fallback
404
+ OLLAMA_HOST=http://localhost:11434
405
+ CORTEX_FAST_MODEL=llama3.2:3b
406
+ CORTEX_VISION_MODEL=moondream
407
+
408
+ # OPTIONAL — Multi-tier provider fallback chain
409
+ # Cortex auto-falls-back when primary returns 401/403/429/5xx:
410
+ # HF primary → HF fallback list → Groq → Ollama (local)
411
+ HF_MODEL_FALLBACK=zai-org/GLM-5:together,zai-org/GLM-5:novita
412
+ GROQ_API_KEY=gsk_xxxxx
413
+ CORTEX_GROQ_FALLBACK_MODEL=openai/gpt-oss-120b
414
+ CORTEX_OLLAMA_FALLBACK_MODEL=llama3.2:3b
415
+
416
+ # OPTIONAL — Dual-model mode (GLM-5 plans, MiniMax executes)
417
+ # When CORTEX_DUAL_MODEL=1, Cortex auto-picks the right model per request:
418
+ # * tool calls (Bash/Edit/Write/...) → Executor (MiniMax)
419
+ # * pure reasoning / planning → Planner (GLM-5)
420
+ CORTEX_DUAL_MODEL=1
421
+ CORTEX_PLANNER_MODEL=zai-org/GLM-5:together
422
+ CORTEX_EXECUTOR_MODEL=MiniMaxAI/MiniMax-M2:novita
423
+ ```
424
+
425
+ ### 🪜 Multi-tier Fallback Chain
426
+
427
+ Cortex automatically falls back when the primary provider returns
428
+ `401`, `403`, `429`, or `5xx`. The chain is configurable end-to-end:
429
+
430
+ ```
431
+ 1. HF primary (HF_MODEL_ID)
432
+ ↓ fails
433
+ 2. HF fallback list (HF_MODEL_FALLBACK — comma-separated, tried in order)
434
+ ↓ all fail
435
+ 3. NVIDIA (NVIDIA_API_KEY + NVIDIA_MODEL_ID)
436
+ ↓ fails
437
+ 4. Groq (GROQ_API_KEY + CORTEX_GROQ_FALLBACK_MODEL)
438
+ ↓ fails
439
+ 5. Ollama (local) (CORTEX_OLLAMA_FALLBACK_MODEL — works offline)
440
+ ```
441
+
442
+ Every step prints a colored status banner to the terminal so you always see
443
+ which provider is serving the request:
444
+
445
+ ```
446
+ ✗ HF primary failed │ moonshotai/Kimi-K2.6:together (HTTP 403)
447
+ ↻ trying fallback │ HF → zai-org/GLM-5:together
448
+ ✓ using HF fallback │ zai-org/GLM-5:together
449
+ ```
450
+
451
+ The active model also appears in the spinner next to the verb:
452
+ `Twisting… · Kimi-K2.6`.
453
+
454
+ ### 🤝 Shared Sessions — `/share` (multiplayer Cortex)
455
+
456
+ Up to 4 teammates can join one Cortex session over your local network. Tasks
457
+ run sequentially (one at a time) but everyone sees every message in real time
458
+ — like Google Docs for a terminal coding session.
459
+
460
+ ```
461
+ /share # start a shared session on your LAN
462
+ /share --port 9900 # pick a specific port
463
+ /share stop # end the shared session
464
+ ```
465
+
466
+ **Two web interfaces:**
467
+
468
+ - **Host Control UI** (`/host`) — Host-only dashboard with:
469
+ - Heavy 3D animations (200 particles, 12 pulsing nodes with glow)
470
+ - Participant list with kick buttons
471
+ - Detailed activity log (color-coded: join/leave/chat/typing/command)
472
+ - Voice call controls (start/end, UI placeholder for WebRTC)
473
+ - Dual chat system (team chat + Cortex commands panel)
474
+ - Message queue visualization
475
+ - Real-time typing indicators
476
+
477
+ - **Participant Dashboard** (`/dashboard`) — Shared view for all:
478
+ - 3D node visualization
479
+ - Participant list with typing indicators
480
+ - Dual chat system (team chat + Cortex commands)
481
+ - Voice call UI
482
+ - Message queue panel
483
+ - Activity tracking
484
+
485
+ What you get:
486
+
487
+ - a **Local** URL (`http://127.0.0.1:<port>`) for you
488
+ - a **Network** URL (`http://<lan-ip>:<port>`) + QR code to share with teammates
489
+ on the same Wi-Fi / LAN
490
+ - **Host UI** at `/host` for the session driver
491
+ - **Dashboard** at `/dashboard` for all participants
492
+ - dual chat: normal team messages (bypass queue) + Cortex commands (queued)
493
+ - real-time typing indicators across all participants
494
+ - detailed activity logging showing everything clients do
495
+
496
+ Use it when:
497
+
498
+ - you want pair / mob programming with 2–4 people
499
+ - a reviewer wants to queue follow-up tasks without taking over your terminal
500
+ - you want shared visibility; use `cortex swarm` instead when you need
501
+ parallel AI execution (up to 8 sub-agents per swarm).
502
+
503
+ ### �🧠 Dual-Model Architecture (GLM-5 Planner + MiniMax Executor)
504
+
505
+ ```
506
+ User input
507
+
508
+ GLM-5 → Planner / Agent brain (no tools — reasons about next step)
509
+
510
+ Task breakdown (steps, tools, plan)
511
+
512
+ MiniMax 2.5 → Executor (tools enabled — code / commands / output)
513
+
514
+ Code / commands / output
515
+
516
+ MiniMax → Self-check (lint / sanity)
517
+
518
+ (Optional) GLM-5 → Re-plan if failure (via HF_MODEL_FALLBACK on 5xx)
519
+ ```
520
+
521
+ Turn it on with one env var: `CORTEX_DUAL_MODEL=1`. Each chat-completion request
522
+ is auto-routed: if the agent loop is calling a tool → Executor; if it's
523
+ producing a plan/reflection → Planner. Falls back to the single-model path when
524
+ the env var is unset, so existing setups keep working.
525
+
526
+ ### 💓 Emotion Layer (tone-aware responses)
527
+
528
+ Cortex can detect your emotional state from each message and adapt its tone
529
+ like a human would — empathetic when you're stuck, concise when you're in a
530
+ hurry, warm when you're happy.
531
+
532
+ ```bash
533
+ CORTEX_EMOTION_LAYER=1 # local heuristic (zero cost, ~0.1ms/turn)
534
+ # or
535
+ CORTEX_EMOTION_LAYER=hf # HuggingFace classifier (adds ~200ms/turn)
536
+ CORTEX_EMOTION_DEBUG=1 # print detected emotion each turn (stderr)
537
+ ```
538
+
539
+ **Detects 8 emotions:** `frustrated` · `angry` · `confused` · `urgent` ·
540
+ `happy` · `curious` · `sad` · `anxious`.
541
+
542
+ **How it works:** before every turn, `@src/services/emotion/detector.ts` scans
543
+ the latest user message for signals (profanity, ALL-CAPS, `!!`, "doesn't
544
+ work", "urgent", "thanks", "how do I", …). When confidence ≥ 0.25 a
545
+ one-line tone hint is prepended to the system prompt, e.g.:
546
+
547
+ > *"User is frustrated. Be empathetic in one short line ('got it — fixing
548
+ > now'), then solve directly. No lectures, no filler, no long preambles."*
549
+
550
+ Verified on 10 test cases — see the regression table in
551
+ `@src/services/emotion/detector.ts`.
552
+
553
+ > **31 of 38 MCPs work with zero config** — filesystem, git, context7, serena, playwright, puppeteer, fetch, memory, sequential-thinking, sqlite, duckduckgo, time, everything, docker, kubernetes, chroma, excel, pandoc, pdf-reader, wikipedia, hackernews, reddit, youtube-transcript, semantic-scholar, repomix, osm, applescript, apple-shortcuts, automation-mac, calculator, html-to-markdown. The other **7 activate when their tokens are set**: `github` (GITHUB_TOKEN), `slack` (SLACK_BOT_TOKEN + SLACK_TEAM_ID), `linear` (LINEAR_API_KEY), `postgres` (POSTGRES_CONNECTION_STRING), `exa` (EXA_API_KEY), `tavily` (TAVILY_API_KEY), `jupyter` (JUPYTER_TOKEN).
554
+
555
+ ### Run
556
+
557
+ ```bash
558
+ AGI # interactive CLI (auto-launches Octogent UI)
559
+ ./cortex.mjs # same thing, explicit path
560
+ AGI -p "refactor auth to async/await" # one-shot
561
+ octo # just open the Cortex (Octogent) UI in your browser
562
+ octo --status # check if Octogent is running
563
+ ./bin/AGI-ui # Electron floating UI
564
+ ./bin/AGI-web # web dashboard
565
+ ./bin/cortex-octogent # Octogent multi-agent UI (auto-opens browser)
566
+ ```
567
+
568
+ > **Note**: Running `AGI` (or `./cortex.mjs`) automatically launches Octogent in the background and opens its UI in your browser. Set `CORTEX_NO_OCTOGENT=1` to disable auto-launch, or `CORTEX_NO_OPEN=1` to prevent browser auto-open. Inside the CLI, type `/octo` to re-open the UI at any time.
569
+
570
+ ---
571
+
572
+ ## 🎨 Five Ways to Run It
573
+
574
+ | Interface | Launch | Best For | Latency |
575
+ |---|---|---|---|
576
+ | **CLI** | `AGI` or `./cortex.mjs` | Full agentic workflows · all 50+ commands · all tools · auto-launches Octogent | 4-8s per step |
577
+ | **Octogent UI** | `octo` (standalone) or `/octo` (in CLI) — auto-launched by `AGI` | Multi-agent orchestration · tentacles · scoped context · todo.md · Cortex-branded glassmorphism UI | <2s |
578
+ | **Electron UI** | `./bin/AGI-ui` | Always-on-top floating chat · screen watcher · voice · hotkey `⌘⇧A` | <2s (Fast mode) |
579
+ | **Web Dashboard** | `./bin/AGI-web` → `localhost:3737` | Browsable commands · agents · MCP status · history · SSE streaming | <2s |
580
+ | **VS Code Extension** | Right-click → Ask/Explain/Refactor/Fix | In-editor assistance · same brain as CLI | 4-8s |
581
+
582
+ ---
583
+
584
+ ## 🧠 Zero-Command UX
585
+
586
+ You don't need to memorize 50+ slash commands. `CORTEX.md` is auto-loaded into every session and teaches the AI to route plain-English to the right capability:
587
+
588
+ ```text
589
+ ✦ fix all the TODOs in this project
590
+ ✦ my auth is broken — something about JWT expiry
591
+ ✦ dockerize this
592
+ ✦ clean up my git branches
593
+ ✦ document the python helpers
594
+ ✦ ship this feature but don't push yet
595
+ ✦ find security issues and fix them
596
+ ✦ write tests for the module I just opened
597
+ ```
598
+
599
+ The AI picks the playbook from `CORTEX.md` and executes. Slash commands remain as explicit shortcuts.
600
+
601
+ ---
602
+
603
+ ## 📋 Command Reference (50+ total)
604
+
605
+ <details>
606
+ <summary><strong>Tier 1 · Core (7)</strong></summary>
607
+
608
+ | Command | Description |
609
+ |---|---|
610
+ | `/smart-commit` `/sc` | Conventional commit with auto-detected type/scope |
611
+ | `/pr-review` | Comprehensive AI PR review |
612
+ | `/db` | Database schema + query analysis |
613
+ | `/test-gen` | Generate tests for a file/function |
614
+ | `/security-scan` | Deep security audit |
615
+ | `/perf-analyze` | Performance hotspot analysis |
616
+ | `/scan-report` | View latest scan reports |
617
+ </details>
618
+
619
+ <details>
620
+ <summary><strong>Tier 2 · Developer Productivity (8)</strong></summary>
621
+
622
+ | Command | Description |
623
+ |---|---|
624
+ | `/refactor` `/rf` | AI refactoring (rename, extract, convert patterns) |
625
+ | `/explain` `/ex` | Explain any code/file/function in plain English |
626
+ | `/docs` | Auto-generate JSDoc / docstrings / README sections |
627
+ | `/fix` | Paste an error → AI diagnoses + fixes it |
628
+ | `/todo` | Scan + prioritize TODO/FIXME/HACK comments |
629
+ | `/deps` | Dependency audit (outdated, vulnerable, unused) |
630
+ | `/lint-fix` | Auto-fix lint errors across the repo |
631
+ | `/type-check` `/tc` | Deep type analysis + AI-suggested fixes |
632
+ </details>
633
+
634
+ <details>
635
+ <summary><strong>Tier 3 · Code Intelligence (7)</strong></summary>
636
+
637
+ | Command | Description |
638
+ |---|---|
639
+ | `/architecture` `/arch` | Mermaid architecture diagrams |
640
+ | `/complexity` `/cx` | Cyclomatic complexity + hot spots |
641
+ | `/dead-code` `/dc` | Find unused exports, functions, files |
642
+ | `/api-map` | Map every endpoint + its consumers |
643
+ | `/schema-diff` | Diff two schemas + generate migration |
644
+ | `/coverage-gap` | Find untested files + auto-generate tests |
645
+ | `/bundle-analyze` | Bundle size breakdown + optimization tips |
646
+ </details>
647
+
648
+ <details>
649
+ <summary><strong>Tier 4 · Git & Collaboration (6)</strong></summary>
650
+
651
+ | Command | Description |
652
+ |---|---|
653
+ | `/release-notes-ai` `/changelog` | Auto-generate release notes from commits |
654
+ | `/bisect` | AI-guided git bisect |
655
+ | `/conflict-resolve` `/cr` | AI merge conflict resolution |
656
+ | `/branch-cleanup` `/bclean` | Identify + delete stale branches |
657
+ | `/commit-squash` `/squash` | Smart squash plan for a PR |
658
+ | `/review-queue` `/rq` | PRs assigned to you, prioritized |
659
+ </details>
660
+
661
+ <details>
662
+ <summary><strong>Tier 5 · Automation / Agentic (6)</strong></summary>
663
+
664
+ | Command | Description |
665
+ |---|---|
666
+ | `/watch` | Watch files and auto-run checks on change |
667
+ | `/auto-fix` | Continuous loop: scan → fix → test → commit |
668
+ | `/pipeline` `/ci` | Generate CI/CD YAML (GitHub Actions · GitLab · CircleCI) |
669
+ | `/dockerize` | Auto-generate Dockerfile + docker-compose |
670
+ | `/deploy` | Deploy helpers (Vercel · Netlify · Railway · Fly) |
671
+ | `/scheduler` `/cron` | Cron-like scheduled AI tasks |
672
+ </details>
673
+
674
+ <details>
675
+ <summary><strong>Tier 6 · Knowledge / RAG (5)</strong></summary>
676
+
677
+ | Command | Description |
678
+ |---|---|
679
+ | `/ask` `/q` | Ask a question grounded in your codebase |
680
+ | `/ai-memory` `/amem` | Persistent project memory (writes `CORTEX.md`) |
681
+ | `/onboard` | Generate onboarding guide for new devs |
682
+ | `/search` `/s` | Semantic code search |
683
+ | `/stackoverflow` `/so` | Diagnose error messages |
684
+ </details>
685
+
686
+ <details>
687
+ <summary><strong>Tier 7 · Multi-Model / Swarm (4)</strong></summary>
688
+
689
+ | Command | Description |
690
+ |---|---|
691
+ | `/swarm` | Parallel AI sub-agents for big tasks |
692
+ | `/compare` `/cmp` | Same prompt, multiple models, compare answers |
693
+ | `/debate` | Two models debate a design decision |
694
+ | `/cheap` | Route a simple query to a cheaper model |
695
+ </details>
696
+
697
+ <details>
698
+ <summary><strong>Tier 8 · Observability (4)</strong></summary>
699
+
700
+ | Command | Description |
701
+ |---|---|
702
+ | `/logs` | AI log analysis (errors, anomalies, patterns) |
703
+ | `/metrics` | Repo health dashboard (LOC, churn, deps) |
704
+ | `/trace` | Distributed trace analysis (OTel · Jaeger · Zipkin) |
705
+ | `/alerts` | Set up AI-driven alert rules |
706
+ </details>
707
+
708
+ <details>
709
+ <summary><strong>Tier 9 · Next-Gen (3) 🔥</strong></summary>
710
+
711
+ | Command | Description |
712
+ |---|---|
713
+ | `/rag` `/r` | Semantic search over your codebase (pgvector + HF embeddings) |
714
+ | `/autonomous` `/auto` `/daemon` | Background agent: scans repo, writes briefs, opens draft PRs |
715
+ | `/voice` `/v` | Voice I/O via HF Whisper + Bark TTS |
716
+
717
+ **Tier 9 setup:** `pip install -r python/requirements-tier-s.txt` (once). RAG needs pgvector: `brew install pgvector`.
718
+ </details>
719
+
720
+ <details>
721
+ <summary><strong>Utility · UI Launchers</strong></summary>
722
+
723
+ | Command | Description |
724
+ |---|---|
725
+ | `/octo` `/octogent` `/ui` | Open the Cortex (Octogent) multi-agent UI in your browser. Auto-launches Octogent if not running. |
726
+
727
+ Also available as a standalone shell command: `octo` (opens), `octo --status` (check), `octo --no-open` (launch only).
728
+ </details>
729
+
730
+ <details>
731
+ <summary><strong>Advanced · Phase 1 (high-impact quick-wins)</strong></summary>
732
+
733
+ | Command | Description |
734
+ |---|---|
735
+ | `/template <stack>` `/scaffold` | Scaffold a new project from a real official starter (Next.js, Django, Rails, FastAPI, Expo, Svelte, Astro, Hono, NestJS, Vite, Express). Runs the official CLI + git init + first commit. |
736
+ | `/api-docs` `/openapi` | Generate a real OpenAPI 3.1 spec + JSDoc/docstrings from your actual HTTP routes (Express, NestJS, Next.js, FastAPI, Flask, Rails, Hono, Go). Validates with Redocly. |
737
+ | `/review-summarize` `/rs` | Structured, evidence-backed AI summary of a PR diff — classifies each file, flags risks, lists missing tests, suggests reviewers from CODEOWNERS / git log. |
738
+ | `/er-diagram` `/erd` | Introspect your real schema (Prisma, Drizzle, SQLAlchemy, Django, TypeORM, Rails, live Postgres/SQLite) and emit a Mermaid ER diagram to `docs/er-diagram.md`. |
739
+ | `/migrate` | Generate a real, reversible DB migration by diffing two schema states. Prefers official tooling (Prisma, Alembic, Django, Rails, Drizzle, Knex) and falls back to safe hand-written SQL with rollback. |
740
+ | `/rollback` | Roll back the last deployment on Vercel / Netlify / Fly.io / Railway / Render / Heroku using the real provider CLI. Always requires explicit user approval before executing. |
741
+ </details>
742
+
743
+ ---
744
+
745
+ ## 👥 153 Specialist Agents
746
+
747
+ `src/skills/agency/` holds 153 expert personas auto-discovered by the skills loader. Invoke implicitly via CORTEX.md or explicitly:
748
+
749
+ ```bash
750
+ /engineering-backend-architect design a REST API for a blog
751
+ /design-ui-designer suggest a color palette for a fintech app
752
+ /testing-reality-checker are my tests actually meaningful?
753
+ /marketing-content-strategist write 3 blog post ideas
754
+ /blockchain-security-auditor top 5 ERC-20 vulnerabilities?
755
+ ```
756
+
757
+ **Categories:**
758
+
759
+ ```
760
+ Marketing (29) ████████████████████████▓
761
+ Engineering (26) ██████████████████████
762
+ Specialized (10) ████████▒
763
+ Sales (9) ████████
764
+ Testing (8) ███████
765
+ Design (8) ███████
766
+ Paid-Media (7) ██████
767
+ Support (6) █████
768
+ Project (6) █████
769
+ Product (5) ████
770
+ Academic (5) ████
771
+ Workflow (4) ███
772
+ Niche (30+) █████████████████████████
773
+ ```
774
+
775
+ Niche = blockchain · healthcare · compliance · XR · recruitment · legal · finance · IoT · robotics · gaming · …
776
+
777
+ ---
778
+
779
+ ## 🔌 MCP Servers (38 registered)
780
+
781
+ CORTEX registers 38 Model Context Protocol servers in `.mcp.json`. They load on-demand via `npx` or `uvx`. **31 work zero-config**; 7 activate when their env tokens are set.
782
+
783
+ ### 🎯 Top 5 Priority (Claude Code CLI level)
784
+
785
+ | MCP | Capability |
786
+ |---|---|
787
+ | `context7` | **Live library docs** — 10k+ libraries, version-specific docs |
788
+ | `serena` | **LSP-level code navigation** — rename symbol, find refs, go-to-def |
789
+ | `playwright` | **Official Playwright MCP** — browser automation (better than puppeteer) |
790
+ | `jupyter` | **Notebook editing** — .ipynb cell read/write/execute |
791
+ | `automation-mac` | **Computer use** — mouse + keyboard control on macOS |
792
+
793
+ ### 🔧 Code Intelligence
794
+
795
+ | MCP | Capability |
796
+ |---|---|
797
+ | `git` | Git operations — blame, diff, log, rebase, branch |
798
+ | `ast-grep-mcp` | Structural code search/refactor using AST patterns |
799
+
800
+ ### 🌐 Search & Data
801
+
802
+ | MCP | Capability | Free Tier |
803
+ |---|---|---|
804
+ | `exa` | Neural search (better than Google for code) | 1000 searches/month |
805
+ | `tavily` | Optimized for LLM agents | 1000 queries/month |
806
+ | `duckduckgo` | Privacy search | 100% free |
807
+
808
+ ### 🤖 Automation
809
+
810
+ | MCP | Capability |
811
+ |---|---|
812
+ | `desktop-commander` | Execute shell, kill processes, manage sessions |
813
+ | `everything` | Spotlight-like file search |
814
+
815
+ ### 📊 Database
816
+
817
+ | MCP | Capability |
818
+ |---|---|
819
+ | `sqlite` | Direct SQLite access (`data/cortex.db`) |
820
+ | `postgres` | Direct Postgres access (requires `POSTGRES_CONNECTION_STRING`) |
821
+
822
+ ### 🔌 Original 11
823
+
824
+ | MCP | Capability |
825
+ |---|---|
826
+ | `filesystem` | Sandboxed FS beyond current directory |
827
+ | `puppeteer` | Browser automation + screenshots |
828
+ | `fetch` | Web scraping + URL reading |
829
+ | `memory` | Persistent cross-session knowledge graph |
830
+ | `sequential-thinking` | Structured step-by-step reasoning |
831
+ | `github` | PRs · issues · releases · workflows (requires `GITHUB_TOKEN`) |
832
+ | `slack` | Send messages · read channels (requires `SLACK_BOT_TOKEN` + `SLACK_TEAM_ID`) |
833
+ | `linear` | Issues · projects · teams (requires `LINEAR_API_KEY`) |
834
+ | `time` | Current time, timezone conversion |
835
+ | `everything` | File search (Windows Everything) |
836
+
837
+ ### 🆓 Open-Source Expansion Pack (31 new, zero API keys)
838
+
839
+ Added 2026-04 — all npm/pypi open-source, no credentials required:
840
+
841
+ **📚 Knowledge & Research:**
842
+ | MCP | Capability |
843
+ |---|---|
844
+ | `arxiv` | Search 2M+ scientific papers |
845
+ | `wikipedia` | Query Wikipedia articles |
846
+ | `hackernews` | Browse HN stories + comments |
847
+ | `reddit` | Browse Reddit (read-only) |
848
+ | `youtube-transcript` | Extract YouTube transcripts |
849
+ | `paperswithcode` | ML papers + code benchmarks |
850
+ | `semantic-scholar` | Academic paper search |
851
+ | `openalex` | 240M+ scholarly works |
852
+
853
+ **📄 Content Processing:**
854
+ | MCP | Capability |
855
+ |---|---|
856
+ | `pandoc` | Convert 40+ document formats |
857
+ | `pdf-reader` | Extract text from PDFs |
858
+ | `markdown` / `html-to-markdown` | Markdown conversion (markitdown) |
859
+ | `excel` | Read/write .xlsx files |
860
+ | `repomix` | Pack entire repo into single file |
861
+
862
+ **🛠 DevOps & Data:**
863
+ | MCP | Capability |
864
+ |---|---|
865
+ | `docker` | Manage containers/images locally |
866
+ | `kubernetes` | K8s cluster management |
867
+ | `redis` | Local Redis cache ops |
868
+ | `duckdb` | Analytics SQL (no server needed) |
869
+ | `chroma` | Local vector database |
870
+ | `qdrant` | Local vector database |
871
+
872
+ **🖥 System & macOS:**
873
+ | MCP | Capability |
874
+ |---|---|
875
+ | `applescript` | Run AppleScript commands |
876
+ | `apple-shortcuts` | Trigger macOS Shortcuts |
877
+ | `cli` | Safe shell command executor |
878
+ | `calculator` | Arbitrary-precision math |
879
+ | `screenshot` | Capture screen to file |
880
+
881
+ **🌐 Utilities:**
882
+ | MCP | Capability |
883
+ |---|---|
884
+ | `rss` | Parse RSS/Atom feeds |
885
+ | `mermaid` | Render Mermaid diagrams |
886
+ | `osm` | OpenStreetMap lookups |
887
+ | `weather` | Free weather data |
888
+ | `regex` | Test and debug regex patterns |
889
+ | `json-tools` | Transform/query JSON |
890
+
891
+ ### Token-gated (set env var to enable)
892
+
893
+ | MCP | Env var | Capability |
894
+ |---|---|---|
895
+ | `github` | `GITHUB_TOKEN` | PRs · issues · releases · workflows |
896
+ | `postgres` | `POSTGRES_CONNECTION_STRING` | Direct Postgres access |
897
+ | `slack` | `SLACK_BOT_TOKEN` + `SLACK_TEAM_ID` | Send messages · read channels |
898
+ | `linear` | `LINEAR_API_KEY` | Issues · projects · teams |
899
+ | `exa` | `EXA_API_KEY` | Neural search |
900
+ | `tavily` | `TAVILY_API_KEY` | LLM-optimized search |
901
+
902
+ Missing tokens don't break the CLI — those MCPs simply show *failed* at startup; everything else runs.
903
+
904
+ ---
905
+
906
+ ## 🔀 Model Fallback + Offline Mode
907
+
908
+ ### Primary → Fallback provider chain
909
+
910
+ ```
911
+ HF Router
912
+
913
+ ┌───────────────────────┼──────────────────────┐
914
+ ▼ ▼ ▼
915
+ zai-org/GLM-5:together zai-org/GLM-5:novita Ollama (local)
916
+ ◆ PRIMARY ◆ AUTO-RETRY ◆ OFFLINE
917
+ (5xx → switch) (on 5xx failure) (no internet)
918
+ ```
919
+
920
+ | Layer | Behaviour |
921
+ |---|---|
922
+ | **Electron Fast mode** | HF non-streaming → on 5xx/empty → retry `HF_MODEL_FALLBACK` → on failure → Ollama |
923
+ | **CLI Full AGI** | Same provider chain, baked into `src/services/api/openaiShim.ts` |
924
+ | **Offline** | `OLLAMA_HOST` detected automatically; uses `llama3.2:3b` for chat, `moondream` for vision |
925
+
926
+ ### Ollama setup
927
+
928
+ ```bash
929
+ brew install ollama
930
+ ollama pull llama3.2:3b # chat fallback
931
+ ollama pull moondream # vision fallback
932
+ ollama serve # listens on :11434
933
+ ```
934
+
935
+ Dashboard → **Overview** tab shows green Ollama indicator when reachable.
936
+
937
+ ---
938
+
939
+ ## 🖥 Tier A — Floating Desktop UI with Screen Watcher
940
+
941
+ ```bash
942
+ ./bin/AGI-ui
943
+ ```
944
+
945
+ **Capabilities:**
946
+
947
+ | Mode | Backend | Speed | Tools |
948
+ |---|---|---|---|
949
+ | ⚡ **Fast** (default) | Direct HF chat · streaming | <2s first byte | — |
950
+ | 🧠 **Full AGI** | Spawns `cortex.mjs -p` · all tools · all MCPs | 4-8s/step | All |
951
+ | 👁 **Watch Screen** | `desktopCapturer` → vision LLM every 10s | Background | Injects screen caption into every prompt |
952
+ | 🎤 **Voice** | Web Speech API · `speechSynthesis` | Instant | STT + TTS |
953
+ | ⌨️ **Text** | Enter to send | Instant | — |
954
+
955
+ **Global hotkeys** (register when app is running):
956
+
957
+ | Key | Action |
958
+ |---|---|
959
+ | `⌘E` / `Ctrl+E` | Show and focus the window |
960
+ | `⌘⇧A` | Toggle window visibility |
961
+ | `⌘⇧F` | Toggle fullscreen |
962
+ | `⌘⇧S` | Snap screen immediately |
963
+
964
+ ### One-time: clickable `.app` bundle
965
+
966
+ ```bash
967
+ ./bin/AGI-install-app
968
+ ```
969
+
970
+ Puts `CORTEX.app` in `~/Applications` → launch via **Spotlight (⌘Space → "CORTEX")** or drag to Dock.
971
+
972
+ First launch asks for macOS **Screen Recording** permission — approve once in *System Settings → Privacy → Screen Recording*.
973
+
974
+ ---
975
+
976
+ ## 🌐 Tier A — Web Dashboard
977
+
978
+ ```bash
979
+ ./bin/AGI-web # or `/web` inside the CLI
980
+ # → http://localhost:3737 (auto-opens)
981
+ ```
982
+
983
+ | Tab | Shows |
984
+ |---|---|
985
+ | **Overview** | Counts · env health (HF · GitHub · Ollama) · active model · PID · uptime |
986
+ | **Ask** | Prompt input · SSE-streamed output from `cortex.mjs -p` |
987
+ | **Commands** | Browsable + filterable list of every `/slash` command |
988
+ | **Agents** | All 153 specialist agents with categories |
989
+ | **MCP** | Each server with `READY` / `NEEDS ENV` status |
990
+ | **History** | Last 50 prompts · timings · exit codes · click to re-run |
991
+
992
+ Tweak via `CORTEX_WEB_PORT=3939` · `CORTEX_AUTO_OPEN=false`.
993
+
994
+ ---
995
+
996
+ ## 💻 Tier A — VS Code / Cursor extension
997
+
998
+ Right-click any code → **Ask / Explain / Refactor / Fix with CORTEX**. See `apps/vscode-extension/README.md`.
999
+
1000
+ **Dev-install (instant):** open `apps/vscode-extension` in VS Code → press **F5**.
1001
+
1002
+ **Permanent-install:**
1003
+
1004
+ ```bash
1005
+ cd apps/vscode-extension && npx @vscode/vsce package
1006
+ code --install-extension cortex-vscode-0.1.0.vsix
1007
+ # or: cursor --install-extension cortex-vscode-0.1.0.vsix
1008
+ ```
1009
+
1010
+ ---
1011
+
1012
+ ## 🎨 Tier A — Media & Diagrams
1013
+
1014
+ | Command | Generates | Backend |
1015
+ |---|---|---|
1016
+ | `/image <prompt>` | PNG (auto-opens) | HF FLUX.1-schnell · override `CORTEX_IMAGE_MODEL` |
1017
+ | `/video <prompt>` | MP4 | HF HunyuanVideo · may need pro tier · override `CORTEX_VIDEO_MODEL` |
1018
+ | `/diagram <desc>` | **Mermaid + Excalidraw + Draw.io** in `data/diagrams/` | Chat-completion → parser |
1019
+
1020
+ **Direct Python:**
1021
+
1022
+ ```bash
1023
+ python3 python/cortex_media.py image "cyberpunk cat at sunset"
1024
+ python3 python/cortex_diagram.py "user signup flow with OAuth + 2FA"
1025
+ ```
1026
+
1027
+ ---
1028
+
1029
+ ## 🏗 Project Structure
1030
+
1031
+ ```
1032
+ cortex/
1033
+ ├── cortex.mjs # CLI launcher (loads .env, imports dist/cli.mjs)
1034
+ ├── dist/
1035
+ │ └── cli.mjs # Bundled CLI (built via `bun run build`)
1036
+ ├── src/
1037
+ │ ├── entrypoints/
1038
+ │ │ └── cli.tsx # CLI bootstrap (Ink terminal UI)
1039
+ │ ├── commands/
1040
+ │ │ ├── _tierHelper.ts # Shared prompt-command factory
1041
+ │ │ ├── tier1/ … tier9/ # 50+ slash commands organised by tier
1042
+ │ │ └── index.ts # COMMANDS() registry
1043
+ │ ├── skills/
1044
+ │ │ └── agency/ # 153 specialist agents (auto-loaded)
1045
+ │ ├── components/ # Ink / React terminal UI
1046
+ │ ├── services/
1047
+ │ │ └── api/
1048
+ │ │ ├── openaiShim.ts # HF Router adapter (with model fallback)
1049
+ │ │ └── providerConfig.ts # Provider resolution logic
1050
+ │ ├── tools/ # Built-in tools: Read · Write · Edit · Bash · …
1051
+ │ └── utils/
1052
+ │ ├── browser-disable.ts # Prevents auto-launched browsers
1053
+ │ └── …
1054
+ ├── apps/
1055
+ │ ├── octogent/ # Vendored multi-agent orchestrator (MIT)
1056
+ │ │ ├── apps/ # Octogent web app + API
1057
+ │ │ ├── bin/octogent # Octogent executable
1058
+ │ │ ├── .shims/claude # Shim to route claude → cortex CLI
1059
+ │ │ └── dist/ # Built Octogent (auto-built with make build)
1060
+ │ ├── voice-ui/ # Electron floating UI (Tier A)
1061
+ │ │ ├── main.js # Electron main process + HF chat + vision
1062
+ │ │ ├── preload.js # IPC bridge
1063
+ │ │ └── index.html # Renderer
1064
+ │ ├── web-ui/ # Express + SSE dashboard (Tier A)
1065
+ │ └── vscode-extension/ # VS Code + Cursor extension (Tier A)
1066
+ ├── python/
1067
+ │ ├── smart_router.py # Multi-provider auto-router
1068
+ │ ├── ollama_provider.py # Ollama adapter
1069
+ │ ├── cortex_rag.py # RAG (pgvector + HF embeddings)
1070
+ │ ├── cortex_voice.py # Whisper STT + Bark TTS
1071
+ │ ├── cortex_media.py # Image / video generation
1072
+ │ ├── cortex_diagram.py # Mermaid / Excalidraw / Draw.io
1073
+ │ ├── cortex_security.py # Security scanner
1074
+ │ ├── cortex_db.py # SQLite history / memory
1075
+ │ └── requirements.txt # Python dependencies for venv
1076
+ ├── bin/
1077
+ │ ├── AGI # Symlink to cortex.mjs
1078
+ │ ├── AGI-ui # Launch Electron floating UI
1079
+ │ ├── AGI-web # Launch web dashboard
1080
+ │ ├── AGI-install-app # Build macOS .app bundle
1081
+ │ ├── cortex # Symlink
1082
+ │ ├── cortex-octogent # Launch Octogent multi-agent orchestrator
1083
+ │ └── octo # Open the Cortex UI (launches Octogent if not running)
1084
+ ├── scripts/
1085
+ │ ├── build.ts # Bun bundler (stubs 21 telemetry modules)
1086
+ │ ├── start-web.sh # Dev server
1087
+ │ └── …
1088
+ ├── data/
1089
+ │ ├── cortex.db # SQLite: history + memory
1090
+ │ └── diagrams/ # Generated diagrams
1091
+ ├── logs/ # Structured JSON logs
1092
+ ├── .mcp.json # MCP server registry (38 servers)
1093
+ ├── CORTEX.md # Zero-command UX router (auto-loaded)
1094
+ ├── .env # Secrets (gitignored)
1095
+ ├── Dockerfile # Multi-stage Docker build
1096
+ ├── docker-compose.yml # Docker Compose orchestration
1097
+ ├── .dockerignore # Docker build exclusions
1098
+ ├── Makefile # Common commands (build, test, docker, etc.)
1099
+ └── install.sh # One-command installer (venv + deps + build)
1100
+ ```
1101
+
1102
+ ---
1103
+
1104
+ ## 🛠 Tech Stack
1105
+
1106
+ | Layer | Stack |
1107
+ |---|---|
1108
+ | **Language** | TypeScript (strict) · Python 3.9+ · Bash |
1109
+ | **Runtime** | Node.js 20+ · Bun 1.1+ |
1110
+ | **Terminal UI** | Ink (React for CLI) · chalk · boxen |
1111
+ | **Desktop UI** | Electron 33 · HTML/CSS/JS renderer |
1112
+ | **Web UI** | Express · Server-Sent Events (SSE) · vanilla JS |
1113
+ | **IDE UI** | VS Code Extension API |
1114
+ | **AI** | HuggingFace Router · Together AI · Novita · Fireworks · Ollama |
1115
+ | **RAG** | pgvector · sentence-transformers |
1116
+ | **Voice** | Whisper · Bark TTS · Web Speech API |
1117
+ | **Vision** | Moondream · LLaVA (via Ollama) |
1118
+ | **Browser** | Lightpanda · Scrapling · Puppeteer |
1119
+ | **Data** | SQLite (better-sqlite3) · pgvector |
1120
+ | **MCP** | 38 servers via `npx` / `uvx` (see `.mcp.json`) |
1121
+ | **Build** | Bun bundler + custom telemetry-stub plugin |
1122
+
1123
+ ---
1124
+
1125
+ ## 🔧 Development
1126
+
1127
+ ```bash
1128
+ # Build the CLI bundle (must re-run after editing src/)
1129
+ bun run build
1130
+
1131
+ # Type-check (pre-existing warnings OK)
1132
+ bun tsc --noEmit
1133
+
1134
+ # Run interactively
1135
+ ./cortex.mjs
1136
+
1137
+ # Run a single prompt (non-interactive)
1138
+ ./cortex.mjs -p "explain the auth flow"
1139
+
1140
+ # Launch Electron UI
1141
+ ./bin/AGI-ui
1142
+
1143
+ # Launch web dashboard
1144
+ ./bin/AGI-web
1145
+
1146
+ # Run tests
1147
+ bun test
1148
+ ```
1149
+
1150
+ ### Adding a new slash command
1151
+
1152
+ All Tier 2-9 commands share a factory in `src/commands/_tierHelper.ts`:
1153
+
1154
+ ```ts
1155
+ import { makeTierCommand, CODE_EDIT_TOOLS } from '../_tierHelper.js'
1156
+
1157
+ export default makeTierCommand({
1158
+ name: 'my-command',
1159
+ aliases: ['mc'],
1160
+ description: 'Does X',
1161
+ progressMessage: 'doing X',
1162
+ allowedTools: CODE_EDIT_TOOLS,
1163
+ buildPrompt: (args) => `## Protocol\n…your prompt here…`,
1164
+ })
1165
+ ```
1166
+
1167
+ Register it in `src/commands.ts` → import + add to the `COMMANDS()` array → `bun run build`.
1168
+
1169
+ ### Adding a new agent
1170
+
1171
+ Drop a `.md` or `.yaml` file into `src/skills/agency/<category>-<name>.md`. It's auto-discovered at startup — no registration needed.
1172
+
1173
+ ### Adding a new MCP server
1174
+
1175
+ Edit `.mcp.json`:
1176
+
1177
+ ```json
1178
+ "my-server": {
1179
+ "command": "npx",
1180
+ "args": ["-y", "@example/mcp-server"],
1181
+ "env": { "MY_TOKEN": "${MY_TOKEN}" }
1182
+ }
1183
+ ```
1184
+
1185
+ ---
1186
+
1187
+ ## 🛡 Privacy & Security
1188
+
1189
+ | | Detail |
1190
+ |---|---|
1191
+ | 🚫 **Zero telemetry** | 21 telemetry modules stubbed at build time (`scripts/build.ts`) |
1192
+ | 🚫 **No browser auto-opens** | We removed auto-launches to `localhost`, OAuth prompts, etc. |
1193
+ | 🔒 **Secrets stay local** | `.env` gitignored · never committed |
1194
+ | 🔓 **No vendor lock-in** | Swap `HF_MODEL_ID` to any HF-hosted model |
1195
+ | 🧹 **Secret scanner** | Built-in startup scan flags `.env` leaks, hardcoded tokens, and unsafe patterns |
1196
+ | 🦙 **Offline-capable** | Full Ollama fallback — code can run without internet |
1197
+
1198
+ ---
1199
+
1200
+ ## 📊 Benchmarks
1201
+
1202
+ Measured on MacBook Air M2 · HF Router + Together provider · unless noted:
1203
+
1204
+ | Operation | Latency |
1205
+ |---|---|
1206
+ | Electron Fast-mode first byte | 0.8 – 1.5 s |
1207
+ | Electron Fast-mode complete answer (100 tokens) | 2 – 4 s |
1208
+ | CLI Full AGI · single tool step | 4 – 8 s |
1209
+ | CLI Full AGI · 5-step task | 30 – 60 s |
1210
+ | CLI Full AGI · full feature build (portfolio site) | 2 – 5 min |
1211
+ | Ollama fallback · `llama3.2:3b` first byte | 45 – 60 s (cold) · 2 – 5 s (warm) |
1212
+ | Screen snap + vision caption (Moondream) | 1 – 3 s |
1213
+ | Build `dist/cli.mjs` | 3 – 5 s |
1214
+ | Startup: CLI `./cortex.mjs` | 1 – 2 s |
1215
+ | Startup: Electron UI | 1 – 2 s |
1216
+ | Startup: Web dashboard | 0.5 s |
1217
+
1218
+ ---
1219
+
1220
+ ## 🗺 Roadmap
1221
+
1222
+ ### ✅ Shipped
1223
+
1224
+ - 50+ slash commands across 9 tiers
1225
+ - 153 specialist agents
1226
+ - 38 MCP servers (Claude Code CLI level)
1227
+ - 4 UIs (CLI · Electron · Web · VS Code)
1228
+ - Auto-failover (`:together` → `:novita` → Ollama)
1229
+ - Screen watcher + vision
1230
+ - Voice I/O
1231
+ - RAG with pgvector
1232
+ - Autonomous daemon
1233
+ - Media + diagrams (image · video · Mermaid · Excalidraw · Draw.io)
1234
+ - macOS `.app` bundle
1235
+ - Smart router with latency/cost/health scoring
1236
+ - uvx installed for Python MCP servers
1237
+ - CORTEX_ALLOW_OPEN flag for app launches
1238
+
1239
+ ### 🚧 In progress
1240
+
1241
+ - Windows + Linux `.app` bundles
1242
+ - Streaming fix for `zai-org/GLM-5:together` (currently returns empty SSE)
1243
+ - Cloud sync for memory / history
1244
+ - Plugin marketplace for community agents
1245
+
1246
+ ### 🎯 Planned
1247
+
1248
+ - Voice wake word ("Hey CORTEX")
1249
+ - Inline code-lens in VS Code
1250
+ - Mobile app (React Native)
1251
+ - Self-hosted control panel for enterprise
1252
+
1253
+ ---
1254
+
1255
+ ## 🤝 Contributing
1256
+
1257
+ 1. Fork the repo
1258
+ 2. `git checkout -b feat/my-feature`
1259
+ 3. Hack — run `bun run build` after every `src/` change
1260
+ 4. Use `/smart-commit` (we eat our own dog food) to generate a conventional commit
1261
+ 5. Push + open a PR
1262
+
1263
+ All contributions welcome — new agents, new commands, new MCPs, UI polish, bug fixes, docs.
1264
+
1265
+ ---
1266
+
1267
+ ## 📜 License
1268
+
1269
+ MIT — do whatever you want, just don't sue me.
1270
+
1271
+ ---
1272
+
1273
+ ## 🙏 Credits
1274
+
1275
+ Built on the shoulders of the open-source community with extensive rewrites:
1276
+
1277
+ - 50+ custom AI commands (original)
1278
+ - Full HuggingFace provider integration (GLM-5 · Llama · DeepSeek · Qwen)
1279
+ - Electron floating UI with screen watcher
1280
+ - Web dashboard + VS Code extension
1281
+ - Smart multi-provider router with auto-failover
1282
+ - 153 specialist agents
1283
+ - 38 MCP server registry
1284
+ - Full telemetry & vendor-auth strip-out
1285
+ - Offline Ollama fallback chain
1286
+ - **Mission 09: Brain-Swarm** default boot theme
1287
+
1288
+ Powered by **HuggingFace Router** + **Together AI** + **Novita** + **zai-org/GLM-5** + **Ollama**.
1289
+
1290
+ ---
1291
+
1292
+ <p align="center">
1293
+ <strong>⭐ Star the repo if CORTEX saves you even one hour</strong><br/>
1294
+ <a href="https://github.com/gokul77898/Cortex">github.com/gokul77898/Cortex</a>
1295
+ </p>