aios-core 3.7.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 (47) 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/install-manifest.yaml +89 -25
  28. package/.aios-core/quality/metrics-collector.js +27 -0
  29. package/.aios-core/scripts/session-context-loader.js +13 -254
  30. package/.aios-core/utils/aios-validator.js +25 -0
  31. package/.aios-core/workflow-intelligence/__tests__/confidence-scorer.test.js +334 -0
  32. package/.aios-core/workflow-intelligence/__tests__/integration.test.js +337 -0
  33. package/.aios-core/workflow-intelligence/__tests__/suggestion-engine.test.js +431 -0
  34. package/.aios-core/workflow-intelligence/__tests__/wave-analyzer.test.js +458 -0
  35. package/.aios-core/workflow-intelligence/__tests__/workflow-registry.test.js +302 -0
  36. package/.aios-core/workflow-intelligence/engine/confidence-scorer.js +305 -0
  37. package/.aios-core/workflow-intelligence/engine/output-formatter.js +285 -0
  38. package/.aios-core/workflow-intelligence/engine/suggestion-engine.js +603 -0
  39. package/.aios-core/workflow-intelligence/engine/wave-analyzer.js +676 -0
  40. package/.aios-core/workflow-intelligence/index.js +327 -0
  41. package/.aios-core/workflow-intelligence/learning/capture-hook.js +147 -0
  42. package/.aios-core/workflow-intelligence/learning/index.js +230 -0
  43. package/.aios-core/workflow-intelligence/learning/pattern-capture.js +340 -0
  44. package/.aios-core/workflow-intelligence/learning/pattern-store.js +498 -0
  45. package/.aios-core/workflow-intelligence/learning/pattern-validator.js +309 -0
  46. package/.aios-core/workflow-intelligence/registry/workflow-registry.js +358 -0
  47. package/package.json +1 -1
@@ -0,0 +1,108 @@
1
+ # {{COMPONENTNAME}} Workflow
2
+ #
3
+ # {{DESCRIPTION}}
4
+ #
5
+ # Created: {{CREATEDAT}}
6
+ # Story: {{STORYID}}
7
+
8
+ name: {{COMPONENTNAME}}
9
+ version: 1.0.0
10
+ description: {{DESCRIPTION}}
11
+ squad: {{SQUADNAME}}
12
+
13
+ # Metadata
14
+ metadata:
15
+ created: {{CREATEDAT}}
16
+ author: squad-creator
17
+ tags:
18
+ - workflow
19
+ - {{SQUADNAME}}
20
+
21
+ # Trigger conditions
22
+ triggers:
23
+ - type: manual
24
+ command: "*{{COMPONENTNAME}}"
25
+ # - type: event
26
+ # event: some-event-name
27
+ # - type: schedule
28
+ # cron: "0 0 * * *"
29
+
30
+ # Input parameters
31
+ inputs:
32
+ - name: param1
33
+ type: string
34
+ required: true
35
+ description: "Description of parameter 1"
36
+ - name: param2
37
+ type: string
38
+ required: false
39
+ default: "default-value"
40
+ description: "Description of parameter 2"
41
+
42
+ # Workflow steps
43
+ steps:
44
+ - id: step-1
45
+ name: "Step 1: Initialize"
46
+ description: "Initialize the workflow"
47
+ action: task
48
+ task: task-name-1
49
+ inputs:
50
+ param: "{{inputs.param1}}"
51
+ on_error: abort
52
+
53
+ - id: step-2
54
+ name: "Step 2: Process"
55
+ description: "Main processing step"
56
+ action: task
57
+ task: task-name-2
58
+ depends_on:
59
+ - step-1
60
+ inputs:
61
+ data: "{{steps.step-1.output}}"
62
+ on_error: retry
63
+ retry:
64
+ max_attempts: 3
65
+ delay: 1000
66
+
67
+ - id: step-3
68
+ name: "Step 3: Finalize"
69
+ description: "Finalize the workflow"
70
+ action: task
71
+ task: task-name-3
72
+ depends_on:
73
+ - step-2
74
+ condition: "{{steps.step-2.success}}"
75
+
76
+ # Conditional branches (optional)
77
+ # branches:
78
+ # - condition: "{{steps.step-2.output.type == 'a'}}"
79
+ # steps:
80
+ # - id: branch-a-step
81
+ # name: "Branch A Step"
82
+ # action: task
83
+ # task: branch-a-task
84
+
85
+ # Output definition
86
+ outputs:
87
+ - name: result
88
+ from: "{{steps.step-3.output}}"
89
+ description: "Final workflow result"
90
+
91
+ # Completion handlers
92
+ completion:
93
+ on_success:
94
+ message: "Workflow '{{COMPONENTNAME}}' completed successfully"
95
+ notify: false
96
+ on_failure:
97
+ message: "Workflow '{{COMPONENTNAME}}' failed"
98
+ notify: true
99
+ rollback: true
100
+
101
+ # Validation
102
+ validation:
103
+ pre_run:
104
+ - "Check all required inputs are provided"
105
+ - "Validate input formats"
106
+ post_run:
107
+ - "Verify output is valid"
108
+ - "Log completion metrics"
@@ -7,10 +7,10 @@
7
7
  # - SHA256 hashes for change detection
8
8
  # - File types for categorization
9
9
  #
10
- version: 3.7.0
11
- generated_at: "2025-12-24T14:42:11.316Z"
10
+ version: 3.8.0
11
+ generated_at: "2025-12-26T21:45:10.223Z"
12
12
  generator: scripts/generate-install-manifest.js
13
- file_count: 579
13
+ file_count: 595
14
14
  files:
15
15
  - path: cli/commands/generate/index.js
16
16
  hash: sha256:36f8e38ab767fa5478d8dabac548c66dc2c0fc521c216e954ac33fcea0ba597b
@@ -329,13 +329,13 @@ files:
329
329
  type: core
330
330
  size: 9178
331
331
  - path: core/session/context-detector.js
332
- hash: sha256:cd77730a0608269bea82d1d794466de538706cbf45e26beef716061b4edeb2bb
332
+ hash: sha256:e76b2a1ae649b2780bfe94259d1f35e9bdd4a3dbde3a4e6f5c610cb1cb553ecb
333
333
  type: core
334
- size: 7069
334
+ size: 7217
335
335
  - path: core/session/context-loader.js
336
- hash: sha256:280345c1a2e1925b75830534eff172a6e28e8850c9831fc1b2fdc1406ff43e68
336
+ hash: sha256:368214ee83593867cef7a220289ec1ec0e4c06ff1998432322e2f7d852345b51
337
337
  type: core
338
- size: 8216
338
+ size: 13747
339
339
  - path: core/utils/output-formatter.js
340
340
  hash: sha256:9c386d8b0232f92887dc6f8d32671444a5857b6c848c84b561eedef27a178470
341
341
  type: core
@@ -356,14 +356,18 @@ files:
356
356
  hash: sha256:21138a86582b713c2106973907bbf4a5ce4e3192dadd832122ac9c6294d0efb1
357
357
  type: data
358
358
  size: 34868
359
+ - path: data/learned-patterns.yaml
360
+ hash: sha256:24ac0b160615583a0ff783d3da8af80b7f94191575d6db2054ec8e10a3f945dc
361
+ type: data
362
+ size: 68
359
363
  - path: data/technical-preferences.md
360
364
  hash: sha256:6d1111823aefaca138dfaa3661139ae57db0ec9841046617e5024a24e532f570
361
365
  type: data
362
366
  size: 64
363
367
  - path: data/workflow-patterns.yaml
364
- hash: sha256:a84b99984dcf1930705d82cbf771716bc0a6b909b3c854251ba178385b209f49
368
+ hash: sha256:e43d4622473a9a7ffa119c17f154d37ae5b1c4a07335826514d6694e200f2d11
365
369
  type: data
366
- size: 8239
370
+ size: 19713
367
371
  - path: development/agent-teams/team-all.yaml
368
372
  hash: sha256:368efa25930f89d33ee4178c7b77871ad2ca1437ca56376233b0c375a2cb311c
369
373
  type: development
@@ -401,9 +405,9 @@ files:
401
405
  type: agent
402
406
  size: 20268
403
407
  - path: development/agents/dev.md
404
- hash: sha256:69a342848917c90bcd91517d226c0b0e55e06abf0871ecf2e7a1eb6f7ea67026
408
+ hash: sha256:b2fc2c28bb871f710546b8e7c6d29cb38966e518be15970fb5073fe39c13f3d5
405
409
  type: agent
406
- size: 17964
410
+ size: 18222
407
411
  - path: development/agents/devops.md
408
412
  hash: sha256:0c7ea6fb80b5758d978003f17aa6c5ba8ca1a5433ac0c53b1dd131e7ecae18a5
409
413
  type: agent
@@ -425,9 +429,9 @@ files:
425
429
  type: agent
426
430
  size: 9866
427
431
  - path: development/agents/squad-creator.md
428
- hash: sha256:b2d40ad818043acd04cb00eb2e5ff778498c65dc91bf81eb6675467fcd60c514
432
+ hash: sha256:51f829162b81693bf34e010718a81f3aa484336f6488e2c7655d2cf5798e79fc
429
433
  type: agent
430
- size: 10367
434
+ size: 11770
431
435
  - path: development/agents/ux-design-expert.md
432
436
  hash: sha256:ce2f28bbd7350f1ca7d1b01ae26924928e496314afb551cafb55604233117954
433
437
  type: agent
@@ -512,6 +516,10 @@ files:
512
516
  hash: sha256:55e0226c3baffe16fd24f3d19179326c43e8dc525697c0b5c972cf15825f7c14
513
517
  type: script
514
518
  size: 3244
519
+ - path: development/scripts/squad/squad-analyzer.js
520
+ hash: sha256:30100571f7d46705b60432fc9e56a19852786d1b3b5a77354e247519b8ca8682
521
+ type: script
522
+ size: 18148
515
523
  - path: development/scripts/squad/squad-designer.js
516
524
  hash: sha256:101cbb7d6ded0d6f991b29ac63dfee2c7bb86cbc8c4fefef728b7d12c3352829
517
525
  type: script
@@ -520,26 +528,30 @@ files:
520
528
  hash: sha256:a62dd5d40ef24426ffdabdcbe0a0a3a7e7e2b1757eba9749a41d3fd4c0e690f8
521
529
  type: script
522
530
  size: 15335
531
+ - path: development/scripts/squad/squad-extender.js
532
+ hash: sha256:ceab4df7d9708449aff28eb2b5cbf57f11b2c93196280c814bf02787e7db22f3
533
+ type: script
534
+ size: 20638
523
535
  - path: development/scripts/squad/squad-generator.js
524
- hash: sha256:6d47ee7e0c662ffd7a8c5975ceca3e71addb54f59fb771d55402d0d57ce3d7d8
536
+ hash: sha256:fa83979eeeac361713e8f99bfec6ac9f9dc9d8d4107ecf809cd3b7370a4de79c
525
537
  type: script
526
- size: 40312
538
+ size: 44048
527
539
  - path: development/scripts/squad/squad-loader.js
528
540
  hash: sha256:7093b9457c93da6845722bf7eac660164963d5007c459afae2149340a7979f1f
529
541
  type: script
530
542
  size: 10549
531
543
  - path: development/scripts/squad/squad-migrator.js
532
- hash: sha256:883899cb84117b66074004fb683ba5f9cefebc57eeb9758f79784e0a92afcd90
544
+ hash: sha256:7aa7c77f252853faa3230898f37f987713c02a21937da69bf0f0da4074884b4a
533
545
  type: script
534
- size: 19520
546
+ size: 19517
535
547
  - path: development/scripts/squad/squad-publisher.js
536
548
  hash: sha256:329c00fb9d1085675a319e8314a5be9e1ee92c617691c47041f58d994982e029
537
549
  type: script
538
550
  size: 18724
539
551
  - path: development/scripts/squad/squad-validator.js
540
- hash: sha256:a19af336adf8caaa79f98e52ab78aee57a9a0a0041f3c4b6c9663a321c0a7f64
552
+ hash: sha256:90f7b1d6f9b072718a7029afe5c238b66c6b880ee18d6c416244dca5d9a6bfa1
541
553
  type: script
542
- size: 19470
554
+ size: 23034
543
555
  - path: development/scripts/story-index-generator.js
544
556
  hash: sha256:5c9bf1339857e25b20875193c6dd42ac6c829491c0f46ba26bf07652aff6ed8b
545
557
  type: script
@@ -908,6 +920,14 @@ files:
908
920
  hash: sha256:091a4236aaf2ef93f6f394b99dc43cbedccbd9a864d55f4992a50dd4684bc97f
909
921
  type: task
910
922
  size: 11422
923
+ - path: development/tasks/next.md
924
+ hash: sha256:53f4311ff6797342701c870b9552884815537dde8cb4936a0b3b5bf53b820f32
925
+ type: task
926
+ size: 6550
927
+ - path: development/tasks/patterns.md
928
+ hash: sha256:447ea50e9c7483d4dd9f88750aee95d459a20385c1c6baea41d93ac3090aa1f8
929
+ type: task
930
+ size: 7372
911
931
  - path: development/tasks/po-backlog-add.md
912
932
  hash: sha256:6d13427b0f323cd27a612ac1504807f66e9aad88ec2ff417ba09ecb0b5b6b850
913
933
  type: task
@@ -1032,10 +1052,14 @@ files:
1032
1052
  hash: sha256:f2a2f314a11af481d48991112c871d65e1def7bb3c9a283b661b67a1f939ac9b
1033
1053
  type: task
1034
1054
  size: 18062
1055
+ - path: development/tasks/squad-creator-analyze.md
1056
+ hash: sha256:5e1c24c1474e77a517b266c862a915d4b5c632340bb7ea426b5ac50ee53273e0
1057
+ type: task
1058
+ size: 7040
1035
1059
  - path: development/tasks/squad-creator-create.md
1036
- hash: sha256:b4c87391c3348ac875d0da966cf28098b5a8d61c67e64360deb7d4c6807db2f9
1060
+ hash: sha256:65f50ac890b671b9321ff18156de02d45b4b5075d3037fa847a5bfe304e7e662
1037
1061
  type: task
1038
- size: 7503
1062
+ size: 8447
1039
1063
  - path: development/tasks/squad-creator-design.md
1040
1064
  hash: sha256:47bcc27f3d3bfa81e567d009b50ac278db386fda48e5a60a3cce7643ef2362bc
1041
1065
  type: task
@@ -1044,6 +1068,10 @@ files:
1044
1068
  hash: sha256:909088d7b585fbb8b465e0b0238ab49546c51876a6752a30f7bf7bf1bf22ef24
1045
1069
  type: task
1046
1070
  size: 3856
1071
+ - path: development/tasks/squad-creator-extend.md
1072
+ hash: sha256:ba5fbc0d4c1512f22790e80efc0660f2af2673a243d3c6d6568bbc76c54d1eef
1073
+ type: task
1074
+ size: 10219
1047
1075
  - path: development/tasks/squad-creator-list.md
1048
1076
  hash: sha256:c0b52c5a8a79b3ed757789e633f42a5458bac18bbcf1aa544fc1f5295151b446
1049
1077
  type: task
@@ -1061,9 +1089,9 @@ files:
1061
1089
  type: task
1062
1090
  size: 8633
1063
1091
  - path: development/tasks/squad-creator-validate.md
1064
- hash: sha256:c07c44217e882cae387d849658e091046e32735a62f6d28e496b4eb042121b98
1092
+ hash: sha256:e4dc8af3ac29ca91998f1db3c70a8ae5a2380f4131dcd635a34eb7ffa24d3b0a
1065
1093
  type: task
1066
- size: 4607
1094
+ size: 5065
1067
1095
  - path: development/tasks/sync-documentation.md
1068
1096
  hash: sha256:caa2077e7a5bbbba9269b04e878b7772a71422ed6fd138447fe5cfb7345f96fb
1069
1097
  type: task
@@ -1104,6 +1132,10 @@ files:
1104
1132
  hash: sha256:7ff03b62614edeb2a9c2bab9681a56ce97cffc59af3bd51054b9dafb1c99701f
1105
1133
  type: task
1106
1134
  size: 14320
1135
+ - path: development/tasks/waves.md
1136
+ hash: sha256:364b955b3315f1621a27ea26ff1459467a19c87781ac714e387fb616aeb336e6
1137
+ type: task
1138
+ size: 4686
1107
1139
  - path: development/templates/service-template/__tests__/index.test.ts.hbs
1108
1140
  hash: sha256:04090b95bc0b606448c161d8e698fcf4d5c7da2517a5ac65663554a54c5acf91
1109
1141
  type: template
@@ -1140,6 +1172,38 @@ files:
1140
1172
  hash: sha256:2338ab2e1ade619bf33a2c8f22b149402b513c05a6d1d8a805c5273c7233d151
1141
1173
  type: template
1142
1174
  size: 2516
1175
+ - path: development/templates/squad/agent-template.md
1176
+ hash: sha256:b8ba4621f0bf03bf3612a683cebaa52e246cba19fb81197493ec4d682a1db14b
1177
+ type: template
1178
+ size: 1432
1179
+ - path: development/templates/squad/checklist-template.md
1180
+ hash: sha256:5c962f20d7d56ef8800f60dc32f8105b2669311664cfd330301f812dc67934af
1181
+ type: template
1182
+ size: 1317
1183
+ - path: development/templates/squad/data-template.yaml
1184
+ hash: sha256:d228821b39c7135e19f49405c10cae7ac43f5ffcd946d6363f053420a3a3019f
1185
+ type: template
1186
+ size: 2121
1187
+ - path: development/templates/squad/script-template.js
1188
+ hash: sha256:2d568171ef0c7ed2822d2b1d81a5f0d02c16bd2a2fb11665c8608dd7da7fc323
1189
+ type: template
1190
+ size: 3375
1191
+ - path: development/templates/squad/task-template.md
1192
+ hash: sha256:3f337082a14cd33dd4876d5dc487d0ec069dad5f54aeaac9853b2a13051a70db
1193
+ type: template
1194
+ size: 1882
1195
+ - path: development/templates/squad/template-template.md
1196
+ hash: sha256:b3f13da1cd377d18d3202bd8998fd9f26ad56b5da4b63e316cd01578998b7f55
1197
+ type: template
1198
+ size: 1497
1199
+ - path: development/templates/squad/tool-template.js
1200
+ hash: sha256:31e026003459be51451d0ca6905847bab2d9e397d92dc9b521b563516d27b5cf
1201
+ type: template
1202
+ size: 1796
1203
+ - path: development/templates/squad/workflow-template.yaml
1204
+ hash: sha256:837991039c9dcb77ad4ded82035da96eac70ac2c4fd208833ace470a3ec32c0e
1205
+ type: template
1206
+ size: 2199
1143
1207
  - path: development/workflows/brownfield-fullstack.yaml
1144
1208
  hash: sha256:e54b5ecf6fffd1351bad125c91be89b262773361785d1f0ee19a7dc2fcdf8822
1145
1209
  type: workflow
@@ -2305,9 +2369,9 @@ files:
2305
2369
  type: script
2306
2370
  size: 4527
2307
2371
  - path: scripts/session-context-loader.js
2308
- hash: sha256:f24c6b273bd19a7b25aa60e68f93df3a100bc291291eeb95cab60a2c001415e6
2372
+ hash: sha256:2581477ca682c6788fc57759b7fc697ffbcaab0a2c1c0cd6eb4f9ad228bb1020
2309
2373
  type: script
2310
- size: 8145
2374
+ size: 1583
2311
2375
  - path: scripts/test-template-system.js
2312
2376
  hash: sha256:4e365df5372a8e09abb43f1f92e99d3e654a51b333dde232bad956e534a481db
2313
2377
  type: script
@@ -279,6 +279,10 @@ class MetricsCollector {
279
279
 
280
280
  const metrics = await this.load();
281
281
 
282
+ // Enforce retention policy before adding new entries (Story SQS-10 nitpick)
283
+ // This prevents unbounded growth of history array
284
+ await this._enforceRetentionPolicy(metrics);
285
+
282
286
  const runRecord = {
283
287
  timestamp: new Date().toISOString(),
284
288
  layer,
@@ -519,6 +523,29 @@ class MetricsCollector {
519
523
  return removedCount;
520
524
  }
521
525
 
526
+ /**
527
+ * Enforce retention policy inline (called before adding new entries)
528
+ * This prevents unbounded growth of the history array.
529
+ * @private
530
+ * @param {Object} metrics - Metrics object to clean
531
+ * @returns {Promise<void>}
532
+ * @see CodeRabbit nitpick: Enforce retention policy to prevent unbounded growth
533
+ */
534
+ async _enforceRetentionPolicy(metrics) {
535
+ const retentionMs = (metrics.retentionDays || this.retentionDays) * 24 * 60 * 60 * 1000;
536
+ const cutoffTimestamp = Date.now() - retentionMs;
537
+
538
+ const originalCount = metrics.history.length;
539
+ metrics.history = metrics.history.filter(
540
+ (entry) => new Date(entry.timestamp).getTime() > cutoffTimestamp,
541
+ );
542
+
543
+ const removedCount = originalCount - metrics.history.length;
544
+ if (removedCount > 0) {
545
+ console.log(`[metrics] Retention policy: removed ${removedCount} old entries (> ${metrics.retentionDays || this.retentionDays} days)`);
546
+ }
547
+ }
548
+
522
549
  /**
523
550
  * Get history for a specific layer
524
551
  * @param {number} layer - Layer number
@@ -1,265 +1,24 @@
1
1
  /**
2
- * Session Context Loader - Multi-Agent Session Continuity
2
+ * Session Context Loader - Re-export from canonical location
3
3
  *
4
- * Provides session context when transitioning between agents.
5
- * Solves the problem: "@po approved story, @dev doesn't know about it"
4
+ * @deprecated Use require('../core/session/context-loader') directly
5
+ * @module scripts/session-context-loader
6
6
  *
7
- * Features:
8
- * - Detects previous agent in session
9
- * - Tracks last N commands
10
- * - Identifies active workflow
11
- * - Provides natural language summary for new agent
7
+ * This file re-exports SessionContextLoader from its canonical location
8
+ * in core/session/context-loader.js for backward compatibility.
12
9
  *
13
- * Part of Story 6.1.2.5 UX Improvements
10
+ * Migration note (WIS-3):
11
+ * - Canonical location: .aios-core/core/session/context-loader.js
12
+ * - This file exists for backward compatibility with existing imports
13
+ * - New code should import from core/session/context-loader directly
14
14
  */
15
15
 
16
- const fs = require('fs');
17
- const path = require('path');
18
- const ContextDetector = require('../core/session/context-detector');
16
+ 'use strict';
19
17
 
20
- const SESSION_STATE_PATH = path.join(process.cwd(), '.aios', 'session-state.json');
21
- const MAX_COMMANDS_HISTORY = 10;
18
+ // Re-export from canonical location
19
+ const SessionContextLoader = require('../core/session/context-loader');
22
20
 
23
- class SessionContextLoader {
24
- constructor() {
25
- this.detector = new ContextDetector();
26
- this.sessionStatePath = SESSION_STATE_PATH;
27
- }
28
-
29
- /**
30
- * Load session context for current agent activation
31
- *
32
- * @param {string} currentAgentId - ID of agent being activated
33
- * @returns {Object} Session context
34
- */
35
- loadContext(currentAgentId) {
36
- // Pass sessionStatePath to detector so it uses the correct file (important for testing)
37
- const sessionType = this.detector.detectSessionType([], this.sessionStatePath);
38
- const sessionState = this.loadSessionState();
39
-
40
- if (sessionType === 'new') {
41
- // Fresh session - no context
42
- return {
43
- sessionType: 'new',
44
- message: null,
45
- previousAgent: null,
46
- lastCommands: [],
47
- workflowActive: null,
48
- };
49
- }
50
-
51
- // Extract context information
52
- const previousAgent = this.getPreviousAgent(sessionState, currentAgentId);
53
- const lastCommands = sessionState.lastCommands || [];
54
- const workflowActive = sessionState.workflowActive || null;
55
-
56
- // Generate natural language summary
57
- const message = this.generateContextMessage({
58
- sessionType,
59
- previousAgent,
60
- lastCommands,
61
- workflowActive,
62
- currentAgentId,
63
- });
64
-
65
- return {
66
- sessionType,
67
- message,
68
- previousAgent,
69
- lastCommands,
70
- workflowActive,
71
- currentStory: sessionState.currentStory || null,
72
- sessionId: sessionState.sessionId,
73
- sessionStartTime: sessionState.startTime,
74
- };
75
- }
76
-
77
- /**
78
- * Load session state from file
79
- *
80
- * @returns {Object} Session state
81
- */
82
- loadSessionState() {
83
- try {
84
- if (!fs.existsSync(this.sessionStatePath)) {
85
- return {};
86
- }
87
-
88
- const content = fs.readFileSync(this.sessionStatePath, 'utf8');
89
- return JSON.parse(content);
90
- } catch (error) {
91
- console.warn('[SessionContext] Failed to load session state:', error.message);
92
- return {};
93
- }
94
- }
95
-
96
- /**
97
- * Get previous agent from session
98
- *
99
- * @param {Object} sessionState - Session state
100
- * @param {string} currentAgentId - Current agent ID
101
- * @returns {Object|null} Previous agent info
102
- */
103
- getPreviousAgent(sessionState, currentAgentId) {
104
- const agentSequence = sessionState.agentSequence || [];
105
-
106
- if (agentSequence.length === 0) {
107
- return null;
108
- }
109
-
110
- // Get last agent that's different from current
111
- for (let i = agentSequence.length - 1; i >= 0; i--) {
112
- const agent = agentSequence[i];
113
- if (agent.agentId !== currentAgentId) {
114
- return {
115
- agentId: agent.agentId,
116
- agentName: agent.agentName,
117
- activatedAt: agent.activatedAt,
118
- lastCommand: agent.lastCommand,
119
- };
120
- }
121
- }
122
-
123
- return null;
124
- }
125
-
126
- /**
127
- * Generate natural language context message
128
- *
129
- * @param {Object} context - Context data
130
- * @returns {string|null} Context message
131
- */
132
- generateContextMessage(context) {
133
- const { sessionType, previousAgent, lastCommands, workflowActive } = context;
134
-
135
- if (sessionType === 'new') {
136
- return null;
137
- }
138
-
139
- const parts = [];
140
-
141
- // Previous agent context
142
- if (previousAgent) {
143
- const agentName = previousAgent.agentName || previousAgent.agentId;
144
- const minutesAgo = Math.floor((Date.now() - previousAgent.activatedAt) / 60000);
145
- const timeAgo = minutesAgo < 1 ? 'just now' : minutesAgo === 1 ? '1 minute ago' : `${minutesAgo} minutes ago`;
146
-
147
- parts.push(`📍 **Session Context**: Continuing from @${previousAgent.agentId} (${agentName}) activated ${timeAgo}`);
148
-
149
- if (previousAgent.lastCommand) {
150
- parts.push(` Last action: *${previousAgent.lastCommand}`);
151
- }
152
- }
153
-
154
- // Recent commands
155
- if (lastCommands.length > 0) {
156
- const recentCmds = lastCommands.slice(-5).join(', *');
157
- parts.push(` Recent commands: *${recentCmds}`);
158
- }
159
-
160
- // Active workflow
161
- if (workflowActive) {
162
- parts.push(` ⚡ Active Workflow: ${workflowActive}`);
163
- }
164
-
165
- return parts.length > 0 ? parts.join('\n') : null;
166
- }
167
-
168
- /**
169
- * Update session state with current agent
170
- *
171
- * @param {string} agentId - Agent ID
172
- * @param {string} agentName - Agent name
173
- * @param {string} lastCommand - Last command executed
174
- * @param {Object} options - Update options
175
- */
176
- updateSession(agentId, agentName, lastCommand = null, options = {}) {
177
- try {
178
- const sessionState = this.loadSessionState();
179
-
180
- // Initialize if new session
181
- if (!sessionState.sessionId) {
182
- sessionState.sessionId = `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
183
- sessionState.startTime = Date.now();
184
- }
185
-
186
- // Update activity timestamp
187
- sessionState.lastActivity = Date.now();
188
-
189
- // Update agent sequence
190
- if (!sessionState.agentSequence) {
191
- sessionState.agentSequence = [];
192
- }
193
-
194
- sessionState.agentSequence.push({
195
- agentId,
196
- agentName,
197
- activatedAt: Date.now(),
198
- lastCommand,
199
- });
200
-
201
- // Keep last 20 agent activations
202
- if (sessionState.agentSequence.length > 20) {
203
- sessionState.agentSequence = sessionState.agentSequence.slice(-20);
204
- }
205
-
206
- // Update command history
207
- if (lastCommand) {
208
- if (!sessionState.lastCommands) {
209
- sessionState.lastCommands = [];
210
- }
211
-
212
- sessionState.lastCommands.push(lastCommand);
213
-
214
- // Keep last N commands
215
- if (sessionState.lastCommands.length > MAX_COMMANDS_HISTORY) {
216
- sessionState.lastCommands = sessionState.lastCommands.slice(-MAX_COMMANDS_HISTORY);
217
- }
218
- }
219
-
220
- // Update workflow status
221
- if (options.workflowActive !== undefined) {
222
- sessionState.workflowActive = options.workflowActive;
223
- }
224
-
225
- // Save to file
226
- this.detector.updateSessionState(sessionState, this.sessionStatePath);
227
- } catch (error) {
228
- console.warn('[SessionContext] Failed to update session:', error.message);
229
- }
230
- }
231
-
232
- /**
233
- * Clear session (start fresh)
234
- */
235
- clearSession() {
236
- try {
237
- if (fs.existsSync(this.sessionStatePath)) {
238
- fs.unlinkSync(this.sessionStatePath);
239
- }
240
- } catch (error) {
241
- console.warn('[SessionContext] Failed to clear session:', error.message);
242
- }
243
- }
244
-
245
- /**
246
- * Format context for display in agent greeting
247
- *
248
- * @param {string} currentAgentId - Current agent ID
249
- * @returns {string} Formatted context message
250
- */
251
- formatForGreeting(currentAgentId) {
252
- const context = this.loadContext(currentAgentId);
253
-
254
- if (!context.message) {
255
- return '';
256
- }
257
-
258
- return `\n${context.message}\n`;
259
- }
260
- }
261
-
262
- // CLI Interface
21
+ // CLI Interface (preserved for backward compatibility)
263
22
  if (require.main === module) {
264
23
  const loader = new SessionContextLoader();
265
24
  const command = process.argv[2];
@@ -0,0 +1,25 @@
1
+ /**
2
+ * AIOS Validator - Re-export from canonical location
3
+ *
4
+ * @deprecated Use require('../infrastructure/scripts/aios-validator') directly
5
+ * @module utils/aios-validator
6
+ *
7
+ * This file re-exports from the canonical location in infrastructure/scripts/
8
+ * for backward compatibility with CI workflows.
9
+ *
10
+ * Migration note:
11
+ * - Canonical location: .aios-core/infrastructure/scripts/aios-validator.js
12
+ * - This file exists for backward compatibility with existing CI workflows
13
+ * - New code should import from infrastructure/scripts/aios-validator directly
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ // Re-export from canonical location
19
+ module.exports = require('../infrastructure/scripts/aios-validator');
20
+
21
+ // CLI Interface - delegate to canonical location
22
+ if (require.main === module) {
23
+ // Pass through to the original script
24
+ require('../infrastructure/scripts/aios-validator');
25
+ }