pikakit 3.0.5 โ 3.7.2
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 +1 -1
- package/bin/lib/commands/install.js +119 -242
- package/package.json +3 -4
- package/lib/agent-cli/bin/agent.js +0 -187
- package/lib/agent-cli/dashboard/dashboard_server.js +0 -312
- package/lib/agent-cli/lib/ab-testing.js +0 -364
- package/lib/agent-cli/lib/audit.js +0 -154
- package/lib/agent-cli/lib/audit.test.js +0 -100
- package/lib/agent-cli/lib/auto-learn.js +0 -319
- package/lib/agent-cli/lib/backup.js +0 -138
- package/lib/agent-cli/lib/backup.test.js +0 -78
- package/lib/agent-cli/lib/causality-engine.js +0 -331
- package/lib/agent-cli/lib/cognitive-lesson.js +0 -476
- package/lib/agent-cli/lib/completion.js +0 -149
- package/lib/agent-cli/lib/config.js +0 -35
- package/lib/agent-cli/lib/dashboard-data.js +0 -380
- package/lib/agent-cli/lib/eslint-fix.js +0 -238
- package/lib/agent-cli/lib/evolution-signal.js +0 -215
- package/lib/agent-cli/lib/export.js +0 -86
- package/lib/agent-cli/lib/export.test.js +0 -65
- package/lib/agent-cli/lib/fix.js +0 -337
- package/lib/agent-cli/lib/fix.test.js +0 -80
- package/lib/agent-cli/lib/gemini-export.js +0 -83
- package/lib/agent-cli/lib/generate-registry.js +0 -42
- package/lib/agent-cli/lib/hooks/install-hooks.js +0 -152
- package/lib/agent-cli/lib/hooks/lint-learn.js +0 -172
- package/lib/agent-cli/lib/icons.js +0 -93
- package/lib/agent-cli/lib/ignore.js +0 -116
- package/lib/agent-cli/lib/ignore.test.js +0 -58
- package/lib/agent-cli/lib/init.js +0 -124
- package/lib/agent-cli/lib/knowledge-index.js +0 -326
- package/lib/agent-cli/lib/knowledge-metrics.js +0 -335
- package/lib/agent-cli/lib/knowledge-retention.js +0 -398
- package/lib/agent-cli/lib/knowledge-validator.js +0 -312
- package/lib/agent-cli/lib/learn.js +0 -255
- package/lib/agent-cli/lib/learn.test.js +0 -70
- package/lib/agent-cli/lib/metrics-collector.js +0 -410
- package/lib/agent-cli/lib/proposals.js +0 -199
- package/lib/agent-cli/lib/proposals.test.js +0 -56
- package/lib/agent-cli/lib/recall.js +0 -835
- package/lib/agent-cli/lib/recall.test.js +0 -107
- package/lib/agent-cli/lib/reinforcement.js +0 -299
- package/lib/agent-cli/lib/selfevolution-bridge.js +0 -167
- package/lib/agent-cli/lib/settings.js +0 -203
- package/lib/agent-cli/lib/skill-generator.js +0 -379
- package/lib/agent-cli/lib/skill-learn.js +0 -296
- package/lib/agent-cli/lib/stats.js +0 -132
- package/lib/agent-cli/lib/stats.test.js +0 -94
- package/lib/agent-cli/lib/types.js +0 -33
- package/lib/agent-cli/lib/ui/audit-ui.js +0 -146
- package/lib/agent-cli/lib/ui/backup-ui.js +0 -107
- package/lib/agent-cli/lib/ui/clack-helpers.js +0 -317
- package/lib/agent-cli/lib/ui/common.js +0 -83
- package/lib/agent-cli/lib/ui/completion-ui.js +0 -126
- package/lib/agent-cli/lib/ui/custom-select.js +0 -69
- package/lib/agent-cli/lib/ui/dashboard-ui.js +0 -222
- package/lib/agent-cli/lib/ui/evolution-signals-ui.js +0 -107
- package/lib/agent-cli/lib/ui/export-ui.js +0 -94
- package/lib/agent-cli/lib/ui/fix-all-ui.js +0 -191
- package/lib/agent-cli/lib/ui/help-ui.js +0 -49
- package/lib/agent-cli/lib/ui/index.js +0 -199
- package/lib/agent-cli/lib/ui/init-ui.js +0 -56
- package/lib/agent-cli/lib/ui/knowledge-ui.js +0 -55
- package/lib/agent-cli/lib/ui/learn-ui.js +0 -706
- package/lib/agent-cli/lib/ui/lessons-ui.js +0 -148
- package/lib/agent-cli/lib/ui/pretty.js +0 -145
- package/lib/agent-cli/lib/ui/proposals-ui.js +0 -99
- package/lib/agent-cli/lib/ui/recall-ui.js +0 -342
- package/lib/agent-cli/lib/ui/routing-demo.js +0 -79
- package/lib/agent-cli/lib/ui/routing-ui.js +0 -325
- package/lib/agent-cli/lib/ui/settings-ui.js +0 -381
- package/lib/agent-cli/lib/ui/stats-ui.js +0 -123
- package/lib/agent-cli/lib/ui/watch-ui.js +0 -236
- package/lib/agent-cli/lib/watcher.js +0 -181
- package/lib/agent-cli/lib/watcher.test.js +0 -85
- package/lib/agent-cli/src/MIGRATION.md +0 -418
- package/lib/agent-cli/src/README.md +0 -367
- package/lib/agent-cli/src/core/evolution/evolution-signal.js +0 -42
- package/lib/agent-cli/src/core/evolution/index.js +0 -17
- package/lib/agent-cli/src/core/evolution/review-gate.js +0 -40
- package/lib/agent-cli/src/core/evolution/signal-detector.js +0 -137
- package/lib/agent-cli/src/core/evolution/signal-queue.js +0 -79
- package/lib/agent-cli/src/core/evolution/threshold-checker.js +0 -79
- package/lib/agent-cli/src/core/index.js +0 -15
- package/lib/agent-cli/src/core/learning/cognitive-enhancer.js +0 -282
- package/lib/agent-cli/src/core/learning/index.js +0 -12
- package/lib/agent-cli/src/core/learning/lesson-synthesizer.js +0 -83
- package/lib/agent-cli/src/core/scanning/index.js +0 -14
- package/lib/agent-cli/src/data/index.js +0 -13
- package/lib/agent-cli/src/data/repositories/index.js +0 -8
- package/lib/agent-cli/src/data/repositories/lesson-repository.js +0 -130
- package/lib/agent-cli/src/data/repositories/signal-repository.js +0 -119
- package/lib/agent-cli/src/data/storage/index.js +0 -8
- package/lib/agent-cli/src/data/storage/json-storage.js +0 -64
- package/lib/agent-cli/src/data/storage/yaml-storage.js +0 -66
- package/lib/agent-cli/src/infrastructure/index.js +0 -13
- package/lib/agent-cli/src/presentation/formatters/skill-formatter.js +0 -232
- package/lib/agent-cli/src/services/export-service.js +0 -162
- package/lib/agent-cli/src/services/index.js +0 -13
- package/lib/agent-cli/src/services/learning-service.js +0 -99
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Smart Learning Script - ESM Version (Production-Ready)
|
|
4
|
-
*
|
|
5
|
-
* The "Teacher" script. Adds new lessons to the system memory.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Manual lesson addition
|
|
9
|
-
* - Category tagging
|
|
10
|
-
* - Source tracking (manual, eslint, test-failure)
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* agent learn --add --pattern "regex" --message "why bad"
|
|
14
|
-
* agent learn --list
|
|
15
|
-
* agent learn --remove <id>
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import fs from "fs";
|
|
19
|
-
import path from "path";
|
|
20
|
-
import yaml from "js-yaml";
|
|
21
|
-
import { KNOWLEDGE_DIR, LESSONS_PATH, DEBUG, VERSION } from "./config.js";
|
|
22
|
-
|
|
23
|
-
// ============================================================================
|
|
24
|
-
// CORE FUNCTIONS
|
|
25
|
-
// ============================================================================
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Load knowledge base from YAML file
|
|
29
|
-
* @returns {{ lessons: Array, version?: number }}
|
|
30
|
-
*/
|
|
31
|
-
function loadKnowledge() {
|
|
32
|
-
try {
|
|
33
|
-
if (!fs.existsSync(LESSONS_PATH)) {
|
|
34
|
-
const initial = { lessons: [], version: 1 };
|
|
35
|
-
fs.mkdirSync(KNOWLEDGE_DIR, { recursive: true });
|
|
36
|
-
fs.writeFileSync(LESSONS_PATH, yaml.dump(initial), "utf8");
|
|
37
|
-
return initial;
|
|
38
|
-
}
|
|
39
|
-
const content = fs.readFileSync(LESSONS_PATH, "utf8");
|
|
40
|
-
return yaml.load(content) || { lessons: [], version: 1 };
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error("โ Failed to load knowledge base:", error.message);
|
|
43
|
-
if (DEBUG) console.error(error.stack);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Save knowledge base to YAML file
|
|
50
|
-
* @param {{ lessons: Array, version?: number }} data
|
|
51
|
-
*/
|
|
52
|
-
function saveKnowledge(data) {
|
|
53
|
-
try {
|
|
54
|
-
fs.mkdirSync(KNOWLEDGE_DIR, { recursive: true });
|
|
55
|
-
const str = yaml.dump(data, { lineWidth: -1, quotingType: '"' });
|
|
56
|
-
fs.writeFileSync(LESSONS_PATH, str, "utf8");
|
|
57
|
-
console.log("โ
Knowledge base updated successfully.");
|
|
58
|
-
} catch (error) {
|
|
59
|
-
console.error("โ Failed to save knowledge base:", error.message);
|
|
60
|
-
if (DEBUG) console.error(error.stack);
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Add a new lesson to the knowledge base
|
|
67
|
-
* @param {string} pattern - Regex pattern
|
|
68
|
-
* @param {string} message - Explanation message
|
|
69
|
-
* @param {string} severity - WARNING or ERROR
|
|
70
|
-
* @param {string} category - Category tag
|
|
71
|
-
*/
|
|
72
|
-
function addLesson(pattern, message, severity = "WARNING", category = "general") {
|
|
73
|
-
const db = loadKnowledge();
|
|
74
|
-
|
|
75
|
-
// Validate Regex
|
|
76
|
-
try {
|
|
77
|
-
new RegExp(pattern);
|
|
78
|
-
} catch (e) {
|
|
79
|
-
console.error("โ Invalid Regex pattern:", e.message);
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Validate severity
|
|
84
|
-
if (!["WARNING", "ERROR"].includes(severity.toUpperCase())) {
|
|
85
|
-
console.error("โ Invalid severity. Must be WARNING or ERROR");
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Check for duplicates
|
|
90
|
-
const exists = db.lessons.some(l => l.pattern === pattern);
|
|
91
|
-
if (exists) {
|
|
92
|
-
console.log("โ ๏ธ Pattern already exists in knowledge base.");
|
|
93
|
-
process.exit(0);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const id = `LEARN-${String(db.lessons.length + 1).padStart(3, "0")}`;
|
|
97
|
-
|
|
98
|
-
const lesson = {
|
|
99
|
-
id,
|
|
100
|
-
pattern,
|
|
101
|
-
message,
|
|
102
|
-
severity: severity.toUpperCase(),
|
|
103
|
-
category,
|
|
104
|
-
source: "manual",
|
|
105
|
-
hitCount: 0,
|
|
106
|
-
lastHit: null,
|
|
107
|
-
autoEscalated: false,
|
|
108
|
-
addedAt: new Date().toISOString()
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
db.lessons.push(lesson);
|
|
112
|
-
saveKnowledge(db);
|
|
113
|
-
|
|
114
|
-
console.log(`\n๐ Lesson Learned: [${id}]`);
|
|
115
|
-
console.log(` Pattern: /${pattern}/`);
|
|
116
|
-
console.log(` Message: ${message}`);
|
|
117
|
-
console.log(` Severity: ${severity.toUpperCase()}`);
|
|
118
|
-
console.log(` Category: ${category}\n`);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Remove a lesson by ID
|
|
123
|
-
* @param {string} lessonId
|
|
124
|
-
*/
|
|
125
|
-
function removeLesson(lessonId) {
|
|
126
|
-
const db = loadKnowledge();
|
|
127
|
-
const idx = db.lessons.findIndex(l => l.id === lessonId.toUpperCase());
|
|
128
|
-
|
|
129
|
-
if (idx === -1) {
|
|
130
|
-
console.log(`โ Lesson not found: ${lessonId}`);
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const removed = db.lessons.splice(idx, 1)[0];
|
|
135
|
-
saveKnowledge(db);
|
|
136
|
-
|
|
137
|
-
console.log(`\n๐๏ธ Removed lesson: [${removed.id}]`);
|
|
138
|
-
console.log(` Pattern: /${removed.pattern}/\n`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* List all learned lessons
|
|
143
|
-
* @param {string} category - Filter by category
|
|
144
|
-
*/
|
|
145
|
-
function listLessons(category = null) {
|
|
146
|
-
const db = loadKnowledge();
|
|
147
|
-
|
|
148
|
-
if (!db.lessons || db.lessons.length === 0) {
|
|
149
|
-
console.log("\nโน๏ธ No lessons learned yet.");
|
|
150
|
-
console.log(" Use: agent learn --add --pattern \"pat\" --message \"msg\"\n");
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
let lessons = db.lessons;
|
|
155
|
-
if (category) {
|
|
156
|
-
lessons = lessons.filter(l => l.category === category);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
console.log(`\n๐ง PikaKit Knowledge Base (${lessons.length} lesson(s))\n`);
|
|
160
|
-
console.log("โ".repeat(60));
|
|
161
|
-
|
|
162
|
-
lessons.forEach(l => {
|
|
163
|
-
const icon = l.severity === "ERROR" ? "โ" : "โ ๏ธ";
|
|
164
|
-
const hits = l.hitCount ? ` (${l.hitCount} hits)` : "";
|
|
165
|
-
const escalated = l.autoEscalated ? " โก" : "";
|
|
166
|
-
|
|
167
|
-
console.log(`${icon} [${l.id}] ${l.message}${hits}${escalated}`);
|
|
168
|
-
console.log(` Pattern: /${l.pattern}/`);
|
|
169
|
-
console.log(` Category: ${l.category || "general"} | Source: ${l.source || "manual"}`);
|
|
170
|
-
console.log("");
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// ============================================================================
|
|
175
|
-
// CLI
|
|
176
|
-
// ============================================================================
|
|
177
|
-
|
|
178
|
-
function printHelp() {
|
|
179
|
-
console.log(`
|
|
180
|
-
๐ Smart Learning Tool v${VERSION}
|
|
181
|
-
|
|
182
|
-
USAGE:
|
|
183
|
-
agent learn --add --pattern "..." --message "..."
|
|
184
|
-
agent learn --list [--category <cat>]
|
|
185
|
-
agent learn --remove <ID>
|
|
186
|
-
|
|
187
|
-
OPTIONS:
|
|
188
|
-
--add Add a new lesson
|
|
189
|
-
--pattern Regex pattern to flag
|
|
190
|
-
--message Explanation message
|
|
191
|
-
--severity WARNING (default) or ERROR
|
|
192
|
-
--category Category tag (default: general)
|
|
193
|
-
--list List all lessons
|
|
194
|
-
--remove Remove lesson by ID
|
|
195
|
-
--help Show this help
|
|
196
|
-
|
|
197
|
-
EXAMPLES:
|
|
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
|
-
`);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function main() {
|
|
205
|
-
const args = process.argv.slice(2);
|
|
206
|
-
|
|
207
|
-
if (args.includes("--help") || args.length === 0) {
|
|
208
|
-
printHelp();
|
|
209
|
-
process.exit(0);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (args.includes("--list")) {
|
|
213
|
-
const catIdx = args.indexOf("--category");
|
|
214
|
-
const category = catIdx !== -1 ? args[catIdx + 1] : null;
|
|
215
|
-
listLessons(category);
|
|
216
|
-
process.exit(0);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (args.includes("--remove")) {
|
|
220
|
-
const removeIdx = args.indexOf("--remove");
|
|
221
|
-
const lessonId = args[removeIdx + 1];
|
|
222
|
-
if (!lessonId) {
|
|
223
|
-
console.error("โ Missing lesson ID for --remove");
|
|
224
|
-
process.exit(1);
|
|
225
|
-
}
|
|
226
|
-
removeLesson(lessonId);
|
|
227
|
-
process.exit(0);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (args.includes("--add")) {
|
|
231
|
-
const pIdx = args.indexOf("--pattern");
|
|
232
|
-
const mIdx = args.indexOf("--message");
|
|
233
|
-
const sIdx = args.indexOf("--severity");
|
|
234
|
-
const cIdx = args.indexOf("--category");
|
|
235
|
-
|
|
236
|
-
if (pIdx === -1 || mIdx === -1) {
|
|
237
|
-
console.error("โ --pattern and --message are required for --add");
|
|
238
|
-
process.exit(1);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const pattern = args[pIdx + 1];
|
|
242
|
-
const message = args[mIdx + 1];
|
|
243
|
-
const severity = sIdx !== -1 ? args[sIdx + 1] : "WARNING";
|
|
244
|
-
const category = cIdx !== -1 ? args[cIdx + 1] : "general";
|
|
245
|
-
|
|
246
|
-
if (!pattern || !message) {
|
|
247
|
-
console.error("โ Missing values for pattern/message");
|
|
248
|
-
process.exit(1);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
addLesson(pattern, message, severity, category);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
main();
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Tests for learn.js functionality
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
5
|
-
import fs from "fs";
|
|
6
|
-
import path from "path";
|
|
7
|
-
import os from "os";
|
|
8
|
-
|
|
9
|
-
// Mock config ฤแป test
|
|
10
|
-
const TEST_DIR = path.join(os.tmpdir(), "agent-skill-kit-test");
|
|
11
|
-
const KNOWLEDGE_DIR = path.join(TEST_DIR, ".agent", "knowledge");
|
|
12
|
-
const LESSONS_PATH = path.join(KNOWLEDGE_DIR, "lessons-learned.yaml");
|
|
13
|
-
|
|
14
|
-
describe("Knowledge Base Operations", () => {
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
fs.mkdirSync(KNOWLEDGE_DIR, { recursive: true });
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
fs.rmSync(TEST_DIR, { recursive: true, force: true });
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("creates initial knowledge file if missing", () => {
|
|
24
|
-
// Simulate missing file scenario
|
|
25
|
-
expect(fs.existsSync(LESSONS_PATH)).toBe(false);
|
|
26
|
-
|
|
27
|
-
// Create initial file
|
|
28
|
-
const initial = { lessons: [] };
|
|
29
|
-
fs.writeFileSync(LESSONS_PATH, JSON.stringify(initial), "utf8");
|
|
30
|
-
|
|
31
|
-
expect(fs.existsSync(LESSONS_PATH)).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("can write and read lessons", () => {
|
|
35
|
-
const lesson = {
|
|
36
|
-
id: "LEARN-001",
|
|
37
|
-
pattern: "console\\.log",
|
|
38
|
-
message: "No console.log in production",
|
|
39
|
-
severity: "WARNING",
|
|
40
|
-
addedAt: new Date().toISOString()
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const data = { lessons: [lesson] };
|
|
44
|
-
fs.writeFileSync(LESSONS_PATH, JSON.stringify(data), "utf8");
|
|
45
|
-
|
|
46
|
-
const content = fs.readFileSync(LESSONS_PATH, "utf8");
|
|
47
|
-
const parsed = JSON.parse(content);
|
|
48
|
-
|
|
49
|
-
expect(parsed.lessons).toHaveLength(1);
|
|
50
|
-
expect(parsed.lessons[0].id).toBe("LEARN-001");
|
|
51
|
-
expect(parsed.lessons[0].pattern).toBe("console\\.log");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("validates regex patterns", () => {
|
|
55
|
-
const validPattern = "console\\.log";
|
|
56
|
-
const invalidPattern = "[invalid(";
|
|
57
|
-
|
|
58
|
-
expect(() => new RegExp(validPattern)).not.toThrow();
|
|
59
|
-
expect(() => new RegExp(invalidPattern)).toThrow();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("validates severity values", () => {
|
|
63
|
-
const validSeverities = ["WARNING", "ERROR"];
|
|
64
|
-
const invalidSeverity = "INFO";
|
|
65
|
-
|
|
66
|
-
expect(validSeverities.includes("WARNING")).toBe(true);
|
|
67
|
-
expect(validSeverities.includes("ERROR")).toBe(true);
|
|
68
|
-
expect(validSeverities.includes(invalidSeverity)).toBe(false);
|
|
69
|
-
});
|
|
70
|
-
});
|