add-skill-kit 3.2.4 → 3.2.6
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.
- package/README.md +179 -119
- package/bin/lib/commands/help.js +0 -4
- package/bin/lib/commands/install.js +129 -9
- package/bin/lib/ui.js +1 -1
- package/lib/agent-cli/__tests__/adaptive_engine.test.js +190 -0
- package/lib/agent-cli/__tests__/integration/cross_script.test.js +222 -0
- package/lib/agent-cli/__tests__/integration/full_cycle.test.js +230 -0
- package/lib/agent-cli/__tests__/pattern_analyzer.test.js +173 -0
- package/lib/agent-cli/__tests__/pre_execution_check.test.js +167 -0
- package/lib/agent-cli/__tests__/skill_injector.test.js +191 -0
- package/lib/agent-cli/bin/{ag-smart.js → agent.js} +48 -15
- package/lib/agent-cli/dashboard/dashboard_server.js +340 -0
- package/lib/agent-cli/dashboard/index.html +538 -0
- package/lib/agent-cli/lib/audit.js +2 -2
- package/lib/agent-cli/lib/auto-learn.js +8 -8
- package/lib/agent-cli/lib/eslint-fix.js +1 -1
- package/lib/agent-cli/lib/fix.js +5 -5
- package/lib/agent-cli/lib/hooks/install-hooks.js +4 -4
- package/lib/agent-cli/lib/hooks/lint-learn.js +4 -4
- package/lib/agent-cli/lib/learn.js +10 -10
- package/lib/agent-cli/lib/recall.js +1 -1
- package/lib/agent-cli/lib/settings.js +24 -0
- package/lib/agent-cli/lib/skill-learn.js +2 -2
- package/lib/agent-cli/lib/stats.js +3 -3
- package/lib/agent-cli/lib/ui/dashboard-ui.js +103 -4
- package/lib/agent-cli/lib/ui/index.js +36 -6
- package/lib/agent-cli/lib/watcher.js +2 -2
- package/lib/agent-cli/package.json +4 -4
- package/lib/agent-cli/scripts/adaptive_engine.js +381 -0
- package/lib/agent-cli/scripts/dashboard_server.js +224 -0
- package/lib/agent-cli/scripts/error_sensor.js +565 -0
- package/lib/agent-cli/scripts/learn_from_failure.js +225 -0
- package/lib/agent-cli/scripts/pattern_analyzer.js +781 -0
- package/lib/agent-cli/scripts/pre_execution_check.js +623 -0
- package/lib/agent-cli/scripts/rule_sharing.js +374 -0
- package/lib/agent-cli/scripts/skill_injector.js +387 -0
- package/lib/agent-cli/scripts/success_sensor.js +500 -0
- package/lib/agent-cli/scripts/user_correction_sensor.js +426 -0
- package/lib/agent-cli/services/auto-learn-service.js +247 -0
- package/lib/agent-cli/src/MIGRATION.md +418 -0
- package/lib/agent-cli/src/README.md +367 -0
- package/lib/agent-cli/src/core/evolution/evolution-signal.js +42 -0
- package/lib/agent-cli/src/core/evolution/index.js +17 -0
- package/lib/agent-cli/src/core/evolution/review-gate.js +40 -0
- package/lib/agent-cli/src/core/evolution/signal-detector.js +137 -0
- package/lib/agent-cli/src/core/evolution/signal-queue.js +79 -0
- package/lib/agent-cli/src/core/evolution/threshold-checker.js +79 -0
- package/lib/agent-cli/src/core/index.js +15 -0
- package/lib/agent-cli/src/core/learning/cognitive-enhancer.js +282 -0
- package/lib/agent-cli/src/core/learning/index.js +12 -0
- package/lib/agent-cli/src/core/learning/lesson-synthesizer.js +83 -0
- package/lib/agent-cli/src/core/scanning/index.js +14 -0
- package/lib/agent-cli/src/data/index.js +13 -0
- package/lib/agent-cli/src/data/repositories/index.js +8 -0
- package/lib/agent-cli/src/data/repositories/lesson-repository.js +130 -0
- package/lib/agent-cli/src/data/repositories/signal-repository.js +119 -0
- package/lib/agent-cli/src/data/storage/index.js +8 -0
- package/lib/agent-cli/src/data/storage/json-storage.js +64 -0
- package/lib/agent-cli/src/data/storage/yaml-storage.js +66 -0
- package/lib/agent-cli/src/infrastructure/index.js +13 -0
- package/lib/agent-cli/src/presentation/formatters/skill-formatter.js +232 -0
- package/lib/agent-cli/src/services/export-service.js +162 -0
- package/lib/agent-cli/src/services/index.js +13 -0
- package/lib/agent-cli/src/services/learning-service.js +99 -0
- package/lib/agent-cli/types/index.d.ts +343 -0
- package/lib/agent-cli/utils/benchmark.js +269 -0
- package/lib/agent-cli/utils/logger.js +303 -0
- package/lib/agent-cli/utils/ml_patterns.js +300 -0
- package/lib/agent-cli/utils/recovery.js +312 -0
- package/lib/agent-cli/utils/telemetry.js +290 -0
- package/lib/agentskillskit-cli/ag-smart.js +15 -15
- package/lib/agentskillskit-cli/package.json +3 -3
- package/package.json +12 -6
- package/lib/agent-cli/lib/auto_preview.py +0 -148
- package/lib/agent-cli/lib/checklist.py +0 -222
- package/lib/agent-cli/lib/session_manager.py +0 -120
- package/lib/agent-cli/lib/verify_all.py +0 -327
- /package/bin/{cli.js → kit.js} +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
|