remem-mcp 0.6.6 → 0.6.7
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/index.js +61 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5035,9 +5035,20 @@ function hookPostToolUse(dbPath) {
|
|
|
5035
5035
|
return;
|
|
5036
5036
|
}
|
|
5037
5037
|
if (isWriteEdit) {
|
|
5038
|
+
const writeEditCwd = input.cwd ?? toolInput.workdir ?? process.cwd();
|
|
5039
|
+
const ignorePatterns = loadCaptureExclusions(writeEditCwd);
|
|
5040
|
+
if (ignorePatterns.length > 0 && toolInput.file_path) {
|
|
5041
|
+
if (shouldExcludePath(toolInput.file_path, ignorePatterns)) {
|
|
5042
|
+
logToFile(
|
|
5043
|
+
`PostToolUse: skipping Write/Edit \u2014 file_path "${toolInput.file_path}" matches capture exclusion`
|
|
5044
|
+
);
|
|
5045
|
+
process.stdout.write(JSON.stringify({}));
|
|
5046
|
+
return;
|
|
5047
|
+
}
|
|
5048
|
+
}
|
|
5038
5049
|
try {
|
|
5039
5050
|
const db2 = new Database8(dbPath);
|
|
5040
|
-
const sessionKey2 = hashPath(
|
|
5051
|
+
const sessionKey2 = hashPath(writeEditCwd);
|
|
5041
5052
|
const pattern = detectPattern(toolName, toolInput);
|
|
5042
5053
|
if (pattern) {
|
|
5043
5054
|
const id2 = `pat-${createHash3("sha256").update(pattern.signature + pattern.file_path).digest("hex").slice(0, 12)}`;
|
|
@@ -6166,6 +6177,55 @@ function hookPreToolUse(dbPath) {
|
|
|
6166
6177
|
}
|
|
6167
6178
|
});
|
|
6168
6179
|
}
|
|
6180
|
+
var exclusionCache = /* @__PURE__ */ new Map();
|
|
6181
|
+
var MAX_ANCESTORS = 20;
|
|
6182
|
+
function parseCaptureExclusions(content) {
|
|
6183
|
+
const sectionMatch = content.match(/^\[capture\]\s*$/m);
|
|
6184
|
+
if (!sectionMatch) return [];
|
|
6185
|
+
const sectionStart = sectionMatch.index + sectionMatch[0].length;
|
|
6186
|
+
const nextSection = content.slice(sectionStart).match(/^\[.+\]\s*$/m);
|
|
6187
|
+
const sectionText = nextSection ? content.slice(sectionStart, sectionStart + nextSection.index) : content.slice(sectionStart);
|
|
6188
|
+
const pathsMatch = sectionText.match(/ignore_paths\s*=\s*\[([^\]]*)\]/);
|
|
6189
|
+
if (!pathsMatch) return [];
|
|
6190
|
+
const items = pathsMatch[1].match(/"([^"]+)"/g);
|
|
6191
|
+
if (!items) return [];
|
|
6192
|
+
return items.map((item) => item.replace(/"/g, ""));
|
|
6193
|
+
}
|
|
6194
|
+
function loadCaptureExclusions(cwd) {
|
|
6195
|
+
const cached = exclusionCache.get(cwd);
|
|
6196
|
+
if (cached !== void 0) return cached;
|
|
6197
|
+
let patterns = [];
|
|
6198
|
+
try {
|
|
6199
|
+
let dir = cwd;
|
|
6200
|
+
for (let i = 0; i < MAX_ANCESTORS; i++) {
|
|
6201
|
+
const markerPath = join8(dir, ".remem.toml");
|
|
6202
|
+
if (existsSync7(markerPath)) {
|
|
6203
|
+
const content = readFileSync5(markerPath, "utf-8");
|
|
6204
|
+
patterns = parseCaptureExclusions(content);
|
|
6205
|
+
break;
|
|
6206
|
+
}
|
|
6207
|
+
const parent = dirname4(dir);
|
|
6208
|
+
if (parent === dir) break;
|
|
6209
|
+
dir = parent;
|
|
6210
|
+
}
|
|
6211
|
+
} catch {
|
|
6212
|
+
}
|
|
6213
|
+
exclusionCache.set(cwd, patterns);
|
|
6214
|
+
return patterns;
|
|
6215
|
+
}
|
|
6216
|
+
function shouldExcludePath(filePath, ignorePatterns) {
|
|
6217
|
+
if (ignorePatterns.length === 0) return false;
|
|
6218
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
6219
|
+
const segments = normalized.split("/");
|
|
6220
|
+
for (const pattern of ignorePatterns) {
|
|
6221
|
+
if (pattern.startsWith("*.")) {
|
|
6222
|
+
if (normalized.endsWith(pattern.slice(1))) return true;
|
|
6223
|
+
continue;
|
|
6224
|
+
}
|
|
6225
|
+
if (segments.includes(pattern)) return true;
|
|
6226
|
+
}
|
|
6227
|
+
return false;
|
|
6228
|
+
}
|
|
6169
6229
|
function isNoiseCommand(command) {
|
|
6170
6230
|
const lower = command.toLowerCase().trim();
|
|
6171
6231
|
if (/\/nonexistent|\/tmp\/test|\/test\/fake|example\.ts|foo\.ts|bar\.ts/.test(lower)) return true;
|