memory-bank-skill 7.4.1 → 7.4.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/dist/cli.js +1 -1
- package/dist/plugin.js +57 -22
- package/package.json +1 -1
- package/skills/memory-bank/references/writer.md +27 -0
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ import { fileURLToPath } from "url";
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "memory-bank-skill",
|
|
14
|
-
version: "7.4.
|
|
14
|
+
version: "7.4.2",
|
|
15
15
|
description: "Memory Bank - \u9879\u76EE\u8BB0\u5FC6\u7CFB\u7EDF\uFF0C\u8BA9 AI \u52A9\u624B\u5728\u6BCF\u6B21\u5BF9\u8BDD\u4E2D\u90FD\u80FD\u5FEB\u901F\u7406\u89E3\u9879\u76EE\u4E0A\u4E0B\u6587",
|
|
16
16
|
type: "module",
|
|
17
17
|
main: "dist/plugin.js",
|
package/dist/plugin.js
CHANGED
|
@@ -3,6 +3,7 @@ var __require = import.meta.require;
|
|
|
3
3
|
|
|
4
4
|
// plugin/memory-bank.ts
|
|
5
5
|
import { stat, readFile, access, realpath } from "fs/promises";
|
|
6
|
+
import { realpathSync } from "fs";
|
|
6
7
|
import { execSync } from "child_process";
|
|
7
8
|
import path from "path";
|
|
8
9
|
var DEBUG = process.env.MEMORY_BANK_DEBUG === "1";
|
|
@@ -382,12 +383,63 @@ var FALLBACK_ANCHORS = [
|
|
|
382
383
|
];
|
|
383
384
|
function canonicalizeRelPath(rawPath, projectRoot) {
|
|
384
385
|
const abs = path.isAbsolute(rawPath) ? rawPath : path.resolve(projectRoot, rawPath);
|
|
385
|
-
|
|
386
|
-
if (rel.startsWith(".."))
|
|
387
|
-
|
|
386
|
+
let rel = path.relative(projectRoot, abs);
|
|
387
|
+
if (rel.startsWith("..")) {
|
|
388
|
+
try {
|
|
389
|
+
const realAbs = realpathSync(abs);
|
|
390
|
+
const realRoot = realpathSync(projectRoot);
|
|
391
|
+
rel = path.relative(realRoot, realAbs);
|
|
392
|
+
if (rel.startsWith(".."))
|
|
393
|
+
return "";
|
|
394
|
+
} catch {
|
|
395
|
+
return "";
|
|
396
|
+
}
|
|
397
|
+
}
|
|
388
398
|
const posix = rel.replace(/\\/g, "/");
|
|
389
399
|
return process.platform === "darwin" || process.platform === "win32" ? posix.toLowerCase() : posix;
|
|
390
400
|
}
|
|
401
|
+
function stripQuotedContent(cmd) {
|
|
402
|
+
let result = "";
|
|
403
|
+
let inSingle = false;
|
|
404
|
+
let inDouble = false;
|
|
405
|
+
for (let i = 0;i < cmd.length; i++) {
|
|
406
|
+
const ch = cmd[i];
|
|
407
|
+
if (inSingle) {
|
|
408
|
+
if (ch === "'")
|
|
409
|
+
inSingle = false;
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
if (inDouble) {
|
|
413
|
+
if (ch === "\\" && i + 1 < cmd.length) {
|
|
414
|
+
i++;
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (ch === '"')
|
|
418
|
+
inDouble = false;
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
if (ch === "'") {
|
|
422
|
+
inSingle = true;
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
if (ch === '"') {
|
|
426
|
+
inDouble = true;
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
result += ch;
|
|
430
|
+
}
|
|
431
|
+
return result;
|
|
432
|
+
}
|
|
433
|
+
var BASH_REDIRECT_PATTERNS = [
|
|
434
|
+
/(?<![0-9&])>(?![&>])\s*\S/,
|
|
435
|
+
/(?<![0-9&])>>\s*\S/,
|
|
436
|
+
/\|\s*tee\s/,
|
|
437
|
+
/\bsed\s+(-[^-]*)?-i/,
|
|
438
|
+
/\bperl\s+(-[^-]*)?-[pi]/
|
|
439
|
+
];
|
|
440
|
+
function hasBashRedirectOutsideQuotes(cmd) {
|
|
441
|
+
return BASH_REDIRECT_PATTERNS.some((p) => p.test(stripQuotedContent(cmd)));
|
|
442
|
+
}
|
|
391
443
|
function isAnchorPath(canonicalPath) {
|
|
392
444
|
return ANCHOR_PATH_PATTERNS.some((p) => p.test(canonicalPath));
|
|
393
445
|
}
|
|
@@ -1045,17 +1097,7 @@ ${triggers.join(`
|
|
|
1045
1097
|
if (anchorState.recovery?.required) {
|
|
1046
1098
|
const writeToolsForRecovery = ["write", "edit", "multiedit", "apply_patch", "patch"];
|
|
1047
1099
|
const isWriteTool = writeToolsForRecovery.includes(toolLowerForRecovery);
|
|
1048
|
-
const isBashWrite = toolLowerForRecovery === "bash" && (
|
|
1049
|
-
const cmd = output.args?.command || "";
|
|
1050
|
-
const bashWritePatterns = [
|
|
1051
|
-
/(?<![0-9&])>(?![&>])\s*\S/,
|
|
1052
|
-
/(?<![0-9&])>>\s*\S/,
|
|
1053
|
-
/\|\s*tee\s/,
|
|
1054
|
-
/\bsed\s+(-[^-]*)?-i/,
|
|
1055
|
-
/\bperl\s+(-[^-]*)?-[pi]/
|
|
1056
|
-
];
|
|
1057
|
-
return bashWritePatterns.some((p) => p.test(cmd));
|
|
1058
|
-
})();
|
|
1100
|
+
const isBashWrite = toolLowerForRecovery === "bash" && hasBashRedirectOutsideQuotes(output.args?.command || "");
|
|
1059
1101
|
if (isWriteTool || isBashWrite) {
|
|
1060
1102
|
const riskLevel = isWriteTool ? assessWriteRisk(toolLowerForRecovery, output.args || {}, projectRoot) : "medium";
|
|
1061
1103
|
if (riskLevel !== "low") {
|
|
@@ -1213,13 +1255,6 @@ Or call: proxy_task({ subagent_type: "memory-reader", ... })`);
|
|
|
1213
1255
|
}
|
|
1214
1256
|
if (toolLower2 === "bash" && !gatingState.contextSatisfied) {
|
|
1215
1257
|
const command = output.args?.command || "";
|
|
1216
|
-
const bashWritePatterns = [
|
|
1217
|
-
/(?<![0-9&])>(?![&>])\s*\S/,
|
|
1218
|
-
/(?<![0-9&])>>\s*\S/,
|
|
1219
|
-
/\|\s*tee\s/,
|
|
1220
|
-
/\bsed\s+(-[^-]*)?-i/,
|
|
1221
|
-
/\bperl\s+(-[^-]*)?-[pi]/
|
|
1222
|
-
];
|
|
1223
1258
|
const bashSensitivePatterns = [
|
|
1224
1259
|
/package\.json/i,
|
|
1225
1260
|
/\.env/i,
|
|
@@ -1231,7 +1266,7 @@ Or call: proxy_task({ subagent_type: "memory-reader", ... })`);
|
|
|
1231
1266
|
/\.github\/workflows/i,
|
|
1232
1267
|
/infra\//i
|
|
1233
1268
|
];
|
|
1234
|
-
const isLikelyWrite =
|
|
1269
|
+
const isLikelyWrite = hasBashRedirectOutsideQuotes(command);
|
|
1235
1270
|
const isSensitiveTarget = bashSensitivePatterns.some((p) => p.test(command));
|
|
1236
1271
|
if (isLikelyWrite) {
|
|
1237
1272
|
const riskLevel = isSensitiveTarget ? "high" : "medium";
|
package/package.json
CHANGED
|
@@ -284,6 +284,33 @@ USER_BLOCK 将保持不变。
|
|
|
284
284
|
| Decision Highlights | 新增决策时追加(保持 10-20 条以内) |
|
|
285
285
|
| Routing Rules | 仅在 details/ 结构变化时更新 |
|
|
286
286
|
|
|
287
|
+
### MEMORY.md 膨胀控制
|
|
288
|
+
|
|
289
|
+
MEMORY.md 是单入口索引,必须保持精简。按行数控制膨胀:
|
|
290
|
+
|
|
291
|
+
| 行数 | 动作 |
|
|
292
|
+
|------|------|
|
|
293
|
+
| ≤ 120 行 | 正常维护 |
|
|
294
|
+
| 120 - 200 行 | 审查:Decision Highlights 超 15 条归档旧条目到 details/patterns.md,Quick Answers 超 8 条删过期项 |
|
|
295
|
+
| > 200 行 | 强制分区:膨胀区块提取到 details/,MEMORY.md 只留摘要 + 指针 |
|
|
296
|
+
|
|
297
|
+
**分区操作**(> 200 行时):
|
|
298
|
+
|
|
299
|
+
```
|
|
300
|
+
1. 识别膨胀区块(通常是 Decision Highlights 或 Routing Rules)
|
|
301
|
+
2. 提取到 details/:
|
|
302
|
+
- Decision Highlights 旧条目 → details/patterns.md
|
|
303
|
+
- Routing Rules 过多 → details/routing-extended.md
|
|
304
|
+
- Quick Answers 过多 → details/faq.md
|
|
305
|
+
3. MEMORY.md 保留:
|
|
306
|
+
- 最近 5-8 条 Decision Highlights
|
|
307
|
+
- 核心 Routing Rules(通用 + 高频项目特定)
|
|
308
|
+
- 3-5 条最高频 Quick Answers
|
|
309
|
+
4. 添加指针:「完整历史见 details/patterns.md」
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**原则**:MEMORY.md 是路由器不是数据库,超过一屏能扫完的量就该分区。
|
|
313
|
+
|
|
287
314
|
### 详情文件写入
|
|
288
315
|
|
|
289
316
|
```
|