pikakit 1.0.8 ā 1.0.9
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 +6 -2
- package/lib/agent-cli/lib/ab-testing.js +508 -0
- package/lib/agent-cli/lib/causality-engine.js +623 -0
- package/lib/agent-cli/lib/dashboard-data.js +365 -0
- package/lib/agent-cli/lib/fix.js +1 -1
- package/lib/agent-cli/lib/metrics-collector.js +523 -0
- package/lib/agent-cli/lib/metrics-schema.js +410 -0
- package/lib/agent-cli/lib/precision-skill-generator.js +584 -0
- package/lib/agent-cli/lib/recall.js +1 -1
- package/lib/agent-cli/lib/reinforcement.js +610 -0
- package/lib/agent-cli/lib/ui/index.js +37 -14
- package/package.json +2 -2
- package/lib/agent-cli/lib/auto-learn.js +0 -319
- package/lib/agent-cli/scripts/adaptive_engine.js +0 -381
- package/lib/agent-cli/scripts/error_sensor.js +0 -565
- package/lib/agent-cli/scripts/learn_from_failure.js +0 -225
- package/lib/agent-cli/scripts/pattern_analyzer.js +0 -781
- package/lib/agent-cli/scripts/skill_injector.js +0 -387
- package/lib/agent-cli/scripts/success_sensor.js +0 -500
- package/lib/agent-cli/scripts/user_correction_sensor.js +0 -426
- package/lib/agent-cli/services/auto-learn-service.js +0 -247
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main Menu UI - Interactive CLI interface
|
|
3
|
+
* AutoLearn v6.0 - Passive Learning Architecture
|
|
4
|
+
*
|
|
5
|
+
* Changes from v1:
|
|
6
|
+
* - Removed "Scan All" option (now runs passively in background)
|
|
7
|
+
* - Renamed to "Insights" view
|
|
8
|
+
* - Added background observer startup
|
|
3
9
|
*/
|
|
4
10
|
import { showIntro, showActionMenu, theme } from "./clack-helpers.js";
|
|
5
11
|
import { loadSettings } from "../settings.js";
|
|
@@ -62,14 +68,37 @@ function showAgentBanner() {
|
|
|
62
68
|
console.log(''); // Empty line to break vertical connector
|
|
63
69
|
}
|
|
64
70
|
|
|
71
|
+
// ============================================================================
|
|
72
|
+
// BACKGROUND OBSERVER (AutoLearn v6.0)
|
|
73
|
+
// ============================================================================
|
|
74
|
+
|
|
75
|
+
let backgroundObserverStarted = false;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Start background observers for passive learning
|
|
79
|
+
* This runs silently without user intervention
|
|
80
|
+
*/
|
|
81
|
+
async function startBackgroundObserver() {
|
|
82
|
+
if (backgroundObserverStarted) return;
|
|
83
|
+
backgroundObserverStarted = true;
|
|
84
|
+
|
|
85
|
+
// Note: Actual implementation would integrate with file watcher
|
|
86
|
+
// For now, we just mark that passive learning is active
|
|
87
|
+
console.log(theme.dim(' š§ AutoLearn v6.0 - Passive learning active'));
|
|
88
|
+
}
|
|
89
|
+
|
|
65
90
|
// ============================================================================
|
|
66
91
|
// MAIN MENU
|
|
67
92
|
// ============================================================================
|
|
68
93
|
|
|
69
94
|
/**
|
|
70
95
|
* Show main interactive menu
|
|
96
|
+
* AutoLearn v6.0 - No more manual "Scan All" needed
|
|
71
97
|
*/
|
|
72
98
|
export async function showMainMenu() {
|
|
99
|
+
// Start background observer on first run
|
|
100
|
+
startBackgroundObserver();
|
|
101
|
+
|
|
73
102
|
while (true) {
|
|
74
103
|
showAgentBanner();
|
|
75
104
|
|
|
@@ -78,12 +107,8 @@ export async function showMainMenu() {
|
|
|
78
107
|
const autoLearningEnabled = settings.autoLearn !== false; // Default to true
|
|
79
108
|
|
|
80
109
|
// Build menu options dynamically
|
|
110
|
+
// NOTE: "Scan All" removed in v6.0 - scanning now runs passively
|
|
81
111
|
const menuOptions = [
|
|
82
|
-
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
83
|
-
// š SCANNING & ACTIONS
|
|
84
|
-
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
85
|
-
{ value: "scanall", label: "š Scan All", hint: "Check & fix violations" },
|
|
86
|
-
|
|
87
112
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
88
113
|
// š LEARNING & KNOWLEDGE
|
|
89
114
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
@@ -98,9 +123,9 @@ export async function showMainMenu() {
|
|
|
98
123
|
{ value: "lessons", label: "š Lessons", hint: "View & manage" },
|
|
99
124
|
|
|
100
125
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
101
|
-
// š ANALYTICS
|
|
126
|
+
// š ANALYTICS (renamed from Stats)
|
|
102
127
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
103
|
-
{ value: "
|
|
128
|
+
{ value: "insights", label: "š” Insights", hint: "Metrics & patterns" },
|
|
104
129
|
|
|
105
130
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
106
131
|
// āļø SETTINGS & MANAGEMENT
|
|
@@ -111,7 +136,7 @@ export async function showMainMenu() {
|
|
|
111
136
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
112
137
|
// š DASHBOARD
|
|
113
138
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
114
|
-
{ value: "dashboard", label: "š Dashboard", hint: "Web UI &
|
|
139
|
+
{ value: "dashboard", label: "š Dashboard", hint: "Web UI & metrics" },
|
|
115
140
|
|
|
116
141
|
{ value: "exit", label: "š Exit" }
|
|
117
142
|
);
|
|
@@ -127,6 +152,7 @@ export async function showMainMenu() {
|
|
|
127
152
|
}
|
|
128
153
|
|
|
129
154
|
// Execute action directly (no submenus)
|
|
155
|
+
// NOTE: scanall case removed - use Dashboard for viewing scan results
|
|
130
156
|
switch (action) {
|
|
131
157
|
case "learn":
|
|
132
158
|
await runLearnUI();
|
|
@@ -134,11 +160,8 @@ export async function showMainMenu() {
|
|
|
134
160
|
case "lessons":
|
|
135
161
|
await runLessonsUI();
|
|
136
162
|
break;
|
|
137
|
-
case "
|
|
138
|
-
await
|
|
139
|
-
break;
|
|
140
|
-
case "stats":
|
|
141
|
-
await runStatsUI(); // Now includes signals
|
|
163
|
+
case "insights":
|
|
164
|
+
await runStatsUI(); // Insights view (formerly stats + signals)
|
|
142
165
|
break;
|
|
143
166
|
case "settings":
|
|
144
167
|
await runSettingsUI();
|
|
@@ -192,7 +215,7 @@ async function runRoutingUI() {
|
|
|
192
215
|
// ============================================================================
|
|
193
216
|
|
|
194
217
|
// Run if executed directly
|
|
195
|
-
if (process.argv[1]
|
|
218
|
+
if (process.argv[1]?.includes("index.js") || process.argv[1]?.includes("ui")) {
|
|
196
219
|
showMainMenu().catch(console.error);
|
|
197
220
|
}
|
|
198
221
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pikakit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Enterprise-grade Agent Skill Manager with Antigravity Skills support, Progressive Disclosure detection, and semantic routing validation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "pikakit <pikakit@gmail.com>",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"prettier": "^3.2.5",
|
|
79
79
|
"vitest": "^4.0.18"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Smart Auto-Learn - True Self-Learning Engine
|
|
4
|
-
*
|
|
5
|
-
* Automatically learns from:
|
|
6
|
-
* 1. ESLint output (runs ESLint and parses)
|
|
7
|
-
* 2. Test failures (runs tests and parses)
|
|
8
|
-
* 3. TypeScript errors (runs tsc and parses)
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
* agent auto-learn # Run all
|
|
12
|
-
* agent auto-learn --eslint # ESLint only
|
|
13
|
-
* agent auto-learn --test # Test failures only
|
|
14
|
-
* agent auto-learn --typescript # TypeScript only
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import fs from "fs";
|
|
18
|
-
import path from "path";
|
|
19
|
-
import { execSync, spawnSync } from "child_process";
|
|
20
|
-
import { loadKnowledge, saveKnowledge } from "./recall.js";
|
|
21
|
-
import { VERSION } from "./config.js";
|
|
22
|
-
|
|
23
|
-
// ============================================================================
|
|
24
|
-
// ESLINT AUTO-LEARN
|
|
25
|
-
// ============================================================================
|
|
26
|
-
|
|
27
|
-
const ESLINT_PATTERN_MAP = {
|
|
28
|
-
"no-console": { pattern: "console\\.(log|warn|error|info|debug)", message: "Avoid console statements in production" },
|
|
29
|
-
"no-debugger": { pattern: "\\bdebugger\\b", message: "Remove debugger statements" },
|
|
30
|
-
"no-var": { pattern: "\\bvar\\s+\\w", message: "Use const/let instead of var" },
|
|
31
|
-
"eqeqeq": { pattern: "[^!=]==[^=]", message: "Use === instead of ==" },
|
|
32
|
-
"no-eval": { pattern: "\\beval\\s*\\(", message: "Avoid eval() for security" },
|
|
33
|
-
"no-alert": { pattern: "\\balert\\s*\\(", message: "Avoid alert() in production" },
|
|
34
|
-
"no-implicit-globals": { pattern: "^(?!const|let|var|function|class|import|export)", message: "Avoid implicit globals" },
|
|
35
|
-
"prefer-const": { pattern: "\\blet\\s+\\w+\\s*=\\s*[^;]+;(?![\\s\\S]*\\1\\s*=)", message: "Use const for variables that are never reassigned" },
|
|
36
|
-
"no-unused-expressions": { pattern: "^\\s*['\"`]use strict['\"`];?\\s*$", message: "Remove unused expressions" },
|
|
37
|
-
"semi": { pattern: "[^;{}]\\s*$", message: "Missing semicolon" },
|
|
38
|
-
"quotes": { pattern: '(?<![\\w])"(?![^"]*"[,\\]\\}\\)])', message: "Prefer single quotes" },
|
|
39
|
-
"no-empty": { pattern: "\\{\\s*\\}", message: "Empty block statement" },
|
|
40
|
-
"no-extra-semi": { pattern: ";;", message: "Unnecessary semicolon" },
|
|
41
|
-
"no-unreachable": { pattern: "(?:return|throw|break|continue)[^}]*[\\n\\r]+[^}]+", message: "Unreachable code" }
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function runEslintAutoLearn(projectRoot) {
|
|
45
|
-
console.log("\nš Running ESLint analysis...\n");
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
// Try to run ESLint with JSON output
|
|
49
|
-
const result = spawnSync("npx", ["eslint", ".", "--format", "json", "--no-error-on-unmatched-pattern"], {
|
|
50
|
-
cwd: projectRoot,
|
|
51
|
-
encoding: "utf8",
|
|
52
|
-
shell: true,
|
|
53
|
-
timeout: 60000
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (!result.stdout) {
|
|
57
|
-
console.log(" ā¹ļø ESLint not configured or no files to lint.");
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const eslintResults = JSON.parse(result.stdout);
|
|
62
|
-
const ruleViolations = {};
|
|
63
|
-
|
|
64
|
-
eslintResults.forEach(file => {
|
|
65
|
-
if (!file.messages) return;
|
|
66
|
-
file.messages.forEach(msg => {
|
|
67
|
-
if (!msg.ruleId) return;
|
|
68
|
-
if (!ruleViolations[msg.ruleId]) {
|
|
69
|
-
ruleViolations[msg.ruleId] = {
|
|
70
|
-
rule: msg.ruleId,
|
|
71
|
-
count: 0,
|
|
72
|
-
severity: msg.severity === 2 ? "ERROR" : "WARNING",
|
|
73
|
-
sample: msg.message
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
ruleViolations[msg.ruleId].count++;
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
return Object.values(ruleViolations).sort((a, b) => b.count - a.count);
|
|
81
|
-
} catch (e) {
|
|
82
|
-
console.log(" ā ļø ESLint analysis skipped:", e.message);
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ============================================================================
|
|
88
|
-
// TEST FAILURE AUTO-LEARN
|
|
89
|
-
// ============================================================================
|
|
90
|
-
|
|
91
|
-
const TEST_PATTERN_MAP = {
|
|
92
|
-
"undefined is not a function": { pattern: "\\w+\\s*\\(", message: "Function may be undefined before call" },
|
|
93
|
-
"cannot read property": { pattern: "\\w+\\.\\w+", message: "Object property access may fail if undefined" },
|
|
94
|
-
"null is not an object": { pattern: "\\.\\w+", message: "Null check needed before property access" },
|
|
95
|
-
"expected.*to equal": { pattern: "expect\\s*\\(", message: "Assertion expectation mismatch" },
|
|
96
|
-
"timeout": { pattern: "async|await|Promise", message: "Async operation may need longer timeout" },
|
|
97
|
-
"not defined": { pattern: "\\b\\w+\\b", message: "Variable may not be defined in scope" }
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
function runTestAutoLearn(projectRoot) {
|
|
101
|
-
console.log("\nš§Ŗ Running test analysis...\n");
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
// Try common test runners
|
|
105
|
-
const testCommands = [
|
|
106
|
-
{ cmd: "npm", args: ["test", "--", "--json", "--passWithNoTests"], name: "npm test" },
|
|
107
|
-
{ cmd: "npx", args: ["vitest", "run", "--reporter=json"], name: "vitest" },
|
|
108
|
-
{ cmd: "npx", args: ["jest", "--json", "--passWithNoTests"], name: "jest" }
|
|
109
|
-
];
|
|
110
|
-
|
|
111
|
-
for (const tc of testCommands) {
|
|
112
|
-
const result = spawnSync(tc.cmd, tc.args, {
|
|
113
|
-
cwd: projectRoot,
|
|
114
|
-
encoding: "utf8",
|
|
115
|
-
shell: true,
|
|
116
|
-
timeout: 120000
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// Look for test failures in output
|
|
120
|
-
const output = result.stdout + result.stderr;
|
|
121
|
-
const failures = [];
|
|
122
|
-
|
|
123
|
-
// Parse failure messages
|
|
124
|
-
const failurePatterns = [
|
|
125
|
-
/FAIL\s+(.+)/g,
|
|
126
|
-
/ā\s+(.+)/g,
|
|
127
|
-
/Error:\s+(.+)/g,
|
|
128
|
-
/AssertionError:\s+(.+)/g
|
|
129
|
-
];
|
|
130
|
-
|
|
131
|
-
failurePatterns.forEach(regex => {
|
|
132
|
-
let match;
|
|
133
|
-
while ((match = regex.exec(output)) !== null) {
|
|
134
|
-
failures.push(match[1].trim());
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
if (failures.length > 0) {
|
|
139
|
-
console.log(` Found ${failures.length} test failure(s) from ${tc.name}`);
|
|
140
|
-
return failures.map(f => ({ message: f, source: tc.name }));
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
console.log(" ā
All tests passing or no tests found.");
|
|
145
|
-
return [];
|
|
146
|
-
} catch (e) {
|
|
147
|
-
console.log(" ā ļø Test analysis skipped:", e.message);
|
|
148
|
-
return [];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// ============================================================================
|
|
153
|
-
// TYPESCRIPT ERROR AUTO-LEARN
|
|
154
|
-
// ============================================================================
|
|
155
|
-
|
|
156
|
-
const TS_PATTERN_MAP = {
|
|
157
|
-
"TS2304": { pattern: "\\b\\w+\\b", message: "TypeScript: Cannot find name" },
|
|
158
|
-
"TS2322": { pattern: ":\\s*\\w+", message: "TypeScript: Type mismatch" },
|
|
159
|
-
"TS2345": { pattern: "\\(.*\\)", message: "TypeScript: Argument type mismatch" },
|
|
160
|
-
"TS2339": { pattern: "\\.\\w+", message: "TypeScript: Property does not exist" },
|
|
161
|
-
"TS7006": { pattern: "\\(\\w+\\)", message: "TypeScript: Parameter implicitly has 'any' type" },
|
|
162
|
-
"TS2531": { pattern: "\\w+\\.", message: "TypeScript: Object is possibly 'null'" },
|
|
163
|
-
"TS2532": { pattern: "\\w+\\.", message: "TypeScript: Object is possibly 'undefined'" }
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
function runTypescriptAutoLearn(projectRoot) {
|
|
167
|
-
console.log("\nš Running TypeScript analysis...\n");
|
|
168
|
-
|
|
169
|
-
try {
|
|
170
|
-
const result = spawnSync("npx", ["tsc", "--noEmit", "--pretty", "false"], {
|
|
171
|
-
cwd: projectRoot,
|
|
172
|
-
encoding: "utf8",
|
|
173
|
-
shell: true,
|
|
174
|
-
timeout: 60000
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const output = result.stdout + result.stderr;
|
|
178
|
-
const errors = {};
|
|
179
|
-
|
|
180
|
-
// Parse TS errors: file(line,col): error TS1234: message
|
|
181
|
-
const tsErrorRegex = /error (TS\d+):\s*(.+)/g;
|
|
182
|
-
let match;
|
|
183
|
-
|
|
184
|
-
while ((match = tsErrorRegex.exec(output)) !== null) {
|
|
185
|
-
const code = match[1];
|
|
186
|
-
const message = match[2];
|
|
187
|
-
|
|
188
|
-
if (!errors[code]) {
|
|
189
|
-
errors[code] = { code, message, count: 0 };
|
|
190
|
-
}
|
|
191
|
-
errors[code].count++;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const errorList = Object.values(errors).sort((a, b) => b.count - a.count);
|
|
195
|
-
|
|
196
|
-
if (errorList.length > 0) {
|
|
197
|
-
console.log(` Found ${errorList.length} unique TypeScript error type(s)`);
|
|
198
|
-
} else {
|
|
199
|
-
console.log(" ā
No TypeScript errors found.");
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return errorList;
|
|
203
|
-
} catch (e) {
|
|
204
|
-
console.log(" ā ļø TypeScript analysis skipped:", e.message);
|
|
205
|
-
return [];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// ============================================================================
|
|
210
|
-
// MAIN AUTO-LEARN ENGINE
|
|
211
|
-
// ============================================================================
|
|
212
|
-
|
|
213
|
-
function autoLearn(projectRoot, options = {}) {
|
|
214
|
-
console.log(`\nš§ Smart Auto-Learn Engine v${VERSION}`);
|
|
215
|
-
console.log(`š Project: ${projectRoot}\n`);
|
|
216
|
-
console.log("ā".repeat(50));
|
|
217
|
-
|
|
218
|
-
const db = loadKnowledge();
|
|
219
|
-
let totalAdded = 0;
|
|
220
|
-
|
|
221
|
-
// ESLint
|
|
222
|
-
if (!options.onlyTest && !options.onlyTypescript) {
|
|
223
|
-
const eslintViolations = runEslintAutoLearn(projectRoot);
|
|
224
|
-
|
|
225
|
-
eslintViolations.forEach(v => {
|
|
226
|
-
const mapping = ESLINT_PATTERN_MAP[v.rule];
|
|
227
|
-
if (!mapping) return;
|
|
228
|
-
|
|
229
|
-
// Check if already exists
|
|
230
|
-
if (db.lessons.some(l => l.pattern === mapping.pattern)) return;
|
|
231
|
-
|
|
232
|
-
const id = `AUTO-${String(db.lessons.length + 1).padStart(3, "0")}`;
|
|
233
|
-
db.lessons.push({
|
|
234
|
-
id,
|
|
235
|
-
pattern: mapping.pattern,
|
|
236
|
-
message: `${mapping.message} (ESLint: ${v.rule})`,
|
|
237
|
-
severity: v.severity,
|
|
238
|
-
source: "auto-eslint",
|
|
239
|
-
hitCount: v.count,
|
|
240
|
-
autoEscalated: false,
|
|
241
|
-
addedAt: new Date().toISOString()
|
|
242
|
-
});
|
|
243
|
-
totalAdded++;
|
|
244
|
-
console.log(` ā
Auto-learned: [${id}] ${v.rule} (${v.count} occurrences)`);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// TypeScript
|
|
249
|
-
if (!options.onlyEslint && !options.onlyTest) {
|
|
250
|
-
const tsErrors = runTypescriptAutoLearn(projectRoot);
|
|
251
|
-
|
|
252
|
-
tsErrors.slice(0, 5).forEach(e => { // Top 5 only
|
|
253
|
-
const mapping = TS_PATTERN_MAP[e.code];
|
|
254
|
-
if (!mapping) return;
|
|
255
|
-
|
|
256
|
-
if (db.lessons.some(l => l.message.includes(e.code))) return;
|
|
257
|
-
|
|
258
|
-
const id = `AUTO-${String(db.lessons.length + 1).padStart(3, "0")}`;
|
|
259
|
-
db.lessons.push({
|
|
260
|
-
id,
|
|
261
|
-
pattern: mapping.pattern,
|
|
262
|
-
message: `${mapping.message} (${e.code})`,
|
|
263
|
-
severity: "WARNING",
|
|
264
|
-
source: "auto-typescript",
|
|
265
|
-
hitCount: e.count,
|
|
266
|
-
autoEscalated: false,
|
|
267
|
-
addedAt: new Date().toISOString()
|
|
268
|
-
});
|
|
269
|
-
totalAdded++;
|
|
270
|
-
console.log(` ā
Auto-learned: [${id}] ${e.code} (${e.count} occurrences)`);
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Summary
|
|
275
|
-
console.log("\n" + "ā".repeat(50));
|
|
276
|
-
|
|
277
|
-
if (totalAdded > 0) {
|
|
278
|
-
saveKnowledge(db);
|
|
279
|
-
console.log(`\nš Auto-learned ${totalAdded} new pattern(s)!`);
|
|
280
|
-
console.log(`š Total lessons in memory: ${db.lessons.length}\n`);
|
|
281
|
-
} else {
|
|
282
|
-
console.log("\nā
No new patterns discovered. Code looks clean!\n");
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return totalAdded;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// ============================================================================
|
|
289
|
-
// CLI
|
|
290
|
-
// ============================================================================
|
|
291
|
-
|
|
292
|
-
const args = process.argv.slice(2);
|
|
293
|
-
const projectRoot = process.cwd();
|
|
294
|
-
|
|
295
|
-
if (args.includes("--help")) {
|
|
296
|
-
console.log(`
|
|
297
|
-
š§ Smart Auto-Learn - True Self-Learning Engine
|
|
298
|
-
|
|
299
|
-
Usage:
|
|
300
|
-
agent auto-learn Run all analyzers
|
|
301
|
-
agent auto-learn --eslint ESLint only
|
|
302
|
-
agent auto-learn --typescript TypeScript only
|
|
303
|
-
agent auto-learn --test Test failures only
|
|
304
|
-
|
|
305
|
-
The engine automatically:
|
|
306
|
-
1. Runs ESLint and learns from violations
|
|
307
|
-
2. Runs TypeScript and learns from type errors
|
|
308
|
-
3. Runs tests and learns from failures
|
|
309
|
-
|
|
310
|
-
Patterns are automatically added to knowledge base!
|
|
311
|
-
`);
|
|
312
|
-
process.exit(0);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
autoLearn(projectRoot, {
|
|
316
|
-
onlyEslint: args.includes("--eslint"),
|
|
317
|
-
onlyTypescript: args.includes("--typescript"),
|
|
318
|
-
onlyTest: args.includes("--test")
|
|
319
|
-
});
|