aios-core 3.6.0 → 3.8.0

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 (62) 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 +13 -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/create-service.md +391 -0
  13. package/.aios-core/development/tasks/next.md +294 -0
  14. package/.aios-core/development/tasks/patterns.md +334 -0
  15. package/.aios-core/development/tasks/squad-creator-analyze.md +315 -0
  16. package/.aios-core/development/tasks/squad-creator-create.md +26 -3
  17. package/.aios-core/development/tasks/squad-creator-extend.md +411 -0
  18. package/.aios-core/development/tasks/squad-creator-validate.md +9 -1
  19. package/.aios-core/development/tasks/waves.md +205 -0
  20. package/.aios-core/development/templates/service-template/README.md.hbs +158 -0
  21. package/.aios-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -0
  22. package/.aios-core/development/templates/service-template/client.ts.hbs +403 -0
  23. package/.aios-core/development/templates/service-template/errors.ts.hbs +182 -0
  24. package/.aios-core/development/templates/service-template/index.ts.hbs +120 -0
  25. package/.aios-core/development/templates/service-template/jest.config.js +89 -0
  26. package/.aios-core/development/templates/service-template/package.json.hbs +87 -0
  27. package/.aios-core/development/templates/service-template/tsconfig.json +45 -0
  28. package/.aios-core/development/templates/service-template/types.ts.hbs +145 -0
  29. package/.aios-core/development/templates/squad/agent-template.md +69 -0
  30. package/.aios-core/development/templates/squad/checklist-template.md +82 -0
  31. package/.aios-core/development/templates/squad/data-template.yaml +105 -0
  32. package/.aios-core/development/templates/squad/script-template.js +179 -0
  33. package/.aios-core/development/templates/squad/task-template.md +125 -0
  34. package/.aios-core/development/templates/squad/template-template.md +97 -0
  35. package/.aios-core/development/templates/squad/tool-template.js +103 -0
  36. package/.aios-core/development/templates/squad/workflow-template.yaml +108 -0
  37. package/.aios-core/infrastructure/scripts/ide-sync/agent-parser.js +45 -1
  38. package/.aios-core/infrastructure/scripts/ide-sync/transformers/antigravity.js +6 -6
  39. package/.aios-core/infrastructure/scripts/ide-sync/transformers/cursor.js +5 -4
  40. package/.aios-core/infrastructure/scripts/ide-sync/transformers/trae.js +3 -3
  41. package/.aios-core/infrastructure/scripts/ide-sync/transformers/windsurf.js +3 -3
  42. package/.aios-core/install-manifest.yaml +139 -35
  43. package/.aios-core/quality/metrics-collector.js +27 -0
  44. package/.aios-core/scripts/session-context-loader.js +13 -254
  45. package/.aios-core/utils/aios-validator.js +25 -0
  46. package/.aios-core/workflow-intelligence/__tests__/confidence-scorer.test.js +334 -0
  47. package/.aios-core/workflow-intelligence/__tests__/integration.test.js +337 -0
  48. package/.aios-core/workflow-intelligence/__tests__/suggestion-engine.test.js +431 -0
  49. package/.aios-core/workflow-intelligence/__tests__/wave-analyzer.test.js +458 -0
  50. package/.aios-core/workflow-intelligence/__tests__/workflow-registry.test.js +302 -0
  51. package/.aios-core/workflow-intelligence/engine/confidence-scorer.js +305 -0
  52. package/.aios-core/workflow-intelligence/engine/output-formatter.js +285 -0
  53. package/.aios-core/workflow-intelligence/engine/suggestion-engine.js +603 -0
  54. package/.aios-core/workflow-intelligence/engine/wave-analyzer.js +676 -0
  55. package/.aios-core/workflow-intelligence/index.js +327 -0
  56. package/.aios-core/workflow-intelligence/learning/capture-hook.js +147 -0
  57. package/.aios-core/workflow-intelligence/learning/index.js +230 -0
  58. package/.aios-core/workflow-intelligence/learning/pattern-capture.js +340 -0
  59. package/.aios-core/workflow-intelligence/learning/pattern-store.js +498 -0
  60. package/.aios-core/workflow-intelligence/learning/pattern-validator.js +309 -0
  61. package/.aios-core/workflow-intelligence/registry/workflow-registry.js +358 -0
  62. package/package.json +1 -1
@@ -0,0 +1,294 @@
1
+ # Next Command Suggestions
2
+
3
+ ## Purpose
4
+
5
+ Suggest next commands based on current workflow context using the Workflow Intelligence System (WIS). Helps users navigate workflows efficiently without memorizing command sequences.
6
+
7
+ ## Task Definition (AIOS Task Format V1.0)
8
+
9
+ ```yaml
10
+ task: next()
11
+ agent: "@dev"
12
+ responsável: Dex (Developer)
13
+ responsavel_type: Agente
14
+ atomic_layer: Workflow
15
+
16
+ elicit: false
17
+
18
+ inputs:
19
+ - name: story
20
+ type: path
21
+ required: false
22
+ description: Explicit story path for context
23
+
24
+ - name: all
25
+ type: flag
26
+ required: false
27
+ default: false
28
+ description: Show all suggestions instead of top 3
29
+
30
+ - name: help
31
+ type: flag
32
+ required: false
33
+ default: false
34
+ description: Show usage documentation
35
+
36
+ outputs:
37
+ - name: suggestions
38
+ type: array
39
+ destino: Console
40
+ persistido: false
41
+
42
+ - name: workflow_context
43
+ type: object
44
+ destino: Console
45
+ persistido: false
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Pre-Conditions
51
+
52
+ ```yaml
53
+ pre-conditions:
54
+ - [ ] WIS modules are available
55
+ tipo: pre-condition
56
+ blocker: false
57
+ validação: Check workflow-intelligence module loads
58
+ error_message: "WIS not available. Suggestions may be limited."
59
+
60
+ - [ ] Session state exists (optional)
61
+ tipo: pre-condition
62
+ blocker: false
63
+ validação: Check .aios/session-state.json exists
64
+ error_message: "No session history. Using project context only."
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Implementation Steps
70
+
71
+ ### Step 1: Check Help Flag
72
+ ```javascript
73
+ if (args.help) {
74
+ displayHelp();
75
+ return;
76
+ }
77
+ ```
78
+
79
+ ### Step 2: Build Context
80
+ ```javascript
81
+ const SuggestionEngine = require('.aios-core/workflow-intelligence/engine/suggestion-engine');
82
+ const engine = new SuggestionEngine();
83
+
84
+ // Build context from multiple sources
85
+ const context = await engine.buildContext({
86
+ storyOverride: args.story, // Explicit story path (optional)
87
+ autoDetect: true // Auto-detect from session/git
88
+ });
89
+ ```
90
+
91
+ ### Step 3: Get Suggestions
92
+ ```javascript
93
+ const result = await engine.suggestNext(context);
94
+
95
+ // result = {
96
+ // workflow: 'story_development',
97
+ // currentState: 'in_development',
98
+ // confidence: 0.92,
99
+ // suggestions: [
100
+ // { command: '*review-qa', args: '${story_path}', description: '...', confidence: 0.95, priority: 1 },
101
+ // ...
102
+ // ]
103
+ // }
104
+ ```
105
+
106
+ ### Step 4: Format Output
107
+ ```javascript
108
+ const formatter = require('.aios-core/workflow-intelligence/engine/output-formatter');
109
+
110
+ // Limit to top 3 unless --all flag
111
+ const displaySuggestions = args.all ? result.suggestions : result.suggestions.slice(0, 3);
112
+
113
+ // Display formatted output
114
+ formatter.displaySuggestions(result.workflow, result.currentState, result.confidence, displaySuggestions);
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Help Text
120
+
121
+ ```
122
+ Usage: *next [options]
123
+
124
+ Suggests next commands based on current workflow context.
125
+
126
+ Options:
127
+ --story <path> Explicit story path for context
128
+ --all Show all suggestions (not just top 3)
129
+ --help Show this help message
130
+
131
+ Examples:
132
+ *next # Auto-detect context
133
+ *next --story docs/stories/v2.1/sprint-10/story-wis-3.md
134
+ *next --all # Show all suggestions
135
+
136
+ How it works:
137
+ 1. Analyzes your recent commands and current agent
138
+ 2. Matches to known workflow patterns (story development, epic creation, etc.)
139
+ 3. Determines your current state in the workflow
140
+ 4. Suggests most likely next commands with confidence scores
141
+
142
+ Workflow detection uses:
143
+ - Recent command history (last 10 commands)
144
+ - Current active agent
145
+ - Git branch and status
146
+ - Active story (if any)
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Output Format
152
+
153
+ ### Standard Output
154
+ ```
155
+ 🧭 Workflow: story_development
156
+ 📍 State: in_development (confidence: 92%)
157
+
158
+ Next steps:
159
+ 1. `*review-qa docs/stories/v2.1/sprint-10/story-wis-3.md` - Run QA review
160
+ 2. `*run-tests` - Execute test suite manually
161
+ 3. `*pre-push-quality-gate` - Final quality checks
162
+
163
+ Type a number to execute, or press Enter to continue manually.
164
+ ```
165
+
166
+ ### Low Confidence Output
167
+ ```
168
+ 🧭 Workflow: unknown
169
+ 📍 State: uncertain (confidence: 35%)
170
+
171
+ Possible next steps (uncertain):
172
+ 1. `*help` - Show available commands
173
+ 2. `*status` - Check project status
174
+
175
+ ⚠️ Low confidence - context is unclear. Try providing --story flag.
176
+ ```
177
+
178
+ ### No Workflow Match
179
+ ```
180
+ 🧭 Workflow: none detected
181
+ 📍 State: N/A
182
+
183
+ Unable to determine workflow from current context.
184
+
185
+ Try:
186
+ *next --story <path-to-story>
187
+ *help
188
+
189
+ Recent commands: *develop, *run-tests
190
+ Current agent: @dev
191
+ ```
192
+
193
+ ---
194
+
195
+ ## Post-Conditions
196
+
197
+ ```yaml
198
+ post-conditions:
199
+ - [ ] Suggestions displayed within 100ms
200
+ tipo: post-condition
201
+ blocker: false
202
+ validação: Measure execution time
203
+
204
+ - [ ] Output is properly formatted
205
+ tipo: post-condition
206
+ blocker: true
207
+ validação: Verify console output matches expected format
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Error Handling
213
+
214
+ | Error | Cause | Resolution |
215
+ |-------|-------|------------|
216
+ | WIS module not found | Missing dependency | Fallback to generic suggestions |
217
+ | Session state corrupt | Invalid JSON | Clear session, show warning |
218
+ | Story path invalid | File doesn't exist | Warning, use auto-detect |
219
+ | No workflow match | Unknown command pattern | Show "unable to determine" message |
220
+
221
+ **Error Recovery Strategy:**
222
+ ```javascript
223
+ try {
224
+ const result = await engine.suggestNext(context);
225
+ formatter.displaySuggestions(result);
226
+ } catch (error) {
227
+ console.warn(`⚠️ Suggestion engine error: ${error.message}`);
228
+ // Fallback: show generic suggestions
229
+ formatter.displayFallback();
230
+ }
231
+ ```
232
+
233
+ ---
234
+
235
+ ## Performance
236
+
237
+ ```yaml
238
+ duration_expected: <100ms (target)
239
+ cost_estimated: $0.00 (no API calls)
240
+ token_usage: 0 (local processing only)
241
+
242
+ optimizations:
243
+ - Workflow patterns cached (5-min TTL)
244
+ - Lazy loading of WIS modules
245
+ - Session state read once per call
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Success Output
251
+
252
+ ```
253
+ ============================================
254
+ SUGGESTION ENGINE RESULTS
255
+ ============================================
256
+
257
+ Context:
258
+ Agent: @dev
259
+ Last Command: *develop
260
+ Story: docs/stories/v2.1/sprint-11/story-wis-3.md
261
+ Branch: feature/wis-3
262
+
263
+ Workflow: story_development
264
+ State: in_development
265
+ Confidence: 92%
266
+
267
+ Suggestions:
268
+ 1. *review-qa (confidence: 95%)
269
+ 2. *run-tests (confidence: 80%)
270
+ 3. *pre-push-quality-gate (confidence: 75%)
271
+
272
+ ============================================
273
+ ```
274
+
275
+ ---
276
+
277
+ ## Metadata
278
+
279
+ ```yaml
280
+ story: WIS-3
281
+ version: 1.0.0
282
+ created: 2025-12-25
283
+ author: "@dev (Dex)"
284
+ dependencies:
285
+ modules:
286
+ - workflow-intelligence (from WIS-2)
287
+ - core/session/context-loader
288
+ tasks: []
289
+ tags:
290
+ - workflow-intelligence
291
+ - suggestions
292
+ - navigation
293
+ - context-aware
294
+ ```
@@ -0,0 +1,334 @@
1
+ # Learned Patterns Management
2
+
3
+ ## Purpose
4
+
5
+ View, manage, and review learned workflow patterns captured by the Workflow Intelligence System (WIS). Patterns are learned from successful workflow executions and boost suggestion confidence.
6
+
7
+ ## Task Definition (AIOS Task Format V1.0)
8
+
9
+ ```yaml
10
+ task: patterns()
11
+ agent: "@dev"
12
+ responsável: Dex (Developer)
13
+ responsavel_type: Agente
14
+ atomic_layer: Workflow
15
+
16
+ elicit: false
17
+
18
+ inputs:
19
+ - name: subcommand
20
+ type: enum
21
+ required: false
22
+ default: list
23
+ options: [list, stats, prune, review]
24
+ description: Action to perform
25
+
26
+ - name: status
27
+ type: enum
28
+ required: false
29
+ options: [pending, active, promoted, deprecated]
30
+ description: Filter patterns by status
31
+
32
+ - name: limit
33
+ type: number
34
+ required: false
35
+ default: 10
36
+ description: Maximum patterns to display
37
+
38
+ - name: help
39
+ type: flag
40
+ required: false
41
+ default: false
42
+ description: Show usage documentation
43
+
44
+ outputs:
45
+ - name: patterns
46
+ type: array
47
+ destino: Console
48
+ persistido: false
49
+
50
+ - name: stats
51
+ type: object
52
+ destino: Console
53
+ persistido: false
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Pre-Conditions
59
+
60
+ ```yaml
61
+ pre-conditions:
62
+ - [ ] Learning module is available
63
+ tipo: pre-condition
64
+ blocker: true
65
+ validação: Check workflow-intelligence/learning module loads
66
+ error_message: "Pattern learning module not available."
67
+
68
+ - [ ] Pattern storage exists
69
+ tipo: pre-condition
70
+ blocker: false
71
+ validação: Check .aios-core/data/learned-patterns.yaml exists
72
+ error_message: "No patterns stored yet."
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Implementation Steps
78
+
79
+ ### Step 1: Check Help Flag
80
+ ```javascript
81
+ if (args.help) {
82
+ displayHelp();
83
+ return;
84
+ }
85
+ ```
86
+
87
+ ### Step 2: Load Learning Module
88
+ ```javascript
89
+ const learning = require('.aios-core/workflow-intelligence/learning');
90
+ const store = learning.getDefaultStore();
91
+ ```
92
+
93
+ ### Step 3: Execute Subcommand
94
+
95
+ #### List Patterns
96
+ ```javascript
97
+ if (args.subcommand === 'list' || !args.subcommand) {
98
+ const data = store.load();
99
+ let patterns = data.patterns;
100
+
101
+ // Filter by status if provided
102
+ if (args.status) {
103
+ patterns = patterns.filter(p => p.status === args.status);
104
+ }
105
+
106
+ // Sort by occurrences (descending)
107
+ patterns.sort((a, b) => (b.occurrences || 1) - (a.occurrences || 1));
108
+
109
+ // Limit results
110
+ patterns = patterns.slice(0, args.limit || 10);
111
+
112
+ displayPatternList(patterns);
113
+ }
114
+ ```
115
+
116
+ #### Show Stats
117
+ ```javascript
118
+ if (args.subcommand === 'stats') {
119
+ const stats = store.getStats();
120
+ displayStats(stats);
121
+ }
122
+ ```
123
+
124
+ #### Prune Patterns
125
+ ```javascript
126
+ if (args.subcommand === 'prune') {
127
+ const result = store.prune();
128
+ console.log(`✓ Pruned ${result.pruned} patterns. ${result.remaining} remaining.`);
129
+ }
130
+ ```
131
+
132
+ #### Review Patterns
133
+ ```javascript
134
+ if (args.subcommand === 'review') {
135
+ const pendingPatterns = store.getByStatus('pending');
136
+
137
+ if (pendingPatterns.length === 0) {
138
+ console.log('No patterns pending review.');
139
+ return;
140
+ }
141
+
142
+ // Interactive review (uses elicitation)
143
+ for (const pattern of pendingPatterns) {
144
+ const action = await promptReviewAction(pattern);
145
+ if (action === 'quit') break;
146
+
147
+ store.updateStatus(pattern.id, action === 'promote' ? 'active' : action);
148
+ console.log(`✓ Pattern ${action}d.`);
149
+ }
150
+ }
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Help Text
156
+
157
+ ```text
158
+ Usage: *patterns [subcommand] [options]
159
+
160
+ Manage learned workflow patterns.
161
+
162
+ Subcommands:
163
+ list List all learned patterns (default)
164
+ stats Show pattern statistics
165
+ prune Remove stale/low-value patterns
166
+ review Interactive review of pending patterns
167
+
168
+ Options:
169
+ --status <status> Filter by status (pending, active, promoted, deprecated)
170
+ --limit <n> Limit results (default: 10)
171
+ --help Show this help message
172
+
173
+ Examples:
174
+ *patterns # List top 10 patterns
175
+ *patterns list --status active # List active patterns only
176
+ *patterns stats # Show statistics
177
+ *patterns prune # Remove stale patterns
178
+ *patterns review # Review pending patterns
179
+
180
+ Pattern Lifecycle:
181
+ 1. pending - Newly captured, awaiting review
182
+ 2. active - Validated, used in suggestions
183
+ 3. promoted - High-value, prioritized in suggestions
184
+ 4. deprecated - Marked for removal
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Output Formats
190
+
191
+ ### List Output
192
+ ```text
193
+ Learned Patterns (15 total)
194
+ ═══════════════════════════
195
+
196
+ Top Patterns by Occurrence:
197
+ 1. validate-story-draft → develop → review-qa
198
+ Occurrences: 12 | Success: 95% | Status: promoted
199
+ Workflow: story_development | Last seen: 2h ago
200
+
201
+ 2. develop → review-qa → apply-qa-fixes
202
+ Occurrences: 8 | Success: 88% | Status: active
203
+ Workflow: story_development | Last seen: 1d ago
204
+
205
+ 3. create-story → validate-story-draft → develop
206
+ Occurrences: 6 | Success: 100% | Status: active
207
+ Workflow: story_creation | Last seen: 3d ago
208
+
209
+ Showing 3 of 15 patterns. Use --limit to see more.
210
+ ```
211
+
212
+ ### Stats Output
213
+ ```text
214
+ Pattern Learning Statistics
215
+ ═══════════════════════════
216
+
217
+ Storage:
218
+ Total patterns: 15
219
+ Max patterns: 100
220
+ Utilization: 15%
221
+
222
+ By Status:
223
+ Pending: 3
224
+ Active: 9
225
+ Promoted: 2
226
+ Deprecated: 1
227
+
228
+ Quality:
229
+ Avg success rate: 92%
230
+ Total occurrences: 45
231
+
232
+ Storage file: .aios-core/data/learned-patterns.yaml
233
+ Last updated: 2025-12-26T10:30:00Z
234
+ ```
235
+
236
+ ### Review Output
237
+ ```text
238
+ *patterns review
239
+
240
+ Patterns Pending Review (3)
241
+ ═══════════════════════════
242
+
243
+ Pattern #1: develop → run-tests → review-qa
244
+ Occurrences: 4 | Success Rate: 100% | First Seen: 2 days ago
245
+ [P]romote [S]kip [D]eprecate [Q]uit
246
+
247
+ > p
248
+
249
+ ✓ Pattern promoted to active status
250
+
251
+ Pattern #2: create-story → develop
252
+ Occurrences: 2 | Success Rate: 50% | First Seen: 5 days ago
253
+ [P]romote [S]kip [D]eprecate [Q]uit
254
+
255
+ > d
256
+
257
+ ✓ Pattern deprecated
258
+
259
+ Review complete. 1 promoted, 0 skipped, 1 deprecated.
260
+ ```
261
+
262
+ ---
263
+
264
+ ## Post-Conditions
265
+
266
+ ```yaml
267
+ post-conditions:
268
+ - [ ] Output displayed correctly
269
+ tipo: post-condition
270
+ blocker: false
271
+ validação: Verify console output matches expected format
272
+
273
+ - [ ] Storage updated for prune/review
274
+ tipo: post-condition
275
+ blocker: true
276
+ validação: Check learned-patterns.yaml was modified
277
+ ```
278
+
279
+ ---
280
+
281
+ ## Error Handling
282
+
283
+ | Error | Cause | Resolution |
284
+ |-------|-------|------------|
285
+ | Learning module not found | Missing dependency | Show error message |
286
+ | Storage file corrupt | Invalid YAML | Reset to empty, show warning |
287
+ | No patterns found | Empty storage | Show "no patterns" message |
288
+ | Review cancelled | User quit | Save any changes made |
289
+
290
+ **Error Recovery Strategy:**
291
+ ```javascript
292
+ try {
293
+ const stats = store.getStats();
294
+ displayStats(stats);
295
+ } catch (error) {
296
+ console.error(`⚠️ Error reading patterns: ${error.message}`);
297
+ console.log('Try running: rm .aios-core/data/learned-patterns.yaml');
298
+ }
299
+ ```
300
+
301
+ ---
302
+
303
+ ## Performance
304
+
305
+ ```yaml
306
+ duration_expected: <50ms
307
+ cost_estimated: $0.00 (local file only)
308
+ token_usage: 0
309
+
310
+ optimizations:
311
+ - Cached pattern loading (5s TTL)
312
+ - Lazy parsing of YAML
313
+ - Streamed display for large lists
314
+ ```
315
+
316
+ ---
317
+
318
+ ## Metadata
319
+
320
+ ```yaml
321
+ story: WIS-5
322
+ version: 1.0.0
323
+ created: 2025-12-26
324
+ author: "@dev (Dex)"
325
+ dependencies:
326
+ modules:
327
+ - workflow-intelligence/learning
328
+ tasks: []
329
+ tags:
330
+ - workflow-intelligence
331
+ - patterns
332
+ - learning
333
+ - management
334
+ ```