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:
@@ -1,6 +1,7 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import { DEFAULT_DATA_DIR_NAME } from '@waggle/shared';
|
||||
import type { EmbeddingProviderConfig, EmbeddingProviderType } from './embeddings/embedding-provider.js';
|
||||
|
||||
export interface ProviderEntry {
|
||||
@@ -14,7 +15,8 @@ export interface CliConfig {
|
||||
}
|
||||
|
||||
// Keys the commercial edition writes (tier, trialStartedAt, teamServer) are not
|
||||
// read here but stay in config.json on save: both editions may share ~/.waggle.
|
||||
// read here but stay in config.json on save, in case a user points both
|
||||
// editions at one data directory with WAGGLE_DATA_DIR.
|
||||
interface ConfigData {
|
||||
defaultModel: string;
|
||||
providers: Record<string, ProviderEntry>;
|
||||
@@ -72,9 +74,17 @@ function getNonBlankEnv(name: string): string | undefined {
|
||||
return process.env[name]?.trim() || undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default data directory, `~/.waggle-community` (ADR-0011). Callers that
|
||||
* honor WAGGLE_DATA_DIR check it before falling back to this.
|
||||
*/
|
||||
export function defaultDataDir(): string {
|
||||
return path.join(os.homedir(), DEFAULT_DATA_DIR_NAME);
|
||||
}
|
||||
|
||||
function getDefaultConfigDir(): string {
|
||||
const home = process.env.HOME || process.env.USERPROFILE || os.homedir();
|
||||
return path.join(home, '.waggle');
|
||||
return path.join(home, DEFAULT_DATA_DIR_NAME);
|
||||
}
|
||||
|
||||
export class WaggleConfig {
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
* In-process embedder using @huggingface/transformers (ONNX Runtime).
|
||||
* Default provider for ALL desktop users — zero config, works offline.
|
||||
* Model: Xenova/all-MiniLM-L6-v2 (384 native dims, normalized to target dims).
|
||||
* Downloads ~90MB fp32 model on first use, cached in ~/.waggle/models/.
|
||||
* Downloads ~90MB fp32 model on first use, cached in <data dir>/models/.
|
||||
*/
|
||||
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import { defaultDataDir } from '../config.js';
|
||||
import { createLazyEmbedder, type Embedder } from './embeddings.js';
|
||||
import { createCoreLogger } from '../logger.js';
|
||||
import { withTransformersModelLoad } from './transformers-model-load.js';
|
||||
@@ -32,7 +32,7 @@ export function normalizeDimensions(embedding: Float32Array, targetDims: number)
|
||||
|
||||
export async function createInProcessEmbedder(config?: Partial<InProcessEmbedderConfig>): Promise<Embedder> {
|
||||
const model = config?.model ?? DEFAULT_MODEL;
|
||||
const cacheDir = config?.cacheDir ?? path.join(os.homedir(), '.waggle', 'models');
|
||||
const cacheDir = config?.cacheDir ?? path.join(defaultDataDir(), 'models');
|
||||
const targetDims = config?.targetDimensions ?? 1024;
|
||||
|
||||
log.info(`Loading in-process embedding model: ${model} (~90MB fp32 first download)`);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Provides a clean interface for reading/writing workspace files that abstracts
|
||||
* over the underlying storage backend. Two implementations:
|
||||
*
|
||||
* - LocalFileStore: manages files in ~/.waggle/workspaces/{id}/files/ (virtual storage)
|
||||
* - LocalFileStore: manages files in ~/.waggle-community/workspaces/{id}/files/ (virtual storage)
|
||||
* - LinkedDirStore: reads/writes to workspace.directory (linked to external folder)
|
||||
*
|
||||
* All operations enforce path traversal protection — files cannot escape
|
||||
|
||||
@@ -54,7 +54,8 @@ export {
|
||||
} from './execution-traces.js';
|
||||
|
||||
// ── Waggle-specific orchestration ──
|
||||
export { WaggleConfig, type ProviderEntry } from './config.js';
|
||||
export { WaggleConfig, defaultDataDir, type ProviderEntry } from './config.js';
|
||||
export { DEFAULT_DATA_DIR_NAME, DEFAULT_DATA_DIR_LABEL } from '@waggle/shared';
|
||||
export {
|
||||
CronStore, CRON_SCHEDULES_TABLE_SQL, CRON_RUN_LEASES_TABLE_SQL, VALID_JOB_TYPES, cronExprError,
|
||||
type CronSchedule, type CreateScheduleInput, type CronJobType,
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import { defaultDataDir } from '../config.js';
|
||||
import { createCoreLogger } from '../logger.js';
|
||||
import { withTransformersModelLoad } from '../embeddings/transformers-model-load.js';
|
||||
|
||||
@@ -53,7 +53,7 @@ export async function createInProcessReranker(
|
||||
config?: Partial<InProcessRerankerConfig>,
|
||||
): Promise<Reranker> {
|
||||
const model = config?.model ?? 'Xenova/ms-marco-MiniLM-L-6-v2';
|
||||
const cacheDir = config?.cacheDir ?? path.join(os.homedir(), '.waggle', 'models');
|
||||
const cacheDir = config?.cacheDir ?? path.join(defaultDataDir(), 'models');
|
||||
|
||||
log.info(`Loading in-process reranker: ${model} (~22MB first download)`);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* TelemetryStore — local, privacy-first event tracking.
|
||||
*
|
||||
* All data stays in ~/.waggle/telemetry.db (SQLite).
|
||||
* All data stays in ~/.waggle-community/telemetry.db (SQLite).
|
||||
* Default: OFF. User opts in via Settings toggle.
|
||||
* No cloud reporting in M2 — data is queryable via local API only.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user