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

@@ -14,6 +14,7 @@
* waggle-market info <name|id> Show package details
*/
import { DATA_DIR_NAME } from './data-dir.js';
import { MarketplaceDB } from './db.js';
import { MarketplaceInstaller } from './installer.js';
import { MarketplaceSync } from './sync.js';
@@ -412,7 +413,7 @@ async function main() {
// Show current config
const gate = new SecurityGate();
console.log('\n🔧 Security Configuration:');
console.log(' (edit ~/.waggle/security-config.json or use waggle-market security-config <key> <value>)');
console.log(` (edit ~/${DATA_DIR_NAME}/security-config.json or use waggle-market security-config <key> <value>)`);
// Would read from security_config table
} else if (positionals.length >= 2) {
console.log(` Set ${positionals[0]} = ${positionals[1]}`);

View File

@@ -0,0 +1,8 @@
/**
* The default data directory under the home directory, kept apart from the
* commercial Waggle's `~/.waggle` (ADR-0011). A temporary name: the final one
* follows the product-name decision (Q8). The marketplace installs on its own,
* without the workspace packages, so this copies `DEFAULT_DATA_DIR_NAME` from
* `@waggle/shared`; `packages/shared/tests/data-dir.test.ts` checks they match.
*/
export const DATA_DIR_NAME = '.waggle-community';

View File

@@ -8,6 +8,7 @@
import Database from 'better-sqlite3';
import { join } from 'path';
import { homedir } from 'os';
import { DATA_DIR_NAME } from './data-dir.js';
import { seedMcpServers } from './mcp-registry.js';
import type {
MarketplacePackage,
@@ -21,7 +22,7 @@ import type {
SearchSort,
} from './types.js';
const DEFAULT_DB_PATH = join(homedir(), '.waggle', 'marketplace.db');
const DEFAULT_DB_PATH = join(homedir(), DATA_DIR_NAME, 'marketplace.db');
export class MarketplaceDB {
private db: Database.Database;

View File

@@ -2,14 +2,14 @@
* Waggle Marketplace — Package Installer
*
* Handles installation of skills, plugins, and MCP servers from the
* marketplace database into the user's ~/.waggle/ directory.
* marketplace database into the user's data directory (~/.waggle-community/).
*
* Installation strategies per type:
*
* SKILL: Download/copy markdown file → ~/.waggle/skills/{name}.md
* SKILL: Download/copy markdown file → ~/.waggle-community/skills/{name}.md
* Then call PUT /api/skills/{name} if server is running.
*
* PLUGIN: Clone/download plugin dir → ~/.waggle/plugins/{name}/
* PLUGIN: Clone/download plugin dir → ~/.waggle-community/plugins/{name}/
* Write plugin.json manifest, copy skill files, register in registry.json.
* Then call POST /api/plugins/install if server is running.
*
@@ -19,6 +19,7 @@
import { existsSync, mkdirSync, writeFileSync, readFileSync, copyFileSync, rmSync } from 'fs';
import { join, dirname, resolve } from 'path';
import { homedir } from 'os';
import { DATA_DIR_NAME } from './data-dir.js';
import { createHash } from 'node:crypto';
import { MarketplaceDB } from './db.js';
import { SecurityGate, type ScanResult, type SecurityGateConfig } from './security.js';
@@ -44,7 +45,7 @@ import type {
PluginManifest,
} from './types.js';
const WAGGLE_DIR = join(homedir(), '.waggle');
const WAGGLE_DIR = join(homedir(), DATA_DIR_NAME);
const SKILLS_DIR = join(WAGGLE_DIR, 'skills');
const PLUGINS_DIR = join(WAGGLE_DIR, 'plugins');
const REGISTRY_PATH = join(PLUGINS_DIR, 'registry.json');
@@ -82,7 +83,7 @@ function isPluginRegistryPath(candidate: string): boolean {
}
// UX-Refactor Phase 4 (C4): the sidecar boot loader reads <dataDir>/.mcp.json
// (dataDir = WAGGLE_DATA_DIR or ~/.waggle — see server local/mcp-config.ts).
// (dataDir = WAGGLE_DATA_DIR or ~/.waggle-community — see server local/mcp-config.ts).
// This previously wrote to process.cwd(), a file nothing ever read.
// Resolved at CALL time (not module import) so a host that sets
// WAGGLE_DATA_DIR after this module loads still writes to the right place.

View File

@@ -21,6 +21,7 @@
import { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync } from 'fs';
import { join, dirname } from 'path';
import { homedir } from 'os';
import { DATA_DIR_NAME } from './data-dir.js';
import { execFileSync } from 'child_process';
import { createHash } from 'crypto';
import type { MarketplacePackage, InstallManifest, McpServerConfig } from './types.js';
@@ -180,7 +181,7 @@ const DEFAULT_CONFIG: SecurityGateConfig = {
allow_force_bypass: false,
gen_trust_hub_url: 'https://ai.gendigital.com/api/scan/lookup',
cisco_scanner_args: ['--use-behavioral', '--format', 'json'],
cache_dir: join(homedir(), '.waggle', 'security-cache'),
cache_dir: join(homedir(), DATA_DIR_NAME, 'security-cache'),
cache_ttl_hours: 24,
};
@@ -1108,6 +1109,7 @@ export class SecurityGate {
const crossOrigin = [
/~\/\.claude\/(?:skills|plugins|hooks|commands)/i,
/~\/\.waggle\/skills/i,
new RegExp(`~/${DATA_DIR_NAME.replace(/\./g, '\\.')}/skills`, 'i'),
/CLAUDE\.md/i,
/\.cursorrules/i,
/write.*(?:CLAUDE\.md|\.cursorrules|settings\.json|hooks\/)/i,