feat: default the data directory to ~/.waggle-community (P1.3c)

The community edition defaulted to ~/.waggle, the data directory of the
commercial Waggle, so both editions would open the same config, vault,
waggle.db, marketplace catalog and skills. Default to
~/.waggle-community instead (ADR-0011). WAGGLE_DATA_DIR still overrides
it wherever it did; nothing is migrated from ~/.waggle.

The name is defined once as DEFAULT_DATA_DIR_NAME and
DEFAULT_DATA_DIR_LABEL in @waggle/shared, with defaultDataDir() in
@waggle/core for the sidecar, the CLI, the agent and the model caches.
The marketplace installs on its own without workspace packages, so it
keeps a copy in its data-dir.ts; the CLI help, which loads no
dependency, spells the path out and its runtime test checks it.

The marketplace security scan also flags skills that reference the new
skills folder. Tests that asserted the old default now use the
constant, and comments name the new directory.
This commit is contained in:
shumeiko.it
2026-11-04 10:31:20 +01:00
parent 120640780c
commit b275f0bf89
72 changed files with 217 additions and 170 deletions

View File

@@ -1,7 +1,7 @@
/**
* D11 (UX-Refactor P4) — dataDir resolution.
*
* - resolveDataDir: explicit option > WAGGLE_DATA_DIR env > ~/.waggle. Before
* - resolveDataDir: explicit option > WAGGLE_DATA_DIR env > ~/.waggle-community. Before
* D11, startService ignored the env var while local/index.ts and the
* marketplace installer honored it — a custom install split
* its state across two directories.
@@ -10,6 +10,7 @@ import { describe, it, expect, afterEach, vi } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { DEFAULT_DATA_DIR_NAME } from '@waggle/shared';
import { startService, resolveDataDir } from '../src/local/service.js';
import type { FastifyInstance } from 'fastify';
@@ -36,14 +37,15 @@ describe('resolveDataDir (D11)', () => {
expect(resolveDataDir()).toBe('D:/from-env');
});
it('defaults to ~/.waggle with neither', () => {
it('defaults to ~/.waggle-community with neither, never the commercial ~/.waggle (ADR-0011)', () => {
delete process.env[ENV_KEY];
expect(resolveDataDir()).toBe(path.join(os.homedir(), '.waggle'));
expect(resolveDataDir()).toBe(path.join(os.homedir(), DEFAULT_DATA_DIR_NAME));
expect(resolveDataDir()).not.toBe(path.join(os.homedir(), '.waggle'));
});
it('a set-but-EMPTY env var falls through to the default (never an empty dataDir)', () => {
process.env[ENV_KEY] = '';
expect(resolveDataDir()).toBe(path.join(os.homedir(), '.waggle'));
expect(resolveDataDir()).toBe(path.join(os.homedir(), DEFAULT_DATA_DIR_NAME));
});
});
@@ -72,7 +74,7 @@ describe('startService honors WAGGLE_DATA_DIR (D11 integration)', () => {
const result = await startService({ port, skipLiteLLM: true });
server = result.server;
// The env-pointed dir got the install, ~/.waggle got nothing new from us.
// The env-pointed dir got the install, ~/.waggle-community got nothing new from us.
expect(fs.existsSync(path.join(envDir, 'waggle.db'))).toBe(true);
expect(server.localConfig.dataDir).toBe(envDir);