@mrpatronz/nexusflow 0.2.13 ā 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/ccc/SKILL.md +71 -0
- package/.agents/skills/ccc/references/management.md +110 -0
- package/.agents/skills/ccc/references/settings.md +126 -0
- package/.github/workflows/ci.yml +44 -0
- package/.github/workflows/dependabot-merge.yml +53 -0
- package/.github/workflows/release-desktop.yml +67 -0
- package/.github/workflows/release-npm.yml +65 -0
- package/.github/workflows/release-vscode.yml +61 -0
- package/GETTING_STARTED.md +5 -0
- package/README.md +53 -0
- package/desktop/build-installer.js +228 -0
- package/desktop/build.js +118 -0
- package/desktop/installer/nexusflow.iss +35 -0
- package/desktop/neutralino.config.json +39 -0
- package/desktop/package-lock.json +1060 -0
- package/desktop/package.json +14 -0
- package/dist/commands/adapter.d.ts +27 -0
- package/dist/commands/adapter.d.ts.map +1 -0
- package/dist/commands/adapter.js +318 -0
- package/dist/commands/adapter.js.map +1 -0
- package/dist/commands/add-repo.d.ts.map +1 -1
- package/dist/commands/add-repo.js +0 -1
- package/dist/commands/add-repo.js.map +1 -1
- package/dist/commands/commands.test.js +2 -2
- package/dist/commands/commands.test.js.map +1 -1
- package/dist/commands/config.d.ts +22 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +50 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +14 -17
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/desktop.d.ts +12 -0
- package/dist/commands/desktop.d.ts.map +1 -0
- package/dist/commands/desktop.js +119 -0
- package/dist/commands/desktop.js.map +1 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +11 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/refresh.d.ts +1 -0
- package/dist/commands/refresh.d.ts.map +1 -1
- package/dist/commands/refresh.js +2 -14
- package/dist/commands/refresh.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +1 -8
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/tui.d.ts +8 -0
- package/dist/commands/tui.d.ts.map +1 -0
- package/dist/commands/tui.js +439 -0
- package/dist/commands/tui.js.map +1 -0
- package/dist/commands/ui.d.ts +3 -1
- package/dist/commands/ui.d.ts.map +1 -1
- package/dist/commands/ui.js +76 -19
- package/dist/commands/ui.js.map +1 -1
- package/dist/core/adapters/local-storage.d.ts +14 -0
- package/dist/core/adapters/local-storage.d.ts.map +1 -0
- package/dist/core/adapters/local-storage.js +58 -0
- package/dist/core/adapters/local-storage.js.map +1 -0
- package/dist/core/adapters/obsidian-storage.d.ts +28 -0
- package/dist/core/adapters/obsidian-storage.d.ts.map +1 -0
- package/dist/core/adapters/obsidian-storage.js +135 -0
- package/dist/core/adapters/obsidian-storage.js.map +1 -0
- package/dist/core/adapters/registry.d.ts +8 -0
- package/dist/core/adapters/registry.d.ts.map +1 -0
- package/dist/core/adapters/registry.js +37 -0
- package/dist/core/adapters/registry.js.map +1 -0
- package/dist/core/adapters/storage.test.d.ts +2 -0
- package/dist/core/adapters/storage.test.d.ts.map +1 -0
- package/dist/core/adapters/storage.test.js +106 -0
- package/dist/core/adapters/storage.test.js.map +1 -0
- package/dist/core/adapters/vault-storage.d.ts +16 -0
- package/dist/core/adapters/vault-storage.d.ts.map +1 -0
- package/dist/core/adapters/vault-storage.js +77 -0
- package/dist/core/adapters/vault-storage.js.map +1 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +28 -4
- package/dist/core/config.js.map +1 -1
- package/dist/core/plugins/index.d.ts +14 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/index.js +2 -0
- package/dist/core/plugins/index.js.map +1 -0
- package/dist/core/plugins/loader.d.ts +2 -0
- package/dist/core/plugins/loader.d.ts.map +1 -0
- package/dist/core/plugins/loader.js +34 -0
- package/dist/core/plugins/loader.js.map +1 -0
- package/dist/core/ports/storage.d.ts +59 -0
- package/dist/core/ports/storage.d.ts.map +1 -0
- package/dist/core/ports/storage.js +10 -0
- package/dist/core/ports/storage.js.map +1 -0
- package/dist/core/storage.d.ts +10 -0
- package/dist/core/storage.d.ts.map +1 -0
- package/dist/core/storage.js +29 -0
- package/dist/core/storage.js.map +1 -0
- package/dist/core/workspace.d.ts.map +1 -1
- package/dist/core/workspace.js +110 -16
- package/dist/core/workspace.js.map +1 -1
- package/dist/generators/base.d.ts.map +1 -1
- package/dist/generators/base.js +19 -6
- package/dist/generators/base.js.map +1 -1
- package/dist/generators/diff-context.d.ts +6 -0
- package/dist/generators/diff-context.d.ts.map +1 -0
- package/dist/generators/diff-context.js +68 -0
- package/dist/generators/diff-context.js.map +1 -0
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +75 -18
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/map-generator.d.ts.map +1 -1
- package/dist/generators/map-generator.js +7 -11
- package/dist/generators/map-generator.js.map +1 -1
- package/dist/generators/plan-generator.d.ts.map +1 -1
- package/dist/generators/plan-generator.js +3 -5
- package/dist/generators/plan-generator.js.map +1 -1
- package/dist/gui/app_logo.png +0 -0
- package/dist/gui/assets/index-CB-jWded.css +1 -0
- package/dist/gui/assets/index-DDXpZZu3.js +25 -0
- package/dist/gui/index.html +2 -2
- package/dist/index.js +174 -20
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +212 -28
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +173 -38
- package/dist/server.test.js.map +1 -1
- package/dist/types.d.ts +11 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/git.d.ts +16 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +52 -0
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/local-ai.d.ts.map +1 -1
- package/dist/utils/local-ai.js +7 -3
- package/dist/utils/local-ai.js.map +1 -1
- package/dist/utils/multi-git.d.ts +2 -0
- package/dist/utils/multi-git.d.ts.map +1 -1
- package/dist/utils/multi-git.js +5 -2
- package/dist/utils/multi-git.js.map +1 -1
- package/dist/utils/update-check.d.ts +3 -1
- package/dist/utils/update-check.d.ts.map +1 -1
- package/dist/utils/update-check.js +23 -34
- package/dist/utils/update-check.js.map +1 -1
- package/dist/utils/workflow-advisor.d.ts +16 -0
- package/dist/utils/workflow-advisor.d.ts.map +1 -0
- package/dist/utils/workflow-advisor.js +100 -0
- package/dist/utils/workflow-advisor.js.map +1 -0
- package/dist/utils/workflows.d.ts +11 -0
- package/dist/utils/workflows.d.ts.map +1 -0
- package/dist/utils/workflows.js +156 -0
- package/dist/utils/workflows.js.map +1 -0
- package/dist/utils/workflows.test.d.ts +2 -0
- package/dist/utils/workflows.test.d.ts.map +1 -0
- package/dist/utils/workflows.test.js +86 -0
- package/dist/utils/workflows.test.js.map +1 -0
- package/extension/media/icon.svg +1 -0
- package/extension/package-lock.json +4893 -1660
- package/extension/package.json +58 -11
- package/extension/src/extension.ts +476 -27
- package/extension/tsconfig.json +4 -2
- package/gui/e2e/wizard.spec.ts +19 -0
- package/gui/package-lock.json +342 -381
- package/gui/package.json +12 -12
- package/gui/public/app_logo.png +0 -0
- package/gui/src/App.tsx +991 -81
- package/gui/src/features/workspace/WorkspaceList.tsx +30 -30
- package/gui/src/index.css +64 -22
- package/gui/src/main.tsx +89 -5
- package/package.json +11 -12
- package/resources/workflows/plan-implement-review.md +8 -0
- package/resources/workflows/research-verify.md +6 -0
- package/resources/workflows/solo-developer.md +3 -0
- package/skills-lock.json +11 -0
- package/src/commands/adapter.ts +348 -0
- package/src/commands/add-repo.ts +0 -1
- package/src/commands/commands.test.ts +3 -2
- package/src/commands/config.ts +52 -0
- package/src/commands/create.ts +14 -17
- package/src/commands/desktop.ts +128 -0
- package/src/commands/doctor.ts +13 -0
- package/src/commands/mcp.ts +2 -0
- package/src/commands/refresh.ts +4 -14
- package/src/commands/sync.ts +2 -8
- package/src/commands/tui.ts +484 -0
- package/src/commands/ui.ts +83 -19
- package/src/core/adapters/local-storage.ts +66 -0
- package/src/core/adapters/obsidian-storage.ts +151 -0
- package/src/core/adapters/registry.ts +44 -0
- package/src/core/adapters/storage.test.ts +174 -0
- package/src/core/adapters/vault-storage.ts +86 -0
- package/src/core/config.ts +29 -4
- package/src/core/plugins/index.ts +17 -0
- package/src/core/plugins/loader.ts +36 -0
- package/src/core/ports/storage.ts +71 -0
- package/src/core/storage.ts +37 -0
- package/src/core/workspace.ts +122 -15
- package/src/generators/base.ts +21 -5
- package/src/generators/diff-context.ts +75 -0
- package/src/generators/index.ts +93 -21
- package/src/generators/map-generator.ts +7 -10
- package/src/generators/plan-generator.ts +6 -4
- package/src/index.ts +178 -21
- package/src/server.test.ts +193 -39
- package/src/server.ts +238 -28
- package/src/types.ts +14 -2
- package/src/utils/git.ts +56 -0
- package/src/utils/local-ai.ts +8 -3
- package/src/utils/multi-git.ts +16 -9
- package/src/utils/update-check.ts +42 -31
- package/src/utils/workflow-advisor.ts +118 -0
- package/src/utils/workflows.test.ts +114 -0
- package/src/utils/workflows.ts +178 -0
- package/.github/workflows/release.yml +0 -100
- package/dist/commands/pack.d.ts +0 -7
- package/dist/commands/pack.d.ts.map +0 -1
- package/dist/commands/pack.js +0 -64
- package/dist/commands/pack.js.map +0 -1
- package/dist/core/packer.d.ts +0 -14
- package/dist/core/packer.d.ts.map +0 -1
- package/dist/core/packer.js +0 -87
- package/dist/core/packer.js.map +0 -1
- package/dist/core/packer.test.d.ts +0 -2
- package/dist/core/packer.test.d.ts.map +0 -1
- package/dist/core/packer.test.js +0 -82
- package/dist/core/packer.test.js.map +0 -1
- package/dist/gui/assets/index-CFWwqFux.js +0 -23
- package/dist/gui/assets/index-Dvc9QMvl.css +0 -2
- package/src/commands/pack.ts +0 -73
- package/src/core/packer.test.ts +0 -99
- package/src/core/packer.ts +0 -107
package/src/commands/sync.ts
CHANGED
|
@@ -48,9 +48,7 @@ export async function syncCommand(workspaceArg?: string): Promise<void> {
|
|
|
48
48
|
|
|
49
49
|
for (const repo of repos) {
|
|
50
50
|
console.log(`Repository: ${chalk.bold(repo.name)}`);
|
|
51
|
-
|
|
52
|
-
// Let's assume 'main' as default unless we fetch/read it.
|
|
53
|
-
const defaultBranch = 'main'; // We can default to 'main' as specified in requirements
|
|
51
|
+
const defaultBranch = repo.defaultBranch || 'main';
|
|
54
52
|
|
|
55
53
|
const spinner = chalk.dim(' Rebasing...');
|
|
56
54
|
process.stdout.write(spinner);
|
|
@@ -95,11 +93,7 @@ export async function syncCommand(workspaceArg?: string): Promise<void> {
|
|
|
95
93
|
|
|
96
94
|
await generateContextFiles(ctx, feature.assistants, workspacePath);
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
if (config.packContextXml) {
|
|
100
|
-
const { packWorkspace } = await import('../core/packer.js');
|
|
101
|
-
await packWorkspace(workspacePath);
|
|
102
|
-
}
|
|
96
|
+
|
|
103
97
|
console.log(chalk.green('ā
Workspace maps and contexts successfully updated.\n'));
|
|
104
98
|
} catch (error) {
|
|
105
99
|
console.error(chalk.red(`ā Failed to regenerate maps: ${error instanceof Error ? error.message : String(error)}\n`));
|
|
@@ -0,0 +1,484 @@
|
|
|
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
|
+
}
|
package/src/commands/ui.ts
CHANGED
|
@@ -4,44 +4,108 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import chalk from 'chalk';
|
|
7
|
-
import { exec } from 'node:child_process';
|
|
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';
|
|
8
11
|
import { startServer } from '../server.js';
|
|
9
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
|
+
|
|
10
43
|
/**
|
|
11
44
|
* Starts the local GUI server and opens the dashboard in the default browser.
|
|
12
45
|
*
|
|
13
|
-
* @param options - CLI options, including optional port.
|
|
46
|
+
* @param options - CLI options, including optional port, daemon, and server-only.
|
|
14
47
|
*/
|
|
15
|
-
export async function uiCommand(options: { port?: string }): Promise<void> {
|
|
48
|
+
export async function uiCommand(options: { port?: string; daemon?: boolean; serverOnly?: boolean }): Promise<void> {
|
|
16
49
|
const port = options.port ? parseInt(options.port, 10) : 3000;
|
|
50
|
+
const url = `http://localhost:${port}`;
|
|
17
51
|
|
|
18
52
|
console.log(chalk.bold.cyan('\nš„ļø NexusFlow ā Web Dashboard\n'));
|
|
19
|
-
console.log(chalk.dim(' Starting local server...'));
|
|
20
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...'));
|
|
21
93
|
try {
|
|
22
94
|
const { port: actualPort } = await startServer(port);
|
|
23
|
-
const
|
|
95
|
+
const actualUrl = `http://localhost:${actualPort}`;
|
|
24
96
|
|
|
25
|
-
console.log(chalk.green(` ā Dashboard running at: ${chalk.bold(
|
|
97
|
+
console.log(chalk.green(` ā Dashboard running at: ${chalk.bold(actualUrl)}`));
|
|
26
98
|
console.log(chalk.dim(' Press Ctrl+C to stop.\n'));
|
|
27
99
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (process.platform === 'win32') {
|
|
31
|
-
openCmd = `start ${url}`;
|
|
32
|
-
} else if (process.platform === 'darwin') {
|
|
33
|
-
openCmd = `open ${url}`;
|
|
34
|
-
} else {
|
|
35
|
-
openCmd = `xdg-open ${url}`;
|
|
100
|
+
if (!options.serverOnly) {
|
|
101
|
+
openBrowser(actualUrl);
|
|
36
102
|
}
|
|
37
103
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
console.log(chalk.dim(` Could not auto-open browser. Please visit ${url} manually.`));
|
|
41
|
-
}
|
|
42
|
-
});
|
|
104
|
+
// Keep process alive
|
|
105
|
+
await new Promise(() => {});
|
|
43
106
|
} catch (error) {
|
|
44
107
|
const msg = error instanceof Error ? error.message : String(error);
|
|
45
108
|
console.error(chalk.red(` ā Failed to start dashboard: ${msg}`));
|
|
46
109
|
}
|
|
47
110
|
}
|
|
111
|
+
|