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

@@ -7,6 +7,8 @@
* waggle --help Show help
*/
// Help loads no dependency (see cli-runtime.test.ts), so the default data
// directory is spelled out here; that test checks it matches DEFAULT_DATA_DIR_LABEL.
function printHelp(): void {
console.log(`
Waggle CLI — interactive AI agent with persistent memory
@@ -17,7 +19,7 @@ Usage:
waggle --help Show this help message
Configuration:
Edit ~/.waggle/config.json to set up providers and API keys.
Edit ~/.waggle-community/config.json to set up providers and API keys.
Commands (inside REPL):
/model <name> Switch model

View File

@@ -7,10 +7,9 @@
*/
import readline from 'node:readline';
import os from 'node:os';
import path from 'node:path';
import chalk from 'chalk';
import { WaggleConfig, WaggleDB, createMemoryEmbedder } from '@waggle/core';
import { WaggleConfig, WaggleDB, createMemoryEmbedder, defaultDataDir, DEFAULT_DATA_DIR_LABEL } from '@waggle/core';
import { PERSONAL_SCOPE } from '@waggle/memory-contract';
import { createMem0MemoryStore } from '@waggle/memory-mem0';
import { Orchestrator, ModelRouter, runAgentLoop, createSystemTools, createPlanTools, createGitTools, Workspace, ensureIdentity, loadSystemPromptWithOverrides, loadSkills, CostTracker, HookRegistry, loadHooksFromConfig, needsConfirmation } from '@waggle/agent';
@@ -44,20 +43,20 @@ export async function startRepl(options: ReplOptions = {}): Promise<void> {
const workspace = new Workspace(process.cwd());
workspace.init();
// Load user customizations from ~/.waggle/.
const waggleHome = path.join(os.homedir(), '.waggle');
// Load user customizations from the data directory.
const waggleHome = defaultDataDir();
const composedPrompt = loadSystemPromptWithOverrides(waggleHome);
const userSystemPrompt = composedPrompt.userPromptMd;
const skills = loadSkills(waggleHome);
// Load user-configurable hooks from ~/.waggle/hooks.json
// Load user-configurable hooks from <data dir>/hooks.json
const hookRegistry = new HookRegistry();
await loadHooksFromConfig(path.join(waggleHome, 'hooks.json'), hookRegistry);
// The proxy for non-local models; local ollama/* models skip it (model-endpoint.ts).
const wsConfig = workspace.getConfig();
// Memory: the same store the desktop app uses (ADR-0007), in ~/.waggle/memory.
// Memory: the same store the desktop app uses (ADR-0007), in <data dir>/memory.
const memory = await createMem0MemoryStore({
directory: path.join(waggleHome, 'memory'),
embedder: createMemoryEmbedder({ cacheDir: path.join(waggleHome, 'models') }),
@@ -176,7 +175,7 @@ export async function startRepl(options: ReplOptions = {}): Promise<void> {
console.log(chalk.dim(' ') + chalk.cyan(m) + marker);
}
if (models.length === 0) {
console.log(chalk.dim(' No models configured. Edit ~/.waggle/config.json'));
console.log(chalk.dim(` No models configured. Edit ${DEFAULT_DATA_DIR_LABEL}/config.json`));
}
console.log('');
break;
@@ -333,9 +332,9 @@ When asked about current events, products, releases, docs, or anything you're no
const errMsg = (err as Error).message;
if (errMsg.includes('Unknown model')) {
console.log(chalk.red(`Model "${currentModel}" is not configured.`));
console.log(chalk.dim('Run /models to see available models, or edit ~/.waggle/config.json'));
console.log(chalk.dim(`Run /models to see available models, or edit ${DEFAULT_DATA_DIR_LABEL}/config.json`));
} else if (errMsg.includes('API key') || errMsg.includes('authentication') || errMsg.includes('401')) {
console.log(chalk.red('Authentication failed. Check your API key in ~/.waggle/config.json'));
console.log(chalk.red(`Authentication failed. Check your API key in ${DEFAULT_DATA_DIR_LABEL}/config.json`));
} else {
console.log(chalk.red(`Error: ${errMsg}`));
}

View File

@@ -8,6 +8,7 @@ import type { AddressInfo } from 'node:net';
import os from 'node:os';
import path from 'node:path';
import { describe, expect, it } from 'vitest';
import { DEFAULT_DATA_DIR_LABEL, DEFAULT_DATA_DIR_NAME } from '@waggle/shared';
const ROOT = path.resolve(import.meta.dirname, '..', '..', '..');
const CLI_DIR = path.join(ROOT, 'packages', 'cli');
@@ -242,8 +243,9 @@ describe('@waggle/cli runtime UX', () => {
expect(result.status).toBe(0);
expect(result.stdout).toContain('Waggle CLI');
expect(result.stdout).toContain('Usage:');
expect(result.stdout).toContain(`${DEFAULT_DATA_DIR_LABEL}/config.json`);
expect(result.stderr).toBe('');
expect(fs.existsSync(path.join(home, '.waggle'))).toBe(false);
expect(fs.existsSync(path.join(home, DEFAULT_DATA_DIR_NAME))).toBe(false);
} finally {
fs.rmSync(home, { recursive: true, force: true });
}
@@ -281,7 +283,7 @@ describe('@waggle/cli runtime UX', () => {
expect(result.stdout).toContain('Waggle CLI');
expect(result.stdout).toContain('Usage:');
expect(result.stderr).toBe('');
expect(fs.existsSync(path.join(home, '.waggle'))).toBe(false);
expect(fs.existsSync(path.join(home, DEFAULT_DATA_DIR_NAME))).toBe(false);
} finally {
fs.rmSync(home, { recursive: true, force: true });
}
@@ -399,7 +401,7 @@ describe('@waggle/cli runtime UX', () => {
expect(result.stdout).toContain('Waggle CLI');
expect(result.stdout).toContain('Usage:');
expect(result.stderr).toBe('');
expect(fs.existsSync(path.join(home, '.waggle'))).toBe(false);
expect(fs.existsSync(path.join(home, DEFAULT_DATA_DIR_NAME))).toBe(false);
} finally {
fs.rmSync(home, { recursive: true, force: true });
}
@@ -505,9 +507,11 @@ describe('@waggle/cli runtime UX', () => {
expect(stdout).toContain('Goodbye!');
expect(stderr).not.toContain('Fatal error');
// Memory (mem0) and Waggle's own database live in the data directory (ADR-0007).
expect(fs.existsSync(path.join(home, '.waggle', 'memory', 'waggle-memory.json'))).toBe(true);
expect(fs.existsSync(path.join(home, '.waggle', 'waggle.db'))).toBe(true);
expect(fs.existsSync(path.join(home, '.waggle', 'default.mind'))).toBe(false);
expect(fs.existsSync(path.join(home, DEFAULT_DATA_DIR_NAME, 'memory', 'waggle-memory.json'))).toBe(true);
expect(fs.existsSync(path.join(home, DEFAULT_DATA_DIR_NAME, 'waggle.db'))).toBe(true);
expect(fs.existsSync(path.join(home, DEFAULT_DATA_DIR_NAME, 'default.mind'))).toBe(false);
// ADR-0011: the commercial edition's directory stays untouched.
expect(fs.existsSync(path.join(home, '.waggle'))).toBe(false);
} finally {
if (child) await stopProcess(child);
fs.rmSync(home, { recursive: true, force: true });
@@ -564,7 +568,7 @@ describe('@waggle/cli runtime UX', () => {
}
mockLiteLlm = await startMockLiteLlm();
const waggleHome = path.join(home, '.waggle');
const waggleHome = path.join(home, DEFAULT_DATA_DIR_NAME);
const workspaceConfigDir = path.join(projectDir, '.waggle');
fs.mkdirSync(waggleHome, { recursive: true });
fs.mkdirSync(workspaceConfigDir, { recursive: true });