diff --git a/packages/agent/src/custom-personas.ts b/packages/agent/src/custom-personas.ts index d0b0315..132a630 100644 --- a/packages/agent/src/custom-personas.ts +++ b/packages/agent/src/custom-personas.ts @@ -1,5 +1,5 @@ /** - * Custom Personas — user-created personas stored as JSON in ~/.waggle/personas/ + * Custom Personas — user-created personas stored as JSON in ~/.waggle-community/personas/ * Loaded at startup and merged with built-in PERSONAS. */ diff --git a/packages/agent/src/custom-workflows.ts b/packages/agent/src/custom-workflows.ts index 768feac..1fff559 100644 --- a/packages/agent/src/custom-workflows.ts +++ b/packages/agent/src/custom-workflows.ts @@ -1,5 +1,5 @@ /** - * Custom Workflows — user-created workflow templates stored as JSON in ~/.waggle/workflows/ + * Custom Workflows — user-created workflow templates stored as JSON in ~/.waggle-community/workflows/ */ import fs from 'node:fs'; diff --git a/packages/agent/src/hook-loader.ts b/packages/agent/src/hook-loader.ts index 042cd22..91b052b 100644 --- a/packages/agent/src/hook-loader.ts +++ b/packages/agent/src/hook-loader.ts @@ -14,7 +14,7 @@ interface HooksConfig { } /** - * Load user-configurable hooks from a JSON config file (e.g. ~/.waggle/hooks.json). + * Load user-configurable hooks from a JSON config file (e.g. ~/.waggle-community/hooks.json). * If the file doesn't exist, returns silently — no error. * * Config format: diff --git a/packages/agent/src/skill-audit-store.ts b/packages/agent/src/skill-audit-store.ts index b075c3f..04efdc2 100644 --- a/packages/agent/src/skill-audit-store.ts +++ b/packages/agent/src/skill-audit-store.ts @@ -1,7 +1,7 @@ /** * Skill-audit sidecar (Odysseus §D2). * - * ~/.waggle/skill-audit.json records the run-and-grade "verified" badge per + * ~/.waggle-community/skill-audit.json records the run-and-grade "verified" badge per * skill — the sellable PRO artifact of the autonomous skill-audit loop * (skill-audit.ts). DISTINCT from skill-hygiene.json (active|draft status): * a skill can be active AND unverified, or active AND verified. The audit diff --git a/packages/agent/src/skill-hygiene-store.ts b/packages/agent/src/skill-hygiene-store.ts index 72dafd9..1551272 100644 --- a/packages/agent/src/skill-hygiene-store.ts +++ b/packages/agent/src/skill-hygiene-store.ts @@ -1,7 +1,7 @@ /** * Skill hygiene sidecar (Odysseus §D1). * - * ~/.waggle/skill-hygiene.json records each skill's hygiene status + advisory. + * ~/.waggle-community/skill-hygiene.json records each skill's hygiene status + advisory. * The single-LLM-call judge (skill-hygiene.ts) writes here when a skill is found * redundant-with-peers or too-generic, DEMOTING it to 'draft'. It never edits or * deletes the SKILL.md, so the proven content and its change-detection hash never diff --git a/packages/agent/src/skill-redaction.ts b/packages/agent/src/skill-redaction.ts index 92782b2..6c95c4d 100644 --- a/packages/agent/src/skill-redaction.ts +++ b/packages/agent/src/skill-redaction.ts @@ -2,7 +2,7 @@ * Pre-write redaction for authored skill content. * * The closed-learning-loop (create_skill / auto_extract_skills) and the UI both - * persist skill markdown to disk (~/.waggle/skills). That content can carry + * persist skill markdown to disk (~/.waggle-community/skills). That content can carry * secrets (API keys / tokens) or machine-specific filesystem paths pulled from * the model's context or the user's input. The loop's "strip secrets/paths" * instruction was model-advisory only — this enforces it deterministically diff --git a/packages/agent/src/skill-retirement.ts b/packages/agent/src/skill-retirement.ts index 64af910..0e6b65a 100644 --- a/packages/agent/src/skill-retirement.ts +++ b/packages/agent/src/skill-retirement.ts @@ -3,7 +3,7 @@ * * Walks the personal-scope skill directory and moves any SKILL.md file * whose last-used timestamp (from skill-usage.json sidecar) is older than - * maxIdleDays into ~/.waggle/skills-archive/. Parallels the existing + * maxIdleDays into ~/.waggle-community/skills-archive/. Parallels the existing * decayFrames() behavior in packages/weaver/src/consolidation.ts. * * Retirement rules: diff --git a/packages/agent/src/skill-tools.ts b/packages/agent/src/skill-tools.ts index a85939e..2303365 100644 --- a/packages/agent/src/skill-tools.ts +++ b/packages/agent/src/skill-tools.ts @@ -39,7 +39,7 @@ import { autoExtractAndCreateSkill, type AutoExtractMessage } from './skill-auto import { retireStaleSkills } from './skill-retirement.js'; export interface SkillToolsDeps { - /** Path to ~/.waggle directory */ + /** Path to ~/.waggle-community directory */ waggleHome: string; /** Callback to reload skills into agent state after changes */ onSkillsChanged?: () => void; @@ -69,10 +69,10 @@ export interface SkillToolsDeps { /** * Skills 2.0 gap E: resolve the on-disk directory for a given scope. - * - personal: ~/.waggle/skills/ - * - workspace: ~/.waggle/workspaces/{workspaceId}/skills/ - * - team: ~/.waggle/teams/{teamId}/skills/ - * - enterprise: ~/.waggle/enterprise/skills/ + * - personal: ~/.waggle-community/skills/ + * - workspace: ~/.waggle-community/workspaces/{workspaceId}/skills/ + * - team: ~/.waggle-community/teams/{teamId}/skills/ + * - enterprise: ~/.waggle-community/enterprise/skills/ * * Returns null when the required context (workspaceId, teamId) is missing. */ @@ -849,7 +849,7 @@ Only use this after acquire_capability has identified a specific installable can name: 'retire_skills', description: 'Archive personal-scope skills that have not been used within the idle window. ' - + 'Moves stale SKILL.md files to ~/.waggle/skills-archive/ (recoverable — no deletion). ' + + 'Moves stale SKILL.md files to ~/.waggle-community/skills-archive/ (recoverable — no deletion). ' + 'Default max_idle_days is 90. Default dry_run is true — call with dry_run: false to ' + 'actually move the files.', parameters: { diff --git a/packages/agent/src/skill-usage.ts b/packages/agent/src/skill-usage.ts index ac43cf4..1e15641 100644 --- a/packages/agent/src/skill-usage.ts +++ b/packages/agent/src/skill-usage.ts @@ -1,7 +1,7 @@ /** * Skills 2.0 gap F — skill usage tracking. * - * Sidecar JSON store at ~/.waggle/skill-usage.json that tracks when each + * Sidecar JSON store at ~/.waggle-community/skill-usage.json that tracks when each * installed skill was last referenced and how many times. Consumed by * retireStaleSkills to decide which SKILL.md files to archive. * diff --git a/packages/agent/src/skill-write-service.ts b/packages/agent/src/skill-write-service.ts index 61546a8..ba367a8 100644 --- a/packages/agent/src/skill-write-service.ts +++ b/packages/agent/src/skill-write-service.ts @@ -21,7 +21,7 @@ import type { InstallAuditRecorder } from '@waggle/shared'; /** Shared deps for every skill-write op. auditStore/onChange degrade gracefully. */ export interface SkillWriteDeps { - /** Directory holding personal-scope SKILL.md files (~/.waggle/skills). */ + /** Directory holding personal-scope SKILL.md files (~/.waggle-community/skills). */ skillsDir: string; /** Audit store — when present, every op records an install_audit row. */ auditStore?: InstallAuditRecorder; diff --git a/packages/agent/src/tool-detection.ts b/packages/agent/src/tool-detection.ts index 35f6a11..8432f45 100644 --- a/packages/agent/src/tool-detection.ts +++ b/packages/agent/src/tool-detection.ts @@ -617,7 +617,7 @@ async function detectFromManifest(m: ToolManifest, deps: ResolvedDeps): Promise< /** * Run every registered tool's detector in parallel and assemble the envelope. * The registry = built-in manifests (source of truth in @waggle/shared) + - * validated third-party adapters from ~/.waggle/adapters/*.json (#5). Order is + * validated third-party adapters from ~/.waggle-community/adapters/*.json (#5). Order is * deterministic (registry order) so the UI doesn't shuffle between calls. */ export async function detectInstalledTools( diff --git a/packages/agent/src/tool-manifest-loader.ts b/packages/agent/src/tool-manifest-loader.ts index db5a5d3..7be8369 100644 --- a/packages/agent/src/tool-manifest-loader.ts +++ b/packages/agent/src/tool-manifest-loader.ts @@ -1,13 +1,13 @@ /** * AI-OS #5 — declarative loader for third-party tool adapters from - * ~/.waggle/adapters/*.json. Data only: hand-validated + safe-string-refined, + * ~/.waggle-community/adapters/*.json. Data only: hand-validated + safe-string-refined, * PATH-detection only, never require()/eval. Never throws into detection. * * Validation is hand-rolled (not zod) to avoid adding a dependency to the agent * package for one small flat schema; the safe-string refinement is the boundary * defense against shell-metachar / path-traversal injection in adapter fields. */ -import os from 'node:os'; +import { defaultDataDir } from '@waggle/core'; import path from 'node:path'; import fs from 'node:fs'; import type { ToolManifest } from '@waggle/shared'; @@ -58,7 +58,7 @@ export interface ManifestLoaderDeps { } export function loadThirdPartyManifests(deps: ManifestLoaderDeps = {}): ToolManifest[] { - const dir = deps.dir ?? path.join(os.homedir(), '.waggle', 'adapters'); + const dir = deps.dir ?? path.join(defaultDataDir(), 'adapters'); const readDir = deps.readDir ?? ((d) => fs.readdirSync(d)); const readFile = deps.readFile ?? ((p) => fs.readFileSync(p, 'utf8')); let names: string[]; diff --git a/packages/agent/tests/eval/hermes-skill-reuse-eval.ts b/packages/agent/tests/eval/hermes-skill-reuse-eval.ts index d8b3642..608bbdd 100644 --- a/packages/agent/tests/eval/hermes-skill-reuse-eval.ts +++ b/packages/agent/tests/eval/hermes-skill-reuse-eval.ts @@ -6,7 +6,7 @@ * in tool-calls, within-model paired, graded on correctness. * * Usage: tsx packages/agent/tests/eval/hermes-skill-reuse-eval.ts - * Env: WAGGLE_DATA_DIR (vault location; default ~/.waggle) + * Env: WAGGLE_DATA_DIR (vault location; default ~/.waggle-community) * HERMES_EVAL_N (override pair count; default = pilot 3) * Output: tmp_hermes-skill-reuse.json (gitignored) + console verdict. * @@ -16,7 +16,7 @@ import { runAgentLoop } from '../../src/agent-loop.js'; import type { ToolDefinition } from '../../src/tools.js'; import { planSkillDistillation } from '../../src/skill-distillation.js'; import { CostTracker, BudgetExceededError } from '../../src/cost-tracker.js'; -import { VaultStore } from '@waggle/core'; +import { VaultStore, defaultDataDir } from '@waggle/core'; import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; @@ -49,7 +49,7 @@ const COST_SAFETY = 1.3; // manifest §9.3 // the $5 pilot / $40 hard cap are enforced against this. const MODEL_PRICING = { [MODEL]: { inputPer1k: 0.003, outputPer1k: 0.015 } }; -const WAGGLE_DATA_DIR = process.env.WAGGLE_DATA_DIR || path.join(os.homedir(), '.waggle'); +const WAGGLE_DATA_DIR = process.env.WAGGLE_DATA_DIR || defaultDataDir(); // ── Forcing corpus (manifest §7 + Amendment 3) ─────────────────────── // Fictional, project-specific "Floruxa" subsystem. Facts are scattered diff --git a/packages/agent/tests/eval/prompt-assembler-eval.ts b/packages/agent/tests/eval/prompt-assembler-eval.ts index 4b200a5..fb7aa18 100644 --- a/packages/agent/tests/eval/prompt-assembler-eval.ts +++ b/packages/agent/tests/eval/prompt-assembler-eval.ts @@ -6,7 +6,7 @@ * tsx packages/agent/tests/eval/prompt-assembler-eval.ts * * Environment: - * WAGGLE_DATA_DIR — override ~/.waggle (for non-default installs) + * WAGGLE_DATA_DIR — override ~/.waggle-community (for non-default installs) * WAGGLE_EVAL_SKIP_SECONDARY=1 — skip Gemma 4 26B MoE + Qwen3 secondary suites * WAGGLE_EVAL_SEEDS — number of seeds per condition (default 3) * @@ -23,7 +23,7 @@ * EVAL-RESULTS.md — human-readable summary (committed) */ -import { VaultStore } from '@waggle/core'; +import { VaultStore, defaultDataDir } from '@waggle/core'; import { createInMemoryMemoryStore, PERSONAL_SCOPE, @@ -43,7 +43,7 @@ import { execFileSync } from 'node:child_process'; // ── Config ────────────────────────────────────────────────────────── -const WAGGLE_DATA_DIR = process.env.WAGGLE_DATA_DIR ?? path.join(os.homedir(), '.waggle'); +const WAGGLE_DATA_DIR = process.env.WAGGLE_DATA_DIR ?? defaultDataDir(); // Use fileURLToPath to handle Windows file:// URLs correctly (avoids // `/D:/...` leading-slash bug that produced `D:\D:\...` double-drive paths). const HARNESS_DIR = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/agent/tests/eval/prompt-assembler-v5-eval.ts b/packages/agent/tests/eval/prompt-assembler-v5-eval.ts index 4cec79e..9132ca9 100644 --- a/packages/agent/tests/eval/prompt-assembler-v5-eval.ts +++ b/packages/agent/tests/eval/prompt-assembler-v5-eval.ts @@ -16,7 +16,7 @@ * tsx packages/agent/tests/eval/prompt-assembler-v5-eval.ts * * Environment: - * WAGGLE_DATA_DIR — override ~/.waggle (for non-default installs) + * WAGGLE_DATA_DIR — override ~/.waggle-community (for non-default installs) * WAGGLE_EVAL_SKIP_SECONDARY=1 — skip Gemma 4 26B MoE + Qwen thinking * WAGGLE_EVAL_SEEDS — base seeds per condition (default 3) * WAGGLE_EVAL_SKIP_SLUG_PROBE=1 — skip the pre-eval slug probe @@ -32,7 +32,7 @@ * judges are reachable, the eval halts and reports partial state. */ -import { VaultStore } from '@waggle/core'; +import { VaultStore, defaultDataDir } from '@waggle/core'; import { createInMemoryMemoryStore, PERSONAL_SCOPE, @@ -57,7 +57,7 @@ process.env.WAGGLE_EVAL_MODE = '1'; // ── Config ────────────────────────────────────────────────────────── -const WAGGLE_DATA_DIR = process.env.WAGGLE_DATA_DIR ?? path.join(os.homedir(), '.waggle'); +const WAGGLE_DATA_DIR = process.env.WAGGLE_DATA_DIR ?? defaultDataDir(); const HARNESS_DIR = path.dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = path.resolve(path.join(HARNESS_DIR, '..', '..', '..', '..')); const RESULTS_JSON = path.join(REPO_ROOT, 'tmp_bench_results-v5.json'); diff --git a/packages/agent/tests/marketplace-commands.test.ts b/packages/agent/tests/marketplace-commands.test.ts index 432adc2..415d0c3 100644 --- a/packages/agent/tests/marketplace-commands.test.ts +++ b/packages/agent/tests/marketplace-commands.test.ts @@ -162,7 +162,7 @@ describe('Marketplace Commands', () => { // Mock install response fetchSpy.mockResolvedValueOnce(new Response(JSON.stringify({ success: true, - message: 'Installed to ~/.waggle/skills/', + message: 'Installed to ~/.waggle-community/skills/', }), { status: 200 })); const ctx = mockContext(); diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 9dceca1..287a717 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -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 Switch model diff --git a/packages/cli/src/repl.ts b/packages/cli/src/repl.ts index a7951f2..140bf77 100644 --- a/packages/cli/src/repl.ts +++ b/packages/cli/src/repl.ts @@ -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 { 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 /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 /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 { 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}`)); } diff --git a/packages/cli/tests/cli-runtime.test.ts b/packages/cli/tests/cli-runtime.test.ts index 49209f4..747c36b 100644 --- a/packages/cli/tests/cli-runtime.test.ts +++ b/packages/cli/tests/cli-runtime.test.ts @@ -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 }); diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index 2ca20e1..9e14158 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -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; @@ -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 { diff --git a/packages/core/src/embeddings/inprocess-embedder.ts b/packages/core/src/embeddings/inprocess-embedder.ts index 128a2d3..1d7d7af 100644 --- a/packages/core/src/embeddings/inprocess-embedder.ts +++ b/packages/core/src/embeddings/inprocess-embedder.ts @@ -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 /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): Promise { 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)`); diff --git a/packages/core/src/file-store.ts b/packages/core/src/file-store.ts index 6ad51f4..3f9103a 100644 --- a/packages/core/src/file-store.ts +++ b/packages/core/src/file-store.ts @@ -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 diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index e05d882..b746eab 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -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, diff --git a/packages/core/src/recall/inprocess-reranker.ts b/packages/core/src/recall/inprocess-reranker.ts index c63297d..d447f70 100644 --- a/packages/core/src/recall/inprocess-reranker.ts +++ b/packages/core/src/recall/inprocess-reranker.ts @@ -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, ): Promise { 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)`); diff --git a/packages/core/src/telemetry.ts b/packages/core/src/telemetry.ts index 920413f..4432210 100644 --- a/packages/core/src/telemetry.ts +++ b/packages/core/src/telemetry.ts @@ -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. * diff --git a/packages/marketplace/ARCHITECTURE.md b/packages/marketplace/ARCHITECTURE.md index 0056e9b..60bab70 100644 --- a/packages/marketplace/ARCHITECTURE.md +++ b/packages/marketplace/ARCHITECTURE.md @@ -40,7 +40,7 @@ The Waggle Marketplace is a **unified package catalog and installer** that aggre │ MarketplaceInstaller ▼ ┌──────────────────────────────────────────────────────────────────────┐ -│ ~/.waggle/ (Runtime) │ +│ ~/.waggle-community/ (Runtime) │ │ │ │ skills/ plugins/ .mcp.json │ │ ├── code-review.md ├── registry.json mcpServers: │ @@ -149,7 +149,7 @@ No installation needed. The SecurityGate calls Gen's free API endpoint at `https ```bash # The marketplace DB ships pre-populated with 120 seed packages. # Copy it to Waggle's runtime directory: -cp marketplace.db ~/.waggle/marketplace.db +cp marketplace.db ~/.waggle-community/marketplace.db # Or build from scratch: python3 build_waggle_marketplace_db.py @@ -190,7 +190,7 @@ Skills, plugins, and MCP servers run inside the agent's trust boundary. A malici ### 2.2 Security Gate — Multi-Layer Defense -The SecurityGate sits between content download and filesystem write. Nothing touches `~/.waggle/` without passing through it. +The SecurityGate sits between content download and filesystem write. Nothing touches `~/.waggle-community/` without passing through it. ``` ┌─────────────────────────────────────────────────────────┐ @@ -363,7 +363,7 @@ waggle-market audit | Property | Value | |----------|-------| | File format | Markdown (`.md`) | -| Install path | `~/.waggle/skills/{name}.md` | +| Install path | `~/.waggle-community/skills/{name}.md` | | How loaded | `loadSkills()` reads all `*.md` from skills dir | | Where used | Appended to agent system prompt | | API endpoint | `PUT /api/skills/{name}` | @@ -373,7 +373,7 @@ waggle-market audit 1. Resolve content (URL, GitHub raw, inline, or stub) 2. SECURITY GATE → scan content 3. If blocked → reject, record in DB -4. If passed → write ~/.waggle/skills/{name}.md +4. If passed → write ~/.waggle-community/skills/{name}.md 5. Notify server: PUT /api/skills/{name} 6. Record installation + scan results in DB ``` @@ -383,8 +383,8 @@ waggle-market audit | Property | Value | |----------|-------| | File format | Directory with `plugin.json` | -| Install path | `~/.waggle/plugins/{name}/` | -| Registry | `~/.waggle/plugins/registry.json` | +| Install path | `~/.waggle-community/plugins/{name}/` | +| Registry | `~/.waggle-community/plugins/registry.json` | | Manager | `@waggle/sdk` `PluginManager` class | | API endpoint | `POST /api/plugins/install` | diff --git a/packages/marketplace/src/cli.ts b/packages/marketplace/src/cli.ts index f249d7a..de1670c 100644 --- a/packages/marketplace/src/cli.ts +++ b/packages/marketplace/src/cli.ts @@ -14,6 +14,7 @@ * waggle-market info 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 )'); + console.log(` (edit ~/${DATA_DIR_NAME}/security-config.json or use waggle-market security-config )`); // Would read from security_config table } else if (positionals.length >= 2) { console.log(` Set ${positionals[0]} = ${positionals[1]}`); diff --git a/packages/marketplace/src/data-dir.ts b/packages/marketplace/src/data-dir.ts new file mode 100644 index 0000000..a5e4795 --- /dev/null +++ b/packages/marketplace/src/data-dir.ts @@ -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'; diff --git a/packages/marketplace/src/db.ts b/packages/marketplace/src/db.ts index 0a8c637..2ed9b79 100644 --- a/packages/marketplace/src/db.ts +++ b/packages/marketplace/src/db.ts @@ -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; diff --git a/packages/marketplace/src/installer.ts b/packages/marketplace/src/installer.ts index a28c4bc..1c5b39d 100644 --- a/packages/marketplace/src/installer.ts +++ b/packages/marketplace/src/installer.ts @@ -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 /.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. diff --git a/packages/marketplace/src/security.ts b/packages/marketplace/src/security.ts index 4306dbf..d6565f1 100644 --- a/packages/marketplace/src/security.ts +++ b/packages/marketplace/src/security.ts @@ -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, diff --git a/packages/marketplace/tests/cli-runtime.test.ts b/packages/marketplace/tests/cli-runtime.test.ts index 2fd5cdf..0ee4993 100644 --- a/packages/marketplace/tests/cli-runtime.test.ts +++ b/packages/marketplace/tests/cli-runtime.test.ts @@ -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(): { diff --git a/packages/marketplace/tests/installer-security.test.ts b/packages/marketplace/tests/installer-security.test.ts index 3562db1..23e78cc 100644 --- a/packages/marketplace/tests/installer-security.test.ts +++ b/packages/marketplace/tests/installer-security.test.ts @@ -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 }); diff --git a/packages/marketplace/tests/sync-verification.test.ts b/packages/marketplace/tests/sync-verification.test.ts index 7484249..7dd3216 100644 --- a/packages/marketplace/tests/sync-verification.test.ts +++ b/packages/marketplace/tests/sync-verification.test.ts @@ -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. */ diff --git a/packages/memory-mem0/bench/search-quality.ts b/packages/memory-mem0/bench/search-quality.ts index 1175e5f..532cac5 100644 --- a/packages/memory-mem0/bench/search-quality.ts +++ b/packages/memory-mem0/bench/search-quality.ts @@ -21,7 +21,7 @@ * * Embedders: * inprocess Xenova/all-MiniLM-L6-v2 padded to 1024 dimensions, as in the - * sidecar, loaded from WAGGLE_MODELS_DIR (default ~/.waggle/models). + * sidecar, loaded from WAGGLE_MODELS_DIR (default ~/.waggle-community/models). * ollama OLLAMA_HOST (default http://localhost:11434) and * OLLAMA_EMBED_MODEL (default nomic-embed-text). Ollama must * already be running with the model pulled. @@ -41,6 +41,7 @@ import path from 'node:path'; import { performance } from 'node:perf_hooks'; import { fileURLToPath } from 'node:url'; import type { MemoryImportance, MemoryKind } from '@waggle/memory-contract'; +import { DEFAULT_DATA_DIR_NAME } from '@waggle/shared'; // The adapter sets this too; setting it first keeps telemetry off even if // something loads mem0 earlier than the adapter. @@ -431,7 +432,7 @@ function packageVersion(fromDir: string, name: string): string { async function main(): Promise { const options = parseArgs(process.argv.slice(2)); const set = JSON.parse(fs.readFileSync(path.join(BENCH_DIR, 'reference-set.json'), 'utf8')) as ReferenceSet; - const modelsDir = process.env.WAGGLE_MODELS_DIR ?? path.join(os.homedir(), '.waggle', 'models'); + const modelsDir = process.env.WAGGLE_MODELS_DIR ?? path.join(os.homedir(), DEFAULT_DATA_DIR_NAME, 'models'); const plan = planEmbedder(options.embedder, modelsDir); guardNetwork(plan.remoteHost); diff --git a/packages/sdk/src/plugin-runtime.ts b/packages/sdk/src/plugin-runtime.ts index 0f0421f..c877481 100644 --- a/packages/sdk/src/plugin-runtime.ts +++ b/packages/sdk/src/plugin-runtime.ts @@ -57,7 +57,7 @@ export interface ActivationDependencies { requiredCapabilities?: string[]; /** Capabilities available in the current environment */ availableCapabilities?: string[]; - /** Path to the plugin directory (e.g., ~/.waggle/plugins//) for resolving tool implementations */ + /** Path to the plugin directory (e.g., ~/.waggle-community/plugins//) for resolving tool implementations */ pluginDir?: string; } diff --git a/packages/sdk/src/starter-skills/index.ts b/packages/sdk/src/starter-skills/index.ts index 6263961..2dd1350 100644 --- a/packages/sdk/src/starter-skills/index.ts +++ b/packages/sdk/src/starter-skills/index.ts @@ -36,7 +36,7 @@ export function listStarterSkills(): string[] { } /** - * Install starter skills into a target directory (e.g., ~/.waggle/skills/). + * Install starter skills into a target directory (e.g., ~/.waggle-community/skills/). * Only installs skills that don't already exist (no overwrite). * Returns list of installed skill names. */ diff --git a/packages/server/src/local/index.ts b/packages/server/src/local/index.ts index dd3243e..6a2bf09 100644 --- a/packages/server/src/local/index.ts +++ b/packages/server/src/local/index.ts @@ -10,7 +10,7 @@ import Fastify, { type FastifyInstance, type FastifyRequest } from 'fastify'; import cors from '@fastify/cors'; import fastifyStatic from '@fastify/static'; import websocket from '@fastify/websocket'; -import { WaggleDB, workspaceDataScope, WorkspaceManager, WaggleConfig, createEmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderInstance, CronStore, AwarenessLayer, VaultStore, SkillHashStore, TelemetryStore, TELEMETRY_EVENTS, ExecutionTraceStore } from '@waggle/core'; +import { WaggleDB, workspaceDataScope, WorkspaceManager, WaggleConfig, createEmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderInstance, CronStore, AwarenessLayer, VaultStore, SkillHashStore, TelemetryStore, TELEMETRY_EVENTS, ExecutionTraceStore, defaultDataDir } from '@waggle/core'; import { corsOriginAllowed } from './cors-config.js'; import { InstallAuditStore } from './install-audit.js'; import { selfBaseUrl, selfRequestHeaders } from './self-request.js'; @@ -185,7 +185,7 @@ import { copyProviderKeysToVault, hydrateProviderEnvFromVault } from './provider export interface LocalConfig { port: number; host: string; - dataDir: string; // ~/.waggle + dataDir: string; // ~/.waggle-community litellmUrl: string; // http://localhost:4000 /** Immutable desktop-launch identity used to prove sidecar ownership. */ instanceId?: string; @@ -470,7 +470,7 @@ export async function buildLocalServer(config: Partial = {}) { // Decorate with local config server.decorate('localConfig', fullConfig); - // Set data dir for custom personas (loaded from ~/.waggle/personas/) + // Set data dir for custom personas (loaded from ~/.waggle-community/personas/) setPersonaDataDir(fullConfig.dataDir); // Event bus (replaces Redis pub/sub) @@ -667,7 +667,7 @@ export async function buildLocalServer(config: Partial = {}) { // Decorate server with embedding provider for status endpoints server.decorate('embeddingProvider', embeddingProvider); - const waggleHome = fullConfig.dataDir || path.join(os.homedir(), '.waggle'); + const waggleHome = fullConfig.dataDir || defaultDataDir(); const rerankerCacheDir = path.join(waggleHome, 'models', 'reranker'); // Memory (ADR-0007): one mem0 store in /memory/, embedded by the @@ -893,7 +893,7 @@ export async function buildLocalServer(config: Partial = {}) { const allTools = [...baseTools, ...subAgentTools, ...workflowTools]; - // Load user customizations from ~/.waggle/ + // Load user customizations from ~/.waggle-community/ const userSystemPrompt = loadSystemPrompt(waggleHome); const skills = loadSkills(waggleHome); @@ -954,7 +954,7 @@ export async function buildLocalServer(config: Partial = {}) { // Plugin runtime manager — lifecycle, tools, skills from plugins const pluginRuntimeManager = new PluginRuntimeManager(); - // Auto-load installed plugins from ~/.waggle/plugins/ + // Auto-load installed plugins from ~/.waggle-community/plugins/ const pluginsDir = path.join(waggleHome, 'plugins'); if (fs.existsSync(pluginsDir)) { try { diff --git a/packages/server/src/local/mcp-config.ts b/packages/server/src/local/mcp-config.ts index b21aa83..ed6013e 100644 --- a/packages/server/src/local/mcp-config.ts +++ b/packages/server/src/local/mcp-config.ts @@ -27,7 +27,7 @@ import fs from 'node:fs'; import * as path from 'node:path'; -import * as os from 'node:os'; +import { defaultDataDir } from '@waggle/core'; import { randomUUID, createHash } from 'node:crypto'; import type { McpRuntime, McpServerConfig } from '@waggle/agent'; import { @@ -51,9 +51,9 @@ export interface McpConfigFile { mcpServers: Record; } -/** Same fallback as local/index.ts `waggleHome`: empty dataDir → ~/.waggle. */ +/** Same fallback as local/index.ts `waggleHome`: empty dataDir → ~/.waggle-community. */ export function mcpConfigPath(dataDir: string): string { - const home = dataDir || path.join(os.homedir(), '.waggle'); + const home = dataDir || defaultDataDir(); return path.join(home, '.mcp.json'); } diff --git a/packages/server/src/local/offline-manager.ts b/packages/server/src/local/offline-manager.ts index d53cc1f..f6272ba 100644 --- a/packages/server/src/local/offline-manager.ts +++ b/packages/server/src/local/offline-manager.ts @@ -24,7 +24,7 @@ export interface QueuedMessage { } export interface OfflineManagerConfig { - /** Directory for persistent storage (e.g. ~/.waggle) */ + /** Directory for persistent storage (e.g. ~/.waggle-community) */ dataDir: string; /** How often to check LLM health, in ms (default: 30000) */ checkIntervalMs?: number; diff --git a/packages/server/src/local/routes/anthropic-proxy.ts b/packages/server/src/local/routes/anthropic-proxy.ts index b9e2ca4..ac74187 100644 --- a/packages/server/src/local/routes/anthropic-proxy.ts +++ b/packages/server/src/local/routes/anthropic-proxy.ts @@ -1407,7 +1407,7 @@ function getAnthropicKey(server: FastifyInstance): string | null { // Legacy fallback: env var (for test harnesses / dev loops) if (process.env.ANTHROPIC_API_KEY) return process.env.ANTHROPIC_API_KEY; - // Legacy fallback: ~/.waggle/config.json + // Legacy fallback: ~/.waggle-community/config.json try { const configPath = path.join(server.localConfig.dataDir, 'config.json'); const raw = fs.readFileSync(configPath, 'utf-8'); diff --git a/packages/server/src/local/routes/backup.ts b/packages/server/src/local/routes/backup.ts index d439dca..91eda18 100644 --- a/packages/server/src/local/routes/backup.ts +++ b/packages/server/src/local/routes/backup.ts @@ -1,5 +1,5 @@ /** - * Backup & Restore Routes — encrypted ZIP-style archive of ~/.waggle/ for machine migration. + * Backup & Restore Routes — encrypted ZIP-style archive of ~/.waggle-community/ for machine migration. * * Endpoints: * POST /api/backup — create and stream an encrypted backup archive diff --git a/packages/server/src/local/routes/chat.ts b/packages/server/src/local/routes/chat.ts index 3c90bd0..5291d7d 100644 --- a/packages/server/src/local/routes/chat.ts +++ b/packages/server/src/local/routes/chat.ts @@ -28,7 +28,7 @@ const NON_RETAINED_TURN_CONTENT = '[Not retained: memory disabled for this turn] /** * Persona resolver that includes built-ins AND on-disk custom personas * (Faza 1 evolved variants like `claude::gen1-v1`, `qwen-thinking::gen1-v1`, - * plus user-saved customs in `~/.waggle/personas/`). + * plus user-saved customs in `~/.waggle-community/personas/`). * * Previously `getPersona(id)` was used here, which only consulted the static * built-in PERSONAS array — `listPersonas()` adds the custom ones from disk diff --git a/packages/server/src/local/routes/command.ts b/packages/server/src/local/routes/command.ts index a7cc26f..188eb95 100644 --- a/packages/server/src/local/routes/command.ts +++ b/packages/server/src/local/routes/command.ts @@ -24,7 +24,7 @@ * later phases. The CommandResultType union carries them so the contract is stable. */ -import os from 'node:os'; +import { defaultDataDir } from '@waggle/core'; import path from 'node:path'; import fs from 'node:fs'; import type { FastifyPluginAsync } from 'fastify'; @@ -79,7 +79,7 @@ function toSubtitle(content: string, max = 120): string { } export const commandRoutes: FastifyPluginAsync = async (server) => { - const waggleHome = server.localConfig.dataDir || path.join(os.homedir(), '.waggle'); + const waggleHome = server.localConfig.dataDir || defaultDataDir(); // ── GET /api/command/search ─────────────────────────────────────────── // Federated read over memory + workspaces + skills + sessions + commands. diff --git a/packages/server/src/local/routes/documents.ts b/packages/server/src/local/routes/documents.ts index 221fb57..bdeabf3 100644 --- a/packages/server/src/local/routes/documents.ts +++ b/packages/server/src/local/routes/documents.ts @@ -13,7 +13,7 @@ import type { FastifyPluginAsync } from 'fastify'; import fs from 'node:fs'; import path from 'node:path'; -import os from 'node:os'; +import { defaultDataDir } from '@waggle/core'; import { assertSafeSegment } from './validate.js'; export interface DocumentVersion { @@ -62,7 +62,7 @@ function writeRegistry(dataDir: string, workspaceId: string, registry: Documents } export const documentRoutes: FastifyPluginAsync = async (server) => { - const dataDir = server.localConfig?.dataDir || process.env.WAGGLE_DATA_DIR || path.join(os.homedir(), '.waggle'); + const dataDir = server.localConfig?.dataDir || process.env.WAGGLE_DATA_DIR || defaultDataDir(); // GET /api/workspaces/:id/documents — list all tracked documents server.get<{ diff --git a/packages/server/src/local/routes/local-inference.ts b/packages/server/src/local/routes/local-inference.ts index 071d4c7..9383924 100644 --- a/packages/server/src/local/routes/local-inference.ts +++ b/packages/server/src/local/routes/local-inference.ts @@ -13,7 +13,7 @@ */ import type { FastifyInstance } from 'fastify'; -import os from 'node:os'; +import { defaultDataDir } from '@waggle/core'; import path from 'node:path'; import { rankModels, OLLAMA_CATALOG } from '@waggle/agent'; import { detectHardware } from '../hardware-detect.js'; @@ -196,7 +196,7 @@ export async function localInferenceRoutes( const VLLM_URL = process.env.VLLM_HOST ?? 'http://localhost:8000'; const dataDir = fastify.localConfig?.dataDir || process.env.WAGGLE_DATA_DIR - || path.join(os.homedir(), '.waggle'); + || defaultDataDir(); const runtime = options.runtimeFactory?.(dataDir, OLLAMA_URL) ?? new ManagedOllamaRuntime(dataDir, OLLAMA_URL); const probeOllama = options.ollamaProbe ?? checkOllama; diff --git a/packages/server/src/local/routes/marketplace-dev.ts b/packages/server/src/local/routes/marketplace-dev.ts index 1cd8dcf..bcc2e09 100644 --- a/packages/server/src/local/routes/marketplace-dev.ts +++ b/packages/server/src/local/routes/marketplace-dev.ts @@ -18,6 +18,7 @@ import { createLogger } from '../logger.js'; const log = createLogger('marketplace-dev'); import fs from 'node:fs'; import { MarketplaceDB, SecurityGate } from '@waggle/marketplace'; +import { DEFAULT_DATA_DIR_NAME } from '@waggle/shared'; import type { InstallationType, MarketplacePack, MarketplacePackage } from '@waggle/marketplace'; export async function marketplaceDevRoutes(fastify: FastifyInstance) { @@ -26,7 +27,7 @@ export async function marketplaceDevRoutes(fastify: FastifyInstance) { const dataDir = fastify.localConfig?.dataDir ?? path.join( process.env.HOME ?? process.env.USERPROFILE ?? '.', - '.waggle', + DEFAULT_DATA_DIR_NAME, ); // Lazy-instantiate marketplace handles on first use. diff --git a/packages/server/src/local/routes/marketplace.ts b/packages/server/src/local/routes/marketplace.ts index 8b6db13..d900dae 100644 --- a/packages/server/src/local/routes/marketplace.ts +++ b/packages/server/src/local/routes/marketplace.ts @@ -11,7 +11,7 @@ import type { FastifyInstance, FastifyReply } from 'fastify'; import { existsSync, readFileSync } from 'fs'; import { join } from 'path'; -import { homedir } from 'os'; +import { defaultDataDir } from '@waggle/core'; import { MarketplaceDB, MarketplaceInstaller, MarketplaceSync, SecurityGate, PACKAGE_CATEGORIES, recategorizeAll, isCiscoScannerAvailable, resolveSkillSource, SkillSourceError, createMarketplaceMcpProvenance } from '@waggle/marketplace'; import type { InstallationType, SearchSort, ScanResult, MarketplacePackage, MarketplaceMcpProvenance, MarketplaceApprovalIdentity, FetchFn } from '@waggle/marketplace'; import { validateSkillMd } from '@waggle/sdk'; @@ -971,7 +971,7 @@ export async function marketplaceRoutes(fastify: FastifyInstance) { // ── POST /api/marketplace/publish ───────────────────────────────── // Publish a local skill to the marketplace catalog. - // Reads the skill from ~/.waggle/skills/, validates frontmatter, + // Reads the skill from ~/.waggle-community/skills/, validates frontmatter, // runs SecurityGate scan, then upserts into the marketplace DB. fastify.post('/api/marketplace/publish', async (request, reply) => { @@ -991,8 +991,8 @@ export async function marketplaceRoutes(fastify: FastifyInstance) { return reply.code(400).send({ error: 'Invalid skill name' }); } - // Read the skill file from ~/.waggle/skills/ - const waggleHome = fastify.localConfig?.dataDir || join(homedir(), '.waggle'); + // Read the skill file from ~/.waggle-community/skills/ + const waggleHome = fastify.localConfig?.dataDir || defaultDataDir(); const skillPath = join(waggleHome, 'skills', `${skillName}.md`); if (!existsSync(skillPath)) { diff --git a/packages/server/src/local/routes/mcps.ts b/packages/server/src/local/routes/mcps.ts index 73cd462..04124bb 100644 --- a/packages/server/src/local/routes/mcps.ts +++ b/packages/server/src/local/routes/mcps.ts @@ -373,7 +373,7 @@ export async function mcpRoutes(fastify: FastifyInstance) { }); } // Persist at the server's dataDir too — the installer writes to - // WAGGLE_DATA_DIR/~/.waggle, which may differ from a custom dataDir. + // WAGGLE_DATA_DIR/~/.waggle-community, which may differ from a custom dataDir. saveMcpServerEntry(dataDir(), configured.name, entry); const runtime = getRuntime(); diff --git a/packages/server/src/local/routes/onboarding.ts b/packages/server/src/local/routes/onboarding.ts index f5f83ad..f2aa84f 100644 --- a/packages/server/src/local/routes/onboarding.ts +++ b/packages/server/src/local/routes/onboarding.ts @@ -71,7 +71,7 @@ export const onboardingRoutes: FastifyPluginAsync = async (server) => { }); // Idempotent completion stamp. The wizard's complete() fires this alongside - // the Tauri filesystem flag (which only covers default ~/.waggle installs). + // the Tauri filesystem flag (which only covers default ~/.waggle-community installs). server.post('/api/onboarding/complete', async () => { fs.mkdirSync(server.localConfig.dataDir, { recursive: true }); fs.writeFileSync(flagPath(), new Date().toISOString()); diff --git a/packages/server/src/local/routes/pins.ts b/packages/server/src/local/routes/pins.ts index 896434b..72b9a2a 100644 --- a/packages/server/src/local/routes/pins.ts +++ b/packages/server/src/local/routes/pins.ts @@ -13,7 +13,7 @@ import type { FastifyPluginAsync } from 'fastify'; import fs from 'node:fs'; import path from 'node:path'; -import os from 'node:os'; +import { defaultDataDir } from '@waggle/core'; import crypto from 'node:crypto'; export interface PinnedItem { @@ -57,7 +57,7 @@ function writePins(dataDir: string, workspaceId: string, pins: PinnedItem[]): vo } export const pinRoutes: FastifyPluginAsync = async (server) => { - const dataDir = server.localConfig?.dataDir || process.env.WAGGLE_DATA_DIR || path.join(os.homedir(), '.waggle'); + const dataDir = server.localConfig?.dataDir || process.env.WAGGLE_DATA_DIR || defaultDataDir(); // GET /api/workspaces/:id/pins — list pins for workspace server.get<{ diff --git a/packages/server/src/local/routes/profile.ts b/packages/server/src/local/routes/profile.ts index 99c1f42..a92e65d 100644 --- a/packages/server/src/local/routes/profile.ts +++ b/packages/server/src/local/routes/profile.ts @@ -1,7 +1,7 @@ /** * User Profile API — identity, writing style, brand, and preferences. * - * Profile data is stored in a JSON file at ~/.waggle/profile.json and + * Profile data is stored in a JSON file at ~/.waggle-community/profile.json and * key fields are also saved to personal memory for agent access. * * Endpoints: diff --git a/packages/server/src/local/routes/skills-audit.ts b/packages/server/src/local/routes/skills-audit.ts index a15d24d..3c032ed 100644 --- a/packages/server/src/local/routes/skills-audit.ts +++ b/packages/server/src/local/routes/skills-audit.ts @@ -1,8 +1,7 @@ -import os from 'node:os'; import path from 'node:path'; import fs from 'node:fs'; import type { FastifyPluginAsync } from 'fastify'; -import { computeSkillHash } from '@waggle/core'; +import { computeSkillHash, defaultDataDir } from '@waggle/core'; import { loadActiveSkills, loadSkillAudit, @@ -44,7 +43,7 @@ async function buildAuditLLM(apiKey: string): Promise { * first, then redacted/provenance-stamped/audited + the change-hash refreshed). */ export const skillsAuditRoutes: FastifyPluginAsync = async (server) => { - const waggleHome = server.localConfig.dataDir || path.join(os.homedir(), '.waggle'); + const waggleHome = server.localConfig.dataDir || defaultDataDir(); const skillsDir = path.join(waggleHome, 'skills'); // GET /api/skills/audit — badge index (Skills Hub card source for the verified badge). diff --git a/packages/server/src/local/routes/skills-hygiene.ts b/packages/server/src/local/routes/skills-hygiene.ts index d7ac441..7f9a356 100644 --- a/packages/server/src/local/routes/skills-hygiene.ts +++ b/packages/server/src/local/routes/skills-hygiene.ts @@ -1,4 +1,4 @@ -import os from 'node:os'; +import { defaultDataDir } from '@waggle/core'; import path from 'node:path'; import type { FastifyPluginAsync } from 'fastify'; import { @@ -17,7 +17,7 @@ import { * Waggle proxy cost — mirroring the evolution route's key gate. */ export const skillsHygieneRoutes: FastifyPluginAsync = async (server) => { - const waggleHome = server.localConfig.dataDir || path.join(os.homedir(), '.waggle'); + const waggleHome = server.localConfig.dataDir || defaultDataDir(); // GET /api/skills/hygiene — current hygiene index (Skills Hub badges) server.get('/api/skills/hygiene', async () => { diff --git a/packages/server/src/local/routes/skills.ts b/packages/server/src/local/routes/skills.ts index 4d3e9c5..22ec159 100644 --- a/packages/server/src/local/routes/skills.ts +++ b/packages/server/src/local/routes/skills.ts @@ -1,4 +1,3 @@ -import os from 'node:os'; import path from 'node:path'; import fs from 'node:fs'; import { createLogger } from '../logger.js'; @@ -7,7 +6,7 @@ import type { FastifyPluginAsync } from 'fastify'; const log = createLogger('skills'); import { PluginManager, getStarterSkillsDir, listStarterSkills, listCapabilityPacks, getPackManifest } from '@waggle/sdk'; import { loadSkills, loadSkillHygiene, loadSkillAudit, clearAuditBadge, SkillRecommender, assessTrust, generateSkillMarkdown, writeSkill, deleteSkill as deleteSkillWrite, parseSkillFrontmatter, extractSkillRequirements, checkSkillRequirements, type SkillTemplate, type SkillRequirements, type SkillRequirementsStatus } from '@waggle/agent'; -import { computeSkillHash } from '@waggle/core'; +import { computeSkillHash, defaultDataDir } from '@waggle/core'; /** Capability family definitions — user-job-first grouping */ const SKILL_FAMILIES: Record = { @@ -36,11 +35,11 @@ const WORKFLOW_SKILLS = new Set(['research-team', 'review-pair', 'plan-execute'] /** * Skills & plugins routes — manage agent extensions. - * Skills: markdown files in ~/.waggle/skills/ that extend the system prompt. - * Plugins: structured packages in ~/.waggle/plugins/ with manifests. + * Skills: markdown files in ~/.waggle-community/skills/ that extend the system prompt. + * Plugins: structured packages in ~/.waggle-community/plugins/ with manifests. */ export const skillRoutes: FastifyPluginAsync = async (server) => { - const waggleHome = server.localConfig.dataDir || path.join(os.homedir(), '.waggle'); + const waggleHome = server.localConfig.dataDir || defaultDataDir(); const skillsDir = path.join(waggleHome, 'skills'); const pluginsDir = path.join(waggleHome, 'plugins'); @@ -83,7 +82,7 @@ export const skillRoutes: FastifyPluginAsync = async (server) => { const starterDir = getStarterSkillsDir(); const starterNames = listStarterSkills(); // returns sorted array of names without .md - // Determine installed skill names (files in ~/.waggle/skills/) + // Determine installed skill names (files in ~/.waggle-community/skills/) const installedNames = new Set(); if (fs.existsSync(skillsDir)) { for (const f of fs.readdirSync(skillsDir)) { diff --git a/packages/server/src/local/routes/tasks.ts b/packages/server/src/local/routes/tasks.ts index 06e927f..b4eb25b 100644 --- a/packages/server/src/local/routes/tasks.ts +++ b/packages/server/src/local/routes/tasks.ts @@ -1,7 +1,7 @@ /** * Task routes — workspace-scoped task board. * - * JSONL-based storage in `~/.waggle/workspaces/{id}/tasks.jsonl`. + * JSONL-based storage in `~/.waggle-community/workspaces/{id}/tasks.jsonl`. * Each task: id, title, status (open|in_progress|done), assignee, creator, timestamps. */ diff --git a/packages/server/src/local/routes/workflows.ts b/packages/server/src/local/routes/workflows.ts index e4cc1ef..250c63c 100644 --- a/packages/server/src/local/routes/workflows.ts +++ b/packages/server/src/local/routes/workflows.ts @@ -4,7 +4,7 @@ import type { WorkflowTemplate } from '@waggle/agent'; /** * Workflow routes — CRUD for custom workflow templates. - * Built-in templates are read-only; custom ones are stored as JSON in ~/.waggle/workflows/. + * Built-in templates are read-only; custom ones are stored as JSON in ~/.waggle-community/workflows/. */ export const workflowRoutes: FastifyPluginAsync = async (fastify) => { const dataDir = fastify.localConfig.dataDir; diff --git a/packages/server/src/local/routes/workspaces.ts b/packages/server/src/local/routes/workspaces.ts index 3d07ee7..f9045b0 100644 --- a/packages/server/src/local/routes/workspaces.ts +++ b/packages/server/src/local/routes/workspaces.ts @@ -1,9 +1,8 @@ import fs from 'node:fs'; -import os from 'node:os'; import path from 'node:path'; import type { FastifyPluginAsync } from 'fastify'; import { z } from 'zod'; -import { AwarenessLayer, createFileStore, workspaceDataScope } from '@waggle/core'; +import { AwarenessLayer, createFileStore, workspaceDataScope, defaultDataDir } from '@waggle/core'; import { workspaceScope, type MemoryRecord, type MemoryStore } from '@waggle/memory-contract'; import { assertSafeSegment } from './validate.js'; import { validateBody } from '../../validate-body.js'; @@ -438,7 +437,7 @@ export const workspaceRoutes: FastifyPluginAsync = async (server) => { // Auto-install starter skills on first workspace creation try { - const waggleHome = server.localConfig.dataDir || path.join(os.homedir(), '.waggle'); + const waggleHome = server.localConfig.dataDir || defaultDataDir(); const skillsDir = path.join(waggleHome, 'skills'); const existingSkills = fs.existsSync(skillsDir) ? fs.readdirSync(skillsDir).filter(f => f.endsWith('.md')) diff --git a/packages/server/src/local/service.ts b/packages/server/src/local/service.ts index 564a5a7..642b339 100644 --- a/packages/server/src/local/service.ts +++ b/packages/server/src/local/service.ts @@ -2,9 +2,8 @@ import fs from 'node:fs'; import { randomUUID } from 'node:crypto'; import net from 'node:net'; import path from 'node:path'; -import os from 'node:os'; import type { FastifyInstance } from 'fastify'; -import { VaultStore, WaggleConfig, WAGGLE_DB_FILE } from '@waggle/core'; +import { VaultStore, WaggleConfig, WAGGLE_DB_FILE, defaultDataDir } from '@waggle/core'; import { buildLocalServer } from './index.js'; import type { LlmHealthStatus } from './index.js'; import { startLiteLLM, stopLiteLLM, type LiteLLMStatus } from './lifecycle.js'; @@ -93,7 +92,7 @@ function removeOwnedDesktopReadyFile(filePath: string, instanceId: string): void /** * Resolve the service data directory: explicit option > WAGGLE_DATA_DIR env > - * ~/.waggle. D11 — the installer/launcher set WAGGLE_DATA_DIR; before this, + * ~/.waggle-community. D11 — the installer/launcher set WAGGLE_DATA_DIR; before this, * startService ignored it while other modules (local/index.ts config, * marketplace installer) honored it, splitting state across two * directories on custom installs. @@ -101,7 +100,7 @@ function removeOwnedDesktopReadyFile(filePath: string, instanceId: string): void export function resolveDataDir(optionDataDir?: string): string { // `||` on the env leg: WAGGLE_DATA_DIR set-but-empty must fall through to // the default, not yield '' (mkdirSync('') throws / resolves to cwd). - return optionDataDir ?? (process.env.WAGGLE_DATA_DIR || path.join(os.homedir(), '.waggle')); + return optionDataDir ?? (process.env.WAGGLE_DATA_DIR || defaultDataDir()); } /** Resolve the listen port: explicit option > validated WAGGLE_PORT > 3333. */ @@ -171,7 +170,7 @@ function getConfiguredProviderIds(dataDir: string, server?: FastifyInstance): st /** * Start the Waggle agent service. * - * 1. Resolves/creates dataDir (option > WAGGLE_DATA_DIR > ~/.waggle) + * 1. Resolves/creates dataDir (option > WAGGLE_DATA_DIR > ~/.waggle-community) * 2. Starts the LiteLLM proxy when config.json enables it and it is not skipped * 3. Builds & starts local Fastify server * 4. Registers graceful shutdown handlers diff --git a/packages/server/src/local/storage/fs-provider.ts b/packages/server/src/local/storage/fs-provider.ts index 6d08e4d..b109295 100644 --- a/packages/server/src/local/storage/fs-provider.ts +++ b/packages/server/src/local/storage/fs-provider.ts @@ -7,7 +7,7 @@ import { STANDARD_DIRS } from './types.js'; /** * Filesystem-backed StorageProvider. - * Used by both "virtual" storage (data in ~/.waggle/workspaces/{id}/files/) + * Used by both "virtual" storage (data in ~/.waggle-community/workspaces/{id}/files/) * and "local" storage (data at a user-specified path). */ export class FsStorageProvider implements StorageProvider { diff --git a/packages/server/src/local/storage/index.ts b/packages/server/src/local/storage/index.ts index a5abbaa..cb2e0fa 100644 --- a/packages/server/src/local/storage/index.ts +++ b/packages/server/src/local/storage/index.ts @@ -17,7 +17,7 @@ interface WorkspaceLike { /** * Resolve the correct StorageProvider for a workspace. * - * - virtual: files in ~/.waggle/workspaces/{id}/files/ (app-managed) + * - virtual: files in ~/.waggle-community/workspaces/{id}/files/ (app-managed) * - local: user-specified directory on their machine (like Claude Code) * - team: shared team storage is part of team mode, which the community * edition does not ship (ADR-0003); such workspaces use virtual storage diff --git a/packages/server/tests/backup-restore.test.ts b/packages/server/tests/backup-restore.test.ts index 20638a3..6a6b915 100644 --- a/packages/server/tests/backup-restore.test.ts +++ b/packages/server/tests/backup-restore.test.ts @@ -1,5 +1,5 @@ /** - * Backup & Restore Tests — PM-5: encrypted backup/restore of ~/.waggle/ + * Backup & Restore Tests — PM-5: encrypted backup/restore of ~/.waggle-community/ * * Tests: * 1. POST /api/backup returns an octet-stream file diff --git a/packages/server/tests/d11-datadir.test.ts b/packages/server/tests/d11-datadir.test.ts index 93fd28d..1a91f68 100644 --- a/packages/server/tests/d11-datadir.test.ts +++ b/packages/server/tests/d11-datadir.test.ts @@ -1,7 +1,7 @@ /** * D11 (UX-Refactor P4) — dataDir resolution. * - * - resolveDataDir: explicit option > WAGGLE_DATA_DIR env > ~/.waggle. Before + * - resolveDataDir: explicit option > WAGGLE_DATA_DIR env > ~/.waggle-community. Before * D11, startService ignored the env var while local/index.ts and the * marketplace installer honored it — a custom install split * its state across two directories. @@ -10,6 +10,7 @@ import { describe, it, expect, afterEach, vi } from 'vitest'; import fs from 'node:fs'; import path from 'node:path'; import os from 'node:os'; +import { DEFAULT_DATA_DIR_NAME } from '@waggle/shared'; import { startService, resolveDataDir } from '../src/local/service.js'; import type { FastifyInstance } from 'fastify'; @@ -36,14 +37,15 @@ describe('resolveDataDir (D11)', () => { expect(resolveDataDir()).toBe('D:/from-env'); }); - it('defaults to ~/.waggle with neither', () => { + it('defaults to ~/.waggle-community with neither, never the commercial ~/.waggle (ADR-0011)', () => { delete process.env[ENV_KEY]; - expect(resolveDataDir()).toBe(path.join(os.homedir(), '.waggle')); + expect(resolveDataDir()).toBe(path.join(os.homedir(), DEFAULT_DATA_DIR_NAME)); + expect(resolveDataDir()).not.toBe(path.join(os.homedir(), '.waggle')); }); it('a set-but-EMPTY env var falls through to the default (never an empty dataDir)', () => { process.env[ENV_KEY] = ''; - expect(resolveDataDir()).toBe(path.join(os.homedir(), '.waggle')); + expect(resolveDataDir()).toBe(path.join(os.homedir(), DEFAULT_DATA_DIR_NAME)); }); }); @@ -72,7 +74,7 @@ describe('startService honors WAGGLE_DATA_DIR (D11 integration)', () => { const result = await startService({ port, skipLiteLLM: true }); server = result.server; - // The env-pointed dir got the install, ~/.waggle got nothing new from us. + // The env-pointed dir got the install, ~/.waggle-community got nothing new from us. expect(fs.existsSync(path.join(envDir, 'waggle.db'))).toBe(true); expect(server.localConfig.dataDir).toBe(envDir); diff --git a/packages/server/tests/local/mcp-config.test.ts b/packages/server/tests/local/mcp-config.test.ts index 9c87f42..044667e 100644 --- a/packages/server/tests/local/mcp-config.test.ts +++ b/packages/server/tests/local/mcp-config.test.ts @@ -11,6 +11,7 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; import fs from 'node:fs'; import * as path from 'node:path'; import * as os from 'node:os'; +import { DEFAULT_DATA_DIR_NAME } from '@waggle/shared'; import { McpRuntime } from '@waggle/agent'; import { MCP_SERVERS, createMarketplaceMcpProvenance } from '@waggle/marketplace'; import { @@ -283,8 +284,8 @@ describe('mcp-config store', () => { for (const variant of variants) expect(validateMcpEntry('brave-search', variant)).not.toBeNull(); }); - it('uses ~/.waggle when dataDir is empty (same fallback as index.ts)', () => { - expect(mcpConfigPath('')).toBe(path.join(os.homedir(), '.waggle', '.mcp.json')); + it('uses ~/.waggle-community when dataDir is empty (same fallback as index.ts)', () => { + expect(mcpConfigPath('')).toBe(path.join(os.homedir(), DEFAULT_DATA_DIR_NAME, '.mcp.json')); }); }); diff --git a/packages/server/tests/local/mcps.test.ts b/packages/server/tests/local/mcps.test.ts index 851824b..292f840 100644 --- a/packages/server/tests/local/mcps.test.ts +++ b/packages/server/tests/local/mcps.test.ts @@ -21,7 +21,7 @@ import { PassThrough } from 'node:stream'; import Database from 'better-sqlite3'; import { WaggleDB } from '@waggle/core'; import { InstallAuditStore } from '../../src/local/install-audit.js'; -import { MCP_CATALOG } from '@waggle/shared'; +import { DEFAULT_DATA_DIR_NAME, MCP_CATALOG } from '@waggle/shared'; import { SecurityGate } from '@waggle/marketplace'; import { McpRuntime, type McpProcess, type SpawnFn } from '@waggle/agent'; import { terminateProcessTree } from '../../../agent/src/system-tools-helpers.js'; @@ -61,7 +61,7 @@ vi.mock('../../src/local/mcp-config.js', async importOriginal => { }); // Redirect the marketplace installer's module-level MCP_CONFIG_PATH away from -// the real ~/.waggle BEFORE the installer module loads (it reads the env at +// the real ~/.waggle-community BEFORE the installer module loads (it reads the env at // import time) — marketplace routes are therefore imported dynamically below. const installerTmp = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-mcps-installer-')); fs.mkdirSync(isolatedHome, { recursive: true }); @@ -766,7 +766,7 @@ describe('MCP Hub routes (Phase 4)', () => { skill_content: '# Safe helper\n\nSummarize a document.', }, }; - const swappedSkillPath = path.join(isolatedHome, '.waggle', 'skills', `${swappedSkillName}.md`); + const swappedSkillPath = path.join(isolatedHome, DEFAULT_DATA_DIR_NAME, 'skills', `${swappedSkillName}.md`); expect(fs.existsSync(swappedSkillPath)).toBe(false); let calls = 0; diff --git a/packages/server/tests/local/pins-documents-data-dir.test.ts b/packages/server/tests/local/pins-documents-data-dir.test.ts index 6f0f94b..08dfbff 100644 --- a/packages/server/tests/local/pins-documents-data-dir.test.ts +++ b/packages/server/tests/local/pins-documents-data-dir.test.ts @@ -6,7 +6,7 @@ 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. */ +/** 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; diff --git a/packages/server/tests/plugin-autoload.test.ts b/packages/server/tests/plugin-autoload.test.ts index 0bcb9bb..19b11cd 100644 --- a/packages/server/tests/plugin-autoload.test.ts +++ b/packages/server/tests/plugin-autoload.test.ts @@ -8,7 +8,7 @@ import type { FastifyInstance } from 'fastify'; /** * Plugin auto-load on startup tests. * - * Verifies that the server scans ~/.waggle/plugins/ at boot and loads + * Verifies that the server scans ~/.waggle-community/plugins/ at boot and loads * plugins with valid plugin.json manifests into the PluginRuntimeManager. */ diff --git a/packages/shared/src/data-dir.ts b/packages/shared/src/data-dir.ts new file mode 100644 index 0000000..0bbc13c --- /dev/null +++ b/packages/shared/src/data-dir.ts @@ -0,0 +1,12 @@ +/** + * The community edition's default data directory, under the user's home + * directory. It is separate from the commercial Waggle's `~/.waggle`, so the + * two editions never open the same databases (ADR-0011). `WAGGLE_DATA_DIR` + * overrides it. The name is temporary: the final one follows the product-name + * decision (Q8). The Rust shell, the launcher, the marketplace and the CLI + * help text keep their own copy; tests check that they match. + */ +export const DEFAULT_DATA_DIR_NAME = '.waggle-community'; + +/** The default data directory as users see it in UI copy and messages. */ +export const DEFAULT_DATA_DIR_LABEL = `~/${DEFAULT_DATA_DIR_NAME}`; diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index d87baaf..bb3ce33 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -2,6 +2,7 @@ export * from './types.js'; export * from './schemas.js'; export * from './constants.js'; +export * from './data-dir.js'; export * from './mcp-catalog.js'; export * from './connector-recommendations.js'; export * from './tool-detection.js'; diff --git a/packages/shared/src/tool-detection.ts b/packages/shared/src/tool-detection.ts index 45a6dc9..f25a1a2 100644 --- a/packages/shared/src/tool-detection.ts +++ b/packages/shared/src/tool-detection.ts @@ -47,7 +47,7 @@ export type ToolReleaseStatus = 'supported' | 'roadmap'; * AI-OS #5 — declarative descriptor for one external tool. The single source of * truth for the per-tool facts that used to be duplicated across SUPPORTED_TOOLS * / LAUNCH_COHORT / TOOL_DISPLAY_NAMES / the per-tool detectors. Built-ins live in BUILTIN_TOOL_MANIFESTS; third-party - * adapters are loaded (data-only) from ~/.waggle/adapters/*.json. + * adapters are loaded (data-only) from ~/.waggle-community/adapters/*.json. */ export interface ToolManifest { id: string; diff --git a/tests/agent-behavior-audit.ts b/tests/agent-behavior-audit.ts index cd98cd7..3a3ad3f 100644 --- a/tests/agent-behavior-audit.ts +++ b/tests/agent-behavior-audit.ts @@ -14,9 +14,10 @@ import * as sqliteVec from 'sqlite-vec'; import os from 'node:os'; import path from 'node:path'; import fs from 'node:fs'; +import { DEFAULT_DATA_DIR_NAME } from '@waggle/shared'; const API = 'http://127.0.0.1:3333'; -const WAGGLE_DIR = path.join(os.homedir(), '.waggle'); +const WAGGLE_DIR = path.join(os.homedir(), DEFAULT_DATA_DIR_NAME); interface SSEEventData { content?: string; diff --git a/vitest.setup.ts b/vitest.setup.ts index d2d5a00..304be00 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -7,7 +7,8 @@ import { mkdtempSync, readFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join, resolve } from 'node:path'; -// Tests must never write to the developer's real ~/.waggle or ~/.claude. Some +// Tests must never write to the developer's real data directories +// (~/.waggle-community, or the commercial edition's ~/.waggle) or ~/.claude. Some // modules resolve paths from os.homedir() at import time (the marketplace // installer's plugin registry and the skill security cache), so point HOME and // USERPROFILE at one temporary directory per worker before any test module loads.