Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { mkdtempSync, readFileSync, rmSync, writeFileSync, mkdirSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
import migration from './233-wan-mlx-gen-models.js';
const oldRows = () => ({
video: { macos: [
{ id: 'wan22_t2v_a14b', name: 'Wan 2.2 T2V A14B (~28 GB, MoE-14B-active)', repo: 'Wan-AI/Wan2.2-T2V-A14B', runtime: 'wan22', mode: 't2v', steps: 25, guidance: 5 },
{ id: 'wan22_i2v_a14b', name: 'Wan 2.2 I2V A14B (~28 GB, image-to-video)', repo: 'Wan-AI/Wan2.2-I2V-A14B', runtime: 'wan22', mode: 'i2v', steps: 25, guidance: 5 },
] },
_shippedDefaults: { video: { macos: ['wan22_t2v_a14b', 'wan22_i2v_a14b'] } },
});
describe('migration 233 — Wan MLX-Gen models', () => {
let rootDir;
let path;
beforeEach(() => {
rootDir = mkdtempSync(join(tmpdir(), 'migration-233-'));
mkdirSync(join(rootDir, 'data'), { recursive: true });
path = join(rootDir, 'data', 'media-models.json');
});
afterEach(() => rmSync(rootDir, { recursive: true, force: true }));
const write = (value) => writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
const read = () => JSON.parse(readFileSync(path, 'utf-8'));
it('upgrades shipped A14B rows and adds TI2V plus both Lightning profiles', async () => {
write(oldRows());
await migration.up({ rootDir });
const config = read();
const byId = new Map(config.video.macos.map((entry) => [entry.id, entry]));
expect(byId.get('wan22_t2v_a14b')).toMatchObject({
repo: 'AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit',
revision: '39ee5f1f630789956f29f40b5c2c6d48c6e9a798',
supportedModes: ['text'], frameStride: 4, memoryGb: 48, steps: 20, guidance: 4,
});
expect(byId.get('wan22_t2v_a14b').mode).toBeUndefined();
expect(byId.get('wan22_ti2v_5b').supportedModes).toEqual(['text', 'image']);
expect(byId.get('wan22_t2v_a14b_lightning').requiredWeights[0]).toMatchObject({
revision: '18bccf8884ec0a078eed79785eb4ef13ea16ce1e',
});
expect(byId.get('wan22_t2v_a14b_lightning').requiredWeights[0].files).toHaveLength(2);
expect(byId.get('wan22_i2v_a14b_lightning').samplerLocked).toBe(true);
expect(config._shippedDefaults.video.macos).toContain('wan22_ti2v_5b');
});
it('preserves a forked existing row while still adding genuinely new ids', async () => {
const config = oldRows();
config.video.macos[0].repo = 'example/Wan-fork';
config.video.macos[0].steps = 17;
write(config);
await migration.up({ rootDir });
const next = read();
expect(next.video.macos.find((entry) => entry.id === 'wan22_t2v_a14b')).toMatchObject({ repo: 'example/Wan-fork', steps: 17 });
expect(next.video.macos.some((entry) => entry.id === 'wan22_ti2v_5b')).toBe(true);
});
it('preserves user-tuned fields while upgrading a shipped repository', async () => {
const config = oldRows();
Object.assign(config.video.macos[0], {
name: 'My Wan profile',
steps: 17,
guidance: 6,
guidance2: 7,
flowShift: 4,
solver: 'euler',
memoryGb: 96,
});
write(config);
await migration.up({ rootDir });
const upgraded = read().video.macos.find((entry) => entry.id === 'wan22_t2v_a14b');
expect(upgraded).toMatchObject({
name: 'My Wan profile',
repo: 'AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit',
steps: 17,
guidance: 6,
guidance2: 7,
flowShift: 4,
solver: 'euler',
memoryGb: 96,
});
});
it('rejects malformed JSON instead of silently marking the migration applied', async () => {
writeFileSync(path, '{not-json');
await expect(migration.up({ rootDir })).rejects.toThrow(/invalid JSON/);
});
it('is idempotent', async () => {
write(oldRows());
await migration.up({ rootDir });
const once = readFileSync(path, 'utf-8');
await migration.up({ rootDir });
expect(readFileSync(path, 'utf-8')).toBe(once);
});
});