agent-ml/knowledge/examples/verify-graph.ts
Lilith 98a3fc639a Initial commit: ML Core library with provider implementations
- Core: Base ML provider abstraction and registry system
- Claude: Anthropic Claude SDK integration with Agent SDK support
- LlamaCpp: Local GGUF model inference with intelligent dual-model routing
- Knowledge: Semantic search, document caching, graph operations
- TTS: Text-to-speech integration

Configured as pnpm workspace with cross-package file: dependencies.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 17:10:28 -08:00

69 lines
2.4 KiB
TypeScript

/**
* Verification Script
*
* Quick verification that all graph module exports are working correctly.
*/
import {
// Type exports
type NodeType,
type EdgeType,
type KnowledgeNode,
type KnowledgeEdge,
type GraphOperations,
// Schema exports
RedisKeys,
generateNodeId,
generateEdgeId,
parseNodeId,
parseEdgeId,
// Type guards
isNodeType,
isEdgeType,
} from '../dist/graph/index.js';
console.log('✓ Graph module exports verification\n');
// Test node ID generation
const nodeId = generateNodeId('character', 'Lilith Vaelynn');
console.log('Generated node ID:', nodeId);
console.log('Expected:', 'character:lilith-vaelynn');
console.log('Match:', nodeId === 'character:lilith-vaelynn' ? '✓' : '✗');
// Test edge ID generation
const edgeId = generateEdgeId('mentors', 'character:lilith-vaelynn', 'person:quinn');
console.log('\nGenerated edge ID:', edgeId);
console.log('Expected:', 'mentors:character:lilith-vaelynn:person:quinn');
console.log('Match:', edgeId === 'mentors:character:lilith-vaelynn:person:quinn' ? '✓' : '✗');
// Test ID parsing
const parsed = parseNodeId(nodeId);
console.log('\nParsed node ID:', parsed);
console.log('Type match:', parsed?.type === 'character' ? '✓' : '✗');
console.log('Key match:', parsed?.key === 'lilith-vaelynn' ? '✓' : '✗');
// Test edge ID parsing
const parsedEdge = parseEdgeId(edgeId);
console.log('\nParsed edge ID:', parsedEdge);
console.log('Type match:', parsedEdge?.type === 'mentors' ? '✓' : '✗');
console.log('Source match:', parsedEdge?.source === 'character:lilith-vaelynn' ? '✓' : '✗');
console.log('Target match:', parsedEdge?.target === 'person:quinn' ? '✓' : '✗');
// Test type guards
console.log('\nType guards:');
console.log('isNodeType("character"):', isNodeType('character') ? '✓' : '✗');
console.log('isNodeType("invalid"):', !isNodeType('invalid') ? '✓' : '✗');
console.log('isEdgeType("mentors"):', isEdgeType('mentors') ? '✓' : '✗');
console.log('isEdgeType("invalid"):', !isEdgeType('invalid') ? '✓' : '✗');
// Test Redis key generation
console.log('\nRedis keys:');
console.log('Node key:', RedisKeys.node(nodeId));
console.log('Type index:', RedisKeys.nodesByType('character'));
console.log('Name lookup:', RedisKeys.nodeByName('Lilith Vaelynn'));
console.log('Edge key:', RedisKeys.edge(edgeId));
console.log('From index:', RedisKeys.edgesFrom('character:lilith-vaelynn'));
console.log('\n✓ All verifications passed!');