add-skill-kit 3.2.3 → 3.2.5

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 (126) hide show
  1. package/README.md +1 -1
  2. package/bin/lib/commands/help.js +0 -4
  3. package/bin/lib/commands/install.js +90 -9
  4. package/bin/lib/ui.js +1 -1
  5. package/lib/agent-cli/__tests__/adaptive_engine.test.js +190 -0
  6. package/lib/agent-cli/__tests__/integration/cross_script.test.js +222 -0
  7. package/lib/agent-cli/__tests__/integration/full_cycle.test.js +230 -0
  8. package/lib/agent-cli/__tests__/pattern_analyzer.test.js +173 -0
  9. package/lib/agent-cli/__tests__/pre_execution_check.test.js +167 -0
  10. package/lib/agent-cli/__tests__/skill_injector.test.js +191 -0
  11. package/lib/agent-cli/bin/agent.js +191 -0
  12. package/lib/agent-cli/dashboard/dashboard_server.js +340 -0
  13. package/lib/agent-cli/dashboard/index.html +538 -0
  14. package/lib/agent-cli/lib/audit.js +154 -0
  15. package/lib/agent-cli/lib/audit.test.js +100 -0
  16. package/lib/agent-cli/lib/auto-learn.js +319 -0
  17. package/lib/agent-cli/lib/auto_preview.py +148 -0
  18. package/lib/agent-cli/lib/backup.js +138 -0
  19. package/lib/agent-cli/lib/backup.test.js +78 -0
  20. package/lib/agent-cli/lib/checklist.py +222 -0
  21. package/lib/agent-cli/lib/cognitive-lesson.js +476 -0
  22. package/lib/agent-cli/lib/completion.js +149 -0
  23. package/lib/agent-cli/lib/config.js +35 -0
  24. package/lib/agent-cli/lib/eslint-fix.js +238 -0
  25. package/lib/agent-cli/lib/evolution-signal.js +215 -0
  26. package/lib/agent-cli/lib/export.js +86 -0
  27. package/lib/agent-cli/lib/export.test.js +65 -0
  28. package/lib/agent-cli/lib/fix.js +337 -0
  29. package/lib/agent-cli/lib/fix.test.js +80 -0
  30. package/lib/agent-cli/lib/gemini-export.js +83 -0
  31. package/lib/agent-cli/lib/generate-registry.js +42 -0
  32. package/lib/agent-cli/lib/hooks/install-hooks.js +152 -0
  33. package/lib/agent-cli/lib/hooks/lint-learn.js +172 -0
  34. package/lib/agent-cli/lib/ignore.js +116 -0
  35. package/lib/agent-cli/lib/ignore.test.js +58 -0
  36. package/lib/agent-cli/lib/init.js +124 -0
  37. package/lib/agent-cli/lib/learn.js +255 -0
  38. package/lib/agent-cli/lib/learn.test.js +70 -0
  39. package/lib/agent-cli/lib/migrate-to-v4.js +322 -0
  40. package/lib/agent-cli/lib/proposals.js +199 -0
  41. package/lib/agent-cli/lib/proposals.test.js +56 -0
  42. package/lib/agent-cli/lib/recall.js +820 -0
  43. package/lib/agent-cli/lib/recall.test.js +107 -0
  44. package/lib/agent-cli/lib/selfevolution-bridge.js +167 -0
  45. package/lib/agent-cli/lib/session_manager.py +120 -0
  46. package/lib/agent-cli/lib/settings.js +227 -0
  47. package/lib/agent-cli/lib/skill-learn.js +296 -0
  48. package/lib/agent-cli/lib/stats.js +132 -0
  49. package/lib/agent-cli/lib/stats.test.js +94 -0
  50. package/lib/agent-cli/lib/types.js +33 -0
  51. package/lib/agent-cli/lib/ui/audit-ui.js +146 -0
  52. package/lib/agent-cli/lib/ui/backup-ui.js +107 -0
  53. package/lib/agent-cli/lib/ui/clack-helpers.js +317 -0
  54. package/lib/agent-cli/lib/ui/common.js +83 -0
  55. package/lib/agent-cli/lib/ui/completion-ui.js +126 -0
  56. package/lib/agent-cli/lib/ui/custom-select.js +69 -0
  57. package/lib/agent-cli/lib/ui/dashboard-ui.js +222 -0
  58. package/lib/agent-cli/lib/ui/evolution-signals-ui.js +107 -0
  59. package/lib/agent-cli/lib/ui/export-ui.js +94 -0
  60. package/lib/agent-cli/lib/ui/fix-all-ui.js +191 -0
  61. package/lib/agent-cli/lib/ui/help-ui.js +49 -0
  62. package/lib/agent-cli/lib/ui/index.js +199 -0
  63. package/lib/agent-cli/lib/ui/init-ui.js +56 -0
  64. package/lib/agent-cli/lib/ui/knowledge-ui.js +55 -0
  65. package/lib/agent-cli/lib/ui/learn-ui.js +706 -0
  66. package/lib/agent-cli/lib/ui/lessons-ui.js +148 -0
  67. package/lib/agent-cli/lib/ui/pretty.js +145 -0
  68. package/lib/agent-cli/lib/ui/proposals-ui.js +99 -0
  69. package/lib/agent-cli/lib/ui/recall-ui.js +342 -0
  70. package/lib/agent-cli/lib/ui/routing-demo.js +79 -0
  71. package/lib/agent-cli/lib/ui/routing-ui.js +325 -0
  72. package/lib/agent-cli/lib/ui/settings-ui.js +381 -0
  73. package/lib/agent-cli/lib/ui/stats-ui.js +123 -0
  74. package/lib/agent-cli/lib/ui/watch-ui.js +236 -0
  75. package/lib/agent-cli/lib/verify_all.py +327 -0
  76. package/lib/agent-cli/lib/watcher.js +181 -0
  77. package/lib/agent-cli/lib/watcher.test.js +85 -0
  78. package/lib/agent-cli/package.json +51 -0
  79. package/lib/agent-cli/scripts/adaptive_engine.js +381 -0
  80. package/lib/agent-cli/scripts/dashboard_server.js +224 -0
  81. package/lib/agent-cli/scripts/error_sensor.js +565 -0
  82. package/lib/agent-cli/scripts/learn_from_failure.js +225 -0
  83. package/lib/agent-cli/scripts/pattern_analyzer.js +781 -0
  84. package/lib/agent-cli/scripts/pre_execution_check.js +623 -0
  85. package/lib/agent-cli/scripts/rule_sharing.js +374 -0
  86. package/lib/agent-cli/scripts/skill_injector.js +387 -0
  87. package/lib/agent-cli/scripts/success_sensor.js +500 -0
  88. package/lib/agent-cli/scripts/user_correction_sensor.js +426 -0
  89. package/lib/agent-cli/services/auto-learn-service.js +247 -0
  90. package/lib/agent-cli/src/MIGRATION.md +418 -0
  91. package/lib/agent-cli/src/README.md +367 -0
  92. package/lib/agent-cli/src/core/evolution/evolution-signal.js +42 -0
  93. package/lib/agent-cli/src/core/evolution/index.js +17 -0
  94. package/lib/agent-cli/src/core/evolution/review-gate.js +40 -0
  95. package/lib/agent-cli/src/core/evolution/signal-detector.js +137 -0
  96. package/lib/agent-cli/src/core/evolution/signal-queue.js +79 -0
  97. package/lib/agent-cli/src/core/evolution/threshold-checker.js +79 -0
  98. package/lib/agent-cli/src/core/index.js +15 -0
  99. package/lib/agent-cli/src/core/learning/cognitive-enhancer.js +282 -0
  100. package/lib/agent-cli/src/core/learning/index.js +12 -0
  101. package/lib/agent-cli/src/core/learning/lesson-synthesizer.js +83 -0
  102. package/lib/agent-cli/src/core/scanning/index.js +14 -0
  103. package/lib/agent-cli/src/data/index.js +13 -0
  104. package/lib/agent-cli/src/data/repositories/index.js +8 -0
  105. package/lib/agent-cli/src/data/repositories/lesson-repository.js +130 -0
  106. package/lib/agent-cli/src/data/repositories/signal-repository.js +119 -0
  107. package/lib/agent-cli/src/data/storage/index.js +8 -0
  108. package/lib/agent-cli/src/data/storage/json-storage.js +64 -0
  109. package/lib/agent-cli/src/data/storage/yaml-storage.js +66 -0
  110. package/lib/agent-cli/src/infrastructure/index.js +13 -0
  111. package/lib/agent-cli/src/presentation/formatters/skill-formatter.js +232 -0
  112. package/lib/agent-cli/src/services/export-service.js +162 -0
  113. package/lib/agent-cli/src/services/index.js +13 -0
  114. package/lib/agent-cli/src/services/learning-service.js +99 -0
  115. package/lib/agent-cli/types/index.d.ts +343 -0
  116. package/lib/agent-cli/utils/benchmark.js +269 -0
  117. package/lib/agent-cli/utils/logger.js +303 -0
  118. package/lib/agent-cli/utils/ml_patterns.js +300 -0
  119. package/lib/agent-cli/utils/recovery.js +312 -0
  120. package/lib/agent-cli/utils/telemetry.js +290 -0
  121. package/lib/agentskillskit-cli/README.md +21 -0
  122. package/{node_modules/agentskillskit-cli/bin → lib/agentskillskit-cli}/ag-smart.js +15 -15
  123. package/lib/agentskillskit-cli/package.json +51 -0
  124. package/package.json +19 -9
  125. /package/bin/{cli.js → kit.js} +0 -0
  126. /package/{node_modules/agentskillskit-cli → lib/agent-cli}/README.md +0 -0
@@ -0,0 +1,418 @@
1
+ # Migration Guide - Old → New Architecture
2
+
3
+ This guide helps you migrate code from the old flat structure to the new layered architecture.
4
+
5
+ ---
6
+
7
+ ## Quick Reference
8
+
9
+ | Old Location | New Location | Layer |
10
+ |--------------|--------------|-------|
11
+ | `lib/evolution-signal.js` | `src/core/evolution/*` | Core + Data |
12
+ | `lib/cognitive-lesson.js` | `src/core/learning/*` | Core |
13
+ | `lib/recall.js` | `src/core/scanning/*` | Core |
14
+ | `lib/settings.js` | `src/data/repositories/settings-repository.js` | Data |
15
+ | `lib/ui/` | `src/presentation/cli/` | Presentation |
16
+
17
+ ---
18
+
19
+ ## Migration Patterns
20
+
21
+ ### Pattern 1: Evolution Signals
22
+
23
+ #### Old Code
24
+ ```javascript
25
+ // lib/some-file.js
26
+ import { signalQueue, checkEvolutionThreshold } from './evolution-signal.js';
27
+
28
+ function doSomething(lesson) {
29
+ const check = checkEvolutionThreshold(lesson, 10);
30
+ if (check.ready) {
31
+ signalQueue.add(new EvolutionSignal(...));
32
+ }
33
+ }
34
+ ```
35
+
36
+ #### New Code
37
+ ```javascript
38
+ // src/services/some-service.js
39
+ import { SignalDetector } from '../core/evolution/signal-detector.js';
40
+ import { ThresholdChecker } from '../core/evolution/threshold-checker.js';
41
+
42
+ export class SomeService {
43
+ constructor(signalDetector) {
44
+ this.signalDetector = signalDetector;
45
+ }
46
+
47
+ async doSomething(lesson) {
48
+ const check = ThresholdChecker.check(lesson, 10);
49
+ if (check.ready) {
50
+ await this.signalDetector.queue(lesson.id, check, metadata);
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ **Key Changes:**
57
+ - ✅ Use dependency injection
58
+ - ✅ Use async/await
59
+ - ✅ Static methods for pure functions
60
+
61
+ ---
62
+
63
+ ### Pattern 2: Direct File Access
64
+
65
+ #### Old Code
66
+ ```javascript
67
+ // lib/some-file.js
68
+ import fs from 'fs';
69
+ import path from 'path';
70
+
71
+ function saveData(data) {
72
+ const filePath = path.join(KNOWLEDGE_DIR, 'data.json');
73
+ fs.writeFileSync(filePath, JSON.stringify(data));
74
+ }
75
+ ```
76
+
77
+ #### New Code
78
+ ```javascript
79
+ // src/data/repositories/some-repository.js
80
+ export class SomeRepository {
81
+ constructor(storage) {
82
+ this.storage = storage;
83
+ }
84
+
85
+ async save(data) {
86
+ await this.storage.write('data', data);
87
+ }
88
+ }
89
+
90
+ // Usage
91
+ const storage = new JsonStorage(KNOWLEDGE_DIR);
92
+ const repository = new SomeRepository(storage);
93
+ await repository.save(data);
94
+ ```
95
+
96
+ **Key Changes:**
97
+ - ✅ Use repository pattern
98
+ - ✅ Abstract storage layer
99
+ - ✅ Testable with mock storage
100
+
101
+ ---
102
+
103
+ ### Pattern 3: Mixed Business Logic + Data
104
+
105
+ #### Old Code
106
+ ```javascript
107
+ // lib/some-file.js
108
+ export class SomeManager {
109
+ constructor() {
110
+ this.dataPath = path.join(...);
111
+ }
112
+
113
+ processItem(item) {
114
+ // Business logic
115
+ if (item.count > 10) {
116
+ item.status = 'ready';
117
+ }
118
+
119
+ // Persistence
120
+ fs.writeFileSync(this.dataPath, JSON.stringify(item));
121
+ }
122
+ }
123
+ ```
124
+
125
+ #### New Code
126
+ ```javascript
127
+ // Core - Pure business logic
128
+ // src/core/some-domain/item-manager.js
129
+ export class ItemManager {
130
+ processItem(item) {
131
+ if (item.count > 10) {
132
+ item.status = 'ready';
133
+ }
134
+ return item;
135
+ }
136
+ }
137
+
138
+ // Data - Persistence
139
+ // src/data/repositories/item-repository.js
140
+ export class ItemRepository {
141
+ constructor(storage) {
142
+ this.storage = storage;
143
+ }
144
+
145
+ async save(item) {
146
+ await this.storage.write('items', item);
147
+ }
148
+ }
149
+
150
+ // Service - Orchestration
151
+ // src/services/item-service.js
152
+ export class ItemService {
153
+ constructor(itemManager, itemRepository) {
154
+ this.itemManager = itemManager;
155
+ this.itemRepository = itemRepository;
156
+ }
157
+
158
+ async processAndSave(item) {
159
+ const processed = this.itemManager.processItem(item);
160
+ await this.itemRepository.save(processed);
161
+ return processed;
162
+ }
163
+ }
164
+ ```
165
+
166
+ **Key Changes:**
167
+ - ✅ Separate business logic (Core)
168
+ - ✅ Separate persistence (Data)
169
+ - ✅ Coordinate with service (Service)
170
+
171
+ ---
172
+
173
+ ## Step-by-Step Migration
174
+
175
+ ### Step 1: Identify Layer
176
+ Ask: "What is this code's primary responsibility?"
177
+ - **Business rule?** → `src/core/`
178
+ - **Data access?** → `src/data/`
179
+ - **Orchestration?** → `src/services/`
180
+ - **UI?** → `src/presentation/`
181
+
182
+ ### Step 2: Extract Domain Models
183
+ Move pure data structures to Core:
184
+ ```javascript
185
+ // Before: mixed with other code
186
+ class Lesson { ... }
187
+
188
+ // After: src/core/learning/lesson.js
189
+ export class Lesson {
190
+ constructor(id, pattern, message) {
191
+ this.id = id;
192
+ this.pattern = pattern;
193
+ this.message = message;
194
+ }
195
+
196
+ // Business logic methods only
197
+ isValid() {
198
+ return this.pattern && this.message;
199
+ }
200
+ }
201
+ ```
202
+
203
+ ### Step 3: Extract Repositories
204
+ Move data access to Data layer:
205
+ ```javascript
206
+ // src/data/repositories/lesson-repository.js
207
+ export class LessonRepository {
208
+ constructor(storage) {
209
+ this.storage = storage;
210
+ }
211
+
212
+ async findAll() {
213
+ const data = await this.storage.read('lessons');
214
+ return data.lessons || [];
215
+ }
216
+
217
+ async save(lesson) {
218
+ const all = await this.findAll();
219
+ const updated = [...all.filter(l => l.id !== lesson.id), lesson];
220
+ await this.storage.write('lessons', { lessons: updated });
221
+ }
222
+ }
223
+ ```
224
+
225
+ ### Step 4: Create Services
226
+ Orchestrate Core + Data:
227
+ ```javascript
228
+ // src/services/lesson-service.js
229
+ export class LessonService {
230
+ constructor(lessonRepository) {
231
+ this.lessonRepository = lessonRepository;
232
+ }
233
+
234
+ async getAllLessons() {
235
+ return this.lessonRepository.findAll();
236
+ }
237
+
238
+ async addLesson(lesson) {
239
+ if (!lesson.isValid()) {
240
+ throw new Error('Invalid lesson');
241
+ }
242
+ return this.lessonRepository.save(lesson);
243
+ }
244
+ }
245
+ ```
246
+
247
+ ### Step 5: Update Imports
248
+ ```javascript
249
+ // Old
250
+ import { loadKnowledge } from './recall.js';
251
+
252
+ // New
253
+ import { LessonRepository } from './src/data/repositories/lesson-repository.js';
254
+ import { JsonStorage } from './src/data/storage/json-storage.js';
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Common Pitfalls
260
+
261
+ ### ❌ Pitfall 1: Core depends on Data
262
+ ```javascript
263
+ // WRONG - Core importing from Data
264
+ // src/core/learning/lesson-manager.js
265
+ import { LessonRepository } from '../../data/repositories/lesson-repository.js';
266
+ ```
267
+
268
+ **Fix:** Use dependency injection
269
+ ```javascript
270
+ // CORRECT
271
+ export class LessonManager {
272
+ constructor(lessonRepository) {
273
+ this.lessonRepository = lessonRepository; // Injected!
274
+ }
275
+ }
276
+ ```
277
+
278
+ ### ❌ Pitfall 2: Sync when should be Async
279
+ ```javascript
280
+ // WRONG - Repository should be async
281
+ findAll() {
282
+ return JSON.parse(fs.readFileSync(...));
283
+ }
284
+ ```
285
+
286
+ **Fix:** Make async
287
+ ```javascript
288
+ // CORRECT
289
+ async findAll() {
290
+ const content = await this.storage.read('lessons');
291
+ return content.lessons;
292
+ }
293
+ ```
294
+
295
+ ### ❌ Pitfall 3: God Class
296
+ ```javascript
297
+ // WRONG - One class does everything
298
+ export class LessonManager {
299
+ validate(lesson) { ... } // Validation
300
+ transform(lesson) { ... } // Business logic
301
+ save(lesson) { ... } // Persistence
302
+ display(lesson) { ... } // Presentation
303
+ }
304
+ ```
305
+
306
+ **Fix:** Split responsibilities
307
+ ```javascript
308
+ // CORRECT
309
+ class LessonValidator { // Core - Validation
310
+ validate(lesson) { ... }
311
+ }
312
+
313
+ class LessonTransformer { // Core - Business logic
314
+ transform(lesson) { ... }
315
+ }
316
+
317
+ class LessonRepository { // Data - Persistence
318
+ save(lesson) { ... }
319
+ }
320
+
321
+ class LessonView { // Presentation - UI
322
+ display(lesson) { ... }
323
+ }
324
+ ```
325
+
326
+ ---
327
+
328
+ ## Testing After Migration
329
+
330
+ ### Before
331
+ ```javascript
332
+ // Hard to test - filesystem access
333
+ function saveLesson(lesson) {
334
+ fs.writeFileSync('/path/to/lessons.json', ...);
335
+ }
336
+
337
+ // Test requires actual filesystem
338
+ test('saves lesson', () => {
339
+ saveLesson(mockLesson);
340
+ const saved = fs.readFileSync('/path/to/lessons.json');
341
+ // ...
342
+ });
343
+ ```
344
+
345
+ ### After
346
+ ```javascript
347
+ // Easy to test - dependency injection
348
+ class LessonRepository {
349
+ constructor(storage) {
350
+ this.storage = storage;
351
+ }
352
+
353
+ async save(lesson) {
354
+ await this.storage.write('lessons', lesson);
355
+ }
356
+ }
357
+
358
+ // Test with mock storage
359
+ test('saves lesson', async () => {
360
+ const mockStorage = {
361
+ write: jest.fn()
362
+ };
363
+
364
+ const repository = new LessonRepository(mockStorage);
365
+ await repository.save(mockLesson);
366
+
367
+ expect(mockStorage.write).toHaveBeenCalledWith('lessons', mockLesson);
368
+ });
369
+ ```
370
+
371
+ ---
372
+
373
+ ## Gradual Migration Strategy
374
+
375
+ ### Week 1-2: New Features Only
376
+ - All new code uses new architecture
377
+ - Existing code unchanged
378
+
379
+ ### Week 3-4: Extract One Module
380
+ - Pick smallest module (e.g., Evolution)
381
+ - Extract to new architecture
382
+ - Add backward compatibility layer
383
+ - Test thoroughly
384
+
385
+ ### Week 5-6: Extract Next Module
386
+ - Apply lessons learned
387
+ - Repeat pattern
388
+
389
+ ### Week 7+: Continue Until Complete
390
+ - One module at a time
391
+ - Always maintain backward compatibility
392
+ - Test after each extraction
393
+
394
+ ---
395
+
396
+ ## Checklist
397
+
398
+ Before marking migration complete:
399
+
400
+ - [ ] Business logic moved to `src/core/`
401
+ - [ ] Data access moved to `src/data/repositories/`
402
+ - [ ] Storage abstracted to `src/data/storage/`
403
+ - [ ] Services created in `src/services/`
404
+ - [ ] All classes use dependency injection
405
+ - [ ] All file I/O is async
406
+ - [ ] Unit tests added
407
+ - [ ] Integration tests added
408
+ - [ ] Backward compatibility layer exists (if needed)
409
+ - [ ] Documentation updated
410
+
411
+ ---
412
+
413
+ ## Need Help?
414
+
415
+ See examples in:
416
+ - `src/core/evolution/` - Complete example
417
+ - `src/data/repositories/signal-repository.js` - Repository pattern
418
+ - `src/data/storage/json-storage.js` - Storage adapter