@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.
- package/.github/dependabot.yml +52 -52
- package/.github/workflows/dependabot-merge.yml +53 -0
- package/.github/workflows/release.yml +112 -100
- package/.vscode/launch.json +17 -17
- package/.vscode/tasks.json +17 -17
- package/GETTING_STARTED.md +114 -109
- package/README.md +336 -311
- 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/add-repo.d.ts.map +1 -1
- package/dist/commands/add-repo.js +24 -14
- package/dist/commands/add-repo.js.map +1 -1
- package/dist/commands/commit.js +1 -1
- package/dist/commands/commit.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/diff.js +1 -1
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/handoff.js +1 -1
- package/dist/commands/handoff.js.map +1 -1
- package/dist/commands/logs.js +1 -1
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/open.d.ts.map +1 -1
- package/dist/commands/open.js +12 -7
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/pack.js +1 -1
- package/dist/commands/pack.js.map +1 -1
- package/dist/commands/refresh.js +13 -8
- package/dist/commands/refresh.js.map +1 -1
- package/dist/commands/remove.d.ts.map +1 -1
- package/dist/commands/remove.js +12 -7
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/stop.js +1 -1
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +14 -11
- 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 +386 -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/workspace.d.ts +7 -0
- package/dist/core/workspace.d.ts.map +1 -1
- package/dist/core/workspace.js +45 -1
- package/dist/core/workspace.js.map +1 -1
- package/dist/generators/base.d.ts.map +1 -1
- package/dist/generators/base.js +78 -66
- package/dist/generators/base.js.map +1 -1
- package/dist/generators/codex.js +11 -11
- package/dist/generators/copilot.js +17 -17
- package/dist/generators/cursor.js +5 -5
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +64 -50
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/map-generator.js +14 -14
- package/dist/generators/skills-generator.js +28 -28
- package/dist/gui/app_logo.png +0 -0
- package/dist/gui/assets/index-Ct3qq-X4.js +25 -0
- package/dist/gui/assets/index-P_ZrgHXg.css +1 -0
- package/dist/gui/icons.svg +24 -24
- package/dist/gui/index.html +18 -18
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -1
- package/dist/orchestration/runner.d.ts +5 -6
- package/dist/orchestration/runner.d.ts.map +1 -1
- package/dist/orchestration/runner.js +105 -102
- package/dist/orchestration/runner.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +235 -2
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +78 -0
- package/dist/server.test.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/detect-editors.js +1 -1
- package/dist/utils/detect-editors.js.map +1 -1
- package/dist/utils/detect-editors.test.js +3 -3
- package/dist/utils/detect-editors.test.js.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/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/prompts.d.ts +1 -0
- package/dist/utils/prompts.d.ts.map +1 -1
- package/dist/utils/prompts.js +77 -15
- package/dist/utils/prompts.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 -6
- package/dist/utils/update-check.js.map +1 -1
- 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 +2673 -2811
- package/extension/package.json +108 -61
- package/extension/src/extension.ts +631 -168
- package/extension/tsconfig.json +21 -19
- package/gui/README.md +73 -73
- package/gui/e2e/wizard.spec.ts +346 -327
- package/gui/eslint.config.js +26 -22
- package/gui/index.html +17 -17
- package/gui/package-lock.json +3079 -3118
- package/gui/package.json +36 -36
- package/gui/playwright.config.ts +41 -41
- package/gui/public/app_logo.png +0 -0
- package/gui/public/icons.svg +24 -24
- package/gui/src/App.css +1 -1
- package/gui/src/App.tsx +3407 -2498
- package/gui/src/assets/vite.svg +1 -1
- package/gui/src/features/changes/ChangesViewer.tsx +388 -212
- package/gui/src/features/knowledge/KnowledgeBase.tsx +84 -84
- package/gui/src/features/onboarding/OnboardingWizard.tsx +230 -230
- package/gui/src/features/plan/ImplementationPlan.tsx +32 -32
- package/gui/src/features/services/ServiceConsole.tsx +250 -159
- package/gui/src/features/sessions/SessionHistory.tsx +195 -195
- package/gui/src/features/workspace/WorkspaceList.tsx +666 -514
- package/gui/src/index.css +152 -17
- package/gui/src/main.tsx +94 -10
- package/gui/src/types.ts +62 -62
- package/gui/tsconfig.app.json +25 -25
- package/gui/tsconfig.json +7 -7
- package/gui/tsconfig.node.json +24 -24
- package/gui/vite.config.ts +12 -12
- package/package.json +56 -55
- 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/scripts/simulate-workspaces.ts +55 -55
- package/src/analyzers/detect-apis.ts +290 -290
- package/src/analyzers/detect-deps.ts +315 -315
- package/src/analyzers/detect-existing.ts +74 -74
- package/src/analyzers/detect-ports.ts +110 -110
- package/src/analyzers/index.ts +97 -97
- package/src/analyzers/messaging-analyzer.ts +254 -254
- package/src/analyzers/readme-summarizer.ts +102 -102
- package/src/analyzers/run-analyzer.ts +269 -269
- package/src/analyzers/tech-stack.ts +283 -283
- package/src/commands/add-repo.ts +157 -141
- package/src/commands/commands.test.ts +155 -155
- package/src/commands/commit.ts +131 -131
- package/src/commands/create.ts +207 -207
- package/src/commands/desktop.ts +128 -0
- package/src/commands/diff.ts +125 -125
- package/src/commands/doctor.ts +357 -357
- package/src/commands/handoff.ts +266 -266
- package/src/commands/init.ts +134 -134
- package/src/commands/list.ts +46 -46
- package/src/commands/logs.ts +63 -63
- package/src/commands/mcp.ts +92 -92
- package/src/commands/open.ts +129 -121
- package/src/commands/pack.ts +73 -73
- package/src/commands/refresh.ts +147 -139
- package/src/commands/remove.ts +98 -90
- package/src/commands/start.ts +117 -117
- package/src/commands/status.ts +54 -54
- package/src/commands/stop.ts +55 -55
- package/src/commands/sync.ts +151 -145
- package/src/commands/tui.ts +424 -0
- package/src/commands/ui.ts +111 -47
- package/src/core/config.test.ts +96 -96
- package/src/core/config.ts +115 -115
- package/src/core/graph.ts +344 -344
- package/src/core/packer.test.ts +99 -99
- package/src/core/packer.ts +107 -107
- package/src/core/scanner.test.ts +61 -61
- package/src/core/scanner.ts +91 -91
- package/src/core/workspace.ts +380 -333
- package/src/core/worktree.ts +120 -120
- package/src/generators/antigravity.ts +32 -32
- package/src/generators/base.ts +240 -227
- package/src/generators/claude.ts +34 -34
- package/src/generators/codex.ts +48 -48
- package/src/generators/copilot.ts +56 -56
- package/src/generators/cursor.ts +44 -44
- package/src/generators/index.ts +250 -230
- package/src/generators/map-generator.test.ts +159 -159
- package/src/generators/map-generator.ts +542 -542
- package/src/generators/plan-generator.ts +481 -481
- package/src/generators/skills-generator.ts +259 -259
- package/src/index.ts +426 -382
- package/src/mcp/server.ts +294 -294
- package/src/orchestration/detect.ts +313 -313
- package/src/orchestration/index.ts +7 -7
- package/src/orchestration/runner.ts +283 -279
- package/src/server.test.ts +555 -464
- package/src/server.ts +1308 -1047
- package/src/types.ts +408 -403
- package/src/utils/detect-ai.test.ts +44 -44
- package/src/utils/detect-ai.ts +84 -84
- package/src/utils/detect-editors.test.ts +48 -48
- package/src/utils/detect-editors.ts +57 -57
- package/src/utils/git.test.ts +74 -74
- package/src/utils/git.ts +117 -61
- package/src/utils/local-ai.test.ts +130 -130
- package/src/utils/local-ai.ts +111 -111
- package/src/utils/multi-git.ts +313 -306
- package/src/utils/prompts.ts +209 -135
- package/src/utils/session-finder.ts +483 -483
- package/src/utils/system-scanner.test.ts +89 -89
- package/src/utils/system-scanner.ts +96 -96
- package/src/utils/update-check.ts +309 -275
- package/src/utils/workflows.test.ts +114 -0
- package/src/utils/workflows.ts +178 -0
- package/tsconfig.json +19 -19
- package/vitest.config.ts +14 -14
- package/dist/gui/assets/index-Ca2VRMrQ.js +0 -22
- package/dist/gui/assets/index-fj0RJiOb.css +0 -2
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module orchestration/runner
|
|
3
3
|
* Manages the lifecycle of services — start, stop, status, and log streaming.
|
|
4
|
-
*
|
|
4
|
+
* Uses PM2 for process management.
|
|
5
5
|
*/
|
|
6
6
|
import * as fs from 'node:fs/promises';
|
|
7
7
|
import * as path from 'node:path';
|
|
8
|
-
import { spawn } from 'node:child_process';
|
|
9
8
|
import chalk from 'chalk';
|
|
9
|
+
import { execa } from 'execa';
|
|
10
10
|
/** Name of the state file that tracks running services. */
|
|
11
11
|
const STATE_FILE = '.nexusflow-running.json';
|
|
12
|
-
/** Active child processes tracked in memory. */
|
|
13
|
-
const activeProcesses = new Map();
|
|
14
12
|
/**
|
|
15
13
|
* Returns the path to the running-state file for a workspace.
|
|
16
14
|
*/
|
|
@@ -18,12 +16,37 @@ function getStatePath(workspacePath) {
|
|
|
18
16
|
return path.join(workspacePath, STATE_FILE);
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
|
-
* Loads the running state from disk.
|
|
19
|
+
* Loads the running state from disk, syncing active status with PM2.
|
|
22
20
|
*/
|
|
23
21
|
export async function loadRunningState(workspacePath) {
|
|
24
22
|
try {
|
|
25
23
|
const raw = await fs.readFile(getStatePath(workspacePath), 'utf-8');
|
|
26
|
-
|
|
24
|
+
const state = JSON.parse(raw);
|
|
25
|
+
try {
|
|
26
|
+
// Query current PM2 process list to verify actual running status
|
|
27
|
+
const { stdout } = await execa('npx', ['pm2', 'jlist']);
|
|
28
|
+
const pm2List = JSON.parse(stdout);
|
|
29
|
+
const workspaceId = path.basename(workspacePath);
|
|
30
|
+
const prefix = `nexusflow-${workspaceId}-`;
|
|
31
|
+
const activeServices = state.services.map((service) => {
|
|
32
|
+
const uniqueName = `${prefix}${service.name}`;
|
|
33
|
+
const pm2App = pm2List.find((app) => app.name === uniqueName);
|
|
34
|
+
const running = pm2App && pm2App.pm2_env?.status === 'online';
|
|
35
|
+
return {
|
|
36
|
+
...service,
|
|
37
|
+
pid: running ? (pm2App.pid || service.pid) : 0,
|
|
38
|
+
};
|
|
39
|
+
}).filter((service) => service.pid > 0);
|
|
40
|
+
return {
|
|
41
|
+
...state,
|
|
42
|
+
services: activeServices,
|
|
43
|
+
updatedAt: new Date().toISOString(),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Fallback to cached state on disk if PM2 query fails
|
|
48
|
+
return state;
|
|
49
|
+
}
|
|
27
50
|
}
|
|
28
51
|
catch {
|
|
29
52
|
return null;
|
|
@@ -48,20 +71,7 @@ async function clearRunningState(workspacePath) {
|
|
|
48
71
|
}
|
|
49
72
|
}
|
|
50
73
|
/**
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
function isProcessRunning(pid) {
|
|
54
|
-
try {
|
|
55
|
-
process.kill(pid, 0);
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Starts all services in the given list.
|
|
64
|
-
* Each service is spawned as a detached child process.
|
|
74
|
+
* Starts all services in the given list using PM2.
|
|
65
75
|
*
|
|
66
76
|
* @param services - Services to start.
|
|
67
77
|
* @param workspacePath - Workspace root path.
|
|
@@ -71,51 +81,57 @@ export async function startServices(services, workspacePath, logDir) {
|
|
|
71
81
|
// Ensure log directory exists
|
|
72
82
|
await fs.mkdir(logDir, { recursive: true });
|
|
73
83
|
const runningServices = [];
|
|
84
|
+
const workspaceId = path.basename(workspacePath);
|
|
74
85
|
for (const service of services) {
|
|
75
86
|
const logFile = path.join(logDir, `${service.name}.log`);
|
|
76
87
|
const portStr = service.port ? ` on port ${service.port}` : '';
|
|
77
|
-
|
|
88
|
+
const uniqueName = `nexusflow-${workspaceId}-${service.name}`;
|
|
89
|
+
console.log(chalk.cyan(` Starting ${chalk.bold(service.name)}${portStr} under PM2...`));
|
|
78
90
|
console.log(chalk.dim(` ${service.command} ${service.args.join(' ')} (in ${service.cwd})`));
|
|
79
91
|
try {
|
|
80
|
-
// Ensure parent directory for this log file exists
|
|
92
|
+
// Ensure parent directory for this log file exists
|
|
81
93
|
await fs.mkdir(path.dirname(logFile), { recursive: true });
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
94
|
+
// Delete any existing PM2 configuration with the same name to avoid duplicate starts
|
|
95
|
+
await execa('npx', ['pm2', 'delete', uniqueName], { reject: false });
|
|
96
|
+
// Start the service using PM2 as a direct process execution
|
|
97
|
+
await execa('npx', [
|
|
98
|
+
'pm2',
|
|
99
|
+
'start',
|
|
100
|
+
service.command,
|
|
101
|
+
'--name',
|
|
102
|
+
uniqueName,
|
|
103
|
+
'--cwd',
|
|
104
|
+
service.cwd,
|
|
105
|
+
'-o',
|
|
106
|
+
logFile,
|
|
107
|
+
'-e',
|
|
108
|
+
logFile,
|
|
109
|
+
'--interpreter',
|
|
110
|
+
'none',
|
|
111
|
+
'--',
|
|
112
|
+
...service.args
|
|
113
|
+
]);
|
|
114
|
+
// Retrieve the real PID from PM2
|
|
115
|
+
const { stdout } = await execa('npx', ['pm2', 'jlist']);
|
|
116
|
+
const pm2List = JSON.parse(stdout);
|
|
117
|
+
const pm2App = pm2List.find((app) => app.name === uniqueName);
|
|
118
|
+
const pid = pm2App?.pid || 0;
|
|
119
|
+
if (pid) {
|
|
107
120
|
runningServices.push({
|
|
108
121
|
name: service.name,
|
|
109
|
-
pid
|
|
122
|
+
pid,
|
|
110
123
|
config: service,
|
|
111
124
|
startedAt: new Date().toISOString(),
|
|
112
125
|
});
|
|
113
|
-
console.log(chalk.green(` ✔ ${service.name} started (PID: ${
|
|
126
|
+
console.log(chalk.green(` ✔ ${service.name} started under PM2 (PID: ${pid})`));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
console.warn(chalk.yellow(` ⚠ Started ${service.name} but could not resolve PID from PM2.`));
|
|
114
130
|
}
|
|
115
131
|
}
|
|
116
132
|
catch (error) {
|
|
117
133
|
const msg = error instanceof Error ? error.message : String(error);
|
|
118
|
-
console.error(chalk.red(` ✖ Failed to start ${service.name}: ${msg}`));
|
|
134
|
+
console.error(chalk.red(` ✖ Failed to start ${service.name} via PM2: ${msg}`));
|
|
119
135
|
}
|
|
120
136
|
}
|
|
121
137
|
// Save state
|
|
@@ -128,74 +144,61 @@ export async function startServices(services, workspacePath, logDir) {
|
|
|
128
144
|
}
|
|
129
145
|
}
|
|
130
146
|
/**
|
|
131
|
-
* Stops all services for a workspace.
|
|
147
|
+
* Stops all services for a workspace under PM2.
|
|
132
148
|
*
|
|
133
149
|
* @param workspacePath - Workspace root path.
|
|
134
150
|
*/
|
|
135
151
|
export async function stopServices(workspacePath) {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
try {
|
|
146
|
-
// Kill the process group (negative PID kills group on Unix, taskkill on Windows)
|
|
147
|
-
if (process.platform === 'win32') {
|
|
148
|
-
spawn('taskkill', ['/pid', String(child.pid), '/f', '/t'], { stdio: 'ignore' });
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
process.kill(-child.pid, 'SIGTERM');
|
|
152
|
-
}
|
|
153
|
-
console.log(chalk.green(` ✔ Stopped ${service.name} (PID: ${service.pid})`));
|
|
154
|
-
activeProcesses.delete(service.name);
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
// Fall through to PID-based kill
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// Fall back to PID from state file
|
|
162
|
-
if (isProcessRunning(service.pid)) {
|
|
163
|
-
try {
|
|
164
|
-
if (process.platform === 'win32') {
|
|
165
|
-
spawn('taskkill', ['/pid', String(service.pid), '/f', '/t'], { stdio: 'ignore' });
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
process.kill(service.pid, 'SIGTERM');
|
|
169
|
-
}
|
|
170
|
-
console.log(chalk.green(` ✔ Stopped ${service.name} (PID: ${service.pid})`));
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
console.log(chalk.yellow(` ⚠ Could not stop ${service.name} (PID: ${service.pid})`));
|
|
174
|
-
}
|
|
152
|
+
const workspaceId = path.basename(workspacePath);
|
|
153
|
+
const prefix = `nexusflow-${workspaceId}-`;
|
|
154
|
+
console.log(chalk.cyan(` Stopping all services under PM2 for workspace: ${workspaceId}...`));
|
|
155
|
+
try {
|
|
156
|
+
const { stdout } = await execa('npx', ['pm2', 'jlist']);
|
|
157
|
+
const pm2List = JSON.parse(stdout);
|
|
158
|
+
const targetApps = pm2List.filter((app) => app.name && app.name.startsWith(prefix));
|
|
159
|
+
if (targetApps.length === 0) {
|
|
160
|
+
console.log(chalk.yellow(' No running services found for this workspace.'));
|
|
175
161
|
}
|
|
176
162
|
else {
|
|
177
|
-
|
|
163
|
+
for (const app of targetApps) {
|
|
164
|
+
console.log(chalk.dim(` Stopping PM2 process: ${app.name}`));
|
|
165
|
+
await execa('npx', ['pm2', 'delete', app.name], { reject: false });
|
|
166
|
+
}
|
|
167
|
+
console.log(chalk.green(` ✔ All services stopped.`));
|
|
178
168
|
}
|
|
179
169
|
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
console.error(chalk.red(` ✖ Failed to stop services via PM2: ${error.message}`));
|
|
172
|
+
}
|
|
180
173
|
await clearRunningState(workspacePath);
|
|
181
174
|
}
|
|
182
175
|
/**
|
|
183
|
-
* Shows the status of all services in a workspace.
|
|
176
|
+
* Shows the status of all services in a workspace by querying PM2.
|
|
184
177
|
*
|
|
185
178
|
* @param workspacePath - Workspace root path.
|
|
186
179
|
*/
|
|
187
180
|
export async function getServiceStatus(workspacePath) {
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
181
|
+
const workspaceId = path.basename(workspacePath);
|
|
182
|
+
const prefix = `nexusflow-${workspaceId}-`;
|
|
183
|
+
try {
|
|
184
|
+
const { stdout } = await execa('npx', ['pm2', 'jlist']);
|
|
185
|
+
const pm2List = JSON.parse(stdout);
|
|
186
|
+
const targetApps = pm2List.filter((app) => app.name && app.name.startsWith(prefix));
|
|
187
|
+
if (targetApps.length === 0) {
|
|
188
|
+
console.log(chalk.yellow(' No running services found for this workspace in PM2.'));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
for (const app of targetApps) {
|
|
192
|
+
const name = app.name.substring(prefix.length);
|
|
193
|
+
const running = app.pm2_env?.status === 'online';
|
|
194
|
+
const status = running ? chalk.green('● running') : chalk.red(`● ${app.pm2_env?.status || 'stopped'}`);
|
|
195
|
+
const pid = app.pid || 'N/A';
|
|
196
|
+
const uptime = app.pm2_env?.pm_uptime ? new Date(app.pm2_env.pm_uptime).toLocaleTimeString() : 'unknown';
|
|
197
|
+
console.log(` ${status} ${chalk.bold(name)} (PID: ${pid}, since ${uptime})`);
|
|
198
|
+
}
|
|
192
199
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const status = running ? chalk.green('● running') : chalk.red('● stopped');
|
|
196
|
-
const portStr = service.config.port ? ` :${service.config.port}` : '';
|
|
197
|
-
const since = new Date(service.startedAt).toLocaleTimeString();
|
|
198
|
-
console.log(` ${status} ${chalk.bold(service.name)}${chalk.dim(portStr)} (PID: ${service.pid}, since ${since})`);
|
|
200
|
+
catch (error) {
|
|
201
|
+
console.error(chalk.red(` ✖ Failed to query PM2 status: ${error.message}`));
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
204
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/orchestration/runner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,k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,CAAC,mBAAmB,CAAC,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AA6C5B,eAAO,MAAM,GAAG,4EAAa,CAAC;AA2tC9B,wBAAgB,WAAW,CAAC,IAAI,SAAO,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,CAc/E"}
|
package/dist/server.js
CHANGED
|
@@ -8,9 +8,13 @@ import { serveStatic } from '@hono/node-server/serve-static';
|
|
|
8
8
|
import { cors } from 'hono/cors';
|
|
9
9
|
import { streamSSE } from 'hono/streaming';
|
|
10
10
|
import * as fs from 'node:fs/promises';
|
|
11
|
+
import { createWriteStream, existsSync } from 'node:fs';
|
|
11
12
|
import * as path from 'node:path';
|
|
12
13
|
import { fileURLToPath } from 'node:url';
|
|
13
14
|
import { execa } from 'execa';
|
|
15
|
+
import * as os from 'node:os';
|
|
16
|
+
import { pipeline } from 'node:stream/promises';
|
|
17
|
+
import { spawn } from 'node:child_process';
|
|
14
18
|
import { loadConfig, saveConfig, getConfigDir } from './core/config.js';
|
|
15
19
|
import { scanForRepos } from './core/scanner.js';
|
|
16
20
|
import { createWorkspace, listWorkspaces, loadFeatureConfig, deleteWorkspace, addRepoToWorkspace } from './core/workspace.js';
|
|
@@ -25,6 +29,7 @@ import { scanSystemSpecs } from './utils/system-scanner.js';
|
|
|
25
29
|
import { getWorkspaceRepos, rebaseRepo, commitAndPush, getRepoStatus } from './utils/multi-git.js';
|
|
26
30
|
import { detectAllServices, detectOrchestrationTools, startServices, stopServices, loadRunningState, } from './orchestration/index.js';
|
|
27
31
|
import { checkForUpdates, getCurrentVersion, getToolsStatus } from './utils/update-check.js';
|
|
32
|
+
import { getWorkflowTemplates, saveWorkflowTemplate, deleteWorkflowTemplate } from './utils/workflows.js';
|
|
28
33
|
// Resolve static files directory
|
|
29
34
|
const __filename = fileURLToPath(import.meta.url);
|
|
30
35
|
const __dirname = path.dirname(__filename);
|
|
@@ -33,7 +38,7 @@ const __dirname = path.dirname(__filename);
|
|
|
33
38
|
const guiPath = path.join(__dirname, 'gui');
|
|
34
39
|
export const app = new Hono();
|
|
35
40
|
// Allowed editor binaries/scripts to prevent command injection
|
|
36
|
-
const ALLOWED_EDITORS = new Set(['code', 'code-insiders', 'cursor', 'agy', 'idea', 'charm', 'webstorm', 'subl', 'nano', 'vim', 'nvim', 'emacs']);
|
|
41
|
+
const ALLOWED_EDITORS = new Set(['code', 'code-insiders', 'cursor', 'antigravity', 'agy', 'idea', 'charm', 'webstorm', 'subl', 'nano', 'vim', 'nvim', 'emacs']);
|
|
37
42
|
// Enable CORS for frontend dev server
|
|
38
43
|
app.use('/api/*', cors());
|
|
39
44
|
// ─── API Endpoints ────────────────────────────────────────────────────────
|
|
@@ -251,6 +256,7 @@ async function runCreationJob(jobId, body, config) {
|
|
|
251
256
|
createdAt: new Date().toISOString(),
|
|
252
257
|
resumption: body.resumption,
|
|
253
258
|
localLlmEnabled: body.localLlmEnabled,
|
|
259
|
+
teamworkInstructions: body.teamworkInstructions,
|
|
254
260
|
};
|
|
255
261
|
if (job) {
|
|
256
262
|
job.feature = feature;
|
|
@@ -604,6 +610,58 @@ app.get('/api/workspace/:id/changes', async (c) => {
|
|
|
604
610
|
return c.json({ error: msg }, 500);
|
|
605
611
|
}
|
|
606
612
|
});
|
|
613
|
+
// 13_diff. Get git diff for a specific file in workspace sub-repositories
|
|
614
|
+
app.get('/api/workspace/:id/changes/diff', async (c) => {
|
|
615
|
+
try {
|
|
616
|
+
const id = c.req.param('id');
|
|
617
|
+
const repoName = c.req.query('repo');
|
|
618
|
+
const filePath = c.req.query('file');
|
|
619
|
+
if (!repoName || !filePath) {
|
|
620
|
+
return c.json({ error: 'Missing repo or file query parameter.' }, 400);
|
|
621
|
+
}
|
|
622
|
+
const config = await loadConfig();
|
|
623
|
+
const workspacePath = path.join(config.workspacesDir, id);
|
|
624
|
+
const worktreePath = path.join(workspacePath, repoName);
|
|
625
|
+
// Security check: ensure path is within workspace directory
|
|
626
|
+
const resolvedPath = path.resolve(worktreePath);
|
|
627
|
+
if (!resolvedPath.startsWith(path.resolve(workspacePath))) {
|
|
628
|
+
return c.json({ error: 'Invalid repository path.' }, 400);
|
|
629
|
+
}
|
|
630
|
+
let diff = '';
|
|
631
|
+
// Check git status for the file to know if it's untracked
|
|
632
|
+
try {
|
|
633
|
+
const { stdout: statusOut } = await execa('git', ['status', '--porcelain', '--', filePath], { cwd: worktreePath });
|
|
634
|
+
const statusLine = statusOut.trim();
|
|
635
|
+
const isUntracked = statusLine.startsWith('??');
|
|
636
|
+
if (isUntracked) {
|
|
637
|
+
const result = await execa('git', ['diff', '--no-index', '--', '/dev/null', filePath], {
|
|
638
|
+
cwd: worktreePath,
|
|
639
|
+
reject: false
|
|
640
|
+
});
|
|
641
|
+
diff = result.stdout || result.stderr || '';
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
const result = await execa('git', ['diff', 'HEAD', '--', filePath], {
|
|
645
|
+
cwd: worktreePath,
|
|
646
|
+
reject: false
|
|
647
|
+
});
|
|
648
|
+
diff = result.stdout || result.stderr || '';
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
catch (e) {
|
|
652
|
+
const result = await execa('git', ['diff', 'HEAD', '--', filePath], {
|
|
653
|
+
cwd: worktreePath,
|
|
654
|
+
reject: false
|
|
655
|
+
});
|
|
656
|
+
diff = result.stdout || result.stderr || '';
|
|
657
|
+
}
|
|
658
|
+
return c.json({ diff });
|
|
659
|
+
}
|
|
660
|
+
catch (error) {
|
|
661
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
662
|
+
return c.json({ error: msg }, 500);
|
|
663
|
+
}
|
|
664
|
+
});
|
|
607
665
|
// 13a. Get workspace knowledge (nexusflow-knowledge.md)
|
|
608
666
|
app.get('/api/workspace/:id/knowledge', async (c) => {
|
|
609
667
|
try {
|
|
@@ -671,7 +729,7 @@ app.post('/api/workspace/:id/sync', async (c) => {
|
|
|
671
729
|
const repos = await getWorkspaceRepos(workspacePath);
|
|
672
730
|
const results = [];
|
|
673
731
|
for (const repo of repos) {
|
|
674
|
-
const result = await rebaseRepo(repo.path, 'main');
|
|
732
|
+
const result = await rebaseRepo(repo.path, repo.defaultBranch || 'main');
|
|
675
733
|
results.push({
|
|
676
734
|
repoName: repo.name,
|
|
677
735
|
success: result.success,
|
|
@@ -885,6 +943,181 @@ app.post('/api/updates/install', async (c) => {
|
|
|
885
943
|
return c.json({ error: msg }, 500);
|
|
886
944
|
}
|
|
887
945
|
});
|
|
946
|
+
let downloadedInstallerPath = null;
|
|
947
|
+
// 17.7. Download matching GitHub Release installer to temporary folder
|
|
948
|
+
app.post('/api/updates/download', async (c) => {
|
|
949
|
+
try {
|
|
950
|
+
const { downloadUrl } = await c.req.json();
|
|
951
|
+
if (!downloadUrl) {
|
|
952
|
+
return c.json({ error: 'Download URL is required' }, 400);
|
|
953
|
+
}
|
|
954
|
+
const tempDir = os.tmpdir();
|
|
955
|
+
const fileName = 'NexusFlowSetup_Update.exe';
|
|
956
|
+
const targetPath = path.join(tempDir, fileName);
|
|
957
|
+
const response = await fetch(downloadUrl);
|
|
958
|
+
if (!response.ok) {
|
|
959
|
+
throw new Error(`HTTP error ${response.status}`);
|
|
960
|
+
}
|
|
961
|
+
// Node fetch body stream download
|
|
962
|
+
const fileStream = createWriteStream(targetPath);
|
|
963
|
+
if (!response.body) {
|
|
964
|
+
throw new Error('Response body is null');
|
|
965
|
+
}
|
|
966
|
+
// Convert ReadableStream to Node stream
|
|
967
|
+
await pipeline(response.body, fileStream);
|
|
968
|
+
downloadedInstallerPath = targetPath;
|
|
969
|
+
return c.json({ success: true, path: targetPath });
|
|
970
|
+
}
|
|
971
|
+
catch (error) {
|
|
972
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
973
|
+
return c.json({ error: `Download failed: ${msg}` }, 500);
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
// 17.8. Launch the silent installer detached and exit server
|
|
977
|
+
app.post('/api/updates/apply', async (c) => {
|
|
978
|
+
if (!downloadedInstallerPath || !existsSync(downloadedInstallerPath)) {
|
|
979
|
+
return c.json({ error: 'No downloaded installer found on disk' }, 400);
|
|
980
|
+
}
|
|
981
|
+
try {
|
|
982
|
+
const isWin = process.platform === 'win32';
|
|
983
|
+
if (isWin) {
|
|
984
|
+
// Inno Setup silent install flags
|
|
985
|
+
console.log(`Applying update: Spawning detached installer at: ${downloadedInstallerPath}`);
|
|
986
|
+
const child = spawn(downloadedInstallerPath, ['/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART'], {
|
|
987
|
+
detached: true,
|
|
988
|
+
stdio: 'ignore',
|
|
989
|
+
});
|
|
990
|
+
child.unref();
|
|
991
|
+
}
|
|
992
|
+
// Gracefully exit server process in 1 second to release file locks
|
|
993
|
+
setTimeout(() => {
|
|
994
|
+
console.log('Update installer successfully spawned. Exiting Hono server process...');
|
|
995
|
+
process.exit(0);
|
|
996
|
+
}, 1000);
|
|
997
|
+
return c.json({ success: true, message: 'Installer spawned, app shutting down...' });
|
|
998
|
+
}
|
|
999
|
+
catch (error) {
|
|
1000
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1001
|
+
return c.json({ error: `Failed to execute update: ${msg}` }, 500);
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
// 17.9. Get available workflow templates
|
|
1005
|
+
app.get('/api/workflows/templates', async (c) => {
|
|
1006
|
+
try {
|
|
1007
|
+
const templates = await getWorkflowTemplates();
|
|
1008
|
+
return c.json({ templates });
|
|
1009
|
+
}
|
|
1010
|
+
catch (error) {
|
|
1011
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1012
|
+
return c.json({ error: msg }, 500);
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
// Save or update custom teamwork template
|
|
1016
|
+
app.post('/api/workflows/templates', async (c) => {
|
|
1017
|
+
try {
|
|
1018
|
+
const { id, name, content } = await c.req.json();
|
|
1019
|
+
if (!name || !content) {
|
|
1020
|
+
return c.json({ error: 'Name and content are required.' }, 400);
|
|
1021
|
+
}
|
|
1022
|
+
const template = await saveWorkflowTemplate(name, content, id);
|
|
1023
|
+
return c.json({ success: true, template });
|
|
1024
|
+
}
|
|
1025
|
+
catch (error) {
|
|
1026
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1027
|
+
return c.json({ error: msg }, 500);
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
// Delete custom teamwork template
|
|
1031
|
+
app.delete('/api/workflows/templates/:id', async (c) => {
|
|
1032
|
+
try {
|
|
1033
|
+
const id = decodeURIComponent(c.req.param('id'));
|
|
1034
|
+
const templates = await getWorkflowTemplates();
|
|
1035
|
+
const target = templates.find(t => t.id === id);
|
|
1036
|
+
if (!target) {
|
|
1037
|
+
return c.json({ error: 'Template not found.' }, 404);
|
|
1038
|
+
}
|
|
1039
|
+
if (!target.custom) {
|
|
1040
|
+
return c.json({ error: 'Cannot delete built-in templates.' }, 403);
|
|
1041
|
+
}
|
|
1042
|
+
await deleteWorkflowTemplate(id);
|
|
1043
|
+
return c.json({ success: true });
|
|
1044
|
+
}
|
|
1045
|
+
catch (error) {
|
|
1046
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1047
|
+
return c.json({ error: msg }, 500);
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
// Analyze teamwork template rules via selected AI coding assistant harness
|
|
1051
|
+
app.post('/api/workflows/templates/:id/analyze', async (c) => {
|
|
1052
|
+
try {
|
|
1053
|
+
const { content, assistant, comment } = await c.req.json();
|
|
1054
|
+
if (!content) {
|
|
1055
|
+
return c.json({ error: 'Content is required.' }, 400);
|
|
1056
|
+
}
|
|
1057
|
+
const selectedAssistant = assistant || 'antigravity';
|
|
1058
|
+
let command = '';
|
|
1059
|
+
let args = [];
|
|
1060
|
+
let prompt = `You are an expert AI system engineering reviewer. Analyze the following Agent Teamwork Strategy guidelines.
|
|
1061
|
+
Evaluate its instructions, identify any ambiguities or contradictions, rate its expected effectiveness for orchestrating subagents, and provide specific recommendations or improvements. Format your analysis in clean Markdown with clear headings (e.g. Overview, Strengths, Weaknesses, Recommendations).
|
|
1062
|
+
|
|
1063
|
+
After your analysis, provide a fully rewritten, optimized, and complete version of the strategy guidelines incorporating all your recommendations. This rewritten version must be suitable for production orchestration.
|
|
1064
|
+
You MUST prefix the rewritten version with the exact delimiter line:
|
|
1065
|
+
=== SUGGESTED IMPROVEMENT START ===
|
|
1066
|
+
and suffix it with:
|
|
1067
|
+
=== SUGGESTED IMPROVEMENT END ===`;
|
|
1068
|
+
if (comment && comment.trim()) {
|
|
1069
|
+
prompt += `\n\nIMPORTANT: The user has provided the following specific instruction/comment that you MUST consider and prioritize during your evaluation and when rewriting the guidelines:\n"${comment.trim()}"`;
|
|
1070
|
+
}
|
|
1071
|
+
prompt += `\n\n--- GUIDELINES START ---\n${content}\n--- GUIDELINES END ---`;
|
|
1072
|
+
const assistants = await detectAIAssistants();
|
|
1073
|
+
const target = assistants.find(ai => ai.name === selectedAssistant);
|
|
1074
|
+
if (!target || !target.detected || !target.command) {
|
|
1075
|
+
return c.json({
|
|
1076
|
+
error: `AI assistant harness '${selectedAssistant}' is not detected or does not support command-line execution.`
|
|
1077
|
+
}, 400);
|
|
1078
|
+
}
|
|
1079
|
+
command = target.command;
|
|
1080
|
+
if (command === 'claude') {
|
|
1081
|
+
args = ['-p', prompt];
|
|
1082
|
+
}
|
|
1083
|
+
else if (command === 'agy') {
|
|
1084
|
+
args = [prompt];
|
|
1085
|
+
}
|
|
1086
|
+
else {
|
|
1087
|
+
args = [prompt];
|
|
1088
|
+
}
|
|
1089
|
+
const result = await execa(command, args, {
|
|
1090
|
+
input: '',
|
|
1091
|
+
shell: false,
|
|
1092
|
+
reject: false
|
|
1093
|
+
});
|
|
1094
|
+
if (result.exitCode !== 0) {
|
|
1095
|
+
return c.json({
|
|
1096
|
+
error: `AI Assistant harness execution failed (exit code ${result.exitCode}): ${result.stderr || result.stdout || 'Unknown error'}`
|
|
1097
|
+
}, 500);
|
|
1098
|
+
}
|
|
1099
|
+
// Clean potential warning lines or stdout prefixes if present
|
|
1100
|
+
let cleanText = result.stdout;
|
|
1101
|
+
if (cleanText.includes('Warning: no stdin data received')) {
|
|
1102
|
+
cleanText = cleanText.replace(/Warning: no stdin data received in \d+s, proceeding without it\. If piping from a slow command, redirect stdin explicitly: < \/dev\/null to skip, or wait longer\.\r?\n?/, '');
|
|
1103
|
+
}
|
|
1104
|
+
let analysis = cleanText.trim();
|
|
1105
|
+
let suggestedImprovement = '';
|
|
1106
|
+
const startDelimiter = '=== SUGGESTED IMPROVEMENT START ===';
|
|
1107
|
+
const endDelimiter = '=== SUGGESTED IMPROVEMENT END ===';
|
|
1108
|
+
const startIdx = cleanText.indexOf(startDelimiter);
|
|
1109
|
+
const endIdx = cleanText.indexOf(endDelimiter);
|
|
1110
|
+
if (startIdx !== -1 && endIdx !== -1) {
|
|
1111
|
+
analysis = cleanText.substring(0, startIdx).trim();
|
|
1112
|
+
suggestedImprovement = cleanText.substring(startIdx + startDelimiter.length, endIdx).trim();
|
|
1113
|
+
}
|
|
1114
|
+
return c.json({ analysis, suggestedImprovement });
|
|
1115
|
+
}
|
|
1116
|
+
catch (error) {
|
|
1117
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1118
|
+
return c.json({ error: msg }, 500);
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
888
1121
|
// 18. Pack workspace codebase and download
|
|
889
1122
|
app.get('/api/workspace/:id/pack', async (c) => {
|
|
890
1123
|
try {
|