@mrpatronz/nexusflow 0.2.18 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/README.md +27 -3
  2. package/dist/analyzers/index.d.ts +23 -0
  3. package/dist/analyzers/index.d.ts.map +1 -1
  4. package/dist/analyzers/index.js +62 -0
  5. package/dist/analyzers/index.js.map +1 -1
  6. package/dist/commands/commands.test.js +20 -6
  7. package/dist/commands/commands.test.js.map +1 -1
  8. package/dist/commands/commit.d.ts +2 -0
  9. package/dist/commands/commit.d.ts.map +1 -1
  10. package/dist/commands/commit.js +27 -5
  11. package/dist/commands/commit.js.map +1 -1
  12. package/dist/commands/diff.d.ts +9 -2
  13. package/dist/commands/diff.d.ts.map +1 -1
  14. package/dist/commands/diff.js +36 -12
  15. package/dist/commands/diff.js.map +1 -1
  16. package/dist/commands/doctor.js +2 -2
  17. package/dist/commands/doctor.js.map +1 -1
  18. package/dist/commands/handoff.js +2 -2
  19. package/dist/commands/handoff.js.map +1 -1
  20. package/dist/commands/refresh.d.ts +4 -2
  21. package/dist/commands/refresh.d.ts.map +1 -1
  22. package/dist/commands/refresh.js +20 -36
  23. package/dist/commands/refresh.js.map +1 -1
  24. package/dist/commands/schedule.d.ts +35 -0
  25. package/dist/commands/schedule.d.ts.map +1 -0
  26. package/dist/commands/schedule.js +151 -0
  27. package/dist/commands/schedule.js.map +1 -0
  28. package/dist/commands/sync.d.ts.map +1 -1
  29. package/dist/commands/sync.js +58 -50
  30. package/dist/commands/sync.js.map +1 -1
  31. package/dist/core/analysis-cache.d.ts +58 -0
  32. package/dist/core/analysis-cache.d.ts.map +1 -0
  33. package/dist/core/analysis-cache.js +116 -0
  34. package/dist/core/analysis-cache.js.map +1 -0
  35. package/dist/core/analysis-cache.test.d.ts +2 -0
  36. package/dist/core/analysis-cache.test.d.ts.map +1 -0
  37. package/dist/core/analysis-cache.test.js +108 -0
  38. package/dist/core/analysis-cache.test.js.map +1 -0
  39. package/dist/core/refresh.d.ts +41 -0
  40. package/dist/core/refresh.d.ts.map +1 -0
  41. package/dist/core/refresh.js +60 -0
  42. package/dist/core/refresh.js.map +1 -0
  43. package/dist/core/scheduler.d.ts +117 -0
  44. package/dist/core/scheduler.d.ts.map +1 -0
  45. package/dist/core/scheduler.js +247 -0
  46. package/dist/core/scheduler.js.map +1 -0
  47. package/dist/core/scheduler.test.d.ts +2 -0
  48. package/dist/core/scheduler.test.d.ts.map +1 -0
  49. package/dist/core/scheduler.test.js +111 -0
  50. package/dist/core/scheduler.test.js.map +1 -0
  51. package/dist/core/sync.d.ts +50 -0
  52. package/dist/core/sync.d.ts.map +1 -0
  53. package/dist/core/sync.js +92 -0
  54. package/dist/core/sync.js.map +1 -0
  55. package/dist/core/workspace-state.d.ts +51 -0
  56. package/dist/core/workspace-state.d.ts.map +1 -0
  57. package/dist/core/workspace-state.js +108 -0
  58. package/dist/core/workspace-state.js.map +1 -0
  59. package/dist/core/workspace-state.test.d.ts +2 -0
  60. package/dist/core/workspace-state.test.d.ts.map +1 -0
  61. package/dist/core/workspace-state.test.js +84 -0
  62. package/dist/core/workspace-state.test.js.map +1 -0
  63. package/dist/generators/index.d.ts +7 -1
  64. package/dist/generators/index.d.ts.map +1 -1
  65. package/dist/generators/index.js +14 -1
  66. package/dist/generators/index.js.map +1 -1
  67. package/dist/gui/assets/index-Bdbld6yY.css +1 -0
  68. package/dist/gui/assets/index-D8iJPvnk.js +26 -0
  69. package/dist/gui/index.html +2 -2
  70. package/dist/index.js +107 -4
  71. package/dist/index.js.map +1 -1
  72. package/dist/mcp/server.d.ts.map +1 -1
  73. package/dist/mcp/server.js +42 -0
  74. package/dist/mcp/server.js.map +1 -1
  75. package/dist/server.d.ts.map +1 -1
  76. package/dist/server.js +175 -13
  77. package/dist/server.js.map +1 -1
  78. package/dist/server.test.js +66 -0
  79. package/dist/server.test.js.map +1 -1
  80. package/dist/types.d.ts +31 -0
  81. package/dist/types.d.ts.map +1 -1
  82. package/dist/utils/multi-git.d.ts +54 -8
  83. package/dist/utils/multi-git.d.ts.map +1 -1
  84. package/dist/utils/multi-git.js +129 -21
  85. package/dist/utils/multi-git.js.map +1 -1
  86. package/dist/utils/multi-git.test.d.ts +2 -0
  87. package/dist/utils/multi-git.test.d.ts.map +1 -0
  88. package/dist/utils/multi-git.test.js +125 -0
  89. package/dist/utils/multi-git.test.js.map +1 -0
  90. package/package.json +13 -1
  91. package/.agents/skills/ccc/SKILL.md +0 -71
  92. package/.agents/skills/ccc/references/management.md +0 -110
  93. package/.agents/skills/ccc/references/settings.md +0 -126
  94. package/.github/dependabot.yml +0 -52
  95. package/.github/workflows/ci.yml +0 -44
  96. package/.github/workflows/dependabot-merge.yml +0 -53
  97. package/.github/workflows/release-desktop.yml +0 -67
  98. package/.github/workflows/release-npm.yml +0 -65
  99. package/.github/workflows/release-vscode.yml +0 -61
  100. package/.vscode/launch.json +0 -17
  101. package/.vscode/tasks.json +0 -17
  102. package/GETTING_STARTED.md +0 -114
  103. package/desktop/build-installer.js +0 -228
  104. package/desktop/build.js +0 -118
  105. package/desktop/installer/nexusflow.iss +0 -35
  106. package/desktop/neutralino.config.json +0 -39
  107. package/desktop/package-lock.json +0 -1060
  108. package/desktop/package.json +0 -14
  109. package/dist/gui/assets/index-CB-jWded.css +0 -1
  110. package/dist/gui/assets/index-DDXpZZu3.js +0 -25
  111. package/extension/media/icon.svg +0 -1
  112. package/extension/package-lock.json +0 -6044
  113. package/extension/package.json +0 -117
  114. package/extension/src/extension.ts +0 -653
  115. package/extension/tsconfig.json +0 -21
  116. package/gui/README.md +0 -73
  117. package/gui/e2e/wizard.spec.ts +0 -346
  118. package/gui/eslint.config.js +0 -26
  119. package/gui/index.html +0 -17
  120. package/gui/package-lock.json +0 -3079
  121. package/gui/package.json +0 -36
  122. package/gui/playwright.config.ts +0 -41
  123. package/gui/public/app_logo.png +0 -0
  124. package/gui/public/favicon.svg +0 -1
  125. package/gui/public/icons.svg +0 -24
  126. package/gui/src/App.css +0 -1
  127. package/gui/src/App.tsx +0 -3632
  128. package/gui/src/assets/hero.png +0 -0
  129. package/gui/src/assets/react.svg +0 -1
  130. package/gui/src/assets/vite.svg +0 -1
  131. package/gui/src/features/changes/ChangesViewer.tsx +0 -388
  132. package/gui/src/features/knowledge/KnowledgeBase.tsx +0 -84
  133. package/gui/src/features/onboarding/OnboardingWizard.tsx +0 -230
  134. package/gui/src/features/plan/ImplementationPlan.tsx +0 -32
  135. package/gui/src/features/services/ServiceConsole.tsx +0 -250
  136. package/gui/src/features/sessions/SessionHistory.tsx +0 -195
  137. package/gui/src/features/workspace/WorkspaceList.tsx +0 -666
  138. package/gui/src/index.css +0 -152
  139. package/gui/src/main.tsx +0 -94
  140. package/gui/src/types.ts +0 -62
  141. package/gui/tsconfig.app.json +0 -25
  142. package/gui/tsconfig.json +0 -7
  143. package/gui/tsconfig.node.json +0 -24
  144. package/gui/vite.config.ts +0 -12
  145. package/resources/workflows/plan-implement-review.md +0 -8
  146. package/resources/workflows/research-verify.md +0 -6
  147. package/resources/workflows/solo-developer.md +0 -3
  148. package/scripts/simulate-workspaces.ts +0 -55
  149. package/skills-lock.json +0 -11
  150. package/src/analyzers/detect-apis.ts +0 -290
  151. package/src/analyzers/detect-deps.ts +0 -315
  152. package/src/analyzers/detect-existing.ts +0 -74
  153. package/src/analyzers/detect-ports.ts +0 -110
  154. package/src/analyzers/index.ts +0 -97
  155. package/src/analyzers/messaging-analyzer.ts +0 -254
  156. package/src/analyzers/readme-summarizer.ts +0 -102
  157. package/src/analyzers/run-analyzer.ts +0 -269
  158. package/src/analyzers/tech-stack.ts +0 -283
  159. package/src/commands/adapter.ts +0 -348
  160. package/src/commands/add-repo.ts +0 -156
  161. package/src/commands/commands.test.ts +0 -156
  162. package/src/commands/commit.ts +0 -131
  163. package/src/commands/config.ts +0 -52
  164. package/src/commands/create.ts +0 -204
  165. package/src/commands/desktop.ts +0 -128
  166. package/src/commands/diff.ts +0 -125
  167. package/src/commands/doctor.ts +0 -370
  168. package/src/commands/handoff.ts +0 -266
  169. package/src/commands/init.ts +0 -134
  170. package/src/commands/list.ts +0 -46
  171. package/src/commands/logs.ts +0 -63
  172. package/src/commands/mcp.ts +0 -94
  173. package/src/commands/open.ts +0 -129
  174. package/src/commands/refresh.ts +0 -137
  175. package/src/commands/remove.ts +0 -98
  176. package/src/commands/start.ts +0 -117
  177. package/src/commands/status.ts +0 -54
  178. package/src/commands/stop.ts +0 -55
  179. package/src/commands/sync.ts +0 -147
  180. package/src/commands/tui.ts +0 -484
  181. package/src/commands/ui.ts +0 -111
  182. package/src/core/adapters/local-storage.ts +0 -66
  183. package/src/core/adapters/obsidian-storage.ts +0 -151
  184. package/src/core/adapters/registry.ts +0 -44
  185. package/src/core/adapters/storage.test.ts +0 -174
  186. package/src/core/adapters/vault-storage.ts +0 -86
  187. package/src/core/config.test.ts +0 -96
  188. package/src/core/config.ts +0 -140
  189. package/src/core/graph.ts +0 -344
  190. package/src/core/plugins/index.ts +0 -17
  191. package/src/core/plugins/loader.ts +0 -36
  192. package/src/core/ports/storage.ts +0 -71
  193. package/src/core/scanner.test.ts +0 -61
  194. package/src/core/scanner.ts +0 -91
  195. package/src/core/storage.ts +0 -37
  196. package/src/core/workspace.ts +0 -487
  197. package/src/core/worktree.ts +0 -120
  198. package/src/generators/antigravity.ts +0 -32
  199. package/src/generators/base.ts +0 -243
  200. package/src/generators/claude.ts +0 -34
  201. package/src/generators/codex.ts +0 -48
  202. package/src/generators/copilot.ts +0 -56
  203. package/src/generators/cursor.ts +0 -44
  204. package/src/generators/diff-context.ts +0 -75
  205. package/src/generators/index.ts +0 -322
  206. package/src/generators/map-generator.test.ts +0 -159
  207. package/src/generators/map-generator.ts +0 -539
  208. package/src/generators/plan-generator.ts +0 -483
  209. package/src/generators/skills-generator.ts +0 -259
  210. package/src/index.ts +0 -539
  211. package/src/mcp/server.ts +0 -294
  212. package/src/orchestration/detect.ts +0 -313
  213. package/src/orchestration/index.ts +0 -7
  214. package/src/orchestration/runner.ts +0 -283
  215. package/src/server.test.ts +0 -618
  216. package/src/server.ts +0 -1314
  217. package/src/types.ts +0 -415
  218. package/src/utils/detect-ai.test.ts +0 -44
  219. package/src/utils/detect-ai.ts +0 -84
  220. package/src/utils/detect-editors.test.ts +0 -48
  221. package/src/utils/detect-editors.ts +0 -57
  222. package/src/utils/git.test.ts +0 -74
  223. package/src/utils/git.ts +0 -117
  224. package/src/utils/local-ai.test.ts +0 -130
  225. package/src/utils/local-ai.ts +0 -116
  226. package/src/utils/multi-git.ts +0 -313
  227. package/src/utils/prompts.ts +0 -209
  228. package/src/utils/session-finder.ts +0 -483
  229. package/src/utils/system-scanner.test.ts +0 -89
  230. package/src/utils/system-scanner.ts +0 -96
  231. package/src/utils/update-check.ts +0 -286
  232. package/src/utils/workflow-advisor.ts +0 -118
  233. package/src/utils/workflows.test.ts +0 -114
  234. package/src/utils/workflows.ts +0 -178
  235. package/tsconfig.json +0 -19
  236. package/vitest.config.ts +0 -14
@@ -1,286 +0,0 @@
1
- /**
2
- * @module utils/update-check
3
- * Checks for updates to the NexusFlow package on the NPM registry.
4
- */
5
-
6
- import { fileURLToPath } from 'node:url';
7
- import * as fs from 'node:fs';
8
- import * as path from 'node:path';
9
- import chalk from 'chalk';
10
-
11
- import { loadConfig, saveConfig } from '../core/config.js';
12
-
13
- export interface UpdateStatus {
14
- currentVersion: string;
15
- latestVersion: string;
16
- updateAvailable: boolean;
17
- downloadUrl?: string | null;
18
- releaseNotes?: string;
19
- }
20
-
21
- interface GitHubAsset {
22
- name: string;
23
- browser_download_url: string;
24
- size: number;
25
- }
26
-
27
- interface GitHubRelease {
28
- tag_name: string;
29
- html_url: string;
30
- body: string;
31
- assets: GitHubAsset[];
32
- }
33
-
34
- /**
35
- * Resolves the current package version by searching for package.json upward
36
- * from the directory of the executing code.
37
- */
38
- export function getCurrentVersion(): string {
39
- try {
40
- const __filename = fileURLToPath(import.meta.url);
41
- const __dirname = path.dirname(__filename);
42
-
43
- let currentDir = __dirname;
44
- for (let i = 0; i < 5; i++) {
45
- const packageJsonPath = path.join(currentDir, 'package.json');
46
- if (fs.existsSync(packageJsonPath)) {
47
- const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
48
- return pkg.version;
49
- }
50
- const parentDir = path.dirname(currentDir);
51
- if (parentDir === currentDir) break;
52
- currentDir = parentDir;
53
- }
54
- } catch {
55
- // Fallback if filesystem access fails
56
- }
57
- return '0.1.5'; // Sensible fallback (active release)
58
- }
59
-
60
- /**
61
- * Checks for updates from the GitHub Releases API (antan87/NexusFlow).
62
- * Employs a 24-hour cache unless forced.
63
- *
64
- * @param force - If true, ignores the 24-hour cache and fetches immediately.
65
- * @returns The update status, or null if the check fails (e.g. offline).
66
- */
67
- export async function checkForUpdates(force = false): Promise<UpdateStatus | null> {
68
- const currentVersion = getCurrentVersion();
69
- const config = await loadConfig();
70
-
71
- const now = Date.now();
72
- const lastCheck = config.lastUpdateCheck ? new Date(config.lastUpdateCheck).getTime() : 0;
73
- const ONE_DAY_MS = 24 * 60 * 60 * 1000;
74
-
75
- // Use cached result if within 24 hours and not forced
76
- if (!force && lastCheck && (now - lastCheck < ONE_DAY_MS) && config.latestVersion) {
77
- return {
78
- currentVersion,
79
- latestVersion: config.latestVersion,
80
- updateAvailable: isNewerVersion(currentVersion, config.latestVersion),
81
- downloadUrl: config.latestDownloadUrl,
82
- releaseNotes: config.latestReleaseNotes,
83
- };
84
- }
85
-
86
- try {
87
- const response = await fetch('https://api.github.com/repos/antan87/NexusFlow/releases/latest', {
88
- headers: { 'User-Agent': 'NexusFlow-Updater' },
89
- signal: AbortSignal.timeout(4000),
90
- });
91
-
92
- if (!response.ok) {
93
- throw new Error(`GitHub API returned status ${response.status}`);
94
- }
95
-
96
- const data = await response.json() as GitHubRelease;
97
- const latestVersion = data.tag_name.replace(/^v/, '');
98
-
99
- // Resolve platform-matching asset (e.g. Setup.exe for Windows)
100
- let downloadUrl: string | null = null;
101
- const targetAsset = data.assets.find(asset => {
102
- return asset.name.endsWith('.exe') && asset.name.toLowerCase().includes('setup');
103
- });
104
- if (targetAsset) {
105
- downloadUrl = targetAsset.browser_download_url;
106
- }
107
-
108
- const releaseNotes = data.body || '';
109
-
110
- // Cache results
111
- config.lastUpdateCheck = new Date().toISOString();
112
- config.latestVersion = latestVersion;
113
- config.latestDownloadUrl = downloadUrl;
114
- config.latestReleaseNotes = releaseNotes;
115
- await saveConfig(config);
116
-
117
- return {
118
- currentVersion,
119
- latestVersion,
120
- updateAvailable: isNewerVersion(currentVersion, latestVersion),
121
- downloadUrl,
122
- releaseNotes,
123
- };
124
- } catch {
125
- // Fallback: If offline or check fails, return cached version status if available
126
- if (config.latestVersion) {
127
- return {
128
- currentVersion,
129
- latestVersion: config.latestVersion,
130
- updateAvailable: isNewerVersion(currentVersion, config.latestVersion),
131
- downloadUrl: config.latestDownloadUrl,
132
- releaseNotes: config.latestReleaseNotes,
133
- };
134
- }
135
- return null;
136
- }
137
- }
138
-
139
- /**
140
- * Simple semver comparison (checks major.minor.patch).
141
- */
142
- function isNewerVersion(current: string, latest: string): boolean {
143
- if (current === latest) return false;
144
-
145
- const currentParts = current.split('.').map(Number);
146
- const latestParts = latest.split('.').map(Number);
147
-
148
- for (let i = 0; i < 3; i++) {
149
- const curr = currentParts[i] || 0;
150
- const lat = latestParts[i] || 0;
151
- if (lat > curr) return true;
152
- if (curr > lat) return false;
153
- }
154
-
155
- return false;
156
- }
157
-
158
- /**
159
- * Prints a clean, premium terminal notification banner if an update is available.
160
- */
161
- export function printUpdateBanner(status: UpdateStatus): void {
162
- if (!status.updateAvailable) return;
163
-
164
- const msg = `Update available: ${chalk.red(status.currentVersion)} → ${chalk.green(status.latestVersion)}`;
165
- const runMsg = `Run ${chalk.cyan('npm install -g @mrpatronz/nexusflow')} to update!`;
166
-
167
- const cleanMsg = `Update available: ${status.currentVersion} → ${status.latestVersion}`;
168
- const cleanRunMsg = `Run npm install -g @mrpatronz/nexusflow to update!`;
169
- const width = Math.max(cleanMsg.length, cleanRunMsg.length) + 2;
170
-
171
- const padMsg = ' '.repeat(width - cleanMsg.length);
172
- const padRunMsg = ' '.repeat(width - cleanRunMsg.length);
173
-
174
- const border = '─'.repeat(width);
175
- console.log();
176
- console.log(chalk.yellow(`┌${border}┐`));
177
- console.log(chalk.yellow(`│ ${msg}${padMsg} │`));
178
- console.log(chalk.yellow(`│ ${runMsg}${padRunMsg} │`));
179
- console.log(chalk.yellow(`└${border}┘`));
180
- console.log();
181
- }
182
-
183
- import { execa } from 'execa';
184
-
185
- export interface ToolUpdateStatus {
186
- id: string;
187
- name: string;
188
- command: string;
189
- installed: boolean;
190
- currentVersion: string;
191
- latestVersion: string;
192
- updateAvailable: boolean;
193
- updateCmd: string;
194
- }
195
-
196
- export async function getToolsStatus(force = false): Promise<ToolUpdateStatus[]> {
197
- const currentVersion = getCurrentVersion();
198
- const tools = [
199
- {
200
- id: 'nexusflow',
201
- name: 'NexusFlow Engine',
202
- command: 'nexusflow',
203
- npmPackage: '@mrpatronz/nexusflow',
204
- updateCmd: 'npm install -g @mrpatronz/nexusflow',
205
- getCurrent: async () => currentVersion,
206
- },
207
-
208
- {
209
- id: 'antigravity',
210
- name: 'Antigravity CLI',
211
- command: 'agy',
212
- npmPackage: '',
213
- updateCmd: 'agy update',
214
- getCurrent: async () => {
215
- try {
216
- const res = await execa('agy', ['--version'], {
217
- reject: false,
218
- shell: process.platform === 'win32',
219
- });
220
- if (res.exitCode === 0) return res.stdout.trim();
221
- } catch {}
222
- return '';
223
- }
224
- },
225
- {
226
- id: 'claude',
227
- name: 'Claude Code CLI',
228
- command: 'claude',
229
- npmPackage: '@anthropic-ai/claude-code',
230
- updateCmd: 'npm install -g @anthropic-ai/claude-code',
231
- getCurrent: async () => {
232
- try {
233
- const res = await execa('claude', ['--version'], {
234
- reject: false,
235
- shell: process.platform === 'win32',
236
- });
237
- if (res.exitCode === 0) return res.stdout.trim();
238
- } catch {}
239
- return '';
240
- }
241
- }
242
- ];
243
-
244
- const results: ToolUpdateStatus[] = [];
245
-
246
- for (const t of tools) {
247
- let installed = false;
248
- let currentVal = '';
249
- let latestVal = '';
250
-
251
- try {
252
- currentVal = await t.getCurrent();
253
- installed = currentVal !== '';
254
- } catch {}
255
-
256
- if (installed && t.npmPackage) {
257
- try {
258
- const response = await fetch(`https://registry.npmjs.org/${t.npmPackage}/latest`, {
259
- signal: AbortSignal.timeout(2000),
260
- });
261
- if (response.ok) {
262
- const data = await response.json() as { version: string };
263
- latestVal = data.version;
264
- }
265
- } catch {}
266
- }
267
-
268
- if (!latestVal) {
269
- latestVal = currentVal || '1.0.0';
270
- }
271
-
272
- results.push({
273
- id: t.id,
274
- name: t.name,
275
- command: t.command,
276
- installed,
277
- currentVersion: currentVal || 'Not Installed',
278
- latestVersion: latestVal,
279
- updateAvailable: installed && isNewerVersion(currentVal, latestVal),
280
- updateCmd: t.updateCmd,
281
- });
282
- }
283
-
284
- return results;
285
- }
286
-
@@ -1,118 +0,0 @@
1
- /**
2
- * @module utils/workflow-advisor
3
- * Dynamically suggests task difficulty and teamwork strategy guidelines.
4
- */
5
-
6
- import { callLocalLlm } from './local-ai.js';
7
- import type { LocalLlmConfig, RepoInfo } from '../types.js';
8
-
9
- export interface WorkflowSuggestion {
10
- difficulty: 'simple' | 'moderate' | 'complex';
11
- rationale: string;
12
- suggestedWorkflowId: 'solo-developer' | 'research-verify' | 'plan-implement-review';
13
- customInstructions: string;
14
- }
15
-
16
- /**
17
- * Analyzes feature description and repositories to recommend strategy guidelines.
18
- */
19
- export async function suggestWorkflow(
20
- description: string,
21
- repos: RepoInfo[],
22
- localLlmConfig?: LocalLlmConfig
23
- ): Promise<WorkflowSuggestion> {
24
- const repoNames = repos.map((r) => r.name);
25
-
26
- const runHeuristic = (): WorkflowSuggestion => {
27
- const descLower = (description || '').toLowerCase();
28
- const isComplexWord = descLower.includes('refactor') ||
29
- descLower.includes('migrate') ||
30
- descLower.includes('architecture') ||
31
- descLower.includes('design') ||
32
- descLower.includes('rewrite') ||
33
- descLower.includes('optimize') ||
34
- descLower.includes('performance') ||
35
- descLower.includes('security') ||
36
- descLower.includes('database') ||
37
- descLower.includes('schema') ||
38
- descLower.includes('break') ||
39
- descLower.includes('major');
40
-
41
- const isSimpleWord = descLower.includes('fix') ||
42
- descLower.includes('bug') ||
43
- descLower.includes('typo') ||
44
- descLower.includes('tweak') ||
45
- descLower.includes('color') ||
46
- descLower.includes('alignment') ||
47
- descLower.includes('comment') ||
48
- descLower.includes('readme') ||
49
- descLower.includes('test') ||
50
- descLower.includes('doc');
51
-
52
- if (repos.length > 2 || isComplexWord) {
53
- return {
54
- difficulty: 'complex',
55
- suggestedWorkflowId: 'plan-implement-review',
56
- rationale: `This task spans multiple repositories or involves architectural components (${repoNames.join(', ')}). A structured Plan-Implement-Review strategy is recommended to coordinate changes carefully.`,
57
- customInstructions: `# Team Strategy: Plan, Implement, Review\n\nThis workspace involves complex changes across multiple projects: ${repoNames.join(', ')}.\n\n## Roles & Coordination\n1. **Lead Planner**: Analyzes requirements and details a step-by-step design plan in \`implementation_plan.md\`.\n2. **Code Implementer**: Executes modifications project-by-project following the approved design.\n3. **Code Reviewer**: Runs testing/verification and approves before completion.\n\nPlease follow these roles strictly.`
58
- };
59
- } else if (repos.length === 1 && isSimpleWord && !isComplexWord) {
60
- return {
61
- difficulty: 'simple',
62
- suggestedWorkflowId: 'solo-developer',
63
- rationale: `This is a localized fix/tweak within a single repository (${repoNames.join(', ')}). A Solo Developer pattern minimizes overhead and speeds up the modification.`,
64
- customInstructions: `# Team Strategy: Solo Developer\n\nThis task is a localized fix in ${repoNames[0] || 'the project'}.\n\n## Guidelines\n- Direct implementation by the main agent.\n- Run tests and compile code immediately.\n- Avoid spawning subagents to reduce overhead.`
65
- };
66
- } else {
67
- return {
68
- difficulty: 'moderate',
69
- suggestedWorkflowId: 'research-verify',
70
- rationale: `This is a feature of moderate scope affecting ${repoNames.join(', ')}. We recommend first researching the codebase and dependencies, followed by targeted implementation.`,
71
- customInstructions: `# Team Strategy: Research & Verify\n\nThis task involves moderate changes in ${repoNames.join(', ')}.\n\n## Guidelines\n1. **Research Phase**: Inspect existing components and API interfaces first.\n2. **Implementation Phase**: Write modular code changes.\n3. **Verification Phase**: Confirm build and runs correctly.`
72
- };
73
- }
74
- };
75
-
76
- if (localLlmConfig?.enabled) {
77
- try {
78
- const prompt = `You are a software architect analyzing a new feature request.
79
- Feature Description: "${description}"
80
- Target Repositories: ${JSON.stringify(repos.map(r => ({ name: r.name, path: r.path })))}
81
-
82
- Determine:
83
- 1. Difficulty: "simple", "moderate", or "complex".
84
- 2. Suggested Workflow Strategy ID: "solo-developer" (for small tweaks), "research-verify" (for moderate features requiring codebase exploration), or "plan-implement-review" (for complex features spanning multiple repositories/refactorings).
85
- 3. A short explanation/rationale.
86
- 4. Custom teamwork cooperation guidelines for AGENTS.md, detailing how the agents should coordinate across the selected repositories.
87
-
88
- Respond ONLY with a JSON object of this structure:
89
- {
90
- "difficulty": "simple" | "moderate" | "complex",
91
- "rationale": "Explanation here",
92
- "suggestedWorkflowId": "solo-developer" | "research-verify" | "plan-implement-review",
93
- "customInstructions": "Markdown format teamwork guidelines for AGENTS.md"
94
- }`;
95
-
96
- const responseText = await callLocalLlm(localLlmConfig, [
97
- { role: 'system', content: 'You are a helpful software architect assistant. Always output valid JSON.' },
98
- { role: 'user', content: prompt }
99
- ]);
100
-
101
- const cleanJson = responseText.replace(/```json/i, '').replace(/```/g, '').trim();
102
- const result = JSON.parse(cleanJson);
103
-
104
- if (result.difficulty && result.suggestedWorkflowId && result.customInstructions) {
105
- return {
106
- difficulty: result.difficulty,
107
- rationale: result.rationale || '',
108
- suggestedWorkflowId: result.suggestedWorkflowId,
109
- customInstructions: result.customInstructions
110
- };
111
- }
112
- } catch (err) {
113
- console.warn('Failed to get LLM workflow suggestion, falling back to heuristics:', err);
114
- }
115
- }
116
-
117
- return runHeuristic();
118
- }
@@ -1,114 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import * as fs from 'node:fs/promises';
3
- import * as os from 'node:os';
4
- import * as path from 'node:path';
5
- import { getWorkflowTemplates, saveWorkflowTemplate, deleteWorkflowTemplate } from './workflows.js';
6
-
7
- vi.mock('node:fs/promises');
8
- vi.mock('node:os', () => ({
9
- homedir: () => '/mock/home'
10
- }));
11
-
12
- describe('Workflows Utility Unit Tests', () => {
13
- beforeEach(() => {
14
- vi.clearAllMocks();
15
- });
16
-
17
- describe('saveWorkflowTemplate', () => {
18
- it('should save a template and extract its name from H1 header', async () => {
19
- vi.spyOn(fs, 'mkdir').mockResolvedValue(undefined);
20
- vi.spyOn(fs, 'writeFile').mockResolvedValue(undefined);
21
-
22
- const result = await saveWorkflowTemplate('My Temp Name', '# Final Strategy Name\n\nStrategy Content');
23
-
24
- expect(fs.mkdir).toHaveBeenCalledWith(path.join('/mock/home', '.nexusflow', 'workflows'), { recursive: true });
25
- expect(fs.writeFile).toHaveBeenCalledWith(
26
- path.join('/mock/home', '.nexusflow', 'workflows', 'final-strategy-name.md'),
27
- '# Final Strategy Name\n\nStrategy Content',
28
- 'utf-8'
29
- );
30
- expect(result).toEqual({
31
- id: 'final-strategy-name',
32
- name: 'Final Strategy Name',
33
- description: 'Strategy Content',
34
- content: '# Final Strategy Name\n\nStrategy Content',
35
- custom: true
36
- });
37
- });
38
-
39
- it('should add H1 header if not present', async () => {
40
- vi.spyOn(fs, 'mkdir').mockResolvedValue(undefined);
41
- vi.spyOn(fs, 'writeFile').mockResolvedValue(undefined);
42
-
43
- const result = await saveWorkflowTemplate('My Temp Name', 'Strategy Content');
44
-
45
- expect(fs.writeFile).toHaveBeenCalledWith(
46
- path.join('/mock/home', '.nexusflow', 'workflows', 'my-temp-name.md'),
47
- '# My Temp Name\n\nStrategy Content',
48
- 'utf-8'
49
- );
50
- expect(result.id).toBe('my-temp-name');
51
- });
52
-
53
- it('should clean up originalId file if template is renamed', async () => {
54
- vi.spyOn(fs, 'mkdir').mockResolvedValue(undefined);
55
- vi.spyOn(fs, 'writeFile').mockResolvedValue(undefined);
56
- vi.spyOn(fs, 'unlink').mockResolvedValue(undefined);
57
-
58
- const result = await saveWorkflowTemplate('New Name', '# New Name\n\nContent', 'old-id');
59
-
60
- expect(fs.unlink).toHaveBeenCalledWith(path.join('/mock/home', '.nexusflow', 'workflows', 'old-id.md'));
61
- expect(result.id).toBe('new-name');
62
- });
63
- });
64
-
65
- describe('deleteWorkflowTemplate', () => {
66
- it('should delete template file', async () => {
67
- vi.spyOn(fs, 'unlink').mockResolvedValue(undefined);
68
-
69
- await deleteWorkflowTemplate('some-id');
70
-
71
- expect(fs.unlink).toHaveBeenCalledWith(path.join('/mock/home', '.nexusflow', 'workflows', 'some-id.md'));
72
- });
73
-
74
- it('should ignore ENOENT error', async () => {
75
- const error = new Error('File not found') as any;
76
- error.code = 'ENOENT';
77
- vi.spyOn(fs, 'unlink').mockRejectedValue(error);
78
-
79
- await expect(deleteWorkflowTemplate('some-id')).resolves.toBeUndefined();
80
- });
81
- });
82
-
83
- describe('getWorkflowTemplates', () => {
84
- it('should load and merge built-in and user templates', async () => {
85
- vi.spyOn(fs, 'mkdir').mockResolvedValue(undefined);
86
- // Mock readdir to return files
87
- vi.spyOn(fs, 'readdir').mockImplementation(async (dirPath) => {
88
- if (dirPath.toString().includes('.nexusflow')) {
89
- return ['custom-one.md'] as any;
90
- }
91
- return ['solo-developer.md'] as any;
92
- });
93
-
94
- // Mock readFile
95
- vi.spyOn(fs, 'readFile').mockImplementation(async (filePath) => {
96
- if (filePath.toString().includes('custom-one.md')) {
97
- return '# Custom One\n\nDescription content.' as any;
98
- }
99
- return '# Solo Developer\n\nOverride content.' as any;
100
- });
101
-
102
- const templates = await getWorkflowTemplates();
103
-
104
- expect(templates.length).toBe(2);
105
- expect(templates.find(t => t.id === 'custom-one')).toEqual({
106
- id: 'custom-one',
107
- name: 'Custom One',
108
- description: 'Description content.',
109
- content: '# Custom One\n\nDescription content.',
110
- custom: true
111
- });
112
- });
113
- });
114
- });
@@ -1,178 +0,0 @@
1
- import * as fs from 'node:fs/promises';
2
- import * as path from 'node:path';
3
- import * as os from 'node:os';
4
- import { fileURLToPath } from 'node:url';
5
-
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
8
-
9
- export interface WorkflowTemplate {
10
- id: string;
11
- name: string;
12
- description: string;
13
- content: string;
14
- custom: boolean;
15
- }
16
-
17
- function parseMarkdownTemplate(id: string, content: string): Omit<WorkflowTemplate, 'id' | 'custom'> {
18
- const lines = content.split('\n');
19
- let name = id.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
20
- let description = '';
21
-
22
- // Extract name from the first H1 header (# Name)
23
- for (const line of lines) {
24
- if (line.startsWith('# ')) {
25
- name = line.substring(2).trim();
26
- break;
27
- }
28
- }
29
-
30
- // Extract description from the first non-empty text paragraph below the H1 header
31
- let foundHeader = false;
32
- for (const line of lines) {
33
- const trimmed = line.trim();
34
- if (trimmed.startsWith('# ')) {
35
- foundHeader = true;
36
- continue;
37
- }
38
- if (foundHeader && trimmed.length > 0 && !trimmed.startsWith('#') && !trimmed.startsWith('>')) {
39
- description = trimmed;
40
- // Truncate to first sentence or 120 chars
41
- const sentenceEnd = description.indexOf('.');
42
- if (sentenceEnd !== -1) {
43
- description = description.substring(0, sentenceEnd + 1);
44
- }
45
- if (description.length > 120) {
46
- description = description.substring(0, 117) + '...';
47
- }
48
- break;
49
- }
50
- }
51
-
52
- // Fallbacks for built-in templates if none extracted
53
- if (!description) {
54
- if (id === 'plan-implement-review') {
55
- description = 'Lead planner designs, Code Implementer subagent writes edits, and Code Reviewer subagent tests & reviews in a loop.';
56
- } else if (id === 'research-verify') {
57
- description = 'Research specialist subagent analyzes codebase, followed by test-driven developer subagent implementation.';
58
- } else if (id === 'solo-developer') {
59
- description = 'Direct coding and verification by the primary agent without subagent delegation overhead.';
60
- } else {
61
- description = 'Custom user-defined teamwork strategy.';
62
- }
63
- }
64
-
65
- return { name, description, content };
66
- }
67
-
68
- async function loadTemplatesFromDir(dirPath: string, custom: boolean): Promise<WorkflowTemplate[]> {
69
- const templates: WorkflowTemplate[] = [];
70
- try {
71
- const files = await fs.readdir(dirPath);
72
- for (const file of files) {
73
- if (!file.endsWith('.md')) continue;
74
- const id = path.basename(file, '.md');
75
- const content = await fs.readFile(path.join(dirPath, file), 'utf-8');
76
- const parsed = parseMarkdownTemplate(id, content);
77
- templates.push({
78
- id,
79
- custom,
80
- ...parsed,
81
- });
82
- }
83
- } catch (error) {
84
- // Only log if directory exists (ignoring non-existent custom folder log spam)
85
- if ((error as any).code !== 'ENOENT') {
86
- console.error(`Failed to read templates from ${dirPath}:`, error);
87
- }
88
- }
89
- return templates;
90
- }
91
-
92
- export async function getWorkflowTemplates(): Promise<WorkflowTemplate[]> {
93
- const builtInDir = path.resolve(__dirname, '../resources/workflows');
94
- const userDir = path.join(os.homedir(), '.nexusflow', 'workflows');
95
-
96
- // Ensure user custom workflows directory exists so they can find it easily
97
- try {
98
- await fs.mkdir(userDir, { recursive: true });
99
- } catch {}
100
-
101
- const [builtInTemplates, userTemplates] = await Promise.all([
102
- loadTemplatesFromDir(builtInDir, false),
103
- loadTemplatesFromDir(userDir, true)
104
- ]);
105
-
106
- // Merge templates (user custom templates override built-in if they share the same ID)
107
- const templateMap = new Map<string, WorkflowTemplate>();
108
-
109
- for (const t of builtInTemplates) {
110
- templateMap.set(t.id, t);
111
- }
112
- for (const t of userTemplates) {
113
- templateMap.set(t.id, t);
114
- }
115
-
116
- return Array.from(templateMap.values());
117
- }
118
-
119
- export async function saveWorkflowTemplate(name: string, content: string, originalId?: string): Promise<WorkflowTemplate> {
120
- const userDir = path.join(os.homedir(), '.nexusflow', 'workflows');
121
- await fs.mkdir(userDir, { recursive: true });
122
-
123
- // Extract name from the first H1 header (# Name) in content if present
124
- let parsedName = name;
125
- const lines = content.split('\n');
126
- for (const line of lines) {
127
- if (line.trim().startsWith('# ')) {
128
- parsedName = line.trim().substring(2).trim();
129
- break;
130
- }
131
- }
132
-
133
- const id = parsedName
134
- .toLowerCase()
135
- .replace(/[^a-z0-9]+/g, '-')
136
- .replace(/(^-|-$)/g, '');
137
-
138
- if (!id) {
139
- throw new Error('Invalid template name');
140
- }
141
-
142
- // Ensure content starts with "# <Name>" header so it parses correctly next time
143
- let fileContent = content.trim();
144
- if (!fileContent.startsWith('# ')) {
145
- fileContent = `# ${parsedName}\n\n${fileContent}`;
146
- }
147
-
148
- const filePath = path.join(userDir, `${id}.md`);
149
- await fs.writeFile(filePath, fileContent, 'utf-8');
150
-
151
- // If we are editing an existing custom template and the ID changed, delete the old file
152
- if (originalId && originalId !== id) {
153
- const oldPath = path.join(userDir, `${originalId}.md`);
154
- try {
155
- await fs.unlink(oldPath);
156
- } catch {}
157
- }
158
-
159
- const parsed = parseMarkdownTemplate(id, fileContent);
160
- return {
161
- id,
162
- custom: true,
163
- ...parsed,
164
- };
165
- }
166
-
167
- export async function deleteWorkflowTemplate(id: string): Promise<void> {
168
- const userDir = path.join(os.homedir(), '.nexusflow', 'workflows');
169
- const filePath = path.join(userDir, `${id}.md`);
170
-
171
- try {
172
- await fs.unlink(filePath);
173
- } catch (error) {
174
- if ((error as any).code !== 'ENOENT') {
175
- throw error;
176
- }
177
- }
178
- }