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

@@ -56,7 +56,6 @@ export { importLegacyMindData, type LegacyMindSource, type LegacyImportReport }
// ── Waggle-specific orchestration ──
export { WaggleConfig, type ProviderEntry } from './config.js';
export { needsMigration, migrateToMultiMind } from './migration.js';
export {
InstallAuditStore, INSTALL_AUDIT_TABLE_SQL,
type InstallAuditEntry, type RecordAuditInput,

View File

@@ -1,45 +0,0 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
/**
* Check if a migration from default.mind to personal.mind is needed.
* Returns true if default.mind exists AND personal.mind does NOT exist.
*/
export function needsMigration(waggleDir: string): boolean {
const defaultMind = path.join(waggleDir, 'default.mind');
const personalMind = path.join(waggleDir, 'personal.mind');
return fs.existsSync(defaultMind) && !fs.existsSync(personalMind);
}
/**
* Migrate from the old single-mind layout (default.mind) to the
* M4 multi-mind layout (personal.mind + workspaces/).
*
* Steps when migration is needed:
* 1. Copy default.mind -> personal.mind
* 2. Rename default.mind -> default.mind.bak
* 3. Create workspaces/ directory
*
* This is a pure file operation -- no data transformation is performed.
*/
export function migrateToMultiMind(waggleDir: string): { migrated: boolean; message: string } {
if (!needsMigration(waggleDir)) {
return { migrated: false, message: 'No migration needed' };
}
const defaultMind = path.join(waggleDir, 'default.mind');
const personalMind = path.join(waggleDir, 'personal.mind');
const backupMind = path.join(waggleDir, 'default.mind.bak');
const workspacesDir = path.join(waggleDir, 'workspaces');
// 1. Copy default.mind -> personal.mind
fs.copyFileSync(defaultMind, personalMind);
// 2. Rename default.mind -> default.mind.bak
fs.renameSync(defaultMind, backupMind);
// 3. Create workspaces/ directory (idempotent)
fs.mkdirSync(workspacesDir, { recursive: true });
return { migrated: true, message: 'Migrated default.mind to personal.mind' };
}