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.
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import { afterEach, describe, expect, it } from 'vitest';
|
|
import Fastify, { type FastifyInstance } from 'fastify';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { documentRoutes } from '../../src/local/routes/documents.js';
|
|
import { pinRoutes } from '../../src/local/routes/pins.js';
|
|
|
|
/** UF-064: pins and documents follow the server's data directory, not ~/.waggle-community. */
|
|
describe('pins and documents storage', () => {
|
|
let server: FastifyInstance;
|
|
let dataDir: string;
|
|
|
|
async function buildServer(): Promise<FastifyInstance> {
|
|
dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-pins-docs-'));
|
|
const instance = Fastify({ logger: false });
|
|
instance.decorate('localConfig', { dataDir } as never);
|
|
await instance.register(pinRoutes);
|
|
await instance.register(documentRoutes);
|
|
await instance.ready();
|
|
return instance;
|
|
}
|
|
|
|
afterEach(async () => {
|
|
await server?.close();
|
|
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
});
|
|
|
|
it('writes pins.json and documents.json under the configured data directory', async () => {
|
|
server = await buildServer();
|
|
|
|
const pin = await server.inject({
|
|
method: 'POST',
|
|
url: '/api/workspaces/ws-one/pins',
|
|
payload: { messageContent: 'Keep this', messageRole: 'assistant' },
|
|
});
|
|
expect(pin.statusCode).toBeLessThan(300);
|
|
const doc = await server.inject({
|
|
method: 'POST',
|
|
url: '/api/workspaces/ws-one/documents',
|
|
payload: { name: 'plan', path: '/tmp/plan.md' },
|
|
});
|
|
expect(doc.statusCode).toBeLessThan(300);
|
|
|
|
expect(fs.existsSync(path.join(dataDir, 'workspaces', 'ws-one', 'pins.json'))).toBe(true);
|
|
expect(fs.existsSync(path.join(dataDir, 'workspaces', 'ws-one', 'documents.json'))).toBe(true);
|
|
|
|
const list = await server.inject({ method: 'GET', url: '/api/workspaces/ws-one/pins' });
|
|
expect(list.json().pins).toHaveLength(1);
|
|
});
|
|
});
|