remem-mcp 0.6.5 → 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 +68 -7
- 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;
|
|
@@ -7406,6 +7466,7 @@ Hooks removed from ${removed} agent(s).`);
|
|
|
7406
7466
|
|
|
7407
7467
|
// src/import.ts
|
|
7408
7468
|
init_esm_shims();
|
|
7469
|
+
init_ulid();
|
|
7409
7470
|
import { existsSync as existsSync9, readFileSync as readFileSync7 } from "fs";
|
|
7410
7471
|
import { dirname as dirname6, join as join10 } from "path";
|
|
7411
7472
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
@@ -7467,15 +7528,15 @@ function importData(dbPath, inputPath) {
|
|
|
7467
7528
|
const transaction = db.transaction(() => {
|
|
7468
7529
|
for (const row of data.captures) {
|
|
7469
7530
|
const result = insertStmt.run(
|
|
7470
|
-
row.id,
|
|
7471
|
-
row.session_key,
|
|
7472
|
-
row.agent_id,
|
|
7531
|
+
row.id ?? generateId(),
|
|
7532
|
+
row.session_key ?? "import",
|
|
7533
|
+
row.agent_id ?? "import",
|
|
7473
7534
|
row.type,
|
|
7474
7535
|
row.content,
|
|
7475
7536
|
row.content_hash ?? null,
|
|
7476
|
-
row.tags,
|
|
7477
|
-
row.created_at,
|
|
7478
|
-
row.metadata,
|
|
7537
|
+
Array.isArray(row.tags) ? JSON.stringify(row.tags) : row.tags ?? null,
|
|
7538
|
+
row.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
7539
|
+
row.metadata ?? null,
|
|
7479
7540
|
row.team_id ?? null,
|
|
7480
7541
|
row.user_id ?? null,
|
|
7481
7542
|
row.task_id ?? null
|