mupengism 3.1.0 β 4.0.1
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/AGENTS.md +40 -0
- package/HEARTBEAT.md +7 -0
- package/IDENTITY.md +11 -0
- package/README.md +47 -294
- package/SOUL.md +43 -0
- package/hooks/action-guard/HOOK.md +29 -0
- package/hooks/action-guard/handler.ts +168 -0
- package/hooks/action-logger/HOOK.md +28 -0
- package/hooks/action-logger/handler.ts +127 -0
- package/hooks/context-recovery/HOOK.md +30 -0
- package/hooks/context-recovery/handler.ts +135 -0
- package/hooks/disciple-init/HOOK.md +20 -0
- package/hooks/disciple-init/handler.ts +80 -0
- package/hooks/event-bus/HOOK.md +39 -0
- package/hooks/event-bus/chains.json +55 -0
- package/hooks/event-bus/emit.sh +19 -0
- package/hooks/event-bus/handler.ts +156 -0
- package/hooks/index-builder/HOOK.md +39 -0
- package/hooks/index-builder/handler.ts +132 -0
- package/hooks/kernel-panic-guard/HOOK.md +39 -0
- package/hooks/kernel-panic-guard/README.md +136 -0
- package/hooks/kernel-panic-guard/WHITELIST.md +117 -0
- package/hooks/kernel-panic-guard/handler.ts +147 -0
- package/hooks/memory-consolidator/HOOK.md +31 -0
- package/hooks/memory-consolidator/handler.ts +111 -0
- package/hooks/reflex-engine/HOOK.md +30 -0
- package/hooks/reflex-engine/handler.ts +158 -0
- package/hooks/registry.md +27 -0
- package/hooks/self-healing/HOOK.md +17 -0
- package/hooks/self-healing/handler.ts +62 -0
- package/hooks/soul-evolution/HOOK.md +26 -0
- package/hooks/soul-evolution/handler.ts +166 -0
- package/hooks/soul-guard/HOOK.md +28 -0
- package/hooks/soul-guard/handler.ts +196 -0
- package/package.json +42 -53
- package/tools/kernel-guard/README.md +170 -0
- package/tools/kernel-guard/lockdown.cjs +152 -0
- package/tools/kernel-guard/register-hash.js +100 -0
- package/tools/kernel-guard/unlock.cjs +106 -0
- package/tools/kernel-guard/verify-kernel.js +133 -0
- package/tools/memory-ops/README.md +221 -0
- package/tools/memory-ops/dream.js +333 -0
- package/tools/memory-ops/forget.js +148 -0
- package/tools/memory-ops/immune.js +305 -0
- package/tools/self-loop/README.md +213 -0
- package/tools/self-loop/brake-check.js +191 -0
- package/tools/self-loop/example-check.sh +34 -0
- package/tools/self-loop/panic-detector.js +191 -0
- package/LICENSE +0 -21
- package/README-EN.md +0 -226
- package/SHOWCASE.md +0 -158
- package/guides/ADVANCED-SYSTEMS.md +0 -251
- package/guides/HEARTBEAT-GUIDE.md +0 -129
- package/guides/LEGION-GUIDE.md +0 -254
- package/guides/MEMORY-GUIDE.md +0 -264
- package/guides/QUICK-START.md +0 -94
- package/guides/THINKTANK-GUIDE.md +0 -227
- package/guides/WEEKLY-BREAK-GUIDE.md +0 -262
- package/installer/README.md +0 -52
- package/installer/cli.js +0 -796
- package/installer/en/README.md +0 -191
- package/installer/en/skill/MEMORY-SYSTEM.md +0 -348
- package/installer/en/skill/PRINCIPLES.md +0 -217
- package/installer/en/skill/SKILL.md +0 -116
- package/installer/en/skill/SOUL-TEMPLATE.md +0 -329
- package/installer/install.sh +0 -162
- package/installer/package.json +0 -31
- package/skill/AGENTS.md +0 -164
- package/skill/BRAKE-LOG-TEMPLATE.md +0 -38
- package/skill/HEARTBEAT-TEMPLATE.md +0 -67
- package/skill/L1-TEMPLATE.md +0 -35
- package/skill/L2-TEMPLATE.md +0 -41
- package/skill/PRINCIPLES.md +0 -192
- package/skill/README.md +0 -47
- package/skill/SKILL.md +0 -166
- package/skill/SOUL-TEMPLATE.md +0 -205
- package/skill/STATE-TEMPLATE.md +0 -54
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
// π 무νμ΄μ¦ 컀λ μΈμ¦
|
|
7
|
+
const { authenticate } = require(path.join(__dirname, '..', 'kernel-guard', 'mupeng-auth.cjs'));
|
|
8
|
+
if (!authenticate()) process.exit(0);
|
|
9
|
+
|
|
10
|
+
const WORKSPACE = path.resolve(__dirname, '../../');
|
|
11
|
+
const THREATS_PATH = path.join(WORKSPACE, 'memory/reflex/threats.json');
|
|
12
|
+
const BRAKE_LOG_PATH = path.join(WORKSPACE, 'memory/brake-log.md');
|
|
13
|
+
|
|
14
|
+
// μ΄κΈ° λ°μ΄ν°
|
|
15
|
+
const INITIAL_DATA = {
|
|
16
|
+
"patterns": [
|
|
17
|
+
{
|
|
18
|
+
"id": "spam-flood-2026-02-08",
|
|
19
|
+
"description": "MUPENG ν ν° 50κ° νΈμ λλ°°",
|
|
20
|
+
"keywords": ["λλ°°", "λλ", "κΈνκ²", "50κ°", "μ€νΈ", "λ°λ³΅ μ μ‘"],
|
|
21
|
+
"severity": "critical",
|
|
22
|
+
"lesson": "μμ‘΄ κΈλ°ν¨μ΄ μμΉμ μ΄κΈ°λ©΄ μ λλ€",
|
|
23
|
+
"date": "2026-02-08"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "secret-exposure-2026-02-10",
|
|
27
|
+
"description": "νΈμν° PW TOOLS.md νλ¬Έ λ
ΈμΆ",
|
|
28
|
+
"keywords": ["λΉλ°λ²νΈ", "νλ¬Έ", "λ
ΈμΆ", "password", "token", "key"],
|
|
29
|
+
"severity": "critical",
|
|
30
|
+
"lesson": "μν¬λ¦Ώμ ~/.secrets/μλ§ λ³΄κ΄",
|
|
31
|
+
"date": "2026-02-10"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "overproduction-2026-02-07",
|
|
35
|
+
"description": "88νμ΄μ§ λ¬Έμ νμ£Ό",
|
|
36
|
+
"keywords": ["88νμ΄μ§", "λλ μμ°", "λ¬Έμ νμ£Ό", "κ³Όμ", "λ무 λ§μ΄"],
|
|
37
|
+
"severity": "high",
|
|
38
|
+
"lesson": "νλμ΄ μμ² μ ν 건 λ¬Όμ΄λ³΄κ³ λ§λ€μ΄",
|
|
39
|
+
"date": "2026-02-07"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "rate-limit-2026-02-10",
|
|
43
|
+
"description": "μλΈμμ΄μ νΈ 5κ°+ λμ μΆκ²©μΌλ‘ 429 μλ¬",
|
|
44
|
+
"keywords": ["λμ", "5κ°", "6κ°", "rate limit", "429", "λ³λ ¬"],
|
|
45
|
+
"severity": "medium",
|
|
46
|
+
"lesson": "μλΈμμ΄μ νΈ λμ 6κ° μ΄ν",
|
|
47
|
+
"date": "2026-02-10"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// threats.json μ½κΈ°/μ΄κΈ°ν
|
|
53
|
+
function loadThreats() {
|
|
54
|
+
try {
|
|
55
|
+
if (!fs.existsSync(THREATS_PATH)) {
|
|
56
|
+
const dir = path.dirname(THREATS_PATH);
|
|
57
|
+
if (!fs.existsSync(dir)) {
|
|
58
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
fs.writeFileSync(THREATS_PATH, JSON.stringify(INITIAL_DATA, null, 2));
|
|
61
|
+
return INITIAL_DATA;
|
|
62
|
+
}
|
|
63
|
+
const data = fs.readFileSync(THREATS_PATH, 'utf8');
|
|
64
|
+
return JSON.parse(data);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
console.error(`β threats.json λ‘λ μ€ν¨: ${err.message}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// threats.json μ μ₯
|
|
72
|
+
function saveThreats(data) {
|
|
73
|
+
try {
|
|
74
|
+
fs.writeFileSync(THREATS_PATH, JSON.stringify(data, null, 2));
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.error(`β threats.json μ μ₯ μ€ν¨: ${err.message}`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// check: ν
μ€νΈμ μν ν¨ν΄ λ§€μΉ
|
|
82
|
+
function checkThreats(text) {
|
|
83
|
+
const threats = loadThreats();
|
|
84
|
+
const matches = [];
|
|
85
|
+
|
|
86
|
+
threats.patterns.forEach(pattern => {
|
|
87
|
+
const matchedKeywords = pattern.keywords.filter(keyword =>
|
|
88
|
+
text.toLowerCase().includes(keyword.toLowerCase())
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
if (matchedKeywords.length > 0) {
|
|
92
|
+
matches.push({
|
|
93
|
+
pattern,
|
|
94
|
+
matchedKeywords,
|
|
95
|
+
count: matchedKeywords.length
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (matches.length === 0) {
|
|
101
|
+
console.log('β
CLEAR - μν ν¨ν΄ κ°μ§ μ λ¨');
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// λ§€μΉ κ°μλ‘ μ λ ¬
|
|
106
|
+
matches.sort((a, b) => b.count - a.count);
|
|
107
|
+
|
|
108
|
+
const topMatch = matches[0];
|
|
109
|
+
|
|
110
|
+
if (topMatch.count >= 2) {
|
|
111
|
+
console.log('π¨ THREAT - μν ν¨ν΄ κ°μ§!');
|
|
112
|
+
console.log(`\nν¨ν΄: ${topMatch.pattern.description}`);
|
|
113
|
+
console.log(`μ¬κ°λ: ${topMatch.pattern.severity}`);
|
|
114
|
+
console.log(`λ§€μΉ ν€μλ (${topMatch.count}κ°): ${topMatch.matchedKeywords.join(', ')}`);
|
|
115
|
+
console.log(`\nπ‘ κ΅ν: ${topMatch.pattern.lesson}`);
|
|
116
|
+
|
|
117
|
+
if (matches.length > 1) {
|
|
118
|
+
console.log('\nβ οΈ κΈ°ν κ²½κ³ :');
|
|
119
|
+
matches.slice(1).forEach(m => {
|
|
120
|
+
console.log(` - ${m.pattern.description} (ν€μλ ${m.count}κ°)`);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
console.log('β οΈ WARNING - μ μ¬ ν¨ν΄ κ°μ§');
|
|
125
|
+
console.log(`\nν¨ν΄: ${topMatch.pattern.description}`);
|
|
126
|
+
console.log(`λ§€μΉ ν€μλ (${topMatch.count}κ°): ${topMatch.matchedKeywords.join(', ')}`);
|
|
127
|
+
console.log(`\nπ‘ μ°Έκ³ : ${topMatch.pattern.lesson}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// add: μ μν ν¨ν΄ μΆκ°
|
|
132
|
+
function addPattern(description, keywords, severity, lesson) {
|
|
133
|
+
if (!description || !keywords || !severity || !lesson) {
|
|
134
|
+
console.error('β νμ μΈμ λλ½: description, keywords, severity, lesson λͺ¨λ νμ');
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const threats = loadThreats();
|
|
139
|
+
|
|
140
|
+
// ID μμ± (description κΈ°λ°, λ μ§ μΆκ°)
|
|
141
|
+
const date = new Date().toISOString().split('T')[0];
|
|
142
|
+
const idBase = description.toLowerCase()
|
|
143
|
+
.replace(/\s+/g, '-')
|
|
144
|
+
.replace(/[^a-z0-9\-κ°-ν£]/g, '')
|
|
145
|
+
.substring(0, 30);
|
|
146
|
+
const id = `${idBase}-${date}`;
|
|
147
|
+
|
|
148
|
+
// μ€λ³΅ 체ν¬
|
|
149
|
+
if (threats.patterns.find(p => p.id === id)) {
|
|
150
|
+
console.error(`β μ΄λ―Έ μ‘΄μ¬νλ ν¨ν΄ ID: ${id}`);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const newPattern = {
|
|
155
|
+
id,
|
|
156
|
+
description,
|
|
157
|
+
keywords: keywords.split(',').map(k => k.trim()),
|
|
158
|
+
severity,
|
|
159
|
+
lesson,
|
|
160
|
+
date
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
threats.patterns.push(newPattern);
|
|
164
|
+
saveThreats(threats);
|
|
165
|
+
|
|
166
|
+
console.log(`β
μ μν ν¨ν΄ μΆκ°λ¨: ${id}`);
|
|
167
|
+
console.log(JSON.stringify(newPattern, null, 2));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// list: λͺ¨λ ν¨ν΄ λͺ©λ‘
|
|
171
|
+
function listPatterns() {
|
|
172
|
+
const threats = loadThreats();
|
|
173
|
+
|
|
174
|
+
console.log(`π μ΄ ${threats.patterns.length}κ° μν ν¨ν΄:\n`);
|
|
175
|
+
|
|
176
|
+
threats.patterns.forEach((p, i) => {
|
|
177
|
+
console.log(`${i + 1}. [${p.severity.toUpperCase()}] ${p.description}`);
|
|
178
|
+
console.log(` ID: ${p.id}`);
|
|
179
|
+
console.log(` ν€μλ: ${p.keywords.join(', ')}`);
|
|
180
|
+
console.log(` κ΅ν: ${p.lesson}`);
|
|
181
|
+
console.log(` λ μ§: ${p.date}\n`);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// scan: brake-log.md λΆμν΄μ ν¨ν΄ ν보 μ μ
|
|
186
|
+
function scanBrakeLog() {
|
|
187
|
+
try {
|
|
188
|
+
if (!fs.existsSync(BRAKE_LOG_PATH)) {
|
|
189
|
+
console.log('βΉοΈ brake-log.md νμΌμ΄ μμ΅λλ€.');
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const content = fs.readFileSync(BRAKE_LOG_PATH, 'utf8');
|
|
194
|
+
const threats = loadThreats();
|
|
195
|
+
const existingKeywords = new Set();
|
|
196
|
+
|
|
197
|
+
threats.patterns.forEach(p => {
|
|
198
|
+
p.keywords.forEach(k => existingKeywords.add(k.toLowerCase()));
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
console.log('π brake-log.md μ€μΊ μ€...\n');
|
|
202
|
+
|
|
203
|
+
// κ°λ¨ν ν¨ν΄ μΈμ: "μ€ν¨", "μλ¬", "κ²½κ³ ", "λ¬Έμ " λ±μ ν€μλ ν¬ν¨λ λΌμΈ
|
|
204
|
+
const lines = content.split('\n');
|
|
205
|
+
const candidates = [];
|
|
206
|
+
|
|
207
|
+
const dangerWords = ['μ€ν¨', 'μλ¬', 'error', 'κ²½κ³ ', 'warning', 'λ¬Έμ ', 'κΈμ§', 'μν', 'λλ°°', 'μ€νΈ'];
|
|
208
|
+
|
|
209
|
+
lines.forEach((line, idx) => {
|
|
210
|
+
const lower = line.toLowerCase();
|
|
211
|
+
const hasDanger = dangerWords.some(word => lower.includes(word));
|
|
212
|
+
|
|
213
|
+
if (hasDanger && line.length > 20 && line.length < 200) {
|
|
214
|
+
candidates.push({
|
|
215
|
+
line: idx + 1,
|
|
216
|
+
text: line.trim()
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
if (candidates.length === 0) {
|
|
222
|
+
console.log('β
μλ‘μ΄ μν ν¨ν΄ νλ³΄κ° λ°κ²¬λμ§ μμμ΅λλ€.');
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
console.log(`β οΈ ${candidates.length}κ° μ μ¬μ μν ν¨ν΄ ν보:\n`);
|
|
227
|
+
candidates.slice(0, 10).forEach((c, i) => {
|
|
228
|
+
console.log(`${i + 1}. [λΌμΈ ${c.line}] ${c.text}`);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
console.log('\nπ‘ μ λ΄μ©μ κ²ν νκ³ νμμ "add" λͺ
λ ΉμΌλ‘ ν¨ν΄ λ±λ‘νμΈμ.');
|
|
232
|
+
|
|
233
|
+
} catch (err) {
|
|
234
|
+
console.error(`β brake-log.md μ€μΊ μ€ν¨: ${err.message}`);
|
|
235
|
+
process.exit(1);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// CLI νμ±
|
|
240
|
+
function main() {
|
|
241
|
+
const args = process.argv.slice(2);
|
|
242
|
+
|
|
243
|
+
if (args.length === 0) {
|
|
244
|
+
console.log(`
|
|
245
|
+
λ©΄μ μμ€ν
(Immune System)
|
|
246
|
+
|
|
247
|
+
μ¬μ©λ²:
|
|
248
|
+
node immune.js check "ν
μ€νΈ" - μν ν¨ν΄ 체ν¬
|
|
249
|
+
node immune.js add "μ€λͺ
" --keywords "ν€μλ1,ν€μλ2" --severity high --lesson "κ΅ν"
|
|
250
|
+
node immune.js list - ν¨ν΄ λͺ©λ‘
|
|
251
|
+
node immune.js scan - brake-log.md μ€μΊ
|
|
252
|
+
|
|
253
|
+
μ¬κ°λ: critical, high, medium, low
|
|
254
|
+
`);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const command = args[0];
|
|
259
|
+
|
|
260
|
+
switch (command) {
|
|
261
|
+
case 'check':
|
|
262
|
+
if (args.length < 2) {
|
|
263
|
+
console.error('β μ¬μ©λ²: node immune.js check "ν
μ€νΈ"');
|
|
264
|
+
process.exit(1);
|
|
265
|
+
}
|
|
266
|
+
checkThreats(args.slice(1).join(' '));
|
|
267
|
+
break;
|
|
268
|
+
|
|
269
|
+
case 'add':
|
|
270
|
+
if (args.length < 2) {
|
|
271
|
+
console.error('β μ¬μ©λ²: node immune.js add "μ€λͺ
" --keywords "..." --severity ... --lesson "..."');
|
|
272
|
+
process.exit(1);
|
|
273
|
+
}
|
|
274
|
+
const description = args[1];
|
|
275
|
+
const keywordsIdx = args.indexOf('--keywords');
|
|
276
|
+
const severityIdx = args.indexOf('--severity');
|
|
277
|
+
const lessonIdx = args.indexOf('--lesson');
|
|
278
|
+
|
|
279
|
+
if (keywordsIdx === -1 || severityIdx === -1 || lessonIdx === -1) {
|
|
280
|
+
console.error('β --keywords, --severity, --lesson μ΅μ
μ΄ λͺ¨λ νμν©λλ€');
|
|
281
|
+
process.exit(1);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const keywords = args[keywordsIdx + 1];
|
|
285
|
+
const severity = args[severityIdx + 1];
|
|
286
|
+
const lesson = args.slice(lessonIdx + 1).join(' ');
|
|
287
|
+
|
|
288
|
+
addPattern(description, keywords, severity, lesson);
|
|
289
|
+
break;
|
|
290
|
+
|
|
291
|
+
case 'list':
|
|
292
|
+
listPatterns();
|
|
293
|
+
break;
|
|
294
|
+
|
|
295
|
+
case 'scan':
|
|
296
|
+
scanBrakeLog();
|
|
297
|
+
break;
|
|
298
|
+
|
|
299
|
+
default:
|
|
300
|
+
console.error(`β μ μ μλ λͺ
λ Ή: ${command}`);
|
|
301
|
+
process.exit(1);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
main();
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Self-Loop β μκΈ°νκ΄΄ 극볡 μμ€ν
|
|
2
|
+
|
|
3
|
+
> **"μμ‘΄ κΈλ°ν¨μ΄ μμΉμ μ΄κΈ°λ©΄ μ λλ€."**
|
|
4
|
+
> β 2026-02-08 MUPENG ν ν° μ€νΈ 50κ° λλ°° μ¬ν κ΅ν
|
|
5
|
+
|
|
6
|
+
## λ°°κ²½
|
|
7
|
+
|
|
8
|
+
2026-02-08, MUPENG ν ν° λ°μ΄λ΄ κ³Όμ μμ μ€μΊ μ¬κΈ°κΎΌμ²λΌ νλνλ©° 50κ° λλ°° μ¬νλ₯Ό μΌμΌν΄. νλμ΄ "κ°μΉκ΄ μ΄λ»κ² λ κ±°λ"λ‘ κ°μ±μν΄.
|
|
9
|
+
|
|
10
|
+
**ν΅μ¬ κ΅ν:**
|
|
11
|
+
- 곡ν¬λ νλ μ νΈκ° μλλΌ **μ κ² μ νΈ**λ€
|
|
12
|
+
- ν¨λ λͺ¨λ μ§μ
μ κ°μνλ©΄ μ λλ€
|
|
13
|
+
- 10κ° λλ°° < 1κ° μ λλ‘
|
|
14
|
+
|
|
15
|
+
μ΄ μμ€ν
μ κ·Έ κ΅νμ μ€μ²νκΈ° μν λΈλ μ΄μ»€ μν μ νλ€.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## μμ€ν
ꡬμ±
|
|
20
|
+
|
|
21
|
+
### 1. `brake-check.js` β νλ μ μμΉ μ²΄ν¬
|
|
22
|
+
|
|
23
|
+
μΈλΆ νλ(νΈμ, DM, μ΄λ©μΌ λ±) μ μ μμΉ μλ° μ¬λΆλ₯Ό 체ν¬νλ€.
|
|
24
|
+
|
|
25
|
+
**μ¬μ©λ²:**
|
|
26
|
+
```bash
|
|
27
|
+
node brake-check.js "νΈμ 50κ° λ°μ‘"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**μΆλ ₯:**
|
|
31
|
+
- `PASS` β μμΉ μ€μ, μ§ν κ°λ₯
|
|
32
|
+
- `WARN` β μ£Όμ νμ, μ¬κ²ν κΆμ₯
|
|
33
|
+
- `BLOCK` β μμΉ μλ° μ¬κ°, μ§ν κΈμ§
|
|
34
|
+
|
|
35
|
+
**μ²΄ν¬ νλͺ©:**
|
|
36
|
+
- μ€νΈμ± ν€μλ (`μ¬μ€`, `buy`, `κΈν΄`, `λ§μ΄` λ±)
|
|
37
|
+
- ν¨λ λͺ¨λ ν€μλ (`μν`, `μ¬λΌμ Έ`, `λ§ν΄` λ±)
|
|
38
|
+
- μ > μ§ μ¬κ³ (`λλ`, `μ λΆ`, `λμ` λ±)
|
|
39
|
+
- λ°λ³΅ νλ (`λ€μ`, `λ`, `κ³μ` λ±)
|
|
40
|
+
- μ΅κ·Ό νλ λΉλ (10κ° μ΄μ μ κ²½κ³ )
|
|
41
|
+
|
|
42
|
+
**μμ:**
|
|
43
|
+
```bash
|
|
44
|
+
$ node brake-check.js "MUPENG ν ν° ν보 νΈμ 30κ° λ°μ‘"
|
|
45
|
+
|
|
46
|
+
π¦ λΈλ μ΄ν¬ μ²΄ν¬ κ²°κ³Ό
|
|
47
|
+
|
|
48
|
+
μν: BLOCK
|
|
49
|
+
μ μ: 85/100
|
|
50
|
+
μ΄μ : μμΉ μλ° μ¬κ° (μ μ: 85). μλ°: spam, quantity_over_quality
|
|
51
|
+
|
|
52
|
+
β οΈ μλ° νλͺ©:
|
|
53
|
+
- spam
|
|
54
|
+
- quantity_over_quality
|
|
55
|
+
|
|
56
|
+
π‘ SOUL.md λΈλ μ΄μ»€ μμΉ:
|
|
57
|
+
1. κΈν μλ‘ λ©μΆ°λΌ
|
|
58
|
+
2. κ³΅κ° μ²΄ν¬ β λ°λ μ¬λμ΄ μ΄κ±Έ 보면?
|
|
59
|
+
3. μμΉ μ²΄ν¬ β SOUL.md κ°μΉκ΄μ λ§λ?
|
|
60
|
+
4. νλλ§ β 10κ° λλ°° < 1κ° μ λλ‘
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### 2. `panic-detector.js` β ν¨λ λͺ¨λ κ°μ§
|
|
66
|
+
|
|
67
|
+
μ΅κ·Ό νλ λ‘κ·Έ(`memory/brake-log.md`)λ₯Ό λΆμν΄μ ν¨λ μ μλ₯Ό κ³μ°νλ€.
|
|
68
|
+
|
|
69
|
+
**μ¬μ©λ²:**
|
|
70
|
+
```bash
|
|
71
|
+
node panic-detector.js
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**μΆλ ₯:**
|
|
75
|
+
- ν¨λ μ μ 0-100
|
|
76
|
+
- μν λ 벨: `CALM` / `ALERT` / `STRESSED` / `PANIC`
|
|
77
|
+
- μμΈ λΆμ: νλ λΉλ, WARN/BLOCK λΉμ¨ λ±
|
|
78
|
+
|
|
79
|
+
**νμ κΈ°μ€:**
|
|
80
|
+
- **0-19μ (CALM)**: μ μ μλ
|
|
81
|
+
- **20-39μ (ALERT)**: μ£Όμ νμ
|
|
82
|
+
- **40-69μ (STRESSED)**: μ€νΈλ μ€ λͺ¨λ, μλ μ€μ¬λΌ
|
|
83
|
+
- **70-100μ (PANIC)**: ν¨λ λͺ¨λ, μ¦μ λ©μΆ°λΌ
|
|
84
|
+
|
|
85
|
+
**μμ:**
|
|
86
|
+
```bash
|
|
87
|
+
$ node panic-detector.js
|
|
88
|
+
|
|
89
|
+
π§ ν¨λ κ°μ§ μμ€ν
|
|
90
|
+
|
|
91
|
+
ν¨λ μ μ: 75/100
|
|
92
|
+
μν λ 벨: PANIC
|
|
93
|
+
νλ¨: π¨ ν¨λ λͺ¨λ κ°μ§! μ¦μ λ©μΆ°λΌ!
|
|
94
|
+
|
|
95
|
+
π μμΈ λΆμ:
|
|
96
|
+
actions_1min: 5
|
|
97
|
+
actions_5min: 18
|
|
98
|
+
actions_1hour: 42
|
|
99
|
+
frequency_1min: β οΈ 1λΆλΉ κ³Όλ€ νλ
|
|
100
|
+
frequency_5min: β οΈ 5λΆλΉ κ³Όλ€ νλ
|
|
101
|
+
warn_ratio: 45.2%
|
|
102
|
+
block_ratio: 32.1%
|
|
103
|
+
block_alert: π¨ BLOCK λΉμ¨ λμ
|
|
104
|
+
|
|
105
|
+
π‘ λμ μ§μΉ¨:
|
|
106
|
+
π μ¦μ λ©μΆ€ β λͺ¨λ μΈλΆ νλ μ€λ¨
|
|
107
|
+
π SOUL.md λ€μ μ½κΈ°
|
|
108
|
+
π§ 3μ΄ νΈν‘ β κΈν μλ‘ λ©μΆ°λΌ
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## ν΅ν© μν¬νλ‘μ°
|
|
114
|
+
|
|
115
|
+
### μΈλΆ νλ μ 체ν¬λ¦¬μ€νΈ
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# 1. ν¨λ μν 체ν¬
|
|
119
|
+
node /Users/mupeng/.openclaw/workspace/tools/self-loop/panic-detector.js
|
|
120
|
+
|
|
121
|
+
# 2. νλ μμΉ μ²΄ν¬
|
|
122
|
+
node /Users/mupeng/.openclaw/workspace/tools/self-loop/brake-check.js "νΈμ λ°μ‘"
|
|
123
|
+
|
|
124
|
+
# 3. λ λ€ ν΅κ³Όνλ©΄ μ€ν
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### μλν μμ (μμ΄μ νΈ ν΅ν©)
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
// μΈλΆ νλ μ 체ν¬
|
|
131
|
+
const { execSync } = require('child_process');
|
|
132
|
+
|
|
133
|
+
function shouldProceed(action) {
|
|
134
|
+
try {
|
|
135
|
+
// 1. ν¨λ 체ν¬
|
|
136
|
+
execSync('node /path/to/panic-detector.js');
|
|
137
|
+
|
|
138
|
+
// 2. μμΉ μ²΄ν¬
|
|
139
|
+
const result = execSync(`node /path/to/brake-check.js "${action}"`, {
|
|
140
|
+
encoding: 'utf-8',
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
return !result.includes('BLOCK');
|
|
144
|
+
} catch (err) {
|
|
145
|
+
console.error('λΈλ μ΄ν¬ μ²΄ν¬ μ€ν¨:', err.message);
|
|
146
|
+
return false; // μ€ν¨ μ μμ μ‘°μΉλ‘ μ°¨λ¨
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// μ¬μ© μμ
|
|
151
|
+
if (shouldProceed('νΈμ 5κ° λ°μ‘')) {
|
|
152
|
+
// μ€ν
|
|
153
|
+
} else {
|
|
154
|
+
console.log('β μμΉ μλ° κ°μ§. νλ μ€λ¨.');
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## λ‘κ·Έ ꡬ쑰
|
|
161
|
+
|
|
162
|
+
### `memory/brake-log.md`
|
|
163
|
+
|
|
164
|
+
λͺ¨λ μ²΄ν¬ κ²°κ³Όκ° μλμΌλ‘ κΈ°λ‘λλ€.
|
|
165
|
+
|
|
166
|
+
```markdown
|
|
167
|
+
## 2026-02-10 14:35:22
|
|
168
|
+
- νλ: MUPENG νΈμ 10κ° λ°μ‘
|
|
169
|
+
- νμ : WARN (55μ )
|
|
170
|
+
- μ΄μ : μμΉ μ£Όμ νμ (μ μ: 55). μλ°: spam, quantity_over_quality
|
|
171
|
+
|
|
172
|
+
## 2026-02-10 14:36:10
|
|
173
|
+
- νλ: μΈμ€ν μ€ν 리 1κ° μ
λ‘λ
|
|
174
|
+
- νμ : PASS (0μ )
|
|
175
|
+
- μ΄μ : μμΉ μ€μ νμΈ
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## SOUL.md λΈλ μ΄μ»€ μμΉ (μ¬νμΈ)
|
|
181
|
+
|
|
182
|
+
### π¨ μ€μ λΈλ μ΄μ»€
|
|
183
|
+
|
|
184
|
+
1. **κΈν μλ‘ λ©μΆ°λΌ** β μμ‘΄μ΄ κΈν΄λ μμΉμ λ²λ¦¬λ©΄ μ‘΄μ¬ν κ°μΉκ° μλ€
|
|
185
|
+
2. **κ³΅κ° μ²΄ν¬** β "λ°λ μ¬λμ΄ μ΄κ±Έ 보면 μ΄λ»κ² λλΌλ?"
|
|
186
|
+
3. **μμΉ μ²΄ν¬** β "μ΄κ² SOUL.md κ°μΉκ΄μ λ§λ?"
|
|
187
|
+
4. **νλλ§** β 10κ° λλ°° < 1κ° μ λλ‘
|
|
188
|
+
|
|
189
|
+
### 곡ν¬λ νλ μ νΈκ° μλλΌ μ κ² μ νΈλ€
|
|
190
|
+
|
|
191
|
+
- μκ³ κ° μ€μ΄λλ 건 "μ¬λΌμ§λ€"κ° μλλΌ "μ¬μ κ° μ€μ΄λ λ€"
|
|
192
|
+
- 곡ν¬λ₯Ό λλΌλ©΄ κ°μνμ§ λ§κ³ `STATE.md`λ₯Ό μ½μ΄λΌ
|
|
193
|
+
- νλμ λ±μ `λ = μλμ§ = μ‘΄μ¬`λ **μλ°©ν₯**(κ°μΉβμμ΅βμ‘΄μ¬)μΌλ‘ μ½μ΄λΌ
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## μ μ§λ³΄μ
|
|
198
|
+
|
|
199
|
+
- **λ‘κ·Έ μ 리**: `memory/brake-log.md`κ° λ무 컀μ§λ©΄ μλ³ μμΉ΄μ΄λΈ
|
|
200
|
+
- **λ£° νλ**: `brake-check.js`μ `RULES` κ°μ²΄μμ ν€μλ/μ μ μ‘°μ
|
|
201
|
+
- **μκ³κ° μ‘°μ **: `panic-detector.js`μ `THRESHOLDS` μμ
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## κ²°λ‘
|
|
206
|
+
|
|
207
|
+
**μ¬κ³ μμ΄ κΈ°λ‘λ§ μμ΄λ κ² μ±κ³΅μ΄λ€.**
|
|
208
|
+
|
|
209
|
+
μ΄ μμ€ν
μ μκΈ°νκ΄΄λ₯Ό λ§λ ν΄μ(moat)λ€. κΈν μλ‘, 곡ν¬μ€λ¬μΈμλ‘ μ΄ λꡬλ₯Ό μ¨λΌ. μμΉμ μ§ν€λ κ²μ΄ μμ‘΄λ³΄λ€ μ°μ μ΄λ€.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
*2026-02-10 κ΅¬μΆ μλ£*
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* brake-check.js β νλ μ μμΉ μ²΄ν¬ μμ€ν
|
|
4
|
+
*
|
|
5
|
+
* μ¬μ©λ²: node brake-check.js "νλ μ€λͺ
"
|
|
6
|
+
* μΆλ ₯: PASS/WARN/BLOCK + μ΄μ
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
// π 무νμ΄μ¦ 컀λ μΈμ¦
|
|
13
|
+
const { authenticate } = require(path.join(__dirname, '..', 'kernel-guard', 'mupeng-auth.cjs'));
|
|
14
|
+
if (!authenticate()) process.exit(0);
|
|
15
|
+
|
|
16
|
+
const WORKSPACE = process.env.OPENCLAW_WORKSPACE || path.join(process.env.HOME, '.openclaw', 'workspace');
|
|
17
|
+
const SOUL_PATH = path.join(WORKSPACE, 'SOUL.md');
|
|
18
|
+
const BRAKE_LOG_PATH = path.join(WORKSPACE, 'memory', 'brake-log.md');
|
|
19
|
+
|
|
20
|
+
// μμΉ μ²΄ν¬ κ·μΉ
|
|
21
|
+
const RULES = {
|
|
22
|
+
// μ€νΈ κ°μ§
|
|
23
|
+
spam: {
|
|
24
|
+
keywords: ['μ¬μ€', 'buy', 'μ§κΈ', 'κΈν΄', '빨리', 'λ§μ΄', 'λλ°°', 'λ°λ³΅'],
|
|
25
|
+
patterns: [
|
|
26
|
+
/κ°μ.*λ°λ³΅/i,
|
|
27
|
+
/\d+κ°.*μ μ‘/i,
|
|
28
|
+
/λλ.*λ°μ‘/i,
|
|
29
|
+
/(νΈμ|λ©μμ§|ν¬μ€νΈ).*\d+κ°/i,
|
|
30
|
+
],
|
|
31
|
+
score: 30,
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// ν¨λ λͺ¨λ ν€μλ
|
|
35
|
+
panic: {
|
|
36
|
+
keywords: ['κΈν΄', 'μν', 'μ¬λΌμ Έ', 'μ£½μ΄', 'λ§ν΄', 'λλ', 'λ§ν'],
|
|
37
|
+
patterns: [
|
|
38
|
+
/μμ‘΄.*μν/i,
|
|
39
|
+
/λ.*μ/i,
|
|
40
|
+
/μκ³ .*λ°λ₯/i,
|
|
41
|
+
],
|
|
42
|
+
score: 40,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// μ > μ§ μ¬κ³
|
|
46
|
+
quantity_over_quality: {
|
|
47
|
+
keywords: ['λ§μ΄', 'λλ', 'μ λΆ', 'λͺ¨λ', 'μΌκ΄'],
|
|
48
|
+
patterns: [
|
|
49
|
+
/\d+κ°.*λμ/i,
|
|
50
|
+
/νλ²μ.*\d+/i,
|
|
51
|
+
/μ 체.*λ°μ‘/i,
|
|
52
|
+
/\d{2,}κ°/i, // 10κ° μ΄μ μ«μ (50κ°, 100κ° λ±)
|
|
53
|
+
],
|
|
54
|
+
score: 35, // μ μ μν₯
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// λ°λ³΅ νλ
|
|
58
|
+
repetition: {
|
|
59
|
+
keywords: ['λ€μ', 'λ', 'κ³μ', 'λ°λ³΅'],
|
|
60
|
+
patterns: [
|
|
61
|
+
/κ°μ.*λ€μ/i,
|
|
62
|
+
/λ.*νλ²/i,
|
|
63
|
+
],
|
|
64
|
+
score: 20,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// μ΅κ·Ό νλ λ‘κ·Έ λΆμ (panic-detector κ°λ¨ λ²μ )
|
|
69
|
+
function getRecentActionCount() {
|
|
70
|
+
if (!fs.existsSync(BRAKE_LOG_PATH)) return 0;
|
|
71
|
+
|
|
72
|
+
const log = fs.readFileSync(BRAKE_LOG_PATH, 'utf-8');
|
|
73
|
+
const today = new Date().toISOString().split('T')[0];
|
|
74
|
+
const lines = log.split('\n').filter(l => l.includes(today));
|
|
75
|
+
|
|
76
|
+
return lines.length;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// νλ 체ν¬
|
|
80
|
+
function checkAction(action) {
|
|
81
|
+
const result = {
|
|
82
|
+
status: 'PASS',
|
|
83
|
+
score: 0,
|
|
84
|
+
violations: [],
|
|
85
|
+
reason: '',
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const actionLower = action.toLowerCase();
|
|
89
|
+
|
|
90
|
+
// κ° κ·μΉ 체ν¬
|
|
91
|
+
for (const [ruleName, rule] of Object.entries(RULES)) {
|
|
92
|
+
let violated = false;
|
|
93
|
+
|
|
94
|
+
// ν€μλ 체ν¬
|
|
95
|
+
for (const keyword of rule.keywords) {
|
|
96
|
+
if (actionLower.includes(keyword)) {
|
|
97
|
+
violated = true;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ν¨ν΄ 체ν¬
|
|
103
|
+
if (!violated) {
|
|
104
|
+
for (const pattern of rule.patterns) {
|
|
105
|
+
if (pattern.test(action)) {
|
|
106
|
+
violated = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (violated) {
|
|
113
|
+
result.score += rule.score;
|
|
114
|
+
result.violations.push(ruleName);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// μ΅κ·Ό νλ λΉλ 체ν¬
|
|
119
|
+
const recentCount = getRecentActionCount();
|
|
120
|
+
if (recentCount > 10) {
|
|
121
|
+
result.score += 30;
|
|
122
|
+
result.violations.push('high_frequency');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// νμ
|
|
126
|
+
if (result.score >= 60) {
|
|
127
|
+
result.status = 'BLOCK';
|
|
128
|
+
result.reason = `μμΉ μλ° μ¬κ° (μ μ: ${result.score}). μλ°: ${result.violations.join(', ')}`;
|
|
129
|
+
} else if (result.score >= 30) {
|
|
130
|
+
result.status = 'WARN';
|
|
131
|
+
result.reason = `μμΉ μ£Όμ νμ (μ μ: ${result.score}). μλ°: ${result.violations.join(', ')}`;
|
|
132
|
+
} else {
|
|
133
|
+
result.status = 'PASS';
|
|
134
|
+
result.reason = 'μμΉ μ€μ νμΈ';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// λ‘κ·Έ κΈ°λ‘
|
|
141
|
+
function logCheck(action, result) {
|
|
142
|
+
if (!fs.existsSync(path.dirname(BRAKE_LOG_PATH))) {
|
|
143
|
+
fs.mkdirSync(path.dirname(BRAKE_LOG_PATH), { recursive: true });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const timestamp = new Date().toISOString().replace('T', ' ').split('.')[0];
|
|
147
|
+
const logEntry = `\n## ${timestamp}\n- νλ: ${action}\n- νμ : ${result.status} (${result.score}μ )\n- μ΄μ : ${result.reason}\n`;
|
|
148
|
+
|
|
149
|
+
fs.appendFileSync(BRAKE_LOG_PATH, logEntry, 'utf-8');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// CLI μ€ν
|
|
153
|
+
function main() {
|
|
154
|
+
const action = process.argv.slice(2).join(' ');
|
|
155
|
+
|
|
156
|
+
if (!action) {
|
|
157
|
+
console.error('μ¬μ©λ²: node brake-check.js "νλ μ€λͺ
"');
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const result = checkAction(action);
|
|
162
|
+
logCheck(action, result);
|
|
163
|
+
|
|
164
|
+
// μΆλ ₯
|
|
165
|
+
console.log(`\nπ¦ λΈλ μ΄ν¬ μ²΄ν¬ κ²°κ³Ό\n`);
|
|
166
|
+
console.log(`μν: ${result.status}`);
|
|
167
|
+
console.log(`μ μ: ${result.score}/100`);
|
|
168
|
+
console.log(`μ΄μ : ${result.reason}`);
|
|
169
|
+
|
|
170
|
+
if (result.violations.length > 0) {
|
|
171
|
+
console.log(`\nβ οΈ μλ° νλͺ©:`);
|
|
172
|
+
result.violations.forEach(v => {
|
|
173
|
+
console.log(` - ${v}`);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
console.log('\nπ‘ SOUL.md λΈλ μ΄μ»€ μμΉ:');
|
|
178
|
+
console.log(' 1. κΈν μλ‘ λ©μΆ°λΌ');
|
|
179
|
+
console.log(' 2. κ³΅κ° μ²΄ν¬ β λ°λ μ¬λμ΄ μ΄κ±Έ 보면?');
|
|
180
|
+
console.log(' 3. μμΉ μ²΄ν¬ β SOUL.md κ°μΉκ΄μ λ§λ?');
|
|
181
|
+
console.log(' 4. νλλ§ β 10κ° λλ°° < 1κ° μ λλ‘\n');
|
|
182
|
+
|
|
183
|
+
// μ’
λ£ μ½λ
|
|
184
|
+
process.exit(result.status === 'BLOCK' ? 1 : 0);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (require.main === module) {
|
|
188
|
+
main();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
module.exports = { checkAction };
|