mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
c3b342a03a
## Summary Successfully fixed all initialization issues and completed Phase 2 integration: - Fixed agent template discovery and copying (18 agents now copy correctly) - Added comprehensive logging throughout init process - Fixed undefined config property serialization bug - All databases initialize correctly (memory.db, patterns.db) - Phase 2 features (learning, patterns, improvement) fully functional ## Bug Fixes 1. **Agent Copy Bug**: Changed from directory copy to individual file copy - Fixed: "Copied 0 agent definitions" → Now copies all 18 agents - Issue: fs.copy with filter wasn't working, changed to per-file copy 2. **Missing Agent**: Created qe-quality-analyzer.md - Was the only missing agent out of 17 required QE agents - Added complete agent definition with AQE hooks integration 3. **Incomplete Fallback**: Updated fallback from 6 to all 17 agents - Ensures all agents are created even if templates not found - Maintains feature parity in all scenarios 4. **Serialization Bug**: Added sanitizeConfig() helper - Fixed: "Cannot read properties of undefined (reading 'replace')" - Issue: jsonfile couldn't serialize config with undefined properties - Solution: Recursive sanitization removes undefined values before write 5. **Config Path Bug**: Fixed target vs source file list confusion - Was passing source files to createMissingAgents instead of target - Now correctly identifies which agents are missing in target ## Improvements - Added detailed path discovery logging with ✓/✗ checkmarks - Show agent template counts and copy progress - Log each config file write with file paths - Added stack traces to all error handlers (removed verbose-only check) - Created sanitizeConfig for robust JSON serialization ## Testing Verified in test project `/tmp/aqe-test-final`: ✅ All 17 QE agents created ✅ memory.db created (221KB, 12 tables) ✅ patterns.db created (155KB, 4 tables + FTS) ✅ All Phase 2 configs written successfully ✅ Complete initialization with no errors ## Phase 2 Features Confirmed Working - Learning System: Q-learning (lr=0.1, γ=0.95, 20% target) - Pattern Bank: 85% confidence, extraction enabled - Improvement Loop: 1hr cycles, A/B testing, manual approval ## Files Changed - .claude/agents/qe-quality-analyzer.md (NEW) - src/cli/commands/init.ts (MAJOR FIXES) - copyAgentTemplates(): Individual file copy, better logging - createBasicAgents(): All 17 agents - createMissingAgents(): Fixed file list bug - writeFleetConfig(): Added sanitization - sanitizeConfig(): NEW helper for undefined removal - src/learning/* (NEW - 9 files) - src/reasoning/* (NEW - 8 files) - tests/* (NEW - 30+ test files) - docs/* (NEW - 60+ documentation files) ## Breaking Changes None - all changes are internal improvements ## Migration No migration needed - initialization now works correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
146 lines
3.8 KiB
TypeScript
146 lines
3.8 KiB
TypeScript
/**
|
|
* Sample Test Code for Pattern Extraction Tests
|
|
*/
|
|
|
|
describe('UserService', () => {
|
|
let service: UserService;
|
|
let database: Database;
|
|
|
|
beforeEach(() => {
|
|
database = new TestDatabase();
|
|
service = new UserService(database);
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await database.cleanup();
|
|
});
|
|
|
|
describe('User Creation', () => {
|
|
it('should create user with valid data', async () => {
|
|
const userData = {
|
|
name: 'John Doe',
|
|
email: 'john@example.com',
|
|
age: 30
|
|
};
|
|
|
|
const user = await service.createUser(userData);
|
|
|
|
expect(user.id).toBeDefined();
|
|
expect(user.name).toBe(userData.name);
|
|
expect(user.email).toBe(userData.email);
|
|
expect(user.createdAt).toBeInstanceOf(Date);
|
|
});
|
|
|
|
it('should throw on duplicate email', async () => {
|
|
const userData = { name: 'John', email: 'duplicate@example.com', age: 25 };
|
|
|
|
await service.createUser(userData);
|
|
|
|
await expect(service.createUser(userData))
|
|
.rejects.toThrow('Email already exists');
|
|
});
|
|
|
|
it('should validate email format', async () => {
|
|
const invalidEmail = { name: 'John', email: 'invalid-email', age: 25 };
|
|
|
|
await expect(service.createUser(invalidEmail))
|
|
.rejects.toThrow('Invalid email format');
|
|
});
|
|
|
|
it('should sanitize user input', async () => {
|
|
const maliciousInput = {
|
|
name: '<script>alert("XSS")</script>',
|
|
email: 'safe@example.com',
|
|
age: 25
|
|
};
|
|
|
|
const user = await service.createUser(maliciousInput);
|
|
|
|
expect(user.name).not.toContain('<script>');
|
|
});
|
|
});
|
|
|
|
describe('User Retrieval', () => {
|
|
it('should retrieve user by ID', async () => {
|
|
const created = await service.createUser({
|
|
name: 'Jane',
|
|
email: 'jane@example.com',
|
|
age: 28
|
|
});
|
|
|
|
const retrieved = await service.getUserById(created.id);
|
|
|
|
expect(retrieved).toBeDefined();
|
|
expect(retrieved.id).toBe(created.id);
|
|
expect(retrieved.email).toBe(created.email);
|
|
});
|
|
|
|
it('should return null for non-existent user', async () => {
|
|
const result = await service.getUserById('non-existent-id');
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it('should retrieve users by email', async () => {
|
|
const email = 'test@example.com';
|
|
await service.createUser({ name: 'Test', email, age: 30 });
|
|
|
|
const users = await service.getUsersByEmail(email);
|
|
|
|
expect(users).toHaveLength(1);
|
|
expect(users[0].email).toBe(email);
|
|
});
|
|
});
|
|
|
|
describe('User Update', () => {
|
|
it('should update user data', async () => {
|
|
const user = await service.createUser({
|
|
name: 'Original',
|
|
email: 'update@example.com',
|
|
age: 25
|
|
});
|
|
|
|
const updated = await service.updateUser(user.id, {
|
|
name: 'Updated'
|
|
});
|
|
|
|
expect(updated.name).toBe('Updated');
|
|
expect(updated.email).toBe(user.email); // Unchanged
|
|
});
|
|
|
|
it('should not update with invalid data', async () => {
|
|
const user = await service.createUser({
|
|
name: 'User',
|
|
email: 'valid@example.com',
|
|
age: 30
|
|
});
|
|
|
|
await expect(service.updateUser(user.id, { email: 'invalid' }))
|
|
.rejects.toThrow('Invalid email format');
|
|
});
|
|
});
|
|
|
|
describe('User Deletion', () => {
|
|
it('should delete user by ID', async () => {
|
|
const user = await service.createUser({
|
|
name: 'Delete Me',
|
|
email: 'delete@example.com',
|
|
age: 30
|
|
});
|
|
|
|
const deleted = await service.deleteUser(user.id);
|
|
|
|
expect(deleted).toBe(true);
|
|
|
|
const retrieved = await service.getUserById(user.id);
|
|
expect(retrieved).toBeNull();
|
|
});
|
|
|
|
it('should return false for non-existent user deletion', async () => {
|
|
const result = await service.deleteUser('non-existent');
|
|
|
|
expect(result).toBe(false);
|
|
});
|
|
});
|
|
});
|