feat(desktop,launcher): default to ~/.waggle-community (P1.3c)

The Tauri shell's bundled npm environment and its first-launch flag, the
server installer's --data-dir default and the NSIS installer config
fell back to ~/.waggle. Use ~/.waggle-community (ADR-0011).

The Rust shell keeps the name in DEFAULT_DATA_DIR_NAME in lib.rs and the
launcher, which uses only Node built-ins, in DATA_DIR_NAME.
packages/shared/tests/data-dir.test.ts fails when either copy, or the
marketplace's, differs from @waggle/shared.
This commit is contained in:
shumeiko.it
2026-11-04 10:31:32 +01:00
parent b275f0bf89
commit 4fabed70c0
10 changed files with 80 additions and 43 deletions

View File

@@ -20,7 +20,7 @@ describe('getDefaultInstallerConfig', () => {
expect(config.version).toBe('0.1.0');
expect(config.publisher).toBe('Waggle');
expect(config.defaultInstallDir).toBe('C:\\Program Files\\Waggle');
expect(config.dataDir).toBe('~/.waggle');
expect(config.dataDir).toBe('~/.waggle-community');
expect(config.autostart).toBe(true);
expect(config.desktopShortcut).toBe(true);
expect(config.startMenuEntry).toBe(true);
@@ -46,7 +46,7 @@ describe('generateNsisDefines', () => {
expect(defines.PRODUCT_VERSION).toBe('0.1.0');
expect(defines.PRODUCT_PUBLISHER).toBe('Waggle');
expect(defines.DEFAULT_INSTALL_DIR).toBe('C:\\Program Files\\Waggle');
expect(defines.DATA_DIR).toBe('~/.waggle');
expect(defines.DATA_DIR).toBe('~/.waggle-community');
expect(defines.AUTOSTART).toBe('1');
expect(defines.DESKTOP_SHORTCUT).toBe('1');
expect(defines.START_MENU_ENTRY).toBe('1');
@@ -188,22 +188,22 @@ describe('isSystemPath', () => {
describe('getUninstallPrompt', () => {
it('includes the data directory in the prompt', () => {
const prompt = getUninstallPrompt('~/.waggle');
expect(prompt).toContain('~/.waggle');
const prompt = getUninstallPrompt('~/.waggle-community');
expect(prompt).toContain('~/.waggle-community');
});
it('mentions keeping data for future use', () => {
const prompt = getUninstallPrompt('C:\\Users\\test\\.waggle');
const prompt = getUninstallPrompt('C:\\Users\\test\\.waggle-community');
expect(prompt).toContain('keep it for future use');
});
it('mentions deleting all data option', () => {
const prompt = getUninstallPrompt('~/.waggle');
const prompt = getUninstallPrompt('~/.waggle-community');
expect(prompt).toContain('delete all data');
});
it('mentions agents and memories', () => {
const prompt = getUninstallPrompt('~/.waggle');
const prompt = getUninstallPrompt('~/.waggle-community');
expect(prompt).toContain('agents');
expect(prompt).toContain('memories');
});

View File

@@ -12,7 +12,7 @@ export interface InstallerConfig {
version: string;
publisher: string;
defaultInstallDir: string;
dataDir: string; // ~/.waggle
dataDir: string; // ~/.waggle-community (ADR-0011)
autostart: boolean;
desktopShortcut: boolean;
startMenuEntry: boolean;
@@ -27,7 +27,7 @@ export function getDefaultInstallerConfig(): InstallerConfig {
version: '0.1.0',
publisher: 'Waggle',
defaultInstallDir: 'C:\\Program Files\\Waggle',
dataDir: '~/.waggle',
dataDir: '~/.waggle-community',
autostart: true,
desktopShortcut: true,
startMenuEntry: true,

View File

@@ -2,7 +2,7 @@
//
// Brief: briefs/2026-04-30-cc-sesija-A-waggle-apps-web-integration.md §2.3 Task A10
//
// Persists a flag file at `~/.waggle/first-launch.flag` so the onboarding wizard
// Persists a flag file at `~/.waggle-community/first-launch.flag` so the onboarding wizard
// state survives across app reinstalls (browser localStorage doesn't, since
// Tauri builds may use a fresh WebView profile per install). The web `npm run
// dev` path continues to use localStorage via useOnboarding — these commands
@@ -13,7 +13,8 @@
use std::path::PathBuf;
const FLAG_DIR: &str = ".waggle";
use crate::DEFAULT_DATA_DIR_NAME;
const FLAG_FILE: &str = "first-launch.flag";
fn home_dir() -> Option<PathBuf> {
@@ -23,10 +24,10 @@ fn home_dir() -> Option<PathBuf> {
}
/// Resolve the flag location: `WAGGLE_DATA_DIR` (when set and non-empty) else
/// `~/.waggle` — the SAME resolution order the sidecar's resolveDataDir uses
/// `~/.waggle-community` — the SAME resolution order the sidecar's resolveDataDir uses
/// (UX-Refactor P4/D11). Without this, a custom-data-dir install reads/writes
/// the flag in `~/.waggle` while the server's completion stamp lives in the
/// data dir — and a stale `~/.waggle` flag from a prior default install would
/// the flag in the default directory while the server's completion stamp lives in the
/// data dir — and a stale default-directory flag from a prior default install would
/// auto-skip onboarding against a brand-new data dir (P4 review, 5 findings).
fn flag_path() -> Result<PathBuf, String> {
if let Some(dir) = std::env::var_os("WAGGLE_DATA_DIR") {
@@ -37,7 +38,7 @@ fn flag_path() -> Result<PathBuf, String> {
let home = home_dir().ok_or_else(|| {
"could not resolve user home directory (USERPROFILE/HOME unset)".to_string()
})?;
Ok(home.join(FLAG_DIR).join(FLAG_FILE))
Ok(home.join(DEFAULT_DATA_DIR_NAME).join(FLAG_FILE))
}
/// Returns true if the user has not yet completed onboarding.
@@ -54,7 +55,7 @@ pub async fn is_first_launch() -> Result<bool, String> {
}
/// Marks onboarding as complete by creating the flag file. Idempotent.
/// Creates the parent `~/.waggle/` directory if needed.
/// Creates the parent data directory if needed.
#[tauri::command]
pub async fn mark_first_launch_complete() -> Result<(), String> {
let path = flag_path()?;
@@ -91,12 +92,12 @@ mod tests {
std::env::set_var("USERPROFILE", &tmp);
std::env::set_var("HOME", &tmp);
// Default: ~/.waggle.
// Default: ~/.waggle-community, never the commercial edition's ~/.waggle.
std::env::remove_var("WAGGLE_DATA_DIR");
let path = flag_path().expect("flag_path resolves with USERPROFILE/HOME set");
assert!(
path.ends_with(".waggle/first-launch.flag")
|| path.ends_with(".waggle\\first-launch.flag")
assert_eq!(
path,
tmp.join(".waggle-community").join("first-launch.flag")
);
// P4/D11: a custom data dir keeps the flag NEXT TO the server's stamp.
@@ -110,9 +111,9 @@ mod tests {
// Empty env value falls through to the home default (matches resolveDataDir).
std::env::set_var("WAGGLE_DATA_DIR", "");
let fallback = flag_path().expect("flag_path resolves with empty WAGGLE_DATA_DIR");
assert!(
fallback.ends_with(".waggle/first-launch.flag")
|| fallback.ends_with(".waggle\\first-launch.flag")
assert_eq!(
fallback,
tmp.join(".waggle-community").join("first-launch.flag")
);
std::env::remove_var("WAGGLE_DATA_DIR");

View File

@@ -8,6 +8,13 @@ mod tray;
use service::ServiceState;
use tauri::Manager;
/// Default data directory under the user's home directory, used when
/// `WAGGLE_DATA_DIR` is unset. It is separate from the commercial Waggle's
/// `~/.waggle` so the two editions never open the same databases (ADR-0011).
/// The name is temporary: the final one follows the product-name decision (Q8).
/// `packages/shared/tests/data-dir.test.ts` checks it matches `@waggle/shared`.
pub(crate) const DEFAULT_DATA_DIR_NAME: &str = ".waggle-community";
#[tauri::command]
async fn show_notification(
app: tauri::AppHandle,

View File

@@ -414,7 +414,7 @@ fn bundled_npm_environment(
home_dir
.filter(|value| !value.is_empty())
.map(PathBuf::from)
.map(|home| home.join(".waggle"))
.map(|home| home.join(crate::DEFAULT_DATA_DIR_NAME))
})
.ok_or_else(|| "Unable to resolve writable npm data directory".to_string())?;
let runtime_dir = resources_dir
@@ -1138,7 +1138,7 @@ mod tests {
}
#[test]
fn bundled_npm_environment_falls_back_to_waggle_home() {
fn bundled_npm_environment_falls_back_to_the_default_data_dir() {
let resources = Path::new("resources");
let home = Path::new("home");
let environment = bundled_npm_environment(
@@ -1149,15 +1149,10 @@ mod tests {
)
.expect("fallback npm environment resolves");
assert_eq!(
environment.npm_prefix,
home.join(".waggle").join("npm").join("prefix")
);
assert_eq!(
environment.npm_cache,
home.join(".waggle").join("npm").join("cache")
);
assert_eq!(environment.data_dir, home.join(".waggle"));
let data_dir = home.join(".waggle-community");
assert_eq!(environment.npm_prefix, data_dir.join("npm").join("prefix"));
assert_eq!(environment.npm_cache, data_dir.join("npm").join("cache"));
assert_eq!(environment.data_dir, data_dir);
}
#[test]

View File

@@ -26,7 +26,8 @@ Run `waggle-server --help` for the full list.
Supported systems: Windows x64, macOS (Apple silicon and Intel), Linux x64. You need Node.js
20 or newer only for the first `npx` call.
Your data lives in `~/.waggle` (or `WAGGLE_DATA_DIR`). `uninstall` does not touch it.
Your data lives in `~/.waggle-community` (or `WAGGLE_DATA_DIR`), apart from the commercial
Waggle's `~/.waggle`. `uninstall` does not touch it.
The package and command names are temporary until the product name is decided, and until
the release location is set, install from an archive with `--from`.

View File

@@ -1,4 +1,4 @@
import { COMMAND_NAME } from './platform.js';
import { COMMAND_NAME, DATA_DIR_NAME } from './platform.js';
export type Command = 'install' | 'update' | 'run' | 'doctor' | 'uninstall' | 'help' | 'version';
@@ -97,7 +97,7 @@ export function formatHelp(version: string): string {
--sha256 <hex> Expected SHA-256 of the archive
--dir <path> Install directory
--bin-dir <path> Where to put the ${COMMAND_NAME} command
--data-dir <path> Data directory (default: $WAGGLE_DATA_DIR or ~/.waggle)
--data-dir <path> Data directory (default: $WAGGLE_DATA_DIR or ~/${DATA_DIR_NAME})
--port, -p <number> Server port (default: ${DEFAULT_PORT})
--no-open Do not open the browser
--force Reinstall even when this version is installed

View File

@@ -9,6 +9,14 @@ import path from 'node:path';
/** The command the installer puts on the PATH. A working name until the product name is decided. */
export const COMMAND_NAME = 'waggle-server';
/**
* 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 launcher uses only Node's
* built-in modules, so this copies `DEFAULT_DATA_DIR_NAME` from `@waggle/shared`.
*/
export const DATA_DIR_NAME = '.waggle-community';
export interface Host {
platform: NodeJS.Platform;
arch: string;
@@ -63,9 +71,9 @@ export function defaultBinDir(host: Host, installDir: string): string {
return host.platform === 'win32' ? p.join(installDir, 'bin') : p.join(host.homedir, '.local', 'bin');
}
/** Same rule as the sidecar's resolveDataDir: WAGGLE_DATA_DIR, else ~/.waggle. */
/** Same rule as the sidecar's resolveDataDir: WAGGLE_DATA_DIR, else ~/.waggle-community. */
export function defaultDataDir(host: Host): string {
return host.env.WAGGLE_DATA_DIR || pathApi(host.platform).join(host.homedir, '.waggle');
return host.env.WAGGLE_DATA_DIR || pathApi(host.platform).join(host.homedir, DATA_DIR_NAME);
}
export function isOnPath(host: Host, dir: string): boolean {

View File

@@ -92,7 +92,8 @@ describe('platform paths', () => {
});
it('follows the sidecar data directory rule', () => {
expect(defaultDataDir(host('linux'))).toBe('/home/ana/.waggle');
expect(defaultDataDir(host('linux'))).toBe('/home/ana/.waggle-community');
expect(defaultDataDir(host('win32'))).toBe('C:\\Users\\ana\\.waggle-community');
expect(defaultDataDir(host('linux', { WAGGLE_DATA_DIR: '/srv/waggle' }))).toBe('/srv/waggle');
});
@@ -107,7 +108,7 @@ describe('payload helpers', () => {
it('gives the server the environment the desktop shell gives it', () => {
const env = serviceEnvironment({
appDir: '/opt/w/app',
dataDir: '/home/ana/.waggle',
dataDir: '/home/ana/.waggle-community',
port: 4000,
platform: 'linux',
baseEnv: { PATH: '/usr/bin', WAGGLE_DATA_DIR: '/stale' },
@@ -119,8 +120,8 @@ describe('payload helpers', () => {
WAGGLE_FRONTEND_DIR: '/opt/w/app/web',
NODE_PATH: '/opt/w/app/node_modules:/opt/w/app/native',
PATH: '/opt/w/app/node_modules/waggle-node-runtime/bin:/opt/w/app:/usr/bin',
NPM_CONFIG_PREFIX: '/home/ana/.waggle/npm/prefix',
NPM_CONFIG_CACHE: '/home/ana/.waggle/npm/cache',
NPM_CONFIG_PREFIX: '/home/ana/.waggle-community/npm/prefix',
NPM_CONFIG_CACHE: '/home/ana/.waggle-community/npm/cache',
});
expect(env.WAGGLE_DATA_DIR).toBeUndefined();

View File

@@ -0,0 +1,24 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, it, expect } from 'vitest';
import { DEFAULT_DATA_DIR_LABEL, DEFAULT_DATA_DIR_NAME } from '../src/data-dir.js';
import { DATA_DIR_NAME as LAUNCHER_DATA_DIR_NAME } from '../../launcher/src/platform.js';
import { DATA_DIR_NAME as MARKETPLACE_DATA_DIR_NAME } from '../../marketplace/src/data-dir.js';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
// ADR-0011: the community edition never defaults to the commercial ~/.waggle.
describe('default data directory', () => {
it('is separate from the commercial edition', () => {
expect(DEFAULT_DATA_DIR_NAME).toBe('.waggle-community');
expect(DEFAULT_DATA_DIR_LABEL).toBe('~/.waggle-community');
});
it('has the same name in the launcher, the marketplace and the Rust shell', () => {
expect(LAUNCHER_DATA_DIR_NAME).toBe(DEFAULT_DATA_DIR_NAME);
expect(MARKETPLACE_DATA_DIR_NAME).toBe(DEFAULT_DATA_DIR_NAME);
const lib = fs.readFileSync(path.join(ROOT, 'app/src-tauri/src/lib.rs'), 'utf8');
expect(lib).toContain(`const DEFAULT_DATA_DIR_NAME: &str = "${DEFAULT_DATA_DIR_NAME}";`);
});
});