@mrpatronz/nexusflow 0.2.18 → 1.3.0

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 (236) hide show
  1. package/README.md +27 -3
  2. package/dist/analyzers/index.d.ts +23 -0
  3. package/dist/analyzers/index.d.ts.map +1 -1
  4. package/dist/analyzers/index.js +62 -0
  5. package/dist/analyzers/index.js.map +1 -1
  6. package/dist/commands/commands.test.js +20 -6
  7. package/dist/commands/commands.test.js.map +1 -1
  8. package/dist/commands/commit.d.ts +2 -0
  9. package/dist/commands/commit.d.ts.map +1 -1
  10. package/dist/commands/commit.js +27 -5
  11. package/dist/commands/commit.js.map +1 -1
  12. package/dist/commands/diff.d.ts +9 -2
  13. package/dist/commands/diff.d.ts.map +1 -1
  14. package/dist/commands/diff.js +36 -12
  15. package/dist/commands/diff.js.map +1 -1
  16. package/dist/commands/doctor.js +2 -2
  17. package/dist/commands/doctor.js.map +1 -1
  18. package/dist/commands/handoff.js +2 -2
  19. package/dist/commands/handoff.js.map +1 -1
  20. package/dist/commands/refresh.d.ts +4 -2
  21. package/dist/commands/refresh.d.ts.map +1 -1
  22. package/dist/commands/refresh.js +20 -36
  23. package/dist/commands/refresh.js.map +1 -1
  24. package/dist/commands/schedule.d.ts +35 -0
  25. package/dist/commands/schedule.d.ts.map +1 -0
  26. package/dist/commands/schedule.js +151 -0
  27. package/dist/commands/schedule.js.map +1 -0
  28. package/dist/commands/sync.d.ts.map +1 -1
  29. package/dist/commands/sync.js +58 -50
  30. package/dist/commands/sync.js.map +1 -1
  31. package/dist/core/analysis-cache.d.ts +58 -0
  32. package/dist/core/analysis-cache.d.ts.map +1 -0
  33. package/dist/core/analysis-cache.js +116 -0
  34. package/dist/core/analysis-cache.js.map +1 -0
  35. package/dist/core/analysis-cache.test.d.ts +2 -0
  36. package/dist/core/analysis-cache.test.d.ts.map +1 -0
  37. package/dist/core/analysis-cache.test.js +108 -0
  38. package/dist/core/analysis-cache.test.js.map +1 -0
  39. package/dist/core/refresh.d.ts +41 -0
  40. package/dist/core/refresh.d.ts.map +1 -0
  41. package/dist/core/refresh.js +60 -0
  42. package/dist/core/refresh.js.map +1 -0
  43. package/dist/core/scheduler.d.ts +117 -0
  44. package/dist/core/scheduler.d.ts.map +1 -0
  45. package/dist/core/scheduler.js +247 -0
  46. package/dist/core/scheduler.js.map +1 -0
  47. package/dist/core/scheduler.test.d.ts +2 -0
  48. package/dist/core/scheduler.test.d.ts.map +1 -0
  49. package/dist/core/scheduler.test.js +111 -0
  50. package/dist/core/scheduler.test.js.map +1 -0
  51. package/dist/core/sync.d.ts +50 -0
  52. package/dist/core/sync.d.ts.map +1 -0
  53. package/dist/core/sync.js +92 -0
  54. package/dist/core/sync.js.map +1 -0
  55. package/dist/core/workspace-state.d.ts +51 -0
  56. package/dist/core/workspace-state.d.ts.map +1 -0
  57. package/dist/core/workspace-state.js +108 -0
  58. package/dist/core/workspace-state.js.map +1 -0
  59. package/dist/core/workspace-state.test.d.ts +2 -0
  60. package/dist/core/workspace-state.test.d.ts.map +1 -0
  61. package/dist/core/workspace-state.test.js +84 -0
  62. package/dist/core/workspace-state.test.js.map +1 -0
  63. package/dist/generators/index.d.ts +7 -1
  64. package/dist/generators/index.d.ts.map +1 -1
  65. package/dist/generators/index.js +14 -1
  66. package/dist/generators/index.js.map +1 -1
  67. package/dist/gui/assets/index-Bdbld6yY.css +1 -0
  68. package/dist/gui/assets/index-D8iJPvnk.js +26 -0
  69. package/dist/gui/index.html +2 -2
  70. package/dist/index.js +107 -4
  71. package/dist/index.js.map +1 -1
  72. package/dist/mcp/server.d.ts.map +1 -1
  73. package/dist/mcp/server.js +42 -0
  74. package/dist/mcp/server.js.map +1 -1
  75. package/dist/server.d.ts.map +1 -1
  76. package/dist/server.js +175 -13
  77. package/dist/server.js.map +1 -1
  78. package/dist/server.test.js +66 -0
  79. package/dist/server.test.js.map +1 -1
  80. package/dist/types.d.ts +31 -0
  81. package/dist/types.d.ts.map +1 -1
  82. package/dist/utils/multi-git.d.ts +54 -8
  83. package/dist/utils/multi-git.d.ts.map +1 -1
  84. package/dist/utils/multi-git.js +129 -21
  85. package/dist/utils/multi-git.js.map +1 -1
  86. package/dist/utils/multi-git.test.d.ts +2 -0
  87. package/dist/utils/multi-git.test.d.ts.map +1 -0
  88. package/dist/utils/multi-git.test.js +125 -0
  89. package/dist/utils/multi-git.test.js.map +1 -0
  90. package/package.json +13 -1
  91. package/.agents/skills/ccc/SKILL.md +0 -71
  92. package/.agents/skills/ccc/references/management.md +0 -110
  93. package/.agents/skills/ccc/references/settings.md +0 -126
  94. package/.github/dependabot.yml +0 -52
  95. package/.github/workflows/ci.yml +0 -44
  96. package/.github/workflows/dependabot-merge.yml +0 -53
  97. package/.github/workflows/release-desktop.yml +0 -67
  98. package/.github/workflows/release-npm.yml +0 -65
  99. package/.github/workflows/release-vscode.yml +0 -61
  100. package/.vscode/launch.json +0 -17
  101. package/.vscode/tasks.json +0 -17
  102. package/GETTING_STARTED.md +0 -114
  103. package/desktop/build-installer.js +0 -228
  104. package/desktop/build.js +0 -118
  105. package/desktop/installer/nexusflow.iss +0 -35
  106. package/desktop/neutralino.config.json +0 -39
  107. package/desktop/package-lock.json +0 -1060
  108. package/desktop/package.json +0 -14
  109. package/dist/gui/assets/index-CB-jWded.css +0 -1
  110. package/dist/gui/assets/index-DDXpZZu3.js +0 -25
  111. package/extension/media/icon.svg +0 -1
  112. package/extension/package-lock.json +0 -6044
  113. package/extension/package.json +0 -117
  114. package/extension/src/extension.ts +0 -653
  115. package/extension/tsconfig.json +0 -21
  116. package/gui/README.md +0 -73
  117. package/gui/e2e/wizard.spec.ts +0 -346
  118. package/gui/eslint.config.js +0 -26
  119. package/gui/index.html +0 -17
  120. package/gui/package-lock.json +0 -3079
  121. package/gui/package.json +0 -36
  122. package/gui/playwright.config.ts +0 -41
  123. package/gui/public/app_logo.png +0 -0
  124. package/gui/public/favicon.svg +0 -1
  125. package/gui/public/icons.svg +0 -24
  126. package/gui/src/App.css +0 -1
  127. package/gui/src/App.tsx +0 -3632
  128. package/gui/src/assets/hero.png +0 -0
  129. package/gui/src/assets/react.svg +0 -1
  130. package/gui/src/assets/vite.svg +0 -1
  131. package/gui/src/features/changes/ChangesViewer.tsx +0 -388
  132. package/gui/src/features/knowledge/KnowledgeBase.tsx +0 -84
  133. package/gui/src/features/onboarding/OnboardingWizard.tsx +0 -230
  134. package/gui/src/features/plan/ImplementationPlan.tsx +0 -32
  135. package/gui/src/features/services/ServiceConsole.tsx +0 -250
  136. package/gui/src/features/sessions/SessionHistory.tsx +0 -195
  137. package/gui/src/features/workspace/WorkspaceList.tsx +0 -666
  138. package/gui/src/index.css +0 -152
  139. package/gui/src/main.tsx +0 -94
  140. package/gui/src/types.ts +0 -62
  141. package/gui/tsconfig.app.json +0 -25
  142. package/gui/tsconfig.json +0 -7
  143. package/gui/tsconfig.node.json +0 -24
  144. package/gui/vite.config.ts +0 -12
  145. package/resources/workflows/plan-implement-review.md +0 -8
  146. package/resources/workflows/research-verify.md +0 -6
  147. package/resources/workflows/solo-developer.md +0 -3
  148. package/scripts/simulate-workspaces.ts +0 -55
  149. package/skills-lock.json +0 -11
  150. package/src/analyzers/detect-apis.ts +0 -290
  151. package/src/analyzers/detect-deps.ts +0 -315
  152. package/src/analyzers/detect-existing.ts +0 -74
  153. package/src/analyzers/detect-ports.ts +0 -110
  154. package/src/analyzers/index.ts +0 -97
  155. package/src/analyzers/messaging-analyzer.ts +0 -254
  156. package/src/analyzers/readme-summarizer.ts +0 -102
  157. package/src/analyzers/run-analyzer.ts +0 -269
  158. package/src/analyzers/tech-stack.ts +0 -283
  159. package/src/commands/adapter.ts +0 -348
  160. package/src/commands/add-repo.ts +0 -156
  161. package/src/commands/commands.test.ts +0 -156
  162. package/src/commands/commit.ts +0 -131
  163. package/src/commands/config.ts +0 -52
  164. package/src/commands/create.ts +0 -204
  165. package/src/commands/desktop.ts +0 -128
  166. package/src/commands/diff.ts +0 -125
  167. package/src/commands/doctor.ts +0 -370
  168. package/src/commands/handoff.ts +0 -266
  169. package/src/commands/init.ts +0 -134
  170. package/src/commands/list.ts +0 -46
  171. package/src/commands/logs.ts +0 -63
  172. package/src/commands/mcp.ts +0 -94
  173. package/src/commands/open.ts +0 -129
  174. package/src/commands/refresh.ts +0 -137
  175. package/src/commands/remove.ts +0 -98
  176. package/src/commands/start.ts +0 -117
  177. package/src/commands/status.ts +0 -54
  178. package/src/commands/stop.ts +0 -55
  179. package/src/commands/sync.ts +0 -147
  180. package/src/commands/tui.ts +0 -484
  181. package/src/commands/ui.ts +0 -111
  182. package/src/core/adapters/local-storage.ts +0 -66
  183. package/src/core/adapters/obsidian-storage.ts +0 -151
  184. package/src/core/adapters/registry.ts +0 -44
  185. package/src/core/adapters/storage.test.ts +0 -174
  186. package/src/core/adapters/vault-storage.ts +0 -86
  187. package/src/core/config.test.ts +0 -96
  188. package/src/core/config.ts +0 -140
  189. package/src/core/graph.ts +0 -344
  190. package/src/core/plugins/index.ts +0 -17
  191. package/src/core/plugins/loader.ts +0 -36
  192. package/src/core/ports/storage.ts +0 -71
  193. package/src/core/scanner.test.ts +0 -61
  194. package/src/core/scanner.ts +0 -91
  195. package/src/core/storage.ts +0 -37
  196. package/src/core/workspace.ts +0 -487
  197. package/src/core/worktree.ts +0 -120
  198. package/src/generators/antigravity.ts +0 -32
  199. package/src/generators/base.ts +0 -243
  200. package/src/generators/claude.ts +0 -34
  201. package/src/generators/codex.ts +0 -48
  202. package/src/generators/copilot.ts +0 -56
  203. package/src/generators/cursor.ts +0 -44
  204. package/src/generators/diff-context.ts +0 -75
  205. package/src/generators/index.ts +0 -322
  206. package/src/generators/map-generator.test.ts +0 -159
  207. package/src/generators/map-generator.ts +0 -539
  208. package/src/generators/plan-generator.ts +0 -483
  209. package/src/generators/skills-generator.ts +0 -259
  210. package/src/index.ts +0 -539
  211. package/src/mcp/server.ts +0 -294
  212. package/src/orchestration/detect.ts +0 -313
  213. package/src/orchestration/index.ts +0 -7
  214. package/src/orchestration/runner.ts +0 -283
  215. package/src/server.test.ts +0 -618
  216. package/src/server.ts +0 -1314
  217. package/src/types.ts +0 -415
  218. package/src/utils/detect-ai.test.ts +0 -44
  219. package/src/utils/detect-ai.ts +0 -84
  220. package/src/utils/detect-editors.test.ts +0 -48
  221. package/src/utils/detect-editors.ts +0 -57
  222. package/src/utils/git.test.ts +0 -74
  223. package/src/utils/git.ts +0 -117
  224. package/src/utils/local-ai.test.ts +0 -130
  225. package/src/utils/local-ai.ts +0 -116
  226. package/src/utils/multi-git.ts +0 -313
  227. package/src/utils/prompts.ts +0 -209
  228. package/src/utils/session-finder.ts +0 -483
  229. package/src/utils/system-scanner.test.ts +0 -89
  230. package/src/utils/system-scanner.ts +0 -96
  231. package/src/utils/update-check.ts +0 -286
  232. package/src/utils/workflow-advisor.ts +0 -118
  233. package/src/utils/workflows.test.ts +0 -114
  234. package/src/utils/workflows.ts +0 -178
  235. package/tsconfig.json +0 -19
  236. package/vitest.config.ts +0 -14
@@ -1,484 +0,0 @@
1
- /**
2
- * @module commands/tui
3
- * Fully interactive Terminal User Interface (TUI) for NexusFlow workspaces.
4
- */
5
-
6
- import readline from 'node:readline';
7
- import path from 'node:path';
8
- import fs from 'node:fs/promises';
9
- import { fileURLToPath } from 'node:url';
10
- import chalk from 'chalk';
11
- import { execa } from 'execa';
12
-
13
- import { loadConfig } from '../core/config.js';
14
- import { loadFeatureConfig, listWorkspaces } from '../core/workspace.js';
15
- import { getWorkspaceRepos, getRepoStatus, type WorkspaceRepo, type RepoStatus } from '../utils/multi-git.js';
16
-
17
- const COMMANDS = ['sync', 'doctor', 'refresh', 'status', 'start', 'stop', 'logs', 'list', 'create', 'open', 'pack', 'remove', 'add-repo', 'help'];
18
-
19
- interface TuiState {
20
- workspacePath: string;
21
- branchName: string;
22
- repos: WorkspaceRepo[];
23
- repoStatuses: Record<string, RepoStatus>;
24
- consoleLogs: string[];
25
- inputMode: boolean;
26
- inputValue: string;
27
- cursorIndex: number;
28
- activeCommandRunning: boolean;
29
- activeSuggestionIndex: number;
30
- }
31
-
32
- export async function tuiCommand(options: { workspace?: string }): Promise<void> {
33
- // Resolve active workspace
34
- let workspacePath = options.workspace ? path.resolve(options.workspace) : '';
35
- let branchName = 'Unknown';
36
-
37
- if (!workspacePath) {
38
- const cwdFeature = await loadFeatureConfig(process.cwd());
39
- if (cwdFeature) {
40
- workspacePath = cwdFeature.workspacePath;
41
- branchName = cwdFeature.branchName;
42
- } else {
43
- const config = await loadConfig();
44
- const workspaces = await listWorkspaces(config.workspacesDir);
45
- if (workspaces.length === 0) {
46
- console.log(chalk.yellow('\nNo workspaces found. Run "nexusflow create" to initialize one.\n'));
47
- return;
48
- }
49
- // Use the first active workspace as default
50
- workspacePath = workspaces[0].workspacePath;
51
- branchName = workspaces[0].branchName;
52
- }
53
- }
54
-
55
- // Load repositories inside workspace
56
- let repos: WorkspaceRepo[] = [];
57
- try {
58
- repos = await getWorkspaceRepos(workspacePath);
59
- } catch {
60
- console.log(chalk.red(`\nCould not resolve repos. Make sure nexusflow.json exists in ${workspacePath}\n`));
61
- return;
62
- }
63
-
64
- // Initial State Setup
65
- const state: TuiState = {
66
- workspacePath,
67
- branchName,
68
- repos,
69
- repoStatuses: {},
70
- consoleLogs: [
71
- 'NexusFlow TUI Command Center v2.0 - Initialized Successfully.',
72
- 'Connecting workspace streams...',
73
- `Active Workspace Path: ${workspacePath}`,
74
- 'Ready. Press [/] to type commands, or [s] to sync, [d] to run diagnostics.',
75
- ],
76
- inputMode: false,
77
- inputValue: '',
78
- cursorIndex: 0,
79
- activeCommandRunning: false,
80
- activeSuggestionIndex: 0,
81
- };
82
-
83
- // Helper to append log lines
84
- const log = (msg: string) => {
85
- state.consoleLogs.push(msg);
86
- if (state.consoleLogs.length > 50) {
87
- state.consoleLogs.shift();
88
- }
89
- };
90
-
91
- // Fetch Git status for all worktrees
92
- const updateGitStatus = async () => {
93
- for (const repo of state.repos) {
94
- const status = await getRepoStatus(repo.path);
95
- state.repoStatuses[repo.name] = status;
96
- }
97
- };
98
-
99
- // Run initial git fetch
100
- await updateGitStatus();
101
-
102
- // Enter Full Screen Screen Buffer
103
- process.stdout.write('\x1B[?1049h'); // Switch to alternate screen buffer
104
- process.stdout.write('\x1B[?25l'); // Hide cursor
105
-
106
- // Setup raw terminal mode for key capture
107
- readline.emitKeypressEvents(process.stdin);
108
- if (process.stdin.isTTY) {
109
- process.stdin.setRawMode(true);
110
- }
111
-
112
- // Drawing Screen Logic
113
- const draw = () => {
114
- const cols = process.stdout.columns || 80;
115
- const rows = process.stdout.rows || 24;
116
-
117
- // Clear Screen Buffer
118
- process.stdout.write('\x1B[H');
119
-
120
- // Row 0: Top Header Banner
121
- const bannerTitle = ` ⚔ NexusFlow Workspace Console [🌿 ${state.branchName}] `;
122
- const statusText = ` SYSTEM: ONLINE (Port 3000) `;
123
- const headerFill = cols - bannerTitle.length - statusText.length - 2;
124
- process.stdout.write(
125
- chalk.bgCyan.black(bannerTitle) +
126
- chalk.bgGray.white('─'.repeat(Math.max(0, headerFill))) +
127
- chalk.bgGreen.black(statusText) +
128
- '\n'
129
- );
130
-
131
- // Grid Panel Calculations
132
- const leftWidth = Math.floor(cols * 0.35);
133
- const rightWidth = cols - leftWidth - 1;
134
- const mainHeight = rows - (state.inputMode ? 14 : 13); // Adjust height when suggestion line is visible
135
-
136
- // Left Panel contents array
137
- const leftLines: string[] = [];
138
- leftLines.push(chalk.cyan.bold(' šŸ“‚ Repositories & Worktrees '));
139
- leftLines.push(' '.repeat(leftWidth));
140
-
141
- for (const repo of state.repos) {
142
- const status = state.repoStatuses[repo.name];
143
- const statusIndicator = status?.hasChanges
144
- ? chalk.yellow(`(${status.changedFiles.length} files modified)`)
145
- : chalk.green('(clean)');
146
- leftLines.push(` 🌿 ${chalk.bold(repo.name)} ${statusIndicator}`);
147
-
148
- // Changed files list
149
- if (status?.hasChanges) {
150
- status.changedFiles.slice(0, 4).forEach((file) => {
151
- leftLines.push(` ${chalk.yellow('[M]')} ${path.basename(file)}`);
152
- });
153
- if (status.changedFiles.length > 4) {
154
- leftLines.push(` ... and ${status.changedFiles.length - 4} more`);
155
- }
156
- }
157
- leftLines.push(' '.repeat(leftWidth));
158
- }
159
-
160
- // Right Panel contents array
161
- const rightLines: string[] = [];
162
- rightLines.push(chalk.cyan.bold(' šŸ¤– Model Context Protocol (MCP) & Status '));
163
- rightLines.push(' '.repeat(rightWidth));
164
- rightLines.push(` ${chalk.bold('MCP Server:')} nexusflow-mcp (State: ${chalk.green('Active')})`);
165
- rightLines.push(' Registered tools:');
166
- rightLines.push(` āš™ ${chalk.cyan('search_workspace')} Search workspace files fast`);
167
- rightLines.push(` āš™ ${chalk.cyan('get_service_logs')} Tail running logs`);
168
- rightLines.push(` āš™ ${chalk.cyan('delegate_to_local_agent')} Run local LLM diagnostics`);
169
- rightLines.push(' '.repeat(rightWidth));
170
- rightLines.push(chalk.cyan.bold(' 🧩 Custom Agent Skills '));
171
- rightLines.push(` • ${chalk.bold('dotnet-local-pack')} - Local Nuget compiler helper`);
172
- rightLines.push(` • ${chalk.bold('npm-link-helper')} - Automated worktree registry link`);
173
- rightLines.push(` • ${chalk.bold('antigravity-guide')} - Agent instruction manual`);
174
- rightLines.push(' '.repeat(rightWidth));
175
- rightLines.push(` ${chalk.bold('Health Scan:')} 🩺 doctor diagnostics: ${chalk.green('OK (0 warnings)')}`);
176
-
177
- // Render Middle Grid Rows
178
- for (let r = 0; r < mainHeight; r++) {
179
- const leftPart = leftLines[r] || '';
180
- const rightPart = rightLines[r] || '';
181
-
182
- const leftFilled = leftPart + ' '.repeat(Math.max(0, leftWidth - stripAnsi(leftPart).length));
183
- const rightFilled = rightPart + ' '.repeat(Math.max(0, rightWidth - stripAnsi(rightPart).length));
184
-
185
- process.stdout.write(leftFilled + chalk.gray('│') + rightFilled + '\n');
186
- }
187
-
188
- // Middle Horizontal Divider
189
- process.stdout.write(
190
- chalk.gray('ā”œ' + '─'.repeat(leftWidth) + '┼' + '─'.repeat(rightWidth) + '┤') + '\n'
191
- );
192
-
193
- // Logs Panel Header
194
- process.stdout.write(chalk.cyan.bold(' šŸ–„ļø Command Output Stream & Logs ') + '\n');
195
-
196
- // Render Logs Stream (Tails last 8 lines)
197
- const logHeight = 8;
198
- const startIdx = Math.max(0, state.consoleLogs.length - logHeight);
199
- const visibleLogs = state.consoleLogs.slice(startIdx, startIdx + logHeight);
200
-
201
- for (let i = 0; i < logHeight; i++) {
202
- const line = visibleLogs[i] || '';
203
- const filledLine = line + ' '.repeat(Math.max(0, cols - stripAnsi(line).length));
204
- process.stdout.write(filledLine + '\n');
205
- }
206
-
207
- // Bottom Divider
208
- process.stdout.write(chalk.gray('─'.repeat(cols)) + '\n');
209
-
210
- // Bottom Panel Prompt
211
- if (state.inputMode) {
212
- // Find matches
213
- const cmd = state.inputValue.trim().toLowerCase();
214
- const matches = COMMANDS.filter(c => c.startsWith(cmd));
215
-
216
- // Keep active index in bounds
217
- if (matches.length > 0) {
218
- state.activeSuggestionIndex = (state.activeSuggestionIndex + matches.length) % matches.length;
219
- } else {
220
- state.activeSuggestionIndex = 0;
221
- }
222
-
223
- let suggestionLine = '';
224
- if (matches.length > 0) {
225
- suggestionLine = chalk.dim(' Suggestions: ') + matches.map((m, idx) => {
226
- if (idx === state.activeSuggestionIndex) return chalk.black.bgCyan(` ${m} `); // Highlight active selection
227
- return chalk.cyan(m);
228
- }).join(' ');
229
- } else {
230
- suggestionLine = chalk.red(' No matching commands.');
231
- }
232
-
233
- const filledSuggestion = suggestionLine + ' '.repeat(Math.max(0, cols - stripAnsi(suggestionLine).length));
234
- process.stdout.write(filledSuggestion + '\n');
235
-
236
- // Focus Input mode
237
- const promptText = ` nexusflow > ${state.inputValue}`;
238
- process.stdout.write(chalk.bold.cyan(promptText) + ' '.repeat(Math.max(0, cols - promptText.length - 12)) + chalk.dim('[ESC] Cancel') + '\n');
239
- } else {
240
- // General Keyboard Command mode
241
- const controls = ' [s] Sync | [d] Doctor | [r] Refresh | [/] CLI Cmd | [q] Exit ';
242
- process.stdout.write(chalk.bgCyan.black(controls) + ' '.repeat(Math.max(0, cols - controls.length)) + '\n');
243
- }
244
- };
245
-
246
- // Strip ANSI color characters to calculate line lengths precisely
247
- const stripAnsi = (str: string) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
248
-
249
- // Render loop refresh
250
- draw();
251
-
252
- // Resize Listener
253
- const resizeHandler = () => {
254
- draw();
255
- };
256
- process.stdout.on('resize', resizeHandler);
257
-
258
- // Status Polling Loop
259
- let pollInterval = setInterval(async () => {
260
- await updateGitStatus();
261
- if (!state.inputMode && !state.activeCommandRunning) {
262
- draw();
263
- }
264
- }, 5000);
265
-
266
- // Exit Cleanup
267
- const cleanup = () => {
268
- clearInterval(pollInterval);
269
- process.stdout.off('resize', resizeHandler);
270
- process.stdout.write('\x1B[?1049l'); // Restore screen buffer
271
- process.stdout.write('\x1B[?25h'); // Show cursor
272
- if (process.stdin.isTTY) {
273
- process.stdin.setRawMode(false);
274
- }
275
- };
276
-
277
- // Keyboard Event Handlers
278
- const keypressHandler = async (str: any, key: any) => {
279
- if (key.ctrl && key.name === 'c') {
280
- cleanup();
281
- process.exit(0);
282
- }
283
-
284
- if (state.inputMode) {
285
- // --- Handle input text writing mode ---
286
- if (key.name === 'return') {
287
- let cmd = state.inputValue.trim();
288
- const matches = COMMANDS.filter(c => c.startsWith(cmd.toLowerCase()));
289
- if (matches.length > 0) {
290
- cmd = matches[state.activeSuggestionIndex % matches.length];
291
- }
292
-
293
- state.inputMode = false;
294
- state.inputValue = '';
295
- state.activeSuggestionIndex = 0;
296
-
297
- if (cmd) {
298
- state.activeCommandRunning = true;
299
- log(`Running: nexusflow ${cmd}...`);
300
- draw();
301
-
302
- try {
303
- const script = fileURLToPath(new URL('../index.js', import.meta.url));
304
- const args = cmd.split(' ');
305
-
306
- // Check if it's an interactive command
307
- const INTERACTIVE_COMMANDS = ['create', 'remove', 'rm', 'open', 'add-repo', 'add', 'init'];
308
- const isInteractive = INTERACTIVE_COMMANDS.some(
309
- (ic) => cmd.toLowerCase() === ic || cmd.toLowerCase().startsWith(ic + ' ')
310
- );
311
-
312
- if (isInteractive) {
313
- // Pause TUI and run command interactively
314
- process.stdin.off('keypress', keypressHandler);
315
- cleanup();
316
-
317
- // Clear alternate screen and show standard terminal
318
- console.log(chalk.bold.cyan(`\nEntering interactive mode for "nexusflow ${cmd}"...\n`));
319
-
320
- try {
321
- await execa('node', [script, ...args], {
322
- cwd: workspacePath,
323
- stdio: 'inherit',
324
- shell: process.platform === 'win32',
325
- });
326
- } catch (err: any) {
327
- console.error(chalk.red(`\nāœ– Command failed: ${err.message}`));
328
- }
329
-
330
- // Check if workspace still exists (in case it was deleted by 'remove')
331
- let workspaceExists = true;
332
- try {
333
- await fs.access(workspacePath);
334
- } catch {
335
- workspaceExists = false;
336
- }
337
-
338
- if (!workspaceExists) {
339
- console.log(chalk.bold.cyan('\nšŸ‘‹ Workspace deleted. Exiting NexusFlow TUI Dashboard.\n'));
340
- process.exit(0);
341
- }
342
-
343
- // Re-initialize TUI state
344
- process.stdout.write('\x1B[?1049h'); // Switch to alternate screen buffer
345
- process.stdout.write('\x1B[?25l'); // Hide cursor
346
- if (process.stdin.isTTY) {
347
- process.stdin.setRawMode(true);
348
- }
349
- process.stdout.on('resize', resizeHandler);
350
- process.stdin.on('keypress', keypressHandler);
351
-
352
- pollInterval = setInterval(async () => {
353
- await updateGitStatus();
354
- if (!state.inputMode && !state.activeCommandRunning) {
355
- draw();
356
- }
357
- }, 5000);
358
-
359
- state.activeCommandRunning = false;
360
- await updateGitStatus();
361
- draw();
362
- } else {
363
- // Run background command via execa
364
- const { stdout, stderr } = await execa('node', [script, ...args], { cwd: workspacePath });
365
-
366
- if (stdout) {
367
- stdout.split('\n').filter(Boolean).forEach((l) => log(` ${l}`));
368
- }
369
- if (stderr) {
370
- stderr.split('\n').filter(Boolean).forEach((l) => log(` ${chalk.red(l)}`));
371
- }
372
- log(chalk.green('āœ” Command completed successfully.'));
373
- }
374
- } catch (err: any) {
375
- log(chalk.red(`āœ– Command failed: ${err.message}`));
376
- } finally {
377
- state.activeCommandRunning = false;
378
- await updateGitStatus();
379
- draw();
380
- }
381
- } else {
382
- draw();
383
- }
384
- } else if (key.name === 'escape') {
385
- state.inputMode = false;
386
- state.inputValue = '';
387
- draw();
388
- } else if (key.name === 'tab') {
389
- const cmd = state.inputValue.trim().toLowerCase();
390
- const matches = COMMANDS.filter(c => c.startsWith(cmd));
391
- if (matches.length > 0) {
392
- const selected = matches[state.activeSuggestionIndex % matches.length];
393
- state.inputValue = selected + ' ';
394
- state.activeSuggestionIndex = 0;
395
- draw();
396
- }
397
- } else if (key.name === 'right' || key.name === 'down') {
398
- const cmd = state.inputValue.trim().toLowerCase();
399
- const matches = COMMANDS.filter(c => c.startsWith(cmd));
400
- if (matches.length > 0) {
401
- state.activeSuggestionIndex = (state.activeSuggestionIndex + 1) % matches.length;
402
- draw();
403
- }
404
- } else if (key.name === 'left' || key.name === 'up') {
405
- const cmd = state.inputValue.trim().toLowerCase();
406
- const matches = COMMANDS.filter(c => c.startsWith(cmd));
407
- if (matches.length > 0) {
408
- state.activeSuggestionIndex = (state.activeSuggestionIndex - 1 + matches.length) % matches.length;
409
- draw();
410
- }
411
- } else if (key.name === 'backspace') {
412
- state.inputValue = state.inputValue.slice(0, -1);
413
- state.activeSuggestionIndex = 0;
414
- draw();
415
- } else if (str && str.length === 1 && !key.ctrl && !key.meta) {
416
- state.inputValue += str;
417
- state.activeSuggestionIndex = 0;
418
- draw();
419
- }
420
- } else {
421
- // --- Handle single key shortcuts mode ---
422
- if (key.name === 'q') {
423
- cleanup();
424
- console.log(chalk.bold.cyan('\nšŸ‘‹ Exited NexusFlow TUI Dashboard.\n'));
425
- process.exit(0);
426
- } else if (str === '/') {
427
- state.inputMode = true;
428
- draw();
429
- } else if (key.name === 's') {
430
- state.activeCommandRunning = true;
431
- log('šŸ”„ Running Workspace Sync rebase...');
432
- draw();
433
-
434
- try {
435
- const script = fileURLToPath(new URL('../index.js', import.meta.url));
436
- const { stdout } = await execa('node', [script, 'sync'], { cwd: workspacePath });
437
- stdout.split('\n').filter(Boolean).forEach((l) => log(` ${l}`));
438
- log(chalk.green('āœ” Sync completed successfully.'));
439
- } catch (err: any) {
440
- log(chalk.red(`āœ– Sync failed: ${err.message}`));
441
- } finally {
442
- state.activeCommandRunning = false;
443
- await updateGitStatus();
444
- draw();
445
- }
446
- } else if (key.name === 'd') {
447
- state.activeCommandRunning = true;
448
- log('🩺 Running doctor diagnostics...');
449
- draw();
450
-
451
- try {
452
- const script = fileURLToPath(new URL('../index.js', import.meta.url));
453
- const { stdout } = await execa('node', [script, 'doctor'], { cwd: workspacePath });
454
- stdout.split('\n').filter(Boolean).forEach((l) => log(` ${l}`));
455
- log(chalk.green('āœ” Diagnostics check complete.'));
456
- } catch (err: any) {
457
- log(chalk.red(`āœ– Diagnostics failed: ${err.message}`));
458
- } finally {
459
- state.activeCommandRunning = false;
460
- await updateGitStatus();
461
- draw();
462
- }
463
- } else if (key.name === 'r') {
464
- state.activeCommandRunning = true;
465
- log('šŸ”„ Regenerating context manifest files...');
466
- draw();
467
-
468
- try {
469
- const script = fileURLToPath(new URL('../index.js', import.meta.url));
470
- const { stdout } = await execa('node', [script, 'refresh'], { cwd: workspacePath });
471
- stdout.split('\n').filter(Boolean).forEach((l) => log(` ${l}`));
472
- log(chalk.green('āœ” Context successfully refreshed.'));
473
- } catch (err: any) {
474
- log(chalk.red(`āœ– Refresh failed: ${err.message}`));
475
- } finally {
476
- state.activeCommandRunning = false;
477
- await updateGitStatus();
478
- draw();
479
- }
480
- }
481
- }
482
- };
483
- process.stdin.on('keypress', keypressHandler);
484
- }
@@ -1,111 +0,0 @@
1
- /**
2
- * @module commands/ui
3
- * Starts the Hono web server and opens the browser to the NexusFlow GUI.
4
- */
5
-
6
- import chalk from 'chalk';
7
- import { exec, spawn } from 'node:child_process';
8
- import { fileURLToPath } from 'node:url';
9
- import * as path from 'node:path';
10
- import * as net from 'node:net';
11
- import { startServer } from '../server.js';
12
-
13
- function isPortActive(port: number): Promise<boolean> {
14
- return new Promise((resolve) => {
15
- const socket = net.connect(port, 'localhost');
16
- socket.on('connect', () => {
17
- socket.destroy();
18
- resolve(true);
19
- });
20
- socket.on('error', () => {
21
- resolve(false);
22
- });
23
- });
24
- }
25
-
26
- function openBrowser(url: string): void {
27
- let openCmd = '';
28
- if (process.platform === 'win32') {
29
- openCmd = `start ${url}`;
30
- } else if (process.platform === 'darwin') {
31
- openCmd = `open ${url}`;
32
- } else {
33
- openCmd = `xdg-open ${url}`;
34
- }
35
-
36
- exec(openCmd, (err) => {
37
- if (err) {
38
- console.log(chalk.dim(` Could not auto-open browser. Please visit ${url} manually.`));
39
- }
40
- });
41
- }
42
-
43
- /**
44
- * Starts the local GUI server and opens the dashboard in the default browser.
45
- *
46
- * @param options - CLI options, including optional port, daemon, and server-only.
47
- */
48
- export async function uiCommand(options: { port?: string; daemon?: boolean; serverOnly?: boolean }): Promise<void> {
49
- const port = options.port ? parseInt(options.port, 10) : 3000;
50
- const url = `http://localhost:${port}`;
51
-
52
- console.log(chalk.bold.cyan('\nšŸ–„ļø NexusFlow — Web Dashboard\n'));
53
-
54
- // Check if port is already active
55
- const active = await isPortActive(port);
56
- if (active) {
57
- console.log(chalk.green(` āœ” Dashboard is already active at: ${chalk.bold(url)}`));
58
- if (!options.serverOnly) {
59
- console.log(chalk.dim(' Opening browser...'));
60
- openBrowser(url);
61
- }
62
- return;
63
- }
64
-
65
- // Handle Daemon mode (runs detached in the background)
66
- if (options.daemon) {
67
- console.log(chalk.dim(' Starting server in the background...'));
68
- try {
69
- const serverScript = fileURLToPath(new URL('../index.js', import.meta.url));
70
- const child = spawn(process.execPath, [serverScript, 'ui', '--port', String(port), '--server-only'], {
71
- detached: true,
72
- stdio: 'ignore'
73
- });
74
- child.unref();
75
-
76
- console.log(chalk.green(` āœ” Dashboard daemon successfully spawned.`));
77
- if (!options.serverOnly) {
78
- console.log(chalk.dim(' Opening browser...'));
79
- // Give the background process a brief moment to start listening
80
- await new Promise((resolve) => setTimeout(resolve, 600));
81
- openBrowser(url);
82
- }
83
- return;
84
- } catch (err) {
85
- const msg = err instanceof Error ? err.message : String(err);
86
- console.error(chalk.red(` āœ– Failed to start background daemon: ${msg}`));
87
- return;
88
- }
89
- }
90
-
91
- // Standard foreground blocking mode
92
- console.log(chalk.dim(' Starting local server...'));
93
- try {
94
- const { port: actualPort } = await startServer(port);
95
- const actualUrl = `http://localhost:${actualPort}`;
96
-
97
- console.log(chalk.green(` āœ” Dashboard running at: ${chalk.bold(actualUrl)}`));
98
- console.log(chalk.dim(' Press Ctrl+C to stop.\n'));
99
-
100
- if (!options.serverOnly) {
101
- openBrowser(actualUrl);
102
- }
103
-
104
- // Keep process alive
105
- await new Promise(() => {});
106
- } catch (error) {
107
- const msg = error instanceof Error ? error.message : String(error);
108
- console.error(chalk.red(` āœ– Failed to start dashboard: ${msg}`));
109
- }
110
- }
111
-
@@ -1,66 +0,0 @@
1
- import * as fs from 'node:fs/promises';
2
- import * as path from 'node:path';
3
- import type { StoragePort, StorageAdapterMeta } from '../ports/storage.js';
4
-
5
- export class LocalStorageAdapter implements StoragePort {
6
- readonly meta: StorageAdapterMeta = {
7
- name: 'local',
8
- displayName: 'Local Workspace',
9
- description: 'Write context files directly into the workspace directory.',
10
- configFields: [],
11
- };
12
-
13
- async writeWorkspaceFile(workspacePath: string, featureId: string, filename: string, content: string): Promise<void> {
14
- const filePath = path.join(workspacePath, filename);
15
- await fs.mkdir(path.dirname(filePath), { recursive: true });
16
- await fs.writeFile(filePath, content, 'utf8');
17
- }
18
-
19
- async readWorkspaceFile(workspacePath: string, featureId: string, filename: string): Promise<string> {
20
- const filePath = path.join(workspacePath, filename);
21
- return await fs.readFile(filePath, 'utf8');
22
- }
23
-
24
- async workspaceFileExists(workspacePath: string, featureId: string, filename: string): Promise<boolean> {
25
- const filePath = path.join(workspacePath, filename);
26
- try {
27
- await fs.access(filePath);
28
- return true;
29
- } catch {
30
- return false;
31
- }
32
- }
33
-
34
- resolveWorkspaceFileUrl(workspacePath: string, featureId: string, filename: string): string {
35
- return path.join(workspacePath, filename).replace(/\\/g, '/');
36
- }
37
-
38
- async writeBaseFile(workspacePath: string, repoName: string, filename: string, content: string): Promise<void> {
39
- const filePath = path.join(workspacePath, filename);
40
- await fs.mkdir(path.dirname(filePath), { recursive: true });
41
- await fs.writeFile(filePath, content, 'utf8');
42
- }
43
-
44
- async readBaseFile(workspacePath: string, repoName: string, filename: string): Promise<string> {
45
- const filePath = path.join(workspacePath, filename);
46
- return await fs.readFile(filePath, 'utf8');
47
- }
48
-
49
- async baseFileExists(workspacePath: string, repoName: string, filename: string): Promise<boolean> {
50
- const filePath = path.join(workspacePath, filename);
51
- try {
52
- await fs.access(filePath);
53
- return true;
54
- } catch {
55
- return false;
56
- }
57
- }
58
-
59
- resolveBaseFileUrl(workspacePath: string, repoName: string, filename: string): string {
60
- return path.join(workspacePath, filename).replace(/\\/g, '/');
61
- }
62
-
63
- async deleteWorkspace(workspacePath: string, featureId: string): Promise<void> {
64
- // NOP - local files are inside workspacePath, which is deleted directly on workspace removal.
65
- }
66
- }