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.
Files changed (78) hide show
  1. package/README.md +179 -119
  2. package/bin/lib/commands/help.js +0 -4
  3. package/bin/lib/commands/install.js +129 -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/{ag-smart.js → agent.js} +48 -15
  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 +2 -2
  15. package/lib/agent-cli/lib/auto-learn.js +8 -8
  16. package/lib/agent-cli/lib/eslint-fix.js +1 -1
  17. package/lib/agent-cli/lib/fix.js +5 -5
  18. package/lib/agent-cli/lib/hooks/install-hooks.js +4 -4
  19. package/lib/agent-cli/lib/hooks/lint-learn.js +4 -4
  20. package/lib/agent-cli/lib/learn.js +10 -10
  21. package/lib/agent-cli/lib/recall.js +1 -1
  22. package/lib/agent-cli/lib/settings.js +24 -0
  23. package/lib/agent-cli/lib/skill-learn.js +2 -2
  24. package/lib/agent-cli/lib/stats.js +3 -3
  25. package/lib/agent-cli/lib/ui/dashboard-ui.js +103 -4
  26. package/lib/agent-cli/lib/ui/index.js +36 -6
  27. package/lib/agent-cli/lib/watcher.js +2 -2
  28. package/lib/agent-cli/package.json +4 -4
  29. package/lib/agent-cli/scripts/adaptive_engine.js +381 -0
  30. package/lib/agent-cli/scripts/dashboard_server.js +224 -0
  31. package/lib/agent-cli/scripts/error_sensor.js +565 -0
  32. package/lib/agent-cli/scripts/learn_from_failure.js +225 -0
  33. package/lib/agent-cli/scripts/pattern_analyzer.js +781 -0
  34. package/lib/agent-cli/scripts/pre_execution_check.js +623 -0
  35. package/lib/agent-cli/scripts/rule_sharing.js +374 -0
  36. package/lib/agent-cli/scripts/skill_injector.js +387 -0
  37. package/lib/agent-cli/scripts/success_sensor.js +500 -0
  38. package/lib/agent-cli/scripts/user_correction_sensor.js +426 -0
  39. package/lib/agent-cli/services/auto-learn-service.js +247 -0
  40. package/lib/agent-cli/src/MIGRATION.md +418 -0
  41. package/lib/agent-cli/src/README.md +367 -0
  42. package/lib/agent-cli/src/core/evolution/evolution-signal.js +42 -0
  43. package/lib/agent-cli/src/core/evolution/index.js +17 -0
  44. package/lib/agent-cli/src/core/evolution/review-gate.js +40 -0
  45. package/lib/agent-cli/src/core/evolution/signal-detector.js +137 -0
  46. package/lib/agent-cli/src/core/evolution/signal-queue.js +79 -0
  47. package/lib/agent-cli/src/core/evolution/threshold-checker.js +79 -0
  48. package/lib/agent-cli/src/core/index.js +15 -0
  49. package/lib/agent-cli/src/core/learning/cognitive-enhancer.js +282 -0
  50. package/lib/agent-cli/src/core/learning/index.js +12 -0
  51. package/lib/agent-cli/src/core/learning/lesson-synthesizer.js +83 -0
  52. package/lib/agent-cli/src/core/scanning/index.js +14 -0
  53. package/lib/agent-cli/src/data/index.js +13 -0
  54. package/lib/agent-cli/src/data/repositories/index.js +8 -0
  55. package/lib/agent-cli/src/data/repositories/lesson-repository.js +130 -0
  56. package/lib/agent-cli/src/data/repositories/signal-repository.js +119 -0
  57. package/lib/agent-cli/src/data/storage/index.js +8 -0
  58. package/lib/agent-cli/src/data/storage/json-storage.js +64 -0
  59. package/lib/agent-cli/src/data/storage/yaml-storage.js +66 -0
  60. package/lib/agent-cli/src/infrastructure/index.js +13 -0
  61. package/lib/agent-cli/src/presentation/formatters/skill-formatter.js +232 -0
  62. package/lib/agent-cli/src/services/export-service.js +162 -0
  63. package/lib/agent-cli/src/services/index.js +13 -0
  64. package/lib/agent-cli/src/services/learning-service.js +99 -0
  65. package/lib/agent-cli/types/index.d.ts +343 -0
  66. package/lib/agent-cli/utils/benchmark.js +269 -0
  67. package/lib/agent-cli/utils/logger.js +303 -0
  68. package/lib/agent-cli/utils/ml_patterns.js +300 -0
  69. package/lib/agent-cli/utils/recovery.js +312 -0
  70. package/lib/agent-cli/utils/telemetry.js +290 -0
  71. package/lib/agentskillskit-cli/ag-smart.js +15 -15
  72. package/lib/agentskillskit-cli/package.json +3 -3
  73. package/package.json +12 -6
  74. package/lib/agent-cli/lib/auto_preview.py +0 -148
  75. package/lib/agent-cli/lib/checklist.py +0 -222
  76. package/lib/agent-cli/lib/session_manager.py +0 -120
  77. package/lib/agent-cli/lib/verify_all.py +0 -327
  78. /package/bin/{cli.js → kit.js} +0 -0
@@ -10,9 +10,9 @@
10
10
  * - Source tracking (manual, eslint, test-failure)
11
11
  *
12
12
  * Usage:
13
- * ag-smart learn --add --pattern "regex" --message "why bad"
14
- * ag-smart learn --list
15
- * ag-smart learn --remove <id>
13
+ * agent learn --add --pattern "regex" --message "why bad"
14
+ * agent learn --list
15
+ * agent learn --remove <id>
16
16
  */
17
17
 
18
18
  import fs from "fs";
@@ -147,7 +147,7 @@ function listLessons(category = null) {
147
147
 
148
148
  if (!db.lessons || db.lessons.length === 0) {
149
149
  console.log("\nℹ️ No lessons learned yet.");
150
- console.log(" Use: ag-smart learn --add --pattern \"pat\" --message \"msg\"\n");
150
+ console.log(" Use: agent learn --add --pattern \"pat\" --message \"msg\"\n");
151
151
  return;
152
152
  }
153
153
 
@@ -180,9 +180,9 @@ function printHelp() {
180
180
  🎓 Smart Learning Tool v${VERSION}
181
181
 
182
182
  USAGE:
183
- ag-smart learn --add --pattern "..." --message "..."
184
- ag-smart learn --list [--category <cat>]
185
- ag-smart learn --remove <ID>
183
+ agent learn --add --pattern "..." --message "..."
184
+ agent learn --list [--category <cat>]
185
+ agent learn --remove <ID>
186
186
 
187
187
  OPTIONS:
188
188
  --add Add a new lesson
@@ -195,9 +195,9 @@ OPTIONS:
195
195
  --help Show this help
196
196
 
197
197
  EXAMPLES:
198
- ag-smart learn --add --pattern "console\\.log" --message "No console.log in production" --severity ERROR
199
- ag-smart learn --list
200
- ag-smart learn --remove LEARN-001
198
+ agent learn --add --pattern "console\\.log" --message "No console.log in production" --severity ERROR
199
+ agent learn --list
200
+ agent learn --remove LEARN-001
201
201
  `);
202
202
  }
203
203
 
@@ -465,7 +465,7 @@ Options:
465
465
  const db = loadKnowledge();
466
466
 
467
467
  if (!db.lessons || db.lessons.length === 0) {
468
- console.log("ℹ️ No lessons learned yet. Use 'ag-smart learn' to add patterns.");
468
+ console.log("ℹ️ No lessons learned yet. Use 'agent learn' to add patterns.");
469
469
  process.exit(0);
470
470
  }
471
471
 
@@ -57,12 +57,26 @@ export function saveSettings(settings) {
57
57
 
58
58
  /**
59
59
  * Toggle Auto-Learning setting
60
+ * When enabled, runs a quick scan automatically
60
61
  * @returns {boolean} New value
61
62
  */
62
63
  export function toggleAutoLearning() {
63
64
  const settings = loadSettings();
64
65
  settings.autoLearning = !settings.autoLearning;
65
66
  saveSettings(settings);
67
+
68
+ // When turning ON, run quick scan (async, non-blocking)
69
+ if (settings.autoLearning) {
70
+ import('../services/auto-learn-service.js')
71
+ .then(({ quickScan }) => {
72
+ console.log('\n🧠 Auto-Learning enabled! Running quick scan...\n');
73
+ quickScan().catch(() => { });
74
+ })
75
+ .catch(() => {
76
+ // Silent fail if service not available
77
+ });
78
+ }
79
+
66
80
  return settings.autoLearning;
67
81
  }
68
82
 
@@ -186,6 +200,15 @@ export function removeApiKey(provider) {
186
200
  }
187
201
  }
188
202
 
203
+ /**
204
+ * Run full Auto-Learn cycle manually
205
+ * @returns {Promise<object>} Results from all scripts
206
+ */
207
+ export async function runAutoLearnCycle() {
208
+ const { runFullCycle } = await import('../services/auto-learn-service.js');
209
+ return runFullCycle();
210
+ }
211
+
189
212
  export default {
190
213
  loadSettings,
191
214
  saveSettings,
@@ -198,6 +221,7 @@ export default {
198
221
  setApiKey,
199
222
  getApiKey,
200
223
  removeApiKey,
224
+ runAutoLearnCycle,
201
225
  SETTINGS_PATH
202
226
  };
203
227
 
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * This makes the Self-Learning Engine truly "self-learning"!
9
9
  *
10
- * Usage: ag-smart sync-skills
10
+ * Usage: agent sync-skills
11
11
  */
12
12
 
13
13
  import fs from "fs";
@@ -280,7 +280,7 @@ if (args.includes("--help")) {
280
280
  🔄 Skill Sync - Auto-update SKILL.md
281
281
 
282
282
  Usage:
283
- ag-smart sync-skills
283
+ agent sync-skills
284
284
 
285
285
  When patterns reach ${SYNC_THRESHOLD}+ violations, they are automatically
286
286
  added to the relevant SKILL.md file as learned rules.
@@ -7,7 +7,7 @@
7
7
  * - Most triggered patterns
8
8
  * - Violation trends
9
9
  *
10
- * Usage: ag-smart stats
10
+ * Usage: agent stats
11
11
  */
12
12
 
13
13
  import { loadKnowledge } from "./recall.js";
@@ -25,7 +25,7 @@ function displayStats() {
25
25
  p.intro(pc.cyan(`📊 Smart Agent Knowledge Base v${VERSION}`));
26
26
 
27
27
  if (!db.lessons || db.lessons.length === 0) {
28
- p.note("No lessons learned yet.\nUse 'ag-smart learn' to add patterns.", pc.dim("Empty"));
28
+ p.note("No lessons learned yet.\nUse 'agent learn' to add patterns.", pc.dim("Empty"));
29
29
  return;
30
30
  }
31
31
 
@@ -118,7 +118,7 @@ if (args.includes("--help")) {
118
118
  📊 Smart Stats - Knowledge Base Statistics
119
119
 
120
120
  Usage:
121
- ag-smart stats
121
+ agent stats
122
122
 
123
123
  Shows:
124
124
  - Total lessons and violations
@@ -7,6 +7,51 @@ import path from "path";
7
7
  import fs from "fs";
8
8
  import http from "http";
9
9
 
10
+ // Track running server globally
11
+ let runningServer = null;
12
+ let runningPort = null;
13
+
14
+ /**
15
+ * Check if a port is already in use by our dashboard
16
+ * Uses /api/summary to verify it's actually our dashboard server
17
+ */
18
+ async function checkPortInUse(port) {
19
+ return new Promise((resolve) => {
20
+ const req = http.get(`http://localhost:${port}/api/summary`, (res) => {
21
+ // If we get 200 response from /api/summary, it's our dashboard
22
+ if (res.statusCode === 200) {
23
+ resolve(true);
24
+ } else {
25
+ resolve(false);
26
+ }
27
+ req.destroy();
28
+ });
29
+ req.on('error', () => {
30
+ resolve(false);
31
+ });
32
+ // Faster timeout - 500ms is enough for localhost
33
+ req.setTimeout(500, () => {
34
+ req.destroy();
35
+ resolve(false);
36
+ });
37
+ });
38
+ }
39
+
40
+ /**
41
+ * Find existing dashboard server on ports 3030-3040
42
+ */
43
+ async function findExistingServer() {
44
+ // Check ports in parallel for faster detection
45
+ const portChecks = [];
46
+ for (let port = 3030; port <= 3040; port++) {
47
+ portChecks.push(checkPortInUse(port).then(inUse => inUse ? port : null));
48
+ }
49
+
50
+ const results = await Promise.all(portChecks);
51
+ const existingPort = results.find(port => port !== null);
52
+ return existingPort || null;
53
+ }
54
+
10
55
  /**
11
56
  * Find an available port
12
57
  */
@@ -26,14 +71,26 @@ async function findAvailablePort(startPort = 3030) {
26
71
  * Find dashboard server script
27
72
  */
28
73
  function findDashboardScript() {
74
+ // Get the directory where this module is located
75
+ const moduleDir = path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/i, '$1'));
76
+ const cliRoot = path.resolve(moduleDir, '..', '..');
77
+
78
+ // User home directory
79
+ const homeDir = process.env.USERPROFILE || process.env.HOME || '';
80
+
29
81
  const possiblePaths = [
82
+ // PRIORITY 1: Bundled with CLI package (always available)
83
+ path.join(cliRoot, "dashboard", "dashboard_server.js"),
84
+ // PRIORITY 2: Current project paths
30
85
  path.join(process.cwd(), ".agent", "skills", "auto-learner", "scripts", "dashboard_server.js"),
31
- path.join(process.cwd(), ".agent", "agentskillskit", ".agent", "skills", "auto-learner", "scripts", "dashboard_server.js")
86
+ path.join(process.cwd(), ".agent", "agentskillskit", ".agent", "skills", "auto-learner", "scripts", "dashboard_server.js"),
87
+ // PRIORITY 3: Fallback user paths (Windows Desktop)
88
+ path.join(homeDir, "Desktop", "agent-skill-kit", ".agent", "skills", "auto-learner", "scripts", "dashboard_server.js"),
32
89
  ];
33
90
 
34
- for (const p of possiblePaths) {
35
- if (fs.existsSync(p)) {
36
- return p;
91
+ for (const searchPath of possiblePaths) {
92
+ if (fs.existsSync(searchPath)) {
93
+ return searchPath;
37
94
  }
38
95
  }
39
96
  return null;
@@ -67,6 +124,43 @@ function openBrowser(url) {
67
124
  export async function runDashboardUI() {
68
125
  const spinner = p.spinner();
69
126
 
127
+ // Check if there's already a server running
128
+ spinner.start("Checking for existing dashboard server...");
129
+ const existingPort = await findExistingServer();
130
+
131
+ if (existingPort) {
132
+ spinner.stop(`Found existing server on port ${existingPort}`);
133
+ const url = `http://localhost:${existingPort}`;
134
+
135
+ p.log.success(`Dashboard already running at: ${url}`);
136
+ openBrowser(url);
137
+
138
+ p.note(`Server running on port ${existingPort}\nUsing existing server`, "📊 Auto-Learn Dashboard");
139
+
140
+ const action = await p.select({
141
+ message: "Dashboard is running. What would you like to do?",
142
+ options: [
143
+ { value: "keep", label: "🏠 Back to menu", hint: "Keep server running" },
144
+ { value: "stop", label: "🛑 Stop server", hint: "Shutdown dashboard" }
145
+ ]
146
+ });
147
+
148
+ if (action === "stop") {
149
+ // Kill all node processes on that port
150
+ p.log.info("Stopping existing server...");
151
+ if (process.platform === "win32") {
152
+ exec(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${existingPort}') do taskkill /F /PID %a`, () => { });
153
+ } else {
154
+ exec(`lsof -ti:${existingPort} | xargs kill -9`, () => { });
155
+ }
156
+ await new Promise(r => setTimeout(r, 1000));
157
+ p.log.success("Dashboard server stopped");
158
+ }
159
+ return;
160
+ }
161
+
162
+ spinner.stop("No existing server found");
163
+
70
164
  // Find dashboard script
71
165
  const scriptPath = findDashboardScript();
72
166
 
@@ -79,6 +173,7 @@ export async function runDashboardUI() {
79
173
  // Find available port
80
174
  spinner.start("Finding available port...");
81
175
  const port = await findAvailablePort(3030);
176
+ runningPort = port;
82
177
  spinner.stop(`Using port ${port}`);
83
178
 
84
179
  // Start dashboard server
@@ -89,6 +184,8 @@ export async function runDashboardUI() {
89
184
  detached: false
90
185
  });
91
186
 
187
+ runningServer = child;
188
+
92
189
  // Wait for server to start
93
190
  await new Promise((resolve) => setTimeout(resolve, 1500));
94
191
 
@@ -114,6 +211,8 @@ export async function runDashboardUI() {
114
211
 
115
212
  if (action === "stop" || p.isCancel(action)) {
116
213
  child.kill();
214
+ runningServer = null;
215
+ runningPort = null;
117
216
  p.log.info("Dashboard server stopped");
118
217
  } else {
119
218
  p.log.info(`Dashboard still running at ${url}`);
@@ -27,6 +27,40 @@ import { runDashboardUI } from "./dashboard-ui.js";
27
27
  import routingUI from "./routing-ui.js";
28
28
  import * as p from "@clack/prompts";
29
29
  import { VERSION } from "../config.js";
30
+ import gradient from 'gradient-string';
31
+
32
+ // ============================================================================
33
+ // ASCII BANNER
34
+ // ============================================================================
35
+
36
+ const AGENT_BANNER = `
37
+ _ _
38
+ / \\ __ _ ___ _ __ | |_
39
+ / _ \\ / _\` |/ _ \\ '_ \\| __|
40
+ / ___ \\ (_| | __/ | | | |_
41
+ /_/ \\_\\__, |\\___|_| |_|\\__|
42
+ |___/
43
+ `;
44
+
45
+ // Custom gradient: white → gray (like PikaKit style)
46
+ const agentGradient = gradient(['#ffffff', '#bbbbbb', '#888888', '#555555']);
47
+
48
+ function showAgentBanner() {
49
+ // Extra clear to remove Clack prompt residuals
50
+ process.stdout.write('\x1B[2J\x1B[0f');
51
+ console.clear();
52
+ console.log(''); // Extra space at top
53
+ const lines = AGENT_BANNER.split('\n').filter(l => l.trim() !== '');
54
+
55
+ // Print all lines except last with gradient
56
+ for (let i = 0; i < lines.length - 1; i++) {
57
+ console.log(agentGradient(lines[i]));
58
+ }
59
+
60
+ // Last line + version (aligned like PikaKit)
61
+ console.log(agentGradient(lines[lines.length - 1]) + theme.dim(` v${VERSION}`));
62
+ console.log(''); // Empty line to break vertical connector
63
+ }
30
64
 
31
65
  // ============================================================================
32
66
  // MAIN MENU
@@ -37,7 +71,7 @@ import { VERSION } from "../config.js";
37
71
  */
38
72
  export async function showMainMenu() {
39
73
  while (true) {
40
- showIntro(`🧠 Agent Skill Kit v${VERSION}`);
74
+ showAgentBanner();
41
75
 
42
76
  // Load settings to check auto-learning status
43
77
  const settings = loadSettings();
@@ -77,9 +111,8 @@ export async function showMainMenu() {
77
111
  // ═════════════════════════════════════════════
78
112
  // 📊 DASHBOARD
79
113
  // ═════════════════════════════════════════════
80
- { value: "dashboard", label: "📊 Dashboard", hint: "Web UI for Auto-Learn" },
114
+ { value: "dashboard", label: "📊 Dashboard", hint: "Web UI & Help" },
81
115
 
82
- { value: "help", label: "📖 Help", hint: "Visual guide" },
83
116
  { value: "exit", label: "👋 Exit" }
84
117
  );
85
118
 
@@ -113,9 +146,6 @@ export async function showMainMenu() {
113
146
  case "backup":
114
147
  await runBackupUI();
115
148
  break;
116
- case "help":
117
- await runHelpUI();
118
- break;
119
149
  case "dashboard":
120
150
  await runDashboardUI();
121
151
  break;
@@ -8,7 +8,7 @@
8
8
  * - Pattern frequency tracking
9
9
  * - Live feedback on violations
10
10
  *
11
- * Usage: ag-smart watch [directory]
11
+ * Usage: agent watch [directory]
12
12
  */
13
13
 
14
14
  import fs from "fs";
@@ -159,7 +159,7 @@ if (args.includes("--help")) {
159
159
  👁️ Smart Watcher - Real-Time Monitor
160
160
 
161
161
  Usage:
162
- ag-smart watch [directory]
162
+ agent watch [directory]
163
163
 
164
164
  Options:
165
165
  --help Show this help
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "agentskillskit-cli",
3
- "version": "3.2.1",
3
+ "version": "3.2.4",
4
4
  "description": "CLI for Agent Skill Kit",
5
5
  "type": "module",
6
6
  "main": "lib/config.js",
7
7
  "bin": {
8
- "agent": "bin/ag-smart.js",
9
- "ag-smart": "bin/ag-smart.js",
10
- "agent-skills-kit": "bin/ag-smart.js"
8
+ "agent": "bin/agent.js",
9
+ "agent": "bin/agent.js",
10
+ "agent-skills-kit": "bin/agent.js"
11
11
  },
12
12
  "scripts": {
13
13
  "test": "vitest run",