refactor(server): search memory through the contract in artifacts, agent runs, route proposals and onboarding (P1.5)
- Artifact Center related search lists personal and workspace memories through server.memory and finds related chat sessions in the session files (UF-034). - /api/agent/run searches the requested workspace's memory, or personal memory when no known workspace is given. - Executor briefs search only the workspace's own memory and leave out temporary memories in the query; route proposals no longer borrow a mind from the cache. - Onboarding treats any personal memory as evidence of prior use. - The service no longer creates personal.mind on a fresh install, and isFirstRun also looks for waggle.db.
This commit is contained in:
@@ -6,7 +6,6 @@ import { describe, it, expect, afterEach } from 'vitest';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import { MindDB } from '@waggle/core';
|
||||
import { startService, isFirstRun } from '../src/local/service.js';
|
||||
import type { StartupEvent, StartupPhase } from '../src/local/service.js';
|
||||
|
||||
@@ -52,16 +51,21 @@ describe('isFirstRun', () => {
|
||||
it('returns false when personal.mind exists', () => {
|
||||
const dir = makeTmpDir();
|
||||
tmpDirs.push(dir);
|
||||
const mind = new MindDB(path.join(dir, 'personal.mind'));
|
||||
mind.close();
|
||||
fs.writeFileSync(path.join(dir, 'personal.mind'), '');
|
||||
expect(isFirstRun(dir)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when waggle.db exists', () => {
|
||||
const dir = makeTmpDir();
|
||||
tmpDirs.push(dir);
|
||||
fs.writeFileSync(path.join(dir, 'waggle.db'), '');
|
||||
expect(isFirstRun(dir)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when default.mind exists (needs migration)', () => {
|
||||
const dir = makeTmpDir();
|
||||
tmpDirs.push(dir);
|
||||
const mind = new MindDB(path.join(dir, 'default.mind'));
|
||||
mind.close();
|
||||
fs.writeFileSync(path.join(dir, 'default.mind'), '');
|
||||
expect(isFirstRun(dir)).toBe(false);
|
||||
});
|
||||
|
||||
@@ -111,9 +115,6 @@ describe('startService onProgress', () => {
|
||||
// Should NOT have migration phase (fresh install, no default.mind)
|
||||
expect(phases).not.toContain('migration');
|
||||
|
||||
// Should have creating-mind phase (fresh install)
|
||||
expect(phases).toContain('creating-mind');
|
||||
|
||||
// Progress should go from 0 to 1
|
||||
expect(events[0].progress).toBeLessThanOrEqual(0.2);
|
||||
expect(events[events.length - 1].progress).toBe(1);
|
||||
@@ -130,8 +131,7 @@ describe('startService onProgress', () => {
|
||||
tmpDirs.push(dataDir);
|
||||
|
||||
// Create default.mind to trigger migration
|
||||
const mind = new MindDB(path.join(dataDir, 'default.mind'));
|
||||
mind.close();
|
||||
fs.writeFileSync(path.join(dataDir, 'default.mind'), '');
|
||||
|
||||
const port = randomPort();
|
||||
const events: StartupEvent[] = [];
|
||||
|
||||
Reference in New Issue
Block a user