@mrpatronz/nexusflow 0.2.19 → 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.
- package/README.md +27 -3
- package/dist/analyzers/index.d.ts +23 -0
- package/dist/analyzers/index.d.ts.map +1 -1
- package/dist/analyzers/index.js +62 -0
- package/dist/analyzers/index.js.map +1 -1
- package/dist/commands/commands.test.js +20 -6
- package/dist/commands/commands.test.js.map +1 -1
- package/dist/commands/commit.d.ts +2 -0
- package/dist/commands/commit.d.ts.map +1 -1
- package/dist/commands/commit.js +27 -5
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/diff.d.ts +9 -2
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +36 -12
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/handoff.js +2 -2
- package/dist/commands/handoff.js.map +1 -1
- package/dist/commands/refresh.d.ts +4 -2
- package/dist/commands/refresh.d.ts.map +1 -1
- package/dist/commands/refresh.js +20 -36
- package/dist/commands/refresh.js.map +1 -1
- package/dist/commands/schedule.d.ts +35 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +151 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +28 -7
- package/dist/commands/sync.js.map +1 -1
- package/dist/core/analysis-cache.d.ts +58 -0
- package/dist/core/analysis-cache.d.ts.map +1 -0
- package/dist/core/analysis-cache.js +116 -0
- package/dist/core/analysis-cache.js.map +1 -0
- package/dist/core/analysis-cache.test.d.ts +2 -0
- package/dist/core/analysis-cache.test.d.ts.map +1 -0
- package/dist/core/analysis-cache.test.js +108 -0
- package/dist/core/analysis-cache.test.js.map +1 -0
- package/dist/core/refresh.d.ts +41 -0
- package/dist/core/refresh.d.ts.map +1 -0
- package/dist/core/refresh.js +60 -0
- package/dist/core/refresh.js.map +1 -0
- package/dist/core/scheduler.d.ts +117 -0
- package/dist/core/scheduler.d.ts.map +1 -0
- package/dist/core/scheduler.js +247 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/scheduler.test.d.ts +2 -0
- package/dist/core/scheduler.test.d.ts.map +1 -0
- package/dist/core/scheduler.test.js +111 -0
- package/dist/core/scheduler.test.js.map +1 -0
- package/dist/core/sync.d.ts +6 -0
- package/dist/core/sync.d.ts.map +1 -1
- package/dist/core/sync.js +15 -5
- package/dist/core/sync.js.map +1 -1
- package/dist/generators/index.d.ts +7 -1
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +14 -1
- package/dist/generators/index.js.map +1 -1
- package/dist/index.js +107 -4
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +81 -0
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +66 -0
- package/dist/server.test.js.map +1 -1
- package/dist/utils/multi-git.d.ts +21 -0
- package/dist/utils/multi-git.d.ts.map +1 -1
- package/dist/utils/multi-git.js +40 -4
- package/dist/utils/multi-git.js.map +1 -1
- package/package.json +13 -1
- package/.agents/skills/ccc/SKILL.md +0 -71
- package/.agents/skills/ccc/references/management.md +0 -110
- package/.agents/skills/ccc/references/settings.md +0 -126
- package/.github/dependabot.yml +0 -52
- package/.github/workflows/ci.yml +0 -44
- package/.github/workflows/dependabot-merge.yml +0 -53
- package/.github/workflows/release-desktop.yml +0 -67
- package/.github/workflows/release-npm.yml +0 -65
- package/.github/workflows/release-vscode.yml +0 -61
- package/.vscode/launch.json +0 -17
- package/.vscode/tasks.json +0 -17
- package/GETTING_STARTED.md +0 -114
- package/desktop/build-installer.js +0 -228
- package/desktop/build.js +0 -118
- package/desktop/installer/nexusflow.iss +0 -35
- package/desktop/neutralino.config.json +0 -39
- package/desktop/package-lock.json +0 -1060
- package/desktop/package.json +0 -14
- package/extension/media/icon.svg +0 -1
- package/extension/package-lock.json +0 -6044
- package/extension/package.json +0 -117
- package/extension/src/extension.ts +0 -653
- package/extension/tsconfig.json +0 -21
- package/gui/README.md +0 -73
- package/gui/e2e/dashboard.spec.ts +0 -61
- package/gui/e2e/wizard.spec.ts +0 -346
- package/gui/eslint.config.js +0 -26
- package/gui/index.html +0 -17
- package/gui/package-lock.json +0 -3137
- package/gui/package.json +0 -37
- package/gui/playwright.config.ts +0 -41
- package/gui/public/app_logo.png +0 -0
- package/gui/public/favicon.svg +0 -1
- package/gui/public/icons.svg +0 -24
- package/gui/src/App.css +0 -1
- package/gui/src/App.tsx +0 -3573
- package/gui/src/app/AppSidebar.tsx +0 -69
- package/gui/src/assets/hero.png +0 -0
- package/gui/src/assets/react.svg +0 -1
- package/gui/src/assets/vite.svg +0 -1
- package/gui/src/components/AddRepoPicker.tsx +0 -81
- package/gui/src/components/ui/Button.tsx +0 -40
- package/gui/src/components/ui/Card.tsx +0 -6
- package/gui/src/components/ui/EmptyState.tsx +0 -22
- package/gui/src/components/ui/Input.tsx +0 -21
- package/gui/src/components/ui/Menu.tsx +0 -71
- package/gui/src/components/ui/Modal.tsx +0 -39
- package/gui/src/components/ui/PageHeader.tsx +0 -21
- package/gui/src/components/ui/RepoStatusStrip.tsx +0 -33
- package/gui/src/components/ui/Skeleton.tsx +0 -5
- package/gui/src/components/ui/StatusPill.tsx +0 -36
- package/gui/src/components/ui/Tabs.tsx +0 -40
- package/gui/src/components/ui/cn.ts +0 -4
- package/gui/src/components/ui/index.ts +0 -16
- package/gui/src/features/changes/ChangesViewer.tsx +0 -388
- package/gui/src/features/knowledge/KnowledgeBase.tsx +0 -84
- package/gui/src/features/onboarding/OnboardingWizard.tsx +0 -230
- package/gui/src/features/plan/ImplementationPlan.tsx +0 -32
- package/gui/src/features/services/ServiceConsole.tsx +0 -215
- package/gui/src/features/sessions/SessionHistory.tsx +0 -195
- package/gui/src/index.css +0 -167
- package/gui/src/lib/status.ts +0 -24
- package/gui/src/main.tsx +0 -94
- package/gui/src/pages/DashboardPage.tsx +0 -129
- package/gui/src/pages/WorkspacesPage.tsx +0 -352
- package/gui/src/types.ts +0 -81
- package/gui/tsconfig.app.json +0 -25
- package/gui/tsconfig.json +0 -7
- package/gui/tsconfig.node.json +0 -24
- package/gui/vite.config.ts +0 -12
- package/resources/workflows/plan-implement-review.md +0 -8
- package/resources/workflows/research-verify.md +0 -6
- package/resources/workflows/solo-developer.md +0 -3
- package/scripts/simulate-workspaces.ts +0 -55
- package/skills-lock.json +0 -11
- package/src/analyzers/detect-apis.ts +0 -290
- package/src/analyzers/detect-deps.ts +0 -315
- package/src/analyzers/detect-existing.ts +0 -74
- package/src/analyzers/detect-ports.ts +0 -110
- package/src/analyzers/index.ts +0 -97
- package/src/analyzers/messaging-analyzer.ts +0 -254
- package/src/analyzers/readme-summarizer.ts +0 -102
- package/src/analyzers/run-analyzer.ts +0 -269
- package/src/analyzers/tech-stack.ts +0 -283
- package/src/commands/adapter.ts +0 -348
- package/src/commands/add-repo.ts +0 -156
- package/src/commands/commands.test.ts +0 -156
- package/src/commands/commit.ts +0 -131
- package/src/commands/config.ts +0 -52
- package/src/commands/create.ts +0 -204
- package/src/commands/desktop.ts +0 -128
- package/src/commands/diff.ts +0 -125
- package/src/commands/doctor.ts +0 -370
- package/src/commands/handoff.ts +0 -266
- package/src/commands/init.ts +0 -134
- package/src/commands/list.ts +0 -46
- package/src/commands/logs.ts +0 -63
- package/src/commands/mcp.ts +0 -94
- package/src/commands/open.ts +0 -129
- package/src/commands/refresh.ts +0 -137
- package/src/commands/remove.ts +0 -98
- package/src/commands/start.ts +0 -117
- package/src/commands/status.ts +0 -54
- package/src/commands/stop.ts +0 -55
- package/src/commands/sync.ts +0 -125
- package/src/commands/tui.ts +0 -484
- package/src/commands/ui.ts +0 -111
- package/src/core/adapters/local-storage.ts +0 -66
- package/src/core/adapters/obsidian-storage.ts +0 -151
- package/src/core/adapters/registry.ts +0 -44
- package/src/core/adapters/storage.test.ts +0 -174
- package/src/core/adapters/vault-storage.ts +0 -86
- package/src/core/config.test.ts +0 -96
- package/src/core/config.ts +0 -140
- package/src/core/graph.ts +0 -344
- package/src/core/plugins/index.ts +0 -17
- package/src/core/plugins/loader.ts +0 -36
- package/src/core/ports/storage.ts +0 -71
- package/src/core/scanner.test.ts +0 -61
- package/src/core/scanner.ts +0 -91
- package/src/core/storage.ts +0 -37
- package/src/core/sync.ts +0 -121
- package/src/core/workspace-state.test.ts +0 -108
- package/src/core/workspace-state.ts +0 -130
- package/src/core/workspace.ts +0 -487
- package/src/core/worktree.ts +0 -120
- package/src/generators/antigravity.ts +0 -32
- package/src/generators/base.ts +0 -243
- package/src/generators/claude.ts +0 -34
- package/src/generators/codex.ts +0 -48
- package/src/generators/copilot.ts +0 -56
- package/src/generators/cursor.ts +0 -44
- package/src/generators/diff-context.ts +0 -75
- package/src/generators/index.ts +0 -322
- package/src/generators/map-generator.test.ts +0 -159
- package/src/generators/map-generator.ts +0 -539
- package/src/generators/plan-generator.ts +0 -483
- package/src/generators/skills-generator.ts +0 -259
- package/src/index.ts +0 -539
- package/src/mcp/server.ts +0 -338
- package/src/orchestration/detect.ts +0 -313
- package/src/orchestration/index.ts +0 -7
- package/src/orchestration/runner.ts +0 -283
- package/src/server.test.ts +0 -618
- package/src/server.ts +0 -1402
- package/src/types.ts +0 -451
- package/src/utils/detect-ai.test.ts +0 -44
- package/src/utils/detect-ai.ts +0 -84
- package/src/utils/detect-editors.test.ts +0 -48
- package/src/utils/detect-editors.ts +0 -57
- package/src/utils/git.test.ts +0 -74
- package/src/utils/git.ts +0 -117
- package/src/utils/local-ai.test.ts +0 -130
- package/src/utils/local-ai.ts +0 -116
- package/src/utils/multi-git.test.ts +0 -158
- package/src/utils/multi-git.ts +0 -405
- package/src/utils/prompts.ts +0 -209
- package/src/utils/session-finder.ts +0 -483
- package/src/utils/system-scanner.test.ts +0 -89
- package/src/utils/system-scanner.ts +0 -96
- package/src/utils/update-check.ts +0 -286
- package/src/utils/workflow-advisor.ts +0 -118
- package/src/utils/workflows.test.ts +0 -114
- package/src/utils/workflows.ts +0 -178
- package/tsconfig.json +0 -19
- 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
|
-
}
|
package/src/core/config.test.ts
DELETED
|
@@ -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
|
-
});
|
package/src/core/config.ts
DELETED
|
@@ -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
|
-
}
|