@mrpatronz/nexusflow 0.2.19 → 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.
- package/README.md +27 -3
- package/dist/analyzers/index.d.ts +23 -0
- package/dist/analyzers/index.d.ts.map +1 -1
- package/dist/analyzers/index.js +62 -0
- package/dist/analyzers/index.js.map +1 -1
- package/dist/commands/commands.test.js +20 -6
- package/dist/commands/commands.test.js.map +1 -1
- package/dist/commands/commit.d.ts +2 -0
- package/dist/commands/commit.d.ts.map +1 -1
- package/dist/commands/commit.js +27 -5
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/diff.d.ts +9 -2
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +36 -12
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/handoff.js +2 -2
- package/dist/commands/handoff.js.map +1 -1
- package/dist/commands/refresh.d.ts +4 -2
- package/dist/commands/refresh.d.ts.map +1 -1
- package/dist/commands/refresh.js +20 -36
- package/dist/commands/refresh.js.map +1 -1
- package/dist/commands/schedule.d.ts +35 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +151 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +28 -7
- package/dist/commands/sync.js.map +1 -1
- package/dist/core/analysis-cache.d.ts +58 -0
- package/dist/core/analysis-cache.d.ts.map +1 -0
- package/dist/core/analysis-cache.js +116 -0
- package/dist/core/analysis-cache.js.map +1 -0
- package/dist/core/analysis-cache.test.d.ts +2 -0
- package/dist/core/analysis-cache.test.d.ts.map +1 -0
- package/dist/core/analysis-cache.test.js +108 -0
- package/dist/core/analysis-cache.test.js.map +1 -0
- package/dist/core/refresh.d.ts +41 -0
- package/dist/core/refresh.d.ts.map +1 -0
- package/dist/core/refresh.js +60 -0
- package/dist/core/refresh.js.map +1 -0
- package/dist/core/scheduler.d.ts +117 -0
- package/dist/core/scheduler.d.ts.map +1 -0
- package/dist/core/scheduler.js +247 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/scheduler.test.d.ts +2 -0
- package/dist/core/scheduler.test.d.ts.map +1 -0
- package/dist/core/scheduler.test.js +111 -0
- package/dist/core/scheduler.test.js.map +1 -0
- package/dist/core/sync.d.ts +6 -0
- package/dist/core/sync.d.ts.map +1 -1
- package/dist/core/sync.js +15 -5
- package/dist/core/sync.js.map +1 -1
- package/dist/generators/index.d.ts +7 -1
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +14 -1
- package/dist/generators/index.js.map +1 -1
- package/dist/index.js +107 -4
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +81 -0
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +66 -0
- package/dist/server.test.js.map +1 -1
- package/dist/utils/multi-git.d.ts +21 -0
- package/dist/utils/multi-git.d.ts.map +1 -1
- package/dist/utils/multi-git.js +40 -4
- package/dist/utils/multi-git.js.map +1 -1
- package/package.json +13 -1
- package/.agents/skills/ccc/SKILL.md +0 -71
- package/.agents/skills/ccc/references/management.md +0 -110
- package/.agents/skills/ccc/references/settings.md +0 -126
- package/.github/dependabot.yml +0 -52
- package/.github/workflows/ci.yml +0 -44
- package/.github/workflows/dependabot-merge.yml +0 -53
- package/.github/workflows/release-desktop.yml +0 -67
- package/.github/workflows/release-npm.yml +0 -65
- package/.github/workflows/release-vscode.yml +0 -61
- package/.vscode/launch.json +0 -17
- package/.vscode/tasks.json +0 -17
- package/GETTING_STARTED.md +0 -114
- package/desktop/build-installer.js +0 -228
- package/desktop/build.js +0 -118
- package/desktop/installer/nexusflow.iss +0 -35
- package/desktop/neutralino.config.json +0 -39
- package/desktop/package-lock.json +0 -1060
- package/desktop/package.json +0 -14
- package/extension/media/icon.svg +0 -1
- package/extension/package-lock.json +0 -6044
- package/extension/package.json +0 -117
- package/extension/src/extension.ts +0 -653
- package/extension/tsconfig.json +0 -21
- package/gui/README.md +0 -73
- package/gui/e2e/dashboard.spec.ts +0 -61
- package/gui/e2e/wizard.spec.ts +0 -346
- package/gui/eslint.config.js +0 -26
- package/gui/index.html +0 -17
- package/gui/package-lock.json +0 -3137
- package/gui/package.json +0 -37
- package/gui/playwright.config.ts +0 -41
- package/gui/public/app_logo.png +0 -0
- package/gui/public/favicon.svg +0 -1
- package/gui/public/icons.svg +0 -24
- package/gui/src/App.css +0 -1
- package/gui/src/App.tsx +0 -3573
- package/gui/src/app/AppSidebar.tsx +0 -69
- package/gui/src/assets/hero.png +0 -0
- package/gui/src/assets/react.svg +0 -1
- package/gui/src/assets/vite.svg +0 -1
- package/gui/src/components/AddRepoPicker.tsx +0 -81
- package/gui/src/components/ui/Button.tsx +0 -40
- package/gui/src/components/ui/Card.tsx +0 -6
- package/gui/src/components/ui/EmptyState.tsx +0 -22
- package/gui/src/components/ui/Input.tsx +0 -21
- package/gui/src/components/ui/Menu.tsx +0 -71
- package/gui/src/components/ui/Modal.tsx +0 -39
- package/gui/src/components/ui/PageHeader.tsx +0 -21
- package/gui/src/components/ui/RepoStatusStrip.tsx +0 -33
- package/gui/src/components/ui/Skeleton.tsx +0 -5
- package/gui/src/components/ui/StatusPill.tsx +0 -36
- package/gui/src/components/ui/Tabs.tsx +0 -40
- package/gui/src/components/ui/cn.ts +0 -4
- package/gui/src/components/ui/index.ts +0 -16
- package/gui/src/features/changes/ChangesViewer.tsx +0 -388
- package/gui/src/features/knowledge/KnowledgeBase.tsx +0 -84
- package/gui/src/features/onboarding/OnboardingWizard.tsx +0 -230
- package/gui/src/features/plan/ImplementationPlan.tsx +0 -32
- package/gui/src/features/services/ServiceConsole.tsx +0 -215
- package/gui/src/features/sessions/SessionHistory.tsx +0 -195
- package/gui/src/index.css +0 -167
- package/gui/src/lib/status.ts +0 -24
- package/gui/src/main.tsx +0 -94
- package/gui/src/pages/DashboardPage.tsx +0 -129
- package/gui/src/pages/WorkspacesPage.tsx +0 -352
- package/gui/src/types.ts +0 -81
- package/gui/tsconfig.app.json +0 -25
- package/gui/tsconfig.json +0 -7
- package/gui/tsconfig.node.json +0 -24
- package/gui/vite.config.ts +0 -12
- package/resources/workflows/plan-implement-review.md +0 -8
- package/resources/workflows/research-verify.md +0 -6
- package/resources/workflows/solo-developer.md +0 -3
- package/scripts/simulate-workspaces.ts +0 -55
- package/skills-lock.json +0 -11
- package/src/analyzers/detect-apis.ts +0 -290
- package/src/analyzers/detect-deps.ts +0 -315
- package/src/analyzers/detect-existing.ts +0 -74
- package/src/analyzers/detect-ports.ts +0 -110
- package/src/analyzers/index.ts +0 -97
- package/src/analyzers/messaging-analyzer.ts +0 -254
- package/src/analyzers/readme-summarizer.ts +0 -102
- package/src/analyzers/run-analyzer.ts +0 -269
- package/src/analyzers/tech-stack.ts +0 -283
- package/src/commands/adapter.ts +0 -348
- package/src/commands/add-repo.ts +0 -156
- package/src/commands/commands.test.ts +0 -156
- package/src/commands/commit.ts +0 -131
- package/src/commands/config.ts +0 -52
- package/src/commands/create.ts +0 -204
- package/src/commands/desktop.ts +0 -128
- package/src/commands/diff.ts +0 -125
- package/src/commands/doctor.ts +0 -370
- package/src/commands/handoff.ts +0 -266
- package/src/commands/init.ts +0 -134
- package/src/commands/list.ts +0 -46
- package/src/commands/logs.ts +0 -63
- package/src/commands/mcp.ts +0 -94
- package/src/commands/open.ts +0 -129
- package/src/commands/refresh.ts +0 -137
- package/src/commands/remove.ts +0 -98
- package/src/commands/start.ts +0 -117
- package/src/commands/status.ts +0 -54
- package/src/commands/stop.ts +0 -55
- package/src/commands/sync.ts +0 -125
- package/src/commands/tui.ts +0 -484
- package/src/commands/ui.ts +0 -111
- package/src/core/adapters/local-storage.ts +0 -66
- package/src/core/adapters/obsidian-storage.ts +0 -151
- package/src/core/adapters/registry.ts +0 -44
- package/src/core/adapters/storage.test.ts +0 -174
- package/src/core/adapters/vault-storage.ts +0 -86
- package/src/core/config.test.ts +0 -96
- package/src/core/config.ts +0 -140
- package/src/core/graph.ts +0 -344
- package/src/core/plugins/index.ts +0 -17
- package/src/core/plugins/loader.ts +0 -36
- package/src/core/ports/storage.ts +0 -71
- package/src/core/scanner.test.ts +0 -61
- package/src/core/scanner.ts +0 -91
- package/src/core/storage.ts +0 -37
- package/src/core/sync.ts +0 -121
- package/src/core/workspace-state.test.ts +0 -108
- package/src/core/workspace-state.ts +0 -130
- package/src/core/workspace.ts +0 -487
- package/src/core/worktree.ts +0 -120
- package/src/generators/antigravity.ts +0 -32
- package/src/generators/base.ts +0 -243
- package/src/generators/claude.ts +0 -34
- package/src/generators/codex.ts +0 -48
- package/src/generators/copilot.ts +0 -56
- package/src/generators/cursor.ts +0 -44
- package/src/generators/diff-context.ts +0 -75
- package/src/generators/index.ts +0 -322
- package/src/generators/map-generator.test.ts +0 -159
- package/src/generators/map-generator.ts +0 -539
- package/src/generators/plan-generator.ts +0 -483
- package/src/generators/skills-generator.ts +0 -259
- package/src/index.ts +0 -539
- package/src/mcp/server.ts +0 -338
- package/src/orchestration/detect.ts +0 -313
- package/src/orchestration/index.ts +0 -7
- package/src/orchestration/runner.ts +0 -283
- package/src/server.test.ts +0 -618
- package/src/server.ts +0 -1402
- package/src/types.ts +0 -451
- package/src/utils/detect-ai.test.ts +0 -44
- package/src/utils/detect-ai.ts +0 -84
- package/src/utils/detect-editors.test.ts +0 -48
- package/src/utils/detect-editors.ts +0 -57
- package/src/utils/git.test.ts +0 -74
- package/src/utils/git.ts +0 -117
- package/src/utils/local-ai.test.ts +0 -130
- package/src/utils/local-ai.ts +0 -116
- package/src/utils/multi-git.test.ts +0 -158
- package/src/utils/multi-git.ts +0 -405
- package/src/utils/prompts.ts +0 -209
- package/src/utils/session-finder.ts +0 -483
- package/src/utils/system-scanner.test.ts +0 -89
- package/src/utils/system-scanner.ts +0 -96
- package/src/utils/update-check.ts +0 -286
- package/src/utils/workflow-advisor.ts +0 -118
- package/src/utils/workflows.test.ts +0 -114
- package/src/utils/workflows.ts +0 -178
- package/tsconfig.json +0 -19
- package/vitest.config.ts +0 -14
package/src/server.test.ts
DELETED
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import * as fs from 'node:fs/promises';
|
|
3
|
-
import { execa } from 'execa';
|
|
4
|
-
import { app } from './server.js';
|
|
5
|
-
import * as workspace from './core/workspace.js';
|
|
6
|
-
import * as config from './core/config.js';
|
|
7
|
-
import * as systemScanner from './utils/system-scanner.js';
|
|
8
|
-
import * as localAi from './utils/local-ai.js';
|
|
9
|
-
import * as updateCheck from './utils/update-check.js';
|
|
10
|
-
import * as analyzers from './analyzers/index.js';
|
|
11
|
-
import * as generators from './generators/index.js';
|
|
12
|
-
import * as workflows from './utils/workflows.js';
|
|
13
|
-
import * as detectAi from './utils/detect-ai.js';
|
|
14
|
-
|
|
15
|
-
// Mock dependencies
|
|
16
|
-
vi.mock('node:fs/promises');
|
|
17
|
-
vi.mock('execa');
|
|
18
|
-
vi.mock('./core/workspace.js');
|
|
19
|
-
vi.mock('./core/config.js');
|
|
20
|
-
vi.mock('./utils/system-scanner.js');
|
|
21
|
-
vi.mock('./utils/local-ai.js');
|
|
22
|
-
vi.mock('./utils/update-check.js');
|
|
23
|
-
vi.mock('./analyzers/index.js');
|
|
24
|
-
vi.mock('./generators/index.js');
|
|
25
|
-
vi.mock('./utils/workflows.js');
|
|
26
|
-
vi.mock('./utils/detect-ai.js', () => ({
|
|
27
|
-
detectAIAssistants: vi.fn().mockResolvedValue([])
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
describe('Server API Endpoints Unit Tests', () => {
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
vi.clearAllMocks();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('POST /api/open-editor', () => {
|
|
36
|
-
it('should return 400 for forbidden editor commands', async () => {
|
|
37
|
-
const response = await app.request('/api/open-editor', {
|
|
38
|
-
method: 'POST',
|
|
39
|
-
headers: { 'Content-Type': 'application/json' },
|
|
40
|
-
body: JSON.stringify({
|
|
41
|
-
workspacePath: '/mock/workspace/path',
|
|
42
|
-
command: 'rm -rf /'
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
expect(response.status).toBe(400);
|
|
47
|
-
const data = await response.json();
|
|
48
|
-
expect(data.error).toBe('Forbidden editor command');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should return 400 if workspace path does not exist', async () => {
|
|
52
|
-
vi.spyOn(fs, 'stat').mockRejectedValue(new Error('File not found'));
|
|
53
|
-
|
|
54
|
-
const response = await app.request('/api/open-editor', {
|
|
55
|
-
method: 'POST',
|
|
56
|
-
headers: { 'Content-Type': 'application/json' },
|
|
57
|
-
body: JSON.stringify({
|
|
58
|
-
workspacePath: '/non-existent/path',
|
|
59
|
-
command: 'code-insiders'
|
|
60
|
-
})
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
expect(response.status).toBe(400);
|
|
64
|
-
const data = await response.json();
|
|
65
|
-
expect(data.error).toBe('Workspace path does not exist');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should return 400 if workspace path is not a directory', async () => {
|
|
69
|
-
vi.spyOn(fs, 'stat').mockResolvedValue({
|
|
70
|
-
isDirectory: () => false
|
|
71
|
-
} as any);
|
|
72
|
-
|
|
73
|
-
const response = await app.request('/api/open-editor', {
|
|
74
|
-
method: 'POST',
|
|
75
|
-
headers: { 'Content-Type': 'application/json' },
|
|
76
|
-
body: JSON.stringify({
|
|
77
|
-
workspacePath: '/mock/file.txt',
|
|
78
|
-
command: 'code-insiders'
|
|
79
|
-
})
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
expect(response.status).toBe(400);
|
|
83
|
-
const data = await response.json();
|
|
84
|
-
expect(data.error).toBe('Workspace path is not a directory');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('should call execa with detached, stdio, shell, and cleanup options and return success', async () => {
|
|
88
|
-
vi.spyOn(fs, 'stat').mockResolvedValue({
|
|
89
|
-
isDirectory: () => true
|
|
90
|
-
} as any);
|
|
91
|
-
|
|
92
|
-
// Mock execa to return a dummy child process with a catch method
|
|
93
|
-
const dummyChild = {
|
|
94
|
-
unref: vi.fn(),
|
|
95
|
-
catch: vi.fn().mockReturnThis()
|
|
96
|
-
};
|
|
97
|
-
vi.mocked(execa).mockReturnValue(dummyChild as any);
|
|
98
|
-
|
|
99
|
-
const response = await app.request('/api/open-editor', {
|
|
100
|
-
method: 'POST',
|
|
101
|
-
headers: { 'Content-Type': 'application/json' },
|
|
102
|
-
body: JSON.stringify({
|
|
103
|
-
workspacePath: '/mock/workspace/dir',
|
|
104
|
-
command: 'code-insiders'
|
|
105
|
-
})
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
expect(response.status).toBe(200);
|
|
109
|
-
const data = await response.json();
|
|
110
|
-
expect(data.success).toBe(true);
|
|
111
|
-
|
|
112
|
-
const isWin = process.platform === 'win32';
|
|
113
|
-
expect(execa).toHaveBeenCalledWith('code-insiders', ['/mock/workspace/dir'], {
|
|
114
|
-
detached: true,
|
|
115
|
-
stdio: 'ignore',
|
|
116
|
-
shell: isWin,
|
|
117
|
-
cleanup: false
|
|
118
|
-
});
|
|
119
|
-
expect(dummyChild.unref).toHaveBeenCalled();
|
|
120
|
-
expect(dummyChild.catch).toHaveBeenCalled();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
describe('POST /api/workspace/:id/resume', () => {
|
|
125
|
-
it('should fail with 400 if command is forbidden', async () => {
|
|
126
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
127
|
-
workspacesDir: '/mock/workspaces'
|
|
128
|
-
} as any);
|
|
129
|
-
vi.spyOn(workspace, 'loadFeatureConfig').mockResolvedValue({
|
|
130
|
-
id: 'test-ws',
|
|
131
|
-
repos: [],
|
|
132
|
-
assistants: ['antigravity']
|
|
133
|
-
} as any);
|
|
134
|
-
|
|
135
|
-
const response = await app.request('/api/workspace/test-ws/resume', {
|
|
136
|
-
method: 'POST',
|
|
137
|
-
headers: { 'Content-Type': 'application/json' },
|
|
138
|
-
body: JSON.stringify({
|
|
139
|
-
command: 'malicious-editor',
|
|
140
|
-
assistant: 'antigravity'
|
|
141
|
-
})
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
expect(response.status).toBe(400);
|
|
145
|
-
const data = await response.json();
|
|
146
|
-
expect(data.error).toBe('Forbidden editor command');
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('should spawn the editor with proper options when resuming', async () => {
|
|
150
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
151
|
-
workspacesDir: '/mock/workspaces'
|
|
152
|
-
} as any);
|
|
153
|
-
vi.spyOn(workspace, 'loadFeatureConfig').mockResolvedValue({
|
|
154
|
-
id: 'test-ws',
|
|
155
|
-
repos: [],
|
|
156
|
-
assistants: ['antigravity']
|
|
157
|
-
} as any);
|
|
158
|
-
|
|
159
|
-
const dummyChild = {
|
|
160
|
-
unref: vi.fn(),
|
|
161
|
-
catch: vi.fn().mockReturnThis()
|
|
162
|
-
};
|
|
163
|
-
vi.mocked(execa).mockReturnValue(dummyChild as any);
|
|
164
|
-
|
|
165
|
-
const response = await app.request('/api/workspace/test-ws/resume', {
|
|
166
|
-
method: 'POST',
|
|
167
|
-
headers: { 'Content-Type': 'application/json' },
|
|
168
|
-
body: JSON.stringify({
|
|
169
|
-
command: 'code',
|
|
170
|
-
assistant: 'antigravity'
|
|
171
|
-
})
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
expect(response.status).toBe(200);
|
|
175
|
-
const data = await response.json();
|
|
176
|
-
expect(data.success).toBe(true);
|
|
177
|
-
|
|
178
|
-
const isWin = process.platform === 'win32';
|
|
179
|
-
expect(execa).toHaveBeenCalledWith('code', [expect.any(String)], {
|
|
180
|
-
detached: true,
|
|
181
|
-
stdio: 'ignore',
|
|
182
|
-
shell: isWin,
|
|
183
|
-
cleanup: false
|
|
184
|
-
});
|
|
185
|
-
expect(dummyChild.unref).toHaveBeenCalled();
|
|
186
|
-
expect(dummyChild.catch).toHaveBeenCalled();
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe('GET /api/config', () => {
|
|
191
|
-
it('should load configuration successfully', async () => {
|
|
192
|
-
vi.spyOn(config, 'getConfigDir').mockReturnValue('/mock/config-dir');
|
|
193
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
194
|
-
devDir: '/mock/dev',
|
|
195
|
-
scanDepth: 2
|
|
196
|
-
} as any);
|
|
197
|
-
vi.spyOn(fs, 'access').mockResolvedValue();
|
|
198
|
-
|
|
199
|
-
const response = await app.request('/api/config');
|
|
200
|
-
expect(response.status).toBe(200);
|
|
201
|
-
const data = await response.json();
|
|
202
|
-
expect(data.config.devDir).toBe('/mock/dev');
|
|
203
|
-
expect(data.exists).toBe(true);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
describe('GET /api/adapters', () => {
|
|
208
|
-
it('should return all registered storage adapters with meta', async () => {
|
|
209
|
-
const response = await app.request('/api/adapters');
|
|
210
|
-
expect(response.status).toBe(200);
|
|
211
|
-
const data = await response.json();
|
|
212
|
-
expect(data.adapters).toBeDefined();
|
|
213
|
-
expect(Array.isArray(data.adapters)).toBe(true);
|
|
214
|
-
// It should include at least 'local', 'central-vault', and 'obsidian'
|
|
215
|
-
const names = data.adapters.map((a: any) => a.name);
|
|
216
|
-
expect(names).toContain('local');
|
|
217
|
-
expect(names).toContain('central-vault');
|
|
218
|
-
expect(names).toContain('obsidian');
|
|
219
|
-
|
|
220
|
-
const obsidian = data.adapters.find((a: any) => a.name === 'obsidian');
|
|
221
|
-
expect(obsidian.displayName).toBe('Obsidian Vault');
|
|
222
|
-
expect(obsidian.configFields.length).toBeGreaterThan(0);
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
describe('POST /api/config', () => {
|
|
227
|
-
it('should validate endpoint domain safety', async () => {
|
|
228
|
-
const response = await app.request('/api/config', {
|
|
229
|
-
method: 'POST',
|
|
230
|
-
headers: { 'Content-Type': 'application/json' },
|
|
231
|
-
body: JSON.stringify({
|
|
232
|
-
localLlm: {
|
|
233
|
-
enabled: true,
|
|
234
|
-
endpoint: 'http://malicious-external-domain.com'
|
|
235
|
-
}
|
|
236
|
-
})
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
expect(response.status).toBe(400);
|
|
240
|
-
const data = await response.json();
|
|
241
|
-
expect(data.error).toContain('Local AI endpoint must be HTTPS, localhost, 127.0.0.1, or a private LAN IP.');
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('should save safe endpoint and config', async () => {
|
|
245
|
-
vi.spyOn(config, 'saveConfig').mockResolvedValue();
|
|
246
|
-
|
|
247
|
-
const response = await app.request('/api/config', {
|
|
248
|
-
method: 'POST',
|
|
249
|
-
headers: { 'Content-Type': 'application/json' },
|
|
250
|
-
body: JSON.stringify({
|
|
251
|
-
localLlm: {
|
|
252
|
-
enabled: true,
|
|
253
|
-
endpoint: 'http://127.0.0.1:11434'
|
|
254
|
-
}
|
|
255
|
-
})
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
expect(response.status).toBe(200);
|
|
259
|
-
const data = await response.json();
|
|
260
|
-
expect(data.success).toBe(true);
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
describe('POST /api/local-llm/test', () => {
|
|
265
|
-
it('should reject unsafe endpoints', async () => {
|
|
266
|
-
const response = await app.request('/api/local-llm/test', {
|
|
267
|
-
method: 'POST',
|
|
268
|
-
headers: { 'Content-Type': 'application/json' },
|
|
269
|
-
body: JSON.stringify({
|
|
270
|
-
endpoint: 'http://unsafe-domain.com',
|
|
271
|
-
provider: 'ollama',
|
|
272
|
-
model: 'qwen2.5-coder:1.5b'
|
|
273
|
-
})
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
expect(response.status).toBe(400);
|
|
277
|
-
const data = await response.json();
|
|
278
|
-
expect(data.success).toBe(false);
|
|
279
|
-
expect(data.error).toContain('Local AI endpoint must be');
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('should perform inference shoot test if shoot = true', async () => {
|
|
283
|
-
vi.spyOn(localAi, 'callLocalLlm').mockResolvedValue('OK\n');
|
|
284
|
-
|
|
285
|
-
const response = await app.request('/api/local-llm/test', {
|
|
286
|
-
method: 'POST',
|
|
287
|
-
headers: { 'Content-Type': 'application/json' },
|
|
288
|
-
body: JSON.stringify({
|
|
289
|
-
endpoint: 'http://localhost:11434',
|
|
290
|
-
provider: 'ollama',
|
|
291
|
-
model: 'qwen2.5-coder:1.5b',
|
|
292
|
-
shoot: true
|
|
293
|
-
})
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
expect(response.status).toBe(200);
|
|
297
|
-
const data = await response.json();
|
|
298
|
-
expect(data.success).toBe(true);
|
|
299
|
-
expect(data.modelReady).toBe(true);
|
|
300
|
-
expect(data.message).toContain('Inference test succeeded');
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
describe('GET /api/local-llm/recommend', () => {
|
|
305
|
-
it('should fetch system specs and return them', async () => {
|
|
306
|
-
vi.spyOn(systemScanner, 'scanSystemSpecs').mockResolvedValue({
|
|
307
|
-
totalRamGb: 16,
|
|
308
|
-
gpuName: 'Nvidia RTX 4080',
|
|
309
|
-
hasHardwareAcceleration: true,
|
|
310
|
-
recommendedModel: 'qwen2.5-coder:7b'
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
const response = await app.request('/api/local-llm/recommend');
|
|
314
|
-
expect(response.status).toBe(200);
|
|
315
|
-
const data = await response.json();
|
|
316
|
-
expect(data.totalRamGb).toBe(16);
|
|
317
|
-
expect(data.gpuName).toBe('Nvidia RTX 4080');
|
|
318
|
-
expect(data.recommendedModel).toBe('qwen2.5-coder:7b');
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
describe('GET and PUT /api/workspace/:id/knowledge', () => {
|
|
323
|
-
it('should get workspace knowledge content', async () => {
|
|
324
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
325
|
-
workspacesDir: '/mock/workspaces'
|
|
326
|
-
} as any);
|
|
327
|
-
vi.spyOn(fs, 'readFile').mockResolvedValue('# Mock Knowledge File content');
|
|
328
|
-
|
|
329
|
-
const response = await app.request('/api/workspace/test-ws/knowledge');
|
|
330
|
-
expect(response.status).toBe(200);
|
|
331
|
-
const data = await response.json();
|
|
332
|
-
expect(data.content).toBe('# Mock Knowledge File content');
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
it('should write workspace knowledge content', async () => {
|
|
336
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
337
|
-
workspacesDir: '/mock/workspaces'
|
|
338
|
-
} as any);
|
|
339
|
-
vi.spyOn(fs, 'writeFile').mockResolvedValue();
|
|
340
|
-
|
|
341
|
-
const response = await app.request('/api/workspace/test-ws/knowledge', {
|
|
342
|
-
method: 'PUT',
|
|
343
|
-
headers: { 'Content-Type': 'application/json' },
|
|
344
|
-
body: JSON.stringify({ content: '# Updated Content' })
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
expect(response.status).toBe(200);
|
|
348
|
-
const data = await response.json();
|
|
349
|
-
expect(data.success).toBe(true);
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
describe('GET /api/workspace/:id/plan', () => {
|
|
354
|
-
it('should get workspace plan content', async () => {
|
|
355
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
356
|
-
workspacesDir: '/mock/workspaces'
|
|
357
|
-
} as any);
|
|
358
|
-
vi.spyOn(fs, 'readFile').mockResolvedValue('# Mock Plan content');
|
|
359
|
-
|
|
360
|
-
const response = await app.request('/api/workspace/test-ws/plan');
|
|
361
|
-
expect(response.status).toBe(200);
|
|
362
|
-
const data = await response.json();
|
|
363
|
-
expect(data.content).toBe('# Mock Plan content');
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
describe('POST /api/updates/install', () => {
|
|
368
|
-
it('should fail if tool not found', async () => {
|
|
369
|
-
const response = await app.request('/api/updates/install', {
|
|
370
|
-
method: 'POST',
|
|
371
|
-
headers: { 'Content-Type': 'application/json' },
|
|
372
|
-
body: JSON.stringify({ toolId: 'invalid-tool' })
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
expect(response.status).toBe(404);
|
|
376
|
-
const data = await response.json();
|
|
377
|
-
expect(data.error).toBe('Tool not found');
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
it('should install tool successfully if execa exits with 0', async () => {
|
|
381
|
-
vi.mocked(execa).mockResolvedValue({ exitCode: 0, stdout: 'Successfully updated' } as any);
|
|
382
|
-
|
|
383
|
-
const response = await app.request('/api/updates/install', {
|
|
384
|
-
method: 'POST',
|
|
385
|
-
headers: { 'Content-Type': 'application/json' },
|
|
386
|
-
body: JSON.stringify({ toolId: 'nexusflow' })
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
expect(response.status).toBe(200);
|
|
390
|
-
const data = await response.json();
|
|
391
|
-
expect(data.success).toBe(true);
|
|
392
|
-
expect(data.output).toBe('Successfully updated');
|
|
393
|
-
expect(execa).toHaveBeenCalledWith('npm', ['install', '-g', '@mrpatronz/nexusflow'], expect.any(Object));
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
describe('POST /api/workspace', () => {
|
|
398
|
-
it('should complete workspace creation successfully', async () => {
|
|
399
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
400
|
-
workspacesDir: '/mock/workspaces',
|
|
401
|
-
storageProvider: 'local'
|
|
402
|
-
} as any);
|
|
403
|
-
|
|
404
|
-
vi.spyOn(workspace, 'createWorkspace').mockResolvedValue('/mock/workspaces/test-ws-creation-no-pack');
|
|
405
|
-
vi.spyOn(analyzers, 'analyzeAllRepos').mockResolvedValue(new Map());
|
|
406
|
-
vi.spyOn(generators, 'generateContextFiles').mockResolvedValue(undefined);
|
|
407
|
-
|
|
408
|
-
const response = await app.request('/api/workspace', {
|
|
409
|
-
method: 'POST',
|
|
410
|
-
headers: { 'Content-Type': 'application/json' },
|
|
411
|
-
body: JSON.stringify({
|
|
412
|
-
branchName: 'test-ws-creation-no-pack',
|
|
413
|
-
description: 'A test workspace',
|
|
414
|
-
repos: [{ name: 'repo-1', path: '/mock/repo-1' }],
|
|
415
|
-
assistants: ['antigravity']
|
|
416
|
-
})
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
expect(response.status).toBe(200);
|
|
420
|
-
const data = await response.json();
|
|
421
|
-
expect(data.success).toBe(true);
|
|
422
|
-
expect(data.jobId).toBe('test-ws-creation-no-pack');
|
|
423
|
-
|
|
424
|
-
// Wait a brief tick for the background job to execute
|
|
425
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
426
|
-
|
|
427
|
-
expect(workspace.createWorkspace).toHaveBeenCalled();
|
|
428
|
-
expect(analyzers.analyzeAllRepos).toHaveBeenCalled();
|
|
429
|
-
expect(generators.generateContextFiles).toHaveBeenCalled();
|
|
430
|
-
|
|
431
|
-
// Read status via SSE stream route
|
|
432
|
-
const streamResponse = await app.request('/api/workspace/create-stream/test-ws-creation-no-pack');
|
|
433
|
-
expect(streamResponse.status).toBe(200);
|
|
434
|
-
const text = await streamResponse.text();
|
|
435
|
-
expect(text).toContain('"status":"completed"');
|
|
436
|
-
expect(text).toContain('"progress":100');
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
// XML context packing tests removed.
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
describe('Workflows Templates API', () => {
|
|
443
|
-
it('GET /api/workflows/templates should return list of templates', async () => {
|
|
444
|
-
vi.spyOn(workflows, 'getWorkflowTemplates').mockResolvedValue([
|
|
445
|
-
{ id: 'test-id', name: 'Test Name', description: 'Test Desc', content: 'Test Content', custom: false }
|
|
446
|
-
]);
|
|
447
|
-
|
|
448
|
-
const response = await app.request('/api/workflows/templates');
|
|
449
|
-
expect(response.status).toBe(200);
|
|
450
|
-
const data = await response.json();
|
|
451
|
-
expect(data).toEqual({
|
|
452
|
-
templates: [
|
|
453
|
-
{ id: 'test-id', name: 'Test Name', description: 'Test Desc', content: 'Test Content', custom: false }
|
|
454
|
-
]
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
it('POST /api/workflows/templates should create or update template', async () => {
|
|
459
|
-
vi.spyOn(workflows, 'saveWorkflowTemplate').mockResolvedValue({
|
|
460
|
-
id: 'test-id',
|
|
461
|
-
name: 'Test Name',
|
|
462
|
-
description: 'Test Desc',
|
|
463
|
-
content: 'Test Content',
|
|
464
|
-
custom: true
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
const response = await app.request('/api/workflows/templates', {
|
|
468
|
-
method: 'POST',
|
|
469
|
-
headers: { 'Content-Type': 'application/json' },
|
|
470
|
-
body: JSON.stringify({ id: 'old-id', name: 'Test Name', content: 'Test Content' })
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
expect(response.status).toBe(200);
|
|
474
|
-
const data = await response.json();
|
|
475
|
-
expect(data.success).toBe(true);
|
|
476
|
-
expect(data.template.id).toBe('test-id');
|
|
477
|
-
expect(workflows.saveWorkflowTemplate).toHaveBeenCalledWith('Test Name', 'Test Content', 'old-id');
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
it('DELETE /api/workflows/templates/:id should delete template', async () => {
|
|
481
|
-
vi.spyOn(workflows, 'getWorkflowTemplates').mockResolvedValue([
|
|
482
|
-
{ id: 'test-id', name: 'Test Name', description: 'Test Desc', content: 'Test Content', custom: true }
|
|
483
|
-
]);
|
|
484
|
-
vi.spyOn(workflows, 'deleteWorkflowTemplate').mockResolvedValue(undefined);
|
|
485
|
-
|
|
486
|
-
const response = await app.request('/api/workflows/templates/test-id', {
|
|
487
|
-
method: 'DELETE'
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
expect(response.status).toBe(200);
|
|
491
|
-
const data = await response.json();
|
|
492
|
-
expect(data.success).toBe(true);
|
|
493
|
-
expect(workflows.deleteWorkflowTemplate).toHaveBeenCalledWith('test-id');
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
it('POST /api/workflows/templates/:id/analyze should run inspection with comment', async () => {
|
|
497
|
-
vi.mocked(detectAi.detectAIAssistants).mockResolvedValue([
|
|
498
|
-
{ name: 'antigravity', displayName: 'Antigravity', detected: true, command: 'agy' }
|
|
499
|
-
]);
|
|
500
|
-
|
|
501
|
-
vi.mocked(execa).mockResolvedValue({
|
|
502
|
-
exitCode: 0,
|
|
503
|
-
stdout: 'Review result: Success\n=== SUGGESTED IMPROVEMENT START ===\n# Refined Strategy\n=== SUGGESTED IMPROVEMENT END ==='
|
|
504
|
-
} as any);
|
|
505
|
-
|
|
506
|
-
const response = await app.request('/api/workflows/templates/test-id/analyze', {
|
|
507
|
-
method: 'POST',
|
|
508
|
-
headers: { 'Content-Type': 'application/json' },
|
|
509
|
-
body: JSON.stringify({
|
|
510
|
-
content: 'My Strategy guidelines',
|
|
511
|
-
assistant: 'antigravity',
|
|
512
|
-
comment: 'Check for timeouts'
|
|
513
|
-
})
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
expect(response.status).toBe(200);
|
|
517
|
-
const data = await response.json();
|
|
518
|
-
expect(data.analysis).toContain('Review result: Success');
|
|
519
|
-
expect(data.suggestedImprovement).toBe('# Refined Strategy');
|
|
520
|
-
expect(execa).toHaveBeenCalled();
|
|
521
|
-
|
|
522
|
-
const calledArgs = vi.mocked(execa).mock.calls[0][1];
|
|
523
|
-
expect(JSON.stringify(calledArgs)).toContain('Check for timeouts');
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
describe('POST /api/workspace/suggest-workflow', () => {
|
|
527
|
-
it('should suggest a workflow using heuristics when local LLM is disabled', async () => {
|
|
528
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
529
|
-
version: '1.0',
|
|
530
|
-
devDir: '/dev',
|
|
531
|
-
workspacesDir: '/dev/workspaces',
|
|
532
|
-
defaultAssistant: null,
|
|
533
|
-
scanDepth: 2,
|
|
534
|
-
localLlm: { enabled: false, provider: 'ollama', endpoint: 'http://localhost:11434', model: 'qwen' }
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
const response = await app.request('/api/workspace/suggest-workflow', {
|
|
538
|
-
method: 'POST',
|
|
539
|
-
headers: { 'Content-Type': 'application/json' },
|
|
540
|
-
body: JSON.stringify({
|
|
541
|
-
description: 'Fix a typo in README.md and update comments',
|
|
542
|
-
repos: [{ name: 'my-project', path: '/dev/my-project', defaultBranch: 'main' }]
|
|
543
|
-
})
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
expect(response.status).toBe(200);
|
|
547
|
-
const data = await response.json();
|
|
548
|
-
expect(data.success).toBe(true);
|
|
549
|
-
expect(data.difficulty).toBe('simple');
|
|
550
|
-
expect(data.suggestedWorkflowId).toBe('solo-developer');
|
|
551
|
-
expect(data.customInstructions).toContain('Solo Developer');
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
it('should suggest a complex workflow when description contains complex keywords', async () => {
|
|
555
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
556
|
-
version: '1.0',
|
|
557
|
-
devDir: '/dev',
|
|
558
|
-
workspacesDir: '/dev/workspaces',
|
|
559
|
-
defaultAssistant: null,
|
|
560
|
-
scanDepth: 2,
|
|
561
|
-
localLlm: { enabled: false, provider: 'ollama', endpoint: 'http://localhost:11434', model: 'qwen' }
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
const response = await app.request('/api/workspace/suggest-workflow', {
|
|
565
|
-
method: 'POST',
|
|
566
|
-
headers: { 'Content-Type': 'application/json' },
|
|
567
|
-
body: JSON.stringify({
|
|
568
|
-
description: 'Refactor database schema and migrate data to postgres',
|
|
569
|
-
repos: [{ name: 'my-project', path: '/dev/my-project', defaultBranch: 'main' }]
|
|
570
|
-
})
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
expect(response.status).toBe(200);
|
|
574
|
-
const data = await response.json();
|
|
575
|
-
expect(data.success).toBe(true);
|
|
576
|
-
expect(data.difficulty).toBe('complex');
|
|
577
|
-
expect(data.suggestedWorkflowId).toBe('plan-implement-review');
|
|
578
|
-
expect(data.customInstructions).toContain('Plan, Implement, Review');
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
it('should call local LLM and return suggested workflow when LLM is enabled', async () => {
|
|
582
|
-
vi.spyOn(config, 'loadConfig').mockResolvedValue({
|
|
583
|
-
version: '1.0',
|
|
584
|
-
devDir: '/dev',
|
|
585
|
-
workspacesDir: '/dev/workspaces',
|
|
586
|
-
defaultAssistant: null,
|
|
587
|
-
scanDepth: 2,
|
|
588
|
-
localLlm: { enabled: true, provider: 'ollama', endpoint: 'http://localhost:11434', model: 'qwen' }
|
|
589
|
-
});
|
|
590
|
-
|
|
591
|
-
vi.spyOn(localAi, 'callLocalLlm').mockResolvedValue(JSON.stringify({
|
|
592
|
-
difficulty: 'moderate',
|
|
593
|
-
rationale: 'LLM selected moderate strategy.',
|
|
594
|
-
suggestedWorkflowId: 'research-verify',
|
|
595
|
-
customInstructions: '# LLM Custom Instructions'
|
|
596
|
-
}));
|
|
597
|
-
|
|
598
|
-
const response = await app.request('/api/workspace/suggest-workflow', {
|
|
599
|
-
method: 'POST',
|
|
600
|
-
headers: { 'Content-Type': 'application/json' },
|
|
601
|
-
body: JSON.stringify({
|
|
602
|
-
description: 'Implement new UI component',
|
|
603
|
-
repos: [{ name: 'my-project', path: '/dev/my-project', defaultBranch: 'main' }]
|
|
604
|
-
})
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
expect(response.status).toBe(200);
|
|
608
|
-
const data = await response.json();
|
|
609
|
-
expect(data.success).toBe(true);
|
|
610
|
-
expect(data.difficulty).toBe('moderate');
|
|
611
|
-
expect(data.rationale).toBe('LLM selected moderate strategy.');
|
|
612
|
-
expect(data.suggestedWorkflowId).toBe('research-verify');
|
|
613
|
-
expect(data.customInstructions).toBe('# LLM Custom Instructions');
|
|
614
|
-
expect(localAi.callLocalLlm).toHaveBeenCalled();
|
|
615
|
-
});
|
|
616
|
-
});
|
|
617
|
-
});
|
|
618
|
-
});
|