@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,151 +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 type { StoragePort, StorageAdapterMeta } from '../ports/storage.js';
5
-
6
- /**
7
- * Obsidian-native storage adapter.
8
- *
9
- * Writes markdown files to a configurable Obsidian vault path with optional
10
- * YAML frontmatter (tags, dates, type). Uses the same two-layer structure
11
- * as CentralVaultAdapter (_base/<repo>/ + <workspace>/).
12
- */
13
- export class ObsidianStorageAdapter implements StoragePort {
14
- readonly meta: StorageAdapterMeta = {
15
- name: 'obsidian',
16
- displayName: 'Obsidian Vault',
17
- description: 'Store context in an Obsidian vault with YAML frontmatter and wikilinks.',
18
- configFields: [
19
- {
20
- key: 'vaultPath',
21
- label: 'Obsidian Vault Path',
22
- type: 'path',
23
- required: true,
24
- description: 'Absolute path to your Obsidian vault folder (e.g. ~/Obsidian/Dev)',
25
- },
26
- {
27
- key: 'addFrontmatter',
28
- label: 'Add YAML Frontmatter',
29
- type: 'boolean',
30
- default: true,
31
- description: 'Add tags, created date, and type metadata to each file',
32
- },
33
- ],
34
- };
35
-
36
- private vaultPath: string = '';
37
- private addFrontmatter: boolean = true;
38
-
39
- constructor() {
40
- try {
41
- const home = os.homedir();
42
- if (home) {
43
- this.vaultPath = path.join(home, 'Obsidian', 'NexusFlow');
44
- }
45
- } catch {}
46
- }
47
-
48
- configure(settings: Record<string, unknown>): void {
49
- if (settings.vaultPath && typeof settings.vaultPath === 'string') {
50
- this.vaultPath = settings.vaultPath.startsWith('~')
51
- ? path.join(os.homedir(), settings.vaultPath.slice(1))
52
- : settings.vaultPath;
53
- }
54
- if (typeof settings.addFrontmatter === 'boolean') {
55
- this.addFrontmatter = settings.addFrontmatter;
56
- }
57
- }
58
-
59
- // ── Frontmatter helpers ──────────────────────────────────
60
-
61
- private wrapWithFrontmatter(content: string, tags: string[], type: string): string {
62
- if (!this.addFrontmatter) return content;
63
-
64
- const now = new Date().toISOString();
65
- const fm = [
66
- '---',
67
- `tags: [${tags.map(t => `"${t}"`).join(', ')}]`,
68
- `type: ${type}`,
69
- `created: ${now}`,
70
- `modified: ${now}`,
71
- `generator: nexusflow`,
72
- '---',
73
- '',
74
- ].join('\n');
75
-
76
- // Strip existing frontmatter if present
77
- const stripped = content.replace(/^---\n[\s\S]*?\n---\n*/, '');
78
- return fm + stripped;
79
- }
80
-
81
- // ── Workspace (feature) layer ────────────────────────────
82
-
83
- private getFeaturePath(featureId: string): string {
84
- return path.join(this.vaultPath, 'nexusflow', 'workspaces', featureId);
85
- }
86
-
87
- async writeWorkspaceFile(workspacePath: string, featureId: string, filename: string, content: string): Promise<void> {
88
- const dir = this.getFeaturePath(featureId);
89
- const filePath = path.join(dir, filename);
90
- await fs.mkdir(path.dirname(filePath), { recursive: true });
91
- const wrapped = this.wrapWithFrontmatter(content, [featureId, 'workspace'], 'workspace-context');
92
- await fs.writeFile(filePath, wrapped, 'utf8');
93
- }
94
-
95
- async readWorkspaceFile(workspacePath: string, featureId: string, filename: string): Promise<string> {
96
- const dir = this.getFeaturePath(featureId);
97
- return await fs.readFile(path.join(dir, filename), 'utf8');
98
- }
99
-
100
- async workspaceFileExists(workspacePath: string, featureId: string, filename: string): Promise<boolean> {
101
- try {
102
- await fs.access(path.join(this.getFeaturePath(featureId), filename));
103
- return true;
104
- } catch {
105
- return false;
106
- }
107
- }
108
-
109
- resolveWorkspaceFileUrl(workspacePath: string, featureId: string, filename: string): string {
110
- return path.join(this.getFeaturePath(featureId), filename).replace(/\\/g, '/');
111
- }
112
-
113
- // ── Base (repo) layer ────────────────────────────────────
114
-
115
- private getBasePath(repoName: string): string {
116
- return path.join(this.vaultPath, 'nexusflow', '_base', repoName);
117
- }
118
-
119
- async writeBaseFile(workspacePath: string, repoName: string, filename: string, content: string): Promise<void> {
120
- const dir = this.getBasePath(repoName);
121
- const filePath = path.join(dir, filename);
122
- await fs.mkdir(path.dirname(filePath), { recursive: true });
123
- const wrapped = this.wrapWithFrontmatter(content, [repoName, 'base'], 'base-knowledge');
124
- await fs.writeFile(filePath, wrapped, 'utf8');
125
- }
126
-
127
- async readBaseFile(workspacePath: string, repoName: string, filename: string): Promise<string> {
128
- const dir = this.getBasePath(repoName);
129
- return await fs.readFile(path.join(dir, filename), 'utf8');
130
- }
131
-
132
- async baseFileExists(workspacePath: string, repoName: string, filename: string): Promise<boolean> {
133
- try {
134
- await fs.access(path.join(this.getBasePath(repoName), filename));
135
- return true;
136
- } catch {
137
- return false;
138
- }
139
- }
140
-
141
- resolveBaseFileUrl(workspacePath: string, repoName: string, filename: string): string {
142
- return path.join(this.getBasePath(repoName), filename).replace(/\\/g, '/');
143
- }
144
-
145
- async deleteWorkspace(workspacePath: string, featureId: string): Promise<void> {
146
- const dir = this.getFeaturePath(featureId);
147
- try {
148
- await fs.rm(dir, { recursive: true, force: true });
149
- } catch {}
150
- }
151
- }
@@ -1,44 +0,0 @@
1
- import type { StoragePort, StorageAdapterMeta } from '../ports/storage.js';
2
- import { LocalStorageAdapter } from './local-storage.js';
3
- import { CentralVaultAdapter } from './vault-storage.js';
4
- import { ObsidianStorageAdapter } from './obsidian-storage.js';
5
-
6
- const storageProviders = new Map<string, StoragePort>();
7
- let activeProvider: StoragePort | null = null;
8
-
9
- export function registerStorageProvider(name: string, provider: StoragePort) {
10
- storageProviders.set(name, provider);
11
- }
12
-
13
- // Auto-register built-in adapters
14
- registerStorageProvider('local', new LocalStorageAdapter());
15
- registerStorageProvider('central-vault', new CentralVaultAdapter());
16
- registerStorageProvider('obsidian', new ObsidianStorageAdapter());
17
-
18
- /** Returns metadata for all registered storage providers. */
19
- export function listStorageProviders(): StorageAdapterMeta[] {
20
- return Array.from(storageProviders.values()).map(p => p.meta);
21
- }
22
-
23
- export function getStorageProvider(name: string): StoragePort {
24
- const provider = storageProviders.get(name);
25
- if (!provider) {
26
- throw new Error(`Storage provider "${name}" is not registered.`);
27
- }
28
- return provider;
29
- }
30
-
31
- export function setActiveStorageProvider(provider: StoragePort) {
32
- activeProvider = provider;
33
- }
34
-
35
- export function getActiveStorageProvider(): StoragePort {
36
- if (!activeProvider) {
37
- const local = storageProviders.get('local');
38
- if (!local) {
39
- throw new Error('No storage providers registered.');
40
- }
41
- return local;
42
- }
43
- return activeProvider;
44
- }
@@ -1,174 +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
-
6
- import { LocalStorageAdapter } from './local-storage.js';
7
- import { CentralVaultAdapter } from './vault-storage.js';
8
- import { ObsidianStorageAdapter } from './obsidian-storage.js';
9
-
10
- vi.mock('node:fs/promises');
11
- vi.mock('node:os', async () => {
12
- const actual = await vi.importActual<typeof import('node:os')>('node:os');
13
- return {
14
- ...actual,
15
- homedir: vi.fn().mockReturnValue('/mock/home'),
16
- };
17
- });
18
-
19
- describe('Storage Adapters', () => {
20
- beforeEach(() => {
21
- vi.clearAllMocks();
22
- vi.mocked(os.homedir).mockReturnValue('/mock/home');
23
- });
24
-
25
- describe('LocalStorageAdapter', () => {
26
- const adapter = new LocalStorageAdapter();
27
-
28
- it('should declare correct meta', () => {
29
- expect(adapter.meta.name).toBe('local');
30
- expect(adapter.meta.configFields.length).toBe(0);
31
- });
32
-
33
- it('should write workspace files directly to the workspace path', async () => {
34
- vi.mocked(fs.mkdir).mockResolvedValue(undefined);
35
- vi.mocked(fs.writeFile).mockResolvedValue(undefined);
36
-
37
- await adapter.writeWorkspaceFile('/ws/path', 'feature-1', 'test.txt', 'hello');
38
-
39
- expect(fs.mkdir).toHaveBeenCalledWith(expect.stringContaining(path.normalize('/ws/path')), { recursive: true });
40
- expect(fs.writeFile).toHaveBeenCalledWith(
41
- path.normalize('/ws/path/test.txt'),
42
- 'hello',
43
- 'utf8'
44
- );
45
- });
46
-
47
- it('should resolve local workspace paths', () => {
48
- const resolved = adapter.resolveWorkspaceFileUrl('/ws/path', 'feature-1', 'test.txt');
49
- expect(resolved).toContain('/ws/path/test.txt');
50
- });
51
-
52
- it('should delete workspace as NOP', async () => {
53
- await adapter.deleteWorkspace('/ws/path', 'feature-1');
54
- expect(fs.rm).not.toHaveBeenCalled();
55
- });
56
- });
57
-
58
- describe('CentralVaultAdapter', () => {
59
- const adapter = new CentralVaultAdapter();
60
-
61
- it('should declare correct meta', () => {
62
- expect(adapter.meta.name).toBe('central-vault');
63
- });
64
-
65
- it('should write workspace files to ~/.nexusflow/vault/<featureId>', async () => {
66
- vi.mocked(fs.mkdir).mockResolvedValue(undefined);
67
- vi.mocked(fs.writeFile).mockResolvedValue(undefined);
68
-
69
- await adapter.writeWorkspaceFile('/ws/path', 'feature-1', 'test.txt', 'hello');
70
-
71
- expect(fs.writeFile).toHaveBeenCalledWith(
72
- expect.stringContaining(path.normalize('.nexusflow/vault/feature-1/test.txt')),
73
- 'hello',
74
- 'utf8'
75
- );
76
- });
77
-
78
- it('should write base files to ~/.nexusflow/vault/_base/<repoName>', async () => {
79
- vi.mocked(fs.mkdir).mockResolvedValue(undefined);
80
- vi.mocked(fs.writeFile).mockResolvedValue(undefined);
81
-
82
- await adapter.writeBaseFile('/ws/path', 'RepoName', 'map.md', 'content');
83
-
84
- expect(fs.writeFile).toHaveBeenCalledWith(
85
- expect.stringContaining(path.normalize('.nexusflow/vault/_base/RepoName/map.md')),
86
- 'content',
87
- 'utf8'
88
- );
89
- });
90
-
91
- it('should delete workspace folder from ~/.nexusflow/vault', async () => {
92
- vi.mocked(fs.rm).mockResolvedValue(undefined);
93
- await adapter.deleteWorkspace('/ws/path', 'feature-1');
94
- expect(fs.rm).toHaveBeenCalledWith(
95
- expect.stringContaining(path.normalize('.nexusflow/vault/feature-1')),
96
- { recursive: true, force: true }
97
- );
98
- });
99
- });
100
-
101
- describe('ObsidianStorageAdapter', () => {
102
- it('should declare correct meta and configuration settings', () => {
103
- const adapter = new ObsidianStorageAdapter();
104
- expect(adapter.meta.name).toBe('obsidian');
105
- expect(adapter.meta.configFields.some(f => f.key === 'vaultPath')).toBe(true);
106
- });
107
-
108
- it('should respect custom vaultPath configuration', async () => {
109
- const adapter = new ObsidianStorageAdapter();
110
- adapter.configure({ vaultPath: '/custom/obsidian/vault' });
111
-
112
- vi.mocked(fs.mkdir).mockResolvedValue(undefined);
113
- vi.mocked(fs.writeFile).mockResolvedValue(undefined);
114
-
115
- await adapter.writeWorkspaceFile('/ws/path', 'feature-1', 'test.txt', 'hello');
116
-
117
- expect(fs.writeFile).toHaveBeenCalledWith(
118
- path.normalize('/custom/obsidian/vault/nexusflow/workspaces/feature-1/test.txt'),
119
- expect.any(String),
120
- 'utf8'
121
- );
122
- });
123
-
124
- it('should wrap content with YAML frontmatter by default', async () => {
125
- const adapter = new ObsidianStorageAdapter();
126
- adapter.configure({ vaultPath: '/custom/obsidian/vault', addFrontmatter: true });
127
-
128
- vi.mocked(fs.mkdir).mockResolvedValue(undefined);
129
- vi.mocked(fs.writeFile).mockResolvedValue(undefined);
130
-
131
- await adapter.writeWorkspaceFile('/ws/path', 'feature-1', 'test.txt', 'hello');
132
-
133
- expect(fs.writeFile).toHaveBeenCalledWith(
134
- expect.any(String),
135
- expect.stringContaining('tags: ["feature-1", "workspace"]'),
136
- 'utf8'
137
- );
138
- expect(fs.writeFile).toHaveBeenCalledWith(
139
- expect.any(String),
140
- expect.stringContaining('generator: nexusflow'),
141
- 'utf8'
142
- );
143
- });
144
-
145
- it('should not wrap content with frontmatter if addFrontmatter is disabled', async () => {
146
- const adapter = new ObsidianStorageAdapter();
147
- adapter.configure({ vaultPath: '/custom/obsidian/vault', addFrontmatter: false });
148
-
149
- vi.mocked(fs.mkdir).mockResolvedValue(undefined);
150
- vi.mocked(fs.writeFile).mockResolvedValue(undefined);
151
-
152
- await adapter.writeWorkspaceFile('/ws/path', 'feature-1', 'test.txt', 'hello');
153
-
154
- expect(fs.writeFile).toHaveBeenCalledWith(
155
- expect.any(String),
156
- 'hello',
157
- 'utf8'
158
- );
159
- });
160
-
161
- it('should delete workspace folder from custom vault path under nexusflow', async () => {
162
- const adapter = new ObsidianStorageAdapter();
163
- adapter.configure({ vaultPath: '/custom/obsidian/vault' });
164
- vi.mocked(fs.rm).mockResolvedValue(undefined);
165
-
166
- await adapter.deleteWorkspace('/ws/path', 'feature-1');
167
-
168
- expect(fs.rm).toHaveBeenCalledWith(
169
- path.normalize('/custom/obsidian/vault/nexusflow/workspaces/feature-1'),
170
- { recursive: true, force: true }
171
- );
172
- });
173
- });
174
- });
@@ -1,86 +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 type { StoragePort, StorageAdapterMeta } from '../ports/storage.js';
5
-
6
- export class CentralVaultAdapter implements StoragePort {
7
- readonly meta: StorageAdapterMeta = {
8
- name: 'central-vault',
9
- displayName: 'Central Vault',
10
- description: 'Store context in ~/.nexusflow/vault/ — keeps repos clean, Obsidian-compatible.',
11
- configFields: [],
12
- };
13
-
14
- private getVaultPath(featureId: string): string {
15
- return path.join(os.homedir(), '.nexusflow', 'vault', featureId);
16
- }
17
-
18
- async writeWorkspaceFile(workspacePath: string, featureId: string, filename: string, content: string): Promise<void> {
19
- const vaultDir = this.getVaultPath(featureId);
20
- const filePath = path.join(vaultDir, filename);
21
- await fs.mkdir(path.dirname(filePath), { recursive: true });
22
- await fs.writeFile(filePath, content, 'utf8');
23
- }
24
-
25
- async readWorkspaceFile(workspacePath: string, featureId: string, filename: string): Promise<string> {
26
- const vaultDir = this.getVaultPath(featureId);
27
- const filePath = path.join(vaultDir, filename);
28
- return await fs.readFile(filePath, 'utf8');
29
- }
30
-
31
- async workspaceFileExists(workspacePath: string, featureId: string, filename: string): Promise<boolean> {
32
- const vaultDir = this.getVaultPath(featureId);
33
- const filePath = path.join(vaultDir, filename);
34
- try {
35
- await fs.access(filePath);
36
- return true;
37
- } catch {
38
- return false;
39
- }
40
- }
41
-
42
- resolveWorkspaceFileUrl(workspacePath: string, featureId: string, filename: string): string {
43
- const vaultDir = this.getVaultPath(featureId);
44
- return path.join(vaultDir, filename).replace(/\\/g, '/');
45
- }
46
-
47
- private getBaseVaultPath(repoName: string): string {
48
- return path.join(os.homedir(), '.nexusflow', 'vault', '_base', repoName);
49
- }
50
-
51
- async writeBaseFile(workspacePath: string, repoName: string, filename: string, content: string): Promise<void> {
52
- const baseDir = this.getBaseVaultPath(repoName);
53
- const filePath = path.join(baseDir, filename);
54
- await fs.mkdir(path.dirname(filePath), { recursive: true });
55
- await fs.writeFile(filePath, content, 'utf8');
56
- }
57
-
58
- async readBaseFile(workspacePath: string, repoName: string, filename: string): Promise<string> {
59
- const baseDir = this.getBaseVaultPath(repoName);
60
- const filePath = path.join(baseDir, filename);
61
- return await fs.readFile(filePath, 'utf8');
62
- }
63
-
64
- async baseFileExists(workspacePath: string, repoName: string, filename: string): Promise<boolean> {
65
- const baseDir = this.getBaseVaultPath(repoName);
66
- const filePath = path.join(baseDir, filename);
67
- try {
68
- await fs.access(filePath);
69
- return true;
70
- } catch {
71
- return false;
72
- }
73
- }
74
-
75
- resolveBaseFileUrl(workspacePath: string, repoName: string, filename: string): string {
76
- const baseDir = this.getBaseVaultPath(repoName);
77
- return path.join(baseDir, filename).replace(/\\/g, '/');
78
- }
79
-
80
- async deleteWorkspace(workspacePath: string, featureId: string): Promise<void> {
81
- const dir = this.getVaultPath(featureId);
82
- try {
83
- await fs.rm(dir, { recursive: true, force: true });
84
- } catch {}
85
- }
86
- }
@@ -1,96 +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 { getConfigDir, getDefaultConfig, ensureConfigDir, loadConfig, saveConfig } from './config.js';
5
-
6
- vi.mock('node:fs/promises');
7
- vi.mock('node:os', async () => {
8
- const actual = await vi.importActual<typeof import('node:os')>('node:os');
9
- return {
10
- ...actual,
11
- homedir: vi.fn(),
12
- };
13
- });
14
-
15
- describe('config core module', () => {
16
- beforeEach(() => {
17
- vi.clearAllMocks();
18
- vi.mocked(os.homedir).mockReturnValue('/mock/home');
19
- });
20
-
21
- describe('getConfigDir', () => {
22
- it('should return path based on home directory', () => {
23
- const dir = getConfigDir();
24
- expect(dir).toContain('.nexusflow');
25
- });
26
- });
27
-
28
- describe('getDefaultConfig', () => {
29
- it('should return config with defaults populated', () => {
30
- const config = getDefaultConfig();
31
- expect(config.version).toBe('1.0.0');
32
- expect(config.scanDepth).toBe(2);
33
- expect(config.localLlm?.enabled).toBe(false);
34
- });
35
- });
36
-
37
- describe('ensureConfigDir', () => {
38
- it('should invoke fs.mkdir with correct options', async () => {
39
- vi.mocked(fs.mkdir).mockResolvedValue(undefined);
40
-
41
- await ensureConfigDir();
42
-
43
- expect(fs.mkdir).toHaveBeenCalledWith(expect.stringContaining('.nexusflow'), { recursive: true });
44
- });
45
- });
46
-
47
- describe('loadConfig', () => {
48
- it('should load config if file exists', async () => {
49
- const savedConfig = {
50
- devDir: '/custom/dev',
51
- localLlm: {
52
- enabled: true,
53
- model: 'custom-model'
54
- }
55
- };
56
-
57
- vi.mocked(fs.readFile).mockResolvedValue(JSON.stringify(savedConfig));
58
-
59
- const config = await loadConfig();
60
-
61
- expect(config.devDir).toBe('/custom/dev');
62
- expect(config.localLlm?.enabled).toBe(true);
63
- expect(config.localLlm?.model).toBe('custom-model');
64
- // Should merge with defaults
65
- expect(config.scanDepth).toBe(2);
66
- });
67
-
68
- it('should return default config if read fails', async () => {
69
- vi.mocked(fs.readFile).mockRejectedValue(new Error('ENOENT'));
70
-
71
- const config = await loadConfig();
72
-
73
- expect(config.version).toBe('1.0.0');
74
- expect(config.localLlm?.enabled).toBe(false);
75
- });
76
- });
77
-
78
- describe('saveConfig', () => {
79
- it('should create directory and save configuration', async () => {
80
- vi.mocked(fs.mkdir).mockResolvedValue(undefined);
81
- vi.mocked(fs.writeFile).mockResolvedValue(undefined);
82
-
83
- const config = getDefaultConfig();
84
- config.devDir = '/custom/saved/dev';
85
-
86
- await saveConfig(config);
87
-
88
- expect(fs.mkdir).toHaveBeenCalled();
89
- expect(fs.writeFile).toHaveBeenCalledWith(
90
- expect.stringContaining('config.json'),
91
- expect.stringContaining('/custom/saved/dev'),
92
- 'utf-8'
93
- );
94
- });
95
- });
96
- });
@@ -1,140 +0,0 @@
1
- /**
2
- * @module core/config
3
- * Manages NexusFlow configuration stored at ~/.nexusflow/config.json.
4
- */
5
-
6
- import * as fs from 'node:fs/promises';
7
- import * as path from 'node:path';
8
- import * as os from 'node:os';
9
-
10
- import type { NexusFlowConfig } from '../types.js';
11
- import { getStorageProvider, setActiveStorageProvider } from './adapters/registry.js';
12
-
13
- /** Name of the config directory under the user's home folder. */
14
- const CONFIG_DIR_NAME = '.nexusflow';
15
-
16
- /** Name of the config file. */
17
- const CONFIG_FILE_NAME = 'config.json';
18
-
19
- /**
20
- * Returns the absolute path to the NexusFlow config directory (~/.nexusflow).
21
- */
22
- export function getConfigDir(): string {
23
- return path.join(os.homedir(), CONFIG_DIR_NAME);
24
- }
25
-
26
- /**
27
- * Returns a NexusFlowConfig populated with sensible defaults.
28
- */
29
- export function getDefaultConfig(): NexusFlowConfig {
30
- return {
31
- version: '1.0.0',
32
- devDir: path.join(os.homedir(), 'dev'),
33
- workspacesDir: path.join(os.homedir(), 'dev', 'workspaces'),
34
- defaultAssistant: null,
35
- defaultEditor: null,
36
- scanDepth: 2,
37
- excludePatterns: [
38
- '**/node_modules/**',
39
- '**/bin/**',
40
- '**/obj/**',
41
- '**/dist/**',
42
- '**/out/**',
43
- '**/.git/**',
44
- '**/*.lock',
45
- '**/package-lock.json',
46
- '**/pnpm-lock.yaml',
47
- '**/yarn.lock',
48
- '**/*.png',
49
- '**/*.jpg',
50
- '**/*.jpeg',
51
- '**/*.gif',
52
- '**/*.svg',
53
- '**/*.ico',
54
- '**/*.pdf',
55
- '**/*.zip',
56
- '**/*.tar.gz',
57
- '**/.vs/**',
58
- '**/.vscode/**',
59
- '**/.idea/**',
60
- ],
61
- localLlm: {
62
- enabled: false,
63
- provider: 'ollama',
64
- endpoint: 'http://localhost:11434',
65
- model: 'qwen2.5-coder:1.5b',
66
- },
67
- };
68
- }
69
-
70
- /**
71
- * Ensures the ~/.nexusflow directory exists, creating it if necessary.
72
- */
73
- export async function ensureConfigDir(): Promise<void> {
74
- const configDir = getConfigDir();
75
- await fs.mkdir(configDir, { recursive: true });
76
- }
77
-
78
- /**
79
- * Loads the NexusFlow config from disk.
80
- * Returns default values when the config file does not exist yet.
81
- *
82
- * @returns The loaded or default configuration.
83
- */
84
- export async function loadConfig(): Promise<NexusFlowConfig> {
85
- const configPath = path.join(getConfigDir(), CONFIG_FILE_NAME);
86
-
87
- let merged: NexusFlowConfig;
88
- try {
89
- const raw = await fs.readFile(configPath, 'utf-8');
90
- const parsed = JSON.parse(raw) as Partial<NexusFlowConfig>;
91
-
92
- // Merge with defaults so newly-added keys are always present.
93
- merged = { ...getDefaultConfig(), ...parsed };
94
- if (parsed.localLlm) {
95
- merged.localLlm = { ...getDefaultConfig().localLlm, ...parsed.localLlm };
96
- }
97
- } catch {
98
- // File doesn't exist or is unreadable — return defaults.
99
- merged = getDefaultConfig();
100
- }
101
-
102
- // Set the active storage provider based on configuration
103
- try {
104
- const providerName = merged.storageProvider || 'local';
105
- const provider = getStorageProvider(providerName);
106
- // Pass per-adapter settings if available
107
- const adapterSettings = merged.adapterConfig?.[providerName] ?? {};
108
- if (provider.configure) {
109
- provider.configure(adapterSettings);
110
- }
111
- setActiveStorageProvider(provider);
112
- } catch {}
113
-
114
- return merged;
115
- }
116
-
117
- /**
118
- * Persists the given configuration to ~/.nexusflow/config.json.
119
- * Creates the config directory if it doesn't exist.
120
- *
121
- * @param config - The configuration to save.
122
- */
123
- export async function saveConfig(config: NexusFlowConfig): Promise<void> {
124
- await ensureConfigDir();
125
-
126
- const configPath = path.join(getConfigDir(), CONFIG_FILE_NAME);
127
- const data = JSON.stringify(config, null, 2) + '\n';
128
- await fs.writeFile(configPath, data, 'utf-8');
129
-
130
- // Set the active storage provider based on configuration
131
- try {
132
- const providerName = config.storageProvider || 'local';
133
- const provider = getStorageProvider(providerName);
134
- const adapterSettings = config.adapterConfig?.[providerName] ?? {};
135
- if (provider.configure) {
136
- provider.configure(adapterSettings);
137
- }
138
- setActiveStorageProvider(provider);
139
- } catch {}
140
- }