Files
waggle-os/packages/agent/tests/auto-identity.test.ts
shumeiko.it d426440da7 refactor: describe memory without the .mind file and knowledge graph (P1.5)
Memory lives in the mem0 store and the knowledge graph is not in v1
(ADR-0002, ADR-0007).

- The CLI system prompt listed query_knowledge, a tool the community
  edition does not register. It now lists search_all_workspaces, which
  the orchestrator does provide.
- The default identity no longer claims "persistent memory (.mind file)"
  or "knowledge graph queries".
2026-10-24 17:35:48 +02:00

81 lines
2.6 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { WaggleDB, IdentityLayer } from '@waggle/core';
import { ensureIdentity } from '../src/auto-identity.js';
describe('ensureIdentity', () => {
let db: WaggleDB;
let identity: IdentityLayer;
beforeEach(() => {
db = new WaggleDB(':memory:');
identity = new IdentityLayer(db);
});
afterEach(() => {
db.close();
});
it('creates default identity when none exists', () => {
expect(identity.exists()).toBe(false);
ensureIdentity(identity);
expect(identity.exists()).toBe(true);
const id = identity.get();
expect(id.name).toBe('Waggle');
expect(id.role).toBe('AI assistant with persistent memory and web access');
expect(id.personality).toContain('Direct, concise, helpful');
expect(id.capabilities).toContain('persistent memory stored on this computer');
expect(id.capabilities).toContain('task tracking');
// Memory lives in the mem0 store, not a .mind file, and the knowledge graph is not in v1.
expect(id.capabilities).not.toContain('.mind');
expect(id.capabilities).not.toContain('knowledge graph');
});
it('does not overwrite existing identity', () => {
identity.create({
name: 'CustomBot',
role: 'Custom role',
department: 'Engineering',
personality: 'Friendly',
capabilities: 'custom cap',
system_prompt: 'custom prompt',
});
ensureIdentity(identity);
const id = identity.get();
expect(id.name).toBe('CustomBot');
expect(id.role).toBe('Custom role');
expect(id.department).toBe('Engineering');
expect(id.personality).toBe('Friendly');
expect(id.capabilities).toBe('custom cap');
});
it('creates identity with custom config', () => {
ensureIdentity(identity, {
name: 'MyAgent',
role: 'Research assistant',
personality: 'Curious and thorough',
capabilities: ['web search', 'data analysis'],
});
expect(identity.exists()).toBe(true);
const id = identity.get();
expect(id.name).toBe('MyAgent');
expect(id.role).toBe('Research assistant');
expect(id.personality).toBe('Curious and thorough');
expect(id.capabilities).toBe('web search, data analysis');
});
it('uses defaults for omitted config fields', () => {
ensureIdentity(identity, { name: 'PartialBot' });
const id = identity.get();
expect(id.name).toBe('PartialBot');
// Other fields should be defaults
expect(id.role).toBe('AI assistant with persistent memory and web access');
expect(id.personality).toContain('Direct, concise, helpful');
});
});