aios-core 3.7.0 → 3.9.1

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 (53) hide show
  1. package/.aios-core/core/session/context-detector.js +3 -0
  2. package/.aios-core/core/session/context-loader.js +154 -0
  3. package/.aios-core/data/learned-patterns.yaml +3 -0
  4. package/.aios-core/data/workflow-patterns.yaml +347 -3
  5. package/.aios-core/development/agents/dev.md +6 -0
  6. package/.aios-core/development/agents/squad-creator.md +30 -0
  7. package/.aios-core/development/scripts/squad/squad-analyzer.js +638 -0
  8. package/.aios-core/development/scripts/squad/squad-extender.js +871 -0
  9. package/.aios-core/development/scripts/squad/squad-generator.js +107 -19
  10. package/.aios-core/development/scripts/squad/squad-migrator.js +3 -5
  11. package/.aios-core/development/scripts/squad/squad-validator.js +98 -0
  12. package/.aios-core/development/tasks/next.md +294 -0
  13. package/.aios-core/development/tasks/patterns.md +334 -0
  14. package/.aios-core/development/tasks/squad-creator-analyze.md +315 -0
  15. package/.aios-core/development/tasks/squad-creator-create.md +26 -3
  16. package/.aios-core/development/tasks/squad-creator-extend.md +411 -0
  17. package/.aios-core/development/tasks/squad-creator-validate.md +9 -1
  18. package/.aios-core/development/tasks/waves.md +205 -0
  19. package/.aios-core/development/templates/squad/agent-template.md +69 -0
  20. package/.aios-core/development/templates/squad/checklist-template.md +82 -0
  21. package/.aios-core/development/templates/squad/data-template.yaml +105 -0
  22. package/.aios-core/development/templates/squad/script-template.js +179 -0
  23. package/.aios-core/development/templates/squad/task-template.md +125 -0
  24. package/.aios-core/development/templates/squad/template-template.md +97 -0
  25. package/.aios-core/development/templates/squad/tool-template.js +103 -0
  26. package/.aios-core/development/templates/squad/workflow-template.yaml +108 -0
  27. package/.aios-core/infrastructure/scripts/test-generator.js +8 -8
  28. package/.aios-core/infrastructure/scripts/test-quality-assessment.js +5 -5
  29. package/.aios-core/infrastructure/scripts/test-utilities.js +3 -3
  30. package/.aios-core/install-manifest.yaml +97 -33
  31. package/.aios-core/quality/metrics-collector.js +27 -0
  32. package/.aios-core/scripts/session-context-loader.js +13 -254
  33. package/.aios-core/scripts/test-template-system.js +6 -6
  34. package/.aios-core/utils/aios-validator.js +25 -0
  35. package/.aios-core/workflow-intelligence/__tests__/confidence-scorer.test.js +334 -0
  36. package/.aios-core/workflow-intelligence/__tests__/integration.test.js +337 -0
  37. package/.aios-core/workflow-intelligence/__tests__/suggestion-engine.test.js +431 -0
  38. package/.aios-core/workflow-intelligence/__tests__/wave-analyzer.test.js +458 -0
  39. package/.aios-core/workflow-intelligence/__tests__/workflow-registry.test.js +302 -0
  40. package/.aios-core/workflow-intelligence/engine/confidence-scorer.js +305 -0
  41. package/.aios-core/workflow-intelligence/engine/output-formatter.js +285 -0
  42. package/.aios-core/workflow-intelligence/engine/suggestion-engine.js +603 -0
  43. package/.aios-core/workflow-intelligence/engine/wave-analyzer.js +676 -0
  44. package/.aios-core/workflow-intelligence/index.js +327 -0
  45. package/.aios-core/workflow-intelligence/learning/capture-hook.js +147 -0
  46. package/.aios-core/workflow-intelligence/learning/index.js +230 -0
  47. package/.aios-core/workflow-intelligence/learning/pattern-capture.js +340 -0
  48. package/.aios-core/workflow-intelligence/learning/pattern-store.js +498 -0
  49. package/.aios-core/workflow-intelligence/learning/pattern-validator.js +309 -0
  50. package/.aios-core/workflow-intelligence/registry/workflow-registry.js +358 -0
  51. package/package.json +1 -1
  52. package/src/installer/brownfield-upgrader.js +1 -1
  53. package/bin/aios-init.backup-v1.1.4.js +0 -352
@@ -0,0 +1,337 @@
1
+ /**
2
+ * @fileoverview Integration tests for Workflow Intelligence System
3
+ * @story WIS-2 - Workflow Registry Enhancement
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ const wis = require('../index');
9
+
10
+ describe('Workflow Intelligence System Integration', () => {
11
+ beforeEach(() => {
12
+ wis.reset();
13
+ });
14
+
15
+ afterEach(() => {
16
+ wis.invalidateCache();
17
+ });
18
+
19
+ describe('Context → Workflow Match → Scored Suggestions flow', () => {
20
+ it('should provide scored suggestions for epic creation context', () => {
21
+ // Need 2 matching commands to meet trigger_threshold
22
+ const context = {
23
+ lastCommand: 'create-story',
24
+ lastCommands: ['create-epic', 'create-story'],
25
+ agentId: '@po',
26
+ projectState: {}
27
+ };
28
+
29
+ const suggestions = wis.getSuggestions(context);
30
+
31
+ expect(Array.isArray(suggestions)).toBe(true);
32
+ expect(suggestions.length).toBeGreaterThan(0);
33
+ expect(suggestions[0]).toHaveProperty('command');
34
+ expect(suggestions[0]).toHaveProperty('confidence');
35
+ expect(suggestions[0].workflow).toBe('epic_creation');
36
+ });
37
+
38
+ it('should provide scored suggestions for story development context', () => {
39
+ const context = {
40
+ lastCommand: 'validate-story-draft',
41
+ lastCommands: ['validate-story-draft', 'develop'],
42
+ agentId: '@po',
43
+ projectState: {}
44
+ };
45
+
46
+ const suggestions = wis.getSuggestions(context);
47
+
48
+ expect(suggestions.length).toBeGreaterThan(0);
49
+ expect(suggestions[0].workflow).toBe('story_development');
50
+ });
51
+
52
+ it('should return empty array for unrecognized context', () => {
53
+ const context = {
54
+ lastCommand: 'random-unknown-command',
55
+ lastCommands: ['random-unknown-command'],
56
+ agentId: '@unknown',
57
+ projectState: {}
58
+ };
59
+
60
+ const suggestions = wis.getSuggestions(context);
61
+ expect(suggestions).toEqual([]);
62
+ });
63
+
64
+ it('should rank suggestions by confidence', () => {
65
+ const context = {
66
+ lastCommand: 'create-story',
67
+ lastCommands: ['create-epic', 'create-story'],
68
+ agentId: '@sm',
69
+ projectState: {}
70
+ };
71
+
72
+ const suggestions = wis.getSuggestions(context);
73
+
74
+ if (suggestions.length > 1) {
75
+ expect(suggestions[0].confidence).toBeGreaterThanOrEqual(suggestions[1].confidence);
76
+ }
77
+ });
78
+
79
+ it('should include workflow and state information', () => {
80
+ // Need 2 matching commands to meet trigger_threshold
81
+ const context = {
82
+ lastCommand: 'create-story',
83
+ lastCommands: ['create-epic', 'create-story'],
84
+ agentId: '@po',
85
+ projectState: {}
86
+ };
87
+
88
+ const suggestions = wis.getSuggestions(context);
89
+
90
+ expect(suggestions[0].workflow).toBe('epic_creation');
91
+ expect(suggestions[0].state).toBeDefined();
92
+ });
93
+ });
94
+
95
+ describe('End-to-end workflow navigation', () => {
96
+ it('should navigate through epic creation workflow', () => {
97
+ // Need 2 commands to meet trigger_threshold
98
+ const context1 = {
99
+ lastCommand: 'create-story',
100
+ lastCommands: ['create-epic', 'create-story'],
101
+ agentId: '@po',
102
+ projectState: {}
103
+ };
104
+
105
+ const suggestions1 = wis.getSuggestions(context1);
106
+ // Should suggest validation after stories created
107
+ expect(suggestions1.some(s =>
108
+ s.command === 'validate-story-draft' || s.command === 'create-next-story'
109
+ )).toBe(true);
110
+
111
+ // Step 2: After validation
112
+ const context2 = {
113
+ lastCommand: 'validate-story-draft',
114
+ lastCommands: ['create-epic', 'create-story', 'validate-story-draft'],
115
+ agentId: '@sm',
116
+ projectState: {}
117
+ };
118
+
119
+ const suggestions2 = wis.getSuggestions(context2);
120
+ expect(suggestions2.some(s =>
121
+ s.command === 'analyze-impact' || s.command === 'develop'
122
+ )).toBe(true);
123
+ });
124
+
125
+ it('should navigate through story development workflow', () => {
126
+ // Step 1: Story validated - need 2 commands to meet trigger threshold
127
+ const context1 = {
128
+ lastCommand: 'validate-story-draft',
129
+ lastCommands: ['validate-story-draft', 'develop'],
130
+ agentId: '@po',
131
+ projectState: {}
132
+ };
133
+
134
+ const suggestions1 = wis.getSuggestions(context1);
135
+ if (suggestions1.length > 0) {
136
+ const hasDevelopCommand = suggestions1.some(s =>
137
+ s.command.includes('develop') || s.command.includes('review')
138
+ );
139
+ expect(hasDevelopCommand).toBe(true);
140
+ }
141
+ });
142
+
143
+ it('should navigate through database workflow', () => {
144
+ // Need 2 commands to meet trigger threshold
145
+ const context = {
146
+ lastCommand: 'db-schema-audit',
147
+ lastCommands: ['db-domain-modeling', 'db-schema-audit'],
148
+ agentId: '@data-engineer',
149
+ projectState: {}
150
+ };
151
+
152
+ const suggestions = wis.getSuggestions(context);
153
+ expect(suggestions.length).toBeGreaterThan(0);
154
+ expect(suggestions[0].workflow).toBe('database_workflow');
155
+ });
156
+ });
157
+
158
+ describe('Multi-agent workflow support', () => {
159
+ it('should support multiple agents in epic creation', () => {
160
+ const poWorkflows = wis.getWorkflowsByAgent('@po');
161
+ const smWorkflows = wis.getWorkflowsByAgent('@sm');
162
+
163
+ const epicInPo = poWorkflows.some(w => w.name === 'epic_creation');
164
+ const epicInSm = smWorkflows.some(w => w.name === 'epic_creation');
165
+
166
+ expect(epicInPo).toBe(true);
167
+ expect(epicInSm).toBe(true);
168
+ });
169
+
170
+ it('should support agent transitions within workflow', () => {
171
+ // PO validates story - need 2 matching commands
172
+ const poContext = {
173
+ lastCommand: 'validate-story-draft',
174
+ lastCommands: ['validate-story-draft', 'develop'],
175
+ agentId: '@po',
176
+ projectState: {}
177
+ };
178
+
179
+ const poSuggestions = wis.getSuggestions(poContext);
180
+ expect(poSuggestions.length).toBeGreaterThan(0);
181
+
182
+ // Dev implements
183
+ const devContext = {
184
+ lastCommand: 'develop',
185
+ lastCommands: ['validate-story-draft', 'develop'],
186
+ agentId: '@dev',
187
+ projectState: {}
188
+ };
189
+
190
+ const devSuggestions = wis.getSuggestions(devContext);
191
+ expect(devSuggestions.length).toBeGreaterThan(0);
192
+ });
193
+ });
194
+
195
+ describe('Public API completeness', () => {
196
+ it('should expose matchWorkflow function', () => {
197
+ const match = wis.matchWorkflow(['create-epic', 'create-story']);
198
+ expect(match).not.toBeNull();
199
+ expect(match.name).toBe('epic_creation');
200
+ });
201
+
202
+ it('should expose getNextSteps function', () => {
203
+ const steps = wis.getNextSteps('epic_creation', 'epic_drafted');
204
+ expect(Array.isArray(steps)).toBe(true);
205
+ expect(steps.length).toBeGreaterThan(0);
206
+ });
207
+
208
+ it('should expose getTransitions function', () => {
209
+ const transition = wis.getTransitions('epic_creation', 'epic_drafted');
210
+ expect(transition).not.toBeNull();
211
+ expect(transition.trigger).toBeDefined();
212
+ });
213
+
214
+ it('should expose getWorkflow function', () => {
215
+ const workflow = wis.getWorkflow('epic_creation');
216
+ expect(workflow).not.toBeNull();
217
+ expect(workflow.description).toBeDefined();
218
+ });
219
+
220
+ it('should expose getWorkflowNames function', () => {
221
+ const names = wis.getWorkflowNames();
222
+ expect(names.length).toBe(10);
223
+ });
224
+
225
+ it('should expose getWorkflowsByAgent function', () => {
226
+ const workflows = wis.getWorkflowsByAgent('@po');
227
+ expect(workflows.length).toBeGreaterThan(0);
228
+ });
229
+
230
+ it('should expose findCurrentState function', () => {
231
+ const state = wis.findCurrentState('epic_creation', 'create-epic');
232
+ expect(state).toBe('epic_drafted');
233
+ });
234
+
235
+ it('should expose getStats function', () => {
236
+ const stats = wis.getStats();
237
+ expect(stats.totalWorkflows).toBe(10);
238
+ expect(stats.workflowsWithTransitions).toBe(10);
239
+ });
240
+
241
+ it('should expose factory functions', () => {
242
+ expect(typeof wis.createWorkflowRegistry).toBe('function');
243
+ expect(typeof wis.createConfidenceScorer).toBe('function');
244
+ });
245
+
246
+ it('should expose class constructors', () => {
247
+ expect(wis.WorkflowRegistry).toBeDefined();
248
+ expect(wis.ConfidenceScorer).toBeDefined();
249
+ });
250
+
251
+ it('should expose constants', () => {
252
+ expect(wis.SCORING_WEIGHTS).toBeDefined();
253
+ expect(wis.DEFAULT_CACHE_TTL).toBeDefined();
254
+ });
255
+ });
256
+
257
+ describe('Cache behavior', () => {
258
+ it('should use cache for repeated calls', () => {
259
+ const stats1 = wis.getStats();
260
+ expect(stats1.cacheValid).toBe(true);
261
+
262
+ const stats2 = wis.getStats();
263
+ expect(stats2.cacheValid).toBe(true);
264
+ expect(stats2.cacheAge).toBeGreaterThanOrEqual(stats1.cacheAge);
265
+ });
266
+
267
+ it('should invalidate cache when requested', () => {
268
+ wis.getStats(); // Populate cache
269
+ wis.invalidateCache();
270
+
271
+ // Force reload
272
+ wis.reset();
273
+ const stats = wis.getStats();
274
+ expect(stats.cacheAge).toBeLessThan(100); // Fresh cache
275
+ });
276
+ });
277
+
278
+ describe('Error handling', () => {
279
+ it('should handle missing context gracefully', () => {
280
+ const suggestions = wis.getSuggestions({});
281
+ expect(Array.isArray(suggestions)).toBe(true);
282
+ });
283
+
284
+ it('should handle null context', () => {
285
+ // This should not throw and return empty array
286
+ const result = wis.getSuggestions(null);
287
+ expect(result).toEqual([]);
288
+ });
289
+
290
+ it('should return empty for invalid workflow name', () => {
291
+ const steps = wis.getNextSteps('invalid_workflow', 'any_state');
292
+ expect(steps).toEqual([]);
293
+ });
294
+ });
295
+
296
+ describe('All 10 workflows have transitions', () => {
297
+ const workflows = [
298
+ 'story_development',
299
+ 'epic_creation',
300
+ 'backlog_management',
301
+ 'architecture_review',
302
+ 'git_workflow',
303
+ 'database_workflow',
304
+ 'code_quality_workflow',
305
+ 'documentation_workflow',
306
+ 'ux_workflow',
307
+ 'research_workflow'
308
+ ];
309
+
310
+ workflows.forEach(workflowName => {
311
+ it(`${workflowName} should have transitions defined`, () => {
312
+ const workflow = wis.getWorkflow(workflowName);
313
+ expect(workflow.transitions).toBeDefined();
314
+ expect(Object.keys(workflow.transitions).length).toBeGreaterThanOrEqual(2);
315
+ });
316
+
317
+ it(`${workflowName} should have at least 2 states`, () => {
318
+ const workflow = wis.getWorkflow(workflowName);
319
+ const stateCount = Object.keys(workflow.transitions).length;
320
+ expect(stateCount).toBeGreaterThanOrEqual(2);
321
+ });
322
+
323
+ it(`${workflowName} transitions should have required fields`, () => {
324
+ const workflow = wis.getWorkflow(workflowName);
325
+
326
+ Object.entries(workflow.transitions).forEach(([state, transition]) => {
327
+ expect(transition.trigger).toBeDefined();
328
+ expect(transition.confidence).toBeDefined();
329
+ expect(transition.confidence).toBeGreaterThanOrEqual(0);
330
+ expect(transition.confidence).toBeLessThanOrEqual(1);
331
+ expect(transition.next_steps).toBeDefined();
332
+ expect(Array.isArray(transition.next_steps)).toBe(true);
333
+ });
334
+ });
335
+ });
336
+ });
337
+ });