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:
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { DATA_DIR_NAME } from '../src/data-dir.js';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dirname, '..', '..', '..');
|
||||
const MARKETPLACE_DIR = path.join(ROOT, 'packages', 'marketplace');
|
||||
@@ -50,7 +51,7 @@ function run(
|
||||
}
|
||||
|
||||
function marketplaceDbExists(home: string): boolean {
|
||||
return fs.existsSync(path.join(home, '.waggle', 'marketplace.db'));
|
||||
return fs.existsSync(path.join(home, DATA_DIR_NAME, 'marketplace.db'));
|
||||
}
|
||||
|
||||
function readPackageJson(): {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { homedir, tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import { afterAll, afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { DATA_DIR_NAME } from '../src/data-dir.js';
|
||||
import { MarketplaceInstaller } from '../src/installer.js';
|
||||
import {
|
||||
assertSafeGitUrl,
|
||||
@@ -188,8 +189,8 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
|
||||
it('rejects a caller-selected skill path inside the managed directory without overwriting it', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const managedPath = join(isolatedHome, '.waggle', 'skills', 'existing.md');
|
||||
mkdirSync(join(isolatedHome, '.waggle', 'skills'), { recursive: true });
|
||||
const managedPath = join(isolatedHome, DATA_DIR_NAME, 'skills', 'existing.md');
|
||||
mkdirSync(join(isolatedHome, DATA_DIR_NAME, 'skills'), { recursive: true });
|
||||
writeFileSync(managedPath, '# keep', 'utf8');
|
||||
const { installer, recordInstallation } = installerFor(packageFixture());
|
||||
|
||||
@@ -203,7 +204,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('does not clean up a pre-existing plugin directory when a forced reinstall fails', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `existing-plugin-${randomUUID()}`;
|
||||
const pluginDir = join(isolatedHome, '.waggle', 'plugins', name);
|
||||
const pluginDir = join(isolatedHome, DATA_DIR_NAME, 'plugins', name);
|
||||
const sentinel = join(pluginDir, 'keep.txt');
|
||||
mkdirSync(pluginDir, { recursive: true });
|
||||
writeFileSync(sentinel, 'keep', 'utf8');
|
||||
@@ -226,8 +227,8 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
|
||||
it('does not delete the plugin registry when a package name collides with it', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const registryPath = join(isolatedHome, '.waggle', 'plugins', 'registry.json');
|
||||
mkdirSync(join(isolatedHome, '.waggle', 'plugins'), { recursive: true });
|
||||
const registryPath = join(isolatedHome, DATA_DIR_NAME, 'plugins', 'registry.json');
|
||||
mkdirSync(join(isolatedHome, DATA_DIR_NAME, 'plugins'), { recursive: true });
|
||||
writeFileSync(registryPath, '{"keep":true}', 'utf8');
|
||||
const { installer, recordInstallation } = installerFor(packageFixture({
|
||||
name: 'registry.json',
|
||||
@@ -245,8 +246,8 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
|
||||
it('rejects a case-insensitive alias of the reserved plugin registry path', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const registryPath = join(isolatedHome, '.waggle', 'plugins', 'registry.json');
|
||||
mkdirSync(join(isolatedHome, '.waggle', 'plugins'), { recursive: true });
|
||||
const registryPath = join(isolatedHome, DATA_DIR_NAME, 'plugins', 'registry.json');
|
||||
mkdirSync(join(isolatedHome, DATA_DIR_NAME, 'plugins'), { recursive: true });
|
||||
writeFileSync(registryPath, '{"keep":true}', 'utf8');
|
||||
const { installer, recordInstallation } = installerFor(packageFixture({
|
||||
name: 'REGISTRY.JSON',
|
||||
@@ -266,7 +267,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('rejects a traversal identifier before a plugin can escape the plugins directory', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const escapedName = `escaped-${randomUUID()}`;
|
||||
const escapedPath = join(homedir(), '.waggle', escapedName);
|
||||
const escapedPath = join(homedir(), DATA_DIR_NAME, escapedName);
|
||||
cleanupPaths.push(escapedPath);
|
||||
const { installer, recordInstallation } = installerFor(packageFixture({
|
||||
name: `../${escapedName}`,
|
||||
@@ -285,7 +286,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('rejects an uncurated plugin git selector before clone execution', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `git-plugin-${randomUUID()}`;
|
||||
cleanupPaths.push(join(homedir(), '.waggle', 'plugins', name));
|
||||
cleanupPaths.push(join(homedir(), DATA_DIR_NAME, 'plugins', name));
|
||||
const { installer } = installerFor(packageFixture({
|
||||
name,
|
||||
package_type: 'plugin',
|
||||
@@ -303,7 +304,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('rejects a plugin git URL containing shell syntax before process launch', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `git-injection-${randomUUID()}`;
|
||||
cleanupPaths.push(join(homedir(), '.waggle', 'plugins', name));
|
||||
cleanupPaths.push(join(homedir(), DATA_DIR_NAME, 'plugins', name));
|
||||
const { installer } = installerFor(packageFixture({
|
||||
name,
|
||||
package_type: 'plugin',
|
||||
@@ -321,7 +322,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('rejects an uncurated plugin npm selector before lifecycle-script execution', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `npm-plugin-${randomUUID()}`;
|
||||
cleanupPaths.push(join(homedir(), '.waggle', 'plugins', name));
|
||||
cleanupPaths.push(join(homedir(), DATA_DIR_NAME, 'plugins', name));
|
||||
const { installer } = installerFor(packageFixture({
|
||||
name,
|
||||
package_type: 'plugin',
|
||||
@@ -345,7 +346,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
});
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
const name = `bundled-skill-${randomUUID()}`;
|
||||
const pluginDir = join(homedir(), '.waggle', 'plugins', name);
|
||||
const pluginDir = join(homedir(), DATA_DIR_NAME, 'plugins', name);
|
||||
cleanupPaths.push(pluginDir);
|
||||
const { installer, getPackageByName, recordInstallation } = installerFor(packageFixture({
|
||||
name,
|
||||
@@ -378,7 +379,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('preserves installation of inline skill content', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `inline-skill-${randomUUID()}`;
|
||||
const skillPath = join(homedir(), '.waggle', 'skills', `${name}.md`);
|
||||
const skillPath = join(homedir(), DATA_DIR_NAME, 'skills', `${name}.md`);
|
||||
cleanupPaths.push(skillPath);
|
||||
const { installer } = installerFor(packageFixture({
|
||||
name,
|
||||
@@ -394,7 +395,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
|
||||
it('installs the exact remote skill bytes that passed the security scan', async () => {
|
||||
const name = `remote-skill-${randomUUID()}`;
|
||||
const skillPath = join(homedir(), '.waggle', 'skills', `${name}.md`);
|
||||
const skillPath = join(homedir(), DATA_DIR_NAME, 'skills', `${name}.md`);
|
||||
cleanupPaths.push(skillPath);
|
||||
const fetchMock = vi.fn()
|
||||
.mockResolvedValueOnce(new Response('# Benign scanned skill'))
|
||||
@@ -419,7 +420,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('rejects plugin npm package shell syntax before process launch', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `npm-injection-${randomUUID()}`;
|
||||
cleanupPaths.push(join(homedir(), '.waggle', 'plugins', name));
|
||||
cleanupPaths.push(join(homedir(), DATA_DIR_NAME, 'plugins', name));
|
||||
const { installer } = installerFor(packageFixture({
|
||||
name,
|
||||
package_type: 'plugin',
|
||||
@@ -458,7 +459,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('rejects custom npm_args instead of treating catalog metadata as npm options', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `npm-args-${randomUUID()}`;
|
||||
cleanupPaths.push(join(homedir(), '.waggle', 'plugins', name));
|
||||
cleanupPaths.push(join(homedir(), DATA_DIR_NAME, 'plugins', name));
|
||||
const { installer } = installerFor(packageFixture({
|
||||
name,
|
||||
package_type: 'plugin',
|
||||
@@ -479,7 +480,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
])('rejects a non-empty $type post-install array before any side effect', async hook => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `post-install-${randomUUID()}`;
|
||||
const pluginDir = join(homedir(), '.waggle', 'plugins', name);
|
||||
const pluginDir = join(homedir(), DATA_DIR_NAME, 'plugins', name);
|
||||
cleanupPaths.push(pluginDir);
|
||||
const { installer, recordInstallation } = installerFor(packageFixture({
|
||||
name,
|
||||
@@ -503,7 +504,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('preserves a plugin manifest containing an exact curated MCP profile', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `curated-mcp-plugin-${randomUUID()}`;
|
||||
const pluginDir = join(homedir(), '.waggle', 'plugins', name);
|
||||
const pluginDir = join(homedir(), DATA_DIR_NAME, 'plugins', name);
|
||||
cleanupPaths.push(pluginDir);
|
||||
const curatedMcp = MCP_SERVERS.find(server => server.name === 'memory')!
|
||||
.install_manifest!.mcp_config!;
|
||||
@@ -532,7 +533,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('maps an embedded plugin MCP setting only to its matching blank environment key', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const name = `brave-plugin-${randomUUID()}`;
|
||||
const pluginDir = join(homedir(), '.waggle', 'plugins', name);
|
||||
const pluginDir = join(homedir(), DATA_DIR_NAME, 'plugins', name);
|
||||
cleanupPaths.push(pluginDir);
|
||||
const braveConfig = MCP_SERVERS.find(server => server.name === 'brave-search')!
|
||||
.install_manifest!.mcp_config!;
|
||||
@@ -570,7 +571,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
|
||||
it('rejects undeclared plugin executable capabilities before writing plugin files', async () => {
|
||||
const name = `plugin-tools-${randomUUID()}`;
|
||||
const pluginDir = join(homedir(), '.waggle', 'plugins', name);
|
||||
const pluginDir = join(homedir(), DATA_DIR_NAME, 'plugins', name);
|
||||
cleanupPaths.push(pluginDir);
|
||||
const pluginManifest = {
|
||||
name,
|
||||
@@ -723,7 +724,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
|
||||
it('rejects an arbitrary launcher embedded in a marketplace plugin manifest', async () => {
|
||||
const name = `plugin-mcp-${randomUUID()}`;
|
||||
cleanupPaths.push(join(homedir(), '.waggle', 'plugins', name));
|
||||
cleanupPaths.push(join(homedir(), DATA_DIR_NAME, 'plugins', name));
|
||||
const { installer, recordInstallation } = installerFor(packageFixture({
|
||||
name,
|
||||
package_type: 'plugin',
|
||||
@@ -829,13 +830,13 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
|
||||
it('rejects an approved MCP manifest cloned under a noncanonical source', async () => {
|
||||
const brave = MCP_SERVERS.find(server => server.name === 'brave-search')!;
|
||||
const configPath = join(isolatedHome, '.waggle', '.mcp.json');
|
||||
const configPath = join(isolatedHome, DATA_DIR_NAME, '.mcp.json');
|
||||
const originalConfig = JSON.stringify({
|
||||
mcpServers: {
|
||||
existing: { command: 'existing-command', args: ['existing-arg'] },
|
||||
},
|
||||
});
|
||||
mkdirSync(join(isolatedHome, '.waggle'), { recursive: true });
|
||||
mkdirSync(join(isolatedHome, DATA_DIR_NAME), { recursive: true });
|
||||
writeFileSync(configPath, originalConfig, 'utf8');
|
||||
const customSource = sourceFixture({
|
||||
id: 77,
|
||||
@@ -983,7 +984,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
const scan = await installer.scanOnly(pkg.id);
|
||||
expect(scan).not.toBeNull();
|
||||
const expectedApprovalIdentity = MarketplaceInstaller.createApprovalIdentity(pkg, scan!);
|
||||
cleanupPaths.push(join(isolatedHome, '.waggle', 'skills', `${name}.md`));
|
||||
cleanupPaths.push(join(isolatedHome, DATA_DIR_NAME, 'skills', `${name}.md`));
|
||||
|
||||
const result = await installer.install({ packageId: pkg.id, expectedApprovalIdentity });
|
||||
|
||||
@@ -1102,7 +1103,7 @@ describe('MarketplaceInstaller security boundaries', () => {
|
||||
it('does not delete outside the plugins directory when uninstalling a traversal identifier', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('server offline')));
|
||||
const escapedName = `uninstall-sentinel-${randomUUID()}`;
|
||||
const escapedPath = join(homedir(), '.waggle', escapedName);
|
||||
const escapedPath = join(homedir(), DATA_DIR_NAME, escapedName);
|
||||
const sentinel = join(escapedPath, 'keep.txt');
|
||||
cleanupPaths.push(escapedPath);
|
||||
mkdirSync(escapedPath, { recursive: true });
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* sources are populated, URLs are well-formed, and sync results have
|
||||
* the correct shape.
|
||||
*
|
||||
* Uses a temporary SQLite database (not the real ~/.waggle/marketplace.db)
|
||||
* Uses a temporary SQLite database (not the real ~/.waggle-community/marketplace.db)
|
||||
* and mocks global fetch to avoid real network calls.
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user