@mrpatronz/nexusflow 0.2.19 → 1.3.1

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