refactor(core): remove the single-mind to multi-mind migration (P1.2)

needsMigration and migrateToMultiMind moved a pre-M4 default.mind to
personal.mind at startup. The community edition has no installs with that
layout, so the module, its export, the startup step, its "migration" progress
phase and the default.mind first-run check go.
This commit is contained in:
shumeiko.it
2026-10-24 16:41:51 +02:00
parent 2226ec1bd7
commit 9aae9d6537
6 changed files with 10 additions and 229 deletions

View File

@@ -4,7 +4,7 @@ import net from 'node:net';
import path from 'node:path';
import os from 'node:os';
import type { FastifyInstance } from 'fastify';
import { needsMigration, migrateToMultiMind, VaultStore, WaggleConfig, WAGGLE_DB_FILE } from '@waggle/core';
import { VaultStore, WaggleConfig, WAGGLE_DB_FILE } from '@waggle/core';
import { buildLocalServer } from './index.js';
import type { LlmHealthStatus } from './index.js';
import { startLiteLLM, stopLiteLLM, type LiteLLMStatus } from './lifecycle.js';
@@ -28,7 +28,7 @@ const log = createLogger('service');
// ── Startup progress types ─────────────────────────────────────────
export type StartupPhase = 'init' | 'migration' | 'litellm' | 'server' | 'ready';
export type StartupPhase = 'init' | 'litellm' | 'server' | 'ready';
export interface StartupEvent {
phase: StartupPhase;
@@ -114,12 +114,11 @@ export function resolveServicePort(optionPort?: number): number {
}
/**
* Check if this is a fresh install: no waggle.db and no legacy personal.mind
* or default.mind.
* Check if this is a fresh install: no waggle.db and no legacy personal.mind.
*/
export function isFirstRun(dataDir: string): boolean {
if (!fs.existsSync(dataDir)) return true;
return ![WAGGLE_DB_FILE, 'personal.mind', 'default.mind']
return ![WAGGLE_DB_FILE, 'personal.mind']
.some((file) => fs.existsSync(path.join(dataDir, file)));
}
@@ -173,10 +172,9 @@ function getConfiguredProviderIds(dataDir: string, server?: FastifyInstance): st
* Start the Waggle agent service.
*
* 1. Resolves/creates dataDir (option > WAGGLE_DATA_DIR > ~/.waggle)
* 2. Runs migration if needed (default.mind -> personal.mind)
* 3. Starts the LiteLLM proxy when config.json enables it and it is not skipped
* 4. Builds & starts local Fastify server
* 5. Registers graceful shutdown handlers
* 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
*
* Optionally accepts an onProgress callback to emit startup phase events
* for UI splash screen display.
@@ -229,21 +227,8 @@ export async function startService(options?: ServiceOptions): Promise<ServiceRes
fs.mkdirSync(dataDir, { recursive: true });
}
// 2. Check/run migration
if (needsMigration(dataDir)) {
emit({ phase: 'migration', message: 'Migrating to multi-mind layout...', progress: 0.15 });
try {
migrateToMultiMind(dataDir);
emit({ phase: 'migration', message: 'Migration complete', progress: 0.2 });
} catch (err) {
const msg = `Migration failed: ${err instanceof Error ? err.message : String(err)}`;
emit({ phase: 'migration', message: msg, progress: 0.2 });
throw new Error(msg);
}
}
// D11: ONE startup line answering "which state am I running against?" —
// the resolved dataDir. Logged after wipe/migration so it reflects the
// the resolved dataDir. Logged after the wipe so it reflects the
// directory the server will actually serve.
log.info(`Data dir: ${dataDir}`);