onbuzz 3.6.1 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/package.json +1 -1
  2. package/src/__test-utils__/fixtures/malformedJson.js +31 -0
  3. package/src/__test-utils__/globalSetup.js +9 -0
  4. package/src/__test-utils__/globalTeardown.js +12 -0
  5. package/src/__test-utils__/mockFactories.js +101 -0
  6. package/src/analyzers/__tests__/CSSAnalyzer.test.js +41 -0
  7. package/src/analyzers/__tests__/ConfigValidator.test.js +362 -0
  8. package/src/analyzers/__tests__/ESLintAnalyzer.test.js +271 -0
  9. package/src/analyzers/__tests__/JavaScriptAnalyzer.test.js +40 -0
  10. package/src/analyzers/__tests__/PrettierFormatter.test.js +197 -0
  11. package/src/analyzers/__tests__/PythonAnalyzer.test.js +208 -0
  12. package/src/analyzers/__tests__/SecurityAnalyzer.test.js +303 -0
  13. package/src/analyzers/__tests__/SparrowAnalyzer.test.js +270 -0
  14. package/src/analyzers/__tests__/TypeScriptAnalyzer.test.js +187 -0
  15. package/src/core/__tests__/agentPool.test.js +601 -0
  16. package/src/core/__tests__/agentScheduler.test.js +576 -0
  17. package/src/core/__tests__/contextManager.test.js +252 -0
  18. package/src/core/__tests__/flowExecutor.test.js +262 -0
  19. package/src/core/__tests__/messageProcessor.test.js +627 -0
  20. package/src/core/__tests__/orchestrator.test.js +257 -0
  21. package/src/core/__tests__/stateManager.test.js +375 -0
  22. package/src/core/agentPool.js +11 -1
  23. package/src/index.js +25 -9
  24. package/src/interfaces/terminal/__tests__/smoke/imports.test.js +3 -5
  25. package/src/services/__tests__/agentActivityService.test.js +319 -0
  26. package/src/services/__tests__/apiKeyManager.test.js +206 -0
  27. package/src/services/__tests__/benchmarkService.test.js +184 -0
  28. package/src/services/__tests__/budgetService.test.js +211 -0
  29. package/src/services/__tests__/contextInjectionService.test.js +205 -0
  30. package/src/services/__tests__/conversationCompactionService.test.js +280 -0
  31. package/src/services/__tests__/credentialVault.test.js +469 -0
  32. package/src/services/__tests__/errorHandler.test.js +314 -0
  33. package/src/services/__tests__/fileAttachmentService.test.js +278 -0
  34. package/src/services/__tests__/flowContextService.test.js +199 -0
  35. package/src/services/__tests__/memoryService.test.js +450 -0
  36. package/src/services/__tests__/modelRouterService.test.js +388 -0
  37. package/src/services/__tests__/modelsService.test.js +261 -0
  38. package/src/services/__tests__/portRegistry.test.js +123 -0
  39. package/src/services/__tests__/projectDetector.test.js +34 -0
  40. package/src/services/__tests__/promptService.test.js +242 -0
  41. package/src/services/__tests__/qualityInspector.test.js +97 -0
  42. package/src/services/__tests__/scheduleService.test.js +308 -0
  43. package/src/services/__tests__/serviceRegistry.test.js +74 -0
  44. package/src/services/__tests__/skillsService.test.js +402 -0
  45. package/src/services/__tests__/tokenCountingService.test.js +48 -0
  46. package/src/tools/__tests__/agentCommunicationTool.test.js +500 -0
  47. package/src/tools/__tests__/agentDelayTool.test.js +342 -0
  48. package/src/tools/__tests__/asyncToolManager.test.js +344 -0
  49. package/src/tools/__tests__/baseTool.test.js +420 -0
  50. package/src/tools/__tests__/codeMapTool.test.js +348 -0
  51. package/src/tools/__tests__/fileContentReplaceTool.test.js +309 -0
  52. package/src/tools/__tests__/fileTreeTool.test.js +274 -0
  53. package/src/tools/__tests__/filesystemTool.test.js +717 -0
  54. package/src/tools/__tests__/helpTool.test.js +204 -0
  55. package/src/tools/__tests__/jobDoneTool.test.js +296 -0
  56. package/src/tools/__tests__/memoryTool.test.js +297 -0
  57. package/src/tools/__tests__/seekTool.test.js +282 -0
  58. package/src/tools/__tests__/skillsTool.test.js +226 -0
  59. package/src/tools/__tests__/staticAnalysisTool.test.js +509 -0
  60. package/src/tools/__tests__/taskManagerTool.test.js +725 -0
  61. package/src/tools/__tests__/terminalTool.test.js +384 -0
  62. package/src/tools/__tests__/userPromptTool.test.js +297 -0
  63. package/src/tools/__tests__/webTool.e2e.test.js +25 -11
  64. package/src/tools/webTool.js +6 -12
  65. package/src/types/__tests__/agent.test.js +499 -0
  66. package/src/types/__tests__/contextReference.test.js +606 -0
  67. package/src/types/__tests__/conversation.test.js +555 -0
  68. package/src/types/__tests__/toolCommand.test.js +584 -0
  69. package/src/types/contextReference.js +1 -1
  70. package/src/utilities/__tests__/attachmentValidator.test.js +80 -0
  71. package/src/utilities/__tests__/configManager.test.js +397 -0
  72. package/src/utilities/__tests__/constants.test.js +49 -0
  73. package/src/utilities/__tests__/directoryAccessManager.test.js +388 -0
  74. package/src/utilities/__tests__/fileProcessor.test.js +104 -0
  75. package/src/utilities/__tests__/jsonRepair.test.js +104 -0
  76. package/src/utilities/__tests__/logger.test.js +129 -0
  77. package/src/utilities/__tests__/platformUtils.test.js +87 -0
  78. package/src/utilities/__tests__/structuredFileValidator.test.js +263 -0
  79. package/src/utilities/__tests__/tagParser.test.js +887 -0
  80. package/src/utilities/__tests__/toolConstants.test.js +94 -0
  81. package/src/utilities/tagParser.js +2 -2
  82. package/src/tools/browserTool.js +0 -897
  83. package/src/utilities/platformUtils.test.js +0 -98
@@ -0,0 +1,226 @@
1
+ import { jest, describe, test, expect, beforeEach } from '@jest/globals';
2
+ import { createMockLogger, createMockConfig } from '../../__test-utils__/mockFactories.js';
3
+
4
+ // Mock the skills service
5
+ const mockSkillsService = {
6
+ initialize: jest.fn().mockResolvedValue(undefined),
7
+ listSkills: jest.fn().mockResolvedValue([{ name: 'code-review', description: 'Code review' }]),
8
+ describeSkill: jest.fn().mockResolvedValue({ name: 'code-review', sections: [] }),
9
+ readSkill: jest.fn().mockResolvedValue({ name: 'code-review', content: '# Code Review' }),
10
+ readSkillSection: jest.fn().mockResolvedValue({ content: 'Section content' }),
11
+ readSkillFile: jest.fn().mockResolvedValue({ content: 'file content' }),
12
+ createSkill: jest.fn().mockResolvedValue({ name: 'new-skill' }),
13
+ updateSkill: jest.fn().mockResolvedValue({ name: 'updated-skill' }),
14
+ deleteSkill: jest.fn().mockResolvedValue(undefined),
15
+ importSkill: jest.fn().mockResolvedValue({ name: 'imported-skill' })
16
+ };
17
+
18
+ jest.unstable_mockModule('../../services/skillsService.js', () => ({
19
+ getSkillsService: jest.fn().mockReturnValue(mockSkillsService)
20
+ }));
21
+
22
+ jest.unstable_mockModule('../../utilities/toolConstants.js', () => ({
23
+ SKILLS_ACTIONS: {
24
+ LIST: 'list',
25
+ DESCRIBE: 'describe',
26
+ READ: 'read',
27
+ READ_SECTION: 'read-section',
28
+ READ_FILE: 'read-file',
29
+ CREATE: 'create',
30
+ UPDATE: 'update',
31
+ DELETE: 'delete',
32
+ IMPORT: 'import'
33
+ }
34
+ }));
35
+
36
+ const { default: SkillsTool } = await import('../skillsTool.js');
37
+
38
+ describe('SkillsTool', () => {
39
+ let tool;
40
+ let logger;
41
+
42
+ beforeEach(() => {
43
+ logger = createMockLogger();
44
+ tool = new SkillsTool({}, logger);
45
+ tool.skillsService = null; // Reset so _ensureSkillsService re-initializes
46
+ jest.clearAllMocks();
47
+ });
48
+
49
+ describe('constructor', () => {
50
+ test('should set correct metadata', () => {
51
+ expect(tool.requiresProject).toBe(false);
52
+ expect(tool.isAsync).toBe(false);
53
+ expect(tool.timeout).toBe(30000);
54
+ expect(tool.skillsService).toBeNull();
55
+ });
56
+ });
57
+
58
+ describe('getDescription', () => {
59
+ test('should return description with all actions', () => {
60
+ const desc = tool.getDescription();
61
+ expect(desc).toContain('Skills Tool');
62
+ expect(desc).toContain('list');
63
+ expect(desc).toContain('describe');
64
+ expect(desc).toContain('read');
65
+ expect(desc).toContain('create');
66
+ expect(desc).toContain('delete');
67
+ expect(desc).toContain('import');
68
+ });
69
+ });
70
+
71
+ describe('parseParameters', () => {
72
+ test('should return content as-is', () => {
73
+ const result = tool.parseParameters('test');
74
+ expect(result).toBe('test');
75
+ });
76
+ });
77
+
78
+ describe('getRequiredParameters', () => {
79
+ test('should require action', () => {
80
+ expect(tool.getRequiredParameters()).toContain('action');
81
+ });
82
+ });
83
+
84
+ describe('getSupportedActions', () => {
85
+ test('should return all skill actions', () => {
86
+ const actions = tool.getSupportedActions();
87
+ expect(actions).toContain('list');
88
+ expect(actions).toContain('describe');
89
+ expect(actions).toContain('read');
90
+ expect(actions).toContain('create');
91
+ expect(actions).toContain('delete');
92
+ expect(actions).toContain('import');
93
+ });
94
+ });
95
+
96
+ describe('validateParameterTypes', () => {
97
+ test('should reject non-string action', () => {
98
+ const errors = tool.validateParameterTypes({ action: 123 });
99
+ expect(errors).toContain('action must be a string');
100
+ });
101
+
102
+ test('should reject non-string name', () => {
103
+ const errors = tool.validateParameterTypes({ name: 123 });
104
+ expect(errors).toContain('name must be a string');
105
+ });
106
+
107
+ test('should accept valid params', () => {
108
+ const errors = tool.validateParameterTypes({ action: 'list' });
109
+ expect(errors).toHaveLength(0);
110
+ });
111
+ });
112
+
113
+ describe('customValidateParameters', () => {
114
+ test('should reject invalid action', () => {
115
+ const errors = tool.customValidateParameters({ action: 'invalid' });
116
+ expect(errors.length).toBeGreaterThan(0);
117
+ expect(errors[0]).toContain('Invalid action');
118
+ });
119
+
120
+ test('should require name for describe', () => {
121
+ const errors = tool.customValidateParameters({ action: 'describe' });
122
+ expect(errors).toContain('"name" is required for action "describe"');
123
+ });
124
+
125
+ test('should require content for create', () => {
126
+ const errors = tool.customValidateParameters({ action: 'create', name: 'test' });
127
+ expect(errors).toContain('"content" is required for action "create"');
128
+ });
129
+
130
+ test('should require section for read-section', () => {
131
+ const errors = tool.customValidateParameters({ action: 'read-section', name: 'test' });
132
+ expect(errors).toContain('"section" is required for action "read-section"');
133
+ });
134
+
135
+ test('should require file for read-file', () => {
136
+ const errors = tool.customValidateParameters({ action: 'read-file', name: 'test' });
137
+ expect(errors).toContain('"file" is required for action "read-file"');
138
+ });
139
+
140
+ test('should require source for import', () => {
141
+ const errors = tool.customValidateParameters({ action: 'import' });
142
+ expect(errors).toContain('"source" is required for action "import"');
143
+ });
144
+
145
+ test('should accept valid list params', () => {
146
+ const errors = tool.customValidateParameters({ action: 'list' });
147
+ expect(errors).toHaveLength(0);
148
+ });
149
+ });
150
+
151
+ describe('execute', () => {
152
+ test('should list skills', async () => {
153
+ const result = await tool.execute({ action: 'list' });
154
+ expect(result.success).toBe(true);
155
+ expect(result.message).toContain('listed');
156
+ });
157
+
158
+ test('should describe a skill', async () => {
159
+ const result = await tool.execute({ action: 'describe', name: 'code-review' });
160
+ expect(result.success).toBe(true);
161
+ expect(mockSkillsService.describeSkill).toHaveBeenCalledWith('code-review');
162
+ });
163
+
164
+ test('should read a skill', async () => {
165
+ const result = await tool.execute({ action: 'read', name: 'code-review' });
166
+ expect(result.success).toBe(true);
167
+ expect(mockSkillsService.readSkill).toHaveBeenCalledWith('code-review');
168
+ });
169
+
170
+ test('should read a section', async () => {
171
+ const result = await tool.execute({ action: 'read-section', name: 'code-review', section: 'Checklist' });
172
+ expect(result.success).toBe(true);
173
+ expect(mockSkillsService.readSkillSection).toHaveBeenCalledWith('code-review', 'Checklist');
174
+ });
175
+
176
+ test('should read a file', async () => {
177
+ const result = await tool.execute({ action: 'read-file', name: 'templates', file: 'welcome.html' });
178
+ expect(result.success).toBe(true);
179
+ expect(mockSkillsService.readSkillFile).toHaveBeenCalledWith('templates', 'welcome.html');
180
+ });
181
+
182
+ test('should create a skill', async () => {
183
+ const result = await tool.execute({ action: 'create', name: 'new', content: '# New' });
184
+ expect(result.success).toBe(true);
185
+ expect(mockSkillsService.createSkill).toHaveBeenCalled();
186
+ });
187
+
188
+ test('should update a skill', async () => {
189
+ const result = await tool.execute({ action: 'update', name: 'existing', content: '# Updated' });
190
+ expect(result.success).toBe(true);
191
+ });
192
+
193
+ test('should delete a skill', async () => {
194
+ const result = await tool.execute({ action: 'delete', name: 'old' });
195
+ expect(result.success).toBe(true);
196
+ expect(result.result.deleted).toBe('old');
197
+ });
198
+
199
+ test('should import a skill', async () => {
200
+ const result = await tool.execute({ action: 'import', source: '/path/to/skill' });
201
+ expect(result.success).toBe(true);
202
+ });
203
+
204
+ test('should return error for unknown action', async () => {
205
+ const result = await tool.execute({ action: 'unknown' });
206
+ expect(result.success).toBe(false);
207
+ });
208
+
209
+ test('should handle service errors', async () => {
210
+ mockSkillsService.readSkill.mockRejectedValueOnce(new Error('Skill not found'));
211
+ const result = await tool.execute({ action: 'read', name: 'nonexistent' });
212
+ expect(result.success).toBe(false);
213
+ expect(result.error).toContain('not found');
214
+ });
215
+ });
216
+
217
+ describe('getParameterSchema', () => {
218
+ test('should return valid schema', () => {
219
+ const schema = tool.getParameterSchema();
220
+ expect(schema.type).toBe('object');
221
+ expect(schema.required).toContain('action');
222
+ expect(schema.properties.action).toBeDefined();
223
+ expect(schema.properties.name).toBeDefined();
224
+ });
225
+ });
226
+ });