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,387 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Skill Injector - Auto-generate SKILL.md from lessons learned
4
+ *
5
+ * Part of FAANG-Grade Auto-Learn System Phase 5
6
+ *
7
+ * Features:
8
+ * - Analyze lessons by category
9
+ * - Generate SKILL.md files from patterns
10
+ * - Create auto-generated skills folder
11
+ * - Link skills to lessons
12
+ *
13
+ * Usage:
14
+ * node skill_injector.js --analyze
15
+ * node skill_injector.js --generate
16
+ * node skill_injector.js --list
17
+ */
18
+
19
+ import fs from 'fs';
20
+ import path from 'path';
21
+ import { fileURLToPath } from 'url';
22
+
23
+ const __filename = fileURLToPath(import.meta.url);
24
+ const __dirname = path.dirname(__filename);
25
+
26
+ // Colors
27
+ const c = {
28
+ reset: '\x1b[0m',
29
+ red: '\x1b[31m',
30
+ green: '\x1b[32m',
31
+ yellow: '\x1b[33m',
32
+ blue: '\x1b[34m',
33
+ cyan: '\x1b[36m',
34
+ gray: '\x1b[90m',
35
+ bold: '\x1b[1m'
36
+ };
37
+
38
+ // Paths
39
+ function findProjectRoot() {
40
+ let current = process.cwd();
41
+ while (current !== path.dirname(current)) {
42
+ if (fs.existsSync(path.join(current, '.agent'))) {
43
+ return current;
44
+ }
45
+ current = path.dirname(current);
46
+ }
47
+ return process.cwd();
48
+ }
49
+
50
+ const projectRoot = findProjectRoot();
51
+ const knowledgePath = path.join(projectRoot, '.agent', 'knowledge');
52
+ const skillsPath = path.join(projectRoot, '.agent', 'skills');
53
+ const autoSkillsPath = path.join(skillsPath, 'auto-generated');
54
+
55
+ // Category mappings for skill generation
56
+ const CATEGORY_CONFIG = {
57
+ 'SAFE': { name: 'safety-rules', description: 'Auto-learned safety rules' },
58
+ 'CODE': { name: 'code-patterns', description: 'Auto-learned code patterns' },
59
+ 'FLOW': { name: 'workflow-rules', description: 'Auto-learned workflow rules' },
60
+ 'INT': { name: 'integration-rules', description: 'Auto-learned integration rules' },
61
+ 'PERF': { name: 'performance-rules', description: 'Auto-learned performance rules' },
62
+ 'TEST': { name: 'testing-rules', description: 'Auto-learned testing rules' },
63
+ 'LEARN': { name: 'general-lessons', description: 'General lessons learned' }
64
+ };
65
+
66
+ // Load JSON file
67
+ function loadJson(filename) {
68
+ const filePath = path.join(knowledgePath, filename);
69
+ try {
70
+ if (fs.existsSync(filePath)) {
71
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
72
+ }
73
+ } catch { }
74
+ return null;
75
+ }
76
+
77
+ // Ensure directories exist
78
+ function ensureDirectories() {
79
+ if (!fs.existsSync(autoSkillsPath)) {
80
+ fs.mkdirSync(autoSkillsPath, { recursive: true });
81
+ }
82
+ }
83
+
84
+ // ==================== ANALYSIS ====================
85
+
86
+ /**
87
+ * Analyze lessons and group by category
88
+ */
89
+ function analyzeLessons() {
90
+ const lessons = loadJson('lessons-learned.json');
91
+ if (!lessons?.lessons?.length) {
92
+ return { categories: {}, total: 0 };
93
+ }
94
+
95
+ const categories = {};
96
+
97
+ for (const lesson of lessons.lessons) {
98
+ // Extract category from ID (e.g., SAFE-001 -> SAFE)
99
+ const category = lesson.id?.split('-')[0] || 'LEARN';
100
+
101
+ if (!categories[category]) {
102
+ categories[category] = [];
103
+ }
104
+ categories[category].push(lesson);
105
+ }
106
+
107
+ return { categories, total: lessons.lessons.length };
108
+ }
109
+
110
+ /**
111
+ * Check which categories have enough lessons for skill generation
112
+ */
113
+ function getSkillCandidates() {
114
+ const { categories } = analyzeLessons();
115
+ const candidates = [];
116
+
117
+ for (const [category, lessons] of Object.entries(categories)) {
118
+ // Need at least 3 lessons to generate a skill
119
+ if (lessons.length >= 3) {
120
+ candidates.push({
121
+ category,
122
+ count: lessons.length,
123
+ config: CATEGORY_CONFIG[category] || {
124
+ name: `${category.toLowerCase()}-rules`,
125
+ description: `Auto-learned ${category.toLowerCase()} rules`
126
+ }
127
+ });
128
+ }
129
+ }
130
+
131
+ return candidates;
132
+ }
133
+
134
+ // ==================== SKILL GENERATION ====================
135
+
136
+ /**
137
+ * Generate SKILL.md content from lessons
138
+ */
139
+ function generateSkillContent(category, lessons, config) {
140
+ const now = new Date().toISOString();
141
+
142
+ let content = `---
143
+ name: ${config.name}
144
+ description: >-
145
+ ${config.description}. Auto-generated from ${lessons.length} lessons learned.
146
+ This skill was automatically created by skill_injector.js.
147
+ metadata:
148
+ category: "auto-generated"
149
+ version: "1.0.0"
150
+ autoGenerated: true
151
+ generatedAt: "${now}"
152
+ lessonCount: ${lessons.length}
153
+ triggers: "auto-learned patterns from ${category} category"
154
+ ---
155
+
156
+ # ${config.name}
157
+
158
+ > **Auto-Generated Skill** - Created from lessons learned in category: ${category}
159
+
160
+ ---
161
+
162
+ ## Rules
163
+
164
+ `;
165
+
166
+ // Add each lesson as a rule
167
+ for (const lesson of lessons) {
168
+ const severity = lesson.severity || 'MEDIUM';
169
+ const severityIcon = {
170
+ 'CRITICAL': '🔴',
171
+ 'HIGH': '🟠',
172
+ 'MEDIUM': '🟡',
173
+ 'LOW': '🟢'
174
+ }[severity] || '⚪';
175
+
176
+ content += `### ${lesson.id}: ${lesson.pattern || 'Unnamed Pattern'}
177
+
178
+ ${severityIcon} **Severity:** ${severity}
179
+
180
+ ${lesson.message || 'No message provided.'}
181
+
182
+ `;
183
+ if (lesson.example_fix) {
184
+ content += `**Example Fix:**
185
+ \`\`\`
186
+ ${lesson.example_fix}
187
+ \`\`\`
188
+
189
+ `;
190
+ }
191
+ }
192
+
193
+ // Add metadata section
194
+ content += `---
195
+
196
+ ## Metadata
197
+
198
+ | Property | Value |
199
+ |----------|-------|
200
+ | Total Rules | ${lessons.length} |
201
+ | Generated At | ${now.split('T')[0]} |
202
+ | Category | ${category} |
203
+ | Source | lessons-learned.json |
204
+
205
+ ---
206
+
207
+ ## When to Apply
208
+
209
+ This skill is automatically invoked when patterns matching the following are detected:
210
+
211
+ `;
212
+
213
+ for (const lesson of lessons.slice(0, 5)) {
214
+ content += `- ${lesson.pattern || lesson.id}\n`;
215
+ }
216
+
217
+ if (lessons.length > 5) {
218
+ content += `- ... and ${lessons.length - 5} more patterns\n`;
219
+ }
220
+
221
+ return content;
222
+ }
223
+
224
+ /**
225
+ * Generate skills for all eligible categories
226
+ */
227
+ function generateSkills(dryRun = false) {
228
+ ensureDirectories();
229
+
230
+ const candidates = getSkillCandidates();
231
+ const { categories } = analyzeLessons();
232
+ const generated = [];
233
+
234
+ for (const candidate of candidates) {
235
+ const lessons = categories[candidate.category];
236
+ const content = generateSkillContent(
237
+ candidate.category,
238
+ lessons,
239
+ candidate.config
240
+ );
241
+
242
+ const skillDir = path.join(autoSkillsPath, candidate.config.name);
243
+ const skillFile = path.join(skillDir, 'SKILL.md');
244
+
245
+ if (!dryRun) {
246
+ if (!fs.existsSync(skillDir)) {
247
+ fs.mkdirSync(skillDir, { recursive: true });
248
+ }
249
+ fs.writeFileSync(skillFile, content);
250
+ }
251
+
252
+ generated.push({
253
+ category: candidate.category,
254
+ name: candidate.config.name,
255
+ path: skillFile,
256
+ lessonCount: lessons.length
257
+ });
258
+ }
259
+
260
+ return generated;
261
+ }
262
+
263
+ // ==================== LIST ====================
264
+
265
+ /**
266
+ * List auto-generated skills
267
+ */
268
+ function listAutoSkills() {
269
+ if (!fs.existsSync(autoSkillsPath)) {
270
+ console.log(`${c.gray}No auto-generated skills yet.${c.reset}`);
271
+ return [];
272
+ }
273
+
274
+ const skills = [];
275
+ const entries = fs.readdirSync(autoSkillsPath, { withFileTypes: true });
276
+
277
+ for (const entry of entries) {
278
+ if (entry.isDirectory()) {
279
+ const skillFile = path.join(autoSkillsPath, entry.name, 'SKILL.md');
280
+ if (fs.existsSync(skillFile)) {
281
+ skills.push({
282
+ name: entry.name,
283
+ path: skillFile
284
+ });
285
+ }
286
+ }
287
+ }
288
+
289
+ return skills;
290
+ }
291
+
292
+ // ==================== MAIN ====================
293
+
294
+ const args = process.argv.slice(2);
295
+
296
+ if (args.includes('--analyze') || args.includes('-a')) {
297
+ console.log(`${c.cyan}╔════════════════════════════════════════╗${c.reset}`);
298
+ console.log(`${c.cyan}║${c.reset} 🧠 Skill Injector Analysis ${c.cyan}║${c.reset}`);
299
+ console.log(`${c.cyan}╚════════════════════════════════════════╝${c.reset}\n`);
300
+
301
+ const { categories, total } = analyzeLessons();
302
+
303
+ console.log(`${c.bold}Lessons by Category:${c.reset}`);
304
+ for (const [cat, lessons] of Object.entries(categories)) {
305
+ const config = CATEGORY_CONFIG[cat];
306
+ const skillName = config?.name || `${cat.toLowerCase()}-rules`;
307
+ const canGenerate = lessons.length >= 3;
308
+ const status = canGenerate ? `${c.green}✓ Can generate${c.reset}` : `${c.gray}(need 3+)${c.reset}`;
309
+ console.log(` ${c.blue}${cat}${c.reset}: ${lessons.length} lessons → ${skillName} ${status}`);
310
+ }
311
+
312
+ console.log(`\n${c.gray}Total lessons: ${total}${c.reset}`);
313
+
314
+ const candidates = getSkillCandidates();
315
+ if (candidates.length > 0) {
316
+ console.log(`${c.green}${c.bold}Ready to generate ${candidates.length} skills${c.reset}`);
317
+ console.log(`${c.gray}Run: node skill_injector.js --generate${c.reset}`);
318
+ }
319
+
320
+ } else if (args.includes('--generate') || args.includes('-g')) {
321
+ console.log(`${c.cyan}🔧 Generating skills from lessons...${c.reset}\n`);
322
+
323
+ const generated = generateSkills();
324
+
325
+ if (generated.length === 0) {
326
+ console.log(`${c.yellow}No skill candidates (need 3+ lessons per category)${c.reset}`);
327
+ } else {
328
+ console.log(`${c.green}${c.bold}Generated ${generated.length} skills:${c.reset}`);
329
+ for (const skill of generated) {
330
+ console.log(` ${c.green}✓${c.reset} ${skill.name} (${skill.lessonCount} rules)`);
331
+ console.log(` ${c.gray}${skill.path}${c.reset}`);
332
+ }
333
+ }
334
+
335
+ } else if (args.includes('--dry-run')) {
336
+ console.log(`${c.cyan}🔍 Dry run - what would be generated:${c.reset}\n`);
337
+
338
+ const generated = generateSkills(true);
339
+
340
+ for (const skill of generated) {
341
+ console.log(` ${c.blue}→${c.reset} ${skill.name} (${skill.lessonCount} rules)`);
342
+ }
343
+
344
+ } else if (args.includes('--list') || args.includes('-l')) {
345
+ console.log(`${c.cyan}📂 Auto-Generated Skills:${c.reset}\n`);
346
+
347
+ const skills = listAutoSkills();
348
+
349
+ if (skills.length === 0) {
350
+ console.log(`${c.gray}No auto-generated skills yet.${c.reset}`);
351
+ console.log(`${c.gray}Run: node skill_injector.js --generate${c.reset}`);
352
+ } else {
353
+ for (const skill of skills) {
354
+ console.log(` ${c.green}●${c.reset} ${skill.name}`);
355
+ console.log(` ${c.gray}${skill.path}${c.reset}`);
356
+ }
357
+ }
358
+
359
+ } else {
360
+ console.log(`${c.cyan}skill_injector - Auto-generate SKILL.md from lessons${c.reset}
361
+
362
+ ${c.bold}Usage:${c.reset}
363
+ node skill_injector.js --analyze Analyze lessons and show candidates
364
+ node skill_injector.js --generate Generate skills from lessons
365
+ node skill_injector.js --dry-run Preview without creating files
366
+ node skill_injector.js --list List auto-generated skills
367
+
368
+ ${c.bold}Requirements:${c.reset}
369
+ - At least 3 lessons in a category to generate a skill
370
+ - Skills are created in: .agent/skills/auto-generated/
371
+
372
+ ${c.bold}Category Mappings:${c.reset}
373
+ SAFE → safety-rules
374
+ CODE → code-patterns
375
+ FLOW → workflow-rules
376
+ INT → integration-rules
377
+ PERF → performance-rules
378
+ TEST → testing-rules
379
+ LEARN → general-lessons
380
+
381
+ ${c.bold}Examples:${c.reset}
382
+ node skill_injector.js --analyze See what can be generated
383
+ node skill_injector.js --generate Create skill files
384
+ `);
385
+ }
386
+
387
+ export { analyzeLessons, getSkillCandidates, generateSkills, listAutoSkills };