@mrpatronz/nexusflow 0.2.17 → 0.2.19
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.
- package/.agents/skills/ccc/SKILL.md +71 -0
- package/.agents/skills/ccc/references/management.md +110 -0
- package/.agents/skills/ccc/references/settings.md +126 -0
- package/.github/dependabot.yml +52 -52
- package/.github/workflows/ci.yml +44 -0
- package/.github/workflows/dependabot-merge.yml +53 -53
- package/.github/workflows/release-desktop.yml +67 -0
- package/.github/workflows/release-npm.yml +65 -0
- package/.github/workflows/release-vscode.yml +61 -0
- package/.vscode/launch.json +17 -17
- package/.vscode/tasks.json +17 -17
- package/GETTING_STARTED.md +114 -114
- package/README.md +364 -336
- package/desktop/build-installer.js +228 -228
- package/desktop/build.js +118 -118
- package/desktop/installer/nexusflow.iss +35 -35
- package/desktop/neutralino.config.json +38 -38
- package/desktop/package-lock.json +1060 -1060
- package/desktop/package.json +14 -14
- package/dist/commands/adapter.d.ts +27 -0
- package/dist/commands/adapter.d.ts.map +1 -0
- package/dist/commands/adapter.js +318 -0
- package/dist/commands/adapter.js.map +1 -0
- package/dist/commands/add-repo.d.ts.map +1 -1
- package/dist/commands/add-repo.js +0 -1
- package/dist/commands/add-repo.js.map +1 -1
- package/dist/commands/commands.test.js +2 -2
- package/dist/commands/commands.test.js.map +1 -1
- package/dist/commands/config.d.ts +22 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +50 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +14 -17
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +11 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/refresh.d.ts +1 -0
- package/dist/commands/refresh.d.ts.map +1 -1
- package/dist/commands/refresh.js +2 -14
- package/dist/commands/refresh.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +36 -54
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/tui.d.ts.map +1 -1
- package/dist/commands/tui.js +63 -10
- package/dist/commands/tui.js.map +1 -1
- package/dist/core/adapters/local-storage.d.ts +14 -0
- package/dist/core/adapters/local-storage.d.ts.map +1 -0
- package/dist/core/adapters/local-storage.js +58 -0
- package/dist/core/adapters/local-storage.js.map +1 -0
- package/dist/core/adapters/obsidian-storage.d.ts +28 -0
- package/dist/core/adapters/obsidian-storage.d.ts.map +1 -0
- package/dist/core/adapters/obsidian-storage.js +135 -0
- package/dist/core/adapters/obsidian-storage.js.map +1 -0
- package/dist/core/adapters/registry.d.ts +8 -0
- package/dist/core/adapters/registry.d.ts.map +1 -0
- package/dist/core/adapters/registry.js +37 -0
- package/dist/core/adapters/registry.js.map +1 -0
- package/dist/core/adapters/storage.test.d.ts +2 -0
- package/dist/core/adapters/storage.test.d.ts.map +1 -0
- package/dist/core/adapters/storage.test.js +106 -0
- package/dist/core/adapters/storage.test.js.map +1 -0
- package/dist/core/adapters/vault-storage.d.ts +16 -0
- package/dist/core/adapters/vault-storage.d.ts.map +1 -0
- package/dist/core/adapters/vault-storage.js +77 -0
- package/dist/core/adapters/vault-storage.js.map +1 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +28 -4
- package/dist/core/config.js.map +1 -1
- package/dist/core/plugins/index.d.ts +14 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/index.js +2 -0
- package/dist/core/plugins/index.js.map +1 -0
- package/dist/core/plugins/loader.d.ts +2 -0
- package/dist/core/plugins/loader.d.ts.map +1 -0
- package/dist/core/plugins/loader.js +34 -0
- package/dist/core/plugins/loader.js.map +1 -0
- package/dist/core/ports/storage.d.ts +59 -0
- package/dist/core/ports/storage.d.ts.map +1 -0
- package/dist/core/ports/storage.js +10 -0
- package/dist/core/ports/storage.js.map +1 -0
- package/dist/core/storage.d.ts +10 -0
- package/dist/core/storage.d.ts.map +1 -0
- package/dist/core/storage.js +29 -0
- package/dist/core/storage.js.map +1 -0
- package/dist/core/sync.d.ts +44 -0
- package/dist/core/sync.d.ts.map +1 -0
- package/dist/core/sync.js +82 -0
- package/dist/core/sync.js.map +1 -0
- package/dist/core/workspace-state.d.ts +51 -0
- package/dist/core/workspace-state.d.ts.map +1 -0
- package/dist/core/workspace-state.js +108 -0
- package/dist/core/workspace-state.js.map +1 -0
- package/dist/core/workspace-state.test.d.ts +2 -0
- package/dist/core/workspace-state.test.d.ts.map +1 -0
- package/dist/core/workspace-state.test.js +84 -0
- package/dist/core/workspace-state.test.js.map +1 -0
- package/dist/core/workspace.d.ts.map +1 -1
- package/dist/core/workspace.js +110 -16
- package/dist/core/workspace.js.map +1 -1
- package/dist/generators/base.d.ts.map +1 -1
- package/dist/generators/base.js +80 -79
- package/dist/generators/base.js.map +1 -1
- package/dist/generators/codex.js +11 -11
- package/dist/generators/copilot.js +17 -17
- package/dist/generators/cursor.js +5 -5
- package/dist/generators/diff-context.d.ts +6 -0
- package/dist/generators/diff-context.d.ts.map +1 -0
- package/dist/generators/diff-context.js +68 -0
- package/dist/generators/diff-context.js.map +1 -0
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +125 -68
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/map-generator.d.ts.map +1 -1
- package/dist/generators/map-generator.js +21 -25
- package/dist/generators/map-generator.js.map +1 -1
- package/dist/generators/plan-generator.d.ts.map +1 -1
- package/dist/generators/plan-generator.js +3 -5
- package/dist/generators/plan-generator.js.map +1 -1
- package/dist/generators/skills-generator.js +28 -28
- package/dist/gui/assets/index-Bdbld6yY.css +1 -0
- package/dist/gui/assets/index-D8iJPvnk.js +26 -0
- package/dist/gui/icons.svg +24 -24
- package/dist/gui/index.html +18 -18
- package/dist/index.js +131 -20
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +42 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +140 -56
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +105 -48
- package/dist/server.test.js.map +1 -1
- package/dist/types.d.ts +38 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/local-ai.d.ts.map +1 -1
- package/dist/utils/local-ai.js +7 -3
- package/dist/utils/local-ai.js.map +1 -1
- package/dist/utils/multi-git.d.ts +33 -8
- package/dist/utils/multi-git.d.ts.map +1 -1
- package/dist/utils/multi-git.js +91 -19
- package/dist/utils/multi-git.js.map +1 -1
- package/dist/utils/multi-git.test.d.ts +2 -0
- package/dist/utils/multi-git.test.d.ts.map +1 -0
- package/dist/utils/multi-git.test.js +125 -0
- package/dist/utils/multi-git.test.js.map +1 -0
- package/dist/utils/update-check.d.ts.map +1 -1
- package/dist/utils/update-check.js +0 -28
- package/dist/utils/update-check.js.map +1 -1
- package/dist/utils/workflow-advisor.d.ts +16 -0
- package/dist/utils/workflow-advisor.d.ts.map +1 -0
- package/dist/utils/workflow-advisor.js +100 -0
- package/dist/utils/workflow-advisor.js.map +1 -0
- package/extension/package-lock.json +6044 -2673
- package/extension/package.json +117 -108
- package/extension/src/extension.ts +653 -631
- package/extension/tsconfig.json +21 -21
- package/gui/README.md +73 -73
- package/gui/e2e/dashboard.spec.ts +61 -0
- package/gui/e2e/wizard.spec.ts +346 -346
- package/gui/eslint.config.js +26 -26
- package/gui/index.html +17 -17
- package/gui/package-lock.json +3137 -3079
- package/gui/package.json +37 -36
- package/gui/playwright.config.ts +41 -41
- package/gui/public/icons.svg +24 -24
- package/gui/src/App.css +1 -1
- package/gui/src/App.tsx +3573 -3407
- package/gui/src/app/AppSidebar.tsx +69 -0
- package/gui/src/assets/vite.svg +1 -1
- package/gui/src/components/AddRepoPicker.tsx +81 -0
- package/gui/src/components/ui/Button.tsx +40 -0
- package/gui/src/components/ui/Card.tsx +6 -0
- package/gui/src/components/ui/EmptyState.tsx +22 -0
- package/gui/src/components/ui/Input.tsx +21 -0
- package/gui/src/components/ui/Menu.tsx +71 -0
- package/gui/src/components/ui/Modal.tsx +39 -0
- package/gui/src/components/ui/PageHeader.tsx +21 -0
- package/gui/src/components/ui/RepoStatusStrip.tsx +33 -0
- package/gui/src/components/ui/Skeleton.tsx +5 -0
- package/gui/src/components/ui/StatusPill.tsx +36 -0
- package/gui/src/components/ui/Tabs.tsx +40 -0
- package/gui/src/components/ui/cn.ts +4 -0
- package/gui/src/components/ui/index.ts +16 -0
- package/gui/src/features/changes/ChangesViewer.tsx +388 -388
- package/gui/src/features/knowledge/KnowledgeBase.tsx +84 -84
- package/gui/src/features/onboarding/OnboardingWizard.tsx +230 -230
- package/gui/src/features/plan/ImplementationPlan.tsx +32 -32
- package/gui/src/features/services/ServiceConsole.tsx +215 -250
- package/gui/src/features/sessions/SessionHistory.tsx +195 -195
- package/gui/src/index.css +167 -152
- package/gui/src/lib/status.ts +24 -0
- package/gui/src/main.tsx +94 -94
- package/gui/src/pages/DashboardPage.tsx +129 -0
- package/gui/src/pages/WorkspacesPage.tsx +352 -0
- package/gui/src/types.ts +81 -62
- package/gui/tsconfig.app.json +25 -25
- package/gui/tsconfig.json +7 -7
- package/gui/tsconfig.node.json +24 -24
- package/gui/vite.config.ts +12 -12
- package/package.json +55 -56
- package/resources/workflows/plan-implement-review.md +8 -8
- package/resources/workflows/research-verify.md +6 -6
- package/resources/workflows/solo-developer.md +3 -3
- package/scripts/simulate-workspaces.ts +55 -55
- package/skills-lock.json +11 -0
- package/src/analyzers/detect-apis.ts +290 -290
- package/src/analyzers/detect-deps.ts +315 -315
- package/src/analyzers/detect-existing.ts +74 -74
- package/src/analyzers/detect-ports.ts +110 -110
- package/src/analyzers/index.ts +97 -97
- package/src/analyzers/messaging-analyzer.ts +254 -254
- package/src/analyzers/readme-summarizer.ts +102 -102
- package/src/analyzers/run-analyzer.ts +269 -269
- package/src/analyzers/tech-stack.ts +283 -283
- package/src/commands/adapter.ts +348 -0
- package/src/commands/add-repo.ts +156 -157
- package/src/commands/commands.test.ts +156 -155
- package/src/commands/commit.ts +131 -131
- package/src/commands/config.ts +52 -0
- package/src/commands/create.ts +204 -207
- package/src/commands/desktop.ts +128 -128
- package/src/commands/diff.ts +125 -125
- package/src/commands/doctor.ts +370 -357
- package/src/commands/handoff.ts +266 -266
- package/src/commands/init.ts +134 -134
- package/src/commands/list.ts +46 -46
- package/src/commands/logs.ts +63 -63
- package/src/commands/mcp.ts +94 -92
- package/src/commands/open.ts +129 -129
- package/src/commands/refresh.ts +137 -147
- package/src/commands/remove.ts +98 -98
- package/src/commands/start.ts +117 -117
- package/src/commands/status.ts +54 -54
- package/src/commands/stop.ts +55 -55
- package/src/commands/sync.ts +125 -151
- package/src/commands/tui.ts +484 -424
- package/src/commands/ui.ts +111 -111
- package/src/core/adapters/local-storage.ts +66 -0
- package/src/core/adapters/obsidian-storage.ts +151 -0
- package/src/core/adapters/registry.ts +44 -0
- package/src/core/adapters/storage.test.ts +174 -0
- package/src/core/adapters/vault-storage.ts +86 -0
- package/src/core/config.test.ts +96 -96
- package/src/core/config.ts +140 -115
- package/src/core/graph.ts +344 -344
- package/src/core/plugins/index.ts +17 -0
- package/src/core/plugins/loader.ts +36 -0
- package/src/core/ports/storage.ts +71 -0
- package/src/core/scanner.test.ts +61 -61
- package/src/core/scanner.ts +91 -91
- package/src/core/storage.ts +37 -0
- package/src/core/sync.ts +121 -0
- package/src/core/workspace-state.test.ts +108 -0
- package/src/core/workspace-state.ts +130 -0
- package/src/core/workspace.ts +487 -380
- package/src/core/worktree.ts +120 -120
- package/src/generators/antigravity.ts +32 -32
- package/src/generators/base.ts +243 -240
- package/src/generators/claude.ts +34 -34
- package/src/generators/codex.ts +48 -48
- package/src/generators/copilot.ts +56 -56
- package/src/generators/cursor.ts +44 -44
- package/src/generators/diff-context.ts +75 -0
- package/src/generators/index.ts +322 -250
- package/src/generators/map-generator.test.ts +159 -159
- package/src/generators/map-generator.ts +539 -542
- package/src/generators/plan-generator.ts +483 -481
- package/src/generators/skills-generator.ts +259 -259
- package/src/index.ts +539 -426
- package/src/mcp/server.ts +338 -294
- package/src/orchestration/detect.ts +313 -313
- package/src/orchestration/index.ts +7 -7
- package/src/orchestration/runner.ts +283 -283
- package/src/server.test.ts +618 -555
- package/src/server.ts +1402 -1308
- package/src/types.ts +451 -408
- package/src/utils/detect-ai.test.ts +44 -44
- package/src/utils/detect-ai.ts +84 -84
- package/src/utils/detect-editors.test.ts +48 -48
- package/src/utils/detect-editors.ts +57 -57
- package/src/utils/git.test.ts +74 -74
- package/src/utils/git.ts +117 -117
- package/src/utils/local-ai.test.ts +130 -130
- package/src/utils/local-ai.ts +116 -111
- package/src/utils/multi-git.test.ts +158 -0
- package/src/utils/multi-git.ts +405 -313
- package/src/utils/prompts.ts +209 -209
- package/src/utils/session-finder.ts +483 -483
- package/src/utils/system-scanner.test.ts +89 -89
- package/src/utils/system-scanner.ts +96 -96
- package/src/utils/update-check.ts +286 -309
- package/src/utils/workflow-advisor.ts +118 -0
- package/src/utils/workflows.test.ts +114 -114
- package/src/utils/workflows.ts +178 -178
- package/tsconfig.json +19 -19
- package/vitest.config.ts +14 -14
- package/.github/workflows/release.yml +0 -112
- package/dist/commands/pack.d.ts +0 -7
- package/dist/commands/pack.d.ts.map +0 -1
- package/dist/commands/pack.js +0 -64
- package/dist/commands/pack.js.map +0 -1
- package/dist/core/packer.d.ts +0 -14
- package/dist/core/packer.d.ts.map +0 -1
- package/dist/core/packer.js +0 -87
- package/dist/core/packer.js.map +0 -1
- package/dist/core/packer.test.d.ts +0 -2
- package/dist/core/packer.test.d.ts.map +0 -1
- package/dist/core/packer.test.js +0 -82
- package/dist/core/packer.test.js.map +0 -1
- package/dist/gui/assets/index-Ct3qq-X4.js +0 -25
- package/dist/gui/assets/index-P_ZrgHXg.css +0 -1
- package/gui/src/features/workspace/WorkspaceList.tsx +0 -666
- package/src/commands/pack.ts +0 -73
- package/src/core/packer.test.ts +0 -99
- package/src/core/packer.ts +0 -107
package/src/commands/ui.ts
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module commands/ui
|
|
3
|
-
* Starts the Hono web server and opens the browser to the NexusFlow GUI.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import { exec, spawn } from 'node:child_process';
|
|
8
|
-
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import * as path from 'node:path';
|
|
10
|
-
import * as net from 'node:net';
|
|
11
|
-
import { startServer } from '../server.js';
|
|
12
|
-
|
|
13
|
-
function isPortActive(port: number): Promise<boolean> {
|
|
14
|
-
return new Promise((resolve) => {
|
|
15
|
-
const socket = net.connect(port, 'localhost');
|
|
16
|
-
socket.on('connect', () => {
|
|
17
|
-
socket.destroy();
|
|
18
|
-
resolve(true);
|
|
19
|
-
});
|
|
20
|
-
socket.on('error', () => {
|
|
21
|
-
resolve(false);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function openBrowser(url: string): void {
|
|
27
|
-
let openCmd = '';
|
|
28
|
-
if (process.platform === 'win32') {
|
|
29
|
-
openCmd = `start ${url}`;
|
|
30
|
-
} else if (process.platform === 'darwin') {
|
|
31
|
-
openCmd = `open ${url}`;
|
|
32
|
-
} else {
|
|
33
|
-
openCmd = `xdg-open ${url}`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exec(openCmd, (err) => {
|
|
37
|
-
if (err) {
|
|
38
|
-
console.log(chalk.dim(` Could not auto-open browser. Please visit ${url} manually.`));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Starts the local GUI server and opens the dashboard in the default browser.
|
|
45
|
-
*
|
|
46
|
-
* @param options - CLI options, including optional port, daemon, and server-only.
|
|
47
|
-
*/
|
|
48
|
-
export async function uiCommand(options: { port?: string; daemon?: boolean; serverOnly?: boolean }): Promise<void> {
|
|
49
|
-
const port = options.port ? parseInt(options.port, 10) : 3000;
|
|
50
|
-
const url = `http://localhost:${port}`;
|
|
51
|
-
|
|
52
|
-
console.log(chalk.bold.cyan('\n🖥️ NexusFlow — Web Dashboard\n'));
|
|
53
|
-
|
|
54
|
-
// Check if port is already active
|
|
55
|
-
const active = await isPortActive(port);
|
|
56
|
-
if (active) {
|
|
57
|
-
console.log(chalk.green(` ✔ Dashboard is already active at: ${chalk.bold(url)}`));
|
|
58
|
-
if (!options.serverOnly) {
|
|
59
|
-
console.log(chalk.dim(' Opening browser...'));
|
|
60
|
-
openBrowser(url);
|
|
61
|
-
}
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Handle Daemon mode (runs detached in the background)
|
|
66
|
-
if (options.daemon) {
|
|
67
|
-
console.log(chalk.dim(' Starting server in the background...'));
|
|
68
|
-
try {
|
|
69
|
-
const serverScript = fileURLToPath(new URL('../index.js', import.meta.url));
|
|
70
|
-
const child = spawn(process.execPath, [serverScript, 'ui', '--port', String(port), '--server-only'], {
|
|
71
|
-
detached: true,
|
|
72
|
-
stdio: 'ignore'
|
|
73
|
-
});
|
|
74
|
-
child.unref();
|
|
75
|
-
|
|
76
|
-
console.log(chalk.green(` ✔ Dashboard daemon successfully spawned.`));
|
|
77
|
-
if (!options.serverOnly) {
|
|
78
|
-
console.log(chalk.dim(' Opening browser...'));
|
|
79
|
-
// Give the background process a brief moment to start listening
|
|
80
|
-
await new Promise((resolve) => setTimeout(resolve, 600));
|
|
81
|
-
openBrowser(url);
|
|
82
|
-
}
|
|
83
|
-
return;
|
|
84
|
-
} catch (err) {
|
|
85
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
86
|
-
console.error(chalk.red(` ✖ Failed to start background daemon: ${msg}`));
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Standard foreground blocking mode
|
|
92
|
-
console.log(chalk.dim(' Starting local server...'));
|
|
93
|
-
try {
|
|
94
|
-
const { port: actualPort } = await startServer(port);
|
|
95
|
-
const actualUrl = `http://localhost:${actualPort}`;
|
|
96
|
-
|
|
97
|
-
console.log(chalk.green(` ✔ Dashboard running at: ${chalk.bold(actualUrl)}`));
|
|
98
|
-
console.log(chalk.dim(' Press Ctrl+C to stop.\n'));
|
|
99
|
-
|
|
100
|
-
if (!options.serverOnly) {
|
|
101
|
-
openBrowser(actualUrl);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Keep process alive
|
|
105
|
-
await new Promise(() => {});
|
|
106
|
-
} catch (error) {
|
|
107
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
108
|
-
console.error(chalk.red(` ✖ Failed to start dashboard: ${msg}`));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module commands/ui
|
|
3
|
+
* Starts the Hono web server and opens the browser to the NexusFlow GUI.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import { exec, spawn } from 'node:child_process';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import * as path from 'node:path';
|
|
10
|
+
import * as net from 'node:net';
|
|
11
|
+
import { startServer } from '../server.js';
|
|
12
|
+
|
|
13
|
+
function isPortActive(port: number): Promise<boolean> {
|
|
14
|
+
return new Promise((resolve) => {
|
|
15
|
+
const socket = net.connect(port, 'localhost');
|
|
16
|
+
socket.on('connect', () => {
|
|
17
|
+
socket.destroy();
|
|
18
|
+
resolve(true);
|
|
19
|
+
});
|
|
20
|
+
socket.on('error', () => {
|
|
21
|
+
resolve(false);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function openBrowser(url: string): void {
|
|
27
|
+
let openCmd = '';
|
|
28
|
+
if (process.platform === 'win32') {
|
|
29
|
+
openCmd = `start ${url}`;
|
|
30
|
+
} else if (process.platform === 'darwin') {
|
|
31
|
+
openCmd = `open ${url}`;
|
|
32
|
+
} else {
|
|
33
|
+
openCmd = `xdg-open ${url}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exec(openCmd, (err) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
console.log(chalk.dim(` Could not auto-open browser. Please visit ${url} manually.`));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Starts the local GUI server and opens the dashboard in the default browser.
|
|
45
|
+
*
|
|
46
|
+
* @param options - CLI options, including optional port, daemon, and server-only.
|
|
47
|
+
*/
|
|
48
|
+
export async function uiCommand(options: { port?: string; daemon?: boolean; serverOnly?: boolean }): Promise<void> {
|
|
49
|
+
const port = options.port ? parseInt(options.port, 10) : 3000;
|
|
50
|
+
const url = `http://localhost:${port}`;
|
|
51
|
+
|
|
52
|
+
console.log(chalk.bold.cyan('\n🖥️ NexusFlow — Web Dashboard\n'));
|
|
53
|
+
|
|
54
|
+
// Check if port is already active
|
|
55
|
+
const active = await isPortActive(port);
|
|
56
|
+
if (active) {
|
|
57
|
+
console.log(chalk.green(` ✔ Dashboard is already active at: ${chalk.bold(url)}`));
|
|
58
|
+
if (!options.serverOnly) {
|
|
59
|
+
console.log(chalk.dim(' Opening browser...'));
|
|
60
|
+
openBrowser(url);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Handle Daemon mode (runs detached in the background)
|
|
66
|
+
if (options.daemon) {
|
|
67
|
+
console.log(chalk.dim(' Starting server in the background...'));
|
|
68
|
+
try {
|
|
69
|
+
const serverScript = fileURLToPath(new URL('../index.js', import.meta.url));
|
|
70
|
+
const child = spawn(process.execPath, [serverScript, 'ui', '--port', String(port), '--server-only'], {
|
|
71
|
+
detached: true,
|
|
72
|
+
stdio: 'ignore'
|
|
73
|
+
});
|
|
74
|
+
child.unref();
|
|
75
|
+
|
|
76
|
+
console.log(chalk.green(` ✔ Dashboard daemon successfully spawned.`));
|
|
77
|
+
if (!options.serverOnly) {
|
|
78
|
+
console.log(chalk.dim(' Opening browser...'));
|
|
79
|
+
// Give the background process a brief moment to start listening
|
|
80
|
+
await new Promise((resolve) => setTimeout(resolve, 600));
|
|
81
|
+
openBrowser(url);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
} catch (err) {
|
|
85
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
86
|
+
console.error(chalk.red(` ✖ Failed to start background daemon: ${msg}`));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Standard foreground blocking mode
|
|
92
|
+
console.log(chalk.dim(' Starting local server...'));
|
|
93
|
+
try {
|
|
94
|
+
const { port: actualPort } = await startServer(port);
|
|
95
|
+
const actualUrl = `http://localhost:${actualPort}`;
|
|
96
|
+
|
|
97
|
+
console.log(chalk.green(` ✔ Dashboard running at: ${chalk.bold(actualUrl)}`));
|
|
98
|
+
console.log(chalk.dim(' Press Ctrl+C to stop.\n'));
|
|
99
|
+
|
|
100
|
+
if (!options.serverOnly) {
|
|
101
|
+
openBrowser(actualUrl);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Keep process alive
|
|
105
|
+
await new Promise(() => {});
|
|
106
|
+
} catch (error) {
|
|
107
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
108
|
+
console.error(chalk.red(` ✖ Failed to start dashboard: ${msg}`));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import type { StoragePort, StorageAdapterMeta } from '../ports/storage.js';
|
|
4
|
+
|
|
5
|
+
export class LocalStorageAdapter implements StoragePort {
|
|
6
|
+
readonly meta: StorageAdapterMeta = {
|
|
7
|
+
name: 'local',
|
|
8
|
+
displayName: 'Local Workspace',
|
|
9
|
+
description: 'Write context files directly into the workspace directory.',
|
|
10
|
+
configFields: [],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
async writeWorkspaceFile(workspacePath: string, featureId: string, filename: string, content: string): Promise<void> {
|
|
14
|
+
const filePath = path.join(workspacePath, filename);
|
|
15
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
16
|
+
await fs.writeFile(filePath, content, 'utf8');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async readWorkspaceFile(workspacePath: string, featureId: string, filename: string): Promise<string> {
|
|
20
|
+
const filePath = path.join(workspacePath, filename);
|
|
21
|
+
return await fs.readFile(filePath, 'utf8');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async workspaceFileExists(workspacePath: string, featureId: string, filename: string): Promise<boolean> {
|
|
25
|
+
const filePath = path.join(workspacePath, filename);
|
|
26
|
+
try {
|
|
27
|
+
await fs.access(filePath);
|
|
28
|
+
return true;
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
resolveWorkspaceFileUrl(workspacePath: string, featureId: string, filename: string): string {
|
|
35
|
+
return path.join(workspacePath, filename).replace(/\\/g, '/');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async writeBaseFile(workspacePath: string, repoName: string, filename: string, content: string): Promise<void> {
|
|
39
|
+
const filePath = path.join(workspacePath, filename);
|
|
40
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
41
|
+
await fs.writeFile(filePath, content, 'utf8');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async readBaseFile(workspacePath: string, repoName: string, filename: string): Promise<string> {
|
|
45
|
+
const filePath = path.join(workspacePath, filename);
|
|
46
|
+
return await fs.readFile(filePath, 'utf8');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async baseFileExists(workspacePath: string, repoName: string, filename: string): Promise<boolean> {
|
|
50
|
+
const filePath = path.join(workspacePath, filename);
|
|
51
|
+
try {
|
|
52
|
+
await fs.access(filePath);
|
|
53
|
+
return true;
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
resolveBaseFileUrl(workspacePath: string, repoName: string, filename: string): string {
|
|
60
|
+
return path.join(workspacePath, filename).replace(/\\/g, '/');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async deleteWorkspace(workspacePath: string, featureId: string): Promise<void> {
|
|
64
|
+
// NOP - local files are inside workspacePath, which is deleted directly on workspace removal.
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
});
|