@mrpatronz/nexusflow 0.2.12 → 0.2.17

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 (233) hide show
  1. package/.github/dependabot.yml +52 -52
  2. package/.github/workflows/dependabot-merge.yml +53 -0
  3. package/.github/workflows/release.yml +112 -100
  4. package/.vscode/launch.json +17 -17
  5. package/.vscode/tasks.json +17 -17
  6. package/GETTING_STARTED.md +114 -109
  7. package/README.md +336 -311
  8. package/desktop/build-installer.js +228 -0
  9. package/desktop/build.js +118 -0
  10. package/desktop/installer/nexusflow.iss +35 -0
  11. package/desktop/neutralino.config.json +39 -0
  12. package/desktop/package-lock.json +1060 -0
  13. package/desktop/package.json +14 -0
  14. package/dist/commands/add-repo.d.ts.map +1 -1
  15. package/dist/commands/add-repo.js +24 -14
  16. package/dist/commands/add-repo.js.map +1 -1
  17. package/dist/commands/commit.js +1 -1
  18. package/dist/commands/commit.js.map +1 -1
  19. package/dist/commands/desktop.d.ts +12 -0
  20. package/dist/commands/desktop.d.ts.map +1 -0
  21. package/dist/commands/desktop.js +119 -0
  22. package/dist/commands/desktop.js.map +1 -0
  23. package/dist/commands/diff.js +1 -1
  24. package/dist/commands/diff.js.map +1 -1
  25. package/dist/commands/doctor.js +1 -1
  26. package/dist/commands/doctor.js.map +1 -1
  27. package/dist/commands/handoff.js +1 -1
  28. package/dist/commands/handoff.js.map +1 -1
  29. package/dist/commands/logs.js +1 -1
  30. package/dist/commands/logs.js.map +1 -1
  31. package/dist/commands/open.d.ts.map +1 -1
  32. package/dist/commands/open.js +12 -7
  33. package/dist/commands/open.js.map +1 -1
  34. package/dist/commands/pack.js +1 -1
  35. package/dist/commands/pack.js.map +1 -1
  36. package/dist/commands/refresh.js +13 -8
  37. package/dist/commands/refresh.js.map +1 -1
  38. package/dist/commands/remove.d.ts.map +1 -1
  39. package/dist/commands/remove.js +12 -7
  40. package/dist/commands/remove.js.map +1 -1
  41. package/dist/commands/start.js +1 -1
  42. package/dist/commands/start.js.map +1 -1
  43. package/dist/commands/status.js +1 -1
  44. package/dist/commands/status.js.map +1 -1
  45. package/dist/commands/stop.js +1 -1
  46. package/dist/commands/stop.js.map +1 -1
  47. package/dist/commands/sync.d.ts.map +1 -1
  48. package/dist/commands/sync.js +14 -11
  49. package/dist/commands/sync.js.map +1 -1
  50. package/dist/commands/tui.d.ts +8 -0
  51. package/dist/commands/tui.d.ts.map +1 -0
  52. package/dist/commands/tui.js +386 -0
  53. package/dist/commands/tui.js.map +1 -0
  54. package/dist/commands/ui.d.ts +3 -1
  55. package/dist/commands/ui.d.ts.map +1 -1
  56. package/dist/commands/ui.js +76 -19
  57. package/dist/commands/ui.js.map +1 -1
  58. package/dist/core/workspace.d.ts +7 -0
  59. package/dist/core/workspace.d.ts.map +1 -1
  60. package/dist/core/workspace.js +45 -1
  61. package/dist/core/workspace.js.map +1 -1
  62. package/dist/generators/base.d.ts.map +1 -1
  63. package/dist/generators/base.js +78 -66
  64. package/dist/generators/base.js.map +1 -1
  65. package/dist/generators/codex.js +11 -11
  66. package/dist/generators/copilot.js +17 -17
  67. package/dist/generators/cursor.js +5 -5
  68. package/dist/generators/index.d.ts.map +1 -1
  69. package/dist/generators/index.js +64 -50
  70. package/dist/generators/index.js.map +1 -1
  71. package/dist/generators/map-generator.js +14 -14
  72. package/dist/generators/skills-generator.js +28 -28
  73. package/dist/gui/app_logo.png +0 -0
  74. package/dist/gui/assets/index-Ct3qq-X4.js +25 -0
  75. package/dist/gui/assets/index-P_ZrgHXg.css +1 -0
  76. package/dist/gui/icons.svg +24 -24
  77. package/dist/gui/index.html +18 -18
  78. package/dist/index.js +43 -0
  79. package/dist/index.js.map +1 -1
  80. package/dist/orchestration/runner.d.ts +5 -6
  81. package/dist/orchestration/runner.d.ts.map +1 -1
  82. package/dist/orchestration/runner.js +105 -102
  83. package/dist/orchestration/runner.js.map +1 -1
  84. package/dist/server.d.ts.map +1 -1
  85. package/dist/server.js +235 -2
  86. package/dist/server.js.map +1 -1
  87. package/dist/server.test.js +78 -0
  88. package/dist/server.test.js.map +1 -1
  89. package/dist/types.d.ts +4 -0
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/utils/detect-editors.js +1 -1
  92. package/dist/utils/detect-editors.js.map +1 -1
  93. package/dist/utils/detect-editors.test.js +3 -3
  94. package/dist/utils/detect-editors.test.js.map +1 -1
  95. package/dist/utils/git.d.ts +16 -0
  96. package/dist/utils/git.d.ts.map +1 -1
  97. package/dist/utils/git.js +52 -0
  98. package/dist/utils/git.js.map +1 -1
  99. package/dist/utils/multi-git.d.ts +2 -0
  100. package/dist/utils/multi-git.d.ts.map +1 -1
  101. package/dist/utils/multi-git.js +5 -2
  102. package/dist/utils/multi-git.js.map +1 -1
  103. package/dist/utils/prompts.d.ts +1 -0
  104. package/dist/utils/prompts.d.ts.map +1 -1
  105. package/dist/utils/prompts.js +77 -15
  106. package/dist/utils/prompts.js.map +1 -1
  107. package/dist/utils/update-check.d.ts +3 -1
  108. package/dist/utils/update-check.d.ts.map +1 -1
  109. package/dist/utils/update-check.js +23 -6
  110. package/dist/utils/update-check.js.map +1 -1
  111. package/dist/utils/workflows.d.ts +11 -0
  112. package/dist/utils/workflows.d.ts.map +1 -0
  113. package/dist/utils/workflows.js +156 -0
  114. package/dist/utils/workflows.js.map +1 -0
  115. package/dist/utils/workflows.test.d.ts +2 -0
  116. package/dist/utils/workflows.test.d.ts.map +1 -0
  117. package/dist/utils/workflows.test.js +86 -0
  118. package/dist/utils/workflows.test.js.map +1 -0
  119. package/extension/media/icon.svg +1 -0
  120. package/extension/package-lock.json +2673 -2811
  121. package/extension/package.json +108 -61
  122. package/extension/src/extension.ts +631 -168
  123. package/extension/tsconfig.json +21 -19
  124. package/gui/README.md +73 -73
  125. package/gui/e2e/wizard.spec.ts +346 -327
  126. package/gui/eslint.config.js +26 -22
  127. package/gui/index.html +17 -17
  128. package/gui/package-lock.json +3079 -3118
  129. package/gui/package.json +36 -36
  130. package/gui/playwright.config.ts +41 -41
  131. package/gui/public/app_logo.png +0 -0
  132. package/gui/public/icons.svg +24 -24
  133. package/gui/src/App.css +1 -1
  134. package/gui/src/App.tsx +3407 -2498
  135. package/gui/src/assets/vite.svg +1 -1
  136. package/gui/src/features/changes/ChangesViewer.tsx +388 -212
  137. package/gui/src/features/knowledge/KnowledgeBase.tsx +84 -84
  138. package/gui/src/features/onboarding/OnboardingWizard.tsx +230 -230
  139. package/gui/src/features/plan/ImplementationPlan.tsx +32 -32
  140. package/gui/src/features/services/ServiceConsole.tsx +250 -159
  141. package/gui/src/features/sessions/SessionHistory.tsx +195 -195
  142. package/gui/src/features/workspace/WorkspaceList.tsx +666 -514
  143. package/gui/src/index.css +152 -17
  144. package/gui/src/main.tsx +94 -10
  145. package/gui/src/types.ts +62 -62
  146. package/gui/tsconfig.app.json +25 -25
  147. package/gui/tsconfig.json +7 -7
  148. package/gui/tsconfig.node.json +24 -24
  149. package/gui/vite.config.ts +12 -12
  150. package/package.json +56 -55
  151. package/resources/workflows/plan-implement-review.md +8 -0
  152. package/resources/workflows/research-verify.md +6 -0
  153. package/resources/workflows/solo-developer.md +3 -0
  154. package/scripts/simulate-workspaces.ts +55 -55
  155. package/src/analyzers/detect-apis.ts +290 -290
  156. package/src/analyzers/detect-deps.ts +315 -315
  157. package/src/analyzers/detect-existing.ts +74 -74
  158. package/src/analyzers/detect-ports.ts +110 -110
  159. package/src/analyzers/index.ts +97 -97
  160. package/src/analyzers/messaging-analyzer.ts +254 -254
  161. package/src/analyzers/readme-summarizer.ts +102 -102
  162. package/src/analyzers/run-analyzer.ts +269 -269
  163. package/src/analyzers/tech-stack.ts +283 -283
  164. package/src/commands/add-repo.ts +157 -141
  165. package/src/commands/commands.test.ts +155 -155
  166. package/src/commands/commit.ts +131 -131
  167. package/src/commands/create.ts +207 -207
  168. package/src/commands/desktop.ts +128 -0
  169. package/src/commands/diff.ts +125 -125
  170. package/src/commands/doctor.ts +357 -357
  171. package/src/commands/handoff.ts +266 -266
  172. package/src/commands/init.ts +134 -134
  173. package/src/commands/list.ts +46 -46
  174. package/src/commands/logs.ts +63 -63
  175. package/src/commands/mcp.ts +92 -92
  176. package/src/commands/open.ts +129 -121
  177. package/src/commands/pack.ts +73 -73
  178. package/src/commands/refresh.ts +147 -139
  179. package/src/commands/remove.ts +98 -90
  180. package/src/commands/start.ts +117 -117
  181. package/src/commands/status.ts +54 -54
  182. package/src/commands/stop.ts +55 -55
  183. package/src/commands/sync.ts +151 -145
  184. package/src/commands/tui.ts +424 -0
  185. package/src/commands/ui.ts +111 -47
  186. package/src/core/config.test.ts +96 -96
  187. package/src/core/config.ts +115 -115
  188. package/src/core/graph.ts +344 -344
  189. package/src/core/packer.test.ts +99 -99
  190. package/src/core/packer.ts +107 -107
  191. package/src/core/scanner.test.ts +61 -61
  192. package/src/core/scanner.ts +91 -91
  193. package/src/core/workspace.ts +380 -333
  194. package/src/core/worktree.ts +120 -120
  195. package/src/generators/antigravity.ts +32 -32
  196. package/src/generators/base.ts +240 -227
  197. package/src/generators/claude.ts +34 -34
  198. package/src/generators/codex.ts +48 -48
  199. package/src/generators/copilot.ts +56 -56
  200. package/src/generators/cursor.ts +44 -44
  201. package/src/generators/index.ts +250 -230
  202. package/src/generators/map-generator.test.ts +159 -159
  203. package/src/generators/map-generator.ts +542 -542
  204. package/src/generators/plan-generator.ts +481 -481
  205. package/src/generators/skills-generator.ts +259 -259
  206. package/src/index.ts +426 -382
  207. package/src/mcp/server.ts +294 -294
  208. package/src/orchestration/detect.ts +313 -313
  209. package/src/orchestration/index.ts +7 -7
  210. package/src/orchestration/runner.ts +283 -279
  211. package/src/server.test.ts +555 -464
  212. package/src/server.ts +1308 -1047
  213. package/src/types.ts +408 -403
  214. package/src/utils/detect-ai.test.ts +44 -44
  215. package/src/utils/detect-ai.ts +84 -84
  216. package/src/utils/detect-editors.test.ts +48 -48
  217. package/src/utils/detect-editors.ts +57 -57
  218. package/src/utils/git.test.ts +74 -74
  219. package/src/utils/git.ts +117 -61
  220. package/src/utils/local-ai.test.ts +130 -130
  221. package/src/utils/local-ai.ts +111 -111
  222. package/src/utils/multi-git.ts +313 -306
  223. package/src/utils/prompts.ts +209 -135
  224. package/src/utils/session-finder.ts +483 -483
  225. package/src/utils/system-scanner.test.ts +89 -89
  226. package/src/utils/system-scanner.ts +96 -96
  227. package/src/utils/update-check.ts +309 -275
  228. package/src/utils/workflows.test.ts +114 -0
  229. package/src/utils/workflows.ts +178 -0
  230. package/tsconfig.json +19 -19
  231. package/vitest.config.ts +14 -14
  232. package/dist/gui/assets/index-Ca2VRMrQ.js +0 -22
  233. package/dist/gui/assets/index-fj0RJiOb.css +0 -2
@@ -1,32 +1,32 @@
1
- import React from 'react';
2
- import { ListOrdered, RefreshCw } from 'lucide-react';
3
-
4
- interface ImplementationPlanProps {
5
- planContent: string;
6
- planLoading: boolean;
7
- }
8
-
9
- export const ImplementationPlan: React.FC<ImplementationPlanProps> = ({
10
- planContent,
11
- planLoading,
12
- }) => {
13
- return (
14
- <div className="bg-[#090d1a]/20 border border-gray-800/60 rounded-xl p-4">
15
- <header className="flex justify-between items-center mb-4">
16
- <h4 className="text-sm font-bold text-white flex items-center gap-2">
17
- <ListOrdered size={16} className="text-cyan-400" /> Inter-Repo Implementation Plan (nexusflow-plan.md)
18
- </h4>
19
- </header>
20
-
21
- {planLoading ? (
22
- <div className="flex justify-center py-10">
23
- <RefreshCw className="animate-spin text-indigo-400" size={20} />
24
- </div>
25
- ) : (
26
- <div className="bg-gray-950/40 border border-gray-800/30 rounded-xl p-4 text-gray-350 text-xs leading-relaxed overflow-auto font-mono whitespace-pre-wrap max-h-96">
27
- {planContent || "No implementation plan generated yet."}
28
- </div>
29
- )}
30
- </div>
31
- );
32
- };
1
+ import React from 'react';
2
+ import { ListOrdered, RefreshCw } from 'lucide-react';
3
+
4
+ interface ImplementationPlanProps {
5
+ planContent: string;
6
+ planLoading: boolean;
7
+ }
8
+
9
+ export const ImplementationPlan: React.FC<ImplementationPlanProps> = ({
10
+ planContent,
11
+ planLoading,
12
+ }) => {
13
+ return (
14
+ <div className="bg-[#090d1a]/20 border border-gray-800/60 rounded-xl p-4">
15
+ <header className="flex justify-between items-center mb-4">
16
+ <h4 className="text-sm font-bold text-white flex items-center gap-2">
17
+ <ListOrdered size={16} className="text-cyan-400" /> Inter-Repo Implementation Plan (nexusflow-plan.md)
18
+ </h4>
19
+ </header>
20
+
21
+ {planLoading ? (
22
+ <div className="flex justify-center py-10">
23
+ <RefreshCw className="animate-spin text-indigo-400" size={20} />
24
+ </div>
25
+ ) : (
26
+ <div className="bg-gray-950/40 border border-gray-800/30 rounded-xl p-4 text-gray-350 text-xs leading-relaxed overflow-auto font-mono whitespace-pre-wrap max-h-96">
27
+ {planContent || "No implementation plan generated yet."}
28
+ </div>
29
+ )}
30
+ </div>
31
+ );
32
+ };
@@ -1,159 +1,250 @@
1
- import React from 'react';
2
- import { Play, Square, AlertTriangle } from 'lucide-react';
3
- import type { Feature, ServiceConfig, RunningService, OrchestrationDetection } from '../../types.js';
4
-
5
- interface ServiceConsoleProps {
6
- ws: Feature;
7
- services: ServiceConfig[];
8
- runningServices: RunningService[];
9
- selectedLogService: string | null;
10
- serviceLogs: string;
11
- logsEndRef: React.RefObject<HTMLDivElement | null>;
12
- setSelectedLogService: (val: string | null) => void;
13
- handleStartServices: (wsId: string) => Promise<void>;
14
- handleStopServices: (wsId: string) => Promise<void>;
15
- orchTools: OrchestrationDetection[];
16
- servicesLoading: boolean;
17
- }
18
-
19
- export const ServiceConsole: React.FC<ServiceConsoleProps> = ({
20
- ws,
21
- services,
22
- runningServices,
23
- selectedLogService,
24
- serviceLogs,
25
- logsEndRef,
26
- setSelectedLogService,
27
- handleStartServices,
28
- handleStopServices,
29
- orchTools,
30
- servicesLoading,
31
- }) => {
32
- return (
33
- <div>
34
- {servicesLoading && (
35
- <div className="flex items-center gap-2 text-[10px] text-gray-500 mb-3 animate-pulse">
36
- <span className="w-1.5 h-1.5 rounded-full bg-indigo-500 animate-ping"></span>
37
- <span>Scanning service configurations...</span>
38
- </div>
39
- )}
40
- {orchTools && orchTools.length > 0 && (
41
- <div className="flex items-center gap-3 bg-indigo-500/5 border border-indigo-500/20 rounded-xl p-4 mb-4 text-xs text-indigo-300">
42
- <AlertTriangle size={16} className="text-indigo-400 shrink-0" />
43
- <div>
44
- <strong>Orchestration manifest detected:</strong> {orchTools.map((t) => t.tool).join(', ')}. You can start them inside sub-repos.
45
- </div>
46
- </div>
47
- )}
48
- {/* Telemetry Dashboard Grid */}
49
- <div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
50
- {/* Telemetry 1: CPU */}
51
- <div className="bg-gray-950/40 border border-gray-800/60 rounded-xl p-4 flex flex-col justify-between">
52
- <div className="flex justify-between items-center text-xs font-semibold text-gray-400 mb-2">
53
- <span>Simulated CPU Load</span>
54
- <span className={runningServices.length > 0 ? "text-emerald-400" : "text-gray-500"}>
55
- {runningServices.length > 0 ? '4.8%' : '0%'}
56
- </span>
57
- </div>
58
- <div className="w-full bg-gray-800 rounded-full h-1.5 mb-2 overflow-hidden">
59
- <div
60
- className={`h-1.5 rounded-full transition-all duration-500 ${runningServices.length > 0 ? "bg-gradient-to-r from-emerald-500 to-teal-400 animate-pulse" : "bg-gray-700"}`}
61
- style={{ width: runningServices.length > 0 ? '48%' : '0%' }}
62
- ></div>
63
- </div>
64
- <span className="text-[10px] text-gray-500">Fluctuating active worker processes</span>
65
- </div>
66
-
67
- {/* Telemetry 2: Memory */}
68
- <div className="bg-gray-950/40 border border-gray-800/60 rounded-xl p-4 flex flex-col justify-between">
69
- <div className="flex justify-between items-center text-xs font-semibold text-gray-400 mb-2">
70
- <span>Simulated Memory Allocation</span>
71
- <span className={runningServices.length > 0 ? "text-cyan-400" : "text-gray-500"}>
72
- {runningServices.length > 0 ? '192 MB' : '0 MB'}
73
- </span>
74
- </div>
75
- <div className="w-full bg-gray-800 rounded-full h-1.5 mb-2 overflow-hidden">
76
- <div
77
- className={`h-1.5 rounded-full transition-all duration-500 ${runningServices.length > 0 ? "bg-gradient-to-r from-cyan-500 to-indigo-400" : "bg-gray-700"}`}
78
- style={{ width: runningServices.length > 0 ? '65%' : '0%' }}
79
- ></div>
80
- </div>
81
- <span className="text-[10px] text-gray-500">Working set size for spawned servers</span>
82
- </div>
83
-
84
- {/* Telemetry 3: Environment Health */}
85
- <div className="bg-gray-950/40 border border-gray-800/60 rounded-xl p-4 flex flex-col justify-between">
86
- <div className="flex justify-between items-center text-xs font-semibold text-gray-400 mb-2">
87
- <span>Active Workspace Status</span>
88
- <span className={`inline-flex items-center gap-1 text-[10px] uppercase font-bold tracking-wider ${runningServices.length > 0 ? "text-emerald-400" : "text-gray-500"}`}>
89
- <span className={`w-1.5 h-1.5 rounded-full ${runningServices.length > 0 ? "bg-emerald-500 animate-ping" : "bg-gray-600"}`}></span>
90
- {runningServices.length > 0 ? 'HEALTHY (ONLINE)' : 'STANDBY (OFFLINE)'}
91
- </span>
92
- </div>
93
- <div className="text-xs text-white font-medium truncate">
94
- {runningServices.length > 0 ? `${runningServices.length} processes active` : "All processes offline"}
95
- </div>
96
- <span className="text-[10px] text-gray-500">Service state mapping</span>
97
- </div>
98
- </div>
99
-
100
- <div className="flex gap-2 mb-6">
101
- <button
102
- className="inline-flex items-center justify-center gap-1.5 px-4 py-2.5 bg-emerald-500 hover:bg-emerald-600 text-white rounded-lg text-xs font-semibold transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed shadow-md shadow-emerald-500/10 hover:-translate-y-0.5 active:translate-y-0"
103
- onClick={() => handleStartServices(ws.branchName)}
104
- disabled={runningServices.length > 0}
105
- >
106
- <Play size={14} /> Start All Services
107
- </button>
108
- <button
109
- className="inline-flex items-center justify-center gap-1.5 px-4 py-2.5 bg-rose-600 hover:bg-rose-700 text-white rounded-lg text-xs font-semibold transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed shadow-md shadow-rose-600/10 hover:-translate-y-0.5 active:translate-y-0"
110
- onClick={() => handleStopServices(ws.branchName)}
111
- disabled={runningServices.length === 0}
112
- >
113
- <Square size={14} /> Stop All
114
- </button>
115
- </div>
116
-
117
- {/* Interactive Console Screen */}
118
- {services.length > 0 && (
119
- <div className="border border-gray-800/80 rounded-xl overflow-hidden shadow-2xl bg-gray-950/60">
120
- {/* Terminal Window Header */}
121
- <div className="flex items-center justify-between bg-gray-900/80 px-4 py-3 border-b border-gray-800/60">
122
- <div className="flex items-center gap-2">
123
- <div className="flex gap-1.5">
124
- <span className="w-3 h-3 rounded-full bg-rose-500/20 border border-rose-500/30"></span>
125
- <span className="w-3 h-3 rounded-full bg-amber-500/20 border border-amber-500/30"></span>
126
- <span className="w-3 h-3 rounded-full bg-emerald-500/20 border border-emerald-500/30"></span>
127
- </div>
128
- <span className="text-[11px] font-mono text-gray-400 font-semibold ml-2">nexusflow-terminal: {selectedLogService}</span>
129
- </div>
130
- <div className="flex gap-1 bg-gray-950/40 p-1 rounded-lg border border-gray-800/60">
131
- {services.map((svc) => (
132
- <button
133
- key={svc.name}
134
- className={`px-3 py-1 rounded-md text-[10px] font-mono font-bold transition-all cursor-pointer ${
135
- selectedLogService === svc.name
136
- ? 'bg-slate-800 text-white shadow-sm'
137
- : 'text-gray-500 hover:text-gray-300'
138
- }`}
139
- onClick={() => setSelectedLogService(svc.name)}
140
- >
141
- {svc.name}
142
- </button>
143
- ))}
144
- </div>
145
- </div>
146
-
147
- {/* Terminal Screen Body */}
148
- <div className="bg-[#030408] p-5 font-mono text-[11px] text-cyan-400/90 h-80 overflow-y-auto whitespace-pre-wrap shadow-inner relative scrollbar-thin scrollbar-thumb-gray-800">
149
- <div className="absolute top-3 right-3 text-[9px] bg-slate-900/60 border border-gray-800 text-cyan-500/60 px-2 py-0.5 rounded font-mono select-none uppercase tracking-wider">
150
- LIVE LOGS
151
- </div>
152
- {serviceLogs}
153
- <div ref={logsEndRef}></div>
154
- </div>
155
- </div>
156
- )}
157
- </div>
158
- );
159
- };
1
+ import React from 'react';
2
+ import { Play, Square, AlertTriangle, Terminal, Maximize2, Minimize2, Trash2, Cpu, Activity, RefreshCw } from 'lucide-react';
3
+ import type { Feature, ServiceConfig, RunningService, OrchestrationDetection } from '../../types.js';
4
+
5
+ interface ServiceConsoleProps {
6
+ ws: Feature;
7
+ services: ServiceConfig[];
8
+ runningServices: RunningService[];
9
+ selectedLogService: string | null;
10
+ serviceLogs: string;
11
+ logsEndRef: React.RefObject<HTMLDivElement | null>;
12
+ setSelectedLogService: (val: string | null) => void;
13
+ handleStartServices: (wsId: string) => Promise<void>;
14
+ handleStopServices: (wsId: string) => Promise<void>;
15
+ orchTools: OrchestrationDetection[];
16
+ servicesLoading: boolean;
17
+ }
18
+
19
+ export const ServiceConsole: React.FC<ServiceConsoleProps> = ({
20
+ ws,
21
+ services,
22
+ runningServices,
23
+ selectedLogService,
24
+ serviceLogs,
25
+ logsEndRef,
26
+ setSelectedLogService,
27
+ handleStartServices,
28
+ handleStopServices,
29
+ orchTools,
30
+ servicesLoading,
31
+ }) => {
32
+ const [termTheme, setTermTheme] = React.useState<'classic' | 'matrix' | 'dracula'>('classic');
33
+ const [isExpanded, setIsExpanded] = React.useState(false);
34
+ const [clearedLogsLength, setClearedLogsLength] = React.useState<Record<string, number>>({});
35
+
36
+ const handleClearLogs = () => {
37
+ if (selectedLogService) {
38
+ setClearedLogsLength((prev) => ({ ...prev, [selectedLogService]: serviceLogs.length }));
39
+ }
40
+ };
41
+
42
+ const isCleared = selectedLogService ? (clearedLogsLength[selectedLogService] === serviceLogs.length) : false;
43
+ const activeLogs = selectedLogService && isCleared ? '' : serviceLogs;
44
+
45
+ const getThemeClass = () => {
46
+ switch (termTheme) {
47
+ case 'matrix': return 'term-matrix';
48
+ case 'dracula': return 'term-dracula';
49
+ default: return 'term-classic';
50
+ }
51
+ };
52
+
53
+ const getStatusColor = (name: string) => {
54
+ const isRunning = runningServices.some((rs) => rs.name === name && rs.pid > 0);
55
+ return isRunning ? 'bg-emerald-500 animate-pulse-glow-green' : 'bg-rose-500';
56
+ };
57
+
58
+ const isAnyRunning = runningServices.some((rs) => rs.pid > 0);
59
+
60
+ return (
61
+ <div className="animate-fade-in">
62
+ {servicesLoading && (
63
+ <div className="flex items-center gap-2 text-[10px] text-indigo-400 mb-4 animate-pulse">
64
+ <RefreshCw className="animate-spin" size={12} />
65
+ <span className="font-semibold tracking-wider uppercase">Scanning service configurations...</span>
66
+ </div>
67
+ )}
68
+ {orchTools && orchTools.length > 0 && (
69
+ <div className="flex items-center gap-3 bg-indigo-500/5 border border-indigo-500/20 rounded-xl p-4 mb-5 text-xs text-indigo-300">
70
+ <AlertTriangle size={16} className="text-indigo-400 shrink-0 animate-bounce" />
71
+ <div>
72
+ <strong>Orchestration manifest detected:</strong> {orchTools.map((t) => t.tool).join(', ')}. You can start them inside sub-repos.
73
+ </div>
74
+ </div>
75
+ )}
76
+
77
+ {/* Telemetry Dashboard Grid */}
78
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
79
+ {/* Telemetry 1: CPU */}
80
+ <div className="glass-card p-5 rounded-2xl border border-slate-800/40 relative overflow-hidden transition-all duration-300 before:absolute before:inset-x-0 before:top-0 before:h-[1px] before:bg-gradient-to-r before:from-indigo-500/10 via-purple-500/10 to-transparent">
81
+ <div className="flex justify-between items-center text-xs font-semibold text-slate-400 mb-3">
82
+ <span className="flex items-center gap-1.5"><Cpu size={14} className="text-indigo-400" /> Simulated CPU Load</span>
83
+ <span className={isAnyRunning ? "text-emerald-400 font-mono font-bold" : "text-slate-550 font-mono"}>
84
+ {isAnyRunning ? '4.8%' : '0%'}
85
+ </span>
86
+ </div>
87
+ <div className="w-full bg-slate-900 rounded-full h-1.5 mb-2 overflow-hidden border border-white/5">
88
+ <div
89
+ className={`h-1.5 rounded-full transition-all duration-500 ${isAnyRunning ? "bg-gradient-to-r from-emerald-500 to-teal-400" : "bg-slate-800"}`}
90
+ style={{ width: isAnyRunning ? '48%' : '0%' }}
91
+ ></div>
92
+ </div>
93
+ <span className="text-[10px] text-slate-550">Fluctuating active worker processes</span>
94
+ </div>
95
+
96
+ {/* Telemetry 2: Memory */}
97
+ <div className="glass-card p-5 rounded-2xl border border-slate-800/40 relative overflow-hidden transition-all duration-300 before:absolute before:inset-x-0 before:top-0 before:h-[1px] before:bg-gradient-to-r before:from-indigo-500/10 via-purple-500/10 to-transparent">
98
+ <div className="flex justify-between items-center text-xs font-semibold text-slate-400 mb-3">
99
+ <span className="flex items-center gap-1.5"><Activity size={14} className="text-indigo-400" /> Simulated Memory</span>
100
+ <span className={isAnyRunning ? "text-cyan-400 font-mono font-bold" : "text-slate-550 font-mono"}>
101
+ {isAnyRunning ? '192 MB' : '0 MB'}
102
+ </span>
103
+ </div>
104
+ <div className="w-full bg-slate-900 rounded-full h-1.5 mb-2 overflow-hidden border border-white/5">
105
+ <div
106
+ className={`h-1.5 rounded-full transition-all duration-500 ${isAnyRunning ? "bg-gradient-to-r from-cyan-500 to-indigo-400" : "bg-slate-800"}`}
107
+ style={{ width: isAnyRunning ? '65%' : '0%' }}
108
+ ></div>
109
+ </div>
110
+ <span className="text-[10px] text-slate-550">Working set size for spawned servers</span>
111
+ </div>
112
+
113
+ {/* Telemetry 3: Environment Health */}
114
+ <div className="glass-card p-5 rounded-2xl border border-slate-800/40 relative overflow-hidden transition-all duration-300 before:absolute before:inset-x-0 before:top-0 before:h-[1px] before:bg-gradient-to-r before:from-indigo-500/10 via-purple-500/10 to-transparent">
115
+ <div className="flex justify-between items-center text-xs font-semibold text-slate-400 mb-3">
116
+ <span>Workspace Status</span>
117
+ <span className={`inline-flex items-center gap-1.5 text-[9px] uppercase font-bold tracking-wider px-2 py-0.5 rounded-full border ${isAnyRunning ? "text-emerald-400 bg-emerald-500/10 border-emerald-500/20" : "text-slate-500 bg-slate-950/40 border-slate-900"}`}>
118
+ <span className={`w-1.5 h-1.5 rounded-full ${isAnyRunning ? "bg-emerald-400 animate-ping" : "bg-slate-600"}`}></span>
119
+ {isAnyRunning ? 'Active' : 'Standby'}
120
+ </span>
121
+ </div>
122
+ <div className="text-xs text-white font-semibold mb-2">
123
+ {isAnyRunning ? `${runningServices.filter(rs => rs.pid > 0).length} processes active` : "All processes offline"}
124
+ </div>
125
+ <span className="text-[10px] text-slate-550">Service state mapping</span>
126
+ </div>
127
+ </div>
128
+
129
+ {/* Action Controls */}
130
+ <div className="flex gap-3 mb-6">
131
+ <button
132
+ className="inline-flex items-center justify-center gap-2 px-5 py-3 bg-emerald-650 hover:bg-emerald-600 text-white rounded-xl text-xs font-bold transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed shadow-md shadow-emerald-500/10 hover:-translate-y-0.5 active:translate-y-0"
133
+ onClick={() => handleStartServices(ws.branchName)}
134
+ disabled={isAnyRunning}
135
+ >
136
+ <Play size={14} /> Start All Services
137
+ </button>
138
+ <button
139
+ className="inline-flex items-center justify-center gap-2 px-5 py-3 bg-rose-950/40 border border-rose-900/60 hover:bg-rose-900/60 hover:border-rose-800 text-red-200 rounded-xl text-xs font-bold transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed hover:-translate-y-0.5 active:translate-y-0"
140
+ onClick={() => handleStopServices(ws.branchName)}
141
+ disabled={!isAnyRunning}
142
+ >
143
+ <Square size={14} /> Stop All
144
+ </button>
145
+ </div>
146
+
147
+ {/* Split-Pane DevOps Console */}
148
+ {services.length > 0 && (
149
+ <div className="grid grid-cols-1 lg:grid-cols-12 border border-slate-900 rounded-2xl overflow-hidden shadow-2xl bg-slate-950/40 backdrop-blur-md">
150
+
151
+ {/* Left Pane: Services List (4 cols) */}
152
+ <div className="lg:col-span-4 border-b lg:border-b-0 lg:border-r border-slate-900 p-5 bg-slate-950/60">
153
+ <h4 className="text-[10px] text-slate-450 uppercase font-bold tracking-wider mb-4 flex items-center gap-1.5 border-b border-slate-900 pb-2">
154
+ <Terminal size={12} className="text-indigo-400" /> Background Services
155
+ </h4>
156
+ <div className="flex flex-col gap-2 max-h-[400px] overflow-y-auto pr-1">
157
+ {services.map((svc) => {
158
+ const isSelected = selectedLogService === svc.name;
159
+ return (
160
+ <div
161
+ key={svc.name}
162
+ className={`flex flex-col p-3 rounded-xl border cursor-pointer transition-all ${
163
+ isSelected
164
+ ? 'bg-indigo-500/10 border-indigo-500/40 text-white shadow-[0_0_15px_rgba(99,102,241,0.05)]'
165
+ : 'bg-slate-950/30 border-slate-900 hover:border-slate-800 text-slate-400 hover:text-slate-200'
166
+ }`}
167
+ onClick={() => setSelectedLogService(svc.name)}
168
+ >
169
+ <div className="flex items-center justify-between gap-2">
170
+ <div className="flex items-center gap-2 truncate">
171
+ <span className={`h-2 w-2 rounded-full ${getStatusColor(svc.name)}`}></span>
172
+ <span className="font-bold text-xs truncate">{svc.name}</span>
173
+ </div>
174
+ {svc.port && (
175
+ <span className="text-[9px] font-mono px-2 py-0.5 bg-slate-900 border border-slate-850 rounded text-slate-400">
176
+ Port: {svc.port}
177
+ </span>
178
+ )}
179
+ </div>
180
+ <code className="text-[9px] font-mono text-slate-500 mt-2 truncate bg-slate-950/50 p-1.5 rounded border border-slate-900/60 block">
181
+ {svc.command} {svc.args.join(' ')}
182
+ </code>
183
+ </div>
184
+ );
185
+ })}
186
+ </div>
187
+ </div>
188
+
189
+ {/* Right Pane: Logs Console (8 cols) */}
190
+ <div className="lg:col-span-8 flex flex-col min-w-0 bg-[#03050a]">
191
+ {/* Console Header */}
192
+ <div className="flex flex-col sm:flex-row sm:items-center sm:justify-between bg-slate-950/80 px-5 py-3 border-b border-slate-900 gap-3">
193
+ <div className="flex items-center gap-2">
194
+ <span className="font-mono text-xs font-bold text-indigo-400 text-glow-indigo">{selectedLogService || 'no-service'}</span>
195
+ <span className="text-slate-700">|</span>
196
+ <span className="text-[9px] font-mono bg-indigo-500/10 text-indigo-300 border border-indigo-500/20 px-2 py-0.5 rounded uppercase font-semibold">stdout_stream</span>
197
+ </div>
198
+
199
+ <div className="flex items-center gap-3 self-end sm:self-auto">
200
+ {/* Theme Toggle */}
201
+ <div className="flex bg-slate-900 border border-slate-850 p-0.5 rounded-lg text-[9px] font-semibold text-slate-400">
202
+ {(['classic', 'matrix', 'dracula'] as const).map((t) => (
203
+ <button
204
+ key={t}
205
+ className={`px-2 py-1 rounded-md capitalize cursor-pointer transition-all ${termTheme === t ? 'bg-slate-800 text-white font-bold' : 'hover:text-white'}`}
206
+ onClick={() => setTermTheme(t)}
207
+ >
208
+ {t}
209
+ </button>
210
+ ))}
211
+ </div>
212
+
213
+ {/* Operations */}
214
+ <div className="flex gap-1.5">
215
+ <button
216
+ onClick={handleClearLogs}
217
+ className="p-1.5 bg-slate-900 border border-slate-850 text-slate-400 hover:text-white rounded-lg transition-all cursor-pointer"
218
+ title="Clear Console"
219
+ >
220
+ <Trash2 size={13} />
221
+ </button>
222
+ <button
223
+ onClick={() => setIsExpanded(!isExpanded)}
224
+ className="p-1.5 bg-slate-900 border border-slate-850 text-slate-400 hover:text-white rounded-lg transition-all cursor-pointer"
225
+ title={isExpanded ? "Minimize Console" : "Expand Console"}
226
+ >
227
+ {isExpanded ? <Minimize2 size={13} /> : <Maximize2 size={13} />}
228
+ </button>
229
+ </div>
230
+ </div>
231
+ </div>
232
+
233
+ {/* Terminal Body */}
234
+ <div className={`p-5 font-mono text-[10.5px] leading-relaxed overflow-y-auto whitespace-pre-wrap select-text selection:bg-indigo-500/30 transition-all duration-300 relative ${getThemeClass()} ${isExpanded ? 'h-[520px]' : 'h-80'}`}>
235
+ <div className="absolute top-4 right-5 text-[8px] bg-slate-900/60 border border-white/5 text-slate-400/50 px-2.5 py-0.5 rounded-md font-mono select-none uppercase tracking-widest font-bold">
236
+ LIVE LOGGER
237
+ </div>
238
+ {activeLogs.trim() ? (
239
+ activeLogs
240
+ ) : (
241
+ <span className="text-slate-650 italic font-mono">(no log content recorded)</span>
242
+ )}
243
+ <div ref={logsEndRef}></div>
244
+ </div>
245
+ </div>
246
+ </div>
247
+ )}
248
+ </div>
249
+ );
250
+ };