@mrpatronz/nexusflow 0.2.19 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/README.md +37 -7
  2. package/dist/analyzers/index.d.ts +23 -0
  3. package/dist/analyzers/index.d.ts.map +1 -1
  4. package/dist/analyzers/index.js +62 -0
  5. package/dist/analyzers/index.js.map +1 -1
  6. package/dist/commands/add-repo.d.ts +9 -0
  7. package/dist/commands/add-repo.d.ts.map +1 -1
  8. package/dist/commands/add-repo.js +12 -1
  9. package/dist/commands/add-repo.js.map +1 -1
  10. package/dist/commands/add-repo.test.d.ts +2 -0
  11. package/dist/commands/add-repo.test.d.ts.map +1 -0
  12. package/dist/commands/add-repo.test.js +30 -0
  13. package/dist/commands/add-repo.test.js.map +1 -0
  14. package/dist/commands/commands.test.js +26 -6
  15. package/dist/commands/commands.test.js.map +1 -1
  16. package/dist/commands/commit.d.ts +7 -1
  17. package/dist/commands/commit.d.ts.map +1 -1
  18. package/dist/commands/commit.js +31 -8
  19. package/dist/commands/commit.js.map +1 -1
  20. package/dist/commands/commit.test.d.ts +2 -0
  21. package/dist/commands/commit.test.d.ts.map +1 -0
  22. package/dist/commands/commit.test.js +54 -0
  23. package/dist/commands/commit.test.js.map +1 -0
  24. package/dist/commands/diff.d.ts +9 -2
  25. package/dist/commands/diff.d.ts.map +1 -1
  26. package/dist/commands/diff.js +36 -12
  27. package/dist/commands/diff.js.map +1 -1
  28. package/dist/commands/doctor.d.ts.map +1 -1
  29. package/dist/commands/doctor.js +16 -20
  30. package/dist/commands/doctor.js.map +1 -1
  31. package/dist/commands/handoff.d.ts.map +1 -1
  32. package/dist/commands/handoff.js +11 -15
  33. package/dist/commands/handoff.js.map +1 -1
  34. package/dist/commands/refresh.d.ts +4 -2
  35. package/dist/commands/refresh.d.ts.map +1 -1
  36. package/dist/commands/refresh.js +20 -36
  37. package/dist/commands/refresh.js.map +1 -1
  38. package/dist/commands/schedule.d.ts +35 -0
  39. package/dist/commands/schedule.d.ts.map +1 -0
  40. package/dist/commands/schedule.js +151 -0
  41. package/dist/commands/schedule.js.map +1 -0
  42. package/dist/commands/sync.d.ts.map +1 -1
  43. package/dist/commands/sync.js +28 -7
  44. package/dist/commands/sync.js.map +1 -1
  45. package/dist/commands/tui.js +1 -1
  46. package/dist/commands/tui.js.map +1 -1
  47. package/dist/commands/ui.d.ts +1 -0
  48. package/dist/commands/ui.d.ts.map +1 -1
  49. package/dist/commands/ui.js +5 -2
  50. package/dist/commands/ui.js.map +1 -1
  51. package/dist/core/adapters/local-storage.d.ts +7 -0
  52. package/dist/core/adapters/local-storage.d.ts.map +1 -1
  53. package/dist/core/adapters/local-storage.js +13 -4
  54. package/dist/core/adapters/local-storage.js.map +1 -1
  55. package/dist/core/adapters/storage.test.js +18 -0
  56. package/dist/core/adapters/storage.test.js.map +1 -1
  57. package/dist/core/analysis-cache.d.ts +58 -0
  58. package/dist/core/analysis-cache.d.ts.map +1 -0
  59. package/dist/core/analysis-cache.js +116 -0
  60. package/dist/core/analysis-cache.js.map +1 -0
  61. package/dist/core/analysis-cache.test.d.ts +2 -0
  62. package/dist/core/analysis-cache.test.d.ts.map +1 -0
  63. package/dist/core/analysis-cache.test.js +108 -0
  64. package/dist/core/analysis-cache.test.js.map +1 -0
  65. package/dist/core/refresh.d.ts +41 -0
  66. package/dist/core/refresh.d.ts.map +1 -0
  67. package/dist/core/refresh.js +56 -0
  68. package/dist/core/refresh.js.map +1 -0
  69. package/dist/core/scheduler.d.ts +117 -0
  70. package/dist/core/scheduler.d.ts.map +1 -0
  71. package/dist/core/scheduler.js +361 -0
  72. package/dist/core/scheduler.js.map +1 -0
  73. package/dist/core/scheduler.test.d.ts +2 -0
  74. package/dist/core/scheduler.test.d.ts.map +1 -0
  75. package/dist/core/scheduler.test.js +163 -0
  76. package/dist/core/scheduler.test.js.map +1 -0
  77. package/dist/core/sync.d.ts +6 -0
  78. package/dist/core/sync.d.ts.map +1 -1
  79. package/dist/core/sync.js +17 -12
  80. package/dist/core/sync.js.map +1 -1
  81. package/dist/core/workspace.d.ts +6 -0
  82. package/dist/core/workspace.d.ts.map +1 -1
  83. package/dist/core/workspace.js +32 -15
  84. package/dist/core/workspace.js.map +1 -1
  85. package/dist/core/workspace.test.d.ts +2 -0
  86. package/dist/core/workspace.test.d.ts.map +1 -0
  87. package/dist/core/workspace.test.js +42 -0
  88. package/dist/core/workspace.test.js.map +1 -0
  89. package/dist/generators/index.d.ts +7 -1
  90. package/dist/generators/index.d.ts.map +1 -1
  91. package/dist/generators/index.js +14 -1
  92. package/dist/generators/index.js.map +1 -1
  93. package/dist/generators/map-generator.d.ts.map +1 -1
  94. package/dist/generators/map-generator.js +4 -3
  95. package/dist/generators/map-generator.js.map +1 -1
  96. package/dist/generators/map-generator.test.js +4 -2
  97. package/dist/generators/map-generator.test.js.map +1 -1
  98. package/dist/gui/assets/index-ElroPpSP.js +26 -0
  99. package/dist/gui/index.html +1 -1
  100. package/dist/index.js +108 -4
  101. package/dist/index.js.map +1 -1
  102. package/dist/orchestration/index.d.ts +1 -1
  103. package/dist/orchestration/index.d.ts.map +1 -1
  104. package/dist/orchestration/index.js +1 -1
  105. package/dist/orchestration/index.js.map +1 -1
  106. package/dist/orchestration/runner.d.ts +16 -1
  107. package/dist/orchestration/runner.d.ts.map +1 -1
  108. package/dist/orchestration/runner.js +41 -5
  109. package/dist/orchestration/runner.js.map +1 -1
  110. package/dist/orchestration/runner.test.d.ts +2 -0
  111. package/dist/orchestration/runner.test.d.ts.map +1 -0
  112. package/dist/orchestration/runner.test.js +71 -0
  113. package/dist/orchestration/runner.test.js.map +1 -0
  114. package/dist/server.d.ts +17 -1
  115. package/dist/server.d.ts.map +1 -1
  116. package/dist/server.js +275 -114
  117. package/dist/server.js.map +1 -1
  118. package/dist/server.test.js +158 -1
  119. package/dist/server.test.js.map +1 -1
  120. package/dist/utils/multi-git.d.ts +21 -0
  121. package/dist/utils/multi-git.d.ts.map +1 -1
  122. package/dist/utils/multi-git.js +40 -4
  123. package/dist/utils/multi-git.js.map +1 -1
  124. package/dist/utils/prompts.d.ts.map +1 -1
  125. package/dist/utils/prompts.js +8 -2
  126. package/dist/utils/prompts.js.map +1 -1
  127. package/package.json +13 -1
  128. package/.agents/skills/ccc/SKILL.md +0 -71
  129. package/.agents/skills/ccc/references/management.md +0 -110
  130. package/.agents/skills/ccc/references/settings.md +0 -126
  131. package/.github/dependabot.yml +0 -52
  132. package/.github/workflows/ci.yml +0 -44
  133. package/.github/workflows/dependabot-merge.yml +0 -53
  134. package/.github/workflows/release-desktop.yml +0 -67
  135. package/.github/workflows/release-npm.yml +0 -65
  136. package/.github/workflows/release-vscode.yml +0 -61
  137. package/.vscode/launch.json +0 -17
  138. package/.vscode/tasks.json +0 -17
  139. package/GETTING_STARTED.md +0 -114
  140. package/desktop/build-installer.js +0 -228
  141. package/desktop/build.js +0 -118
  142. package/desktop/installer/nexusflow.iss +0 -35
  143. package/desktop/neutralino.config.json +0 -39
  144. package/desktop/package-lock.json +0 -1060
  145. package/desktop/package.json +0 -14
  146. package/dist/gui/assets/index-D8iJPvnk.js +0 -26
  147. package/extension/media/icon.svg +0 -1
  148. package/extension/package-lock.json +0 -6044
  149. package/extension/package.json +0 -117
  150. package/extension/src/extension.ts +0 -653
  151. package/extension/tsconfig.json +0 -21
  152. package/gui/README.md +0 -73
  153. package/gui/e2e/dashboard.spec.ts +0 -61
  154. package/gui/e2e/wizard.spec.ts +0 -346
  155. package/gui/eslint.config.js +0 -26
  156. package/gui/index.html +0 -17
  157. package/gui/package-lock.json +0 -3137
  158. package/gui/package.json +0 -37
  159. package/gui/playwright.config.ts +0 -41
  160. package/gui/public/app_logo.png +0 -0
  161. package/gui/public/favicon.svg +0 -1
  162. package/gui/public/icons.svg +0 -24
  163. package/gui/src/App.css +0 -1
  164. package/gui/src/App.tsx +0 -3573
  165. package/gui/src/app/AppSidebar.tsx +0 -69
  166. package/gui/src/assets/hero.png +0 -0
  167. package/gui/src/assets/react.svg +0 -1
  168. package/gui/src/assets/vite.svg +0 -1
  169. package/gui/src/components/AddRepoPicker.tsx +0 -81
  170. package/gui/src/components/ui/Button.tsx +0 -40
  171. package/gui/src/components/ui/Card.tsx +0 -6
  172. package/gui/src/components/ui/EmptyState.tsx +0 -22
  173. package/gui/src/components/ui/Input.tsx +0 -21
  174. package/gui/src/components/ui/Menu.tsx +0 -71
  175. package/gui/src/components/ui/Modal.tsx +0 -39
  176. package/gui/src/components/ui/PageHeader.tsx +0 -21
  177. package/gui/src/components/ui/RepoStatusStrip.tsx +0 -33
  178. package/gui/src/components/ui/Skeleton.tsx +0 -5
  179. package/gui/src/components/ui/StatusPill.tsx +0 -36
  180. package/gui/src/components/ui/Tabs.tsx +0 -40
  181. package/gui/src/components/ui/cn.ts +0 -4
  182. package/gui/src/components/ui/index.ts +0 -16
  183. package/gui/src/features/changes/ChangesViewer.tsx +0 -388
  184. package/gui/src/features/knowledge/KnowledgeBase.tsx +0 -84
  185. package/gui/src/features/onboarding/OnboardingWizard.tsx +0 -230
  186. package/gui/src/features/plan/ImplementationPlan.tsx +0 -32
  187. package/gui/src/features/services/ServiceConsole.tsx +0 -215
  188. package/gui/src/features/sessions/SessionHistory.tsx +0 -195
  189. package/gui/src/index.css +0 -167
  190. package/gui/src/lib/status.ts +0 -24
  191. package/gui/src/main.tsx +0 -94
  192. package/gui/src/pages/DashboardPage.tsx +0 -129
  193. package/gui/src/pages/WorkspacesPage.tsx +0 -352
  194. package/gui/src/types.ts +0 -81
  195. package/gui/tsconfig.app.json +0 -25
  196. package/gui/tsconfig.json +0 -7
  197. package/gui/tsconfig.node.json +0 -24
  198. package/gui/vite.config.ts +0 -12
  199. package/resources/workflows/plan-implement-review.md +0 -8
  200. package/resources/workflows/research-verify.md +0 -6
  201. package/resources/workflows/solo-developer.md +0 -3
  202. package/scripts/simulate-workspaces.ts +0 -55
  203. package/skills-lock.json +0 -11
  204. package/src/analyzers/detect-apis.ts +0 -290
  205. package/src/analyzers/detect-deps.ts +0 -315
  206. package/src/analyzers/detect-existing.ts +0 -74
  207. package/src/analyzers/detect-ports.ts +0 -110
  208. package/src/analyzers/index.ts +0 -97
  209. package/src/analyzers/messaging-analyzer.ts +0 -254
  210. package/src/analyzers/readme-summarizer.ts +0 -102
  211. package/src/analyzers/run-analyzer.ts +0 -269
  212. package/src/analyzers/tech-stack.ts +0 -283
  213. package/src/commands/adapter.ts +0 -348
  214. package/src/commands/add-repo.ts +0 -156
  215. package/src/commands/commands.test.ts +0 -156
  216. package/src/commands/commit.ts +0 -131
  217. package/src/commands/config.ts +0 -52
  218. package/src/commands/create.ts +0 -204
  219. package/src/commands/desktop.ts +0 -128
  220. package/src/commands/diff.ts +0 -125
  221. package/src/commands/doctor.ts +0 -370
  222. package/src/commands/handoff.ts +0 -266
  223. package/src/commands/init.ts +0 -134
  224. package/src/commands/list.ts +0 -46
  225. package/src/commands/logs.ts +0 -63
  226. package/src/commands/mcp.ts +0 -94
  227. package/src/commands/open.ts +0 -129
  228. package/src/commands/refresh.ts +0 -137
  229. package/src/commands/remove.ts +0 -98
  230. package/src/commands/start.ts +0 -117
  231. package/src/commands/status.ts +0 -54
  232. package/src/commands/stop.ts +0 -55
  233. package/src/commands/sync.ts +0 -125
  234. package/src/commands/tui.ts +0 -484
  235. package/src/commands/ui.ts +0 -111
  236. package/src/core/adapters/local-storage.ts +0 -66
  237. package/src/core/adapters/obsidian-storage.ts +0 -151
  238. package/src/core/adapters/registry.ts +0 -44
  239. package/src/core/adapters/storage.test.ts +0 -174
  240. package/src/core/adapters/vault-storage.ts +0 -86
  241. package/src/core/config.test.ts +0 -96
  242. package/src/core/config.ts +0 -140
  243. package/src/core/graph.ts +0 -344
  244. package/src/core/plugins/index.ts +0 -17
  245. package/src/core/plugins/loader.ts +0 -36
  246. package/src/core/ports/storage.ts +0 -71
  247. package/src/core/scanner.test.ts +0 -61
  248. package/src/core/scanner.ts +0 -91
  249. package/src/core/storage.ts +0 -37
  250. package/src/core/sync.ts +0 -121
  251. package/src/core/workspace-state.test.ts +0 -108
  252. package/src/core/workspace-state.ts +0 -130
  253. package/src/core/workspace.ts +0 -487
  254. package/src/core/worktree.ts +0 -120
  255. package/src/generators/antigravity.ts +0 -32
  256. package/src/generators/base.ts +0 -243
  257. package/src/generators/claude.ts +0 -34
  258. package/src/generators/codex.ts +0 -48
  259. package/src/generators/copilot.ts +0 -56
  260. package/src/generators/cursor.ts +0 -44
  261. package/src/generators/diff-context.ts +0 -75
  262. package/src/generators/index.ts +0 -322
  263. package/src/generators/map-generator.test.ts +0 -159
  264. package/src/generators/map-generator.ts +0 -539
  265. package/src/generators/plan-generator.ts +0 -483
  266. package/src/generators/skills-generator.ts +0 -259
  267. package/src/index.ts +0 -539
  268. package/src/mcp/server.ts +0 -338
  269. package/src/orchestration/detect.ts +0 -313
  270. package/src/orchestration/index.ts +0 -7
  271. package/src/orchestration/runner.ts +0 -283
  272. package/src/server.test.ts +0 -618
  273. package/src/server.ts +0 -1402
  274. package/src/types.ts +0 -451
  275. package/src/utils/detect-ai.test.ts +0 -44
  276. package/src/utils/detect-ai.ts +0 -84
  277. package/src/utils/detect-editors.test.ts +0 -48
  278. package/src/utils/detect-editors.ts +0 -57
  279. package/src/utils/git.test.ts +0 -74
  280. package/src/utils/git.ts +0 -117
  281. package/src/utils/local-ai.test.ts +0 -130
  282. package/src/utils/local-ai.ts +0 -116
  283. package/src/utils/multi-git.test.ts +0 -158
  284. package/src/utils/multi-git.ts +0 -405
  285. package/src/utils/prompts.ts +0 -209
  286. package/src/utils/session-finder.ts +0 -483
  287. package/src/utils/system-scanner.test.ts +0 -89
  288. package/src/utils/system-scanner.ts +0 -96
  289. package/src/utils/update-check.ts +0 -286
  290. package/src/utils/workflow-advisor.ts +0 -118
  291. package/src/utils/workflows.test.ts +0 -114
  292. package/src/utils/workflows.ts +0 -178
  293. package/tsconfig.json +0 -19
  294. package/vitest.config.ts +0 -14
@@ -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
- });