mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-05 15:09:42 +02:00
perf: implement phase 1-3 performance optimizations
Add implementation plans and code structure analysis for a 3-phase performance optimization effort. Refactor core modules to reduce timer overhead, consolidate regex usage, extract exec timeout config, add debouncer utility, and streamline server/schema validation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -126,7 +126,10 @@ describe('writeHooksConfig', () => {
|
||||
writeHooksConfig(testDir);
|
||||
const settingsPath = join(testDir, '.claude', 'settings.local.json');
|
||||
const content = readFileSync(settingsPath, 'utf-8');
|
||||
expect(() => JSON.parse(content)).not.toThrow();
|
||||
const parsed = JSON.parse(content);
|
||||
expect(parsed).toHaveProperty('hooks');
|
||||
expect(parsed.hooks).toHaveProperty('Notification');
|
||||
expect(parsed.hooks).toHaveProperty('Stop');
|
||||
});
|
||||
|
||||
it('should include hooks config in output', () => {
|
||||
|
||||
@@ -121,6 +121,7 @@ describe('ImageWatcher', () => {
|
||||
|
||||
it('should be safe to call for non-watched session', () => {
|
||||
expect(() => watcher.unwatchSession('nonexistent')).not.toThrow();
|
||||
expect(watcher.getWatchedSessions()).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should clear pending debounce timers for the session', () => {
|
||||
|
||||
@@ -214,6 +214,7 @@ describe('SessionManager', () => {
|
||||
|
||||
it('should handle non-existent session gracefully', async () => {
|
||||
await expect(manager.stopSession('non-existent')).resolves.not.toThrow();
|
||||
expect(manager.getSessionCount()).toBe(0);
|
||||
});
|
||||
|
||||
it('should update stored session to stopped', async () => {
|
||||
|
||||
@@ -536,9 +536,11 @@ describe('circular dependency detection', () => {
|
||||
|
||||
it('should allow dependencies on non-existent tasks (just unsatisfied, not a cycle)', () => {
|
||||
// Dependencies on non-existent tasks are valid - they just won't be satisfied
|
||||
expect(() => {
|
||||
queue.addTask({ prompt: 'Task D', dependencies: ['non-existent-id'] });
|
||||
}).not.toThrow();
|
||||
const task = queue.addTask({ prompt: 'Task D', dependencies: ['non-existent-id'] });
|
||||
expect(queue.getAllTasks()).toHaveLength(1);
|
||||
expect(task.dependencies).toEqual(['non-existent-id']);
|
||||
// Task is blocked by unsatisfied dependency, so next() should return null
|
||||
expect(queue.next()).toBeNull();
|
||||
});
|
||||
|
||||
it('should detect self-dependency when task references itself', () => {
|
||||
|
||||
@@ -564,14 +564,18 @@ describe('TaskTracker', () => {
|
||||
describe('Edge Cases', () => {
|
||||
it('should handle null message', () => {
|
||||
expect(() => tracker.processMessage(null)).not.toThrow();
|
||||
expect(tracker.getAllTasks().size).toBe(0);
|
||||
expect(tracker.getRunningCount()).toBe(0);
|
||||
});
|
||||
|
||||
it('should handle message without content', () => {
|
||||
expect(() => tracker.processMessage({ message: {} })).not.toThrow();
|
||||
expect(tracker.getAllTasks().size).toBe(0);
|
||||
});
|
||||
|
||||
it('should handle empty content array', () => {
|
||||
expect(() => tracker.processMessage({ message: { content: [] } })).not.toThrow();
|
||||
expect(tracker.getAllTasks().size).toBe(0);
|
||||
});
|
||||
|
||||
it('should handle tool_result for unknown task', () => {
|
||||
@@ -587,11 +591,15 @@ describe('TaskTracker', () => {
|
||||
},
|
||||
});
|
||||
}).not.toThrow();
|
||||
expect(tracker.getTask('unknown-task')).toBeUndefined();
|
||||
expect(tracker.getAllTasks().size).toBe(0);
|
||||
});
|
||||
|
||||
it('should handle empty terminal output', () => {
|
||||
expect(() => tracker.processTerminalOutput('')).not.toThrow();
|
||||
expect(() => tracker.processTerminalOutput(' ')).not.toThrow();
|
||||
expect(tracker.getAllTasks().size).toBe(0);
|
||||
expect(tracker.getRunningCount()).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user