@mrpatronz/nexusflow 0.2.13 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/.agents/skills/ccc/SKILL.md +71 -0
  2. package/.agents/skills/ccc/references/management.md +110 -0
  3. package/.agents/skills/ccc/references/settings.md +126 -0
  4. package/.github/workflows/ci.yml +44 -0
  5. package/.github/workflows/dependabot-merge.yml +53 -0
  6. package/.github/workflows/release-desktop.yml +67 -0
  7. package/.github/workflows/release-npm.yml +65 -0
  8. package/.github/workflows/release-vscode.yml +61 -0
  9. package/GETTING_STARTED.md +5 -0
  10. package/README.md +53 -0
  11. package/desktop/build-installer.js +228 -0
  12. package/desktop/build.js +118 -0
  13. package/desktop/installer/nexusflow.iss +35 -0
  14. package/desktop/neutralino.config.json +39 -0
  15. package/desktop/package-lock.json +1060 -0
  16. package/desktop/package.json +14 -0
  17. package/dist/commands/adapter.d.ts +27 -0
  18. package/dist/commands/adapter.d.ts.map +1 -0
  19. package/dist/commands/adapter.js +318 -0
  20. package/dist/commands/adapter.js.map +1 -0
  21. package/dist/commands/add-repo.d.ts.map +1 -1
  22. package/dist/commands/add-repo.js +0 -1
  23. package/dist/commands/add-repo.js.map +1 -1
  24. package/dist/commands/commands.test.js +2 -2
  25. package/dist/commands/commands.test.js.map +1 -1
  26. package/dist/commands/config.d.ts +22 -0
  27. package/dist/commands/config.d.ts.map +1 -0
  28. package/dist/commands/config.js +50 -0
  29. package/dist/commands/config.js.map +1 -0
  30. package/dist/commands/create.d.ts.map +1 -1
  31. package/dist/commands/create.js +14 -17
  32. package/dist/commands/create.js.map +1 -1
  33. package/dist/commands/desktop.d.ts +12 -0
  34. package/dist/commands/desktop.d.ts.map +1 -0
  35. package/dist/commands/desktop.js +119 -0
  36. package/dist/commands/desktop.js.map +1 -0
  37. package/dist/commands/doctor.d.ts.map +1 -1
  38. package/dist/commands/doctor.js +11 -0
  39. package/dist/commands/doctor.js.map +1 -1
  40. package/dist/commands/refresh.d.ts +1 -0
  41. package/dist/commands/refresh.d.ts.map +1 -1
  42. package/dist/commands/refresh.js +2 -14
  43. package/dist/commands/refresh.js.map +1 -1
  44. package/dist/commands/sync.d.ts.map +1 -1
  45. package/dist/commands/sync.js +1 -8
  46. package/dist/commands/sync.js.map +1 -1
  47. package/dist/commands/tui.d.ts +8 -0
  48. package/dist/commands/tui.d.ts.map +1 -0
  49. package/dist/commands/tui.js +439 -0
  50. package/dist/commands/tui.js.map +1 -0
  51. package/dist/commands/ui.d.ts +3 -1
  52. package/dist/commands/ui.d.ts.map +1 -1
  53. package/dist/commands/ui.js +76 -19
  54. package/dist/commands/ui.js.map +1 -1
  55. package/dist/core/adapters/local-storage.d.ts +14 -0
  56. package/dist/core/adapters/local-storage.d.ts.map +1 -0
  57. package/dist/core/adapters/local-storage.js +58 -0
  58. package/dist/core/adapters/local-storage.js.map +1 -0
  59. package/dist/core/adapters/obsidian-storage.d.ts +28 -0
  60. package/dist/core/adapters/obsidian-storage.d.ts.map +1 -0
  61. package/dist/core/adapters/obsidian-storage.js +135 -0
  62. package/dist/core/adapters/obsidian-storage.js.map +1 -0
  63. package/dist/core/adapters/registry.d.ts +8 -0
  64. package/dist/core/adapters/registry.d.ts.map +1 -0
  65. package/dist/core/adapters/registry.js +37 -0
  66. package/dist/core/adapters/registry.js.map +1 -0
  67. package/dist/core/adapters/storage.test.d.ts +2 -0
  68. package/dist/core/adapters/storage.test.d.ts.map +1 -0
  69. package/dist/core/adapters/storage.test.js +106 -0
  70. package/dist/core/adapters/storage.test.js.map +1 -0
  71. package/dist/core/adapters/vault-storage.d.ts +16 -0
  72. package/dist/core/adapters/vault-storage.d.ts.map +1 -0
  73. package/dist/core/adapters/vault-storage.js +77 -0
  74. package/dist/core/adapters/vault-storage.js.map +1 -0
  75. package/dist/core/config.d.ts.map +1 -1
  76. package/dist/core/config.js +28 -4
  77. package/dist/core/config.js.map +1 -1
  78. package/dist/core/plugins/index.d.ts +14 -0
  79. package/dist/core/plugins/index.d.ts.map +1 -0
  80. package/dist/core/plugins/index.js +2 -0
  81. package/dist/core/plugins/index.js.map +1 -0
  82. package/dist/core/plugins/loader.d.ts +2 -0
  83. package/dist/core/plugins/loader.d.ts.map +1 -0
  84. package/dist/core/plugins/loader.js +34 -0
  85. package/dist/core/plugins/loader.js.map +1 -0
  86. package/dist/core/ports/storage.d.ts +59 -0
  87. package/dist/core/ports/storage.d.ts.map +1 -0
  88. package/dist/core/ports/storage.js +10 -0
  89. package/dist/core/ports/storage.js.map +1 -0
  90. package/dist/core/storage.d.ts +10 -0
  91. package/dist/core/storage.d.ts.map +1 -0
  92. package/dist/core/storage.js +29 -0
  93. package/dist/core/storage.js.map +1 -0
  94. package/dist/core/workspace.d.ts.map +1 -1
  95. package/dist/core/workspace.js +110 -16
  96. package/dist/core/workspace.js.map +1 -1
  97. package/dist/generators/base.d.ts.map +1 -1
  98. package/dist/generators/base.js +19 -6
  99. package/dist/generators/base.js.map +1 -1
  100. package/dist/generators/diff-context.d.ts +6 -0
  101. package/dist/generators/diff-context.d.ts.map +1 -0
  102. package/dist/generators/diff-context.js +68 -0
  103. package/dist/generators/diff-context.js.map +1 -0
  104. package/dist/generators/index.d.ts +1 -1
  105. package/dist/generators/index.d.ts.map +1 -1
  106. package/dist/generators/index.js +75 -18
  107. package/dist/generators/index.js.map +1 -1
  108. package/dist/generators/map-generator.d.ts.map +1 -1
  109. package/dist/generators/map-generator.js +7 -11
  110. package/dist/generators/map-generator.js.map +1 -1
  111. package/dist/generators/plan-generator.d.ts.map +1 -1
  112. package/dist/generators/plan-generator.js +3 -5
  113. package/dist/generators/plan-generator.js.map +1 -1
  114. package/dist/gui/app_logo.png +0 -0
  115. package/dist/gui/assets/index-CB-jWded.css +1 -0
  116. package/dist/gui/assets/index-DDXpZZu3.js +25 -0
  117. package/dist/gui/index.html +2 -2
  118. package/dist/index.js +174 -20
  119. package/dist/index.js.map +1 -1
  120. package/dist/server.d.ts.map +1 -1
  121. package/dist/server.js +212 -28
  122. package/dist/server.js.map +1 -1
  123. package/dist/server.test.js +173 -38
  124. package/dist/server.test.js.map +1 -1
  125. package/dist/types.d.ts +11 -2
  126. package/dist/types.d.ts.map +1 -1
  127. package/dist/utils/git.d.ts +16 -0
  128. package/dist/utils/git.d.ts.map +1 -1
  129. package/dist/utils/git.js +52 -0
  130. package/dist/utils/git.js.map +1 -1
  131. package/dist/utils/local-ai.d.ts.map +1 -1
  132. package/dist/utils/local-ai.js +7 -3
  133. package/dist/utils/local-ai.js.map +1 -1
  134. package/dist/utils/multi-git.d.ts +2 -0
  135. package/dist/utils/multi-git.d.ts.map +1 -1
  136. package/dist/utils/multi-git.js +5 -2
  137. package/dist/utils/multi-git.js.map +1 -1
  138. package/dist/utils/update-check.d.ts +3 -1
  139. package/dist/utils/update-check.d.ts.map +1 -1
  140. package/dist/utils/update-check.js +23 -34
  141. package/dist/utils/update-check.js.map +1 -1
  142. package/dist/utils/workflow-advisor.d.ts +16 -0
  143. package/dist/utils/workflow-advisor.d.ts.map +1 -0
  144. package/dist/utils/workflow-advisor.js +100 -0
  145. package/dist/utils/workflow-advisor.js.map +1 -0
  146. package/dist/utils/workflows.d.ts +11 -0
  147. package/dist/utils/workflows.d.ts.map +1 -0
  148. package/dist/utils/workflows.js +156 -0
  149. package/dist/utils/workflows.js.map +1 -0
  150. package/dist/utils/workflows.test.d.ts +2 -0
  151. package/dist/utils/workflows.test.d.ts.map +1 -0
  152. package/dist/utils/workflows.test.js +86 -0
  153. package/dist/utils/workflows.test.js.map +1 -0
  154. package/extension/media/icon.svg +1 -0
  155. package/extension/package-lock.json +4893 -1660
  156. package/extension/package.json +58 -11
  157. package/extension/src/extension.ts +476 -27
  158. package/extension/tsconfig.json +4 -2
  159. package/gui/e2e/wizard.spec.ts +19 -0
  160. package/gui/package-lock.json +342 -381
  161. package/gui/package.json +12 -12
  162. package/gui/public/app_logo.png +0 -0
  163. package/gui/src/App.tsx +991 -81
  164. package/gui/src/features/workspace/WorkspaceList.tsx +30 -30
  165. package/gui/src/index.css +64 -22
  166. package/gui/src/main.tsx +89 -5
  167. package/package.json +11 -12
  168. package/resources/workflows/plan-implement-review.md +8 -0
  169. package/resources/workflows/research-verify.md +6 -0
  170. package/resources/workflows/solo-developer.md +3 -0
  171. package/skills-lock.json +11 -0
  172. package/src/commands/adapter.ts +348 -0
  173. package/src/commands/add-repo.ts +0 -1
  174. package/src/commands/commands.test.ts +3 -2
  175. package/src/commands/config.ts +52 -0
  176. package/src/commands/create.ts +14 -17
  177. package/src/commands/desktop.ts +128 -0
  178. package/src/commands/doctor.ts +13 -0
  179. package/src/commands/mcp.ts +2 -0
  180. package/src/commands/refresh.ts +4 -14
  181. package/src/commands/sync.ts +2 -8
  182. package/src/commands/tui.ts +484 -0
  183. package/src/commands/ui.ts +83 -19
  184. package/src/core/adapters/local-storage.ts +66 -0
  185. package/src/core/adapters/obsidian-storage.ts +151 -0
  186. package/src/core/adapters/registry.ts +44 -0
  187. package/src/core/adapters/storage.test.ts +174 -0
  188. package/src/core/adapters/vault-storage.ts +86 -0
  189. package/src/core/config.ts +29 -4
  190. package/src/core/plugins/index.ts +17 -0
  191. package/src/core/plugins/loader.ts +36 -0
  192. package/src/core/ports/storage.ts +71 -0
  193. package/src/core/storage.ts +37 -0
  194. package/src/core/workspace.ts +122 -15
  195. package/src/generators/base.ts +21 -5
  196. package/src/generators/diff-context.ts +75 -0
  197. package/src/generators/index.ts +93 -21
  198. package/src/generators/map-generator.ts +7 -10
  199. package/src/generators/plan-generator.ts +6 -4
  200. package/src/index.ts +178 -21
  201. package/src/server.test.ts +193 -39
  202. package/src/server.ts +238 -28
  203. package/src/types.ts +14 -2
  204. package/src/utils/git.ts +56 -0
  205. package/src/utils/local-ai.ts +8 -3
  206. package/src/utils/multi-git.ts +16 -9
  207. package/src/utils/update-check.ts +42 -31
  208. package/src/utils/workflow-advisor.ts +118 -0
  209. package/src/utils/workflows.test.ts +114 -0
  210. package/src/utils/workflows.ts +178 -0
  211. package/.github/workflows/release.yml +0 -100
  212. package/dist/commands/pack.d.ts +0 -7
  213. package/dist/commands/pack.d.ts.map +0 -1
  214. package/dist/commands/pack.js +0 -64
  215. package/dist/commands/pack.js.map +0 -1
  216. package/dist/core/packer.d.ts +0 -14
  217. package/dist/core/packer.d.ts.map +0 -1
  218. package/dist/core/packer.js +0 -87
  219. package/dist/core/packer.js.map +0 -1
  220. package/dist/core/packer.test.d.ts +0 -2
  221. package/dist/core/packer.test.d.ts.map +0 -1
  222. package/dist/core/packer.test.js +0 -82
  223. package/dist/core/packer.test.js.map +0 -1
  224. package/dist/gui/assets/index-CFWwqFux.js +0 -23
  225. package/dist/gui/assets/index-Dvc9QMvl.css +0 -2
  226. package/src/commands/pack.ts +0 -73
  227. package/src/core/packer.test.ts +0 -99
  228. package/src/core/packer.ts +0 -107
@@ -0,0 +1,118 @@
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
+ }
@@ -0,0 +1,114 @@
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
+ });
@@ -0,0 +1,178 @@
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
+ }
@@ -1,100 +0,0 @@
1
- name: Release & Publish
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- branches: [main]
8
-
9
- permissions:
10
- contents: write
11
-
12
- jobs:
13
- build-and-test:
14
- runs-on: ubuntu-latest
15
- steps:
16
- - name: Checkout Repository
17
- uses: actions/checkout@v4
18
-
19
- - name: Setup Node.js
20
- uses: actions/setup-node@v4
21
- with:
22
- node-version: 20
23
-
24
- - name: Install Dependencies
25
- run: npm ci
26
-
27
- - name: Install GUI Dependencies
28
- run: npm ci --prefix gui
29
-
30
- - name: Install Extension Dependencies
31
- run: npm ci --prefix extension
32
-
33
- - name: Build Project
34
- run: npm run build
35
-
36
- - name: Run Tests
37
- run: npm test
38
-
39
- - name: Install Playwright Browsers
40
- run: npx playwright install chromium --with-deps
41
- working-directory: gui
42
-
43
- - name: Run GUI E2E Tests
44
- run: npm run test:gui
45
-
46
- publish:
47
- needs: build-and-test
48
- runs-on: ubuntu-latest
49
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
50
- steps:
51
- - name: Checkout Repository
52
- uses: actions/checkout@v4
53
-
54
- - name: Setup Node.js
55
- uses: actions/setup-node@v4
56
- with:
57
- node-version: 20
58
- registry-url: 'https://registry.npmjs.org/'
59
-
60
- - name: Install Dependencies
61
- run: npm ci
62
-
63
- - name: Install GUI Dependencies
64
- run: npm ci --prefix gui
65
-
66
- - name: Install Extension Dependencies
67
- run: npm ci --prefix extension
68
-
69
- - name: Build Project
70
- run: npm run build
71
-
72
- - name: Check version and NPM
73
- id: check-version
74
- run: |
75
- CURRENT_VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('./package.json', 'utf8')).version)")
76
- echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
77
- if npm info @mrpatronz/nexusflow@$CURRENT_VERSION --json >/dev/null 2>&1; then
78
- echo "is_new=false" >> $GITHUB_OUTPUT
79
- echo "Version $CURRENT_VERSION is already published on NPM. Skipping publish."
80
- else
81
- echo "is_new=true" >> $GITHUB_OUTPUT
82
- echo "Version $CURRENT_VERSION is new."
83
- fi
84
- env:
85
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
86
-
87
- - name: Publish to NPM
88
- if: steps.check-version.outputs.is_new == 'true'
89
- run: npm publish --access public
90
- env:
91
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
92
-
93
- - name: Create GitHub Release
94
- if: steps.check-version.outputs.is_new == 'true'
95
- uses: softprops/action-gh-release@v2
96
- with:
97
- tag_name: v${{ steps.check-version.outputs.version }}
98
- name: Release v${{ steps.check-version.outputs.version }}
99
- generate_release_notes: true
100
- target_commitish: ${{ github.sha }}
@@ -1,7 +0,0 @@
1
- /**
2
- * Packs the workspace codebase into a single token-efficient XML file.
3
- */
4
- export declare function packCommand(workspaceArg?: string, options?: {
5
- compress?: boolean;
6
- }): Promise<void>;
7
- //# sourceMappingURL=pack.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/commands/pack.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAsB,WAAW,CAC/B,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GACnC,OAAO,CAAC,IAAI,CAAC,CAmBf"}
@@ -1,64 +0,0 @@
1
- import chalk from 'chalk';
2
- import ora from 'ora';
3
- import * as path from 'node:path';
4
- import * as fs from 'node:fs/promises';
5
- import { select } from '@inquirer/prompts';
6
- import { loadConfig } from '../core/config.js';
7
- import { listWorkspaces, loadFeatureConfig } from '../core/workspace.js';
8
- import { packWorkspace } from '../core/packer.js';
9
- /**
10
- * Packs the workspace codebase into a single token-efficient XML file.
11
- */
12
- export async function packCommand(workspaceArg, options = {}) {
13
- console.log(chalk.bold.cyan('\nšŸ“¦ NexusFlow — Codebase Context Packing\n'));
14
- const workspacePath = await resolveWorkspace(workspaceArg);
15
- if (!workspacePath)
16
- return;
17
- const spinner = ora('Packing workspace repositories using Repomix...').start();
18
- try {
19
- const result = await packWorkspace(workspacePath, { compress: options.compress });
20
- spinner.succeed('Workspace packed successfully!');
21
- console.log(`\nšŸ“„ ${chalk.bold('Packed Output File:')} ${chalk.green(result.outputPath)}`);
22
- console.log(`šŸ“Š ${chalk.bold('Total Files:')} ${result.totalFiles}`);
23
- console.log(`šŸ”  ${chalk.bold('Total Characters:')} ${result.totalCharacters}`);
24
- console.log(`šŸ’¾ ${chalk.bold('File Size:')} ${(result.fileSize / 1024).toFixed(2)} KB\n`);
25
- }
26
- catch (error) {
27
- spinner.fail('Failed to pack workspace');
28
- console.error(chalk.red(` Error: ${error.message}`));
29
- }
30
- }
31
- /**
32
- * Resolves the workspace path from argument, cwd, or list.
33
- */
34
- async function resolveWorkspace(workspaceArg) {
35
- if (workspaceArg) {
36
- const absolutePath = path.resolve(workspaceArg);
37
- try {
38
- await fs.access(path.join(absolutePath, 'nexusflow.json'));
39
- return absolutePath;
40
- }
41
- catch {
42
- console.error(chalk.red(`āœ– Invalid workspace: No nexusflow.json found at ${absolutePath}`));
43
- return null;
44
- }
45
- }
46
- const cwdFeature = await loadFeatureConfig(process.cwd());
47
- if (cwdFeature)
48
- return cwdFeature.workspacePath;
49
- const config = await loadConfig();
50
- const workspaces = await listWorkspaces(config.workspacesDir);
51
- if (workspaces.length === 0) {
52
- console.log(chalk.yellow('No workspaces found.\n'));
53
- return null;
54
- }
55
- const selected = await select({
56
- message: 'Select a workspace to pack:',
57
- choices: workspaces.map((ws) => ({
58
- name: `${ws.branchName} ${chalk.dim(`(${ws.repos.length} repos)`)}`,
59
- value: ws.workspacePath,
60
- })),
61
- });
62
- return selected;
63
- }
64
- //# sourceMappingURL=pack.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pack.js","sourceRoot":"","sources":["../../src/commands/pack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,kBAAkB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O,EAAE,6BAA6B;QACtC,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC/B,IAAI,EAAE,GAAG,EAAE,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,SAAS,CAAC,EAAE;YACnE,KAAK,EAAE,EAAE,CAAC,aAAa;SACxB,CAAC,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,14 +0,0 @@
1
- export interface PackResult {
2
- outputPath: string;
3
- outputPaths?: string[];
4
- totalFiles: number;
5
- totalCharacters: number;
6
- fileSize: number;
7
- }
8
- /**
9
- * Packs all repositories in a workspace into individual XML files using Repomix.
10
- */
11
- export declare function packWorkspace(workspacePath: string, options?: {
12
- compress?: boolean;
13
- }): Promise<PackResult>;
14
- //# sourceMappingURL=packer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packer.d.ts","sourceRoot":"","sources":["../../src/core/packer.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GACnC,OAAO,CAAC,UAAU,CAAC,CAsFrB"}